Flow123d  jenkins-Flow123d-linux-release-multijob-198
field_elementwise.hh
Go to the documentation of this file.
1 /*
2  * field_elementwise.hh
3  *
4  * Created on: Jan 22, 2013
5  * Author: jb
6  */
7 
8 #ifndef FIELD_ELEMENTWISE_HH_
9 #define FIELD_ELEMENTWISE_HH_
10 
11 /**
12  * The simplest approximative Field. In future we want to replace it by pair: DofHandler + vector of dof values.
13  *
14  * In current setting:
15  * This should implement mapping: (ElementAccessor.INDEX) -> value
16  * Currently INDEX is global index of element (any dimension, both bulk and boundary part). In future INDEX should
17  * probably consist of MESH_LEVEL (unique mesh, dimension, bulk/boundary, level of refinement) and INDEX within this level.
18  * We want to make memory optimization since usually field lives either on boundary or on bulk part and some bulk fields live only on some dimension(s).
19  * This can be achieved by two level indirection table of mesh_levelscontaining tables for indexes. We should test if the performance penalty is not to big.
20  *
21  * Currently, we just use one vector for bulk and one for boundary elements.
22  *
23  * TODO:
24  * - move raw access resolution functions from FieldValues_ into FieldElementwise
25  * - allow elementwise int or FieldEnum data with optimal storage buffer, this needs
26  * templated GMSH reader
27  * - After this do following cleanup:
28  * Partitioning::subdomain_id_field_data should return vector<int>
29  * pertitioning_test.cpp should make correct test.
30  *
31  * - allow initialization of multiple fields by one reader
32  * - allow common storage for more elementwise fields to have values for one element on one place
33  */
34 
35 #include "system/system.hh"
37 
38 class GmshMeshReader;
39 
40 template <int spacedim, class Value>
41 class FieldElementwise : public FieldAlgorithmBase<spacedim, Value>
42 {
43 public:
45 
46  FieldElementwise(unsigned int n_comp=0);
47 
48  /**
49  * Alternative to previous constructor.
50  */
51  FieldElementwise(std::shared_ptr< std::vector<typename Value::element_type> > data, unsigned int n_components);
52 
54 
55  static Input::Type::Record get_input_type(Input::Type::AbstractRecord &a_type, const typename Value::ElementInputType *eit);
56 
57  virtual void init_from_input(const Input::Record &rec);
58 
59  /**
60  * Set row of boundary data. Used to implement old BC input.
61  */
62  void set_data_row(unsigned int boundary_idx, typename Value::return_type &value);
63 
64  /**
65  * Update time and possibly update data from GMSH file.
66  */
67  bool set_time(const TimeStep &time) override;
68 
69  /**
70  * Has to be set before calling init_from_input. This also
71  * allocate and initialize internal buffer. Do nothing if mesh is already set.
72  *
73  * See also description of the FieldBase<...>::set_mesh.
74  */
75  virtual void set_mesh(const Mesh *mesh, bool boundary_domain);
76 
77 
78  /**
79  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
80  */
81  virtual typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
82 
83  /**
84  * Returns std::vector of scalar values in several points at once.
85  */
86  virtual void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
88 
89 
90  virtual ~FieldElementwise();
91 
92 private:
93  /// Is flase whne the data vector is provided at construction. Then, we disallow initialization form input
94  /// and do not delete data pointer in destructor.
96  /**
97  * Is set in set_mesh method. Value true means, that we accept only boundary element accessors in the @p value method.
98  * TODO: temporary solution until we have separate mesh for the boundary part
99  */
101  /// Raw buffer of n_entities rows each containing Value::size() doubles.
102  std::shared_ptr< std::vector<typename Value::element_type> > data_;
103  /// Number of rows in @p data_ buffer.
104  unsigned int n_entities_;
105  /// Size of Value
106  unsigned int n_components_;
107 
109  const Mesh *mesh_;
110  std::string field_name_;
111 };
112 
113 
114 #endif /* FIELD_ELEMENTWISE_HH_ */
std::shared_ptr< std::vector< typename Value::element_type > > data_
Raw buffer of n_entities rows each containing Value::size() doubles.
static Input::Type::Record get_input_type(Input::Type::AbstractRecord &a_type, const typename Value::ElementInputType *eit)
virtual void init_from_input(const Input::Record &rec)
Definition: mesh.h:109
void set_data_row(unsigned int boundary_idx, typename Value::return_type &value)
bool set_time(const TimeStep &time) override
FieldAlgorithmBase< spacedim, Value >::Point Point
Accessor to the data with type Type::Record.
Definition: accessors.hh:327
FieldElementwise(unsigned int n_comp=0)
Class for declaration of polymorphic Record.
Definition: type_record.hh:487
Space< spacedim >::Point Point
static Input::Type::Record input_type
Implementation.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Dedicated class for storing path to input and output files.
Definition: file_path.hh:32
unsigned int n_components_
Size of Value.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
unsigned int n_entities_
Number of rows in data_ buffer.
virtual void set_mesh(const Mesh *mesh, bool boundary_domain)
Record type proxy class.
Definition: type_record.hh:169
Representation of one time step.
unsigned int n_comp() const