Flow123d  intersections_paper-476-gbe68821
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"
30 #include "fem/dofhandler.hh"
31 #include "input/factory.hh"
32 
33 #include <memory>
34 
35 
36 
37 /**
38  * Class representing fields given by finite element approximation.
39  *
40  */
41 template <int spacedim, class Value>
42 class FieldFE : public FieldAlgorithmBase<spacedim, Value>
43 {
44 public:
47 
48  /**
49  * Default constructor, optionally we need number of components @p n_comp in the case of Vector valued fields.
50  */
51  FieldFE(unsigned int n_comp=0);
52 
53  /**
54  * Return Record for initialization of FieldFE that is derived from Abstract
55  */
56  static const Input::Type::Record & get_input_type();
57 
58  /**
59  * Setter for the finite element data. The mappings are required for computation of local coordinates.
60  * @param dh Dof handler.
61  * @param map1 1D mapping.
62  * @param map2 2D mapping.
63  * @param map3 3D mapping.
64  * @param data Vector of dof values.
65  */
66  void set_fe_data(std::shared_ptr<DOFHandlerMultiDim> dh,
67  MappingP1<1,3> *map1,
68  MappingP1<2,3> *map2,
69  MappingP1<3,3> *map3,
70  VectorSeqDouble *data);
71 
72  /**
73  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
74  */
75  virtual typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
76 
77  /**
78  * Returns std::vector of scalar values in several points at once.
79  */
80  virtual void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
82 
83  /**
84  * Initialization from the input interface.
85  */
86  virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data);
87 
88 
89  /**
90  * Update time and possibly update data from GMSH file.
91  */
92  bool set_time(const TimeStep &time) override;
93 
94 
95  /**
96  * Set target mesh.
97  */
98  void set_mesh(const Mesh *mesh, bool boundary_domain) override;
99 
100 
101  /// Destructor.
102  virtual ~FieldFE();
103 
104 private:
105  /// Create DofHandler object
106  void make_dof_handler(const Mesh *mesh);
107 
108  /// Interpolate data over all elements of target mesh.
110 
111  /// DOF handler object
112  std::shared_ptr<DOFHandlerMultiDim> dh_;
113  /// Store data of Field
115  /// Array of indexes to data_vec_, used for get/set values
116  unsigned int *dof_indices;
117 
118  /// Value handler that allows get value of 1D elements.
120  /// Value handler that allows get value of 2D elements.
122  /// Value handler that allows get value of 3D elements.
124 
125  /**
126  * Used in DOFHandler::distribute_dofs method. Represents 1D element.
127  *
128  * For correct functionality must be created proper descendant of FiniteElement class.
129  */
131  /// Same as previous, but represents 2D element.
133  /// Same as previous, but represents 3D element.
135 
136  /// mesh reader file
138 
139  /// field name read from input
140  std::string field_name_;
141 
142  /// Field flags.
144 
145  /// Registrar of class to factory
146  static const int registrar;
147 };
148 
149 
150 #endif /* FIELD_FE_HH_ */
virtual ~FieldFE()
Destructor.
Definition: field_fe.cc:281
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:121
std::shared_ptr< std::vector< T > > ComponentDataPtr
void interpolate(ElementDataCache< double >::ComponentDataPtr data_vec)
Interpolate data over all elements of target mesh.
Definition: field_fe.cc:228
VectorSeqDouble * data_vec_
Store data of Field.
Definition: field_fe.hh:114
std::string field_name_
field name read from input
Definition: field_fe.hh:140
FEValueHandler< 2, spacedim, Value > value_handler2_
Value handler that allows get value of 2D elements.
Definition: field_fe.hh:121
FilePath reader_file_
mesh reader file
Definition: field_fe.hh:137
Definition: mesh.h:95
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
FieldAlgorithmBase< spacedim, Value >::Point Point
Definition: field_fe.hh:45
static const int registrar
Registrar of class to factory.
Definition: field_fe.hh:146
void set_mesh(const Mesh *mesh, bool boundary_domain) override
Definition: field_fe.cc:157
FEValueHandler< 3, spacedim, Value > value_handler3_
Value handler that allows get value of 3D elements.
Definition: field_fe.hh:123
bool set_time(const TimeStep &time) override
Definition: field_fe.cc:200
FieldAlgorithmBase< spacedim, Value > FactoryBaseType
Definition: field_fe.hh:46
unsigned int * dof_indices
Array of indexes to data_vec_, used for get/set values.
Definition: field_fe.hh:116
std::shared_ptr< DOFHandlerMultiDim > dh_
DOF handler object.
Definition: field_fe.hh:112
static const Input::Type::Record & get_input_type()
Implementation.
Definition: field_fe.cc:39
FiniteElement< 2, 3 > * fe2_
Same as previous, but represents 2D element.
Definition: field_fe.hh:132
Accessor to the data with type Type::Record.
Definition: accessors.hh:286
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Definition: field_fe.cc:99
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:68
FEValueHandler< 1, spacedim, Value > value_handler1_
Value handler that allows get value of 1D elements.
Definition: field_fe.hh:119
Dedicated class for storing path to input and output files.
Definition: file_path.hh:48
FieldFE(unsigned int n_comp=0)
Definition: field_fe.cc:59
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Definition: field_fe.cc:144
Record type proxy class.
Definition: type_record.hh:177
FiniteElement< 1, 3 > * fe1_
Definition: field_fe.hh:130
FieldFlag::Flags flags_
Field flags.
Definition: field_fe.hh:143
FiniteElement< 3, 3 > * fe3_
Same as previous, but represents 3D element.
Definition: field_fe.hh:134
Representation of one time step..
void make_dof_handler(const Mesh *mesh)
Create DofHandler object.
Definition: field_fe.cc:168
unsigned int n_comp() const