54 template <
int spacedim, class
Value>
61 "GMSH mesh with data. Can be different from actual computational mesh.")
63 "Section where to find the field.\n Some sections are specific to file format: " 64 "point_data/node_data, cell_data/element_data, -/element_node_data, native/-.\n" 65 "If not given by a user, we try to find the field in all sections, but we report an error " 66 "if it is found in more than one section.")
68 "The values of the Field are read from the ```$ElementData``` section with field name given by this key.")
70 "Default value is set on elements which values have not been listed in the mesh data file.")
72 "Definition of the unit of all times defined in the mesh data file.")
74 "This key allows reading field data from the mesh data file shifted in time. Considering the time 't', field descriptor with time 'T', " 75 "time shift 'S', then if 't > T', we read the time frame 't + S'.")
77 IT::Default(
"\"equivalent_mesh\""),
"Type of interpolation applied to the input spatial data.\n" 78 "The default value 'equivalent_mesh' assumes the data being constant on elements living on the same mesh " 79 "as the computational mesh, but possibly with different numbering. In the case of the same numbering, " 80 "the user can set 'identical_mesh' to omit algorithm for guessing node and element renumbering. " 81 "Alternatively, in case of different input mesh, several interpolation algorithms are available.")
85 template <
int spacedim,
class Value>
89 "Specify the section in mesh input file where field data is listed.\nSome sections are specific to file format.")
90 .
add_value(OutputTime::DiscreteSpace::NODE_DATA,
"node_data",
"point_data (VTK) / node_data (GMSH)")
91 .
add_value(OutputTime::DiscreteSpace::ELEM_DATA,
"element_data",
"cell_data (VTK) / element_data (GMSH)")
92 .
add_value(OutputTime::DiscreteSpace::CORNER_DATA,
"element_node_data",
"element_node_data (only for GMSH)")
93 .
add_value(OutputTime::DiscreteSpace::NATIVE_DATA,
"native_data",
"native_data (only for VTK)")
97 template <
int spacedim,
class Value>
100 return it::Selection(
"interpolation",
"Specify interpolation of the input data from its input mesh to the computational mesh.")
101 .
add_value(DataInterpolation::identic_msh,
"identic_mesh",
"Topology and indices of nodes and elements of" 102 "the input mesh and the computational mesh are identical. " 103 "This interpolation is typically used for GMSH input files containing only the field values without " 104 "explicit mesh specification.")
105 .
add_value(DataInterpolation::equivalent_msh,
"equivalent_mesh",
"Topologies of the input mesh and the computational mesh " 106 "are the same, the node and element numbering may differ. " 107 "This interpolation can be used also for VTK input data.")
108 .
add_value(DataInterpolation::gauss_p0,
"P0_gauss",
"Topologies of the input mesh and the computational mesh may differ. " 109 "Constant values on the elements of the computational mesh are evaluated using the Gaussian quadrature of the fixed order 4, " 110 "where the quadrature points and their values are found in the input mesh and input data using the BIH tree search." 112 .
add_value(DataInterpolation::interp_p0,
"P0_intersection",
"Topologies of the input mesh and the computational mesh may differ. " 113 "Can be applied only for boundary fields. For every (boundary) element of the computational mesh the " 114 "intersection with the input mesh is computed. Constant values on the elements of the computational mesh " 115 "are evaluated as the weighted average of the (constant) values on the intersecting elements of the input mesh.")
119 template <
int spacedim,
class Value>
121 Input::register_class< FieldFE<spacedim, Value>,
unsigned int >(
"FieldFE") +
126 template <
int spacedim,
class Value>
136 template <
int spacedim,
class Value>
150 template <
int spacedim,
class Value>
159 template <
int spacedim,
class Value>
166 unsigned int ndofs =
dh_->max_elem_dofs();
173 init_data.
ndofs = ndofs;
192 template <
int spacedim,
class Value>
205 ASSERT(
false).error(
"Invalid element dimension!");
216 template <
int spacedim,
class Value>
220 ASSERT_EQ( point_list.size(), value_list.size() ).error();
236 ASSERT(
false).error(
"Invalid element dimension!");
242 template <
int spacedim,
class Value>
265 template <
int spacedim,
class Value>
269 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
273 case DataInterpolation::identic_msh:
276 case DataInterpolation::equivalent_msh:
279 WarningOut().fmt(
"Source mesh of FieldFE '{}' is not compatible with target mesh.\nInterpolation of input data will be changed to 'P0_gauss'.\n",
283 case DataInterpolation::gauss_p0:
289 case DataInterpolation::interp_p0:
293 if (!boundary_domain) {
295 WarningOut().fmt(
"Interpolation 'P0_intersection' of FieldFE '{}' can't be used on bulk region.\nIt will be changed to 'P0_gauss'.\n",
field_name_);
306 template <
int spacedim,
class Value>
310 auto bc_mesh =
dh_->mesh()->get_bc_mesh();
312 boundary_dofs_ = std::make_shared< std::vector<LongIdx> >( n_comp * bc_mesh->n_elements() );
316 for (
auto ele : bc_mesh->elements_range()) {
317 LongIdx elm_shift = n_comp * ele.idx();
318 for (
unsigned int i=0; i<
n_comp; ++i, ++j) {
319 in_vec[j] = elm_shift + i;
333 template <
int spacedim,
class Value>
336 switch (this->
value_.n_rows() * this->
value_.n_cols()) {
345 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
346 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
347 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
348 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
356 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
357 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
358 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
359 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
367 ASSERT(
false).error(
"Should not happen!\n");
371 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>( &
const_cast<Mesh &
>(*mesh),
fe0_,
fe1_,
fe2_,
fe3_);
374 unsigned int ndofs =
dh_->max_elem_dofs();
384 init_data.ndofs = ndofs;
385 init_data.n_comp = this->
n_comp();
396 template <
int spacedim,
class Value>
400 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
404 unsigned int n_components = this->
value_.n_rows() * this->
value_.n_cols();
407 double read_time = (time.
end()+time_shift) / time_unit_coef;
412 unsigned int n_entities;
413 bool is_native = (header_query.discretization == OutputTime::DiscreteSpace::NATIVE_DATA);
416 n_entities =
dh_->mesh()->n_elements();
446 template <
int spacedim,
class Value>
449 static const unsigned int quadrature_order = 4;
454 unsigned int quadrature_size;
456 unsigned int elem_count;
463 q_points.resize(quad.
size());
464 q_weights.resize(quad.
size());
469 else mesh =
dh_->mesh();
471 std::fill(elem_value.begin(), elem_value.end(), 0.0);
472 switch (ele->dim()) {
475 q_points[0] = ele.node(0)->point();
488 searched_elements.clear();
489 source_mesh->get_bih_tree().find_bounding_box(ele.bounding_box(), searched_elements);
491 for (
unsigned int i=0; i<quadrature_size; ++i) {
492 std::fill(sum_val.begin(), sum_val.end(), 0.0);
497 switch (elm->
dim()) {
499 contains = arma::norm(elm.
node(0)->
point()-q_points[i], 2) < 4*std::numeric_limits<double>::epsilon();
511 ASSERT(
false).error(
"Invalid element dimension!");
515 unsigned int index = sum_val.size() * (*it);
516 for (
unsigned int j=0; j < sum_val.size(); j++) {
517 sum_val[j] += (*data_vec)[index+j];
523 if (elem_count > 0) {
524 for (
unsigned int j=0; j < sum_val.size(); j++) {
525 elem_value[j] += (sum_val[j] / elem_count) * q_weights[i];
532 for (
unsigned int i=0; i < elem_value.size(); i++) {
540 template <
int spacedim,
class Value>
546 double total_measure, measure;
550 else mesh =
dh_->mesh();
552 if (elm.dim() == 3) {
553 xprintf(
Err,
"Dimension of element in target mesh must be 0, 1 or 2! elm.idx() = %d\n", elm.idx());
556 double epsilon = 4* numeric_limits<double>::epsilon() * elm.measure();
559 if (elm.dim() == 0) {
560 searched_elements.clear();
561 source_mesh->get_bih_tree().find_point(elm.node(0)->point(), searched_elements);
564 searched_elements.clear();
565 source_mesh->get_bih_tree().find_bounding_box(bb, searched_elements);
581 if (ele->
dim() == 3) {
585 arma::vec::fixed<3> real_point = elm.node(0)->point();
586 arma::mat::fixed<3, 4> elm_map = mapping.element_map(ele);
587 arma::vec::fixed<4> unit_point = mapping.project_real_to_unit(real_point, elm_map);
589 measure = (std::fabs(arma::sum( unit_point )-1) <= 1e-14
590 && arma::min( unit_point ) >= 0)
617 if (measure > epsilon) {
618 unsigned int index =
value.size() * (*it);
620 for (
unsigned int i=0; i <
value.size(); i++) {
621 value[i] += vec[index+i] * measure;
623 total_measure += measure;
629 if (total_measure > epsilon) {
633 for (
unsigned int i=0; i <
value.size(); i++) {
637 WarningOut().fmt(
"Processed element with idx {} is out of source mesh!\n", elm.idx());
645 template <
int spacedim,
class Value>
649 unsigned int dof_size, data_vec_i;
657 else mesh =
dh_->mesh();
662 for (
unsigned int i=0; i<dof_size; ++i, ++data_vec_i) {
663 (*data_vector)[
dof_indices_[i] ] += (*data_cache)[data_vec_i];
664 ++count_vector[ dof_indices_[i] ];
680 if (count_vector[i]>0) (*data_vector)[i] /= count_vector[i];
685 template <
int spacedim,
class Value>
689 double loc_values[output_data_cache.
n_elem()];
690 unsigned int i, dof_filled_size;
693 for (
auto ele :
dh_->mesh()->elements_range()) {
695 for (i=0; i<dof_filled_size; ++i) loc_values[i] = (*data_vec)[
dof_indices_[0] ];
696 for ( ; i<output_data_cache.
n_elem(); ++i) loc_values[i] = numeric_limits<double>::signaling_NaN();
697 output_data_cache.
store_value( ele.idx(), loc_values );
705 template <
int spacedim,
class Value>
712 template <
int spacedim,
class Value>
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
std::shared_ptr< DOFHandlerMultiDim > sequential()
Returns sequential version of the current dof handler.
virtual ~FieldFE()
Destructor.
void init_unit_conversion_coefficient(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Init value of unit_conversion_coefficient_ from input.
Bounding box in 3d ambient space.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
void set_boundary_dofs_vector(std::shared_ptr< std::vector< LongIdx > > boundary_dofs)
TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
void set_dof_handler_hash(std::size_t hash)
void interpolate_gauss(ElementDataCache< double >::ComponentDataPtr data_vec)
Interpolate data (use Gaussian distribution) over all elements of target mesh.
FEValueHandler< 0, spacedim, Value > value_handler0_
Value handler that allows get value of 0D elements.
std::shared_ptr< std::vector< T > > ComponentDataPtr
double read_coef(Input::Iterator< std::string > unit_it) const
Classes with algorithms for computation of intersections of meshes.
Some value(s) is set to NaN.
VectorMPI * data_vec
Store data of Field.
unsigned int component_idx_
Specify if the field is part of a MultiField and which component it is.
static void get_element_ids(const FilePath &file_path, const Mesh &mesh)
void initialize(FEValueInitData init_data, MappingP1< elemdim, 3 > *map=nullptr)
Initialize data members.
std::string field_name_
field name read from input
double compute_measure() const override
Computes the relative measure of intersection object.
void fill_data_to_cache(ElementDataCache< double > &output_data_cache)
static VectorMPI * sequential(unsigned int size)
FEValueHandler< 2, spacedim, Value > value_handler2_
Value handler that allows get value of 2D elements.
void store_value(unsigned int idx, const T *value)
Fundamental simplicial intersections.
void distribute_dofs(std::shared_ptr< DiscreteSpace > ds)
Distributes degrees of freedom on the mesh needed for the given discrete space.
FilePath reader_file_
mesh reader file
void set_fe_data(std::shared_ptr< DOFHandlerMultiDim > dh, MappingP1< 1, 3 > *map1, MappingP1< 2, 3 > *map2, MappingP1< 3, 3 > *map3, VectorMPI *data)
#define INSTANCE_ALL(field)
void init()
Initializes lower dimensional objects. Sets correctly the pointers to Plucker coordinates and product...
void initialize(FEValueInitData init_data)
Initialize data members.
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Returns one value in one given point.
Class FESystem for compound finite elements.
VectorDataPtr data_ptr()
Getter for shared pointer of output data.
void set_mesh(const Mesh *mesh, bool boundary_domain) override
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
#define ADD_CALLS(n_calls)
Increase number of calls in actual timer.
double default_value_
Default value of element if not set in mesh data file.
FEValueHandler< 3, spacedim, Value > value_handler3_
Value handler that allows get value of 3D elements.
bool set_time(const TimeStep &time) override
FiniteElement< 3 > * fe3_
Same as previous, but represents 3D element.
static const Input::Type::Selection & get_interp_selection_input_type()
Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Returns one value in one given point.
std::shared_ptr< std::vector< LongIdx > > boundary_dofs_
Value::return_type r_value_
void fill_boundary_dofs()
Symmetric Gauss-Legendre quadrature formulae on simplices.
unsigned int data_size() const
constexpr bool match(Mask mask) const
void init()
Initializes lower dimensional objects. Sets correctly the pointers to Plucker coordinates and product...
double unit_conversion_coefficient_
Coeficient of conversion of user-defined unit.
bool boundary_domain_
Is set in set_mesh method. Value true means, that we accept only boundary element accessors in the va...
void set_native_dh(std::shared_ptr< DOFHandlerMultiDim > dh) override
OutputTime::DiscreteSpace discretization_
Specify section where to find the field data in input mesh file.
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
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())
void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Returns std::vector of scalar values in several points at once.
DataInterpolation interpolation_
Specify type of FE data interpolation.
Compound finite element on dim dimensional simplex.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
void resize(unsigned int local_size)
#define START_TIMER(tag)
Starts a timer with specified tag.
Provides the numbering of the finite element degrees of freedom on the computational mesh...
void interpolate_intersection(ElementDataCache< double >::ComponentDataPtr data_vec)
Interpolate data (use intersection library) over all elements of target mesh.
NumCompValueType n_elem()
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
virtual Range< ElementAccessor< 3 > > elements_range() const
Returns range of bulk elements.
static bool check_compatible_mesh(const FilePath &file_path, Mesh &mesh)
unsigned int ndofs
number of dofs
Space< spacedim >::Point Point
void reinit_fe_data(MappingP1< 1, 3 > *map1, MappingP1< 2, 3 > *map2, MappingP1< 3, 3 > *map3)
Ensure data setting of methods set_fe_data and set_native_dh.
unsigned int compute_quadrature(std::vector< arma::vec::fixed< 3 >> &q_points, std::vector< double > &q_weights, const ElementAccessor< spacedim > &elm, unsigned int order=3)
Compute real coordinates and weights (use QGauss) for given element.
CheckResult
Return type of method that checked data stored in ElementDataCache (NaN values, limits) ...
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
unsigned int get_dof_indices(const ElementAccessor< 3 > &cell, std::vector< LongIdx > &indices) const
TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
FEValueHandler< 1, spacedim, Value > value_handler1_
Value handler that allows get value of 1D elements.
Dedicated class for storing path to input and output files.
MappingP1< elemdim, 3 > * get_mapping()
Return mapping object.
FiniteElement< 1 > * fe1_
Same as previous, but represents 1D element.
static const Input::Type::Selection & get_disc_selection_input_type()
FiniteElement< 2 > * fe2_
Same as previous, but represents 2D element.
bool is_constant_in_space_
Flag detects that field is only dependent on time.
Value value_
Last value, prevents passing large values (vectors) by value.
VectorMPI * data_vec_
Store data of Field.
Input::Record in_rec_
Accessor to Input::Record.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
FieldFE(unsigned int n_comp=0)
const unsigned int size() const
Returns number of quadrature points.
void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Returns std::vector of scalar values in several points at once.
std::vector< LongIdx > dof_indices_
Array of indexes to data_vec_, used for get/set values.
Definitions of particular quadrature rules on simplices.
Class for 2D-2D intersections.
#define WarningOut()
Macro defining 'warning' record of log.
void set_boundary_dofs_vector(std::shared_ptr< std::vector< LongIdx > > boundary_dofs)
TODO: Temporary solution. Fix problem with merge new DOF handler and boundary Mesh. Will be removed in future.
#define END_TIMER(tag)
Ends a timer with specified tag.
FiniteElement< 0 > * fe0_
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
static std::shared_ptr< Mesh > get_mesh(const FilePath &file_path)
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
bool contains_point(arma::vec point, ElementAccessor< 3 > elm)
Test if element contains given point.
Internal auxiliary class representing intersection object of simplex<dimA> and simplex<dimB>.
static std::shared_ptr< BaseMeshReader > get_reader(const FilePath &file_path)
std::shared_ptr< VectorData > VectorDataPtr
unsigned int n_comp
number of components
void calculate_native_values(ElementDataCache< double >::ComponentDataPtr data_cache)
Calculate native data over all elements of target mesh.
FieldFlag::Flags flags_
Field flags.
Initialization structure of FEValueHandler class.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Representation of one time step..
void make_dof_handler(const Mesh *mesh)
Create DofHandler object.
Implementation of range helper class.
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on) ...
unsigned int size()
Return size of output data.
unsigned int n_comp() const
Internal class representing intersection object.
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
const Node * node(unsigned int ni) const