v0.8.23
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 /*
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 __PROBLEMSMANAGER_HPP__
20 #define __PROBLEMSMANAGER_HPP__
21 
22 #include "UnknownInterface.hpp"
23 
24 namespace MoFEM {
25 
28 
29 /**
30  * \brief Problem manager is used to build and partition problems
31  * \ingroup mofem_problems_manager
32  *
33  */
35 
37  UnknownInterface **iface) const;
38 
40  ProblemsManager(const MoFEM::Core &core);
41 
42  /**
43  * \brief Destructor
44  */
46 
47  PetscBool buildProblemFromFields; ///< If set to true, problem is build from
48  /// DOFs in fields, not from DOFs on elements
49 
51 
53 
54  /**
55  * \brief Set partition tag to each finite element in the problem
56  * \ingroup mofem_problems_manager
57  *
58  * This will use one of the mesh partitioning programs available from PETSc
59  * See
60  * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatPartitioningType.html>
61  *
62  * @param ents Entities to partition
63  * @param dim Dimension of entities to partition
64  * @param adj_dim Adjacency dimension
65  * @param n_parts Number of partitions
66  * @param verb Verbosity level
67  * @return Error code
68  */
69  MoFEMErrorCode partitionMesh(const Range &ents, const int dim,
70  const int adj_dim, const int n_parts,
71  Tag *th_vertex_weights = nullptr,
72  Tag *th_edge_weights = nullptr,
73  Tag *th_part_weights = nullptr,
74  int verb = VERBOSE, const bool debug = false);
75 
76  /** \brief build problem data structures
77  * \ingroup mofem_problems_manager
78  *
79  * \note If square_matrix is set to true, that indicate that problem is
80  * structurally
81  * symmetric, i.e. rows and columns have the same dofs and are indexed in the
82  * same
83  * way.
84  *
85  * @param name problem name
86  * @param square_matrix structurally symmetric problem
87  * @param verb verbosity level
88  * @return error code
89  *
90  */
91  MoFEMErrorCode buildProblem(const std::string name, const bool square_matrix,
92  int verb = VERBOSE);
93 
94  /** \brief build problem data structures
95  * \ingroup mofem_problems_manager
96  *
97  * \note If square_matrix is set to true, that indicate that problem is
98  * structurally
99  * symmetric, i.e. rows and columns have the same dofs and are indexed in the
100  * same
101  * way.
102  *
103  * @param problem pointer
104  * @param square_matrix structurally symmetric problem
105  * @param verb verbosity level
106  * @return error code
107  *
108  */
109  MoFEMErrorCode buildProblem(Problem *problem_ptr, 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  */
123  MoFEMErrorCode buildProblemOnDistributedMesh(const std::string name,
124  const bool square_matrix,
125  int verb = VERBOSE);
126 
127  /** \brief build problem data structures, assuming that mesh is distributed
128  (collective)
129  * \ingroup mofem_problems_manager
130 
131  Mesh is distributed, that means that each processor keeps only own part of
132  the mesh and shared entities.
133 
134  Collective - need to be run on all processors in communicator, i.e. each
135  function has to call this function.
136 
137  */
139  const bool square_matrix = true,
140  int verb = VERBOSE);
141 
142  /**
143  * \brief build sub problem
144  * \ingroup mofem_problems_manager
145  *
146  * @param out_name problem
147  * @param fields_row vector of fields composing problem
148  * @param fields_col vector of fields composing problem
149  * @param main_problem main problem
150  * @return error code
151  */
153  const std::string out_name, const std::vector<std::string> &fields_row,
154  const std::vector<std::string> &fields_col,
155  const std::string main_problem, const bool square_matrix = true,
156  const map<std::string, std::pair<EntityType, EntityType>> *entityMapRow =
157  nullptr,
158  const map<std::string, std::pair<EntityType, EntityType>> *entityMapCol =
159  nullptr,
160  int verb = VERBOSE);
161 
162  /**
163  * \brief build composite problem
164  * \ingroup mofem_problems_manager
165  *
166  * @param out_name name of build problem
167  * @param add_row_problems vector of add row problems
168  * @param add_col_problems vector of add col problems
169  * @param square_matrix true if structurally squared matrix
170  * @param verb verbosity level
171  * @return error code
172  */
174  buildCompsedProblem(const std::string out_name,
175  const std::vector<std::string> add_row_problems,
176  const std::vector<std::string> add_col_problems,
177  const bool square_matrix = true, int verb = 1);
178 
179  /**
180  * \brief build indexing and partition problem inheriting indexing and
181  * partitioning from two other problems
182  * \ingroup mofem_problems_manager
183  *
184  * \param name problem name
185  * \param problem_for_rows problem used to index rows
186  * \param copy_rows just copy rows dofs
187  * \param problem_for_cols problem used to index cols
188  * \param copy_cols just copy cols dofs
189  *
190  * If copy_rows/copy_cols is set to false only partition is copied between
191  * problems.
192  *
193  */
194  MoFEMErrorCode inheritPartition(const std::string name,
195  const std::string problem_for_rows,
196  bool copy_rows,
197  const std::string problem_for_cols,
198  bool copy_cols, int verb = VERBOSE);
199 
200  /** \brief partition problem dofs
201  * \ingroup mofem_problems_manager
202  *
203  * \param name problem name
204  */
205  MoFEMErrorCode partitionSimpleProblem(const std::string name,
206  int verb = VERBOSE);
207 
208  /** \brief partition problem dofs (collective)
209  * \ingroup mofem_problems_manager
210  *
211  * \param name problem name
212  */
213  MoFEMErrorCode partitionProblem(const std::string name, int verb = VERBOSE);
214 
216  int verb = VERBOSE);
217 
219  int verb = VERBOSE);
220 
221  /** \brief partition finite elements
222  * \ingroup mofem_problems_manager
223  *
224  * Function which partition finite elements based on dofs partitioning.<br>
225  * In addition it sets information about local row and cols dofs at given
226  * element on partition.
227  *
228  * \param name problem name
229  */
230  MoFEMErrorCode partitionFiniteElements(const std::string name,
231  bool part_from_moab = false,
232  int low_proc = -1, int hi_proc = -1,
233  int verb = VERBOSE);
234 
235  /** \brief determine ghost nodes
236  * \ingroup mofem_problems_manager
237  * \param name problem name
238  *
239  * DOFs are ghost dofs if are used by elements on given partitition, but not
240  * owned by that partitition.
241  *
242  */
243  MoFEMErrorCode partitionGhostDofs(const std::string name, int verb = VERBOSE);
244 
245  /** \brief determine ghost nodes on distributed meshes
246  * \ingroup mofem_problems_manager
247  * \param name problem name
248  *
249  * It is very similar for partitionGhostDofs, however this explits that mesh
250  * is
251  * distributed.
252  *
253  * DOFs are ghosted if are shered but not owned by partition.
254  *
255  */
257  int verb = VERBOSE);
258 
259  /**
260  * \create add entities of finite element in the problem
261  * \ingroup mofem_problems_manager
262  *
263  * \note Meshset entity has to be crated
264  *
265  */
266 
267  /**
268  * @brief create add entities of finite element in the problem
269  *
270  * @note Meshset entity has to be crated
271  *
272  * @param prb_name name of the problem
273  * @param fe_name name of the entity
274  * @param meshset pointer meshset handle
275  * @return MoFEMErrorCode
276  */
277  MoFEMErrorCode getFEMeshset(const std::string prb_name,
278  const std::string fe_name,
279  EntityHandle *meshset) const;
280 
281  /**
282  * \brief Get layout of elements in the problem
283  * \ingroup mofem_problems_manager
284  *
285  * In layout is stored information how many elements is on each processor, for
286  * more information look int petsc documentation
287  * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/PetscLayoutCreate.html#PetscLayoutCreate>
288  *
289  * @param name problem name
290  * @param fe_name finite elements
291  * @param layout layout
292  * @param verb verbosity level
293  * @return error code
294  */
295  MoFEMErrorCode getProblemElementsLayout(const std::string name,
296  const std::string fe_name,
297  PetscLayout *layout) const;
298 
299  /**
300  * @brief Remove DOFs from problem
301  * @ingroup mofem_problems_manager
302  *
303  * Remove DOFs from problem which are on entities on the given range and given
304  * field name. On the finite element level, DOFs can be still accessed however
305  * local PETSc indices and global PETSc indices are marked with the index -1.
306  *
307  * @note If the index is marked -1 it is not assembled and dropped by
308  * VecSetValues and MatSetValues.
309  *
310  * @todo Not yet implemented update for AO maps and IS ranges if removed
311  * entities in composite problem or sub-problem
312  *
313  * @param problem_name name of the problem
314  * @param field_name name of the field
315  * @param ents entities on which DOFs are removed
316  * @param lo_coeff low dof coefficient (rank)
317  * @param hi_coeff high dof coefficient (rank)
318  * @param verb verbosity level
319  * @param debug to debug and seek for inconsistencies set to true
320  * @return MoFEMErrorCode
321  */
322  MoFEMErrorCode removeDofsOnEntities(const std::string problem_name,
323  const std::string field_name,
324  const Range ents, const int lo_coeff = 0,
325  const int hi_coeff = MAX_DOFS_ON_ENTITY,
326  int verb = VERBOSE,
327  const bool debug = false);
328 
329 private:
331 };
332 } // namespace MoFEM
333 
334 #endif //__PROBLEMSMANAGER_HPP__
335 
336 /**
337  * \defgroup mofem_problems_manager ProblemsManager
338  * \brief Adding and managing problems
339  *
340  * \ingroup mofem
341  */
MoFEM interface unique ID.
Problem manager is used to build and partition problems.
static const MOFEMuuid IDD_MOFEMProblemsManager
PetscLogEvent MOFEM_EVENT_ProblemsManager
MoFEMErrorCode partitionProblem(const std::string name, int verb=VERBOSE)
partition problem dofs (collective)
MoFEMErrorCode buildCompsedProblem(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 buildProblem(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures
base class for all interface classes
MoFEMErrorCode debugPartitionedProblem(const Problem *problem_ptr, int verb=VERBOSE)
Core (interface) class.
Definition: Core.hpp:50
MoFEM interface.
keeps basic data about problemThis is low level structure with information about problem,...
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, int verb=VERBOSE, const bool debug=false)
Remove DOFs from problemRemove DOFs from problem which are on entities on the given range and given f...
std::bitset< BITINTERFACEUID_SIZE > BitIntefaceId
Definition: Types.hpp:56
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
MoFEMErrorCode printPartitionedProblem(const Problem *problem_ptr, int verb=VERBOSE)
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 problemThis will use one of the mesh partitioning pro...
MoFEMErrorCode getProblemElementsLayout(const std::string name, const std::string fe_name, PetscLayout *layout) const
Get layout of elements in the problemIn layout is stored information how many elements is on each pro...
MoFEMErrorCode partitionGhostDofsOnDistributedMesh(const std::string name, int verb=VERBOSE)
determine ghost nodes on distributed meshes
ProblemsManager(const MoFEM::Core &core)
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
static const bool debug
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
PetscBool synchroniseProblemEntities
DOFs in fields, not from DOFs on elements.
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 partitionGhostDofs(const std::string name, int verb=VERBOSE)
determine ghost nodes
MoFEMErrorCode buildProblemOnDistributedMesh(const std::string name, const bool square_matrix, int verb=VERBOSE)
build problem data structures, assuming that mesh is distributed (collective)Mesh is distributed,...
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:297
MoFEMErrorCode partitionFiniteElements(const std::string name, bool part_from_moab=false, int low_proc=-1, int hi_proc=-1, int verb=VERBOSE)
partition finite elementsFunction which partition finite elements based on dofs partitioning....
MoFEMErrorCode getOptions()
MoFEMErrorCode partitionSimpleProblem(const std::string name, int verb=VERBOSE)
partition problem dofs
MoFEMErrorCode getFEMeshset(const std::string prb_name, const std::string fe_name, EntityHandle *meshset) const
create add entities of finite element in the problem