Flow123d  release_2.2.0-914-gf1a3a4f
field_fe.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file field_fe.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_FE_HH_
19 #define FIELD_FE_HH_
20 
21 #include "petscmat.h"
22 #include "system/system.hh"
24 #include "fields/vec_seq_double.hh"
26 #include "mesh/mesh.h"
27 #include "mesh/point.hh"
28 #include "mesh/bih_tree.hh"
29 #include "io/element_data_cache.hh"
30 #include "io/msh_basereader.hh"
31 #include "fem/dofhandler.hh"
32 #include "input/factory.hh"
33 
34 #include <memory>
35 
36 
37 
38 /**
39  * Class representing fields given by finite element approximation.
40  *
41  */
42 template <int spacedim, class Value>
43 class FieldFE : public FieldAlgorithmBase<spacedim, Value>
44 {
45 public:
48 
49  /**
50  * Default constructor, optionally we need number of components @p n_comp in the case of Vector valued fields.
51  */
52  FieldFE(unsigned int n_comp=0);
53 
54  /**
55  * Return Record for initialization of FieldFE that is derived from Abstract
56  */
57  static const Input::Type::Record & get_input_type();
58 
59  /**
60  * Return Input selection for discretization type (determines the section of VTK file).
61  */
63 
64  /**
65  * Setter for the finite element data. The mappings are required for computation of local coordinates.
66  * @param dh Dof handler.
67  * @param map1 1D mapping.
68  * @param map2 2D mapping.
69  * @param map3 3D mapping.
70  * @param data Vector of dof values.
71  */
72  void set_fe_data(std::shared_ptr<DOFHandlerMultiDim> dh,
73  MappingP1<1,3> *map1,
74  MappingP1<2,3> *map2,
75  MappingP1<3,3> *map3,
76  VectorSeqDouble *data);
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  * Initialization from the input interface.
91  */
92  virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data);
93 
94 
95  /**
96  * Update time and possibly update data from GMSH file.
97  */
98  bool set_time(const TimeStep &time) override;
99 
100 
101  /**
102  * Set target mesh.
103  */
104  void set_mesh(const Mesh *mesh, bool boundary_domain) override;
105 
106 
107  /**
108  * Copy data vector to given output ElementDataCache
109  */
110  void fill_data_to_cache(ElementDataCache<double> &output_data_cache);
111 
112 
113  /**
114  * Return size of vector of data stored in Field
115  */
116  inline unsigned int data_size() const {
117  return data_vec_->size();
118  }
119 
120 
121  /// Destructor.
122  virtual ~FieldFE();
123 
124 private:
125  /// Create DofHandler object
126  void make_dof_handler(const Mesh *mesh);
127 
128  /// Interpolate data over all elements of target mesh.
130 
131  /// Calculate native data over all elements of target mesh.
133 
134  /// DOF handler object
135  std::shared_ptr<DOFHandlerMultiDim> dh_;
136  /// Store data of Field
138  /// Array of indexes to data_vec_, used for get/set values
140 
141  /// Value handler that allows get value of 1D elements.
143  /// Value handler that allows get value of 2D elements.
145  /// Value handler that allows get value of 3D elements.
147 
148  /**
149  * Used in DOFHandler::distribute_dofs method. Represents 1D element.
150  *
151  * For correct functionality must be created proper descendant of FiniteElement class.
152  */
154  /// Same as previous, but represents 2D element.
156  /// Same as previous, but represents 3D element.
158 
159  /// mesh reader file
161 
162  /// field name read from input
163  std::string field_name_;
164 
165  /// Specify section where to find the field data in input mesh file
167 
168  /// Field flags.
170 
171  /// Registrar of class to factory
172  static const int registrar;
173 };
174 
175 
176 #endif /* FIELD_FE_HH_ */
virtual ~FieldFE()
Destructor.
Definition: field_fe.cc:354
Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between loca...
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Definition: field_fe.cc:143
std::shared_ptr< std::vector< T > > ComponentDataPtr
std::vector< IdxInt > dof_indices_
Array of indexes to data_vec_, used for get/set values.
Definition: field_fe.hh:139
void interpolate(ElementDataCache< double >::ComponentDataPtr data_vec)
Interpolate data over all elements of target mesh.
Definition: field_fe.cc:256
VectorSeqDouble * data_vec_
Store data of Field.
Definition: field_fe.hh:137
std::string field_name_
field name read from input
Definition: field_fe.hh:163
void fill_data_to_cache(ElementDataCache< double > &output_data_cache)
Definition: field_fe.cc:334
FEValueHandler< 2, spacedim, Value > value_handler2_
Value handler that allows get value of 2D elements.
Definition: field_fe.hh:144
FilePath reader_file_
mesh reader file
Definition: field_fe.hh:160
Definition: mesh.h:99
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
FieldAlgorithmBase< spacedim, Value >::Point Point
Definition: field_fe.hh:46
static const int registrar
Registrar of class to factory.
Definition: field_fe.hh:172
void set_mesh(const Mesh *mesh, bool boundary_domain) override
Definition: field_fe.cc:182
FEValueHandler< 3, spacedim, Value > value_handler3_
Value handler that allows get value of 3D elements.
Definition: field_fe.hh:146
bool set_time(const TimeStep &time) override
Definition: field_fe.cc:226
unsigned int size()
Getter for shared pointer of output data.
FieldAlgorithmBase< spacedim, Value > FactoryBaseType
Definition: field_fe.hh:47
unsigned int data_size() const
Definition: field_fe.hh:116
OutputTime::DiscreteSpace discretization_
Specify section where to find the field data in input mesh file.
Definition: field_fe.hh:166
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
Definition: field_fe.hh:135
static const Input::Type::Record & get_input_type()
Implementation.
Definition: field_fe.cc:42
FiniteElement< 2, 3 > * fe2_
Same as previous, but represents 2D element.
Definition: field_fe.hh:155
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Definition: field_fe.cc:121
Space< spacedim >::Point Point
void set_fe_data(std::shared_ptr< DOFHandlerMultiDim > dh, MappingP1< 1, 3 > *map1, MappingP1< 2, 3 > *map2, MappingP1< 3, 3 > *map3, VectorSeqDouble *data)
Definition: field_fe.cc:87
FEValueHandler< 1, spacedim, Value > value_handler1_
Value handler that allows get value of 1D elements.
Definition: field_fe.hh:142
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
static const Input::Type::Selection & get_disc_selection_input_type()
Definition: field_fe.cc:60
FieldFE(unsigned int n_comp=0)
Definition: field_fe.cc:79
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Definition: field_fe.cc:166
Record type proxy class.
Definition: type_record.hh:182
FiniteElement< 1, 3 > * fe1_
Definition: field_fe.hh:153
void calculate_native_values(ElementDataCache< double >::ComponentDataPtr data_cache)
Calculate native data over all elements of target mesh.
Definition: field_fe.cc:308
FieldFlag::Flags flags_
Field flags.
Definition: field_fe.hh:169
FiniteElement< 3, 3 > * fe3_
Same as previous, but represents 3D element.
Definition: field_fe.hh:157
Representation of one time step..
Template for classes storing finite set of named values.
void make_dof_handler(const Mesh *mesh)
Create DofHandler object.
Definition: field_fe.cc:194
Definition: field.hh:37
unsigned int n_comp() const