v0.13.1
Loading...
Searching...
No Matches
ProblemsManager.hpp
Go to the documentation of this file.
1/** \file ProblemsManager.hpp
2 * \brief Interface managing problems
3 * \ingroup mofem_problems_manager
4 *
5 * Managing problems, build and partitioning.
6 *
7 */
8
9#ifndef __PROBLEMSMANAGER_HPP__
10#define __PROBLEMSMANAGER_HPP__
11
12#include "UnknownInterface.hpp"
13
14namespace MoFEM {
15
16/**
17 * \brief Problem manager is used to build and partition problems
18 * \ingroup mofem_problems_manager
19 *
20 */
22
23 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
24 UnknownInterface **iface) const;
25
27 ProblemsManager(const MoFEM::Core &core);
28 virtual ~ProblemsManager() = default;
29
30 PetscBool buildProblemFromFields; ///< If set to true, problem is build from
31 /// DOFs in fields, not from DOFs on elements
32
34
36
37 /**
38 * \brief Set partition tag to each finite element in the problem
39 * \deprecated Use CommInterface
40 * \ingroup mofem_problems_manager
41 *
42 * This will use one of the mesh partitioning programs available from PETSc
43 * See
44 * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatPartitioningType.html>
45 *
46 * @param ents Entities to partition
47 * @param dim Dimension of entities to partition
48 * @param adj_dim Adjacency dimension
49 * @param n_parts Number of partitions
50 * @param verb Verbosity level
51 * @return Error code
52 */
53 DEPRECATED MoFEMErrorCode partitionMesh(const Range &ents, const int dim,
54 const int adj_dim, const int n_parts,
55 Tag *th_vertex_weights = nullptr,
56 Tag *th_edge_weights = nullptr,
57 Tag *th_part_weights = nullptr,
58 int verb = VERBOSE,
59 const bool debug = false);
60
61 /** \brief build problem data structures
62 * \ingroup mofem_problems_manager
63 *
64 * \note If square_matrix is set to true, that indicate that problem is
65 * structurally
66 * symmetric, i.e. rows and columns have the same dofs and are indexed in the
67 * same
68 * way.
69 *
70 * @param name problem name
71 * @param square_matrix structurally symmetric problem
72 * @param verb verbosity level
73 * @return error code
74 *
75 */
76 MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix,
77 int verb = VERBOSE);
78
79 /** \brief build problem data structures
80 * \ingroup mofem_problems_manager
81 *
82 * \note If square_matrix is set to true, that indicate that problem is
83 * structurally
84 * symmetric, i.e. rows and columns have the same dofs and are indexed in the
85 * same
86 * way.
87 *
88 * @param problem pointer
89 * @param square_matrix structurally symmetric problem
90 * @param verb verbosity level
91 * @return error code
92 *
93 */
94 MoFEMErrorCode buildProblem(Problem *problem_ptr, const bool square_matrix,
95 int verb = VERBOSE);
96
97 /** \brief build problem data structures, assuming that mesh is distributed
98 (collective)
99 * \ingroup mofem_problems_manager
100
101 Mesh is distributed, that means that each processor keeps only own part of
102 the mesh and shared entities.
103
104 Collective - need to be run on all processors in communicator, i.e. each
105 function has to call this function.
106
107 */
108 MoFEMErrorCode buildProblemOnDistributedMesh(const std::string name,
109 const bool square_matrix,
110 int verb = VERBOSE);
111
112 /** \brief build problem data structures, assuming that mesh is distributed
113 (collective)
114 * \ingroup mofem_problems_manager
115
116 Mesh is distributed, that means that each processor keeps only own part of
117 the mesh and shared entities.
118
119 Collective - need to be run on all processors in communicator, i.e. each
120 function has to call this function.
121
122 */
124 const bool square_matrix = true,
125 int verb = VERBOSE);
126
127 /**
128 * \brief build sub problem
129 * \ingroup mofem_problems_manager
130 *
131 * @param out_name problem
132 * @param fields_row vector of fields composing problem
133 * @param fields_col vector of fields composing problem
134 * @param main_problem main problem
135 * @return error code
136 */
138 const std::string out_name, const std::vector<std::string> &fields_row,
139 const std::vector<std::string> &fields_col,
140 const std::string main_problem, const bool square_matrix = true,
141 const map<std::string, std::pair<EntityType, EntityType>> *entityMapRow =
142 nullptr,
143 const map<std::string, std::pair<EntityType, EntityType>> *entityMapCol =
144 nullptr,
145 int verb = VERBOSE);
146
147 /**
148 * \brief build composite problem
149 * \ingroup mofem_problems_manager
150 *
151 * @param out_name name of build problem
152 * @param add_row_problems vector of add row problems
153 * @param add_col_problems vector of add col problems
154 * @param square_matrix true if structurally squared matrix
155 * @param verb verbosity level
156 * @return error code
157 */
159 buildComposedProblem(const std::string out_name,
160 const std::vector<std::string> add_row_problems,
161 const std::vector<std::string> add_col_problems,
162 const bool square_matrix = true, int verb = 1);
163
164 /**
165 * \brief build indexing and partition problem inheriting indexing and
166 * partitioning from two other problems
167 * \ingroup mofem_problems_manager
168 *
169 * \param name problem name
170 * \param problem_for_rows problem used to index rows
171 * \param copy_rows just copy rows dofs
172 * \param problem_for_cols problem used to index cols
173 * \param copy_cols just copy cols dofs
174 *
175 * If copy_rows/copy_cols is set to false only partition is copied between
176 * problems.
177 *
178 */
179 MoFEMErrorCode inheritPartition(const std::string name,
180 const std::string problem_for_rows,
181 bool copy_rows,
182 const std::string problem_for_cols,
183 bool copy_cols, int verb = VERBOSE);
184
185 /** \brief partition problem dofs
186 * \ingroup mofem_problems_manager
187 *
188 * \param name problem name
189 */
190 MoFEMErrorCode partitionSimpleProblem(const std::string name,
191 int verb = VERBOSE);
192
193 /** \brief partition problem dofs (collective)
194 * \ingroup mofem_problems_manager
195 *
196 * \param name problem name
197 */
198 MoFEMErrorCode partitionProblem(const std::string name, int verb = VERBOSE);
199
201 int verb = VERBOSE);
202
204 int verb = VERBOSE);
205
206 /** \brief partition finite elements
207 * \ingroup mofem_problems_manager
208 *
209 * Function which partition finite elements based on dofs partitioning.<br>
210 * In addition it sets information about local row and cols dofs at given
211 * element on partition.
212 *
213 * @param name
214 * @param part_from_moab
215 * @param low_proc
216 * @param hi_proc
217 * @param verb
218 * @return MoFEMErrorCode
219 *
220 * \param name problem name
221 */
222 MoFEMErrorCode partitionFiniteElements(const std::string name,
223 bool part_from_moab = false,
224 int low_proc = -1, int hi_proc = -1,
225 int verb = VERBOSE);
226
227 /** \brief determine ghost nodes
228 * \ingroup mofem_problems_manager
229 * \param name problem name
230 *
231 * DOFs are ghost dofs if are used by elements on given partitition, but not
232 * owned by that partitition.
233 *
234 */
235 MoFEMErrorCode partitionGhostDofs(const std::string name, int verb = VERBOSE);
236
237 /** \brief determine ghost nodes on distributed meshes
238 * \ingroup mofem_problems_manager
239 * \param name problem name
240 *
241 * It is very similar for partitionGhostDofs, however this explits that mesh
242 * is
243 * distributed.
244 *
245 * DOFs are ghosted if are shered but not owned by partition.
246 *
247 */
249 int verb = VERBOSE);
250
251 /**
252 * \create add entities of finite element in the problem
253 * \ingroup mofem_problems_manager
254 *
255 * \note Meshset entity has to be crated
256 *
257 */
258
259 /**
260 * @brief create add entities of finite element in the problem
261 *
262 * @note Meshset entity has to be crated
263 *
264 * @param prb_name name of the problem
265 * @param fe_name name of the entity
266 * @param meshset pointer meshset handle
267 * @return MoFEMErrorCode
268 */
269 MoFEMErrorCode getFEMeshset(const std::string prb_name,
270 const std::string fe_name,
271 EntityHandle *meshset) const;
272
273 /**
274 * \brief Get layout of elements in the problem
275 * \ingroup mofem_problems_manager
276 *
277 * In layout is stored information how many elements is on each processor, for
278 * more information look int petsc documentation
279 * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/PetscLayoutCreate.html#PetscLayoutCreate>
280 *
281 * @param name problem name
282 * @param fe_name finite elements
283 * @param layout layout
284 * @param verb verbosity level
285 * @return error code
286 */
287 MoFEMErrorCode getProblemElementsLayout(const std::string name,
288 const std::string fe_name,
289 PetscLayout *layout) const;
290
291 /**
292 * @brief Remove DOFs from problem
293 * @ingroup mofem_problems_manager
294 *
295 * Remove DOFs from problem which are on entities on the given range and given
296 * field name. On the finite element level, DOFs can be still accessed however
297 * local PETSc indices and global PETSc indices are marked with the index -1.
298 *
299 * @note If the index is marked -1 it is not assembled and dropped by
300 * VecSetValues and MatSetValues.
301 *
302 * @todo Not yet implemented update for AO maps and IS ranges if removed
303 * entities in composite problem or sub-problem
304 *
305 * @param problem_name name of the problem
306 * @param field_name name of the field
307 * @param ents entities on which DOFs are removed
308 * @param lo_coeff low dof coefficient (rank)
309 * @param hi_coeff high dof coefficient (rank)
310 * @param verb verbosity level
311 * @param debug to debug and seek for inconsistencies set to true
312 * @return MoFEMErrorCode
313 */
315 const std::string problem_name, const std::string field_name,
316 const Range ents, const int lo_coeff = 0,
317 const int hi_coeff = MAX_DOFS_ON_ENTITY, const int lo_order = 0,
318 const int hi_order = 100, int verb = VERBOSE, const bool debug = false);
319
320 /**
321 * @copydoc removeDofsOnEntities
322 *
323 * \note Use this function for nondistributed meshes
324 */
326 const std::string problem_name, const std::string field_name,
327 const Range ents, const int lo_coeff = 0,
328 const int hi_coeff = MAX_DOFS_ON_ENTITY, const int lo_order = 0,
329 const int hi_order = 100, int verb = VERBOSE, const bool debug = false);
330
331 /**
332 * @brief Remove DOFs from problem by bit ref level
333 * @ingroup mofem_problems_manager
334 *
335 * See for more detail other implementation for removeDofsOnEntities.
336 *
337 * @param problem_name name of the problem
338 * @param field_name name of the field
339 * @param bit_ref_level bit ref level on which DOFs are removed
340 * @param bit_ref_mask bit ref mask on which DOFs are removed
341 * @param ents_ptr filter entities with given bit and mask
342 * @param lo_coeff low dof coefficient (rank)
343 * @param hi_coeff high dof coefficient (rank)
344 * @param verb verbosity level
345 * @param debug to debug and seek for inconsistencies set to true
346 * @return MoFEMErrorCode
347 */
349 const std::string problem_name, const std::string field_name,
350 const BitRefLevel bit_ref_level, const BitRefLevel bit_ref_mask,
351 Range *ents_ptr = nullptr, const int lo_coeff = 0,
352 const int hi_coeff = MAX_DOFS_ON_ENTITY, const int lo_order = 0,
353 const int hi_order = 100, int verb = VERBOSE, const bool debug = false);
354
355 /**
356 * @copydoc removeDofsOnEntities
357 *
358 * \note Use this function for nondistributed meshes
359 */
361 const std::string problem_name, const std::string field_name,
362 const BitRefLevel bit_ref_level, const BitRefLevel bit_ref_mask,
363 Range *ents_ptr = nullptr, const int lo_coeff = 0,
364 const int hi_coeff = MAX_DOFS_ON_ENTITY, const int lo_order = 0,
365 const int hi_order = 100, int verb = VERBOSE, const bool debug = false);
366
367 enum MarkOP { OR, AND };
368
369 /**
370 * @brief Create vector with marked indices
371 *
372 * Vector with local DOFs marked by entities
373 *
374 *
375 * @param problem_name
376 * @param row
377 * @param ents
378 * @param marker
379 * @return MoFEMErrorCode
380 */
381 MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc,
382 const enum MarkOP op, const Range ents,
383 std::vector<unsigned char> &marker) const;
384
385 /**
386 * @deprecated use function with MarkOP
387 */
389 markDofs(const std::string problem_name, RowColData rc, const Range ents,
390 std::vector<unsigned char> &marker) const {
391 return markDofs(problem_name, rc, MarkOP::OR, ents, marker);
392 }
393
394 /**
395 * @brief Mark DOFs
396 *
397 * @param problem_name
398 * @param rc
399 * @param field_name
400 * @param lo
401 * @param hi
402 * @param op
403 * @param marker
404 * @return MoFEMErrorCode
405 */
406 MoFEMErrorCode modifyMarkDofs(const std::string problem_name, RowColData rc,
407 const std::string field_name, const int lo,
408 const int hi, const enum MarkOP op,
409 const unsigned char c,
410 std::vector<unsigned char> &marker) const;
411
412 /**
413 * @brief add empty block to problem
414 *
415 * MatrixManager assumes that all blocks, i.e. all fields combinations are non
416 * zero. This is not always the case, to optimise code and reduce memory usage
417 * user can specifi which blocks are empty.
418 *
419 * @param problem_name problem name
420 * @param row_field row filed name
421 * @param col_field col field name
422 * @return MoFEMErrorCode
423 */
424 MoFEMErrorCode addFieldToEmptyFieldBlocks(const std::string problem_name,
425 const std::string row_field,
426 const std::string col_field) const;
427
428private:
430};
431} // namespace MoFEM
432
433#endif //__PROBLEMSMANAGER_HPP__
434
435/**
436 * \defgroup mofem_problems_manager ProblemsManager
437 * \brief Adding and managing problems
438 *
439 * \ingroup mofem
440 */
MoFEM interface.
@ VERBOSE
Definition: definitions.h:209
RowColData
RowColData.
Definition: definitions.h:123
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:236
#define DEPRECATED
Definition: definitions.h:17
static const bool debug
const int dim
MoFEMErrorCode buildProblemOnDistributedMesh(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures, assuming that mesh is distributed (collective)
MoFEMErrorCode getProblemElementsLayout(const std::string name, const std::string fe_name, PetscLayout *layout) const
Get layout of elements in the problem.
MoFEMErrorCode partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode partitionSimpleProblem(const std::string name, int verb=VERBOSE)
partition problem dofs
MoFEMErrorCode buildComposedProblem(const std::string out_name, const std::vector< std::string > add_row_problems, const std::vector< std::string > add_col_problems, const bool square_matrix=true, int verb=1)
build composite problem
MoFEMErrorCode getFEMeshset(const std::string prb_name, const std::string fe_name, EntityHandle *meshset) const
create add entities of finite element in the problem
MoFEMErrorCode buildSubProblem(const std::string out_name, const std::vector< std::string > &fields_row, const std::vector< std::string > &fields_col, const std::string main_problem, const bool square_matrix=true, const map< std::string, std::pair< EntityType, EntityType > > *entityMapRow=nullptr, const map< std::string, std::pair< EntityType, EntityType > > *entityMapCol=nullptr, int verb=VERBOSE)
build sub problem
MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
DEPRECATED MoFEMErrorCode partitionMesh(const Range &ents, const int dim, const int adj_dim, const int n_parts, Tag *th_vertex_weights=nullptr, Tag *th_edge_weights=nullptr, Tag *th_part_weights=nullptr, int verb=VERBOSE, const bool debug=false)
Set partition tag to each finite element in the problem.
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
MoFEMErrorCode partitionGhostDofsOnDistributedMesh(const std::string name, int verb=VERBOSE)
determine ghost nodes on distributed meshes
MoFEMErrorCode inheritPartition(const std::string name, const std::string problem_for_rows, bool copy_rows, const std::string problem_for_cols, bool copy_cols, int verb=VERBOSE)
build indexing and partition problem inheriting indexing and partitioning from two other problems
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elements
MoFEMErrorCode removeDofsOnEntities(const std::string problem_name, const std::string field_name, const Range ents, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
Remove DOFs from problem.
auto marker
set bit to marker
const double c
speed of light (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr auto field_name
Core (interface) class.
Definition: Core.hpp:82
keeps basic data about problem
Problem manager is used to build and partition problems.
DEPRECATED MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc, const Range ents, std::vector< unsigned char > &marker) const
MoFEMErrorCode markDofs(const std::string problem_name, RowColData rc, const enum MarkOP op, const Range ents, std::vector< unsigned char > &marker) const
Create vector with marked indices.
MoFEMErrorCode printPartitionedProblem(const Problem *problem_ptr, int verb=VERBOSE)
MoFEMErrorCode addFieldToEmptyFieldBlocks(const std::string problem_name, const std::string row_field, const std::string col_field) const
add empty block to problem
MoFEMErrorCode modifyMarkDofs(const std::string problem_name, RowColData rc, const std::string field_name, const int lo, const int hi, const enum MarkOP op, const unsigned char c, std::vector< unsigned char > &marker) const
Mark DOFs.
PetscLogEvent MOFEM_EVENT_ProblemsManager
virtual ~ProblemsManager()=default
PetscBool synchroniseProblemEntities
DOFs in fields, not from DOFs on elements.
MoFEMErrorCode debugPartitionedProblem(const Problem *problem_ptr, int verb=VERBOSE)
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
MoFEMErrorCode removeDofsOnEntitiesNotDistributed(const std::string problem_name, const std::string field_name, const Range ents, const int lo_coeff=0, const int hi_coeff=MAX_DOFS_ON_ENTITY, const int lo_order=0, const int hi_order=100, int verb=VERBOSE, const bool debug=false)
Remove DOFs from problem.
MoFEMErrorCode getOptions()
base class for all interface classes