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