v0.16.3
Loading...
Searching...
No Matches
DMMoFEM.hpp
Go to the documentation of this file.
1/** \file DMMoFEM.hpp
2 \brief Discrete manager interface for MoFEM
3
4 This file implements PETSc's DM (Distributed Mesh) interface for MoFEM,
5 providing integration between MoFEM's Problem data structures and PETSc
6 solvers (KSP, SNES, TS, TAO).
7
8 \section dm_problem_connection DM-Problem Integration
9
10 The DM serves as a bridge between MoFEM's core Problem structure and PETSc's
11 algebraic objects (vectors and matrices). Each DM instance contains:
12 - Reference to MoFEM::Interface for mesh and field access
13 - Reference to MoFEM::Problem for DOF management and finite element definitions
14 - Context structures for solver-specific data (KspCtx, SnesCtx, TsCtx)
15
16 \section dm_solver_usage DM Usage with PETSc Solvers
17
18 **KSP (Linear Solvers):**
19 - DM provides matrix and vector creation routines
20 - Integrates with MoFEM finite element assembly for stiffness matrices
21 - Handles DOF mapping between local and global indexing
22
23 **SNES (Nonlinear Solvers):**
24 - DM manages residual and Jacobian evaluation through FEMethod callbacks
25 - Coordinates finite element loops for nonlinear assembly operations
26 - Provides context for Newton-based iteration data
27
28 **TS (Time Steppers):**
29 - DM handles time-dependent mass matrices and residual evaluation
30 - Manages implicit and explicit time integration schemes
31 - Coordinates with MoFEM field history and time-dependent boundary conditions
32
33 \section dm_workflow Typical Workflow
34
35 1. Create DM with DMMoFEMCreateMoFEM() linking to Problem
36 2. Configure solver contexts (KSP/SNES/TS) via DMMoFEMSetXxxCtx()
37 3. Set finite element methods for matrix/vector assembly
38 4. Use standard PETSc solver interfaces with MoFEM-backed DM
39 5. DM automatically handles MoFEM-specific operations during solve
40
41 The DM abstraction enables seamless use of PETSc's solver ecosystem while
42 maintaining access to MoFEM's mesh management and finite element capabilities.
43 */
44
45
46
47#ifndef __DMMOFEM_H
48#define __DMMOFEM_H
49
50#define DM_NO_ELEMENT "DMNONEFE"
51
52namespace MoFEM {
53
54/**
55 * \brief Register MoFEM problem
56 * \ingroup dm
57 *
58 * @param sname Solver name string identifier
59 * @return Error code
60 */
61PetscErrorCode DMRegister_MoFEM(const char sname[]);
62
63/**
64 * @brief Clear solver and Schur data owned by a MoFEM DM context
65 *
66 * This operation is idempotent. Call it before releasing an application-owned
67 * DM when objects retained by the context can hold PETSc references back to
68 * that DM. DMDestroy_MoFEM also calls it once PETSc reaches the type-specific
69 * destroy callback.
70 *
71 * @param dm Distributed mesh manager
72 * @return Error code
73 */
74PetscErrorCode DMMoFEMClearDMCtx(DM dm);
75
76/**
77 * \brief Must be called by user to set MoFEM data structures
78 *
79 * \note If problem exist function create DM for it. If you set bit levels,
80 * those bits are to existing bits. Thus if you do not like to change bit ref
81 * level for existing problem, set bits to zero.
82 *
83 * \ingroup dm
84 */
85PetscErrorCode DMMoFEMCreateMoFEM(
86 DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[],
87 const MoFEM::BitRefLevel bit_level,
88 const MoFEM::BitRefLevel bit_mask = MoFEM::BitRefLevel().set());
89
90/**
91 * @brief Duplicate internal data structure
92 *
93 * @param dm
94 * @param dm_duplicate
95 * @return PetscErrorCode
96 */
97PetscErrorCode DMMoFEMDuplicateDMCtx(DM dm, DM dm_duplicate);
98
99/**
100 * @brief Swap internal data structure
101 *
102 * @param dm
103 * @param dm_swap
104 * @return PetscErrorCode
105 */
106PetscErrorCode DMMoFEMSwapDMCtx(DM dm, DM dm_swap);
107
108/**
109 * \brief Must be called by user to set Sub DM MoFEM data structures
110 * \ingroup dm
111 *
112 * @param subdm Sub distributed mesh manager to create
113 * @param dm Parent distributed mesh manager
114 * @param problem_name Name of the problem to create sub DM for
115 * @return Error code
116 */
117PetscErrorCode DMMoFEMCreateSubDM(DM subdm, DM dm, const char problem_name[]);
118
119/**
120 * \brief Get pointer to MoFEM::Interface
121 * @param dm Distributed mesh manager
122 * @param m_field_ptr Pointer to pointer of field interface
123 * @return Error code
124 * \ingroup dm
125 */
126PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr);
127
128/**
129 * \brief Get pointer to problem data structure
130 * \ingroup dm
131 *
132 * @param dm Distributed mesh manager
133 * @param problem_ptr Pointer to pointer of problem data structure
134 * @return Error code
135 */
136PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr);
137
138/**
139 * If this is set to PETSC_TRUE problem is deleted with DM
140 * @param dm the DM object
141 * @param destroy if PETSC_TRUE problem is destroyed
142 * @return error code
143 */
144PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem);
145
146/**
147 * Get if problem will be destroyed with DM
148 * @param dm the DM object
149 * @param destroy return if PETSC_TRUE problem is destroyed
150 * @return error code
151 */
152PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem);
153
154/**
155 * \brief Rebuild the DM's parent problem in place on a new bit ref level
156 * \ingroup dm
157 *
158 * Collective. For a set-up, partitioned, non-composite parent DM: the problem
159 * keeps its name and the DM, its selector is set to target_bit and
160 * target_mask, the numbered DOFs are rebuilt by the distributed builder
161 * (every index changes; nothing is preserved), the finite elements and the
162 * ghost DOFs are partitioned again, and the vectors the DM caches, its block
163 * matrix structure and its nested Schur data are dropped. Sub-DMs, matrices,
164 * vectors, index sets and solvers made from the old numbering must be
165 * recreated by the caller.
166 *
167 * @param dm parent DMMOFEM, set up with DMMoFEMSetIsPartitioned true
168 * @param target_bit bit ref level of the rebuilt problem
169 * @param target_mask bit ref mask of the rebuilt problem
170 * @param old_row_indices optional, collective: old global row indices of
171 * the DOFs owned by this rank that exist in both numberings; the caller
172 * destroys it
173 * @param new_row_indices optional, collective: their new global row
174 * indices, same order; the caller destroys it
175 * @return error code
176 */
177PetscErrorCode DMMoFEMRebuildProblem(DM dm,
178 const MoFEM::BitRefLevel target_bit,
179 const MoFEM::BitRefLevel target_mask,
180 IS *old_row_indices = PETSC_NULLPTR,
181 IS *new_row_indices = PETSC_NULLPTR);
182
183/**
184 * \brief set squared problem
185 * \ingroup dm
186
187 If true, it is assumed that matrix has the same indexing on rows and
188 columns. This reduces interprocessor communication.
189
190 */
191PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem);
192
193/**
194 * \brief get squared problem
195 * \ingroup dm
196
197 If true, it is assumed that matrix has the same indexing on rows and
198 columns. This reduces interprocessor communication.
199
200 */
201PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem);
202
203/**
204 * \brief Resolve shared entities
205 *
206 * @param dm dm
207 * @param fe_name finite element for which shared entities are resolved
208 * @return error code
209 *
210 * \note This function is valid for parallel algebra and serial mesh. It
211 * should be run collectively, i.e. on all processors.
212 *
213 * This allows for tag reduction or tag exchange, f.e.
214 *
215 * \code
216 * CHKERR DMMoFEMResolveSharedFiniteElements(dm,"SHELL_ELEMENT");
217 * Tag th;
218 * CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
219 * ParallelComm* pcomm =
220 * ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
221 * // CHKERR pcomm->reduce_tags(th,MPI_SUM,prisms);
222 * CHKERR pcomm->exchange_tags(th,prisms);
223 * \endcode
224 *
225 * \ingroup dm
226 */
227PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name);
228
229/**
230 * \brief Get finite elements layout in the problem
231 *
232 * In layout is stored information how many elements are on each processor, for
233 * more information look at petsc documentation
234 * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/PetscLayoutCreate.html#PetscLayoutCreate>
235 *
236 * @param dm discrete manager for this problem
237 * @param fe_name finite element name
238 * @param layout pointer to layout, for created layout user takes
239 * responsibility for destroying it.
240 * @return error code
241 *
242 * \ingroup dm
243 */
244PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name,
245 PetscLayout *layout);
246
247/**
248 * \brief add element to dm
249 * \ingroup dm
250 *
251 * \note add_file is a collective, should be executed on all processors.
252 * Otherwise could lead to deadlock.
253 *
254 * @param dm Distributed mesh manager
255 * @param fe_name Finite element name
256 * @return Error code
257 */
258PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name);
259
260/**
261 * \brief add element to dm
262 * \ingroup dm
263 *
264 * \note add_file is a collective, should be executed on all processors.
265 * Otherwise could lead to deadlock.
266 *
267 * @param dm Distributed mesh manager
268 * @param fe_name Vector of finite element names
269 * @return Error code
270 */
271PetscErrorCode DMMoFEMAddElement(DM dm, std::vector<std::string> fe_name);
272
273/**
274 * \brief unset element from dm
275 * \ingroup dm
276 *
277 * @param dm Distributed mesh manager
278 * @param fe_name Finite element name to remove
279 * @return Error code
280 */
281PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name);
282
283/**
284 * \brief set local (or ghosted) vector values on mesh for partition only
285 * \ingroup dm
286
287 * \param l vector
288 * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
289 * \param scatter_mode see petsc manual for ScatterMode (The available modes
290 are: SCATTER_FORWARD or SCATTER_REVERSE)
291 *
292 * SCATTER_REVERSE set data to field entities from V vector.
293 * SCATTER_FORWARD set vector V from data field entities
294 *
295 * This code will update ghosted entities on all processors
296 \code
297 * auto d_vector = createDMVector(dm);
298 * // fill d_vector on owned entities
299 CHKERR DMoFEMMeshToLocalVector(dm, d_vector, INSERT_VALUES,
300 SCATTER_FORWARD);
301 // update ghost values in d_vector
302 CHKERR VecGhostUpdateBegin(d_vector, INSERT_VALUES, SCATTER_FORWARD);
303 CHKERR VecGhostUpdateEnd(d_vector, INSERT_VALUES, SCATTER_FORWARD);
304 // now d_vector has updated ghost values, and following save values of
305 // vector to fields entities
306 CHKERR DMoFEMMeshToLocalVector(dm, d_vector, INSERT_VALUES,
307 SCATTER_REVERSE);
308 * \endcode
309 *
310 * \note you use DMoFEMMeshToGlobalVector as scatter reverse
311 *
312 * For implementations see VecManager::setLocalGhostVector.
313 */
314PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode,
315 ScatterMode scatter_mode,
317
318/**
319 * \brief set ghosted vector values on all existing mesh entities
320 * \ingroup dm
321
322 * \param g vector
323 * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
324 * \param scatter_mode see petsc manual for ScatterMode (The available modes
325 are: SCATTER_FORWARD or SCATTER_REVERSE)
326 *
327 * SCATTER_REVERSE set data to field entities from V vector.
328 *
329 * SCATTER_FORWARD set vector V from data field entities
330
331 */
332PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode,
333 ScatterMode scatter_mode,
335
336/**
337 * \brief execute finite element method for each element in dm (problem)
338 * \ingroup dm
339 *
340 * @param dm Distributed mesh manager
341 * @param method Finite element method to execute for preprocessing
342 * @return Error code
343 */
344PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
345
346/**
347 * \brief execute finite element method for each element in dm (problem)
348 * \ingroup dm
349 *
350 * @param dm Distributed mesh manager
351 * @param method Finite element method to execute for postprocessing
352 * @return Error code
353 */
354PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
355
356/**
357 * \brief Executes FEMethod for finite elements in DM
358 * @param dm MoFEM discrete manager
359 * @param fe_name name of finite element
360 * @param method pointer to \ref MoFEM::FEMethod
361 * @param low_rank lowest rank of processor
362 * @param up_rank upper run of processor
363 * @return Error code
364 * \ingroup dm
365 */
367 DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank,
368 int up_rank, CacheTupleWeakPtr cache_ptr = CacheTupleSharedPtr());
369
370/**
371 * \brief Executes FEMethod for finite elements in DM
372 * @param dm MoFEM discrete manager
373 * @param fe_name name of finite element
374 * @param method pointer to \ref MoFEM::FEMethod
375 * @param low_rank lowest rank of processor
376 * @param up_rank upper run of processor
377 * @return Error code
378 * \ingroup dm
379 */
381 DM dm, const std::string fe_name, boost::shared_ptr<MoFEM::FEMethod> method,
382 int low_rank, int up_rank,
384
385/**
386 * \brief Executes FEMethod for finite elements in DM
387 * @param dm MoFEM discrete manager
388 * @param fe_name name of element
389 * @param method pointer to \ref MOFEM::FEMethod
390 * @return Error code
391 * \ingroup dm
392 */
393PetscErrorCode
394DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method,
396
397/**
398 * \brief Executes FEMethod for finite elements in DM
399 * @param dm MoFEM discrete manager
400 * @param fe_name name of element
401 * @param method pointer to \ref MOFEM::FEMethod
402 * @return Error code
403 * \ingroup dm
404 */
405PetscErrorCode
406DMoFEMLoopFiniteElements(DM dm, const std::string fe_name,
407 boost::shared_ptr<MoFEM::FEMethod> method,
409
410/**
411 * \brief execute method for dofs on field in problem
412 * \ingroup dm
413 */
414PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[],
415 MoFEM::DofMethod *method);
416
417// /**
418// * \brief Set compute operator for KSP solver via sub-matrix and IS
419// *
420// * @param dm DM
421// * @return error code
422// *
423// * \ingroup dm
424// */
425// PetscErrorCode DMMoFEMKSPSetComputeOperatorsViaSubMatrixbByIs(DM dm);
426
427/**
428 * \brief set KSP right hand side evaluation function
429 * \ingroup dm
430 */
431PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[],
432 MoFEM::FEMethod *method,
433 MoFEM::BasicMethod *pre_only,
434 MoFEM::BasicMethod *post_only);
435
436/**
437 * \brief set KSP right hand side evaluation function
438 * \ingroup dm
439 */
440PetscErrorCode
441DMMoFEMKSPSetComputeRHS(DM dm, const std::string fe_name,
442 boost::shared_ptr<MoFEM::FEMethod> method,
443 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
444 boost::shared_ptr<MoFEM::BasicMethod> post_only);
445
446/**
447 * \brief Set KSP operators and push mofem finite element methods
448 *
449 * @param dm DM
450 * @param fe_name finite element name
451 * @param method method on the element (executed for each element in the
452 * problem which given name)
453 * @param pre_only method for pre-process before element method
454 * @param post_only method for post-process after element method
455 * @return error code
456 *
457 * \ingroup dm
458 */
459PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[],
460 MoFEM::FEMethod *method,
461 MoFEM::BasicMethod *pre_only,
462 MoFEM::BasicMethod *post_only);
463
464/**
465 * \brief Set KSP operators and push mofem finite element methods
466 *
467 * @param dm DM
468 * @param fe_name finite element name
469 * @param method method on the element (executed for each element in the
470 * problem which given name)
471 * @param pre_only method for pre-process before element method
472 * @param post_only method for post-process after element method
473 * @return error code
474 *
475 * \ingroup dm
476 */
477PetscErrorCode
478DMMoFEMKSPSetComputeOperators(DM dm, const std::string fe_name,
479 boost::shared_ptr<MoFEM::FEMethod> method,
480 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
481 boost::shared_ptr<MoFEM::BasicMethod> post_only);
482
483/**
484 * \brief set SNES residual evaluation function
485 * \ingroup dm
486 */
487PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[],
488 MoFEM::FEMethod *method,
489 MoFEM::BasicMethod *pre_only,
490 MoFEM::BasicMethod *post_only);
491
492/**
493 * \brief set SNES residual evaluation function
494 * \ingroup dm
495 */
496PetscErrorCode
497DMMoFEMSNESSetFunction(DM dm, const std::string fe_name,
498 boost::shared_ptr<MoFEM::FEMethod> method,
499 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
500 boost::shared_ptr<MoFEM::BasicMethod> post_only);
501
502/**
503 * \brief set SNES Jacobian evaluation function
504 * \ingroup dm
505 */
506PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[],
507 MoFEM::FEMethod *method,
508 MoFEM::BasicMethod *pre_only,
509 MoFEM::BasicMethod *post_only);
510
511/**
512 * \brief set SNES Jacobian evaluation function
513 * \ingroup dm
514 */
515PetscErrorCode
516DMMoFEMSNESSetJacobian(DM dm, const std::string fe_name,
517 boost::shared_ptr<MoFEM::FEMethod> method,
518 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
519 boost::shared_ptr<MoFEM::BasicMethod> post_only);
520
521/**
522 * \brief set TS implicit function evaluation function
523 * \ingroup dm
524 */
525PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[],
526 MoFEM::FEMethod *method,
527 MoFEM::BasicMethod *pre_only,
528 MoFEM::BasicMethod *post_only);
529
530/**
531 * \brief set TS implicit function evaluation function
532 * \ingroup dm
533 */
534PetscErrorCode
535DMMoFEMTSSetIFunction(DM dm, const std::string fe_name,
536 boost::shared_ptr<MoFEM::FEMethod> method,
537 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
538 boost::shared_ptr<MoFEM::BasicMethod> post_only);
539
540/**
541 * \brief set TS Jacobian evaluation function
542 * \ingroup dm
543 */
544PetscErrorCode
545DMMoFEMTSSetIJacobian(DM dm, const std::string fe_name,
546 boost::shared_ptr<MoFEM::FEMethod> method,
547 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
548 boost::shared_ptr<MoFEM::BasicMethod> post_only);
549
550/**
551 * \brief set TS Jacobian evaluation function
552 * \ingroup dm
553 */
554PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, const char fe_name[],
555 MoFEM::FEMethod *method,
556 MoFEM::BasicMethod *pre_only,
557 MoFEM::BasicMethod *post_only);
558
559/**
560 * @brief set TS the right hand side function
561 *
562 * <a
563 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetRHSFunction.html#TSSetRHSFunction>See
564 * petsc documentation</a>
565 *
566 * @param dm
567 * @param fe_name
568 * @param method
569 * @param pre_only
570 * @param post_only
571 * @return PetscErrorCode
572 */
573PetscErrorCode
574DMMoFEMTSSetRHSFunction(DM dm, const std::string fe_name,
575 boost::shared_ptr<MoFEM::FEMethod> method,
576 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
577 boost::shared_ptr<MoFEM::BasicMethod> post_only);
578
579PetscErrorCode DMMoFEMTSSetRHSFunction(DM dm, const char fe_name[],
580 MoFEM::FEMethod *method,
581 MoFEM::BasicMethod *pre_only,
582 MoFEM::BasicMethod *post_only);
583
584/**
585 * @brief set TS the right hand side jacobian
586 *
587 * <a
588 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetRHSJacobian.html>See
589 * petsc documentation</a>
590 *
591 * @param dm
592 * @param fe_name
593 * @param method
594 * @param pre_only
595 * @param post_only
596 * @return PetscErrorCode
597 */
598PetscErrorCode
599DMMoFEMTSSetRHSJacobian(DM dm, const std::string fe_name,
600 boost::shared_ptr<MoFEM::FEMethod> method,
601 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
602 boost::shared_ptr<MoFEM::BasicMethod> post_only);
603
604PetscErrorCode DMMoFEMTSSetRHSJacobian(DM dm, const char fe_name[],
605 MoFEM::FEMethod *method,
606 MoFEM::BasicMethod *pre_only,
607 MoFEM::BasicMethod *post_only);
608
609/**
610 * \brief set TS implicit function evaluation function
611 * \ingroup dm
612 */
613PetscErrorCode
614DMMoFEMTSSetI2Function(DM dm, const std::string fe_name,
615 boost::shared_ptr<MoFEM::FEMethod> method,
616 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
617 boost::shared_ptr<MoFEM::BasicMethod> post_only);
618/**
619 * \brief set TS implicit function evaluation function
620 * \ingroup dm
621 */
622PetscErrorCode DMMoFEMTSSetI2Function(DM dm, const char fe_name[],
623 MoFEM::FEMethod *method,
624 MoFEM::BasicMethod *pre_only,
625 MoFEM::BasicMethod *post_only);
626
627/**
628 * \brief set TS Jacobian evaluation function
629 * \ingroup dm
630 */
631PetscErrorCode
632DMMoFEMTSSetI2Jacobian(DM dm, const std::string fe_name,
633 boost::shared_ptr<MoFEM::FEMethod> method,
634 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
635 boost::shared_ptr<MoFEM::BasicMethod> post_only);
636/**
637 * \brief set TS Jacobian evaluation function
638 * \ingroup dm
639 */
640PetscErrorCode
641DMMoFEMTSSetI2Jacobian(DM dm, const char fe_name[],
642 MoFEM::FEMethod *method,
643 MoFEM::BasicMethod *pre_only,
644 MoFEM::BasicMethod *post_only);
645
646/**
647 * @brief Set Monitor To TS solver
648 *
649 * <a
650 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html>See
651 * PETSc documentation here</a>
652 *
653 * @param dm
654 * @param ts time solver
655 * @param fe_name
656 * @param method
657 * @param pre_only
658 * @param post_only
659 * @return PetscErrorCode
660 */
661PetscErrorCode
662DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name,
663 boost::shared_ptr<MoFEM::FEMethod> method,
664 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
665 boost::shared_ptr<MoFEM::BasicMethod> post_only);
666
667/**
668 * @brief Set Monitor To TS solver
669 *
670 * <a
671 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html>See
672 * PETSc documentation here</a>
673 *
674 * @param dm
675 * @param ts time solver
676 * @param fe_name
677 * @param method
678 * @param pre_only
679 * @param post_only
680 * @return PetscErrorCode
681 */
682PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const char fe_name[],
683 MoFEM::FEMethod *method,
684 MoFEM::BasicMethod *pre_only,
685 MoFEM::BasicMethod *post_only);
686
687/**
688 * \brief get MoFEM::KspCtx data structure
689 * \ingroup dm
690 *
691 * @param dm Distributed mesh manager
692 * @param ksp_ctx Pointer to KSP context structure
693 * @return Error code
694 */
695PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx);
696
697/**
698 * \brief get MoFEM::KspCtx data structure
699 * \ingroup dm
700 *
701 * @param dm Distributed mesh manager
702 * @param ksp_ctx Shared pointer to KSP context structure
703 * @return Error code
704 */
705PetscErrorCode
706DMMoFEMGetKspCtx(DM dm, const boost::shared_ptr<MoFEM::KspCtx> &ksp_ctx);
707
708/**
709 * \brief set MoFEM::KspCtx data structure
710 * \ingroup dm
711 *
712 * @param dm Distributed mesh manager
713 * @param ksp_ctx Shared pointer to KSP context structure to set
714 * @return Error code
715 */
716PetscErrorCode DMMoFEMSetKspCtx(DM dm,
717 boost::shared_ptr<MoFEM::KspCtx> ksp_ctx);
718
719/**
720 * \brief get MoFEM::SnesCtx data structure
721 * \ingroup dm
722 *
723 * @param dm Distributed mesh manager
724 * @param snes_ctx Pointer to SNES context structure
725 * @return Error code
726 */
727PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx);
728
729/**
730 * \brief get MoFEM::SnesCtx data structure
731 * \ingroup dm
732 *
733 * @param dm Distributed mesh manager
734 * @param snes_ctx Shared pointer to SNES context structure
735 * @return Error code
736 */
737PetscErrorCode
738DMMoFEMGetSnesCtx(DM dm, const boost::shared_ptr<MoFEM::SnesCtx> &snes_ctx);
739
740/**
741 * \brief Set MoFEM::SnesCtx data structure
742 * \ingroup dm
743
744 */
745PetscErrorCode DMMoFEMSetSnesCtx(DM dm,
746 boost::shared_ptr<MoFEM::SnesCtx> snes_ctx);
747
748/**
749 * \brief get MoFEM::TsCtx data structure
750 * \ingroup dm
751 */
752PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx);
753
754/**
755 * \brief get MoFEM::TsCtx data structure
756 * \ingroup dm
757 */
758PetscErrorCode DMMoFEMGetTsCtx(DM dm,
759 const boost::shared_ptr<MoFEM::TsCtx> &ts_ctx);
760
761/**
762 * \brief Set MoFEM::TsCtx data structure
763 * \ingroup dm
764
765 It take over pointer, do not delete it, DM will destroy pointer
766 when is destroyed.
767
768 */
769PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr<MoFEM::TsCtx> ts_ctx);
770
771/** sets if read mesh is partitioned
772 * \ingroup dm
773 *
774 * @param dm Distributed mesh manager
775 * @param is_partitioned Boolean flag indicating if mesh is partitioned
776 * @return Error code
777 */
778PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned);
779
780/** get if read mesh is partitioned
781 * \ingroup dm
782 *
783 * @param dm Distributed mesh manager
784 * @param is_partitioned Pointer to boolean flag for partition status
785 * @return Error code
786 */
787PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned);
788
789/**
790 * \brief Set operators for MoFEM dm
791 * @param dm Distributed mesh manager
792 * @return Error code
793 * \ingroup dm
794 */
795PetscErrorCode DMSetOperators_MoFEM(DM dm);
796
797/**
798 * \brief Create dm data structure with MoFEM data structure
799 * \ingroup dm
800 *
801 * @param dm Distributed mesh manager to create
802 * @return Error code
803 */
804PetscErrorCode DMCreate_MoFEM(DM dm);
805
806/**
807 * \brief Destroys dm with MoFEM data structure
808 * \ingroup dm
809 *
810 * @param dm Distributed mesh manager to destroy
811 * @return Error code
812 */
813PetscErrorCode DMDestroy_MoFEM(DM dm);
814
815/**
816 * \brief DMShellSetCreateGlobalVector
817 * \ingroup dm
818 *
819 * sets the routine to create a global vector
820 * associated with the shell DM
821 *
822 * @param dm Distributed mesh manager
823 * @param g Pointer to global vector to create
824 * @return Error code
825 */
826PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g);
827
828/**
829 * \brief DMShellSetCreateGlobalVector
830 * \ingroup dm
831 *
832 * sets the routine to create a global vector
833 * associated with the shell DM
834 */
835PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, SmartPetscObj<Vec> &g_ptr,
837
838/**
839 * \brief DMShellSetCreateLocalVector
840 * \ingroup dm
841 *
842 * sets the routine to create a local vector
843 * associated with the shell DM
844 */
845PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l);
846
847/**
848 * DMShellSetCreateMatrix
849 * \ingroup dm
850 *
851 * sets the routine to create a matrix associated with the shell DM
852 */
853PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M);
854
855/**
856 * DMShellSetCreateMatrix
857 * \ingroup dm
858 *
859 * sets the routine to create a matrix associated with the shell DM
860 */
861PetscErrorCode DMCreateMatrix_MoFEM(DM dm, SmartPetscObj<Mat> &M);
862
863/**
864 * Set options for MoFEM DM
865 * \ingroup dm
866 */
867#if PETSC_VERSION_GE(3, 17, 0)
868PetscErrorCode DMSetFromOptions_MoFEM(DM dm,
869 PetscOptionItems *PetscOptionsObject);
870#elif PETSC_VERSION_GE(3, 7, 0)
871PetscErrorCode DMSetFromOptions_MoFEM(PetscOptionItems *PetscOptionsObject,
872 DM dm);
873#elif PETSC_VERSION_GE(3, 5, 3)
874PetscErrorCode DMSetFromOptions_MoFEM(PetscOptions *PetscOptionsObject, DM dm);
875#else
876PetscErrorCode DMSetFromOptions_MoFEM(DM dm);
877#endif
878
879/**
880 * sets up the MoFEM structures inside a DM object
881 * \ingroup dm
882 */
883PetscErrorCode DMSetUp_MoFEM(DM dm);
884
885/**
886 * Sets up the MoFEM structures inside a DM object for sub dm
887 * \ingroup dm
888 *
889 * @param subdm Sub distributed mesh manager to set up
890 * @return Error code
891 */
892PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm);
893
894/**
895 * Add field to sub dm problem on rows
896 * \ingroup dm
897 *
898 * @param dm Distributed mesh manager
899 * @param field_name Name of field to add to rows
900 * @return Error code
901 */
902PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[]);
903
904/** @copydoc DMMoFEMAddSubFieldRow(DM dm, const char field_name[]) */
905PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name);
906
907/**
908 * @brief Add field to sub dm problem on rows
909 * \ingroup dm
910 *
911 * @param dm
912 * @param field_name
913 * @param m
914 * @return PetscErrorCode
915 */
916PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[],
917 boost::shared_ptr<Range> r_ptr);
918
919/** @copydoc DMMoFEMAddSubFieldRow(DM dm, const char field_name[], boost::shared_ptr<Range> r_ptr) */
920PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name,
921 boost::shared_ptr<Range> r_ptr);
922
923/**
924 * Add field to sub dm problem on columns
925 * \ingroup dm
926 */
927PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[]);
928
929/** @copydoc DMMoFEMAddSubFieldCol(DM dm, const char field_name[]) */
930PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name);
931
932/**
933 * @brief Add field to sub dm problem on columns
934 *
935 * @param dm
936 * @param field_name
937 * @param range of entities
938 * @return PetscErrorCode
939 */
940PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[],
941 boost::shared_ptr<Range> r_ptr);
942
943
944/** @copydoc DMMoFEMAddSubFieldCol(DM dm, const char field_name[], boost::shared_ptr<Range> r_ptr); */
945PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name,
946 boost::shared_ptr<Range> r_ptr);
947
948/**
949 * Return true if this DM is sub problem
950 \ingroup dm
951 * @param dm the DM object
952 * @param is_subproblem true if subproblem
953 * @return error code
954 */
955PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm);
956
957/**
958 * \brief get sub problem is
959 * @param dm has to be created with DMMoFEMSetSquareProblem
960 * @param is return is on the row
961 * @return error code
962 *
963 * Returns IS with global indices of the DM used to create SubDM
964 *
965 */
966PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is);
967
968/**
969 * \brief get sub problem is
970 * @param dm has to be created with DMMoFEMSetSquareProblem
971 * @param is return is on the row
972 * @return error code
973 *
974 * Returns IS with global indices of the DM used to create SubDM
975 *
976 */
977PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is);
978
979/**
980 * \brief Add problem to composite DM on row
981 \ingroup dm
982 *
983 * This create block on row with DOFs from problem of given name
984 *
985 * @param dm the DM object
986 * @param prb_name add problem name
987 * @return error code
988 */
989PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[]);
990
991/**
992 * \brief Add problem to composite DM on col
993 * \ingroup dm
994 *
995 * This create block on col with DOFs from problem of given name
996 *
997 * @param dm the DM object
998 * @param prb_name add problem name
999 * @return error code
1000 */
1001PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[]);
1002
1003/**
1004 * \brief Get if this DM is composite DM
1005 * \ingroup dm
1006 *
1007 * @param dm the DM object
1008 * @param is_comp_dm return true if composite problem here
1009 * @return error code
1010 */
1011PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm);
1012
1013/**
1014 * destroy the MoFEM structure
1015 * \ingroup dm
1016 */
1017PetscErrorCode DMDestroy_MoFEM(DM dm);
1018
1019/**
1020 * DMShellSetGlobalToLocal
1021 * \ingroup dm
1022 *
1023 * the routine that begins the global to local scatter
1024 */
1025PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec);
1026
1027/**
1028 * DMShellSetGlobalToLocal
1029 * \ingroup dm
1030 *
1031 * the routine that begins the global to local scatter
1032 */
1033PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec);
1034
1035/**
1036 * DMShellSetLocalToGlobal
1037 * \ingroup dm
1038 *
1039 * the routine that begins the local to global scatter
1040 */
1041PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
1042
1043/**
1044 * DMShellSetLocalToGlobal
1045 * \ingroup dm
1046 *
1047 * the routine that ends the local to global scatter
1048 */
1049PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
1050
1051/**
1052 * DMShellSetLocalToGlobal
1053 * \ingroup dm
1054 *
1055 * the routine that ends the local to global scatter
1056 */
1057PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec);
1058
1059/**
1060 * Creates a set of IS objects with the global indices of dofs for each field
1061 * @param dm The number of fields (or NULL if not requested)
1062 *
1063 * Output:
1064 * @param numFields The number of fields (or NULL if not requested)
1065 * @param fieldNames The name for each field (or NULL if not requested)
1066 * @param fields The global indices for each field (or NULL if not
1067 requested)
1068 *
1069 * @return error code
1070
1071 * \note The user is responsible for freeing all requested arrays. In
1072 particular,
1073 * every entry of names should be freed with PetscFree(), every entry of fields
1074 * should be destroyed with ISDestroy(), and both arrays should be freed with
1075 * PetscFree().
1076
1077 \ingroup dm
1078
1079 */
1080PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields,
1081 char ***fieldNames, IS **fields);
1082
1083/**
1084 * \brief get field is in the problem
1085 * @param dm the DM objects
1086 * @param rc ROW or COL (no difference is problem is squared)
1087 * @param field_name name of the field
1088 * @param is returned the IS object
1089 * @return error code
1090 *
1091 * \code
1092 * IS is;
1093 * ierr = DMMoFEMGetFieldIS(dm,ROW,"DISP",&is_disp); CHKERRG(ierr);
1094 * \endcode
1095 *
1096 *
1097 \ingroup dm
1098 */
1099PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[],
1100 IS *is);
1101
1102/**
1103 * @brief Set verbosity level
1104 *
1105 * @param dm
1106 * @param verb see VERBOSITY_LEVELS for list of the levels
1107 * @return PetscErrorCode
1108 */
1109PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb);
1110
1111struct BlockStructure;
1112
1113/** @brief Set data for block mat
1114 *
1115 * \note You can reset data by setting nullptr
1116 *
1117 */
1119 boost::shared_ptr<BlockStructure>);
1120
1121/**
1122 * @brief Get data for block mat
1123 *
1124 * @param dm
1125 * @return MoFEMErrorCode
1126 */
1127MoFEMErrorCode DMMoFEMGetBlocMatData(DM dm, boost::shared_ptr<BlockStructure> &);
1128
1129/**
1130 * @brief Create block matrix
1131 \ingroup dm
1132 *
1133 * @param dm
1134 * @param mat
1135 * @return MoFEMErrorCode
1136 */
1137MoFEMErrorCode DMMoFEMCreateBlockMat(DM dm, Mat *mat);
1138
1139/**
1140 * @brief Create block matrix
1141 \ingroup dm
1142 *
1143 * @param dm
1144 * @param mat smart pointer
1145 * @return MoFEMErrorCode
1146 */
1148
1149/**
1150 * @brief Set data for nest schur (see specialisation in Schur.hpp)
1151 *
1152 * \note You can reset data by setting nullptr
1153 *
1154 * @tparam T = NestSchurData
1155 * @param dm
1156 * @return MoFEMErrorCode
1157 */
1158template <typename T>
1159MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr<T>);
1160
1161/**
1162 * @brief Create nest schur matrix
1163 *
1164 * @param dm
1165 * @param mat
1166 * @return MoFEMErrorCode
1167 */
1169
1170/**
1171 * @brief Create matrix for hybridised system
1172 *
1173 * @param dm
1174 * @param mat
1175 * @return MoFEMErrorCode
1176 */
1178
1179/**
1180 * \brief PETSc Discrete Manager data structure
1181 *
1182 * This structure should not be accessed or modified by user. Is not
1183 * available from outside MoFEM DM manager. However user can inherit dat
1184 * class and add data for additional functionality.
1185 *
1186 * This is part of implementation for PETSc interface, see more details in
1187 * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/index.html>
1188 *
1189 * \ingroup dm
1190 *
1191 */
1192struct DMCtx : public UnknownInterface {
1193
1194 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
1195 UnknownInterface **iface) const;
1196
1197 virtual ~DMCtx() = default;
1198
1199 boost::shared_ptr<KspCtx> kspCtx; ///< data structure KSP
1200 boost::shared_ptr<SnesCtx> snesCtx; ///< data structure SNES
1201 boost::shared_ptr<TsCtx> tsCtx; ///< data structure for TS solver
1202
1203protected:
1204 DMCtx() = default;
1205};
1206
1207/**
1208 * @brief Get the Interface Ptr object
1209 *
1210 * @param dm
1211 * @return auto
1212 */
1213inline auto getInterfacePtr(DM dm) {
1214 MoFEM::Interface *m_field_ptr;
1215 CHK_THROW_MESSAGE(DMoFEMGetInterfacePtr(dm, &m_field_ptr),
1216 "Can not get interface ptr from DM");
1217 return m_field_ptr;
1218};
1219
1220/**
1221 * @brief get problem pointer from DM
1222 *
1223 */
1224inline auto getProblemPtr(DM dm) {
1225 const MoFEM::Problem *problem_ptr;
1226 CHK_THROW_MESSAGE(DMMoFEMGetProblemPtr(dm, &problem_ptr),
1227 "Get cot get problem ptr from DM");
1228 return problem_ptr;
1229};
1230
1231/**
1232 * @brief Get smart matrix from DM
1233 * \ingroup dm
1234 *
1235 */
1236inline auto createDMMatrix(DM dm) {
1239 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1240 return a;
1241};
1242
1243/**
1244 * @brief Get smart hybridised L2 matrix from DM
1245 *
1246 * @param dm
1247 * @return auto
1248 */
1249inline auto createDMHybridisedL2Matrix(DM dm) {
1252 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1253 return a;
1254};
1255
1256inline auto createDMBlockMat(DM dm) {
1257 Mat raw_a;
1258 ierr = DMMoFEMCreateBlockMat(dm, &raw_a);
1259 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1260 return SmartPetscObj<Mat>(raw_a);
1261};
1262
1263inline auto createDMNestSchurMat(DM dm) {
1264 Mat raw_a;
1265 ierr = DMMoFEMCreateNestSchurMat(dm, &raw_a);
1266 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1267 return SmartPetscObj<Mat>(raw_a);
1268};
1269
1270
1271/** @deprecated use createDMMatrix */
1272DEPRECATED inline auto smartCreateDMMatrix(DM dm) { return createDMMatrix(dm); }
1273
1274/**
1275 * @brief Get smart vector from DM
1276 * \ingroup dm
1277 *
1278 */
1282 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1283 return v;
1284};
1285
1286/** @deprecated use createDMVector*/
1287DEPRECATED inline auto smartCreateDMVector(DM dm) { return createDMVector(dm); }
1288
1289/**
1290 * @brief Get KSP context data structure used by DM
1291 *
1292 */
1293inline auto getDMKspCtx(DM dm) {
1294 boost::shared_ptr<MoFEM::KspCtx> ksp_ctx;
1295 ierr = DMMoFEMGetKspCtx(dm, ksp_ctx);
1296 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1297 return ksp_ctx;
1298};
1299
1300/** @deprecated getDMKspCtx */
1301DEPRECATED inline auto smartGetDMKspCtx(DM dm) { return getDMKspCtx(dm); }
1302
1303/**
1304 * @brief Get SNES context data structure used by DM
1305 *
1306 */
1307inline auto getDMSnesCtx(DM dm) {
1308 boost::shared_ptr<MoFEM::SnesCtx> snes_ctx;
1309 ierr = DMMoFEMGetSnesCtx(dm, snes_ctx);
1310 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1311 return snes_ctx;
1312};
1313
1314/** @deprecated use smartGetDMSnesCtx*/
1315DEPRECATED inline auto smartGetDMSnesCtx(DM dm) { return getDMSnesCtx(dm); }
1316
1317/**
1318 * @brief Get TS context data structure used by DM
1319 *
1320 */
1321inline auto getDMTsCtx(DM dm) {
1322 boost::shared_ptr<MoFEM::TsCtx> ts_ctx;
1324 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1325 return ts_ctx;
1326};
1327
1328/** @deprecated use getDMTsCtx */
1329DEPRECATED inline auto smartGetDMTsCtx(DM dm) { return getDMTsCtx(dm); }
1330
1331/**
1332 * @brief Get sub problem data structure
1333 *
1334 * @param dm
1335 * @return auto
1336 */
1337inline auto getDMSubData(DM dm) {
1338 auto prb_ptr = getProblemPtr(dm);
1339 return prb_ptr->getSubData();
1340};
1341
1342
1343} // namespace MoFEM
1344
1345#endif //__DMMOFEM_H
1346
1347/**
1348 * \defgroup dm Distributed mesh manager
1349 * \brief Implementation of PETSc DM, managing interactions between mesh data
1350 *structures and vectors and matrices
1351 *
1352 * DM objects are used to manage communication between the algebraic structures
1353 *in PETSc (Vec and Mat) and mesh data structures in PDE-based (or other)
1354 * simulations.
1355 *
1356 * DM is abstract interface, here is it particular implementation for MoFEM
1357 *code.
1358 *
1359 * \ingroup mofem
1360 **/
constexpr double a
RowColData
RowColData.
@ COL
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define DEPRECATED
Definition definitions.h:17
PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1478
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set ghosted vector values on all existing mesh entities
Definition DMMoFEM.cpp:611
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1486
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition DMMoFEM.cpp:1199
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:244
PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned)
Definition DMMoFEM.cpp:1210
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:574
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:794
PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name, PetscLayout *layout)
Get finite elements layout in the problem.
Definition DMMoFEM.cpp:553
PetscErrorCode DMMoFEMRebuildProblem(DM dm, const MoFEM::BitRefLevel target_bit, const MoFEM::BitRefLevel target_mask, IS *old_row_indices=PETSC_NULLPTR, IS *new_row_indices=PETSC_NULLPTR)
Rebuild the DM's parent problem in place on a new bit ref level.
Definition DMMoFEM.cpp:479
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition DMMoFEM.cpp:1264
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition DMMoFEM.cpp:536
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:876
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
Definition DMMoFEM.cpp:105
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:143
PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition DMMoFEM.cpp:632
PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on col.
Definition DMMoFEM.cpp:411
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1514
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition DMMoFEM.cpp:451
PetscErrorCode DMCreate_MoFEM(DM dm)
Create dm data structure with MoFEM data structure.
Definition DMMoFEM.cpp:71
PetscErrorCode DMMoFEMSetSnesCtx(DM dm, boost::shared_ptr< MoFEM::SnesCtx > snes_ctx)
Set MoFEM::SnesCtx data structure.
Definition DMMoFEM.cpp:1187
PetscErrorCode DMMoFEMSetKspCtx(DM dm, boost::shared_ptr< MoFEM::KspCtx > ksp_ctx)
set MoFEM::KspCtx data structure
Definition DMMoFEM.cpp:1161
PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[])
Definition DMMoFEM.cpp:267
PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm)
Definition DMMoFEM.cpp:351
PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[])
Add problem to composite DM on row.
Definition DMMoFEM.cpp:393
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:835
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition DMMoFEM.cpp:1274
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition DMMoFEM.cpp:1362
PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
Definition DMMoFEM.cpp:1218
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
Definition DMMoFEM.cpp:600
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition DMMoFEM.cpp:43
PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx)
get MoFEM::KspCtx data structure
Definition DMMoFEM.cpp:1144
PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem)
get squared problem
Definition DMMoFEM.cpp:566
PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[], MoFEM::DofMethod *method)
execute method for dofs on field in problem
Definition DMMoFEM.cpp:681
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:713
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name)
Resolve shared entities.
Definition DMMoFEM.cpp:544
PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr< MoFEM::TsCtx > ts_ctx)
Set MoFEM::TsCtx data structure.
Definition DMMoFEM.cpp:1235
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:662
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
Definition DMMoFEM.cpp:1593
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1279
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:929
MoFEMErrorCode DMMoFEMCreateBlockMat(DM dm, Mat *mat)
Create block matrix.
Definition DMMoFEM.cpp:1630
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
Definition DMMoFEM.cpp:439
PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[])
Definition DMMoFEM.cpp:309
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:1093
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:1051
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition DMMoFEM.hpp:1236
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition DMMoFEM.cpp:1243
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
Definition DMMoFEM.cpp:1170
PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm)
Get if this DM is composite DM.
Definition DMMoFEM.cpp:431
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition DMMoFEM.cpp:1431
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:754
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition DMMoFEM.cpp:1548
PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name)
unset element from dm
Definition DMMoFEM.cpp:591
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition DMMoFEM.cpp:1384
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1543
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:643
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition DMMoFEM.cpp:622
PetscErrorCode DMSetOperators_MoFEM(DM dm)
Set operators for MoFEM dm.
Definition DMMoFEM.cpp:49
const double v
phase velocity of light in medium (cm/ns)
MoFEM::TsCtx * ts_ctx
FTensor::Index< 'l', 3 > l
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
DEPRECATED auto smartCreateDMMatrix(DM dm)
Definition DMMoFEM.hpp:1272
MPI_Comm getCommFromPetscObject(PetscObject obj)
Get the Comm From Petsc Object object.
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:1132
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
Definition DMMoFEM.hpp:1321
DEPRECATED auto smartGetDMKspCtx(DM dm)
Definition DMMoFEM.hpp:1301
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:958
PetscErrorCode DMMoFEMSetDestroyProblem(DM dm, PetscBool destroy_problem)
Definition DMMoFEM.cpp:463
MoFEMErrorCode DMMoFEMCreateHybridL2Mat(DM dm, SmartPetscObj< Mat > &mat)
Create matrix for hybridised system.
Definition DMMoFEM.cpp:1664
PetscErrorCode DMMoFEMGetDestroyProblem(DM dm, PetscBool *destroy_problem)
Definition DMMoFEM.cpp:471
MoFEMErrorCode DMMoFEMGetBlocMatData(DM dm, boost::shared_ptr< BlockStructure > &)
Get data for block mat.
Definition DMMoFEM.cpp:1621
PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is)
get sub problem is
Definition DMMoFEM.cpp:359
PetscErrorCode DMMoFEMClearDMCtx(DM dm)
Clear solver and Schur data owned by a MoFEM DM context.
Definition DMMoFEM.cpp:79
DEPRECATED auto smartCreateDMVector(DM dm)
Definition DMMoFEM.hpp:1287
MoFEMErrorCode DMMoFEMCreateNestSchurMat(DM dm, Mat *mat)
Create nest schur matrix.
Definition DMMoFEM.cpp:1654
PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is)
get sub problem is
Definition DMMoFEM.cpp:376
auto getDMKspCtx(DM dm)
Get KSP context data structure used by DM.
Definition DMMoFEM.hpp:1293
auto createDMHybridisedL2Matrix(DM dm)
Get smart hybridised L2 matrix from DM.
Definition DMMoFEM.hpp:1249
auto getDMSubData(DM dm)
Get sub problem data structure.
Definition DMMoFEM.hpp:1337
MoFEMErrorCode DMMoFEMSetBlocMatData(DM dm, boost::shared_ptr< BlockStructure >)
Set data for block mat.
Definition DMMoFEM.cpp:1612
DEPRECATED auto smartGetDMTsCtx(DM dm)
Definition DMMoFEM.hpp:1329
auto getInterfacePtr(DM dm)
Get the Interface Ptr object.
Definition DMMoFEM.hpp:1213
MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr< NestSchurData >)
Definition DMMoFEM.cpp:1641
DEPRECATED auto smartGetDMSnesCtx(DM dm)
Definition DMMoFEM.hpp:1315
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
Definition DMMoFEM.hpp:1307
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:998
PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb)
Set verbosity level.
Definition DMMoFEM.cpp:1604
auto createDMNestSchurMat(DM dm)
Definition DMMoFEM.hpp:1263
PetscErrorCode DMMoFEMSwapDMCtx(DM dm, DM dm_swap)
Swap internal data structure.
Definition DMMoFEM.cpp:225
boost::shared_ptr< CacheTuple > CacheTupleSharedPtr
auto getProblemPtr(DM dm)
get problem pointer from DM
Definition DMMoFEM.hpp:1224
PetscErrorCode DMMoFEMDuplicateDMCtx(DM dm, DM dm_duplicate)
Duplicate internal data structure.
Definition DMMoFEM.cpp:209
boost::weak_ptr< CacheTuple > CacheTupleWeakPtr
auto createDMBlockMat(DM dm)
Definition DMMoFEM.hpp:1256
constexpr auto field_name
Data structure to exchange data between MoFEM and User Loop Methods.
PETSc Discrete Manager data structure.
Definition DMMoFEM.hpp:1192
virtual ~DMCtx()=default
boost::shared_ptr< SnesCtx > snesCtx
data structure SNES
Definition DMMoFEM.hpp:1200
boost::shared_ptr< TsCtx > tsCtx
data structure for TS solver
Definition DMMoFEM.hpp:1201
boost::shared_ptr< KspCtx > kspCtx
data structure KSP
Definition DMMoFEM.hpp:1199
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition DMMoFEM.cpp:19
DMCtx()=default
Deprecated interface functions.
Data structure for user loop methods on degrees of freedom (DOFs)
Structure for user loop methods on finite elements.
Interface for linear (KSP) solver.
Definition KspCtx.hpp:14
keeps basic data about problem
intrusive_ptr for managing petsc objects
Interface for nonlinear (SNES) solver.
Definition SnesCtx.hpp:15
Interface for Time Stepping (TS) solver.
Definition TsCtx.hpp:17
base class for all interface classes