v0.8.23
DMMoFEM.hpp
Go to the documentation of this file.
1 /** \file DMMoFEM.hpp
2  \brief Discrete manager interface for MoFEM
3  */
4 
5 /* This file is part of MoFEM.
6  * MoFEM is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14  * License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
18 
19 #ifndef __DMMMOFEM_H
20 #define __DMMMOFEM_H
21 
22 #define DM_NO_ELEMENT "DMNONEFE"
23 
24 namespace MoFEM {
25 
26 /**
27  * \brief Register MoFEM problem
28  * \ingroup dm
29  */
30 PetscErrorCode DMRegister_MoFEM(const char sname[]);
31 
32 /**
33  * \brief Must be called by user to set MoFEM data structures
34  * \ingroup dm
35  */
36 PetscErrorCode DMMoFEMCreateMoFEM(
37  DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[],
38  const MoFEM::BitRefLevel bit_level,
39  const MoFEM::BitRefLevel bit_mask = MoFEM::BitRefLevel().set());
40 
41 /**
42  * \brief Must be called by user to set Sub DM MoFEM data structures
43  * \ingroup dm
44  */
45 PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[]);
46 
47 /**
48  * \brief Get pointer to MoFEM::Interface
49  * @param dm Distributed mesh manager
50  * @param m_field_ptr Pointer to pointer of field interface
51  * @return Error code
52  * \ingroup dm
53  */
54 PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr);
55 
56 /**
57  * \brief Get pointer to problem data structure
58  * \ingroup dm
59  */
60 PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr);
61 
62 /**
63  * If this is set to PETSC_TRUE problem is deleted with DM
64  * @param dm the DM object
65  * @param destroy if PETSC_TRUE problem is destroyed
66  * @return error code
67  */
68 PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem);
69 
70 /**
71  * Get if problem will be destroyed with DM
72  * @param dm the DM object
73  * @param destroy return if PETSC_TRUE problem is destroyed
74  * @return error code
75  */
76 PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem);
77 
78 /**
79  * \brief set squared problem
80  * \ingroup dm
81 
82  It if true is assumed that matrix has the same indexing on rows and
83  columns. This reduces interprocessor communication.
84 
85  */
86 PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem);
87 
88 /**
89  * \brief get squared problem
90  * \ingroup dm
91 
92  It if true is assumed that matrix has the same indexing on rows and
93  columns. This reduces interprocessor communication.
94 
95  */
96 PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem);
97 
98 /**
99  * \brief Resolve shared entities
100  * @param dm dm
101  * @param fe_name finite element for which shared entities are resolved
102  * @return error code
103  *
104 
105  * This allows for tag reduction or tag exchange, f.e.
106 
107  \code
108  ierr = DMMoFEMGetSquareProblem(dm,"SHELL_ELEMENT"); CHKERRG(ierr);
109  Tag th;
110  rval = mField.get_moab().tag_get_handle("ADAPT_ORDER",th); CHKERRQ_MOAB(rval);
111  ParallelComm* pcomm =
112  ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
113  // rval = pcomm->reduce_tags(th,MPI_SUM,prisms);
114  rval = pcomm->exchange_tags(th,prisms);
115  \endcode
116 
117  * \ingroup dm
118  */
119 PetscErrorCode DMMoFEMResolveSharedEntities(DM dm, const char fe_name[]);
120 
121 /**
122  * \brief Get finite elements layout in the problem
123  *
124  * In layout is stored information how many elements is on each processor, for
125  * more information look int petsc documentation
126  * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/PetscLayoutCreate.html#PetscLayoutCreate>
127  *
128  * @param dm discrete manager for this problem
129  * @param fe_name finite element name
130  * @param layout pointer to layout, for created layout user takes
131  * responsibility for destroying it.
132  * @return error code
133  *
134  * \ingroup dm
135  */
136 PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, const char fe_name[],
137  PetscLayout *layout);
138 
139 /**
140  * \brief add element to dm
141  * \ingroup dm
142  *
143  * \note add_file is a collective, should be executed on all processors.
144  * Otherwise could lead to deadlock.
145  *
146  */
147 PetscErrorCode DMMoFEMAddElement(DM dm, const char fe_name[]);
148 
149 /**
150  * \brief unset element from dm
151  * \ingroup dm
152  */
153 PetscErrorCode DMMoFEMUnSetElement(DM dm, const char fe_name[]);
154 
155 /**
156  * \brief set local (or ghosted) vector values on mesh for partition only
157  * \ingroup dm
158 
159  * \param l vector
160  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
161  * \param scatter_mode see petsc manual for ScatterMode (The available modes
162  are: SCATTER_FORWARD or SCATTER_REVERSE)
163  *
164  * SCATTER_REVERSE set data to field entities from V vector.
165  *
166  * SCATTER_FORWARD set vector V from data field entities
167 
168  */
169 PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode,
170  ScatterMode scatter_mode);
171 
172 /**
173  * \brief set ghosted vector values on all existing mesh entities
174  * \ingroup dm
175 
176  * \param g 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
179  are: SCATTER_FORWARD or SCATTER_REVERSE)
180  *
181  * SCATTER_REVERSE set data to field entities from V vector.
182  *
183  * SCATTER_FORWARD set vector V from data field entities
184 
185  */
186 PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode,
187  ScatterMode scatter_mode);
188 
189 /**
190  * \brief execute finite element method for each element in dm (problem)
191  * \ingroup dm
192  */
193 PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
194 
195 /**
196  * \brief execute finite element method for each element in dm (problem)
197  * \ingroup dm
198  */
199 PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
200 
201 /**
202  * \brief Executes FEMethod for finite elements in DM
203  * @param dm MoFEM discrete manager
204  * @param fe_name name of finite element
205  * @param method pointer to \ref MoFEM::FEMethod
206  * @param low_rank lowest rank of processor
207  * @param up_rank upper run of processor
208  * @return Error code
209  * \ingroup dm
210  */
211 PetscErrorCode DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[],
212  MoFEM::FEMethod *method,
213  int low_rank, int up_rank);
214 
215 /**
216  * \brief Executes FEMethod for finite elements in DM
217  * @param dm MoFEM discrete manager
218  * @param fe_name name of finite element
219  * @param method pointer to \ref MoFEM::FEMethod
220  * @param low_rank lowest rank of processor
221  * @param up_rank upper run of processor
222  * @return Error code
223  * \ingroup dm
224  */
225 PetscErrorCode
226 DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const std::string &fe_name,
227  boost::shared_ptr<MoFEM::FEMethod> method,
228  int low_rank, int up_rank);
229 
230 /**
231  * \brief Executes FEMethod for finite elements in DM
232  * @param dm MoFEM discrete manager
233  * @param fe_name name of element
234  * @param method pointer to \ref MOFEM::FEMethod
235  * @return Error code
236  * \ingroup dm
237  */
238 PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[],
239  MoFEM::FEMethod *method);
240 
241 /**
242  * \brief Executes FEMethod for finite elements in DM
243  * @param dm MoFEM discrete manager
244  * @param fe_name name of element
245  * @param method pointer to \ref MOFEM::FEMethod
246  * @return Error code
247  * \ingroup dm
248  */
249 PetscErrorCode
250 DMoFEMLoopFiniteElements(DM dm, const std::string &fe_name,
251  boost::shared_ptr<MoFEM::FEMethod> method);
252 
253 /**
254  * \brief execute method for dofs on field in problem
255  * \ingroup dm
256  */
257 PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[],
258  MoFEM::DofMethod *method);
259 
260 // /**
261 // * \brief Set compute operator for KSP solver via sub-matrix and IS
262 // *
263 // * @param dm DM
264 // * @return error code
265 // *
266 // * \ingroup dm
267 // */
268 // PetscErrorCode DMMoFEMKSPSetComputeOperatorsViaSubMatrixbByIs(DM dm);
269 
270 /**
271  * \brief set KSP right hand side evaluation function
272  * \ingroup dm
273  */
274 PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[],
275  MoFEM::FEMethod *method,
276  MoFEM::BasicMethod *pre_only,
277  MoFEM::BasicMethod *post_only);
278 
279 /**
280  * \brief set KSP right hand side evaluation function
281  * \ingroup dm
282  */
283 PetscErrorCode
284 DMMoFEMKSPSetComputeRHS(DM dm, const std::string &fe_name,
285  boost::shared_ptr<MoFEM::FEMethod> method,
286  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
287  boost::shared_ptr<MoFEM::BasicMethod> post_only);
288 
289 /**
290  * \brief Set KSP operators and push mofem finite element methods
291  *
292  * @param dm DM
293  * @param fe_name finite element name
294  * @param method method on the element (executed for each element in the
295  * problem which given name)
296  * @param pre_only method for pre-process before element method
297  * @param post_only method for post-process after element method
298  * @return error code
299  *
300  * \ingroup dm
301  */
302 PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[],
303  MoFEM::FEMethod *method,
304  MoFEM::BasicMethod *pre_only,
305  MoFEM::BasicMethod *post_only);
306 
307 /**
308  * \brief Set KSP operators and push mofem finite element methods
309  *
310  * @param dm DM
311  * @param fe_name finite element name
312  * @param method method on the element (executed for each element in the
313  * problem which given name)
314  * @param pre_only method for pre-process before element method
315  * @param post_only method for post-process after element method
316  * @return error code
317  *
318  * \ingroup dm
319  */
320 PetscErrorCode
321 DMMoFEMKSPSetComputeOperators(DM dm, const std::string &fe_name,
322  boost::shared_ptr<MoFEM::FEMethod> method,
323  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
324  boost::shared_ptr<MoFEM::BasicMethod> post_only);
325 
326 /**
327  * \brief set SNES residual evaluation function
328  * \ingroup dm
329  */
330 PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[],
331  MoFEM::FEMethod *method,
332  MoFEM::BasicMethod *pre_only,
333  MoFEM::BasicMethod *post_only);
334 
335 /**
336  * \brief set SNES residual evaluation function
337  * \ingroup dm
338  */
339 PetscErrorCode
340 DMMoFEMSNESSetFunction(DM dm, const std::string &fe_name,
341  boost::shared_ptr<MoFEM::FEMethod> method,
342  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
343  boost::shared_ptr<MoFEM::BasicMethod> post_only);
344 
345 /**
346  * \brief set SNES Jacobian evaluation function
347  * \ingroup dm
348  */
349 PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[],
350  MoFEM::FEMethod *method,
351  MoFEM::BasicMethod *pre_only,
352  MoFEM::BasicMethod *post_only);
353 
354 /**
355  * \brief set SNES Jacobian evaluation function
356  * \ingroup dm
357  */
358 PetscErrorCode
359 DMMoFEMSNESSetJacobian(DM dm, const std::string &fe_name,
360  boost::shared_ptr<MoFEM::FEMethod> method,
361  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
362  boost::shared_ptr<MoFEM::BasicMethod> post_only);
363 
364 /**
365  * \brief set TS implicit function evaluation function
366  * \ingroup dm
367  */
368 PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[],
369  MoFEM::FEMethod *method,
370  MoFEM::BasicMethod *pre_only,
371  MoFEM::BasicMethod *post_only);
372 
373 /**
374  * \brief set TS implicit function evaluation function
375  * \ingroup dm
376  */
377 PetscErrorCode
378 DMMoFEMTSSetIFunction(DM dm, const std::string &fe_name,
379  boost::shared_ptr<MoFEM::FEMethod> method,
380  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
381  boost::shared_ptr<MoFEM::BasicMethod> post_only);
382 
383 /**
384  * \brief set TS Jacobian evaluation function
385  * \ingroup dm
386  */
387 PetscErrorCode
388 DMMoFEMTSSetIJacobian(DM dm, const std::string &fe_name,
389  boost::shared_ptr<MoFEM::FEMethod> method,
390  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
391  boost::shared_ptr<MoFEM::BasicMethod> post_only);
392 
393 /**
394  * \brief set TS Jacobian evaluation function
395  * \ingroup dm
396  */
397 PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, const char fe_name[],
398  MoFEM::FEMethod *method,
399  MoFEM::BasicMethod *pre_only,
400  MoFEM::BasicMethod *post_only);
401 
402 /**
403  * \brief get MoFEM::KspCtx data structure
404  * \ingroup dm
405  */
406 PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx);
407 
408 /**
409  * \brief get MoFEM::KspCtx data structure
410  * \ingroup dm
411  */
412 PetscErrorCode
413 DMMoFEMGetKspCtx(DM dm, const boost::shared_ptr<MoFEM::KspCtx> &ksp_ctx);
414 
415 /**
416  * \brief set MoFEM::KspCtx data structure
417  * \ingroup dm
418  */
419 PetscErrorCode DMMoFEMSetKspCtx(DM dm,
420  boost::shared_ptr<MoFEM::KspCtx> &ksp_ctx);
421 
422 /**
423  * \brief get MoFEM::SnesCtx data structure
424  * \ingroup dm
425  */
426 PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx);
427 
428 /**
429  * \brief get MoFEM::SnesCtx data structure
430  * \ingroup dm
431  */
432 PetscErrorCode
433 DMMoFEMGetSnesCtx(DM dm, const boost::shared_ptr<MoFEM::SnesCtx> &snes_ctx);
434 
435 /**
436  * \brief Set MoFEM::SnesCtx data structure
437  * \ingroup dm
438 
439  */
440 PetscErrorCode DMMoFEMSetSnesCtx(DM dm,
441  boost::shared_ptr<MoFEM::SnesCtx> &snes_ctx);
442 
443 /**
444  * \brief get MoFEM::TsCtx data structure
445  * \ingroup dm
446  */
447 PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx);
448 
449 /**
450  * \brief get MoFEM::TsCtx data structure
451  * \ingroup dm
452  */
453 PetscErrorCode DMMoFEMGetTsCtx(DM dm,
454  const boost::shared_ptr<MoFEM::TsCtx> &ts_ctx);
455 
456 /**
457  * \brief Set MoFEM::TsCtx data structure
458  * \ingroup dm
459 
460  It take over pointer, do not delete it, DM will destroy pointer
461  when is destroyed.
462 
463  */
464 PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr<MoFEM::TsCtx> &ts_ctx);
465 
466 /** sets if read mesh is partitioned
467  * \ingroup dm
468  */
469 PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned);
470 
471 /** get if read mesh is partitioned
472  * \ingroup dm
473  */
474 PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned);
475 
476 /**
477  * \brief Set operators for MoFEM dm
478  * @param dm
479  * @return error code
480  * \ingroup dm
481  */
482 PetscErrorCode DMSetOperators_MoFEM(DM dm);
483 
484 /**
485  * \brief Create dm data structure with MoFEM data structure
486  * \ingroup dm
487  */
488 PetscErrorCode DMCreate_MoFEM(DM dm);
489 
490 /**
491  * \brief Destroys dm with MoFEM data structure
492  * \ingroup dm
493  */
494 PetscErrorCode DMDestroy_MoFEM(DM dm);
495 
496 /**
497  * \brief DMShellSetCreateGlobalVector
498  * \ingroup dm
499  *
500  * sets the routine to create a global vector
501  * associated with the shell DM
502  */
503 PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g);
504 
505 /**
506  * \brief DMShellSetCreateLocalVector
507  * \ingroup dm
508  *
509  * sets the routine to create a local vector
510  * associated with the shell DM
511  */
512 PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l);
513 
514 /**
515  * DMShellSetCreateMatrix
516  * \ingroup dm
517  *
518  * sets the routine to create a matrix associated with the shell DM
519  */
520 PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M);
521 
522 /**
523  * Set options for MoFEM DM
524  * \ingroup dm
525  */
526 #if PETSC_VERSION_GE(3, 7, 0)
527 PetscErrorCode DMSetFromOptions_MoFEM(PetscOptionItems *PetscOptionsObject,
528  DM dm);
529 #elif PETSC_VERSION_GE(3, 5, 3)
530 PetscErrorCode DMSetFromOptions_MoFEM(PetscOptions *PetscOptionsObject, DM dm);
531 #else
532 PetscErrorCode DMSetFromOptions_MoFEM(DM dm);
533 #endif
534 
535 /**
536  * sets up the MoFEM structures inside a DM object
537  * \ingroup dm
538  */
539 PetscErrorCode DMSetUp_MoFEM(DM dm);
540 
541 /**
542  * Sets up the MoFEM structures inside a DM object for sub dm
543  * \ingroup dm
544  */
545 PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm);
546 
547 /**
548  * Add field to sub dm problem on rows
549  * \ingroup dm
550  */
551 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[],
552  EntityType lo_type = MBVERTEX,
553  EntityType hi_type = MBMAXTYPE);
554 
555 /**
556  * Add field to sub dm problem on columns
557  * \ingroup dm
558  */
559 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[],
560  EntityType lo_type = MBVERTEX,
561  EntityType hi_type = MBMAXTYPE);
562 
563 /**
564  * Return true if this DM is sub problem
565  \ingroup dm
566  * @param dm the DM object
567  * @param is_subproblem true if subproblem
568  * @return error code
569  */
570 PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm);
571 
572 /**
573  * \brief get sub problem is
574  * @param dm has to be created with DMMoFEMSetSquareProblem
575  * @param is return is on the row
576  * @return error code
577  *
578  * Returns IS with global indices of the DM used to create SubDM
579  *
580  */
581 PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is);
582 
583 /**
584  * \brief get sub problem is
585  * @param dm has to be created with DMMoFEMSetSquareProblem
586  * @param is return is on the row
587  * @return error code
588  *
589  * Returns IS with global indices of the DM used to create SubDM
590  *
591  */
592 PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is);
593 
594 /**
595  * \brief Add problem to composite DM on row
596  \ingroup dm
597  *
598  * This create block on row with DOFs from problem of given name
599  *
600  * @param dm the DM object
601  * @param prb_name add problem name
602  * @return error code
603  */
604 PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[]);
605 
606 /**
607  * \brief Add problem to composite DM on col
608  * \ingroup dm
609  *
610  * This create block on col with DOFs from problem of given name
611  *
612  * @param dm the DM object
613  * @param prb_name add problem name
614  * @return error code
615  */
616 PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[]);
617 
618 /**
619  * \brief Get if this DM is composite DM
620  * \ingroup dm
621  *
622  * @param dm the DM object
623  * @param is_comp_dm return true if composite problem here
624  * @return error code
625  */
626 PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm);
627 
628 /**
629  * destroy the MoFEM structure
630  * \ingroup dm
631  */
632 PetscErrorCode DMDestroy_MoFEM(DM dm);
633 
634 /**
635  * DMShellSetGlobalToLocal
636  * \ingroup dm
637  *
638  * the routine that begins the global to local scatter
639  */
640 PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec);
641 
642 /**
643  * DMShellSetGlobalToLocal
644  * \ingroup dm
645  *
646  * the routine that begins the global to local scatter
647  */
648 PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec);
649 
650 /**
651  * DMShellSetLocalToGlobal
652  * \ingroup dm
653  *
654  * the routine that begins the local to global scatter
655  */
656 PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
657 
658 /**
659  * DMShellSetLocalToGlobal
660  * \ingroup dm
661  *
662  * the routine that ends the local to global scatter
663  */
664 PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
665 
666 /**
667  * DMShellSetLocalToGlobal
668  * \ingroup dm
669  *
670  * the routine that ends the local to global scatter
671  */
672 PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec);
673 
674 /**
675  * Creates a set of IS objects with the global indices of dofs for each field
676  * @param dm The number of fields (or NULL if not requested)
677  *
678  * Output:
679  * @param numFields The number of fields (or NULL if not requested)
680  * @param fieldNames The name for each field (or NULL if not requested)
681  * @param fields The global indices for each field (or NULL if not
682  requested)
683  *
684  * @return error code
685 
686  * \note The user is responsible for freeing all requested arrays. In
687  particular,
688  * every entry of names should be freed with PetscFree(), every entry of fields
689  * should be destroyed with ISDestroy(), and both arrays should be freed with
690  * PetscFree().
691 
692  \ingroup dm
693 
694  */
695 PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields,
696  char ***fieldNames, IS **fields);
697 
698 /**
699  * \brief get field is in the problem
700  * @param dm the DM objects
701  * @param rc ROW or COL (no difference is problem is squared)
702  * @param field_name name of the field
703  * @param is returned the IS object
704  * @return error code
705  *
706  * \code
707  * IS is;
708  * ierr = DMMoFEMGetFieldIS(dm,ROW,"DISP",&is_disp); CHKERRG(ierr);
709  * \endcode
710  *
711  *
712  \ingroup dm
713  */
714 PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[],
715  IS *is);
716 
717 /**
718  * @brief Set verbosity level
719  *
720  * @param dm
721  * @param verb see VERBOSITY_LEVELS for list of the levels
722  * @return PetscErrorCode
723  */
724 PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb);
725 
727 
728 /**
729  * \brief PETSc Discrete Manager data structure
730  *
731  * This structure should not be accessed or modified by user. Is not available
732  * from outside MoFEM DM manager. However user can inherit dat class and
733  * add data for additional functionality.
734  *
735  * This is part of implementation for PETSc interface, see more details in
736  * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/index.html>
737  *
738  * \ingroup dm
739  *
740  */
741 struct DMCtx : public UnknownInterface {
742 
744  UnknownInterface **iface) const;
745 
746  Interface *mField_ptr; ///< MoFEM interface
747  PetscBool isProblemBuild; ///< True if problem is build
748  std::string problemName; ///< Problem name
749 
750  // Options
751  PetscBool isPartitioned; ///< true if read mesh is on parts
752  PetscBool isSquareMatrix; ///< true if rows equals to cols
753 
754  int rAnk, sIze;
755 
756  // pointer to data structures
757  const Problem *problemPtr; ///< pinter to problem data structure
758 
759  // sub problem
760  PetscBool isSubDM;
761  std::vector<std::string> rowFields;
762  std::vector<std::string> colFields;
763  const Problem *problemMainOfSubPtr; ///< pinter to main problem to sub-problem
764 
765  PetscBool isCompDM;
766  std::vector<std::string> rowCompPrb;
767  std::vector<std::string> colCompPrb;
768  boost::shared_ptr<std::map<std::string, std::pair<EntityType, EntityType>>>
770  boost::shared_ptr<std::map<std::string, std::pair<EntityType, EntityType>>>
772 
773  PetscBool destroyProblem; ///< If true destroy problem with DM
774 
775  DMCtx();
776  virtual ~DMCtx();
777 
778  int verbosity; ///< verbosity
780 
781  boost::shared_ptr<KspCtx> kspCtx; ///< data structure KSP
782  boost::shared_ptr<SnesCtx> snesCtx; ///< data structure SNES
783  boost::shared_ptr<TsCtx> tsCtx; ///< data structure for TS solver
784 };
785 } // namespace MoFEM
786 
787 #endif //__DMMMOFEM_H
788 
789 /***************************************************************************/ /**
790  * \defgroup dm Distributed mesh manager
791  * \brief Implementation of PETSc DM, managing interactions between mesh data structures and vectors and matrices
792  *
793  * DM objects are used to manage communication between the algebraic structures in
794  * PETSc (Vec and Mat) and mesh data structures in PDE-based (or other)
795  * simulations.
796  *
797  * DM is abstract interface, here is it particular implementation for MoFEM code.
798  *
799  * \ingroup mofem
800  ******************************************************************************/
std::string problemName
Problem name.
Definition: DMMoFEM.hpp:748
PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is)
get sub problem is
Definition: DMMMoFEM.cpp:242
structure for User Loop Methods on finite elementsIt can be used to calculate stiffness matrices,...
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
Definition: DMMMoFEM.cpp:622
MoFEM interface unique ID.
PetscBool isSquareMatrix
true if rows equals to cols
Definition: DMMoFEM.hpp:752
PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb)
Set verbosity level.
Definition: DMMMoFEM.cpp:1155
int verbosity
verbosity
Definition: DMMoFEM.hpp:778
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set compute operator for KSP solver via sub-matrix and IS.
Definition: DMMMoFEM.cpp:541
PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMMoFEM.cpp:1026
boost::shared_ptr< std::map< std::string, std::pair< EntityType, EntityType > > > mapTypeRow
Definition: DMMoFEM.hpp:769
PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is)
get sub problem is
Definition: DMMMoFEM.cpp:260
PetscBool isSubDM
Definition: DMMoFEM.hpp:760
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMMoFEM.cpp:430
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problemIt if true is assumed that matrix has the same indexing on rows and columns....
Definition: DMMMoFEM.cpp:367
Interface for Time Stepping (TS) solver.
Definition: TsCtx.hpp:27
PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm)
Definition: DMMMoFEM.cpp:233
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[], EntityType lo_type=MBVERTEX, EntityType hi_type=MBMAXTYPE)
Definition: DMMMoFEM.cpp:210
PetscErrorCode DMMoFEMResolveSharedEntities(DM dm, const char fe_name[])
Resolve shared entities.
Definition: DMMMoFEM.cpp:376
PetscErrorCode DMMoFEMAddElement(DM dm, const char fe_name[])
add element to dm
Definition: DMMMoFEM.cpp:410
Interface * mField_ptr
MoFEM interface.
Definition: DMMoFEM.hpp:746
base class for all interface classes
PetscBool isPartitioned
true if read mesh is on parts
Definition: DMMoFEM.hpp:751
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition: DMMMoFEM.cpp:932
PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on colThis create block on col with DOFs from problem of given name.
Definition: DMMMoFEM.cpp:296
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
Definition: DMMMoFEM.cpp:41
const Problem * problemPtr
pinter to problem data structure
Definition: DMMoFEM.hpp:757
std::vector< std::string > colCompPrb
Definition: DMMoFEM.hpp:767
Data structure to exchange data between mofem and User Loop Methods on entities.It allows to exchange...
virtual ~DMCtx()
Definition: DMMMoFEM.cpp:36
keeps basic data about problemThis is low level structure with information about problem,...
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMMoFEM.cpp:1063
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition: DMMMoFEM.cpp:885
PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set KSP operators and push mofem finite element methods.
Definition: DMMMoFEM.cpp:582
RowColData
RowColData.
Definition: definitions.h:185
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method)
Executes FEMethod for finite elements in DM.
Definition: DMMMoFEM.cpp:492
std::bitset< BITINTERFACEUID_SIZE > BitIntefaceId
Definition: Types.hpp:56
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm)
Get if this DM is composite DM.
Definition: DMMMoFEM.cpp:316
PetscBool destroyProblem
If true destroy problem with DM.
Definition: DMMoFEM.hpp:773
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
Definition: DMMMoFEM.cpp:89
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVectorsets the routine to create a global vector associated with the shell DM.
Definition: DMMMoFEM.cpp:867
PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, const char fe_name[], PetscLayout *layout)
Get finite elements layout in the problem.
Definition: DMMMoFEM.cpp:386
boost::shared_ptr< TsCtx > tsCtx
data structure for TS solver
Definition: DMMoFEM.hpp:783
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
Definition: DMMMoFEM.cpp:166
PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on rowThis create block on row with DOFs from problem of given name.
Definition: DMMMoFEM.cpp:278
std::vector< std::string > rowFields
Definition: DMMoFEM.hpp:761
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[], EntityType lo_type=MBVERTEX, EntityType hi_type=MBMAXTYPE)
Definition: DMMMoFEM.cpp:187
PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr< MoFEM::TsCtx > &ts_ctx)
Set MoFEM::TsCtx data structureIt take over pointer, do not delete it, DM will destroy pointer when i...
Definition: DMMMoFEM.cpp:859
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition: DMMMoFEM.cpp:979
PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem)
get squared problemIt if true is assumed that matrix has the same indexing on rows and columns....
Definition: DMMMoFEM.cpp:400
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
Definition: DMMMoFEM.cpp:794
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
Definition: DMMMoFEM.cpp:442
boost::shared_ptr< KspCtx > kspCtx
data structure KSP
Definition: DMMoFEM.hpp:781
PetscBool isProblemBuild
True if problem is build.
Definition: DMMoFEM.hpp:747
int referenceNumber
Definition: DMMoFEM.hpp:779
Interface for nonlinear (SNES) solver.
Definition: SnesCtx.hpp:27
const Problem * problemMainOfSubPtr
pinter to main problem to sub-problem
Definition: DMMoFEM.hpp:763
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMMoFEM.cpp:53
PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem)
Definition: DMMMoFEM.cpp:358
boost::shared_ptr< SnesCtx > snesCtx
data structure SNES
Definition: DMMoFEM.hpp:782
PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx)
get MoFEM::KspCtx data structure
Definition: DMMMoFEM.cpp:768
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
Definition: DMMMoFEM.cpp:663
PetscErrorCode DMMoFEMUnSetElement(DM dm, const char fe_name[])
unset element from dm
Definition: DMMMoFEM.cpp:420
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition: DMMMoFEM.cpp:453
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMMoFEM.cpp:1034
PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition: DMMMoFEM.cpp:463
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
Definition: DMMMoFEM.cpp:109
PetscErrorCode DMCreate_MoFEM(DM dm)
Create dm data structure with MoFEM data structure.
Definition: DMMMoFEM.cpp:81
PetscErrorCode DMSetOperators_MoFEM(DM dm)
Set operators for MoFEM dm.
Definition: DMMMoFEM.cpp:59
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition: DMMMoFEM.cpp:1098
std::vector< std::string > colFields
Definition: DMMoFEM.hpp:762
PetscBool isCompDM
Definition: DMMoFEM.hpp:765
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
std::vector< std::string > rowCompPrb
Definition: DMMoFEM.hpp:766
Interface for linear (KSP) solver.
Definition: KspCtx.hpp:27
PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
Definition: DMMMoFEM.cpp:842
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
Definition: DMMMoFEM.cpp:1144
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
Definition: DMMMoFEM.cpp:325
PETSc Discrete Manager data structure.
Definition: DMMoFEM.hpp:741
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
Definition: DMMMoFEM.cpp:349
PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set TS implicit function evaluation function
Definition: DMMMoFEM.cpp:704
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition: DMMMoFEM.cpp:337
PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned)
Definition: DMMMoFEM.cpp:834
static const MOFEMuuid IDD_DMCTX
Definition: DMMoFEM.hpp:726
PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[], MoFEM::DofMethod *method)
execute method for dofs on field in problem
Definition: DMMMoFEM.cpp:509
PetscErrorCode DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank, int up_rank)
Executes FEMethod for finite elements in DM.
Definition: DMMMoFEM.cpp:473
boost::shared_ptr< std::map< std::string, std::pair< EntityType, EntityType > > > mapTypeCol
Definition: DMMoFEM.hpp:771
PetscErrorCode DMMoFEMSetKspCtx(DM dm, boost::shared_ptr< MoFEM::KspCtx > &ksp_ctx)
set MoFEM::KspCtx data structure
Definition: DMMMoFEM.cpp:785
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition: DMMMoFEM.cpp:823
PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, const std::string &fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS Jacobian evaluation function
Definition: DMMMoFEM.cpp:757
Data structure to exchange data between mofem and User Loop Methods.It allows to exchange data betwee...
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMMoFEM.cpp:1092
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition: DMMMoFEM.cpp:910
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVectorsets the routine to create a local vector associated with the shell DM.
Definition: DMMMoFEM.cpp:876
PetscErrorCode DMMoFEMSetSnesCtx(DM dm, boost::shared_ptr< MoFEM::SnesCtx > &snes_ctx)
Set MoFEM::SnesCtx data structure.
Definition: DMMMoFEM.cpp:811