46 template <
int spacedim, class
Value>
53 "GMSH mesh with data. Can be different from actual computational mesh.")
55 "Section where to find the field, some sections are specific to file format \n" 56 "point_data/node_data, cell_data/element_data, -/element_node_data, native/-.\n" 57 "If not given by user we try to find the field in all sections, but report error \n" 58 "if it is found in more the one section.")
60 "The values of the Field are read from the ```$ElementData``` section with field name given by this key.")
62 "Allow set default value of elements that have not listed values in mesh data file.")
64 "Definition of unit of all times defined in mesh data file.")
66 "Allow set time shift of field data read from the mesh data file. For time 't', field descriptor with time 'T', " 67 "time shift 'S' and if 't > T', we read time frame 't + S'.")
71 template <
int spacedim,
class Value>
75 "Specify the section in mesh input file where field data is listed.\nSome sections are specific to file format.")
76 .
add_value(OutputTime::DiscreteSpace::NODE_DATA,
"node_data",
"point_data (VTK) / node_data (GMSH)")
77 .
add_value(OutputTime::DiscreteSpace::ELEM_DATA,
"element_data",
"cell_data (VTK) / element_data (GMSH)")
78 .
add_value(OutputTime::DiscreteSpace::CORNER_DATA,
"element_node_data",
"element_node_data (only for GMSH)")
79 .
add_value(OutputTime::DiscreteSpace::NATIVE_DATA,
"native_data",
"native_data (only for VTK)")
83 template <
int spacedim,
class Value>
85 Input::register_class< FieldFE<spacedim, Value>,
unsigned int >(
"FieldFE") +
90 template <
int spacedim,
class Value>
95 has_compatible_mesh_(false)
101 template <
int spacedim,
class Value>
115 template <
int spacedim,
class Value>
124 template <
int spacedim,
class Value>
131 unsigned int ndofs =
dh_->max_elem_dofs();
138 init_data.
ndofs = ndofs;
156 template <
int spacedim,
class Value>
169 ASSERT(
false).error(
"Invalid element dimension!");
180 template <
int spacedim,
class Value>
184 ASSERT_EQ( point_list.size(), value_list.size() ).error();
200 ASSERT(
false).error(
"Invalid element dimension!");
206 template <
int spacedim,
class Value>
226 template <
int spacedim,
class Value>
230 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
239 template <
int spacedim,
class Value>
242 switch (this->
value_.n_rows() * this->
value_.n_cols()) {
251 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
252 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
253 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
254 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
262 std::shared_ptr< FiniteElement<0> > fe0_ptr = std::make_shared< FE_P_disc<0> >(0);
263 std::shared_ptr< FiniteElement<1> > fe1_ptr = std::make_shared< FE_P_disc<1> >(0);
264 std::shared_ptr< FiniteElement<2> > fe2_ptr = std::make_shared< FE_P_disc<2> >(0);
265 std::shared_ptr< FiniteElement<3> > fe3_ptr = std::make_shared< FE_P_disc<3> >(0);
273 ASSERT(
false).error(
"Should not happen!\n");
276 dh_ = std::make_shared<DOFHandlerMultiDim>(
const_cast<Mesh &
>(*mesh) );
277 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>( &
const_cast<Mesh &
>(*mesh),
fe0_,
fe1_,
fe2_,
fe3_);
278 dh_->distribute_dofs(ds,
true);
279 unsigned int ndofs =
dh_->max_elem_dofs();
291 init_data.
ndofs = ndofs;
303 template <
int spacedim,
class Value>
307 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
311 unsigned int n_components = this->
value_.n_rows() * this->
value_.n_cols();
314 double read_time = (time.
end()+time_shift) / time_unit_coef;
319 unsigned int n_entities;
320 bool is_native = (header_query.discretization == OutputTime::DiscreteSpace::NATIVE_DATA);
322 n_entities =
dh_->mesh()->n_elements();
348 template <
int spacedim,
class Value>
357 for (
auto ele :
dh_->mesh()->elements_range()) {
358 searched_elements.clear();
359 source_mesh->get_bih_tree().find_point(ele.centre(), searched_elements);
360 std::fill(sum_val.begin(), sum_val.end(), 0.0);
361 std::fill(elem_count.begin(), elem_count.end(), 0);
365 switch (elm->
dim()) {
367 contains = arma::norm(elm.
node(0)->
point()-ele.centre(), 2) < 4*std::numeric_limits<double>::epsilon();
379 ASSERT(
false).error(
"Invalid element dimension!");
383 sum_val[elm->
dim()] += (*data_vec)[*
it];
384 ++elem_count[elm->
dim()];
387 unsigned int dim = ele->dim();
388 double elem_value = 0.0;
390 if (elem_count[dim] > 0) {
391 elem_value = sum_val[dim] / elem_count[dim];
404 template <
int spacedim,
class Value>
408 unsigned int dof_size, data_vec_i;
414 for (
auto ele :
dh_->mesh()->elements_range()) {
417 for (
unsigned int i=0; i<dof_size; ++i, ++data_vec_i) {
418 (*data_vector)[
dof_indices_[i] ] += (*data_cache)[data_vec_i];
419 ++count_vector[ dof_indices_[i] ];
425 if (count_vector[i]>0) (*data_vector)[i] /= count_vector[i];
430 template <
int spacedim,
class Value>
434 double loc_values[output_data_cache.
n_elem()];
435 unsigned int i, dof_filled_size;
438 for (
auto ele :
dh_->mesh()->elements_range()) {
440 for (i=0; i<dof_filled_size; ++i) loc_values[i] = (*data_vec)[
dof_indices_[0] ];
441 for ( ; i<output_data_cache.
n_elem(); ++i) loc_values[i] = numeric_limits<double>::signaling_NaN();
442 output_data_cache.
store_value( ele.idx(), loc_values );
450 template <
int spacedim,
class Value>
457 template <
int spacedim,
class Value>
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.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
void set_dof_handler_hash(std::size_t hash)
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
void interpolate(ElementDataCache< double >::ComponentDataPtr data_vec)
Interpolate data over all elements of target mesh.
VectorSeqDouble * data_vec_
Store data of Field.
Some value(s) is set to NaN.
unsigned int component_idx_
Specify if the field is part of a MultiField and which component it is.
void initialize(FEValueInitData init_data, MappingP1< elemdim, 3 > *map=nullptr)
Initialize data members.
void fill(double value)
Fill all values of data vector with given value.
std::string field_name_
field name read from input
void fill_data_to_cache(ElementDataCache< double > &output_data_cache)
FEValueHandler< 2, spacedim, Value > value_handler2_
Value handler that allows get value of 2D elements.
void store_value(unsigned int idx, const T *value)
FilePath reader_file_
mesh reader file
std::shared_ptr< std::vector< double > > VectorSeq
#define INSTANCE_ALL(field)
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.
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...
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.
Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Returns one value in one given point.
Value::return_type r_value_
unsigned int size()
Getter for shared pointer of output data.
unsigned int data_size() const
constexpr bool match(Mask mask) const
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
friend class VectorSeqDouble
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.
Compound finite element on dim dimensional simplex.
VectorSeqDouble * data_vec
Store data of Field.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
void resize(unsigned int size)
Create shared pointer and PETSC vector with given size.
NumCompValueType n_elem()
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
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.
CheckResult
Return type of method that checked data stored in ElementDataCache (NaN values, limits) ...
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
bool has_compatible_mesh_
Flag that determines if source mesh and target mesh are compatible.
double read_time(Input::Iterator< Input::Tuple > time_it, double default_time=std::numeric_limits< double >::quiet_NaN()) const
void set_fe_data(std::shared_ptr< DOFHandlerMultiDim > dh, MappingP1< 1, 3 > *map1, MappingP1< 2, 3 > *map2, MappingP1< 3, 3 > *map3, VectorSeqDouble *data)
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)
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.
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)
VectorSeq get_data_ptr()
Getter for shared pointer of output data.
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.
static std::shared_ptr< BaseMeshReader > get_reader(const FilePath &file_path)
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 n_comp() const
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
const Node * node(unsigned int ni) const