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 
27 
28  /**
29  * \brief Vector manager is used to create vectors
30  * \mofem_vectors
31  *
32  * Managing Vectors, creation, scatter, etc.
33  *
34  */
35  struct VecManager: public UnknownInterface {
36 
37  MoFEMErrorCode query_interface(const MOFEMuuid& uuid, UnknownInterface** iface) const;
38 
40  bool dEbug;
41 
42  VecManager(const MoFEM::Core& core);
43 
44  /**
45  * \brief Destructor
46  */
47  ~VecManager();
48 
49  /** \brief create local vector for problem
50  * \ingroup mofem_vectors
51  *
52  * \param name problem name
53  * \param RowColData specify what data is taken from Row, Col or Data
54  * \param Vec the vector where data is stored
55  */
56  MoFEMErrorCode vecCreateSeq(const std::string &name,RowColData rc,Vec *V) const;
57 
58 
59  /**
60  * \brief create ghost vector for problem (collective)
61  * \ingroup mofem_vectors
62 
63  collective - need to be run on all processors in communicator
64 
65  * \param name problem name
66  * \param RowColData specify what data is taken from Row, Col or Data
67  * \param Vec the vector where data is stored
68  */
69  MoFEMErrorCode vecCreateGhost(const std::string &name,RowColData rc,Vec *V) const;
70 
71  /**
72  * \brief create scatter for vectors form one to another problem (collective)
73  * \ingroup mofem_vectors
74  *
75  * User specify what name of field on one problem is scattered to another.
76  *
77  * \ingroup mofem_vectors
78  *
79  * \param xin vector
80  * \param x_proble problem name
81  * \param x_field name
82  * \param yin vector
83  * \param y_problem problem name
84  * \param y_field_name
85  * \retval newctx scatter
86 
87  */
89  Vec xin,const std::string &x_problem,const std::string &x_field_name,RowColData x_rc,
90  Vec yin,const std::string &y_problem,const std::string &y_field_name,RowColData y_rc,
91  VecScatter *newctx
92  ) const;
93 
94  /**
95  * \brief create scatter for vectors form one to another problem (collective)
96  * \ingroup mofem_vectors
97  *
98  * \param xin vector
99  * \param x_proble problem name
100  * \param yin vector
101  * \param y_problem problem name
102  * \retval newctx scatter
103 
104  */
106  Vec xin,const std::string &x_problem,RowColData x_rc,
107  Vec yin,const std::string &y_problem,RowColData y_rc,
108  VecScatter *newctx
109  ) const;
110 
111  /**
112  * \brief set values of vector from/to meshdatabase
113  * \ingroup mofem_vectors
114  *
115  * \param pointer to problem struture
116  * \param RowColData for row or column:e (i.e. Row,Col)
117  * \param V vector
118  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
119  * \param scatter_mode see petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)
120  *
121  * SCATTER_REVERSE set data to field entities from V vector.
122  *
123  * SCATTER_FORWARD set vector V from data field entities
124  *
125  */
127  const Problem *problem_ptr,RowColData rc,Vec V,InsertMode mode,ScatterMode scatter_mode
128  ) const;
129 
130  /**
131  * \brief set values of vector from/to meshdatabase
132  * \ingroup mofem_vectors
133  *
134  * \param name of the problem
135  * \param RowColData for row or column:e (i.e. Row,Col)
136  * \param V vector
137  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
138  * \param scatter_mode see petsc manual for ScatterMode (The available modes 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  */
146  const std::string &name,RowColData rc,Vec V,InsertMode mode,ScatterMode scatter_mode
147  ) const;
148 
149  /**
150  * \brief set values of vector from/to mesh database (collective)
151  * \ingroup mofem_vectors
152 
153  collective - need tu be run on all processors in communicator
154 
155  * \param pointer to porblem struture
156  * \param RowColData for row or column (i.e. Row,Col)
157  * \param V vector
158  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
159  * \param scatter_mode see petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)
160  *
161  * SCATTER_REVERSE set data to field entities form V vector.
162  *
163  */
165  const Problem *problem_ptr,RowColData rc,Vec V,InsertMode mode,ScatterMode scatter_mode
166  ) const;
167 
168  /**
169  * \brief set values of vector from/to mesh database (collective)
170  * \ingroup mofem_vectors
171 
172  collective - need tu be run on all processors in communicator
173 
174  * \param name of the problem
175  * \param RowColData for row or column (i.e. Row,Col)
176  * \param V vector
177  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
178  * \param scatter_mode see petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)
179  *
180  * SCATTER_REVERSE set data to field entities form V vector.
181  *
182  */
184  const std::string &name,RowColData rc,Vec V,InsertMode mode,ScatterMode scatter_mode
185  ) const;
186 
187  /**
188  * \brief Copy vector to field which is not part of the problem
189  * \ingroup mofem_vectors
190  *
191  * \param pointer to problem multi_index
192  * \param field_name field name used for indexing petsc vectors used in the problem
193  * \param cpy_field field name where data from vector are stored
194  * \param RowColData for row or column
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 are: SCATTER_FORWARD or SCATTER_REVERSE)
198  *
199  * SCATTER_REVERSE set data to field entities form V vector.
200  *
201  */
203  const Problem *problem_ptr,const std::string& field_name,const std::string& cpy_field_name,RowColData rc,
204  Vec V,InsertMode mode,ScatterMode scatter_mode
205  ) const;
206 
207  /**
208  * \brief Copy vector to field which is not part of the problem
209  * \ingroup mofem_vectors
210  *
211  * \param name problem name
212  * \param field_name field name used for indexing petsc vectors used in the problem
213  * \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 are: SCATTER_FORWARD or SCATTER_REVERSE)
218  *
219  * SCATTER_REVERSE set data to field entities form V vector.
220  *
221  */
223  const std::string &name,const std::string& field_name,const std::string& cpy_field_name,RowColData rc,
224  Vec V,InsertMode mode,ScatterMode scatter_mode
225  ) const;
226 
227  /** \brief Copy vector to field which is not part of the problem (collective)
228  * \ingroup mofem_vectors
229 
230  collective - need tu be run on all processors in communicator
231 
232  * \param problem_ptr pointer to problem
233  * \param field_name field name used for indexing petsc vectors used in the problem
234  * \param cpy_field field name where data from vector are stored
235  * \param RowColData for row or column
236  * \param V vector
237  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
238  * \param scatter_mode see petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)
239  *
240  * SCATTER_REVERSE set data to field entities form V vector.
241  *
242  */
244  const Problem *problem_ptr,
245  const std::string& field_name,
246  const std::string& cpy_field_name,
247  RowColData rc,
248  Vec V,
249  InsertMode mode,
250  ScatterMode scatter_mode
251  ) const;
252 
253  /** \deprecated VecManager
254  * \brief Copy vector to field which is not part of the problem (collective)
255  * \ingroup mofem_vectors
256 
257  collective - need tu be run on all processors in communicator
258 
259  * \param name problem name
260  * \param field_name field name used for indexing petsc vectors used in the 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 are: SCATTER_FORWARD or SCATTER_REVERSE)
266  *
267  * SCATTER_REVERSE set data to field entities form V vector.
268  *
269  */
271  const std::string& name,
272  const std::string& field_name,
273  const std::string& cpy_field_name,
274  RowColData rc,
275  Vec V,
276  InsertMode mode,
277  ScatterMode scatter_mode
278  ) const;
279 
280  };
281 
282 }
283 
284 #endif //__VECMANAGER_HPP__
285 
286 /***************************************************************************//**
287  * \defgroup mofem_vectors Vectors (Vec)
288  * \brief Creating and scattering vectors on the mesh for given problem
289  *
290  * \ingroup mofem
291  ******************************************************************************/
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:325
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:39
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:148
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:250
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:102
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:35
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:451