v0.14.0
VecManager.hpp
Go to the documentation of this file.
1 /** \file VecManager.hpp
2  * \brief Interface managing vectors
3  * \ingroup mofem_vectors
4  *
5  * Managing problems, build and partitioning.
6  *
7  */
8 
9 #ifndef __VECMANAGER_HPP__
10 #define __VECMANAGER_HPP__
11 
12 #include "UnknownInterface.hpp"
13 
14 namespace MoFEM {
15 
16 /**
17  * \brief Vector manager is used to create vectors
18  * \mofem_vectors
19  *
20  * Managing Vectors, creation, scatter, etc.
21  *
22  */
23 struct VecManager : public UnknownInterface {
24 
25  MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
26  UnknownInterface **iface) const;
27 
29  bool dEbug;
30 
31  VecManager(const MoFEM::Core &core);
32 
33  ~VecManager() = default;
34 
35  /** \brief create local vector for problem
36  * \ingroup mofem_vectors
37  *
38  * \param name problem name
39  * \param RowColData specify what data is taken from Row, Col or Data
40  * \param Vec the vector where data is stored
41  */
42  MoFEMErrorCode vecCreateSeq(const std::string name, RowColData rc,
43  Vec *V) const;
44 
45  /**
46  * \brief create ghost vector for problem (collective)
47  * \ingroup mofem_vectors
48 
49  collective - need to be run on all processors in communicator
50 
51  * \param name problem name
52  * \param RowColData specify what data is taken from Row, Col or Data
53  * \param Vec the vector where data is stored
54  */
55  MoFEMErrorCode vecCreateGhost(const std::string name, RowColData rc,
56  Vec *V) const;
57 
58  /** @copydoc MoFEM::VecManager::vecCreateGhost
59  */
60  MoFEMErrorCode vecCreateGhost(const std::string name, RowColData rc,
61  SmartPetscObj<Vec> &v_ptr) const;
62 
63  /**
64  * \brief create scatter for vectors form one to another problem (collective)
65  * \ingroup mofem_vectors
66  *
67  * User specify what name of field on one problem is scattered to another.
68  *
69  * \ingroup mofem_vectors
70  *
71  * \param xin vector
72  * \param x_proble problem name
73  * \param x_field name
74  * \param yin vector
75  * \param y_problem problem name
76  * \param y_field_name
77  * \retval newctx scatter
78 
79  */
80  MoFEMErrorCode vecScatterCreate(Vec xin, const std::string x_problem,
81  const std::string x_field_name,
82  RowColData x_rc, Vec yin,
83  const std::string y_problem,
84  const std::string y_field_name,
85  RowColData y_rc, VecScatter *newctx) const;
86 
87  /** @copydoc MoFEM::VecManager::vecScatterCreate
88  */
90  vecScatterCreate(Vec xin, const std::string x_problem,
91  const std::string x_field_name, RowColData x_rc, Vec yin,
92  const std::string y_problem, const std::string y_field_name,
93  RowColData y_rc,
94  SmartPetscObj<VecScatter> &smart_newctx) const;
95 
96  /**
97  * \brief create scatter for vectors from one to another problem (collective)
98  * \ingroup mofem_vectors
99  *
100  * \param xin vector
101  * \param x_proble problem name
102  * \param yin vector
103  * \param y_problem problem name
104  * \retval newctx scatter
105 
106  */
107  MoFEMErrorCode vecScatterCreate(Vec xin, const std::string x_problem,
108  RowColData x_rc, Vec yin,
109  const std::string y_problem, RowColData y_rc,
110  VecScatter *newctx) const;
111 
112  /** @copydoc MoFEM::VecManager::vecScatterCreate
113  */
115  vecScatterCreate(Vec xin, const std::string x_problem, RowColData x_rc,
116  Vec yin, const std::string y_problem, RowColData y_rc,
117  SmartPetscObj<VecScatter> &smart_newctx) const;
118 
119  /**
120  * \brief set values of vector from/to mesh database
121  * \ingroup mofem_vectors
122  *
123  * \param pointer to problem struture
124  * \param RowColData for row or column:e (i.e. Row,Col)
125  * \param V vector
126  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
127  * \param scatter_mode see petsc manual for ScatterMode (The available modes
128  * are: SCATTER_FORWARD or SCATTER_REVERSE)
129  *
130  * SCATTER_REVERSE set data to field entities from V vector.
131  *
132  * SCATTER_FORWARD set vector V from data field entities
133  *
134  */
135  MoFEMErrorCode setLocalGhostVector(const Problem *problem_ptr, RowColData rc,
136  Vec V, InsertMode mode,
137  ScatterMode scatter_mode) const;
138 
139  /**
140  * \brief set values of vector from/to mesh database
141  * \ingroup mofem_vectors
142  *
143  * \param name of the problem
144  * \param RowColData for row or column:e (i.e. Row,Col)
145  * \param V vector
146  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
147  * \param scatter_mode see petsc manual for ScatterMode (The available modes
148  * are: SCATTER_FORWARD or SCATTER_REVERSE)
149  *
150  * SCATTER_REVERSE set data to field entities from V vector.
151  *
152  * SCATTER_FORWARD set vector V from data field entities
153  *
154  */
155  MoFEMErrorCode setLocalGhostVector(const std::string name, RowColData rc,
156  Vec V, InsertMode mode,
157  ScatterMode scatter_mode) const;
158 
159  /**
160  * \brief set values of vector from/to mesh database (collective)
161  * \ingroup mofem_vectors
162 
163  collective - need tu be run on all processors in communicator
164 
165  * \param pointer to porblem struture
166  * \param RowColData for row or column (i.e. Row,Col)
167  * \param V vector
168  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
169  * \param scatter_mode see petsc manual for ScatterMode (The available modes
170  are: SCATTER_FORWARD or SCATTER_REVERSE)
171  *
172  * SCATTER_REVERSE set data to field entities form V vector.
173  *
174  */
175  MoFEMErrorCode setGlobalGhostVector(const Problem *problem_ptr, RowColData rc,
176  Vec V, InsertMode mode,
177  ScatterMode scatter_mode) const;
178 
179  /**
180  * \brief set values of vector from/to mesh database (collective)
181  * \ingroup mofem_vectors
182 
183  collective - need tu be run on all processors in communicator
184 
185  * \param name of the problem
186  * \param RowColData for row or column (i.e. Row,Col)
187  * \param V vector
188  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
189  * \param scatter_mode see petsc manual for ScatterMode (The available modes
190  are: SCATTER_FORWARD or SCATTER_REVERSE)
191  *
192  * SCATTER_REVERSE set data to field entities form V vector.
193  *
194  */
195  MoFEMErrorCode setGlobalGhostVector(const std::string name, RowColData rc,
196  Vec V, InsertMode mode,
197  ScatterMode scatter_mode) const;
198 
199  /**
200  * \brief Copy vector to field which is not part of the problem
201  * \ingroup mofem_vectors
202  *
203  * \param pointer to problem multi_index
204  * \param field_name field name used for indexing petsc vectors used in the
205  * problem \param cpy_field field name where data from vector are stored
206  * \param RowColData for row or column
207  * \param V vector
208  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
209  * \param scatter_mode see petsc manual for ScatterMode (The available modes
210  * are: SCATTER_FORWARD or SCATTER_REVERSE)
211  *
212  * SCATTER_REVERSE set data to field entities form V vector.
213  *
214  */
216  const std::string field_name,
217  const std::string cpy_field_name,
218  RowColData rc, Vec V, InsertMode mode,
219  ScatterMode scatter_mode) const;
220 
221  /**
222  * \brief Copy vector to field which is not part of the problem
223  * \ingroup mofem_vectors
224  *
225  * \param name problem name
226  * \param field_name field name used for indexing petsc vectors used in the
227  * problem \param cpy_field field name where data from vector are stored
228  * \param RowColData for row or column
229  * \param V vector
230  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
231  * \param scatter_mode see petsc manual for ScatterMode (The available modes
232  * are: SCATTER_FORWARD or SCATTER_REVERSE)
233  *
234  * SCATTER_REVERSE set data to field entities form V vector.
235  *
236  */
237  MoFEMErrorCode setOtherLocalGhostVector(const std::string name,
238  const std::string field_name,
239  const std::string cpy_field_name,
240  RowColData rc, Vec V, InsertMode mode,
241  ScatterMode scatter_mode) const;
242 
243  /** \brief Copy vector to field which is not part of the problem (collective)
244  * \ingroup mofem_vectors
245 
246  collective - need tu be run on all processors in communicator
247 
248  * \param problem_ptr pointer to problem
249  * \param field_name field name used for indexing petsc vectors used in the
250  problem
251  * \param cpy_field field name where data from vector are stored
252  * \param RowColData for row or column
253  * \param V vector
254  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
255  * \param scatter_mode see petsc manual for ScatterMode (The available modes
256  are: SCATTER_FORWARD or SCATTER_REVERSE)
257  *
258  * SCATTER_REVERSE set data to field entities form V vector.
259  *
260  */
262  const std::string field_name,
263  const std::string cpy_field_name,
264  RowColData rc, Vec V,
265  InsertMode mode,
266  ScatterMode scatter_mode) const;
267 
268  /** \deprecated VecManager
269  * \brief Copy vector to field which is not part of the problem (collective)
270  * \ingroup mofem_vectors
271 
272  collective - need tu be run on all processors in communicator
273 
274  * \param name problem name
275  * \param field_name field name used for indexing petsc vectors used in the
276  problem
277  * \param cpy_field field name where data from vector are stored
278  * \param RowColData for row or column
279  * \param V vector
280  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
281  * \param scatter_mode see petsc manual for ScatterMode (The available modes
282  are: SCATTER_FORWARD or SCATTER_REVERSE)
283  *
284  * SCATTER_REVERSE set data to field entities form V vector.
285  *
286  */
287  MoFEMErrorCode setOtherGlobalGhostVector(const std::string name,
288  const std::string field_name,
289  const std::string cpy_field_name,
290  RowColData rc, Vec V,
291  InsertMode mode,
292  ScatterMode scatter_mode) const;
293 };
294 
295 } // namespace MoFEM
296 
297 #endif //__VECMANAGER_HPP__
298 
299 /**
300  * \defgroup mofem_vectors Vectors (Vec)
301  * \brief Creating and scattering vectors on the mesh for given problem
302  *
303  * \ingroup mofem
304  **/
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::VecManager::vecCreateSeq
MoFEMErrorCode vecCreateSeq(const std::string name, RowColData rc, Vec *V) const
create local vector for problem
Definition: VecManager.cpp:38
MoFEM::VecManager::setOtherLocalGhostVector
MoFEMErrorCode setOtherLocalGhostVector(const Problem *problem_ptr, const std::string field_name, const std::string cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
Copy vector to field which is not part of the problem.
Definition: VecManager.cpp:413
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::VecManager::setOtherGlobalGhostVector
MoFEMErrorCode setOtherGlobalGhostVector(const Problem *problem_ptr, const std::string field_name, const std::string cpy_field_name, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
Copy vector to field which is not part of the problem (collective)
Definition: VecManager.cpp:544
MoFEM::VecManager::vecCreateGhost
MoFEMErrorCode vecCreateGhost(const std::string name, RowColData rc, Vec *V) const
create ghost vector for problem (collective)
Definition: VecManager.cpp:64
MoFEM::VecManager::~VecManager
~VecManager()=default
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::VecManager::cOre
const MoFEM::Interface & cOre
Definition: VecManager.hpp:28
MoFEM::VecManager::vecScatterCreate
MoFEMErrorCode vecScatterCreate(Vec xin, const std::string x_problem, const std::string x_field_name, RowColData x_rc, Vec yin, const std::string y_problem, const std::string y_field_name, RowColData y_rc, VecScatter *newctx) const
create scatter for vectors form one to another problem (collective)
Definition: VecManager.cpp:131
RowColData
RowColData
RowColData.
Definition: definitions.h:136
MoFEM::VecManager::dEbug
bool dEbug
Definition: VecManager.hpp:29
UnknownInterface.hpp
MoFEM interface.
MoFEM::VecManager
Vector manager is used to create vectors \mofem_vectors.
Definition: VecManager.hpp:23
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::VecManager::setLocalGhostVector
MoFEMErrorCode setLocalGhostVector(const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
set values of vector from/to mesh database
Definition: VecManager.cpp:202
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
MoFEM::VecManager::setGlobalGhostVector
MoFEMErrorCode setGlobalGhostVector(const Problem *problem_ptr, RowColData rc, Vec V, InsertMode mode, ScatterMode scatter_mode) const
set values of vector from/to mesh database (collective)
Definition: VecManager.cpp:301
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MoFEM::VecManager::VecManager
VecManager(const MoFEM::Core &core)
Definition: VecManager.cpp:14
MoFEM::Problem
keeps basic data about problem
Definition: ProblemsMultiIndices.hpp:54
MoFEM::SmartPetscObj< Vec >
MoFEM::VecManager::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: VecManager.cpp:8