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