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>
138 unsigned int component_index,
VectorMPI *dof_values)
141 if (dof_values==
nullptr) {
148 unsigned int ndofs =
dh_->max_elem_dofs();
155 init_data.
ndofs = ndofs;
176 template <
int spacedim,
class Value>
189 ASSERT(
false).error(
"Invalid element dimension!");
200 template <
int spacedim,
class Value>
204 ASSERT_EQ( point_list.size(), value_list.size() ).error();
220 ASSERT(
false).error(
"Invalid element dimension!");
226 template <
int spacedim,
class Value>
249 template <
int spacedim,
class Value>
253 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
257 case DataInterpolation::identic_msh:
260 case DataInterpolation::equivalent_msh:
263 WarningOut().fmt(
"Source mesh of FieldFE '{}' is not compatible with target mesh.\nInterpolation of input data will be changed to 'P0_gauss'.\n",
267 case DataInterpolation::gauss_p0:
273 case DataInterpolation::interp_p0:
277 if (!boundary_domain) {
279 WarningOut().fmt(
"Interpolation 'P0_intersection' of FieldFE '{}' can't be used on bulk region.\nIt will be changed to 'P0_gauss'.\n",
field_name_);
290 template <
int spacedim,
class Value>
294 auto bc_mesh =
dh_->mesh()->get_bc_mesh();
296 boundary_dofs_ = std::make_shared< std::vector<LongIdx> >( n_comp * bc_mesh->n_elements() );
300 for (
auto ele : bc_mesh->elements_range()) {
301 LongIdx elm_shift = n_comp * ele.idx();
302 for (
unsigned int i=0; i<
n_comp; ++i, ++j) {
303 in_vec[j] = elm_shift + i;
317 template <
int spacedim,
class Value>
320 switch (this->
value_.n_rows() * this->
value_.n_cols()) {
329 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
330 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
331 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
332 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
340 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
341 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
342 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
343 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
351 ASSERT(
false).error(
"Should not happen!\n");
355 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>( &
const_cast<Mesh &
>(*mesh),
fe0_,
fe1_,
fe2_,
fe3_);
358 unsigned int ndofs =
dh_->max_elem_dofs();
368 init_data.ndofs = ndofs;
369 init_data.n_comp = this->
n_comp();
370 init_data.comp_index = 0;
381 template <
int spacedim,
class Value>
385 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
389 unsigned int n_components = this->
value_.n_rows() * this->
value_.n_cols();
392 double read_time = (time.
end()+time_shift) / time_unit_coef;
397 unsigned int n_entities;
398 bool is_native = (header_query.discretization == OutputTime::DiscreteSpace::NATIVE_DATA);
401 n_entities =
dh_->mesh()->n_elements();
431 template <
int spacedim,
class Value>
434 static const unsigned int quadrature_order = 4;
439 unsigned int quadrature_size;
441 unsigned int elem_count;
448 q_points.resize(quad.
size());
449 q_weights.resize(quad.
size());
454 else mesh =
dh_->mesh();
456 std::fill(elem_value.begin(), elem_value.end(), 0.0);
457 switch (ele->dim()) {
460 q_points[0] = ele.node(0)->point();
473 searched_elements.clear();
474 source_mesh->get_bih_tree().find_bounding_box(ele.bounding_box(), searched_elements);
476 for (
unsigned int i=0; i<quadrature_size; ++i) {
477 std::fill(sum_val.begin(), sum_val.end(), 0.0);
482 switch (elm->
dim()) {
484 contains = arma::norm(elm.
node(0)->
point()-q_points[i], 2) < 4*std::numeric_limits<double>::epsilon();
496 ASSERT(
false).error(
"Invalid element dimension!");
500 unsigned int index = sum_val.size() * (*it);
501 for (
unsigned int j=0; j < sum_val.size(); j++) {
502 sum_val[j] += (*data_vec)[index+j];
508 if (elem_count > 0) {
509 for (
unsigned int j=0; j < sum_val.size(); j++) {
510 elem_value[j] += (sum_val[j] / elem_count) * q_weights[i];
517 for (
unsigned int i=0; i < elem_value.size(); i++) {
525 template <
int spacedim,
class Value>
531 double total_measure, measure;
535 else mesh =
dh_->mesh();
537 if (elm.dim() == 3) {
538 xprintf(
Err,
"Dimension of element in target mesh must be 0, 1 or 2! elm.idx() = %d\n", elm.idx());
541 double epsilon = 4* numeric_limits<double>::epsilon() * elm.measure();
544 if (elm.dim() == 0) {
545 searched_elements.clear();
546 source_mesh->get_bih_tree().find_point(elm.node(0)->point(), searched_elements);
549 searched_elements.clear();
550 source_mesh->get_bih_tree().find_bounding_box(bb, searched_elements);
566 if (ele->
dim() == 3) {
570 arma::vec::fixed<3> real_point = elm.node(0)->point();
571 arma::mat::fixed<3, 4> elm_map = mapping.element_map(ele);
572 arma::vec::fixed<4> unit_point = mapping.project_real_to_unit(real_point, elm_map);
574 measure = (std::fabs(arma::sum( unit_point )-1) <= 1e-14
575 && arma::min( unit_point ) >= 0)
602 if (measure > epsilon) {
603 unsigned int index =
value.size() * (*it);
605 for (
unsigned int i=0; i <
value.size(); i++) {
606 value[i] += vec[index+i] * measure;
608 total_measure += measure;
614 if (total_measure > epsilon) {
618 for (
unsigned int i=0; i <
value.size(); i++) {
622 WarningOut().fmt(
"Processed element with idx {} is out of source mesh!\n", elm.idx());
630 template <
int spacedim,
class Value>
634 unsigned int dof_size, data_vec_i;
642 else mesh =
dh_->mesh();
647 for (
unsigned int i=0; i<dof_size; ++i, ++data_vec_i) {
648 (*data_vector)[
dof_indices_[i] ] += (*data_cache)[data_vec_i];
649 ++count_vector[ dof_indices_[i] ];
665 if (count_vector[i]>0) (*data_vector)[i] /= count_vector[i];
670 template <
int spacedim,
class Value>
674 double loc_values[output_data_cache.
n_elem()];
675 unsigned int i, dof_filled_size;
678 for (
auto ele :
dh_->mesh()->elements_range()) {
680 for (i=0; i<dof_filled_size; ++i) loc_values[i] = (*data_vec)[
dof_indices_[0] ];
681 for ( ; i<output_data_cache.
n_elem(); ++i) loc_values[i] = numeric_limits<double>::signaling_NaN();
682 output_data_cache.
store_value( ele.idx(), loc_values );
690 template <
int spacedim,
class Value>
697 template <
int spacedim,
class Value>
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
unsigned int comp_index
index of component (of vector_value/tensor_value)
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.
void initialize(FEValueInitData init_data)
Initialize data members.
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)
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
#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...
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
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.
VectorMPI * set_fe_data(std::shared_ptr< DOFHandlerMultiDim > dh, unsigned int component_index=0, VectorMPI *dof_values=nullptr)
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