v0.8.23
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  /**
75  * \brief create ghost vector for problem (collective)
76  * \ingroup mofem_vectors
77 
78  collective - need to be run on all processors in communicator
79 
80  * \param name problem name
81  * \param RowColData specify what data is taken from Row, Col or Data
82  * \param Vec the vector where data is stored
83  */
84  MoFEMErrorCode vecCreateGhost(const std::string &name, RowColData rc,
85  SmartPetscObj<Vec> &v_ptr) const;
86 
87  /**
88  * \brief create scatter for vectors form one to another problem (collective)
89  * \ingroup mofem_vectors
90  *
91  * User specify what name of field on one problem is scattered to another.
92  *
93  * \ingroup mofem_vectors
94  *
95  * \param xin vector
96  * \param x_proble problem name
97  * \param x_field name
98  * \param yin vector
99  * \param y_problem problem name
100  * \param y_field_name
101  * \retval newctx scatter
102 
103  */
104  MoFEMErrorCode vecScatterCreate(Vec xin, const std::string &x_problem,
105  const std::string &x_field_name,
106  RowColData x_rc, Vec yin,
107  const std::string &y_problem,
108  const std::string &y_field_name,
109  RowColData y_rc, VecScatter *newctx) const;
110 
111  /**
112  * \brief create scatter for vectors form one to another problem (collective)
113  * \ingroup mofem_vectors
114  *
115  * \param xin vector
116  * \param x_proble problem name
117  * \param yin vector
118  * \param y_problem problem name
119  * \retval newctx scatter
120 
121  */
122  MoFEMErrorCode vecScatterCreate(Vec xin, const std::string &x_problem,
123  RowColData x_rc, Vec yin,
124  const std::string &y_problem, RowColData y_rc,
125  VecScatter *newctx) const;
126 
127  /**
128  * \brief set values of vector from/to meshdatabase
129  * \ingroup mofem_vectors
130  *
131  * \param pointer to problem struture
132  * \param RowColData for row or column:e (i.e. Row,Col)
133  * \param V vector
134  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
135  * \param scatter_mode see petsc manual for ScatterMode (The available modes
136  * are: SCATTER_FORWARD or SCATTER_REVERSE)
137  *
138  * SCATTER_REVERSE set data to field entities from V vector.
139  *
140  * SCATTER_FORWARD set vector V from data field entities
141  *
142  */
143  MoFEMErrorCode setLocalGhostVector(const Problem *problem_ptr, RowColData rc,
144  Vec V, InsertMode mode,
145  ScatterMode scatter_mode) const;
146 
147  /**
148  * \brief set values of vector from/to meshdatabase
149  * \ingroup mofem_vectors
150  *
151  * \param name of the problem
152  * \param RowColData for row or column:e (i.e. Row,Col)
153  * \param V vector
154  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
155  * \param scatter_mode see petsc manual for ScatterMode (The available modes
156  * are: SCATTER_FORWARD or SCATTER_REVERSE)
157  *
158  * SCATTER_REVERSE set data to field entities from V vector.
159  *
160  * SCATTER_FORWARD set vector V from data field entities
161  *
162  */
163  MoFEMErrorCode setLocalGhostVector(const std::string &name, RowColData rc,
164  Vec V, InsertMode mode,
165  ScatterMode scatter_mode) const;
166 
167  /**
168  * \brief set values of vector from/to mesh database (collective)
169  * \ingroup mofem_vectors
170 
171  collective - need tu be run on all processors in communicator
172 
173  * \param pointer to porblem struture
174  * \param RowColData for row or column (i.e. Row,Col)
175  * \param V vector
176  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
177  * \param scatter_mode see petsc manual for ScatterMode (The available modes
178  are: SCATTER_FORWARD or SCATTER_REVERSE)
179  *
180  * SCATTER_REVERSE set data to field entities form V vector.
181  *
182  */
183  MoFEMErrorCode setGlobalGhostVector(const Problem *problem_ptr, RowColData rc,
184  Vec V, InsertMode mode,
185  ScatterMode scatter_mode) const;
186 
187  /**
188  * \brief set values of vector from/to mesh database (collective)
189  * \ingroup mofem_vectors
190 
191  collective - need tu be run on all processors in communicator
192 
193  * \param name of the problem
194  * \param RowColData for row or column (i.e. Row,Col)
195  * \param V vector
196  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
197  * \param scatter_mode see petsc manual for ScatterMode (The available modes
198  are: SCATTER_FORWARD or SCATTER_REVERSE)
199  *
200  * SCATTER_REVERSE set data to field entities form V vector.
201  *
202  */
203  MoFEMErrorCode setGlobalGhostVector(const std::string &name, RowColData rc,
204  Vec V, InsertMode mode,
205  ScatterMode scatter_mode) const;
206 
207  /**
208  * \brief Copy vector to field which is not part of the problem
209  * \ingroup mofem_vectors
210  *
211  * \param pointer to problem multi_index
212  * \param field_name field name used for indexing petsc vectors used in the
213  * problem \param cpy_field field name where data from vector are stored
214  * \param RowColData for row or column
215  * \param V vector
216  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
217  * \param scatter_mode see petsc manual for ScatterMode (The available modes
218  * are: SCATTER_FORWARD or SCATTER_REVERSE)
219  *
220  * SCATTER_REVERSE set data to field entities form V vector.
221  *
222  */
224  const std::string &field_name,
225  const std::string &cpy_field_name,
226  RowColData rc, Vec V, InsertMode mode,
227  ScatterMode scatter_mode) const;
228 
229  /**
230  * \brief Copy vector to field which is not part of the problem
231  * \ingroup mofem_vectors
232  *
233  * \param name problem name
234  * \param field_name field name used for indexing petsc vectors used in the
235  * problem \param cpy_field field name where data from vector are stored
236  * \param RowColData for row or column
237  * \param V vector
238  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
239  * \param scatter_mode see petsc manual for ScatterMode (The available modes
240  * are: SCATTER_FORWARD or SCATTER_REVERSE)
241  *
242  * SCATTER_REVERSE set data to field entities form V vector.
243  *
244  */
245  MoFEMErrorCode setOtherLocalGhostVector(const std::string &name,
246  const std::string &field_name,
247  const std::string &cpy_field_name,
248  RowColData rc, Vec V, InsertMode mode,
249  ScatterMode scatter_mode) const;
250 
251  /** \brief Copy vector to field which is not part of the problem (collective)
252  * \ingroup mofem_vectors
253 
254  collective - need tu be run on all processors in communicator
255 
256  * \param problem_ptr pointer to problem
257  * \param field_name field name used for indexing petsc vectors used in the
258  problem
259  * \param cpy_field field name where data from vector are stored
260  * \param RowColData for row or column
261  * \param V vector
262  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
263  * \param scatter_mode see petsc manual for ScatterMode (The available modes
264  are: SCATTER_FORWARD or SCATTER_REVERSE)
265  *
266  * SCATTER_REVERSE set data to field entities form V vector.
267  *
268  */
270  const std::string &field_name,
271  const std::string &cpy_field_name,
272  RowColData rc, Vec V,
273  InsertMode mode,
274  ScatterMode scatter_mode) const;
275 
276  /** \deprecated VecManager
277  * \brief Copy vector to field which is not part of the problem (collective)
278  * \ingroup mofem_vectors
279 
280  collective - need tu be run on all processors in communicator
281 
282  * \param name problem name
283  * \param field_name field name used for indexing petsc vectors used in the
284  problem
285  * \param cpy_field field name where data from vector are stored
286  * \param RowColData for row or column
287  * \param V vector
288  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
289  * \param scatter_mode see petsc manual for ScatterMode (The available modes
290  are: SCATTER_FORWARD or SCATTER_REVERSE)
291  *
292  * SCATTER_REVERSE set data to field entities form V vector.
293  *
294  */
295  MoFEMErrorCode setOtherGlobalGhostVector(const std::string &name,
296  const std::string &field_name,
297  const std::string &cpy_field_name,
298  RowColData rc, Vec V,
299  InsertMode mode,
300  ScatterMode scatter_mode) const;
301 };
302 
303 } // namespace MoFEM
304 
305 #endif //__VECMANAGER_HPP__
306 
307 /**
308  * \defgroup mofem_vectors Vectors (Vec)
309  * \brief Creating and scattering vectors on the mesh for given problem
310  *
311  * \ingroup mofem
312  **/
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:364
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:185
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:158
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:260
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:495
intrusive_ptr for managing petsc objects
Definition: AuxPETSc.hpp:124