v0.8.23
LoopMethods.cpp
Go to the documentation of this file.
1 /** \file LoopMethods.cpp
2 \brief methods for managing loops
3 */
4 
5 /* MoFEM is free software: you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation, either version 3 of the License, or (at your
8  * option) any later version.
9  *
10  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
17  */
18 
19 namespace MoFEM {
20 
21 // KSP
24  ksp_ctx = ctx;
26 }
29  ksp = ksp_;
31 }
34  this->ksp_ctx = ksp.ksp_ctx;
35  this->ksp = ksp.ksp;
36  this->ksp_f = ksp.ksp_f;
37  this->ksp_A = ksp.ksp_A;
38  this->ksp_B = ksp.ksp_B;
40 }
41 
42 // SNES
45  snes_ctx = ctx;
47 }
50  snes = _snes;
52 }
55  this->snes_ctx = snes.snes_ctx;
56  this->snes = snes.snes;
57  this->snes_x = snes.snes_x;
58  this->snes_f = snes.snes_f;
59  this->snes_A = snes.snes_A;
60  this->snes_B = snes.snes_B;
62 }
63 
64 // TS
67  ts_ctx = ctx;
69 }
72  ts = _ts;
74 }
77  this->ts_ctx = ts.ts_ctx;
78  this->ts = ts.ts;
79  this->ts_u = ts.ts_u;
80  this->ts_u_t = ts.ts_u_t;
81  this->ts_F = ts.ts_F;
82  this->ts_A = ts.ts_A;
83  this->ts_B = ts.ts_B;
84  this->ts_step = ts.ts_step;
85  this->ts_a = ts.ts_a;
86  this->ts_t = ts.ts_t;
88 }
89 
90 // BasicMethod
92  : KspMethod(), SnesMethod(), TSMethod(), nInTheLoop(0), loopSize(0),
93  rAnk(-1), sIze(-1), refinedEntitiesPtr(nullptr),
94  refinedFiniteElementsPtr(nullptr), problemPtr(nullptr),
95  fieldsPtr(nullptr), entitiesPtr(nullptr), dofsPtr(nullptr),
96  finiteElementsPtr(nullptr), finiteElementsEntitiesPtr(nullptr),
97  adjacenciesPtr(nullptr) {}
98 
101 
102  this->nInTheLoop = basic.nInTheLoop;
103  this->loopSize = basic.loopSize;
104  this->rAnk = basic.rAnk;
105  this->sIze = basic.sIze;
108  this->problemPtr = basic.problemPtr;
109  this->fieldsPtr = basic.fieldsPtr;
110  this->entitiesPtr = basic.entitiesPtr;
111  this->dofsPtr = basic.dofsPtr;
112  this->finiteElementsPtr = basic.finiteElementsPtr;
114  this->adjacenciesPtr = basic.adjacenciesPtr;
115 
117 }
118 
121  if (preProcessHook) {
122  ierr = preProcessHook();
123  CHKERRG(ierr);
124  } else {
125  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
126  "should be implemented by user in derived class (preProcess)");
127  }
129 }
132  if (postProcessHook) {
133  ierr = postProcessHook();
134  CHKERRG(ierr);
135  } else {
136  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
137  "should be implemented by user in derived class (postProcess)");
138  }
140 }
143  if (operatorHook) {
144  ierr = operatorHook();
145  CHKERRG(ierr);
146  } else {
147  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
148  "should be implemented by user in derived class (operator)");
149  }
151 }
152 
153 // FEMethod
155 
156 // Entity method
158 
159 // DofMethod
161 
162 } // namespace MoFEM
MoFEMErrorCode copyBasicMethod(const BasicMethod &basic)
Copy data from other base method to this base method.
Definition: LoopMethods.cpp:99
const DofEntity_multiIndex * dofsPtr
raw pointer container of dofs
const FieldEntityEntFiniteElementAdjacencyMap_multiIndex * adjacenciesPtr
KSP ksp
KSP solver.
Definition: LoopMethods.hpp:91
Mat ksp_B
preconditioner matrix
Definition: LoopMethods.hpp:94
const Field_multiIndex * fieldsPtr
raw pointer to fields container
const FiniteElement_multiIndex * finiteElementsPtr
raw pointer to container finite elements
MoFEMErrorCode setSnes(SNES snes)
Set SNES instance.
Definition: LoopMethods.cpp:48
int loopSize
local number oe methods to process
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:500
const FieldEntity_multiIndex * entitiesPtr
raw pointer to container of field entities
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:543
const RefElement_multiIndex * refinedFiniteElementsPtr
container of mofem finite element entities
data structure for snes (nonlinear solver) contextStructure stores context data which are set in func...
int rAnk
processor rank
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:507
virtual MoFEMErrorCode preProcess()
function is run at the beginning of loop
KSPContext ksp_ctx
Context.
Definition: LoopMethods.hpp:90
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
boost::function< MoFEMErrorCode()> postProcessHook
Hook function for post-processing.
const Problem * problemPtr
raw pointer to problem
MoFEMErrorCode copyKsp(const KspMethod &ksp)
copy data form another method
Definition: LoopMethods.cpp:32
virtual MoFEMErrorCode operator()()
function is run for every finite element
virtual MoFEMErrorCode postProcess()
function is run at the end of loop
const RefEntity_multiIndex * refinedEntitiesPtr
container of mofem dof entities
MoFEMErrorCode copyTs(const TSMethod &ts)
Copy TS solver data.
Definition: LoopMethods.cpp:75
MoFEMErrorCode setSnesCtx(const SNESContext &ctx)
Set SNES context.
Definition: LoopMethods.cpp:43
boost::function< MoFEMErrorCode()> operatorHook
Hook function for operator.
int sIze
number of processors in communicator
MoFEMErrorCode setTs(TS _ts)
Set TS solver.
Definition: LoopMethods.cpp:70
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
data structure for ksp (linear solver) contextStruture stores context data which are set in functions...
Definition: LoopMethods.hpp:45
MoFEMErrorCode setKsp(KSP ksp)
set solver
Definition: LoopMethods.cpp:27
KSPContext
pass information about context of KSP/DM for with finite element is computed
Definition: LoopMethods.hpp:61
data structure for TS (time stepping) contextStructure stores context data which are set in functions...
int nInTheLoop
number currently of processed method
MoFEMErrorCode setKspCtx(const KSPContext &ctx)
set operator type
Definition: LoopMethods.cpp:22
MoFEMErrorCode setTsCtx(const TSContext &ctx)
Set Ts context.
Definition: LoopMethods.cpp:65
MoFEMErrorCode copySnes(const SnesMethod &snes)
Copy snes data.
Definition: LoopMethods.cpp:53
SNESContext snes_ctx
const EntFiniteElement_multiIndex * finiteElementsEntitiesPtr
Vec ksp_f
the right hand side vector
Definition: LoopMethods.hpp:92
TSContext ts_ctx
boost::function< MoFEMErrorCode()> preProcessHook
Hook function for pre-processing.
Data structure to exchange data between mofem and User Loop Methods.It allows to exchange data betwee...