v0.14.0
DMMoFEM.hpp
Go to the documentation of this file.
1 /** \file DMMoFEM.hpp
2  \brief Discrete manager interface for MoFEM
3  */
4 
5 
6 
7 #ifndef __DMMOFEM_H
8 #define __DMMOFEM_H
9 
10 #define DM_NO_ELEMENT "DMNONEFE"
11 
12 namespace MoFEM {
13 
14 /**
15  * \brief Register MoFEM problem
16  * \ingroup dm
17  */
18 PetscErrorCode DMRegister_MoFEM(const char sname[]);
19 
20 /**
21  * \brief Must be called by user to set MoFEM data structures
22  *
23  * \note If problem exist function create DM for it. If you set bit levels,
24  * those bits are to existing bits. Thus if you do not like to change bit ref
25  * level for existing problem, set bits to zero.
26  *
27  * \ingroup dm
28  */
29 PetscErrorCode DMMoFEMCreateMoFEM(
30  DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[],
31  const MoFEM::BitRefLevel bit_level,
32  const MoFEM::BitRefLevel bit_mask = MoFEM::BitRefLevel().set());
33 
34 /**
35  * @brief Duplicate internal data struture
36  *
37  * @param dm
38  * @param dm_duplicate
39  * @return PetscErrorCode
40  */
41 PetscErrorCode DMMoFEMDuplicateDMCtx(DM dm, DM dm_duplicate);
42 
43 /**
44  * @brief Swap internal data struture
45  *
46  * @param dm
47  * @param dm_swap
48  * @return PetscErrorCode
49  */
50 PetscErrorCode DMMoFEMSwapDMCtx(DM dm, DM dm_swap);
51 
52 /**
53  * \brief Must be called by user to set Sub DM MoFEM data structures
54  * \ingroup dm
55  */
56 PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[]);
57 
58 /**
59  * \brief Get pointer to MoFEM::Interface
60  * @param dm Distributed mesh manager
61  * @param m_field_ptr Pointer to pointer of field interface
62  * @return Error code
63  * \ingroup dm
64  */
65 PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr);
66 
67 /**
68  * \brief Get pointer to problem data structure
69  * \ingroup dm
70  */
71 PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr);
72 
73 /**
74  * If this is set to PETSC_TRUE problem is deleted with DM
75  * @param dm the DM object
76  * @param destroy if PETSC_TRUE problem is destroyed
77  * @return error code
78  */
79 PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem);
80 
81 /**
82  * Get if problem will be destroyed with DM
83  * @param dm the DM object
84  * @param destroy return if PETSC_TRUE problem is destroyed
85  * @return error code
86  */
87 PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem);
88 
89 /**
90  * \brief set squared problem
91  * \ingroup dm
92 
93  It if true is assumed that matrix has the same indexing on rows and
94  columns. This reduces interprocessor communication.
95 
96  */
97 PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem);
98 
99 /**
100  * \brief get squared problem
101  * \ingroup dm
102 
103  It if true is assumed that matrix has the same indexing on rows and
104  columns. This reduces interprocessor communication.
105 
106  */
107 PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem);
108 
109 /**
110  * \brief Resolve shared entities
111  *
112  * @param dm dm
113  * @param fe_name finite element for which shared entities are resolved
114  * @return error code
115  *
116  * \note This function is valid for parallel algebra and serial mesh. It
117  * should be run collectively, i.e. on all processors.
118  *
119  * This allows for tag reduction or tag exchange, f.e.
120  *
121  * \code
122  * CHKERR DMMoFEMResolveSharedFiniteElements(dm,"SHELL_ELEMENT");
123  * Tag th;
124  * CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
125  * ParallelComm* pcomm =
126  * ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
127  * // CHKERR pcomm->reduce_tags(th,MPI_SUM,prisms);
128  * CHKERR pcomm->exchange_tags(th,prisms);
129  * \endcode
130  *
131  * \ingroup dm
132  */
133 PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name);
134 
135 /**
136  * \brief Get finite elements layout in the problem
137  *
138  * In layout is stored information how many elements is on each processor, for
139  * more information look int petsc documentation
140  * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/PetscLayoutCreate.html#PetscLayoutCreate>
141  *
142  * @param dm discrete manager for this problem
143  * @param fe_name finite element name
144  * @param layout pointer to layout, for created layout user takes
145  * responsibility for destroying it.
146  * @return error code
147  *
148  * \ingroup dm
149  */
150 PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name,
151  PetscLayout *layout);
152 
153 /**
154  * \brief add element to dm
155  * \ingroup dm
156  *
157  * \note add_file is a collective, should be executed on all processors.
158  * Otherwise could lead to deadlock.
159  *
160  */
161 PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name);
162 
163 /**
164  * \brief add element to dm
165  * \ingroup dm
166  *
167  * \note add_file is a collective, should be executed on all processors.
168  * Otherwise could lead to deadlock.
169  *
170  */
171 PetscErrorCode DMMoFEMAddElement(DM dm, std::vector<std::string> fe_name);
172 
173 /**
174  * \brief unset element from dm
175  * \ingroup dm
176  */
177 PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name);
178 
179 /**
180  * \brief set local (or ghosted) vector values on mesh for partition only
181  * \ingroup dm
182 
183  * \param l vector
184  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
185  * \param scatter_mode see petsc manual for ScatterMode (The available modes
186  are: SCATTER_FORWARD or SCATTER_REVERSE)
187  *
188  * SCATTER_REVERSE set data to field entities from V vector.
189  *
190  * SCATTER_FORWARD set vector V from data field entities
191 
192  */
193 PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode,
194  ScatterMode scatter_mode);
195 
196 /**
197  * \brief set ghosted vector values on all existing mesh entities
198  * \ingroup dm
199 
200  * \param g vector
201  * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
202  * \param scatter_mode see petsc manual for ScatterMode (The available modes
203  are: SCATTER_FORWARD or SCATTER_REVERSE)
204  *
205  * SCATTER_REVERSE set data to field entities from V vector.
206  *
207  * SCATTER_FORWARD set vector V from data field entities
208 
209  */
210 PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode,
211  ScatterMode scatter_mode);
212 
213 /**
214  * \brief execute finite element method for each element in dm (problem)
215  * \ingroup dm
216  */
217 PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
218 
219 /**
220  * \brief execute finite element method for each element in dm (problem)
221  * \ingroup dm
222  */
223 PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
224 
225 /**
226  * \brief Executes FEMethod for finite elements in DM
227  * @param dm MoFEM discrete manager
228  * @param fe_name name of finite element
229  * @param method pointer to \ref MoFEM::FEMethod
230  * @param low_rank lowest rank of processor
231  * @param up_rank upper run of processor
232  * @return Error code
233  * \ingroup dm
234  */
236  DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank,
237  int up_rank, CacheTupleWeakPtr cache_ptr = CacheTupleSharedPtr());
238 
239 /**
240  * \brief Executes FEMethod for finite elements in DM
241  * @param dm MoFEM discrete manager
242  * @param fe_name name of finite element
243  * @param method pointer to \ref MoFEM::FEMethod
244  * @param low_rank lowest rank of processor
245  * @param up_rank upper run of processor
246  * @return Error code
247  * \ingroup dm
248  */
250  DM dm, const std::string fe_name, boost::shared_ptr<MoFEM::FEMethod> method,
251  int low_rank, int up_rank,
252  CacheTupleWeakPtr cache_ptr = CacheTupleSharedPtr());
253 
254 /**
255  * \brief Executes FEMethod for finite elements in DM
256  * @param dm MoFEM discrete manager
257  * @param fe_name name of element
258  * @param method pointer to \ref MOFEM::FEMethod
259  * @return Error code
260  * \ingroup dm
261  */
262 PetscErrorCode
263 DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method,
264  CacheTupleWeakPtr cache_ptr = CacheTupleSharedPtr());
265 
266 /**
267  * \brief Executes FEMethod for finite elements in DM
268  * @param dm MoFEM discrete manager
269  * @param fe_name name of element
270  * @param method pointer to \ref MOFEM::FEMethod
271  * @return Error code
272  * \ingroup dm
273  */
274 PetscErrorCode
275 DMoFEMLoopFiniteElements(DM dm, const std::string fe_name,
276  boost::shared_ptr<MoFEM::FEMethod> method,
277  CacheTupleWeakPtr cache_ptr = CacheTupleSharedPtr());
278 
279 /**
280  * \brief execute method for dofs on field in problem
281  * \ingroup dm
282  */
283 PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[],
284  MoFEM::DofMethod *method);
285 
286 // /**
287 // * \brief Set compute operator for KSP solver via sub-matrix and IS
288 // *
289 // * @param dm DM
290 // * @return error code
291 // *
292 // * \ingroup dm
293 // */
294 // PetscErrorCode DMMoFEMKSPSetComputeOperatorsViaSubMatrixbByIs(DM dm);
295 
296 /**
297  * \brief set KSP right hand side evaluation function
298  * \ingroup dm
299  */
300 PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[],
301  MoFEM::FEMethod *method,
302  MoFEM::BasicMethod *pre_only,
303  MoFEM::BasicMethod *post_only);
304 
305 /**
306  * \brief set KSP right hand side evaluation function
307  * \ingroup dm
308  */
309 PetscErrorCode
310 DMMoFEMKSPSetComputeRHS(DM dm, const std::string fe_name,
311  boost::shared_ptr<MoFEM::FEMethod> method,
312  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
313  boost::shared_ptr<MoFEM::BasicMethod> post_only);
314 
315 /**
316  * \brief Set KSP operators and push mofem finite element methods
317  *
318  * @param dm DM
319  * @param fe_name finite element name
320  * @param method method on the element (executed for each element in the
321  * problem which given name)
322  * @param pre_only method for pre-process before element method
323  * @param post_only method for post-process after element method
324  * @return error code
325  *
326  * \ingroup dm
327  */
328 PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[],
329  MoFEM::FEMethod *method,
330  MoFEM::BasicMethod *pre_only,
331  MoFEM::BasicMethod *post_only);
332 
333 /**
334  * \brief Set KSP operators and push mofem finite element methods
335  *
336  * @param dm DM
337  * @param fe_name finite element name
338  * @param method method on the element (executed for each element in the
339  * problem which given name)
340  * @param pre_only method for pre-process before element method
341  * @param post_only method for post-process after element method
342  * @return error code
343  *
344  * \ingroup dm
345  */
346 PetscErrorCode
347 DMMoFEMKSPSetComputeOperators(DM dm, const std::string fe_name,
348  boost::shared_ptr<MoFEM::FEMethod> method,
349  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
350  boost::shared_ptr<MoFEM::BasicMethod> post_only);
351 
352 /**
353  * \brief set SNES residual evaluation function
354  * \ingroup dm
355  */
356 PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[],
357  MoFEM::FEMethod *method,
358  MoFEM::BasicMethod *pre_only,
359  MoFEM::BasicMethod *post_only);
360 
361 /**
362  * \brief set SNES residual evaluation function
363  * \ingroup dm
364  */
365 PetscErrorCode
366 DMMoFEMSNESSetFunction(DM dm, const std::string fe_name,
367  boost::shared_ptr<MoFEM::FEMethod> method,
368  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
369  boost::shared_ptr<MoFEM::BasicMethod> post_only);
370 
371 /**
372  * \brief set SNES Jacobian evaluation function
373  * \ingroup dm
374  */
375 PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[],
376  MoFEM::FEMethod *method,
377  MoFEM::BasicMethod *pre_only,
378  MoFEM::BasicMethod *post_only);
379 
380 /**
381  * \brief set SNES Jacobian evaluation function
382  * \ingroup dm
383  */
384 PetscErrorCode
385 DMMoFEMSNESSetJacobian(DM dm, const std::string fe_name,
386  boost::shared_ptr<MoFEM::FEMethod> method,
387  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
388  boost::shared_ptr<MoFEM::BasicMethod> post_only);
389 
390 /**
391  * \brief set TS implicit function evaluation function
392  * \ingroup dm
393  */
394 PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[],
395  MoFEM::FEMethod *method,
396  MoFEM::BasicMethod *pre_only,
397  MoFEM::BasicMethod *post_only);
398 
399 /**
400  * \brief set TS implicit function evaluation function
401  * \ingroup dm
402  */
403 PetscErrorCode
404 DMMoFEMTSSetIFunction(DM dm, const std::string fe_name,
405  boost::shared_ptr<MoFEM::FEMethod> method,
406  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
407  boost::shared_ptr<MoFEM::BasicMethod> post_only);
408 
409 /**
410  * \brief set TS Jacobian evaluation function
411  * \ingroup dm
412  */
413 PetscErrorCode
414 DMMoFEMTSSetIJacobian(DM dm, const std::string fe_name,
415  boost::shared_ptr<MoFEM::FEMethod> method,
416  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
417  boost::shared_ptr<MoFEM::BasicMethod> post_only);
418 
419 /**
420  * \brief set TS Jacobian evaluation function
421  * \ingroup dm
422  */
423 PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, const char fe_name[],
424  MoFEM::FEMethod *method,
425  MoFEM::BasicMethod *pre_only,
426  MoFEM::BasicMethod *post_only);
427 
428 /**
429  * @brief set TS the right hand side function
430  *
431  * <a
432  * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetRHSFunction.html#TSSetRHSFunction>See
433  * petsc documentation</a>
434  *
435  * @param dm
436  * @param fe_name
437  * @param method
438  * @param pre_only
439  * @param post_only
440  * @return PetscErrorCode
441  */
442 PetscErrorCode
443 DMMoFEMTSSetRHSFunction(DM dm, const std::string fe_name,
444  boost::shared_ptr<MoFEM::FEMethod> method,
445  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
446  boost::shared_ptr<MoFEM::BasicMethod> post_only);
447 
448 PetscErrorCode DMMoFEMTSSetRHSFunction(DM dm, const char fe_name[],
449  MoFEM::FEMethod *method,
450  MoFEM::BasicMethod *pre_only,
451  MoFEM::BasicMethod *post_only);
452 
453 /**
454  * @brief set TS the right hand side jacobian
455  *
456  * <a
457  * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetRHSJacobian.html>See
458  * petsc documentation</a>
459  *
460  * @param dm
461  * @param fe_name
462  * @param method
463  * @param pre_only
464  * @param post_only
465  * @return PetscErrorCode
466  */
467 PetscErrorCode
468 DMMoFEMTSSetRHSJacobian(DM dm, const std::string fe_name,
469  boost::shared_ptr<MoFEM::FEMethod> method,
470  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
471  boost::shared_ptr<MoFEM::BasicMethod> post_only);
472 
473 PetscErrorCode DMMoFEMTSSetRHSJacobian(DM dm, const char fe_name[],
474  MoFEM::FEMethod *method,
475  MoFEM::BasicMethod *pre_only,
476  MoFEM::BasicMethod *post_only);
477 
478 /**
479  * \brief set TS implicit function evaluation function
480  * \ingroup dm
481  */
482 PetscErrorCode
483 DMMoFEMTSSetI2Function(DM dm, const std::string fe_name,
484  boost::shared_ptr<MoFEM::FEMethod> method,
485  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
486  boost::shared_ptr<MoFEM::BasicMethod> post_only);
487 /**
488  * \brief set TS implicit function evaluation function
489  * \ingroup dm
490  */
491 PetscErrorCode DMMoFEMTSSetI2Function(DM dm, const char fe_name[],
492  MoFEM::FEMethod *method,
493  MoFEM::BasicMethod *pre_only,
494  MoFEM::BasicMethod *post_only);
495 
496 /**
497  * \brief set TS Jacobian evaluation function
498  * \ingroup dm
499  */
500 PetscErrorCode
501 DMMoFEMTSSetI2Jacobian(DM dm, const std::string fe_name,
502  boost::shared_ptr<MoFEM::FEMethod> method,
503  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
504  boost::shared_ptr<MoFEM::BasicMethod> post_only);
505 /**
506  * \brief set TS Jacobian evaluation function
507  * \ingroup dm
508  */
509 PetscErrorCode
510 DMMoFEMTSSetI2Jacobian(DM dm, const char fe_name[],
511  MoFEM::FEMethod *method,
512  MoFEM::BasicMethod *pre_only,
513  MoFEM::BasicMethod *post_only);
514 
515 /**
516  * @brief Set Monitor To TS solver
517  *
518  * <a
519  * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html>See
520  * PETSc documentaton here</a>
521  *
522  * @param dm
523  * @param ts time solver
524  * @param fe_name
525  * @param method
526  * @param pre_only
527  * @param post_only
528  * @return PetscErrorCod
529  */
530 PetscErrorCode
531 DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name,
532  boost::shared_ptr<MoFEM::FEMethod> method,
533  boost::shared_ptr<MoFEM::BasicMethod> pre_only,
534  boost::shared_ptr<MoFEM::BasicMethod> post_only);
535 
536 /**
537  * @brief Set Monitor To TS solver
538  *
539  * <a
540  * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html>See
541  * PETSc documentaton here</a>
542  *
543  * @param dm
544  * @param ts time solver
545  * @param fe_name
546  * @param method
547  * @param pre_only
548  * @param post_only
549  * @return PetscErrorCod
550  */
551 PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const char fe_name[],
552  MoFEM::FEMethod *method,
553  MoFEM::BasicMethod *pre_only,
554  MoFEM::BasicMethod *post_only);
555 
556 /**
557  * \brief get MoFEM::KspCtx data structure
558  * \ingroup dm
559  */
560 PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx);
561 
562 /**
563  * \brief get MoFEM::KspCtx data structure
564  * \ingroup dm
565  */
566 PetscErrorCode
567 DMMoFEMGetKspCtx(DM dm, const boost::shared_ptr<MoFEM::KspCtx> &ksp_ctx);
568 
569 /**
570  * \brief set MoFEM::KspCtx data structure
571  * \ingroup dm
572  */
573 PetscErrorCode DMMoFEMSetKspCtx(DM dm,
574  boost::shared_ptr<MoFEM::KspCtx> ksp_ctx);
575 
576 /**
577  * \brief get MoFEM::SnesCtx data structure
578  * \ingroup dm
579  */
580 PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx);
581 
582 /**
583  * \brief get MoFEM::SnesCtx data structure
584  * \ingroup dm
585  */
586 PetscErrorCode
587 DMMoFEMGetSnesCtx(DM dm, const boost::shared_ptr<MoFEM::SnesCtx> &snes_ctx);
588 
589 /**
590  * \brief Set MoFEM::SnesCtx data structure
591  * \ingroup dm
592 
593  */
594 PetscErrorCode DMMoFEMSetSnesCtx(DM dm,
595  boost::shared_ptr<MoFEM::SnesCtx> snes_ctx);
596 
597 /**
598  * \brief get MoFEM::TsCtx data structure
599  * \ingroup dm
600  */
601 PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx);
602 
603 /**
604  * \brief get MoFEM::TsCtx data structure
605  * \ingroup dm
606  */
607 PetscErrorCode DMMoFEMGetTsCtx(DM dm,
608  const boost::shared_ptr<MoFEM::TsCtx> &ts_ctx);
609 
610 /**
611  * \brief Set MoFEM::TsCtx data structure
612  * \ingroup dm
613 
614  It take over pointer, do not delete it, DM will destroy pointer
615  when is destroyed.
616 
617  */
618 PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr<MoFEM::TsCtx> ts_ctx);
619 
620 /** sets if read mesh is partitioned
621  * \ingroup dm
622  */
623 PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned);
624 
625 /** get if read mesh is partitioned
626  * \ingroup dm
627  */
628 PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned);
629 
630 /**
631  * \brief Set operators for MoFEM dm
632  * @param dm
633  * @return error code
634  * \ingroup dm
635  */
636 PetscErrorCode DMSetOperators_MoFEM(DM dm);
637 
638 /**
639  * \brief Create dm data structure with MoFEM data structure
640  * \ingroup dm
641  */
642 PetscErrorCode DMCreate_MoFEM(DM dm);
643 
644 /**
645  * \brief Destroys dm with MoFEM data structure
646  * \ingroup dm
647  */
648 PetscErrorCode DMDestroy_MoFEM(DM dm);
649 
650 /**
651  * \brief DMShellSetCreateGlobalVector
652  * \ingroup dm
653  *
654  * sets the routine to create a global vector
655  * associated with the shell DM
656  */
657 PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g);
658 
659 /**
660  * \brief DMShellSetCreateGlobalVector
661  * \ingroup dm
662  *
663  * sets the routine to create a global vector
664  * associated with the shell DM
665  */
666 PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, SmartPetscObj<Vec> &g_ptr);
667 
668 /**
669  * \brief DMShellSetCreateLocalVector
670  * \ingroup dm
671  *
672  * sets the routine to create a local vector
673  * associated with the shell DM
674  */
675 PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l);
676 
677 /**
678  * DMShellSetCreateMatrix
679  * \ingroup dm
680  *
681  * sets the routine to create a matrix associated with the shell DM
682  */
683 PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M);
684 
685 /**
686  * DMShellSetCreateMatrix
687  * \ingroup dm
688  *
689  * sets the routine to create a matrix associated with the shell DM
690  */
691 PetscErrorCode DMCreateMatrix_MoFEM(DM dm, SmartPetscObj<Mat> &M);
692 
693 /**
694  * Set options for MoFEM DM
695  * \ingroup dm
696  */
697 #if PETSC_VERSION_GE(3, 7, 0)
698 PetscErrorCode DMSetFromOptions_MoFEM(PetscOptionItems *PetscOptionsObject,
699  DM dm);
700 #elif PETSC_VERSION_GE(3, 5, 3)
701 PetscErrorCode DMSetFromOptions_MoFEM(PetscOptions *PetscOptionsObject, DM dm);
702 #else
703 PetscErrorCode DMSetFromOptions_MoFEM(DM dm);
704 #endif
705 
706 /**
707  * sets up the MoFEM structures inside a DM object
708  * \ingroup dm
709  */
710 PetscErrorCode DMSetUp_MoFEM(DM dm);
711 
712 /**
713  * Sets up the MoFEM structures inside a DM object for sub dm
714  * \ingroup dm
715  */
716 PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm);
717 
718 /**
719  * Add field to sub dm problem on rows
720  * \ingroup dm
721  */
722 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[]);
723 
724 /** @copydoc DMMoFEMAddSubFieldRow(DM dm, const char field_name[]) */
725 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name);
726 
727 /**
728  * @brief Add field to sub dm problem on rows
729  * \ingroup dm
730  *
731  * @param dm
732  * @param field_name
733  * @param m
734  * @return PetscErrorCode
735  */
736 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[],
737  boost::shared_ptr<Range> r_ptr);
738 
739 /** @copydoc DMMoFEMAddSubFieldRow(DM dm, const char field_name[], boost::shared_ptr<Range> r_ptr) */
740 PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name,
741  boost::shared_ptr<Range> r_ptr);
742 
743 /**
744  * Add field to sub dm problem on columns
745  * \ingroup dm
746  */
747 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[]);
748 
749 /** @copydoc DMMoFEMAddSubFieldCol(DM dm, const char field_name[]) */
750 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name);
751 
752 /**
753  * @brief Add field to sub dm problem on columns
754  *
755  * @param dm
756  * @param field_name
757  * @param range of entities
758  * @return PetscErrorCode
759  */
760 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[],
761  boost::shared_ptr<Range> r_ptr);
762 
763 
764 /** @copydoc DMMoFEMAddSubFieldCol(DM dm, const char field_name[], boost::shared_ptr<Range> r_ptr); */
765 PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name,
766  boost::shared_ptr<Range> r_ptr);
767 
768 /**
769  * Return true if this DM is sub problem
770  \ingroup dm
771  * @param dm the DM object
772  * @param is_subproblem true if subproblem
773  * @return error code
774  */
775 PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm);
776 
777 /**
778  * \brief get sub problem is
779  * @param dm has to be created with DMMoFEMSetSquareProblem
780  * @param is return is on the row
781  * @return error code
782  *
783  * Returns IS with global indices of the DM used to create SubDM
784  *
785  */
786 PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is);
787 
788 /**
789  * \brief get sub problem is
790  * @param dm has to be created with DMMoFEMSetSquareProblem
791  * @param is return is on the row
792  * @return error code
793  *
794  * Returns IS with global indices of the DM used to create SubDM
795  *
796  */
797 PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is);
798 
799 /**
800  * \brief Add problem to composite DM on row
801  \ingroup dm
802  *
803  * This create block on row with DOFs from problem of given name
804  *
805  * @param dm the DM object
806  * @param prb_name add problem name
807  * @return error code
808  */
809 PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[]);
810 
811 /**
812  * \brief Add problem to composite DM on col
813  * \ingroup dm
814  *
815  * This create block on col with DOFs from problem of given name
816  *
817  * @param dm the DM object
818  * @param prb_name add problem name
819  * @return error code
820  */
821 PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[]);
822 
823 /**
824  * \brief Get if this DM is composite DM
825  * \ingroup dm
826  *
827  * @param dm the DM object
828  * @param is_comp_dm return true if composite problem here
829  * @return error code
830  */
831 PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm);
832 
833 /**
834  * destroy the MoFEM structure
835  * \ingroup dm
836  */
837 PetscErrorCode DMDestroy_MoFEM(DM dm);
838 
839 /**
840  * DMShellSetGlobalToLocal
841  * \ingroup dm
842  *
843  * the routine that begins the global to local scatter
844  */
845 PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec);
846 
847 /**
848  * DMShellSetGlobalToLocal
849  * \ingroup dm
850  *
851  * the routine that begins the global to local scatter
852  */
853 PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec);
854 
855 /**
856  * DMShellSetLocalToGlobal
857  * \ingroup dm
858  *
859  * the routine that begins the local to global scatter
860  */
861 PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
862 
863 /**
864  * DMShellSetLocalToGlobal
865  * \ingroup dm
866  *
867  * the routine that ends the local to global scatter
868  */
869 PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
870 
871 /**
872  * DMShellSetLocalToGlobal
873  * \ingroup dm
874  *
875  * the routine that ends the local to global scatter
876  */
877 PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec);
878 
879 /**
880  * Creates a set of IS objects with the global indices of dofs for each field
881  * @param dm The number of fields (or NULL if not requested)
882  *
883  * Output:
884  * @param numFields The number of fields (or NULL if not requested)
885  * @param fieldNames The name for each field (or NULL if not requested)
886  * @param fields The global indices for each field (or NULL if not
887  requested)
888  *
889  * @return error code
890 
891  * \note The user is responsible for freeing all requested arrays. In
892  particular,
893  * every entry of names should be freed with PetscFree(), every entry of fields
894  * should be destroyed with ISDestroy(), and both arrays should be freed with
895  * PetscFree().
896 
897  \ingroup dm
898 
899  */
900 PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields,
901  char ***fieldNames, IS **fields);
902 
903 /**
904  * \brief get field is in the problem
905  * @param dm the DM objects
906  * @param rc ROW or COL (no difference is problem is squared)
907  * @param field_name name of the field
908  * @param is returned the IS object
909  * @return error code
910  *
911  * \code
912  * IS is;
913  * ierr = DMMoFEMGetFieldIS(dm,ROW,"DISP",&is_disp); CHKERRG(ierr);
914  * \endcode
915  *
916  *
917  \ingroup dm
918  */
919 PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[],
920  IS *is);
921 
922 /**
923  * @brief Set verbosity level
924  *
925  * @param dm
926  * @param verb see VERBOSITY_LEVELS for list of the levels
927  * @return PetscErrorCode
928  */
929 PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb);
930 
931 /**
932  * \brief PETSc Discrete Manager data structure
933  *
934  * This structure should not be accessed or modified by user. Is not
935  * available from outside MoFEM DM manager. However user can inherit dat
936  * class and add data for additional functionality.
937  *
938  * This is part of implementation for PETSc interface, see more details in
939  * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/index.html>
940  *
941  * \ingroup dm
942  *
943  */
944 struct DMCtx : public UnknownInterface {
945 
946  MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
947  UnknownInterface **iface) const;
948 
949  Interface *mField_ptr; ///< MoFEM interface
950  PetscBool isProblemBuild; ///< True if problem is build
951  std::string problemName; ///< Problem name
952 
953  // Options
954  PetscBool isPartitioned; ///< true if read mesh is on parts
955  PetscBool isSquareMatrix; ///< true if rows equals to cols
956 
957  int rAnk, sIze;
958 
959  // pointer to data structures
960  const Problem *problemPtr; ///< pinter to problem data structure
961 
962  // sub problem
963  PetscBool isSubDM;
964  std::vector<std::string> rowFields;
965  std::vector<std::string> colFields;
966  const Problem *problemMainOfSubPtr; ///< pinter to main problem to sub-problem
967 
968  PetscBool isCompDM;
969  std::vector<std::string> rowCompPrb;
970  std::vector<std::string> colCompPrb;
971  std::map<std::string, boost::shared_ptr<Range>> mapTypeRow;
972  std::map<std::string, boost::shared_ptr<Range>> mapTypeCol;
973 
974  PetscBool destroyProblem; ///< If true destroy problem with DM
975 
976  DMCtx();
977  virtual ~DMCtx() = default;
978 
979  int verbosity; ///< verbosity
981 
982  boost::shared_ptr<KspCtx> kspCtx; ///< data structure KSP
983  boost::shared_ptr<SnesCtx> snesCtx; ///< data structure SNES
984  boost::shared_ptr<TsCtx> tsCtx; ///< data structure for TS solver
985 };
986 
987 /**
988  * @brief get problem pointer from DM
989  *
990  */
991 inline auto getProblemPtr(DM dm) {
992  const MoFEM::Problem *problem_ptr;
993  CHK_THROW_MESSAGE(DMMoFEMGetProblemPtr(dm, &problem_ptr),
994  "Get cot get problem ptr from DM");
995  return problem_ptr;
996 };
997 
998 /**
999  * @brief Get smart matrix from DM
1000  * \ingroup dm
1001  *
1002  */
1003 inline auto createDMMatrix(DM dm) {
1005  ierr = DMCreateMatrix_MoFEM(dm, a);
1006  CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1007  return a;
1008 };
1009 
1010 /** @deprecated use createDMMatrix */
1011 DEPRECATED inline auto smartCreateDMMatrix(DM dm) { return createDMMatrix(dm); }
1012 
1013 /**
1014  * @brief Get smart vector from DM
1015  * \ingroup dm
1016  *
1017  */
1018 inline auto createDMVector(DM dm) {
1021  CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1022  return v;
1023 };
1024 
1025 /** @deprecated use createDMVector*/
1026 DEPRECATED inline auto smartCreateDMVector(DM dm) { return createDMVector(dm); }
1027 
1028 /**
1029  * @brief Get KSP context data structure used by DM
1030  *
1031  */
1032 inline auto getDMKspCtx(DM dm) {
1033  boost::shared_ptr<MoFEM::KspCtx> ksp_ctx;
1034  ierr = DMMoFEMGetKspCtx(dm, ksp_ctx);
1035  CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1036  return ksp_ctx;
1037 };
1038 
1039 /** @deprecated getDMKspCtx */
1040 DEPRECATED inline auto smartGetDMKspCtx(DM dm) { return getDMKspCtx(dm); }
1041 
1042 /**
1043  * @brief Get SNES context data structure used by DM
1044  *
1045  */
1046 inline auto getDMSnesCtx(DM dm) {
1047  boost::shared_ptr<MoFEM::SnesCtx> snes_ctx;
1048  ierr = DMMoFEMGetSnesCtx(dm, snes_ctx);
1049  CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1050  return snes_ctx;
1051 };
1052 
1053 /** @deprecated use smartGetDMSnesCtx*/
1054 DEPRECATED inline auto smartGetDMSnesCtx(DM dm) { return getDMSnesCtx(dm); }
1055 
1056 /**
1057  * @brief Get TS context data structure used by DM
1058  *
1059  */
1060 inline auto getDMTsCtx(DM dm) {
1061  boost::shared_ptr<MoFEM::TsCtx> ts_ctx;
1062  ierr = DMMoFEMGetTsCtx(dm, ts_ctx);
1063  CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1064  return ts_ctx;
1065 };
1066 
1067 /** @deprecated use getDMTsCtx */
1068 DEPRECATED inline auto smartGetDMTsCtx(DM dm) { return getDMTsCtx(dm); }
1069 
1070 /**
1071  * @brief Get sub problem data structure
1072  *
1073  * @param dm
1074  * @return auto
1075  */
1076 inline auto getDMSubData(DM dm) {
1077  auto prb_ptr = getProblemPtr(dm);
1078  return prb_ptr->getSubData();
1079 };
1080 
1081 
1082 } // namespace MoFEM
1083 
1084 #endif //__DMMOFEM_H
1085 
1086 /**
1087  * \defgroup dm Distributed mesh manager
1088  * \brief Implementation of PETSc DM, managing interactions between mesh data
1089  *structures and vectors and matrices
1090  *
1091  * DM objects are used to manage communication between the algebraic structures
1092  *in PETSc (Vec and Mat) and mesh data structures in PDE-based (or other)
1093  * simulations.
1094  *
1095  * DM is abstract interface, here is it particular implementation for MoFEM
1096  *code.
1097  *
1098  * \ingroup mofem
1099  **/
MoFEM::DMCtx::destroyProblem
PetscBool destroyProblem
If true destroy problem with DM.
Definition: DMMoFEM.hpp:974
MoFEM::DMSetFromOptions_MoFEM
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1263
g
constexpr double g
Definition: shallow_wave.cpp:63
MoFEM::DMMoFEMSetSnesCtx
PetscErrorCode DMMoFEMSetSnesCtx(DM dm, boost::shared_ptr< MoFEM::SnesCtx > snes_ctx)
Set MoFEM::SnesCtx data structure.
Definition: DMMoFEM.cpp:1115
MoFEM::DMMoFEMSetKspCtx
PetscErrorCode DMMoFEMSetKspCtx(DM dm, boost::shared_ptr< MoFEM::KspCtx > ksp_ctx)
set MoFEM::KspCtx data structure
Definition: DMMoFEM.cpp:1089
MoFEM::smartGetDMSnesCtx
DEPRECATED auto smartGetDMSnesCtx(DM dm)
Definition: DMMoFEM.hpp:1054
MoFEM::DMMoFEMKSPSetComputeRHS
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set KSP right hand side evaluation function
Definition: DMMoFEM.cpp:641
DEPRECATED
#define DEPRECATED
Definition: definitions.h:17
MoFEM::DMCtx::referenceNumber
int referenceNumber
Definition: DMMoFEM.hpp:980
MoFEM::DMMoFEMAddSubFieldCol
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition: DMMoFEM.cpp:284
MoFEM::smartGetDMKspCtx
DEPRECATED auto smartGetDMKspCtx(DM dm)
Definition: DMMoFEM.hpp:1040
MoFEM::DMMoFEMGetDestroyProblem
PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem)
Definition: DMMoFEM.cpp:451
MoFEM::DMCtx::isCompDM
PetscBool isCompDM
Definition: DMMoFEM.hpp:968
MoFEM::FEMethod
structure for User Loop Methods on finite elements
Definition: LoopMethods.hpp:369
CHK_THROW_MESSAGE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:596
MoFEM::DMMoFEMSetSquareProblem
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition: DMMoFEM.cpp:460
MoFEM::getDMKspCtx
auto getDMKspCtx(DM dm)
Get KSP context data structure used by DM.
Definition: DMMoFEM.hpp:1032
MoFEM::DMCtx::problemPtr
const Problem * problemPtr
pinter to problem data structure
Definition: DMMoFEM.hpp:960
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::DMGlobalToLocalBegin_MoFEM
PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1379
MoFEM::DMCtx::~DMCtx
virtual ~DMCtx()=default
MoFEM::DMMoFEMGetSubColIS
PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is)
get sub problem is
Definition: DMMoFEM.cpp:353
MoFEM::DMMoFEMAddColCompositeProblem
PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on col.
Definition: DMMoFEM.cpp:389
MoFEM::DMSetUp_MoFEM
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1285
MoFEM::DMoFEMMeshToLocalVector
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMoFEM.cpp:527
MoFEM::DMMoFEMTSSetRHSJacobian
PetscErrorCode DMMoFEMTSSetRHSJacobian(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 the right hand side jacobian
Definition: DMMoFEM.cpp:926
MoFEM::DMMoFEMGetIsSubDM
PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm)
Definition: DMMoFEM.cpp:326
MoFEM::DofMethod
Data structure to exchange data between mofem and User Loop Methods on entities.
Definition: LoopMethods.hpp:493
MoFEM::DMMoFEMKSPSetComputeOperators
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: DMMoFEM.cpp:682
ts_ctx
MoFEM::TsCtx * ts_ctx
Definition: level_set.cpp:1932
MoFEM::DMLocalToGlobalBegin_MoFEM
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1416
MoFEM::DMCtx::sIze
int sIze
Definition: DMMoFEM.hpp:957
MoFEM::getDMSubData
auto getDMSubData(DM dm)
Get sub problem data structure.
Definition: DMMoFEM.hpp:1076
MoFEM::DMMoFEMSwapDMCtx
PetscErrorCode DMMoFEMSwapDMCtx(DM dm, DM dm_swap)
Swap internal data struture.
Definition: DMMoFEM.cpp:200
MoFEM::createDMMatrix
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition: DMMoFEM.hpp:1003
MoFEM::DMMoFEMAddElement
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition: DMMoFEM.cpp:501
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::DMMoFEMGetIsCompDM
PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm)
Get if this DM is composite DM.
Definition: DMMoFEM.cpp:409
MoFEM::DMCreateGlobalVector_MoFEM
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition: DMMoFEM.cpp:1171
MoFEM::DMCtx::mapTypeRow
std::map< std::string, boost::shared_ptr< Range > > mapTypeRow
Definition: DMMoFEM.hpp:971
MoFEM::DMMoFEMSetDestroyProblem
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
Definition: DMMoFEM.cpp:442
MoFEM::DMCtx::mapTypeCol
std::map< std::string, boost::shared_ptr< Range > > mapTypeCol
Definition: DMMoFEM.hpp:972
PlasticOps::M
FTensor::Index< 'M', 3 > M
Definition: PlasticOps.hpp:117
MoFEM::smartGetDMTsCtx
DEPRECATED auto smartGetDMTsCtx(DM dm)
Definition: DMMoFEM.hpp:1068
MoFEM::DMCreateMatrix_MoFEM
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition: DMMoFEM.cpp:1201
MoFEM::DMMoFEMAddRowCompositeProblem
PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on row.
Definition: DMMoFEM.cpp:371
MoFEM::DMCtx::rAnk
int rAnk
Definition: DMMoFEM.hpp:957
MoFEM::createDMVector
auto createDMVector(DM dm)
Get smart vector from DM.
Definition: DMMoFEM.hpp:1018
MoFEM::DMMoFEMTSSetIJacobian
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: DMMoFEM.cpp:857
MoFEM::DMoFEMLoopFiniteElementsUpAndLowRank
PetscErrorCode DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank, int up_rank, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:571
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
a
constexpr double a
Definition: approx_sphere.cpp:30
MoFEM::DMMoFEMTSSetI2Jacobian
PetscErrorCode DMMoFEMTSSetI2Jacobian(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: DMMoFEM.cpp:1021
MoFEM::DMDestroy_MoFEM
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
Definition: DMMoFEM.cpp:83
MoFEM::DMSubDMSetUp_MoFEM
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition: DMMoFEM.cpp:1332
MoFEM::DMMoFEMTSSetI2Function
PetscErrorCode DMMoFEMTSSetI2Function(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 implicit function evaluation function
Definition: DMMoFEM.cpp:979
MoFEM::DMCtx::verbosity
int verbosity
verbosity
Definition: DMMoFEM.hpp:979
MoFEM::DMMoFEMCreateSubDM
PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[])
Must be called by user to set Sub DM MoFEM data structures.
Definition: DMMoFEM.cpp:219
RowColData
RowColData
RowColData.
Definition: definitions.h:123
MoFEM::DMMoFEMGetSubRowIS
PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is)
get sub problem is
Definition: DMMoFEM.cpp:335
MoFEM::DMCtx::kspCtx
boost::shared_ptr< KspCtx > kspCtx
data structure KSP
Definition: DMMoFEM.hpp:982
MoFEM::DMCtx::colCompPrb
std::vector< std::string > colCompPrb
Definition: DMMoFEM.hpp:970
MoFEM::DMoFEMMeshToGlobalVector
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
Definition: DMMoFEM.cpp:539
MoFEM::DMMoFEMGetSnesCtx
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
Definition: DMMoFEM.cpp:1098
MoFEM::TsCtx
Interface for Time Stepping (TS) solver.
Definition: TsCtx.hpp:17
MoFEM::DMRegister_MoFEM
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMoFEM.cpp:47
MoFEM::DMCtx::isProblemBuild
PetscBool isProblemBuild
True if problem is build.
Definition: DMMoFEM.hpp:950
MoFEM::DMCtx::tsCtx
boost::shared_ptr< TsCtx > tsCtx
data structure for TS solver
Definition: DMMoFEM.hpp:984
MoFEM::smartCreateDMMatrix
DEPRECATED auto smartCreateDMMatrix(DM dm)
Definition: DMMoFEM.hpp:1011
MoFEM::DMMoFEMSNESSetJacobian
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: DMMoFEM.cpp:763
MoFEM::smartCreateDMVector
DEPRECATED auto smartCreateDMVector(DM dm)
Definition: DMMoFEM.hpp:1026
MoFEM::DMoFEMPreProcessFiniteElements
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition: DMMoFEM.cpp:550
MoFEM::DMCtx
PETSc Discrete Manager data structure.
Definition: DMMoFEM.hpp:944
MoFEM::DMCtx::isSquareMatrix
PetscBool isSquareMatrix
true if rows equals to cols
Definition: DMMoFEM.hpp:955
MoFEM::DMMoFEMGetSquareProblem
PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem)
get squared problem
Definition: DMMoFEM.cpp:491
MoFEM::DMGlobalToLocalEnd_MoFEM
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1387
MoFEM::BasicMethod
Data structure to exchange data between mofem and User Loop Methods.
Definition: LoopMethods.hpp:183
MoFEM::DMoFEMPostProcessFiniteElements
PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition: DMMoFEM.cpp:560
MoFEM::CacheTupleSharedPtr
boost::shared_ptr< CacheTuple > CacheTupleSharedPtr
Definition: FEMultiIndices.hpp:495
MoFEM::DMMoFEMCreateMoFEM
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: DMMoFEM.cpp:118
MoFEM::DMCtx::isPartitioned
PetscBool isPartitioned
true if read mesh is on parts
Definition: DMMoFEM.hpp:954
MoFEM::DMCtx::DMCtx
DMCtx()
Definition: DMMoFEM.cpp:18
MoFEM::DMSetOperators_MoFEM
PetscErrorCode DMSetOperators_MoFEM(DM dm)
Set operators for MoFEM dm.
Definition: DMMoFEM.cpp:53
MoFEM::DMCreateFieldIS_MoFEM
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition: DMMoFEM.cpp:1451
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::DMCtx::snesCtx
boost::shared_ptr< SnesCtx > snesCtx
data structure SNES
Definition: DMMoFEM.hpp:983
MoFEM::DMMoFEMResolveSharedFiniteElements
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name)
Resolve shared entities.
Definition: DMMoFEM.cpp:468
MoFEM::DMMoFEMGetKspCtx
PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx)
get MoFEM::KspCtx data structure
Definition: DMMoFEM.cpp:1072
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
MoFEM::DMMoFEMSetTsCtx
PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr< MoFEM::TsCtx > ts_ctx)
Set MoFEM::TsCtx data structure.
Definition: DMMoFEM.cpp:1163
v
const double v
phase velocity of light in medium (cm/ns)
Definition: initial_diffusion.cpp:40
MoFEM::DMMoFEMTSSetRHSFunction
PetscErrorCode DMMoFEMTSSetRHSFunction(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 the right hand side function
Definition: DMMoFEM.cpp:886
MoFEM::DMCreate_MoFEM
PetscErrorCode DMCreate_MoFEM(DM dm)
Create dm data structure with MoFEM data structure.
Definition: DMMoFEM.cpp:75
MoFEM::DMCtx::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: DMMoFEM.cpp:41
MoFEM::DMMoFEMGetFieldIS
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
Definition: DMMoFEM.cpp:1496
MoFEM::DMCtx::mField_ptr
Interface * mField_ptr
MoFEM interface.
Definition: DMMoFEM.hpp:949
MoFEM::DMoFEMGetInterfacePtr
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
Definition: DMMoFEM.cpp:418
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MoFEM::DMMoFEMTSSetMonitor
PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, 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 Monitor To TS solver.
Definition: DMMoFEM.cpp:1060
MoFEM::DMMoFEMTSSetIFunction
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: DMMoFEM.cpp:804
MoFEM::getProblemPtr
auto getProblemPtr(DM dm)
get problem pointer from DM
Definition: DMMoFEM.hpp:991
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MoFEM::getCommFromPetscObject
MPI_Comm getCommFromPetscObject(PetscObject obj)
Get the Comm From Petsc Object object.
Definition: PetscSmartObj.hpp:156
MoFEM::DMMoFEMGetIsPartitioned
PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned)
Definition: DMMoFEM.cpp:1138
MoFEM::DMMoFEMGetProblemPtr
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition: DMMoFEM.cpp:430
MoFEM::DMMoFEMUnSetElement
PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name)
unset element from dm
Definition: DMMoFEM.cpp:518
MoFEM::CacheTupleWeakPtr
boost::weak_ptr< CacheTuple > CacheTupleWeakPtr
Definition: FEMultiIndices.hpp:494
MoFEM::DMCtx::colFields
std::vector< std::string > colFields
Definition: DMMoFEM.hpp:965
MoFEM::DMMoFEMGetTsCtx
PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
Definition: DMMoFEM.cpp:1146
MoFEM::KspCtx
Interface for linear (KSP) solver.
Definition: KspCtx.hpp:13
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEM::DMCtx::rowFields
std::vector< std::string > rowFields
Definition: DMMoFEM.hpp:964
MoFEM::getDMSnesCtx
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
Definition: DMMoFEM.hpp:1046
MoFEM::SnesCtx
Interface for nonlinear (SNES) solver.
Definition: SnesCtx.hpp:13
MoFEM::Problem
keeps basic data about problem
Definition: ProblemsMultiIndices.hpp:54
MoFEM::DMMoFEMAddSubFieldRow
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition: DMMoFEM.cpp:242
MoFEM::DMCtx::isSubDM
PetscBool isSubDM
Definition: DMMoFEM.hpp:963
MoFEM::SmartPetscObj< Mat >
MoFEM::DMMoFEMGetProblemFiniteElementLayout
PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name, PetscLayout *layout)
Get finite elements layout in the problem.
Definition: DMMoFEM.cpp:477
MoFEM::DMMoFEMDuplicateDMCtx
PetscErrorCode DMMoFEMDuplicateDMCtx(DM dm, DM dm_duplicate)
Duplicate internal data struture.
Definition: DMMoFEM.cpp:184
MoFEM::DMLocalToGlobalEnd_MoFEM
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1445
MoFEM::DMoFEMLoopFiniteElements
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:590
MoFEM::DMoFEMLoopDofs
PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[], MoFEM::DofMethod *method)
execute method for dofs on field in problem
Definition: DMMoFEM.cpp:609
MoFEM::DMCreateLocalVector_MoFEM
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition: DMMoFEM.cpp:1191
MoFEM::getDMTsCtx
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
Definition: DMMoFEM.hpp:1060
MoFEM::DMCtx::problemName
std::string problemName
Problem name.
Definition: DMMoFEM.hpp:951
l
FTensor::Index< 'l', 3 > l
Definition: matrix_function.cpp:21
MoFEM::DMCtx::rowCompPrb
std::vector< std::string > rowCompPrb
Definition: DMMoFEM.hpp:969
MoFEM::DMCtx::problemMainOfSubPtr
const Problem * problemMainOfSubPtr
pinter to main problem to sub-problem
Definition: DMMoFEM.hpp:966
MoFEM::DMMoFEMSetVerbosity
PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb)
Set verbosity level.
Definition: DMMoFEM.cpp:1507
MoFEM::DMMoFEMSetIsPartitioned
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition: DMMoFEM.cpp:1127
MoFEM::DMMoFEMSNESSetFunction
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: DMMoFEM.cpp:722