Flow123d
release_3.0.0-968-gc87a28e79
|
Go to the documentation of this file.
40 template <
int spacedim,
class Value>
47 "Input file with ASCII GMSH file format.")
49 "The values of the Field are read from the ```$ElementData``` section with field name given by this key.")
53 "Allow set default value of elements that have not listed values in mesh data file.")
55 "Definition of unit of all times defined in mesh data file.")
57 "Allow set time shift of field data read from the mesh data file. For time 't', field descriptor with time 'T', "
58 "time shift 'S' and if 't > T', we read time frame 't + S'.")
64 template <
int spacedim,
class Value>
66 Input::register_class< FieldInterpolatedP0<spacedim, Value>,
unsigned int >(
"FieldInterpolatedP0") +
70 template <
int spacedim,
class Value>
79 template <
int spacedim,
class Value>
81 this->init_unit_conversion_coefficient(rec, init_data);
93 bih_tree_->add_boxes( source_mesh_->get_element_boxes() );
94 bih_tree_->construct();
97 unsigned int data_size = source_mesh_->n_elements() * (this->value_.n_rows() * this->value_.n_cols());
98 data_ = std::make_shared<std::vector<typename Value::element_type>>();
99 data_->resize(data_size);
101 field_name_ = rec.
val<std::string>(
"field_name");
102 if (!rec.
opt_val(
"default_value", default_value_) ) {
103 default_value_ = numeric_limits<double>::signaling_NaN();
110 template <
int spacedim,
class Value>
112 OLD_ASSERT(source_mesh_,
"Null mesh pointer of elementwise field: %s, did you call init_from_input(Input::Record)?\n", field_name_.c_str());
113 if ( reader_file_ ==
FilePath() )
return false;
120 computed_elm_idx_ = numeric_limits<unsigned int>::max();
122 bool boundary_domain_ =
false;
123 double time_unit_coef = time.
read_coef(in_rec_.find<
string>(
"time_unit"));
125 double read_time = (time.
end()+time_shift) / time_unit_coef;
129 source_mesh_->n_elements(), this->value_.n_rows() * this->value_.n_cols(), boundary_domain_, this->component_idx_);
131 this->unit_conversion_coefficient_, default_value_);
134 THROW( ExcUndefElementValue() << EI_Field(field_name_) );
142 template <
int spacedim,
class Value>
146 if (elm.
idx() != computed_elm_idx_ || elm.
is_boundary() != computed_elm_boundary_) {
147 computed_elm_idx_ = elm.
idx();
150 if (elm.
dim() == 3) {
151 xprintf(
Err,
"Dimension of element in target mesh must be 0, 1 or 2! elm.idx() = %d\n", elm.
idx());
154 double epsilon = 4* numeric_limits<double>::epsilon() * elm.
measure();
157 if (elm.
dim() == 0) {
158 searched_elements_.clear();
159 ((
BIHTree *)bih_tree_)->find_point(elm.
node(0)->
point(), searched_elements_);
162 searched_elements_.clear();
163 ((
BIHTree *)bih_tree_)->find_bounding_box(bb, searched_elements_);
167 for (
unsigned int i=0; i < this->value_.n_rows(); i++) {
168 for (
unsigned int j=0; j < this->value_.n_cols(); j++) {
169 this->value_(i,j) = 0.0;
173 double total_measure=0.0, measure;
184 if (ele->
dim() == 3) {
188 arma::vec::fixed<3> real_point = elm.
node(0)->
point();
189 arma::mat::fixed<3, 4> elm_map = mapping.
element_map(ele);
192 measure = (std::fabs(arma::sum( unit_point )-1) <= 1e-14
193 && arma::min( unit_point ) >= 0)
220 if (measure > epsilon) {
221 unsigned int index = this->value_.n_rows() * this->value_.n_cols() * (*it);
223 typename Value::return_type & ret_type_value =
const_cast<typename Value::return_type &
>( Value::from_raw(this->r_value_, (
typename Value::element_type *)(&vec[index])) );
226 for (
unsigned int i=0; i < this->value_.n_rows(); i++) {
227 for (
unsigned int j=0; j < this->value_.n_cols(); j++) {
228 this->value_(i,j) += tmp_value(i,j) * measure;
231 total_measure += measure;
237 if (total_measure > epsilon) {
238 for (
unsigned int i=0; i < this->value_.n_rows(); i++) {
239 for (
unsigned int j=0; j < this->value_.n_cols(); j++) {
240 this->value_(i,j) /= total_measure;
244 WarningOut().fmt(
"Processed element with idx {} is out of source mesh!\n", elm.
idx());
249 return this->r_value_;
254 template <
int spacedim,
class Value>
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Class for 2D-2D intersections.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
double compute_measure() const override
Computes the relative measure of intersection object.
Dedicated class for storing path to input and output files.
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
Class for O(log N) lookup for intersections with a set of bounding boxes.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
bool is_constant_in_space_
Flag detects that field is only dependent on time.
const Node * node(unsigned int ni) const
virtual const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm)
bool is_elemental() const
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
Space< spacedim >::Point Point
static const Input::Type::Record & get_input_type()
Bounding box in 3d ambient space.
void init()
Initializes lower dimensional objects. Sets correctly the pointers to Plucker coordinates and product...
bool set_time(const TimeStep &time) override
bool is_boundary() const
We need this method after replacing Region by RegionIdx, and movinf RegionDB instance into particular...
BoundingBox bounding_box() const
BaryPoint project_real_to_unit(const RealPoint &point, const ElementMap &map) const
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
Representation of one time step..
CheckResult
Return type of method that checked data stored in ElementDataCache (NaN values, limits)
ElementMap element_map(ElementAccessor< 3 > elm) const
void init()
Initializes lower dimensional objects. Sets correctly the pointers to Plucker coordinates and product...
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)=0
unsigned int compute(std::vector< IPAux > &IP13s)
Computes intersection points for 1D-3D intersection. Computes lower dimensional CIs abscissa vs tetra...
@ not_a_number
Some value(s) is set to NaN.
Internal class representing intersection object.
#define WarningOut()
Macro defining 'warning' record of log.
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
#define INSTANCE_ALL(field)
static bool check_compatible_mesh(const FilePath &file_path, Mesh &mesh)
Fundamental simplicial intersections.
static std::shared_ptr< Mesh > get_mesh(const FilePath &file_path)
#define ADD_CALLS(n_calls)
Increase number of calls in actual timer.
unsigned int idx() const
Return local idx of element in boundary / bulk part of element vector.
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell.
static std::shared_ptr< BaseMeshReader > get_reader(const FilePath &file_path)
static const Input::Type::Tuple & get_input_time_type(double lower_bound=-std::numeric_limits< double >::max(), double upper_bound=std::numeric_limits< double >::max())
FieldInterpolatedP0(unsigned int n_comp=0)
#define START_TIMER(tag)
Starts a timer with specified tag.
void compute(IntersectionAux< 2, 3 > &intersection)
Computes intersection points for 2D-3D intersection. Computes lower dimensional CIs: 1) 3x triangle s...
double measure() const
Computes the measure of the element.
#define END_TIMER(tag)
Ends a timer with specified tag.
double read_coef(Input::Iterator< std::string > unit_it) const
Classes with algorithms for computation of intersections of meshes.