v0.15.5
Loading...
Searching...
No Matches
LoopMethods.hpp
Go to the documentation of this file.
1/** \file LoopMethods.hpp
2 * \brief MoFEM loop methods interface for finite element computations
3 * \author Anonymous author(s) committing under MIT license
4 *
5 * This file defines data structures and interfaces for making loops over finite
6 * elements, entities, and degrees of freedom (DOFs) in MoFEM problems and database.
7 *
8 * \section loop_overview Loop Methods Overview
9 *
10 * The core loop methods enable efficient iteration over:
11 * - **Finite Elements**: Using FEMethod with Interface::loop_finite_elements()
12 * - **Entities**: Using EntityMethod with Interface::loop_entities()
13 * - **DOFs**: Using DofMethod with Interface::loop_dofs()
14 *
15 * \section femethod_usage FEMethod Usage in Core Interface
16 *
17 * FEMethod is the primary interface for finite element computations, designed for
18 * high-performance element-level operations. It integrates with MoFEM's
19 * core looping mechanisms:
20 *
21 * **Loop Integration:**
22 * - Called via Interface::loop_finite_elements() for each element in a mesh
23 * - User overloads FEMethod::operator() to define element-specific computations
24 * - Provides access to element geometry, DOF data, and field values
25 * - Supports assembly of global matrices/vectors from element contributions
26 *
27 * **PETSc Solver Integration:**
28 * - **KSP (Linear)**: FEMethod assembles stiffness matrices and load vectors
29 * - **SNES (Nonlinear)**: Computes residuals and Jacobians for Newton methods
30 * - **TS (Time-stepping)**: Handles time-dependent mass matrices and residuals
31 * - **TAO (Optimization)**: Evaluates objective functions and gradients
32 *
33 * **ForcesAndSources Integration:**
34 * - FEMethod works with ForcesAndSources user data operators for element computations
35 * - ForcesAndSources provides high-level element assembly and integration routines
36 * - FEMethod offers direct low-level access for performance-critical applications
37 *
38 * Each solver context provides appropriate data structures (matrices, vectors,
39 * contexts) accessible through the inheritance hierarchy (BasicMethod -> FEMethod).
40 *
41 *
42 * \see Interface::loop_finite_elements, Interface::loop_entities, Interface::loop_dofs
43 *
44 */
45
46#ifndef __LOOPMETHODS_HPP__
47#define __LOOPMETHODS_HPP__
48
49namespace MoFEM {
50
51/**
52 * \brief Base data structure for PETSc-related contexts
53 * \ingroup mofem_loops
54 *
55 * This structure provides a foundation for managing PETSc data objects and contexts
56 * used throughout MoFEM finite element computations. It handles vectors, matrices,
57 * and context information needed for various PETSc solvers (KSP, SNES, TS, TAO).
58 */
59struct PetscData : public UnknownInterface {
60
61 /**
62 * \brief Query interface for type casting
63 * \param type_index Type information for interface querying
64 * \param iface Pointer to interface object
65 * \return Error code
66 */
67 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
68 UnknownInterface **iface) const;
69
70 /**
71 * \brief Default constructor
72 */
73 PetscData();
74
75 /**
76 * \brief Virtual destructor
77 */
78 virtual ~PetscData() = default;
79
80 /**
81 * \brief Enumeration for data context flags
82 *
83 * These flags indicate which PETSc data structures are currently set
84 * and available for use in computations. Multiple flags can be combined
85 * using bitwise operations.
86 */
88 CTX_SET_NONE = 0, ///< No data set
89 CTX_SET_F = 1 << 0, ///< Residual vector F is set
90 CTX_SET_A = 1 << 1, ///< Jacobian matrix A is set
91 CTX_SET_B = 1 << 2, ///< Preconditioner matrix B is set
92 CTX_SET_X = 1 << 3, ///< Solution vector X is set
93 CTX_SET_DX = 1 << 4, ///< Solution increment DX is set
94 CTX_SET_X_T = 1 << 5, ///< Time derivative X_t is set
95 CTX_SET_X_TT = 1 << 6, ///< Second time derivative X_tt is set
96 CTX_SET_TIME = 1 << 7 ///< Time value is set
97 };
98
99 using Switches = std::bitset<8>; ///< Bitset type for context switches
100
101 static constexpr Switches CtxSetNone = PetscData::Switches(CTX_SET_NONE); ///< No data switch
102 static constexpr Switches CtxSetF = PetscData::Switches(CTX_SET_F); ///< Residual vector switch
103 static constexpr Switches CtxSetA = PetscData::Switches(CTX_SET_A); ///< Jacobian matrix switch
104 static constexpr Switches CtxSetB = PetscData::Switches(CTX_SET_B); ///< Preconditioner matrix switch
105 static constexpr Switches CtxSetX = PetscData::Switches(CTX_SET_X); ///< Solution vector switch
106 static constexpr Switches CtxSetDX = PetscData::Switches(CTX_SET_DX); ///< Solution increment switch
107 static constexpr Switches CtxSetX_T = PetscData::Switches(CTX_SET_X_T); ///< First time derivative switch
108 static constexpr Switches CtxSetX_TT = PetscData::Switches(CTX_SET_X_TT); ///< Second time derivative switch
109 static constexpr Switches CtxSetTime = PetscData::Switches(CTX_SET_TIME); ///< Time value switch
110
111 Switches data_ctx; ///< Current data context switches
112
113 /**
114 * \brief Copy PETSc data from another instance
115 * \param petsc_data Source PETSc data structure
116 * \return Error code
117 */
118 MoFEMErrorCode copyPetscData(const PetscData &petsc_data);
119
120 Vec f; ///< PETSc residual vector
121 Mat A; ///< PETSc Jacobian matrix
122 Mat B; ///< PETSc preconditioner matrix
123 Vec x; ///< PETSc solution vector
124 Vec dx; ///< PETSc solution increment vector
125 Vec x_t; ///< PETSc first time derivative vector
126 Vec x_tt; ///< PETSc second time derivative vector
127};
128
129/**
130 * \brief Data structure for KSP (linear solver) context
131 * \ingroup mofem_loops
132 *
133 * This structure extends PetscData to provide context and data management
134 * specifically for PETSc KSP (Krylov Subspace) linear solvers. It stores
135 * the KSP solver instance and maintains context information about the
136 * current computation phase.
137 */
138struct KspMethod : virtual public PetscData {
139
140 /**
141 * \brief Query interface for type casting
142 * \param type_index Type information for interface querying
143 * \param iface Pointer to interface object
144 * \return Error code
145 */
146 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
147 UnknownInterface **iface) const;
148
149 /**
150 * \brief Context enumeration for KSP solver phases
151 *
152 * Indicates the current phase of KSP computation, which determines
153 * which data structures are being used and what operations are valid.
154 */
156 CTX_SETFUNCTION, ///< Setting up the linear system function
157 CTX_OPERATORS, ///< Setting up linear operators
158 CTX_KSPNONE ///< No specific KSP context
159 };
160
161 /**
162 * \brief Default constructor
163 */
164 KspMethod();
165
166 /**
167 * \brief Virtual destructor
168 */
169 virtual ~KspMethod() = default;
170
171 /**
172 * \brief Copy data from another KSP method
173 * \param ksp Source KSP method
174 * \return Error code
175 */
177
178 KSPContext ksp_ctx; ///< Current KSP computation context
179 KSP ksp; ///< PETSc KSP linear solver object
180
181 Vec &ksp_f; ///< Reference to residual vector in KSP context
182 Mat &ksp_A; ///< Reference to system matrix in KSP context
183 Mat &ksp_B; ///< Reference to preconditioner matrix in KSP context
184};
185
186/**
187 * \brief Data structure for SNES (nonlinear solver) context
188 * \ingroup mofem_loops
189 *
190 * This structure extends PetscData to provide context and data management
191 * specifically for PETSc SNES (Scalable Nonlinear Equation Solvers). It stores
192 * the SNES solver instance and maintains context information about nonlinear
193 * solution phases including function evaluation and Jacobian computation.
194 */
195struct SnesMethod : virtual protected PetscData {
196
197 /**
198 * \brief Query interface for type casting
199 * \param type_index Type information for interface querying
200 * \param iface Pointer to interface object
201 * \return Error code
202 */
203 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
204 UnknownInterface **iface) const;
205
206 /**
207 * \brief Context enumeration for SNES solver phases
208 *
209 * Indicates the current phase of SNES computation, determining which
210 * operations are being performed and what data structures are active.
211 */
213 CTX_SNESSETFUNCTION, ///< Setting up nonlinear function evaluation
214 CTX_SNESSETJACOBIAN, ///< Setting up Jacobian matrix computation
215 CTX_SNESNONE ///< No specific SNES context
216 };
217
218 /**
219 * \brief Default constructor
220 */
221 SnesMethod();
222
223 /**
224 * \brief Virtual destructor
225 */
226 virtual ~SnesMethod() = default;
227
228 /**
229 * \brief Copy SNES data from another instance
230 * \param snes Source SNES method
231 * \return Error code
232 */
234
235 SNESContext snes_ctx; ///< Current SNES computation context
236
237 SNES snes; ///< PETSc SNES nonlinear solver object
238 Vec &snes_x; ///< Reference to current solution state vector
239 Vec &snes_dx; ///< Reference to solution update/increment vector
240 Vec &snes_f; ///< Reference to residual vector
241 Mat &snes_A; ///< Reference to Jacobian matrix
242 Mat &snes_B; ///< Reference to preconditioner of Jacobian matrix
243};
244
245/**
246 * \brief Data structure for TS (time stepping) context
247 * \ingroup mofem_loops
248 *
249 * This structure extends PetscData to provide context and data management
250 * specifically for PETSc TS (Time Stepping) solvers. It manages time-dependent
251 * computations including time derivatives, time step information, and temporal
252 * integration contexts for transient finite element analyses.
253 */
254struct TSMethod : virtual protected PetscData {
255
256 /**
257 * \brief Query interface for type casting
258 * \param type_index Type information for interface querying
259 * \param iface Pointer to interface object
260 * \return Error code
261 */
262 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
263 UnknownInterface **iface) const;
264
265 /**
266 * \brief Context enumeration for TS solver phases
267 *
268 * Indicates the current phase of time stepping computation, determining
269 * which temporal operations are being performed and what data is active.
270 */
272 CTX_TSSETRHSFUNCTION, ///< Setting up right-hand side function
273 CTX_TSSETRHSJACOBIAN, ///< Setting up right-hand side Jacobian
274 CTX_TSSETIFUNCTION, ///< Setting up implicit function
275 CTX_TSSETIJACOBIAN, ///< Setting up implicit Jacobian
276 CTX_TSTSMONITORSET, ///< Setting up time step monitoring
277 CTX_TSNONE ///< No specific TS context
278 };
279
280 /**
281 * \brief Default constructor
282 */
283 TSMethod();
284
285 /**
286 * \brief Virtual destructor
287 */
288 virtual ~TSMethod() = default;
289
290 /**
291 * \brief Copy TS solver data from another instance
292 * \param ts Source TS method
293 * \return Error code
294 */
296
297 TS ts; ///< PETSc time stepping solver object
298
299 TSContext ts_ctx; ///< Current TS computation context
300
301 PetscInt ts_step; ///< Current time step number
302 PetscReal ts_a; ///< Shift parameter for U_t (see PETSc Time Solver documentation)
303 PetscReal ts_aa; ///< Shift parameter for U_tt (second time derivative)
304 PetscReal ts_t; ///< Current time value
305 PetscReal ts_dt; ///< Current time step size
306
307 Vec &ts_u; ///< Reference to current state vector U(t)
308 Vec &ts_u_t; ///< Reference to first time derivative of state vector dU/dt
309 Vec &ts_u_tt; ///< Reference to second time derivative of state vector d²U/dt²
310 Vec &ts_F; ///< Reference to residual vector F(t,U,U_t,U_tt)
311
312 Mat &ts_A; ///< Reference to Jacobian matrix: dF/dU + a*dF/dU_t + aa*dF/dU_tt
313 Mat &ts_B; ///< Reference to preconditioner matrix for ts_A
314};
315
316/**
317 * \brief Data structure for TAO (optimization) context
318 * \ingroup mofem_loops
319 *
320 * This structure extends PetscData to provide context and data management
321 * specifically for PETSc TAO (Toolkit for Advanced Optimization) solvers.
322 * It manages optimization computations including objective function evaluation,
323 * gradient computation, and Hessian matrix assembly for constrained and
324 * unconstrained optimization problems.
325 */
326struct TaoMethod : virtual protected PetscData {
327
328 /**
329 * \brief Query interface for type casting
330 * \param type_index Type information for interface querying
331 * \param iface Pointer to interface object
332 * \return Error code
333 */
334 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
335 UnknownInterface **iface) const;
336
337 /**
338 * \brief Context enumeration for TAO solver phases
339 *
340 * Indicates the current phase of optimization computation, determining
341 * which optimization operations are being performed.
342 */
344 CTX_TAO_OBJECTIVE, ///< Evaluating objective function
345 CTX_TAO_GRADIENT, ///< Computing gradient vector
346 CTX_TAO_HESSIAN, ///< Assembling Hessian matrix
347 CTX_TAO_NONE ///< No specific TAO context
348 };
349
350 /**
351 * \brief Default constructor
352 */
353 TaoMethod();
354
355 /**
356 * \brief Virtual destructor
357 */
358 virtual ~TaoMethod() = default;
359
360 /**
361 * \brief Copy TAO data from another instance
362 * \param tao Source TAO method
363 * \return Error code
364 */
366
367 TAOContext tao_ctx; ///< Current TAO computation context
368
369 Tao tao; ///< PETSc TAO optimization solver object
370 Vec &tao_x; ///< Reference to optimization variables vector
371 Vec &tao_f; ///< Reference to gradient vector
372 Mat &tao_A; ///< Reference to Hessian matrix
373 Mat &tao_B; ///< Reference to preconditioner matrix for Hessian
374};
375
376/**
377 * \brief Data structure to exchange data between MoFEM and User Loop Methods
378 * \ingroup mofem_loops
379 *
380 * This is a comprehensive base class that combines all PETSc solver contexts
381 * (KSP, SNES, TS, TAO) and provides fundamental data exchange capabilities
382 * between MoFEM and user-defined functions. It stores information about
383 * multi-indices, problem databases, and provides access to finite element
384 * data structures for loop-based computations.
385 */
387
388 /**
389 * \brief Query interface for type casting
390 * \param type_index Type information for interface querying
391 * \param iface Pointer to interface object
392 * \return Error code
393 */
394 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
395 UnknownInterface **iface) const {
397 *iface = const_cast<BasicMethod *>(this);
399 }
400
401 /**
402 * \brief Default constructor
403 */
404 BasicMethod();
405
406 /**
407 * \brief Virtual destructor
408 */
409 virtual ~BasicMethod() = default;
410
411 /**
412 * @brief Current index of processed method in the loop
413 *
414 * This counter tracks which method/element is currently being processed
415 * in the loop iteration, useful for debugging and progress monitoring.
416 */
418
419 /**
420 * @brief Total number of methods to process in the loop
421 *
422 * This value represents the total count of items (elements, entities, etc.)
423 * that will be processed in the current loop execution.
424 */
426
427 /**
428 * \brief Get current loop iteration index
429 * \return Current position in the loop (0-based)
430 */
431 inline int getNinTheLoop() const { return nInTheLoop; }
432
433 /**
434 * \brief Get total loop size
435 * \return Total number of items to process in the loop
436 */
437 inline int getLoopSize() const { return loopSize; }
438
439 /**
440 * @brief Processor rank range for distributed finite element iteration
441 *
442 * This pair stores the low and high processor ranks that define the range
443 * of processors involved in the current finite element iteration. Used for
444 * parallel processing and load balancing across MPI processes.
445 */
446 std::pair<int, int> loHiFERank;
447
448 /**
449 * @brief Get processor rank range for finite element iteration
450 *
451 * Returns the pair containing the lowest and highest processor ranks
452 * involved in the current finite element loop iteration.
453 *
454 * @return Pair<low_rank, high_rank> of processor ranges
455 */
456 inline auto getLoHiFERank() const { return loHiFERank; }
457
458 /**
459 * @brief Get lower processor rank for finite element iteration
460 *
461 * Returns the lowest processor rank in the range of processors
462 * that will process finite elements in the current loop.
463 *
464 * @return Lowest processor rank in the iteration range
465 */
466 inline auto getLoFERank() const { return loHiFERank.first; }
467
468 /**
469 * @brief Get upper processor rank for finite element iteration
470 *
471 * Returns the highest processor rank in the range of processors
472 * that will process finite elements in the current loop.
473 *
474 * @return Highest processor rank in the iteration range
475 */
476 inline auto getHiFERank() const { return loHiFERank.second; }
477
478 int rAnk; ///< Current processor rank in MPI communicator
479
480 int sIze; ///< Total number of processors in MPI communicator
481
483 *refinedEntitiesPtr; ///< Pointer to container of refined MoFEM DOF entities
484
486 *refinedFiniteElementsPtr; ///< Pointer to container of refined finite element entities
487
488 const Problem *problemPtr; ///< Raw pointer to current MoFEM problem instance
489
490 const Field_multiIndex *fieldsPtr; ///< Raw pointer to fields multi-index container
491
493 *entitiesPtr; ///< Raw pointer to container of field entities
494
495 const DofEntity_multiIndex *dofsPtr; ///< Raw pointer to container of degree of freedom entities
496
498 *finiteElementsPtr; ///< Raw pointer to container of finite elements
499
501 *finiteElementsEntitiesPtr; ///< Raw pointer to container of finite element entities
502
504 *adjacenciesPtr; ///< Raw pointer to container of adjacencies between DOFs and finite elements
505
506 /**
507 * \brief Get bit number for a specific field by name
508 *
509 * This function looks up a field by name in the fields container and returns
510 * its bit number, which is used for field identification and bit operations
511 * in MoFEM's field management system.
512 *
513 * \param field_name Name of the field to look up
514 * \return Bit number of the field, or BITFEID_SIZE if field not found
515 * \throws MoFEM exception if fieldsPtr is not set
516 */
517 inline unsigned int getFieldBitNumber(std::string field_name) const {
518 if (fieldsPtr) {
519 auto field_it = fieldsPtr->get<FieldName_mi_tag>().find(field_name);
520 if (field_it != fieldsPtr->get<FieldName_mi_tag>().end())
521 return (*field_it)->getBitNumber();
522 else
523 return BITFEID_SIZE;
524 } else {
525 THROW_MESSAGE("Pointer to fields multi-index is not set");
526 return BITFEID_SIZE;
527 }
528 }
529
530 /**
531 * @brief Copy data from another BasicMethod instance
532 *
533 * This function copies all relevant data from another BasicMethod instance
534 * including solver contexts, database pointers, and configuration settings.
535 *
536 * @param basic Source BasicMethod to copy from
537 * @return Error code indicating success or failure
538 */
540
541 /**
542 * @brief Hook function for pre-processing operations
543 *
544 * User-defined function that is executed before the main loop begins.
545 * Can be used for initialization, setup operations, or custom preprocessing.
546 */
547 boost::function<MoFEMErrorCode()> preProcessHook;
548
549 /**
550 * @brief Hook function for post-processing operations
551 *
552 * User-defined function that is executed after the main loop completes.
553 * Can be used for cleanup, finalization, or custom post-processing.
554 */
555 boost::function<MoFEMErrorCode()> postProcessHook;
556
557 /**
558 * @brief Hook function for main operator execution
559 *
560 * User-defined function that can be executed during the main operator
561 * call, providing additional customization points in the computation.
562 */
563 boost::function<MoFEMErrorCode()> operatorHook;
564
565 /**
566 * \brief Pre-processing function executed at loop initialization
567 *
568 * This virtual function is called once at the beginning of the loop.
569 * It is typically used for:
570 * - Zeroing matrices and vectors
571 * - Computing shape functions on reference elements
572 * - Preprocessing boundary conditions
573 * - Setting up initial computation state
574 *
575 * \return Error code indicating success or failure
576 */
577 virtual MoFEMErrorCode preProcess();
578
579 /**
580 * \brief Main operator function executed for each loop iteration
581 *
582 * This virtual function is called for every item (finite element, entity, etc.)
583 * in the loop. It is the core computation function typically used for:
584 * - Calculating element local matrices and vectors
585 * - Assembling contributions to global system
586 * - Element-level post-processing operations
587 *
588 * \return Error code indicating success or failure
589 */
590 virtual MoFEMErrorCode operator()();
591
592 /**
593 * \brief Post-processing function executed at loop completion
594 *
595 * This virtual function is called once at the end of the loop.
596 * It is typically used for:
597 * - Assembling matrices and vectors to global system
598 * - Computing global variables (e.g., total internal energy)
599 * - Finalizing computation results
600 * - Cleanup operations
601 *
602 * Example of iterating over DOFs:
603 * \code
604 * for(_IT_GET_FEROW_BY_NAME_DOFS_FOR_LOOP_(this,"DISPLACEMENT",it)) {
605 * // Process each DOF
606 * }
607 * \endcode
608 *
609 * \return Error code indicating success or failure
610 */
611 virtual MoFEMErrorCode postProcess();
612
613 /**
614 * @brief Get the cache weak pointer object
615 *
616 * Returns a weak pointer to the cache tuple that stores problem information
617 * on entities about DOFs. Each problem stores different information.
618 *
619 * \warning When iterating over finite elements in a TS (time-stepping) solver
620 * preprocessor, use the TS cache in the loop. Using wrong cache will cause
621 * undefined behavior or segmentation faults. This design is a necessary
622 * compromise between bug resilience and memory/performance optimization.
623 *
624 * @return Weak pointer to the cache tuple
625 */
626 inline boost::weak_ptr<CacheTuple> getCacheWeakPtr() const {
627 return cacheWeakPtr;
628 }
629
630 boost::movelib::unique_ptr<bool> vecAssembleSwitch; ///< Switch for vector assembly operations
631 boost::movelib::unique_ptr<bool> matAssembleSwitch; ///< Switch for matrix assembly operations
632
633 boost::weak_ptr<CacheTuple> cacheWeakPtr; ///< Weak pointer to cached entity data
634};
635
636/**
637 * \brief Structure for user loop methods on finite elements
638 * \ingroup mofem_loops
639 *
640 * This class provides a high-performance interface for finite element computations.
641 * It can be used to calculate stiffness matrices, residual vectors, load vectors,
642 * and other element-level quantities. While it is a low-level class, users seeking
643 * maximum speed and efficiency can use it directly.
644 *
645 * This class is designed to work with Interface::loop_finite_elements, where the
646 * user-overloaded operator FEMethod::operator() is executed for each element in
647 * the problem. The class provides additional virtual methods (preProcess and
648 * postProcess) that can be overloaded by users for custom preprocessing and
649 * postprocessing operations.
650 *
651 * Key features:
652 * - Direct access to finite element data structures
653 * - High-performance element iteration
654 * - Customizable preprocessing and postprocessing
655 * - Integration with MoFEM's data management system
656 */
657struct FEMethod : public BasicMethod {
658
659 /**
660 * \brief Query interface for type casting
661 * \param type_index Type information for interface querying
662 * \param iface Pointer to interface object
663 * \return Error code
664 */
665 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
666 UnknownInterface **iface) const {
668 *iface = const_cast<FEMethod *>(this);
670 }
671
672 /**
673 * \brief Default constructor
674 */
675 FEMethod() = default;
676
677 std::string feName; ///< Name of the finite element being processed
678
679 boost::shared_ptr<const NumeredEntFiniteElement>
680 numeredEntFiniteElementPtr; ///< Shared pointer to finite element database structure
681
682 /**
683 * @brief Get the name of the current finite element
684 *
685 * Returns the name string identifier of the finite element currently
686 * being processed in the loop.
687 *
688 * @return String containing the finite element name
689 */
690 inline auto getFEName() const { return feName; }
691
692 /**
693 * @brief Test function to determine if element should be skipped
694 *
695 * This optional hook function allows users to implement custom logic
696 * to determine whether a particular finite element should be skipped
697 * during the loop execution. If this function is set and returns false,
698 * the element will be skipped in MoFEM::Core::loop_finite_elements.
699 *
700 * \note This functionality is particularly useful for running elements
701 * only on specific bit levels or under certain conditions.
702 *
703 * @param fe_method_ptr Pointer to the current FEMethod instance
704 * @return true if element should be processed, false if it should be skipped
705 */
706 boost::function<bool(FEMethod *fe_method_ptr)> exeTestHook;
707
708 /**
709 * \brief Get pointer to DOF data for the current finite element
710 * \return Pointer to DOF data container
711 */
712 inline auto getDataDofsPtr() const {
713 return numeredEntFiniteElementPtr->getDataDofsPtr();
714 };
715
716 /**
717 * \brief Get pointer to vector DOF data for the current finite element
718 * \return Pointer to vector DOF data container
719 */
720 inline auto getDataVectorDofsPtr() const {
721 return numeredEntFiniteElementPtr->getDataVectorDofsPtr();
722 };
723
724 /**
725 * \brief Get reference to data field entities for the current finite element
726 * \return Constant reference to field entities view
727 */
729 return numeredEntFiniteElementPtr->getDataFieldEnts();
730 }
731
732 /**
733 * \brief Get shared pointer to data field entities for the current finite element
734 * \return Shared pointer to field entities view (mutable access)
735 */
736 inline boost::shared_ptr<FieldEntity_vector_view> &
738 return const_cast<NumeredEntFiniteElement *>(
741 }
742
743 /**
744 * \brief Get reference to row field entities for the current finite element
745 * \return Reference to row field entities container
746 */
747 inline auto &getRowFieldEnts() const {
748 return numeredEntFiniteElementPtr->getRowFieldEnts();
749 };
750
751 /**
752 * \brief Get shared pointer to row field entities for the current finite element
753 * \return Shared pointer to row field entities container
754 */
755 inline auto &getRowFieldEntsPtr() const {
756 return numeredEntFiniteElementPtr->getRowFieldEntsPtr();
757 };
758
759 /**
760 * \brief Get reference to column field entities for the current finite element
761 * \return Reference to column field entities container
762 */
763 inline auto &getColFieldEnts() const {
764 return numeredEntFiniteElementPtr->getColFieldEnts();
765 };
766
767 /**
768 * \brief Get shared pointer to column field entities for the current finite element
769 * \return Shared pointer to column field entities container
770 */
771 inline auto &getColFieldEntsPtr() const {
772 return numeredEntFiniteElementPtr->getColFieldEntsPtr();
773 };
774
775 /**
776 * \brief Get pointer to row DOFs for the current finite element
777 *
778 * Returns a pointer to the container of row degrees of freedom
779 * associated with the current finite element. Row DOFs are used
780 * in matrix assembly for the row indices.
781 *
782 * \return Pointer to row DOFs container
783 */
784 inline auto getRowDofsPtr() const {
785 return numeredEntFiniteElementPtr->getRowDofsPtr();
786 };
787
788 /**
789 * \brief Get pointer to column DOFs for the current finite element
790 *
791 * Returns a pointer to the container of column degrees of freedom
792 * associated with the current finite element. Column DOFs are used
793 * in matrix assembly for the column indices.
794 *
795 * \return Pointer to column DOFs container
796 */
797 inline auto getColDofsPtr() const {
798 return numeredEntFiniteElementPtr->getColDofsPtr();
799 };
800
801 /**
802 * \brief Get the number of nodes in the current finite element
803 *
804 * Returns the number of vertex nodes for the current finite element
805 * based on its entity type (e.g., 4 for tetrahedron, 8 for hexahedron).
806 *
807 * \return Number of nodes in the finite element
808 */
809 inline auto getNumberOfNodes() const;
810
811 /**
812 * \brief Get the entity handle of the current finite element
813 *
814 * Returns the MOAB entity handle that uniquely identifies the
815 * current finite element in the mesh database.
816 *
817 * \return MOAB entity handle of the finite element
818 */
819 inline EntityHandle getFEEntityHandle() const;
820
821 /**
822 * \brief Get nodal data for a specific field
823 *
824 * Extracts nodal values for the specified field from the current
825 * finite element and stores them in the provided data vector.
826 *
827 * \param field_name Name of the field to extract data for
828 * \param data Vector to store the extracted nodal data
829 * \param reset_dofs Flag to reset DOF values (default: true)
830 * \return Error code indicating success or failure
831 */
832 MoFEMErrorCode getNodeData(const std::string field_name, VectorDouble &data,
833 const bool reset_dofs = true);
834
835};
836
837inline auto FEMethod::getNumberOfNodes() const {
838 return moab::CN::VerticesPerEntity(numeredEntFiniteElementPtr->getEntType());
839};
840
842 return numeredEntFiniteElementPtr->getEnt();
843}
844
845/**
846 * \brief Data structure for user loop methods on entities
847 * \ingroup mofem_loops
848 *
849 * This structure extends BasicMethod to provide entity-level loop operations.
850 * It allows exchange of data between MoFEM and user functions when iterating
851 * over mesh entities (vertices, edges, faces, volumes). It stores pointers
852 * to field and entity information for entity-based computations.
853 *
854 * Key features:
855 * - Entity-level iteration capabilities
856 * - Field data access for entities
857 * - Integration with MoFEM's entity management system
858 */
859struct EntityMethod : public BasicMethod {
860
861 /**
862 * \brief Query interface for type casting
863 * \param type_index Type information for interface querying
864 * \param iface Pointer to interface object
865 * \return Error code
866 */
867 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
868 UnknownInterface **iface) const {
870 *iface = const_cast<EntityMethod *>(this);
872 }
873
874 /**
875 * \brief Default constructor
876 */
877 EntityMethod() = default;
878
879 boost::shared_ptr<Field> fieldPtr; ///< Shared pointer to field information
880 boost::shared_ptr<FieldEntity> entPtr; ///< Shared pointer to field entity data
881};
882
883/**
884 * \brief Data structure for user loop methods on degrees of freedom (DOFs)
885 * \ingroup mofem_loops
886 *
887 * This structure extends BasicMethod to provide DOF-level loop operations.
888 * It allows exchange of data between MoFEM and user functions when iterating
889 * over degrees of freedom. It stores pointers to field, DOF entity, and
890 * numbered DOF entity information for DOF-based computations.
891 *
892 * Key features:
893 * - DOF-level iteration capabilities
894 * - Access to both raw and numbered DOF data
895 * - Field information associated with DOFs
896 * - Integration with MoFEM's DOF management system
897 */
898struct DofMethod : public BasicMethod {
899
900 /**
901 * \brief Query interface for type casting
902 * \param type_index Type information for interface querying
903 * \param iface Pointer to interface object
904 * \return Error code
905 */
906 MoFEMErrorCode query_interface(boost::typeindex::type_index type_index,
907 UnknownInterface **iface) const {
909 *iface = const_cast<DofMethod *>(this);
911 }
912
913 /**
914 * \brief Default constructor
915 */
916 DofMethod() = default;
917
918 boost::shared_ptr<Field> fieldPtr; ///< Shared pointer to field information
919 boost::shared_ptr<DofEntity> dofPtr; ///< Shared pointer to DOF entity data
920 boost::shared_ptr<NumeredDofEntity> dofNumeredPtr; ///< Shared pointer to numbered DOF entity data
921};
922
923/// \deprecated name changed use DofMethod instead EntMethod
925
926} // namespace MoFEM
927
928#endif // __LOOPMETHODS_HPP__
929
930/**
931 * \defgroup mofem_loops Loops
932 * \ingroup mofem
933 */
multi_index_container< FieldEntityEntFiniteElementAdjacencyMap, indexed_by< ordered_unique< tag< Composite_Unique_mi_tag >, composite_key< FieldEntityEntFiniteElementAdjacencyMap, const_mem_fun< FieldEntityEntFiniteElementAdjacencyMap, UId, &FieldEntityEntFiniteElementAdjacencyMap::getEntUniqueId >, const_mem_fun< FieldEntityEntFiniteElementAdjacencyMap, UId, &FieldEntityEntFiniteElementAdjacencyMap::getFeUniqueId > > >, ordered_non_unique< tag< Unique_mi_tag >, const_mem_fun< FieldEntityEntFiniteElementAdjacencyMap, UId, &FieldEntityEntFiniteElementAdjacencyMap::getEntUniqueId > >, ordered_non_unique< tag< FE_Unique_mi_tag >, const_mem_fun< FieldEntityEntFiniteElementAdjacencyMap, UId, &FieldEntityEntFiniteElementAdjacencyMap::getFeUniqueId > >, ordered_non_unique< tag< FEEnt_mi_tag >, const_mem_fun< FieldEntityEntFiniteElementAdjacencyMap, EntityHandle, &FieldEntityEntFiniteElementAdjacencyMap::getFeHandle > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< FieldEntityEntFiniteElementAdjacencyMap, EntityHandle, &FieldEntityEntFiniteElementAdjacencyMap::getEntHandle > > > > FieldEntityEntFiniteElementAdjacencyMap_multiIndex
MultiIndex container keeps Adjacencies Element and dof entities adjacencies and vice versa.
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Multi-index container for field storage and retrieval.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define DEPRECATED
Definition definitions.h:17
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define BITFEID_SIZE
max number of finite elements
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
multi_index_container< boost::shared_ptr< DofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< DofEntity, UId, &DofEntity::getLocalUniqueId > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< DofEntity, EntityHandle, &DofEntity::getEnt > > > > DofEntity_multiIndex
MultiIndex container keeps DofEntity.
multi_index_container< boost::shared_ptr< EntFiniteElement >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< EntFiniteElement, UId, &EntFiniteElement::getLocalUniqueId > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< EntFiniteElement::interface_type_RefEntity, EntityHandle, &EntFiniteElement::getEnt > > > > EntFiniteElement_multiIndex
MultiIndex container for EntFiniteElement.
multi_index_container< boost::shared_ptr< FiniteElement >, indexed_by< hashed_unique< tag< FiniteElement_Meshset_mi_tag >, member< FiniteElement, EntityHandle, &FiniteElement::meshset > >, hashed_unique< tag< BitFEId_mi_tag >, const_mem_fun< FiniteElement, BitFEId, &FiniteElement::getId >, HashBit< BitFEId >, EqBit< BitFEId > >, ordered_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< FiniteElement, boost::string_ref, &FiniteElement::getNameRef > > > > FiniteElement_multiIndex
MultiIndex for entities for FiniteElement.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
UBlasVector< double > VectorDouble
Definition Types.hpp:68
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
DEPRECATED typedef DofMethod EntMethod
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getEnt > >, ordered_non_unique< tag< Ent_Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, ordered_non_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityType, &RefEntity::getParentEntType > > >, ordered_non_unique< tag< Composite_ParentEnt_And_EntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > > > > > RefEntity_multiIndex
std::vector< boost::weak_ptr< FieldEntity > > FieldEntity_vector_view
Field_multiIndex::index< FieldName_mi_tag >::type::iterator field_it
multi_index_container< boost::shared_ptr< RefElement >, indexed_by< ordered_unique< tag< Ent_mi_tag >, const_mem_fun< RefElement::interface_type_RefEntity, EntityHandle, &RefElement::getEnt > > > > RefElement_multiIndex
multi_index_container< boost::shared_ptr< FieldEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< FieldEntity, UId, &FieldEntity::localUId > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< FieldEntity::interface_type_RefEntity, EntityHandle, &FieldEntity::getEnt > > > > FieldEntity_multiIndex
constexpr auto field_name
Data structure to exchange data between MoFEM and User Loop Methods.
int loopSize
Total number of methods to process in the loop.
boost::movelib::unique_ptr< bool > matAssembleSwitch
Switch for matrix assembly operations.
const FieldEntity_multiIndex * entitiesPtr
Raw pointer to container of field entities.
BasicMethod()
Default constructor.
unsigned int getFieldBitNumber(std::string field_name) const
Get bit number for a specific field by name.
virtual ~BasicMethod()=default
Virtual destructor.
MoFEMErrorCode copyBasicMethod(const BasicMethod &basic)
Copy data from another BasicMethod instance.
auto getHiFERank() const
Get upper processor rank for finite element iteration.
const FiniteElement_multiIndex * finiteElementsPtr
Raw pointer to container of finite elements.
const RefElement_multiIndex * refinedFiniteElementsPtr
Pointer to container of refined finite element entities.
int getLoopSize() const
Get total loop size.
std::pair< int, int > loHiFERank
Processor rank range for distributed finite element iteration.
boost::function< MoFEMErrorCode()> preProcessHook
Hook function for pre-processing operations.
const DofEntity_multiIndex * dofsPtr
Raw pointer to container of degree of freedom entities.
int rAnk
Current processor rank in MPI communicator.
boost::weak_ptr< CacheTuple > getCacheWeakPtr() const
Get the cache weak pointer object.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
const Field_multiIndex * fieldsPtr
Raw pointer to fields multi-index container.
int nInTheLoop
Current index of processed method in the loop.
auto getLoHiFERank() const
Get processor rank range for finite element iteration.
const RefEntity_multiIndex * refinedEntitiesPtr
Pointer to container of refined MoFEM DOF entities.
boost::movelib::unique_ptr< bool > vecAssembleSwitch
Switch for vector assembly operations.
virtual MoFEMErrorCode postProcess()
Post-processing function executed at loop completion.
const FieldEntityEntFiniteElementAdjacencyMap_multiIndex * adjacenciesPtr
Raw pointer to container of adjacencies between DOFs and finite elements.
virtual MoFEMErrorCode operator()()
Main operator function executed for each loop iteration.
virtual MoFEMErrorCode preProcess()
Pre-processing function executed at loop initialization.
const EntFiniteElement_multiIndex * finiteElementsEntitiesPtr
Raw pointer to container of finite element entities.
const Problem * problemPtr
Raw pointer to current MoFEM problem instance.
auto getLoFERank() const
Get lower processor rank for finite element iteration.
boost::function< MoFEMErrorCode()> operatorHook
Hook function for main operator execution.
int sIze
Total number of processors in MPI communicator.
boost::weak_ptr< CacheTuple > cacheWeakPtr
Weak pointer to cached entity data.
int getNinTheLoop() const
Get current loop iteration index.
boost::function< MoFEMErrorCode()> postProcessHook
Hook function for post-processing operations.
Data structure for user loop methods on degrees of freedom (DOFs)
boost::shared_ptr< DofEntity > dofPtr
Shared pointer to DOF entity data.
DofMethod()=default
Default constructor.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
boost::shared_ptr< NumeredDofEntity > dofNumeredPtr
Shared pointer to numbered DOF entity data.
boost::shared_ptr< Field > fieldPtr
Shared pointer to field information.
Data structure for user loop methods on entities.
EntityMethod()=default
Default constructor.
boost::shared_ptr< Field > fieldPtr
Shared pointer to field information.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
boost::shared_ptr< FieldEntity > entPtr
Shared pointer to field entity data.
Structure for user loop methods on finite elements.
std::string feName
Name of the finite element being processed.
auto & getColFieldEntsPtr() const
Get shared pointer to column field entities for the current finite element.
FEMethod()=default
Default constructor.
auto & getRowFieldEnts() const
Get reference to row field entities for the current finite element.
auto getFEName() const
Get the name of the current finite element.
MoFEMErrorCode getNodeData(const std::string field_name, VectorDouble &data, const bool reset_dofs=true)
Get nodal data for a specific field.
auto getDataDofsPtr() const
Get pointer to DOF data for the current finite element.
const FieldEntity_vector_view & getDataFieldEnts() const
Get reference to data field entities for the current finite element.
auto getDataVectorDofsPtr() const
Get pointer to vector DOF data for the current finite element.
boost::shared_ptr< FieldEntity_vector_view > & getDataFieldEntsPtr() const
Get shared pointer to data field entities for the current finite element.
auto getColDofsPtr() const
Get pointer to column DOFs for the current finite element.
EntityHandle getFEEntityHandle() const
Get the entity handle of the current finite element.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
auto & getRowFieldEntsPtr() const
Get shared pointer to row field entities for the current finite element.
auto getNumberOfNodes() const
Get the number of nodes in the current finite element.
auto getRowDofsPtr() const
Get pointer to row DOFs for the current finite element.
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Shared pointer to finite element database structure.
auto & getColFieldEnts() const
Get reference to column field entities for the current finite element.
boost::function< bool(FEMethod *fe_method_ptr)> exeTestHook
Test function to determine if element should be skipped.
MultiIndex Tag for field name.
Data structure for KSP (linear solver) context.
MoFEMErrorCode copyKsp(const KspMethod &ksp)
Copy data from another KSP method.
Mat & ksp_B
Reference to preconditioner matrix in KSP context.
KSPContext ksp_ctx
Current KSP computation context.
virtual ~KspMethod()=default
Virtual destructor.
KSPContext
Context enumeration for KSP solver phases.
@ CTX_KSPNONE
No specific KSP context.
@ CTX_SETFUNCTION
Setting up the linear system function.
@ CTX_OPERATORS
Setting up linear operators.
KspMethod()
Default constructor.
KSP ksp
PETSc KSP linear solver object.
Mat & ksp_A
Reference to system matrix in KSP context.
Vec & ksp_f
Reference to residual vector in KSP context.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
Partitioned (Indexed) Finite Element in Problem.
Base data structure for PETSc-related contexts.
static constexpr Switches CtxSetA
Jacobian matrix switch.
static constexpr Switches CtxSetX
Solution vector switch.
Vec f
PETSc residual vector.
static constexpr Switches CtxSetX_TT
Second time derivative switch.
static constexpr Switches CtxSetNone
No data switch.
static constexpr Switches CtxSetF
Residual vector switch.
Vec x_t
PETSc first time derivative vector.
std::bitset< 8 > Switches
Bitset type for context switches.
virtual ~PetscData()=default
Virtual destructor.
Vec x_tt
PETSc second time derivative vector.
Vec dx
PETSc solution increment vector.
Switches data_ctx
Current data context switches.
static constexpr Switches CtxSetDX
Solution increment switch.
static constexpr Switches CtxSetX_T
First time derivative switch.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
DataContext
Enumeration for data context flags.
@ CTX_SET_NONE
No data set.
@ CTX_SET_X_T
Time derivative X_t is set.
@ CTX_SET_A
Jacobian matrix A is set.
@ CTX_SET_TIME
Time value is set.
@ CTX_SET_DX
Solution increment DX is set.
@ CTX_SET_X
Solution vector X is set.
@ CTX_SET_F
Residual vector F is set.
@ CTX_SET_X_TT
Second time derivative X_tt is set.
@ CTX_SET_B
Preconditioner matrix B is set.
Vec x
PETSc solution vector.
Mat B
PETSc preconditioner matrix.
static constexpr Switches CtxSetB
Preconditioner matrix switch.
PetscData()
Default constructor.
static constexpr Switches CtxSetTime
Time value switch.
MoFEMErrorCode copyPetscData(const PetscData &petsc_data)
Copy PETSc data from another instance.
Mat A
PETSc Jacobian matrix.
keeps basic data about problem
Data structure for SNES (nonlinear solver) context.
SNESContext
Context enumeration for SNES solver phases.
@ CTX_SNESSETJACOBIAN
Setting up Jacobian matrix computation.
@ CTX_SNESSETFUNCTION
Setting up nonlinear function evaluation.
@ CTX_SNESNONE
No specific SNES context.
MoFEMErrorCode copySnes(const SnesMethod &snes)
Copy SNES data from another instance.
Vec & snes_f
Reference to residual vector.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
Vec & snes_x
Reference to current solution state vector.
SnesMethod()
Default constructor.
virtual ~SnesMethod()=default
Virtual destructor.
Vec & snes_dx
Reference to solution update/increment vector.
Mat & snes_B
Reference to preconditioner of Jacobian matrix.
SNESContext snes_ctx
Current SNES computation context.
Mat & snes_A
Reference to Jacobian matrix.
SNES snes
PETSc SNES nonlinear solver object.
Data structure for TS (time stepping) context.
TS ts
PETSc time stepping solver object.
TSContext
Context enumeration for TS solver phases.
@ CTX_TSSETIFUNCTION
Setting up implicit function.
@ CTX_TSSETRHSFUNCTION
Setting up right-hand side function.
@ CTX_TSSETRHSJACOBIAN
Setting up right-hand side Jacobian.
@ CTX_TSTSMONITORSET
Setting up time step monitoring.
@ CTX_TSSETIJACOBIAN
Setting up implicit Jacobian.
@ CTX_TSNONE
No specific TS context.
TSMethod()
Default constructor.
PetscReal ts_t
Current time value.
Mat & ts_A
Reference to Jacobian matrix: dF/dU + a*dF/dU_t + aa*dF/dU_tt.
Vec & ts_F
Reference to residual vector F(t,U,U_t,U_tt)
PetscReal ts_dt
Current time step size.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
Vec & ts_u_tt
Reference to second time derivative of state vector d²U/dt²
TSContext ts_ctx
Current TS computation context.
PetscReal ts_a
Shift parameter for U_t (see PETSc Time Solver documentation)
Vec & ts_u_t
Reference to first time derivative of state vector dU/dt.
PetscInt ts_step
Current time step number.
Vec & ts_u
Reference to current state vector U(t)
virtual ~TSMethod()=default
Virtual destructor.
PetscReal ts_aa
Shift parameter for U_tt (second time derivative)
MoFEMErrorCode copyTs(const TSMethod &ts)
Copy TS solver data from another instance.
Mat & ts_B
Reference to preconditioner matrix for ts_A.
Data structure for TAO (optimization) context.
Mat & tao_B
Reference to preconditioner matrix for Hessian.
TAOContext tao_ctx
Current TAO computation context.
virtual ~TaoMethod()=default
Virtual destructor.
Tao tao
PETSc TAO optimization solver object.
Mat & tao_A
Reference to Hessian matrix.
TaoMethod()
Default constructor.
TAOContext
Context enumeration for TAO solver phases.
@ CTX_TAO_HESSIAN
Assembling Hessian matrix.
@ CTX_TAO_NONE
No specific TAO context.
@ CTX_TAO_GRADIENT
Computing gradient vector.
@ CTX_TAO_OBJECTIVE
Evaluating objective function.
MoFEMErrorCode copyTao(const TaoMethod &tao)
Copy TAO data from another instance.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Query interface for type casting.
Vec & tao_x
Reference to optimization variables vector.
Vec & tao_f
Reference to gradient vector.
base class for all interface classes