41 template <
int spacedim, class
Value>
48 "GMSH mesh with data. Can be different from actual computational mesh.")
50 "Section where to find the field, some sections are specific to file format \n" 51 "point_data/node_data, cell_data/element_data, -/element_node_data, native/-.\n" 52 "If not given by user we try to find the field in all sections, but report error \n" 53 "if it is found in more the one section.")
55 "The values of the Field are read from the ```$ElementData``` section with field name given by this key.")
59 template <
int spacedim,
class Value>
63 "Specify the section in mesh input file where field data is listed.\nSome sections are specific to file format.")
64 .
add_value(OutputTime::DiscreteSpace::NODE_DATA,
"node_data",
"point_data (VTK) / node_data (GMSH)")
65 .
add_value(OutputTime::DiscreteSpace::ELEM_DATA,
"element_data",
"cell_data (VTK) / element_data (GMSH)")
66 .
add_value(OutputTime::DiscreteSpace::CORNER_DATA,
"element_node_data",
"element_node_data (only for GMSH)")
67 .
add_value(OutputTime::DiscreteSpace::NATIVE_DATA,
"native_data",
"native_data (only for VTK)")
71 template <
int spacedim,
class Value>
73 Input::register_class< FieldFE<spacedim, Value>,
unsigned int >(
"FieldFE") +
78 template <
int spacedim,
class Value>
86 template <
int spacedim,
class Value>
96 unsigned int ndofs =
dh_->max_elem_dofs();
103 init_data.
ndofs = ndofs;
120 template <
int spacedim,
class Value>
131 ASSERT(
false).error(
"Invalid element dimension!");
142 template <
int spacedim,
class Value>
146 ASSERT_EQ( point_list.size(), value_list.size() ).error();
159 ASSERT(
false).error(
"Invalid element dimension!");
165 template <
int spacedim,
class Value>
181 template <
int spacedim,
class Value>
185 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
193 template <
int spacedim,
class Value>
200 dh_ = std::make_shared<DOFHandlerMultiDim>(
const_cast<Mesh &
>(*mesh) );
201 dh_->distribute_dofs(*
fe1_, *fe2_, *fe3_);
202 unsigned int ndofs = dh_->max_elem_dofs();
206 unsigned int data_size = dh_->n_global_dofs();
214 init_data.
ndofs = ndofs;
225 template <
int spacedim,
class Value>
229 ASSERT(
field_name_ !=
"").error(
"Uninitialized FieldFE, did you call init_from_input()?\n");
233 unsigned int n_components = this->
value_.n_rows() * this->
value_.n_cols();
234 bool boundary_domain =
false;
238 if (header_query.discretization == OutputTime::DiscreteSpace::NATIVE_DATA) {
255 template <
int spacedim,
class Value>
264 searched_elements.clear();
265 source_mesh->get_bih_tree().find_point(ele->centre(), searched_elements);
266 std::fill(sum_val.begin(), sum_val.end(), 0.0);
267 std::fill(elem_count.begin(), elem_count.end(), 0);
271 switch (elm->dim()) {
282 ASSERT(
false).error(
"Invalid element dimension!");
286 sum_val[elm->dim()] += (*data_vec)[*
it];
287 ++elem_count[elm->dim()];
290 unsigned int dim = ele->dim();
291 double elem_value = 0.0;
293 if (elem_count[dim] > 0) {
294 elem_value = sum_val[dim] / elem_count[dim];
307 template <
int spacedim,
class Value>
311 unsigned int dof_size, data_vec_i;
320 for (
unsigned int i=0; i<dof_size; ++i, ++data_vec_i) {
321 (*data_vector)[
dof_indices_[i] ] += (*data_cache)[data_vec_i];
322 ++count_vector[ dof_indices_[i] ];
328 if (count_vector[i]>0) (*data_vector)[i] /= count_vector[i];
333 template <
int spacedim,
class Value>
337 double loc_values[output_data_cache.
n_elem()];
338 unsigned int i, dof_filled_size;
343 for (i=0; i<dof_filled_size; ++i) loc_values[i] = (*data_vec)[
dof_indices_[0] ];
344 for ( ; i<output_data_cache.
n_elem(); ++i) loc_values[i] = numeric_limits<double>::signaling_NaN();
345 output_data_cache.
store_value( ele.index(), loc_values );
353 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)
std::shared_ptr< std::vector< T > > ComponentDataPtr
std::vector< IdxInt > dof_indices_
Array of indexes to data_vec_, used for get/set values.
void interpolate(ElementDataCache< double >::ComponentDataPtr data_vec)
Interpolate data over all elements of target mesh.
VectorSeqDouble * data_vec_
Store data of Field.
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.
#define FOR_ELEMENTS(_mesh_, __i)
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)
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
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...
FEValueHandler< 3, spacedim, Value > value_handler3_
Value handler that allows get value of 3D elements.
bool set_time(const TimeStep &time) override
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.
OutputTime::DiscreteSpace discretization_
Specify section where to find the field data in input mesh file.
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
FiniteElement< 2, 3 > * fe2_
Same as previous, but represents 2D element.
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.
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)
unsigned int ndofs
number of dofs
Space< spacedim >::Point Point
std::shared_ptr< DOFHandlerMultiDim > dh
DOF handler object.
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.
static const Input::Type::Selection & get_disc_selection_input_type()
Value value_
Last value, prevents passing large values (vectors) by value.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
FieldFE(unsigned int n_comp=0)
bool contains_point(arma::vec point, Element &elm)
Test if element contains given point.
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)
static std::shared_ptr< BaseMeshReader > get_reader(const FilePath &file_path)
FiniteElement< 1, 3 > * fe1_
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.
FiniteElement< 3, 3 > * fe3_
Same as previous, but represents 3D element.
Representation of one time step..
void make_dof_handler(const Mesh *mesh)
Create DofHandler object.
#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.