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 set squared problem
156 * \ingroup dm
157
158 If true, it is assumed that matrix has the same indexing on rows and
159 columns. This reduces interprocessor communication.
160
161 */
162PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem);
163
164/**
165 * \brief get squared problem
166 * \ingroup dm
167
168 If true, it is assumed that matrix has the same indexing on rows and
169 columns. This reduces interprocessor communication.
170
171 */
172PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem);
173
174/**
175 * \brief Resolve shared entities
176 *
177 * @param dm dm
178 * @param fe_name finite element for which shared entities are resolved
179 * @return error code
180 *
181 * \note This function is valid for parallel algebra and serial mesh. It
182 * should be run collectively, i.e. on all processors.
183 *
184 * This allows for tag reduction or tag exchange, f.e.
185 *
186 * \code
187 * CHKERR DMMoFEMResolveSharedFiniteElements(dm,"SHELL_ELEMENT");
188 * Tag th;
189 * CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
190 * ParallelComm* pcomm =
191 * ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
192 * // CHKERR pcomm->reduce_tags(th,MPI_SUM,prisms);
193 * CHKERR pcomm->exchange_tags(th,prisms);
194 * \endcode
195 *
196 * \ingroup dm
197 */
198PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name);
199
200/**
201 * \brief Get finite elements layout in the problem
202 *
203 * In layout is stored information how many elements are on each processor, for
204 * more information look at petsc documentation
205 * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/PetscLayoutCreate.html#PetscLayoutCreate>
206 *
207 * @param dm discrete manager for this problem
208 * @param fe_name finite element name
209 * @param layout pointer to layout, for created layout user takes
210 * responsibility for destroying it.
211 * @return error code
212 *
213 * \ingroup dm
214 */
215PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name,
216 PetscLayout *layout);
217
218/**
219 * \brief add element to dm
220 * \ingroup dm
221 *
222 * \note add_file is a collective, should be executed on all processors.
223 * Otherwise could lead to deadlock.
224 *
225 * @param dm Distributed mesh manager
226 * @param fe_name Finite element name
227 * @return Error code
228 */
229PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name);
230
231/**
232 * \brief add element to dm
233 * \ingroup dm
234 *
235 * \note add_file is a collective, should be executed on all processors.
236 * Otherwise could lead to deadlock.
237 *
238 * @param dm Distributed mesh manager
239 * @param fe_name Vector of finite element names
240 * @return Error code
241 */
242PetscErrorCode DMMoFEMAddElement(DM dm, std::vector<std::string> fe_name);
243
244/**
245 * \brief unset element from dm
246 * \ingroup dm
247 *
248 * @param dm Distributed mesh manager
249 * @param fe_name Finite element name to remove
250 * @return Error code
251 */
252PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name);
253
254/**
255 * \brief set local (or ghosted) vector values on mesh for partition only
256 * \ingroup dm
257
258 * \param l vector
259 * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
260 * \param scatter_mode see petsc manual for ScatterMode (The available modes
261 are: SCATTER_FORWARD or SCATTER_REVERSE)
262 *
263 * SCATTER_REVERSE set data to field entities from V vector.
264 * SCATTER_FORWARD set vector V from data field entities
265 *
266 * This code will update ghosted entities on all processors
267 \code
268 * auto d_vector = createDMVector(dm);
269 * // fill d_vector on owned entities
270 CHKERR DMoFEMMeshToLocalVector(dm, d_vector, INSERT_VALUES,
271 SCATTER_FORWARD);
272 // update ghost values in d_vector
273 CHKERR VecGhostUpdateBegin(d_vector, INSERT_VALUES, SCATTER_FORWARD);
274 CHKERR VecGhostUpdateEnd(d_vector, INSERT_VALUES, SCATTER_FORWARD);
275 // now d_vector has updated ghost values, and following save values of
276 // vector to fields entities
277 CHKERR DMoFEMMeshToLocalVector(dm, d_vector, INSERT_VALUES,
278 SCATTER_REVERSE);
279 * \endcode
280 *
281 * \note you use DMoFEMMeshToGlobalVector as scatter reverse
282 *
283 * For implementations see VecManager::setLocalGhostVector.
284 */
285PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode,
286 ScatterMode scatter_mode,
288
289/**
290 * \brief set ghosted vector values on all existing mesh entities
291 * \ingroup dm
292
293 * \param g vector
294 * \param mode see petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
295 * \param scatter_mode see petsc manual for ScatterMode (The available modes
296 are: SCATTER_FORWARD or SCATTER_REVERSE)
297 *
298 * SCATTER_REVERSE set data to field entities from V vector.
299 *
300 * SCATTER_FORWARD set vector V from data field entities
301
302 */
303PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode,
304 ScatterMode scatter_mode,
306
307/**
308 * \brief execute finite element method for each element in dm (problem)
309 * \ingroup dm
310 *
311 * @param dm Distributed mesh manager
312 * @param method Finite element method to execute for preprocessing
313 * @return Error code
314 */
315PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
316
317/**
318 * \brief execute finite element method for each element in dm (problem)
319 * \ingroup dm
320 *
321 * @param dm Distributed mesh manager
322 * @param method Finite element method to execute for postprocessing
323 * @return Error code
324 */
325PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method);
326
327/**
328 * \brief Executes FEMethod for finite elements in DM
329 * @param dm MoFEM discrete manager
330 * @param fe_name name of finite element
331 * @param method pointer to \ref MoFEM::FEMethod
332 * @param low_rank lowest rank of processor
333 * @param up_rank upper run of processor
334 * @return Error code
335 * \ingroup dm
336 */
338 DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank,
339 int up_rank, CacheTupleWeakPtr cache_ptr = CacheTupleSharedPtr());
340
341/**
342 * \brief Executes FEMethod for finite elements in DM
343 * @param dm MoFEM discrete manager
344 * @param fe_name name of finite element
345 * @param method pointer to \ref MoFEM::FEMethod
346 * @param low_rank lowest rank of processor
347 * @param up_rank upper run of processor
348 * @return Error code
349 * \ingroup dm
350 */
352 DM dm, const std::string fe_name, boost::shared_ptr<MoFEM::FEMethod> method,
353 int low_rank, int up_rank,
355
356/**
357 * \brief Executes FEMethod for finite elements in DM
358 * @param dm MoFEM discrete manager
359 * @param fe_name name of element
360 * @param method pointer to \ref MOFEM::FEMethod
361 * @return Error code
362 * \ingroup dm
363 */
364PetscErrorCode
365DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method,
367
368/**
369 * \brief Executes FEMethod for finite elements in DM
370 * @param dm MoFEM discrete manager
371 * @param fe_name name of element
372 * @param method pointer to \ref MOFEM::FEMethod
373 * @return Error code
374 * \ingroup dm
375 */
376PetscErrorCode
377DMoFEMLoopFiniteElements(DM dm, const std::string fe_name,
378 boost::shared_ptr<MoFEM::FEMethod> method,
380
381/**
382 * \brief execute method for dofs on field in problem
383 * \ingroup dm
384 */
385PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[],
386 MoFEM::DofMethod *method);
387
388// /**
389// * \brief Set compute operator for KSP solver via sub-matrix and IS
390// *
391// * @param dm DM
392// * @return error code
393// *
394// * \ingroup dm
395// */
396// PetscErrorCode DMMoFEMKSPSetComputeOperatorsViaSubMatrixbByIs(DM dm);
397
398/**
399 * \brief set KSP right hand side evaluation function
400 * \ingroup dm
401 */
402PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[],
403 MoFEM::FEMethod *method,
404 MoFEM::BasicMethod *pre_only,
405 MoFEM::BasicMethod *post_only);
406
407/**
408 * \brief set KSP right hand side evaluation function
409 * \ingroup dm
410 */
411PetscErrorCode
412DMMoFEMKSPSetComputeRHS(DM dm, const std::string fe_name,
413 boost::shared_ptr<MoFEM::FEMethod> method,
414 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
415 boost::shared_ptr<MoFEM::BasicMethod> post_only);
416
417/**
418 * \brief Set KSP operators and push mofem finite element methods
419 *
420 * @param dm DM
421 * @param fe_name finite element name
422 * @param method method on the element (executed for each element in the
423 * problem which given name)
424 * @param pre_only method for pre-process before element method
425 * @param post_only method for post-process after element method
426 * @return error code
427 *
428 * \ingroup dm
429 */
430PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[],
431 MoFEM::FEMethod *method,
432 MoFEM::BasicMethod *pre_only,
433 MoFEM::BasicMethod *post_only);
434
435/**
436 * \brief Set KSP operators and push mofem finite element methods
437 *
438 * @param dm DM
439 * @param fe_name finite element name
440 * @param method method on the element (executed for each element in the
441 * problem which given name)
442 * @param pre_only method for pre-process before element method
443 * @param post_only method for post-process after element method
444 * @return error code
445 *
446 * \ingroup dm
447 */
448PetscErrorCode
449DMMoFEMKSPSetComputeOperators(DM dm, const std::string fe_name,
450 boost::shared_ptr<MoFEM::FEMethod> method,
451 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
452 boost::shared_ptr<MoFEM::BasicMethod> post_only);
453
454/**
455 * \brief set SNES residual evaluation function
456 * \ingroup dm
457 */
458PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[],
459 MoFEM::FEMethod *method,
460 MoFEM::BasicMethod *pre_only,
461 MoFEM::BasicMethod *post_only);
462
463/**
464 * \brief set SNES residual evaluation function
465 * \ingroup dm
466 */
467PetscErrorCode
468DMMoFEMSNESSetFunction(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/**
474 * \brief set SNES Jacobian evaluation function
475 * \ingroup dm
476 */
477PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[],
478 MoFEM::FEMethod *method,
479 MoFEM::BasicMethod *pre_only,
480 MoFEM::BasicMethod *post_only);
481
482/**
483 * \brief set SNES Jacobian evaluation function
484 * \ingroup dm
485 */
486PetscErrorCode
487DMMoFEMSNESSetJacobian(DM dm, const std::string fe_name,
488 boost::shared_ptr<MoFEM::FEMethod> method,
489 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
490 boost::shared_ptr<MoFEM::BasicMethod> post_only);
491
492/**
493 * \brief set TS implicit function evaluation function
494 * \ingroup dm
495 */
496PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[],
497 MoFEM::FEMethod *method,
498 MoFEM::BasicMethod *pre_only,
499 MoFEM::BasicMethod *post_only);
500
501/**
502 * \brief set TS implicit function evaluation function
503 * \ingroup dm
504 */
505PetscErrorCode
506DMMoFEMTSSetIFunction(DM dm, const std::string fe_name,
507 boost::shared_ptr<MoFEM::FEMethod> method,
508 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
509 boost::shared_ptr<MoFEM::BasicMethod> post_only);
510
511/**
512 * \brief set TS Jacobian evaluation function
513 * \ingroup dm
514 */
515PetscErrorCode
516DMMoFEMTSSetIJacobian(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 Jacobian evaluation function
523 * \ingroup dm
524 */
525PetscErrorCode DMMoFEMTSSetIJacobian(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 the right hand side function
532 *
533 * <a
534 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetRHSFunction.html#TSSetRHSFunction>See
535 * petsc documentation</a>
536 *
537 * @param dm
538 * @param fe_name
539 * @param method
540 * @param pre_only
541 * @param post_only
542 * @return PetscErrorCode
543 */
544PetscErrorCode
545DMMoFEMTSSetRHSFunction(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
550PetscErrorCode DMMoFEMTSSetRHSFunction(DM dm, const char fe_name[],
551 MoFEM::FEMethod *method,
552 MoFEM::BasicMethod *pre_only,
553 MoFEM::BasicMethod *post_only);
554
555/**
556 * @brief set TS the right hand side jacobian
557 *
558 * <a
559 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSSetRHSJacobian.html>See
560 * petsc documentation</a>
561 *
562 * @param dm
563 * @param fe_name
564 * @param method
565 * @param pre_only
566 * @param post_only
567 * @return PetscErrorCode
568 */
569PetscErrorCode
570DMMoFEMTSSetRHSJacobian(DM dm, const std::string fe_name,
571 boost::shared_ptr<MoFEM::FEMethod> method,
572 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
573 boost::shared_ptr<MoFEM::BasicMethod> post_only);
574
575PetscErrorCode DMMoFEMTSSetRHSJacobian(DM dm, const char fe_name[],
576 MoFEM::FEMethod *method,
577 MoFEM::BasicMethod *pre_only,
578 MoFEM::BasicMethod *post_only);
579
580/**
581 * \brief set TS implicit function evaluation function
582 * \ingroup dm
583 */
584PetscErrorCode
585DMMoFEMTSSetI2Function(DM dm, const std::string fe_name,
586 boost::shared_ptr<MoFEM::FEMethod> method,
587 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
588 boost::shared_ptr<MoFEM::BasicMethod> post_only);
589/**
590 * \brief set TS implicit function evaluation function
591 * \ingroup dm
592 */
593PetscErrorCode DMMoFEMTSSetI2Function(DM dm, const char fe_name[],
594 MoFEM::FEMethod *method,
595 MoFEM::BasicMethod *pre_only,
596 MoFEM::BasicMethod *post_only);
597
598/**
599 * \brief set TS Jacobian evaluation function
600 * \ingroup dm
601 */
602PetscErrorCode
603DMMoFEMTSSetI2Jacobian(DM dm, const std::string fe_name,
604 boost::shared_ptr<MoFEM::FEMethod> method,
605 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
606 boost::shared_ptr<MoFEM::BasicMethod> post_only);
607/**
608 * \brief set TS Jacobian evaluation function
609 * \ingroup dm
610 */
611PetscErrorCode
612DMMoFEMTSSetI2Jacobian(DM dm, const char fe_name[],
613 MoFEM::FEMethod *method,
614 MoFEM::BasicMethod *pre_only,
615 MoFEM::BasicMethod *post_only);
616
617/**
618 * @brief Set Monitor To TS solver
619 *
620 * <a
621 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html>See
622 * PETSc documentation here</a>
623 *
624 * @param dm
625 * @param ts time solver
626 * @param fe_name
627 * @param method
628 * @param pre_only
629 * @param post_only
630 * @return PetscErrorCode
631 */
632PetscErrorCode
633DMMoFEMTSSetMonitor(DM dm, TS ts, const std::string fe_name,
634 boost::shared_ptr<MoFEM::FEMethod> method,
635 boost::shared_ptr<MoFEM::BasicMethod> pre_only,
636 boost::shared_ptr<MoFEM::BasicMethod> post_only);
637
638/**
639 * @brief Set Monitor To TS solver
640 *
641 * <a
642 * href=https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/TSMonitorSet.html>See
643 * PETSc documentation here</a>
644 *
645 * @param dm
646 * @param ts time solver
647 * @param fe_name
648 * @param method
649 * @param pre_only
650 * @param post_only
651 * @return PetscErrorCode
652 */
653PetscErrorCode DMMoFEMTSSetMonitor(DM dm, TS ts, const char fe_name[],
654 MoFEM::FEMethod *method,
655 MoFEM::BasicMethod *pre_only,
656 MoFEM::BasicMethod *post_only);
657
658/**
659 * \brief get MoFEM::KspCtx data structure
660 * \ingroup dm
661 *
662 * @param dm Distributed mesh manager
663 * @param ksp_ctx Pointer to KSP context structure
664 * @return Error code
665 */
666PetscErrorCode DMMoFEMGetKspCtx(DM dm, MoFEM::KspCtx **ksp_ctx);
667
668/**
669 * \brief get MoFEM::KspCtx data structure
670 * \ingroup dm
671 *
672 * @param dm Distributed mesh manager
673 * @param ksp_ctx Shared pointer to KSP context structure
674 * @return Error code
675 */
676PetscErrorCode
677DMMoFEMGetKspCtx(DM dm, const boost::shared_ptr<MoFEM::KspCtx> &ksp_ctx);
678
679/**
680 * \brief set MoFEM::KspCtx data structure
681 * \ingroup dm
682 *
683 * @param dm Distributed mesh manager
684 * @param ksp_ctx Shared pointer to KSP context structure to set
685 * @return Error code
686 */
687PetscErrorCode DMMoFEMSetKspCtx(DM dm,
688 boost::shared_ptr<MoFEM::KspCtx> ksp_ctx);
689
690/**
691 * \brief get MoFEM::SnesCtx data structure
692 * \ingroup dm
693 *
694 * @param dm Distributed mesh manager
695 * @param snes_ctx Pointer to SNES context structure
696 * @return Error code
697 */
698PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx);
699
700/**
701 * \brief get MoFEM::SnesCtx data structure
702 * \ingroup dm
703 *
704 * @param dm Distributed mesh manager
705 * @param snes_ctx Shared pointer to SNES context structure
706 * @return Error code
707 */
708PetscErrorCode
709DMMoFEMGetSnesCtx(DM dm, const boost::shared_ptr<MoFEM::SnesCtx> &snes_ctx);
710
711/**
712 * \brief Set MoFEM::SnesCtx data structure
713 * \ingroup dm
714
715 */
716PetscErrorCode DMMoFEMSetSnesCtx(DM dm,
717 boost::shared_ptr<MoFEM::SnesCtx> snes_ctx);
718
719/**
720 * \brief get MoFEM::TsCtx data structure
721 * \ingroup dm
722 */
723PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx);
724
725/**
726 * \brief get MoFEM::TsCtx data structure
727 * \ingroup dm
728 */
729PetscErrorCode DMMoFEMGetTsCtx(DM dm,
730 const boost::shared_ptr<MoFEM::TsCtx> &ts_ctx);
731
732/**
733 * \brief Set MoFEM::TsCtx data structure
734 * \ingroup dm
735
736 It take over pointer, do not delete it, DM will destroy pointer
737 when is destroyed.
738
739 */
740PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr<MoFEM::TsCtx> ts_ctx);
741
742/** sets if read mesh is partitioned
743 * \ingroup dm
744 *
745 * @param dm Distributed mesh manager
746 * @param is_partitioned Boolean flag indicating if mesh is partitioned
747 * @return Error code
748 */
749PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned);
750
751/** get if read mesh is partitioned
752 * \ingroup dm
753 *
754 * @param dm Distributed mesh manager
755 * @param is_partitioned Pointer to boolean flag for partition status
756 * @return Error code
757 */
758PetscErrorCode DMMoFEMGetIsPartitioned(DM dm, PetscBool *is_partitioned);
759
760/**
761 * \brief Set operators for MoFEM dm
762 * @param dm Distributed mesh manager
763 * @return Error code
764 * \ingroup dm
765 */
766PetscErrorCode DMSetOperators_MoFEM(DM dm);
767
768/**
769 * \brief Create dm data structure with MoFEM data structure
770 * \ingroup dm
771 *
772 * @param dm Distributed mesh manager to create
773 * @return Error code
774 */
775PetscErrorCode DMCreate_MoFEM(DM dm);
776
777/**
778 * \brief Destroys dm with MoFEM data structure
779 * \ingroup dm
780 *
781 * @param dm Distributed mesh manager to destroy
782 * @return Error code
783 */
784PetscErrorCode DMDestroy_MoFEM(DM dm);
785
786/**
787 * \brief DMShellSetCreateGlobalVector
788 * \ingroup dm
789 *
790 * sets the routine to create a global vector
791 * associated with the shell DM
792 *
793 * @param dm Distributed mesh manager
794 * @param g Pointer to global vector to create
795 * @return Error code
796 */
797PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g);
798
799/**
800 * \brief DMShellSetCreateGlobalVector
801 * \ingroup dm
802 *
803 * sets the routine to create a global vector
804 * associated with the shell DM
805 */
806PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, SmartPetscObj<Vec> &g_ptr,
808
809/**
810 * \brief DMShellSetCreateLocalVector
811 * \ingroup dm
812 *
813 * sets the routine to create a local vector
814 * associated with the shell DM
815 */
816PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l);
817
818/**
819 * DMShellSetCreateMatrix
820 * \ingroup dm
821 *
822 * sets the routine to create a matrix associated with the shell DM
823 */
824PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M);
825
826/**
827 * DMShellSetCreateMatrix
828 * \ingroup dm
829 *
830 * sets the routine to create a matrix associated with the shell DM
831 */
832PetscErrorCode DMCreateMatrix_MoFEM(DM dm, SmartPetscObj<Mat> &M);
833
834/**
835 * Set options for MoFEM DM
836 * \ingroup dm
837 */
838#if PETSC_VERSION_GE(3, 17, 0)
839PetscErrorCode DMSetFromOptions_MoFEM(DM dm,
840 PetscOptionItems *PetscOptionsObject);
841#elif PETSC_VERSION_GE(3, 7, 0)
842PetscErrorCode DMSetFromOptions_MoFEM(PetscOptionItems *PetscOptionsObject,
843 DM dm);
844#elif PETSC_VERSION_GE(3, 5, 3)
845PetscErrorCode DMSetFromOptions_MoFEM(PetscOptions *PetscOptionsObject, DM dm);
846#else
847PetscErrorCode DMSetFromOptions_MoFEM(DM dm);
848#endif
849
850/**
851 * sets up the MoFEM structures inside a DM object
852 * \ingroup dm
853 */
854PetscErrorCode DMSetUp_MoFEM(DM dm);
855
856/**
857 * Sets up the MoFEM structures inside a DM object for sub dm
858 * \ingroup dm
859 *
860 * @param subdm Sub distributed mesh manager to set up
861 * @return Error code
862 */
863PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm);
864
865/**
866 * Add field to sub dm problem on rows
867 * \ingroup dm
868 *
869 * @param dm Distributed mesh manager
870 * @param field_name Name of field to add to rows
871 * @return Error code
872 */
873PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[]);
874
875/** @copydoc DMMoFEMAddSubFieldRow(DM dm, const char field_name[]) */
876PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name);
877
878/**
879 * @brief Add field to sub dm problem on rows
880 * \ingroup dm
881 *
882 * @param dm
883 * @param field_name
884 * @param m
885 * @return PetscErrorCode
886 */
887PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, const char field_name[],
888 boost::shared_ptr<Range> r_ptr);
889
890/** @copydoc DMMoFEMAddSubFieldRow(DM dm, const char field_name[], boost::shared_ptr<Range> r_ptr) */
891PetscErrorCode DMMoFEMAddSubFieldRow(DM dm, std::string field_name,
892 boost::shared_ptr<Range> r_ptr);
893
894/**
895 * Add field to sub dm problem on columns
896 * \ingroup dm
897 */
898PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[]);
899
900/** @copydoc DMMoFEMAddSubFieldCol(DM dm, const char field_name[]) */
901PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name);
902
903/**
904 * @brief Add field to sub dm problem on columns
905 *
906 * @param dm
907 * @param field_name
908 * @param range of entities
909 * @return PetscErrorCode
910 */
911PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, const char field_name[],
912 boost::shared_ptr<Range> r_ptr);
913
914
915/** @copydoc DMMoFEMAddSubFieldCol(DM dm, const char field_name[], boost::shared_ptr<Range> r_ptr); */
916PetscErrorCode DMMoFEMAddSubFieldCol(DM dm, std::string field_name,
917 boost::shared_ptr<Range> r_ptr);
918
919/**
920 * Return true if this DM is sub problem
921 \ingroup dm
922 * @param dm the DM object
923 * @param is_subproblem true if subproblem
924 * @return error code
925 */
926PetscErrorCode DMMoFEMGetIsSubDM(DM dm, PetscBool *is_sub_dm);
927
928/**
929 * \brief get sub problem is
930 * @param dm has to be created with DMMoFEMSetSquareProblem
931 * @param is return is on the row
932 * @return error code
933 *
934 * Returns IS with global indices of the DM used to create SubDM
935 *
936 */
937PetscErrorCode DMMoFEMGetSubRowIS(DM dm, IS *is);
938
939/**
940 * \brief get sub problem is
941 * @param dm has to be created with DMMoFEMSetSquareProblem
942 * @param is return is on the row
943 * @return error code
944 *
945 * Returns IS with global indices of the DM used to create SubDM
946 *
947 */
948PetscErrorCode DMMoFEMGetSubColIS(DM dm, IS *is);
949
950/**
951 * \brief Add problem to composite DM on row
952 \ingroup dm
953 *
954 * This create block on row with DOFs from problem of given name
955 *
956 * @param dm the DM object
957 * @param prb_name add problem name
958 * @return error code
959 */
960PetscErrorCode DMMoFEMAddRowCompositeProblem(DM dm, const char prb_name[]);
961
962/**
963 * \brief Add problem to composite DM on col
964 * \ingroup dm
965 *
966 * This create block on col with DOFs from problem of given name
967 *
968 * @param dm the DM object
969 * @param prb_name add problem name
970 * @return error code
971 */
972PetscErrorCode DMMoFEMAddColCompositeProblem(DM dm, const char prb_name[]);
973
974/**
975 * \brief Get if this DM is composite DM
976 * \ingroup dm
977 *
978 * @param dm the DM object
979 * @param is_comp_dm return true if composite problem here
980 * @return error code
981 */
982PetscErrorCode DMMoFEMGetIsCompDM(DM dm, PetscBool *is_comp_dm);
983
984/**
985 * destroy the MoFEM structure
986 * \ingroup dm
987 */
988PetscErrorCode DMDestroy_MoFEM(DM dm);
989
990/**
991 * DMShellSetGlobalToLocal
992 * \ingroup dm
993 *
994 * the routine that begins the global to local scatter
995 */
996PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec);
997
998/**
999 * DMShellSetGlobalToLocal
1000 * \ingroup dm
1001 *
1002 * the routine that begins the global to local scatter
1003 */
1004PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec);
1005
1006/**
1007 * DMShellSetLocalToGlobal
1008 * \ingroup dm
1009 *
1010 * the routine that begins the local to global scatter
1011 */
1012PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
1013
1014/**
1015 * DMShellSetLocalToGlobal
1016 * \ingroup dm
1017 *
1018 * the routine that ends the local to global scatter
1019 */
1020PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec);
1021
1022/**
1023 * DMShellSetLocalToGlobal
1024 * \ingroup dm
1025 *
1026 * the routine that ends the local to global scatter
1027 */
1028PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec);
1029
1030/**
1031 * Creates a set of IS objects with the global indices of dofs for each field
1032 * @param dm The number of fields (or NULL if not requested)
1033 *
1034 * Output:
1035 * @param numFields The number of fields (or NULL if not requested)
1036 * @param fieldNames The name for each field (or NULL if not requested)
1037 * @param fields The global indices for each field (or NULL if not
1038 requested)
1039 *
1040 * @return error code
1041
1042 * \note The user is responsible for freeing all requested arrays. In
1043 particular,
1044 * every entry of names should be freed with PetscFree(), every entry of fields
1045 * should be destroyed with ISDestroy(), and both arrays should be freed with
1046 * PetscFree().
1047
1048 \ingroup dm
1049
1050 */
1051PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields,
1052 char ***fieldNames, IS **fields);
1053
1054/**
1055 * \brief get field is in the problem
1056 * @param dm the DM objects
1057 * @param rc ROW or COL (no difference is problem is squared)
1058 * @param field_name name of the field
1059 * @param is returned the IS object
1060 * @return error code
1061 *
1062 * \code
1063 * IS is;
1064 * ierr = DMMoFEMGetFieldIS(dm,ROW,"DISP",&is_disp); CHKERRG(ierr);
1065 * \endcode
1066 *
1067 *
1068 \ingroup dm
1069 */
1070PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[],
1071 IS *is);
1072
1073/**
1074 * @brief Set verbosity level
1075 *
1076 * @param dm
1077 * @param verb see VERBOSITY_LEVELS for list of the levels
1078 * @return PetscErrorCode
1079 */
1080PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb);
1081
1082struct BlockStructure;
1083
1084/** @brief Set data for block mat
1085 *
1086 * \note You can reset data by setting nullptr
1087 *
1088 */
1090 boost::shared_ptr<BlockStructure>);
1091
1092/**
1093 * @brief Get data for block mat
1094 *
1095 * @param dm
1096 * @return MoFEMErrorCode
1097 */
1098MoFEMErrorCode DMMoFEMGetBlocMatData(DM dm, boost::shared_ptr<BlockStructure> &);
1099
1100/**
1101 * @brief Create block matrix
1102 \ingroup dm
1103 *
1104 * @param dm
1105 * @param mat
1106 * @return MoFEMErrorCode
1107 */
1108MoFEMErrorCode DMMoFEMCreateBlockMat(DM dm, Mat *mat);
1109
1110/**
1111 * @brief Create block matrix
1112 \ingroup dm
1113 *
1114 * @param dm
1115 * @param mat smart pointer
1116 * @return MoFEMErrorCode
1117 */
1119
1120/**
1121 * @brief Set data for nest schur (see specialisation in Schur.hpp)
1122 *
1123 * \note You can reset data by setting nullptr
1124 *
1125 * @tparam T = NestSchurData
1126 * @param dm
1127 * @return MoFEMErrorCode
1128 */
1129template <typename T>
1130MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr<T>);
1131
1132/**
1133 * @brief Create nest schur matrix
1134 *
1135 * @param dm
1136 * @param mat
1137 * @return MoFEMErrorCode
1138 */
1140
1141/**
1142 * @brief Create matrix for hybridised system
1143 *
1144 * @param dm
1145 * @param mat
1146 * @return MoFEMErrorCode
1147 */
1149
1150/**
1151 * \brief PETSc Discrete Manager data structure
1152 *
1153 * This structure should not be accessed or modified by user. Is not
1154 * available from outside MoFEM DM manager. However user can inherit dat
1155 * class and add data for additional functionality.
1156 *
1157 * This is part of implementation for PETSc interface, see more details in
1158 * <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/DM/index.html>
1159 *
1160 * \ingroup dm
1161 *
1162 */
1163struct DMCtx : public UnknownInterface {
1164
1165 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
1166 UnknownInterface **iface) const;
1167
1168 virtual ~DMCtx() = default;
1169
1170 boost::shared_ptr<KspCtx> kspCtx; ///< data structure KSP
1171 boost::shared_ptr<SnesCtx> snesCtx; ///< data structure SNES
1172 boost::shared_ptr<TsCtx> tsCtx; ///< data structure for TS solver
1173
1174protected:
1175 DMCtx() = default;
1176};
1177
1178/**
1179 * @brief Get the Interface Ptr object
1180 *
1181 * @param dm
1182 * @return auto
1183 */
1184inline auto getInterfacePtr(DM dm) {
1185 MoFEM::Interface *m_field_ptr;
1186 CHK_THROW_MESSAGE(DMoFEMGetInterfacePtr(dm, &m_field_ptr),
1187 "Can not get interface ptr from DM");
1188 return m_field_ptr;
1189};
1190
1191/**
1192 * @brief get problem pointer from DM
1193 *
1194 */
1195inline auto getProblemPtr(DM dm) {
1196 const MoFEM::Problem *problem_ptr;
1197 CHK_THROW_MESSAGE(DMMoFEMGetProblemPtr(dm, &problem_ptr),
1198 "Get cot get problem ptr from DM");
1199 return problem_ptr;
1200};
1201
1202/**
1203 * @brief Get smart matrix from DM
1204 * \ingroup dm
1205 *
1206 */
1207inline auto createDMMatrix(DM dm) {
1210 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1211 return a;
1212};
1213
1214/**
1215 * @brief Get smart hybridised L2 matrix from DM
1216 *
1217 * @param dm
1218 * @return auto
1219 */
1220inline auto createDMHybridisedL2Matrix(DM dm) {
1223 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1224 return a;
1225};
1226
1227inline auto createDMBlockMat(DM dm) {
1228 Mat raw_a;
1229 ierr = DMMoFEMCreateBlockMat(dm, &raw_a);
1230 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1231 return SmartPetscObj<Mat>(raw_a);
1232};
1233
1234inline auto createDMNestSchurMat(DM dm) {
1235 Mat raw_a;
1236 ierr = DMMoFEMCreateNestSchurMat(dm, &raw_a);
1237 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1238 return SmartPetscObj<Mat>(raw_a);
1239};
1240
1241
1242/** @deprecated use createDMMatrix */
1243DEPRECATED inline auto smartCreateDMMatrix(DM dm) { return createDMMatrix(dm); }
1244
1245/**
1246 * @brief Get smart vector from DM
1247 * \ingroup dm
1248 *
1249 */
1253 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1254 return v;
1255};
1256
1257/** @deprecated use createDMVector*/
1258DEPRECATED inline auto smartCreateDMVector(DM dm) { return createDMVector(dm); }
1259
1260/**
1261 * @brief Get KSP context data structure used by DM
1262 *
1263 */
1264inline auto getDMKspCtx(DM dm) {
1265 boost::shared_ptr<MoFEM::KspCtx> ksp_ctx;
1266 ierr = DMMoFEMGetKspCtx(dm, ksp_ctx);
1267 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1268 return ksp_ctx;
1269};
1270
1271/** @deprecated getDMKspCtx */
1272DEPRECATED inline auto smartGetDMKspCtx(DM dm) { return getDMKspCtx(dm); }
1273
1274/**
1275 * @brief Get SNES context data structure used by DM
1276 *
1277 */
1278inline auto getDMSnesCtx(DM dm) {
1279 boost::shared_ptr<MoFEM::SnesCtx> snes_ctx;
1280 ierr = DMMoFEMGetSnesCtx(dm, snes_ctx);
1281 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1282 return snes_ctx;
1283};
1284
1285/** @deprecated use smartGetDMSnesCtx*/
1286DEPRECATED inline auto smartGetDMSnesCtx(DM dm) { return getDMSnesCtx(dm); }
1287
1288/**
1289 * @brief Get TS context data structure used by DM
1290 *
1291 */
1292inline auto getDMTsCtx(DM dm) {
1293 boost::shared_ptr<MoFEM::TsCtx> ts_ctx;
1295 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1296 return ts_ctx;
1297};
1298
1299/** @deprecated use getDMTsCtx */
1300DEPRECATED inline auto smartGetDMTsCtx(DM dm) { return getDMTsCtx(dm); }
1301
1302/**
1303 * @brief Get sub problem data structure
1304 *
1305 * @param dm
1306 * @return auto
1307 */
1308inline auto getDMSubData(DM dm) {
1309 auto prb_ptr = getProblemPtr(dm);
1310 return prb_ptr->getSubData();
1311};
1312
1313
1314} // namespace MoFEM
1315
1316#endif //__DMMOFEM_H
1317
1318/**
1319 * \defgroup dm Distributed mesh manager
1320 * \brief Implementation of PETSc DM, managing interactions between mesh data
1321 *structures and vectors and matrices
1322 *
1323 * DM objects are used to manage communication between the algebraic structures
1324 *in PETSc (Vec and Mat) and mesh data structures in PDE-based (or other)
1325 * simulations.
1326 *
1327 * DM is abstract interface, here is it particular implementation for MoFEM
1328 *code.
1329 *
1330 * \ingroup mofem
1331 **/
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:1421
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:554
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1429
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition DMMoFEM.cpp:1142
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:1153
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:517
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:737
PetscErrorCode DMMoFEMGetProblemFiniteElementLayout(DM dm, std::string fe_name, PetscLayout *layout)
Get finite elements layout in the problem.
Definition DMMoFEM.cpp:496
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition DMMoFEM.cpp:1207
PetscErrorCode DMMoFEMSetSquareProblem(DM dm, PetscBool square_problem)
set squared problem
Definition DMMoFEM.cpp:479
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:819
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:575
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:1457
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:1130
PetscErrorCode DMMoFEMSetKspCtx(DM dm, boost::shared_ptr< MoFEM::KspCtx > ksp_ctx)
set MoFEM::KspCtx data structure
Definition DMMoFEM.cpp:1104
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:778
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition DMMoFEM.cpp:1217
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition DMMoFEM.cpp:1305
PetscErrorCode DMMoFEMGetTsCtx(DM dm, MoFEM::TsCtx **ts_ctx)
get MoFEM::TsCtx data structure
Definition DMMoFEM.cpp:1161
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:543
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:1087
PetscErrorCode DMMoFEMGetSquareProblem(DM dm, PetscBool *square_problem)
get squared problem
Definition DMMoFEM.cpp:509
PetscErrorCode DMoFEMLoopDofs(DM dm, const char field_name[], MoFEM::DofMethod *method)
execute method for dofs on field in problem
Definition DMMoFEM.cpp:624
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:656
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name)
Resolve shared entities.
Definition DMMoFEM.cpp:487
PetscErrorCode DMMoFEMSetTsCtx(DM dm, boost::shared_ptr< MoFEM::TsCtx > ts_ctx)
Set MoFEM::TsCtx data structure.
Definition DMMoFEM.cpp:1178
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:605
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
Definition DMMoFEM.cpp:1536
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1250
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:872
MoFEMErrorCode DMMoFEMCreateBlockMat(DM dm, Mat *mat)
Create block matrix.
Definition DMMoFEM.cpp:1573
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:1036
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:994
auto createDMMatrix(DM dm)
Get smart matrix from DM.
Definition DMMoFEM.hpp:1207
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition DMMoFEM.cpp:1186
PetscErrorCode DMMoFEMGetSnesCtx(DM dm, MoFEM::SnesCtx **snes_ctx)
get MoFEM::SnesCtx data structure
Definition DMMoFEM.cpp:1113
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:1374
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:697
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition DMMoFEM.cpp:1491
PetscErrorCode DMMoFEMUnSetElement(DM dm, std::string fe_name)
unset element from dm
Definition DMMoFEM.cpp:534
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition DMMoFEM.cpp:1327
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1486
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:586
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
Definition DMMoFEM.cpp:565
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:1243
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:1075
auto getDMTsCtx(DM dm)
Get TS context data structure used by DM.
Definition DMMoFEM.hpp:1292
DEPRECATED auto smartGetDMKspCtx(DM dm)
Definition DMMoFEM.hpp:1272
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:901
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:1607
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:1564
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:1258
MoFEMErrorCode DMMoFEMCreateNestSchurMat(DM dm, Mat *mat)
Create nest schur matrix.
Definition DMMoFEM.cpp:1597
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:1264
auto createDMHybridisedL2Matrix(DM dm)
Get smart hybridised L2 matrix from DM.
Definition DMMoFEM.hpp:1220
auto getDMSubData(DM dm)
Get sub problem data structure.
Definition DMMoFEM.hpp:1308
MoFEMErrorCode DMMoFEMSetBlocMatData(DM dm, boost::shared_ptr< BlockStructure >)
Set data for block mat.
Definition DMMoFEM.cpp:1555
DEPRECATED auto smartGetDMTsCtx(DM dm)
Definition DMMoFEM.hpp:1300
auto getInterfacePtr(DM dm)
Get the Interface Ptr object.
Definition DMMoFEM.hpp:1184
MoFEMErrorCode DMMoFEMSetNestSchurData(DM dm, boost::shared_ptr< NestSchurData >)
Definition DMMoFEM.cpp:1584
DEPRECATED auto smartGetDMSnesCtx(DM dm)
Definition DMMoFEM.hpp:1286
auto getDMSnesCtx(DM dm)
Get SNES context data structure used by DM.
Definition DMMoFEM.hpp:1278
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:941
PetscErrorCode DMMoFEMSetVerbosity(DM dm, const int verb)
Set verbosity level.
Definition DMMoFEM.cpp:1547
auto createDMNestSchurMat(DM dm)
Definition DMMoFEM.hpp:1234
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:1195
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:1227
constexpr auto field_name
constexpr double g
Data structure to exchange data between MoFEM and User Loop Methods.
PETSc Discrete Manager data structure.
Definition DMMoFEM.hpp:1163
virtual ~DMCtx()=default
boost::shared_ptr< SnesCtx > snesCtx
data structure SNES
Definition DMMoFEM.hpp:1171
boost::shared_ptr< TsCtx > tsCtx
data structure for TS solver
Definition DMMoFEM.hpp:1172
boost::shared_ptr< KspCtx > kspCtx
data structure KSP
Definition DMMoFEM.hpp:1170
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