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>
135 template <
int spacedim,
class Value>
137 unsigned int component_index,
VectorMPI dof_values)
140 if (dof_values.
size()==0) {
147 unsigned int ndofs =
dh_->max_elem_dofs();
154 init_data.
ndofs = ndofs;
175 template <
int spacedim,
class Value>
188 ASSERT(
false).error(
"Invalid element dimension!");
199 template <
int spacedim,
class Value>
203 ASSERT_EQ( point_list.size(), value_list.size() ).error();
219 ASSERT(
false).error(
"Invalid element dimension!");
225 template <
int spacedim,
class Value>
248 template <
int spacedim,
class Value>
252 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
256 case DataInterpolation::identic_msh:
259 case DataInterpolation::equivalent_msh:
262 WarningOut().fmt(
"Source mesh of FieldFE '{}' is not compatible with target mesh.\nInterpolation of input data will be changed to 'P0_gauss'.\n",
266 case DataInterpolation::gauss_p0:
272 case DataInterpolation::interp_p0:
276 if (!boundary_domain) {
278 WarningOut().fmt(
"Interpolation 'P0_intersection' of FieldFE '{}' can't be used on bulk region.\nIt will be changed to 'P0_gauss'.\n",
field_name_);
288 template <
int spacedim,
class Value>
292 auto bc_mesh =
dh_->mesh()->get_bc_mesh();
294 boundary_dofs_ = std::make_shared< std::vector<LongIdx> >( n_comp * bc_mesh->n_elements() );
298 for (
auto ele : bc_mesh->elements_range()) {
299 LongIdx elm_shift = n_comp * ele.idx();
300 for (
unsigned int i=0; i<
n_comp; ++i, ++j) {
301 in_vec[j] = elm_shift + i;
315 template <
int spacedim,
class Value>
318 switch (this->
value_.n_rows() * this->
value_.n_cols()) {
327 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
328 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
329 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
330 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
338 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
339 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
340 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
341 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
349 ASSERT(
false).error(
"Should not happen!\n");
353 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>( &
const_cast<Mesh &
>(*mesh),
fe0_,
fe1_,
fe2_,
fe3_);
356 unsigned int ndofs =
dh_->max_elem_dofs();
366 init_data.ndofs = ndofs;
367 init_data.n_comp = this->
n_comp();
368 init_data.comp_index = 0;
379 template <
int spacedim,
class Value>
383 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
387 unsigned int n_components = this->
value_.n_rows() * this->
value_.n_cols();
390 double read_time = (time.
end()+time_shift) / time_unit_coef;
395 unsigned int n_entities;
396 bool is_native = (header_query.discretization == OutputTime::DiscreteSpace::NATIVE_DATA);
399 n_entities =
dh_->mesh()->n_elements();
429 template <
int spacedim,
class Value>
432 static const unsigned int quadrature_order = 4;
437 unsigned int quadrature_size=0;
439 unsigned int elem_count;
445 QGauss quad(3, quadrature_order);
446 q_points.resize(quad.
size());
447 q_weights.resize(quad.
size());
452 else mesh =
dh_->mesh();
454 std::fill(elem_value.begin(), elem_value.end(), 0.0);
455 switch (ele->dim()) {
458 q_points[0] = ele.node(0)->point();
471 searched_elements.clear();
472 source_mesh->get_bih_tree().find_bounding_box(ele.bounding_box(), searched_elements);
474 for (
unsigned int i=0; i<quadrature_size; ++i) {
475 std::fill(sum_val.begin(), sum_val.end(), 0.0);
480 switch (elm->
dim()) {
482 contains = arma::norm(elm.
node(0)->
point()-q_points[i], 2) < 4*std::numeric_limits<double>::epsilon();
494 ASSERT(
false).error(
"Invalid element dimension!");
498 unsigned int index = sum_val.size() * (*it);
499 for (
unsigned int j=0; j < sum_val.size(); j++) {
500 sum_val[j] += (*data_vec)[index+j];
506 if (elem_count > 0) {
507 for (
unsigned int j=0; j < sum_val.size(); j++) {
508 elem_value[j] += (sum_val[j] / elem_count) * q_weights[i];
518 for (
unsigned int i=0; i < elem_value.size(); i++) {
526 template <
int spacedim,
class Value>
532 double total_measure;
537 else mesh =
dh_->mesh();
539 if (elm.dim() == 3) {
540 xprintf(
Err,
"Dimension of element in target mesh must be 0, 1 or 2! elm.idx() = %d\n", elm.idx());
543 double epsilon = 4* numeric_limits<double>::epsilon() * elm.measure();
546 if (elm.dim() == 0) {
547 searched_elements.clear();
548 source_mesh->get_bih_tree().find_point(elm.node(0)->point(), searched_elements);
551 searched_elements.clear();
552 source_mesh->get_bih_tree().find_bounding_box(bb, searched_elements);
568 if (ele->
dim() == 3) {
572 arma::vec::fixed<3> real_point = elm.node(0)->point();
573 arma::mat::fixed<3, 4> elm_map = mapping.element_map(ele);
574 arma::vec::fixed<4> unit_point = mapping.project_real_to_unit(real_point, elm_map);
576 measure = (std::fabs(arma::sum( unit_point )-1) <= 1e-14
577 && arma::min( unit_point ) >= 0)
604 if (measure > epsilon) {
605 unsigned int index =
value.size() * (*it);
607 for (
unsigned int i=0; i <
value.size(); i++) {
608 value[i] += vec[index+i] * measure;
610 total_measure += measure;
616 if (total_measure > epsilon) {
623 for (
unsigned int i=0; i <
value.size(); i++) {
627 WarningOut().fmt(
"Processed element with idx {} is out of source mesh!\n", elm.idx());
635 template <
int spacedim,
class Value>
639 unsigned int dof_size, data_vec_i;
647 else mesh =
dh_->mesh();
650 else dof_size =
dh_->cell_accessor_from_element(ele.idx()).get_loc_dof_indices(
dof_indices_ );
652 for (
unsigned int i=0; i<dof_size; ++i, ++data_vec_i) {
653 (*data_vector)[
dof_indices_[i] ] += (*data_cache)[data_vec_i];
654 ++count_vector[ dof_indices_[i] ];
670 if (count_vector[i]>0) (*data_vector)[i] /= count_vector[i];
675 template <
int spacedim,
class Value>
679 double loc_values[output_data_cache.
n_comp()];
680 unsigned int i, dof_filled_size;
683 for (
auto dh_cell :
dh_->own_range()) {
684 dof_filled_size = dh_cell.get_loc_dof_indices(
dof_indices_);
685 for (i=0; i<dof_filled_size; ++i) loc_values[i] = (*data_vec)[
dof_indices_[i] ];
686 for ( ; i<output_data_cache.
n_comp(); ++i) loc_values[i] = numeric_limits<double>::signaling_NaN();
687 output_data_cache.
store_value( dh_cell.local_idx(), loc_values );
695 template <
int spacedim,
class Value>
702 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.
unsigned int size() const
Return size of output data.
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.
unsigned int n_values() const
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.
unsigned int get_loc_dof_indices(std::vector< LongIdx > &indices) const
Returns the indices of dofs associated to the cell on the local process.
FEValueHandler< 2, spacedim, Value > value_handler2_
Value handler that allows get value of 2D elements.
VectorMPI data_vec_
Store data of Field.
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.
Cell accessor allow iterate over DOF handler cells.
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.
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.
VectorMPI set_fe_data(std::shared_ptr< DOFHandlerMultiDim > dh, unsigned int component_index=0, VectorMPI dof_values=VectorMPI::sequential(0))
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.
Input::Record in_rec_
Accessor to Input::Record.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
static VectorMPI sequential(unsigned int size)
FieldFE(unsigned int n_comp=0)
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)
VectorMPI data_vec
Store data of Field.
unsigned int n_comp() const
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
unsigned int size() const
Returns number of quadrature points.
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.
void native_data_to_cache(ElementDataCache< double > &output_data_cache)
#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 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