v0.16.3
Loading...
Searching...
No Matches
TaoCtx.cpp
Go to the documentation of this file.
1/**
2 * @brief Context for Tao optimization routines
3 * @author Anonymous author(s) committing under MIT license
4 */
5
6namespace MoFEM {
7
8namespace {
9
10PetscErrorCode zeroTaoOutputVector(Vec v) {
12 Vec local = PETSC_NULLPTR;
13 CHKERR VecGhostGetLocalForm(v, &local);
14 if (local) {
15 CHKERR VecZeroEntries(local);
16 CHKERR VecGhostRestoreLocalForm(v, &local);
17 } else {
18 CHKERR VecZeroEntries(v);
19 }
21}
22
23PetscErrorCode assembleTaoOutputVector(Vec v) {
25 Vec local = PETSC_NULLPTR;
26 CHKERR VecGhostGetLocalForm(v, &local);
27 const bool has_local_form = local != PETSC_NULLPTR;
28 if (local)
29 CHKERR VecGhostRestoreLocalForm(v, &local);
30 if (has_local_form) {
31 CHKERR VecGhostUpdateBegin(v, ADD_VALUES, SCATTER_REVERSE);
32 CHKERR VecGhostUpdateEnd(v, ADD_VALUES, SCATTER_REVERSE);
33 }
34 CHKERR VecAssemblyBegin(v);
35 CHKERR VecAssemblyEnd(v);
37}
38
39} // namespace
40
66
92
94 Tao tao, Vec x, Vec c, FEMethodsSequence &loops,
95 BasicMethodsSequence &pre_process, BasicMethodsSequence &post_process,
96 TaoMethod::TAOContext evaluation_context, PetscLogEvent log_event) {
98 PetscLogEventBegin(log_event, 0, 0, 0, 0);
99
100 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
101 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
102 CHKERR mField.getInterface<VecManager>()->setLocalGhostVector(
103 problemName, COL, x, INSERT_VALUES, SCATTER_REVERSE);
104 CHKERR zeroTaoOutputVector(c);
105
106 vecAssembleSwitch = boost::movelib::make_unique<bool>(true);
107 auto cache_ptr = boost::make_shared<CacheTuple>();
109
110 auto set = [&](auto &fe) {
111 fe.tao = tao;
112 fe.tao_x = x;
113 fe.tao_c = c;
115 fe.ksp_ctx = KspMethod::CTX_SETFUNCTION;
116 fe.tao_ctx = evaluation_context;
118 fe.cacheWeakPtr = cache_ptr;
119 };
120
121 auto unset = [&](auto &fe) {
122 fe.snes_ctx = SnesMethod::CTX_SNESNONE;
123 fe.ksp_ctx = KspMethod::CTX_KSPNONE;
124 fe.tao_ctx = TaoMethod::CTX_TAO_NONE;
125 fe.data_ctx = PetscData::CtxSetNone;
126 };
127
128 for (auto &method : pre_process) {
129 method->vecAssembleSwitch = boost::move(vecAssembleSwitch);
130 set(*method);
132 unset(*method);
133 vecAssembleSwitch = boost::move(method->vecAssembleSwitch);
134 }
135
136 for (auto &loop : loops) {
137 loop.second->vecAssembleSwitch = boost::move(vecAssembleSwitch);
138 set(*loop.second);
139 CHKERR mField.loop_finite_elements(problemName, loop.first, *loop.second,
140 nullptr, MF_EXIST, cache_ptr);
141 unset(*loop.second);
142 vecAssembleSwitch = boost::move(loop.second->vecAssembleSwitch);
143 }
144
145 for (auto &method : post_process) {
146 method->vecAssembleSwitch = boost::move(vecAssembleSwitch);
147 set(*method);
149 unset(*method);
150 vecAssembleSwitch = boost::move(method->vecAssembleSwitch);
151 }
152
154 CHKERR assembleTaoOutputVector(c);
155
156 PetscLogEventEnd(log_event, 0, 0, 0, 0);
158}
159
161 Tao tao, Vec x, Mat J, Mat Jpre, FEMethodsSequence &loops,
162 BasicMethodsSequence &pre_process, BasicMethodsSequence &post_process,
163 TaoMethod::TAOContext evaluation_context, PetscLogEvent log_event) {
165 PetscLogEventBegin(log_event, 0, 0, 0, 0);
166
167 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
168 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
169 CHKERR mField.getInterface<VecManager>()->setLocalGhostVector(
170 problemName, COL, x, INSERT_VALUES, SCATTER_REVERSE);
171
172 matAssembleSwitch = boost::movelib::make_unique<bool>(true);
173 CHKERR MatZeroEntries(Jpre);
174 if (J != Jpre)
175 CHKERR MatZeroEntries(J);
176
177 auto cache_ptr = boost::make_shared<CacheTuple>();
179
180 auto set = [&](auto &fe) {
181 fe.tao = tao;
182 fe.tao_x = x;
183 fe.tao_J = J;
184 fe.tao_Jpre = Jpre;
185 fe.ksp_ctx = KspMethod::CTX_OPERATORS;
187 fe.tao_ctx = evaluation_context;
189 fe.cacheWeakPtr = cache_ptr;
190 };
191
192 auto unset = [&](auto &fe) {
193 fe.snes_ctx = SnesMethod::CTX_SNESNONE;
194 fe.ksp_ctx = KspMethod::CTX_KSPNONE;
195 fe.tao_ctx = TaoMethod::CTX_TAO_NONE;
196 fe.data_ctx = PetscData::CtxSetNone;
197 };
198
199 for (auto &method : pre_process) {
200 method->matAssembleSwitch = boost::move(matAssembleSwitch);
201 set(*method);
203 unset(*method);
204 matAssembleSwitch = boost::move(method->matAssembleSwitch);
205 }
206
207 for (auto &loop : loops) {
208 loop.second->matAssembleSwitch = boost::move(matAssembleSwitch);
209 set(*loop.second);
210 CHKERR mField.loop_finite_elements(problemName, loop.first, *loop.second,
211 nullptr, MF_EXIST, cache_ptr);
212 unset(*loop.second);
213 matAssembleSwitch = boost::move(loop.second->matAssembleSwitch);
214 }
215
216 for (auto &method : post_process) {
217 method->matAssembleSwitch = boost::move(matAssembleSwitch);
218 set(*method);
220 unset(*method);
221 matAssembleSwitch = boost::move(method->matAssembleSwitch);
222 }
223
224 if (*matAssembleSwitch) {
225 CHKERR MatAssemblyBegin(Jpre, MAT_FINAL_ASSEMBLY);
226 CHKERR MatAssemblyEnd(Jpre, MAT_FINAL_ASSEMBLY);
227 if (J != Jpre) {
228 CHKERR MatAssemblyBegin(J, MAT_FINAL_ASSEMBLY);
229 CHKERR MatAssemblyEnd(J, MAT_FINAL_ASSEMBLY);
230 }
231 }
232
233 PetscLogEventEnd(log_event, 0, 0, 0, 0);
235}
236
237PetscErrorCode TaoSetObjective(Tao tao, Vec x, PetscReal *f, void *ctx) {
238 auto *tao_ctx = static_cast<TaoCtx *>(ctx);
240 if (tao_ctx->objectiveHook) {
241 CHKERR tao_ctx->objectiveHook(tao, x, f);
243 }
244 PetscLogEventBegin(tao_ctx->MOFEM_EVENT_TaoObjective, 0, 0, 0, 0);
245 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
246 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
247 CHKERR tao_ctx->mField.getInterface<VecManager>()->setLocalGhostVector(
248 tao_ctx->problemName, COL, x, INSERT_VALUES, SCATTER_REVERSE);
249
250 auto cache_ptr = boost::make_shared<CacheTuple>();
251 CHKERR tao_ctx->mField.cache_problem_entities(tao_ctx->problemName,
252 cache_ptr);
253
254 auto set = [&](auto &fe) {
255 fe.tao = tao;
256 fe.tao_x = x;
257 fe.tao_ctx = TaoMethod::CTX_TAO_OBJECTIVE;
258 fe.data_ctx = PetscData::CtxSetX;
259 fe.cacheWeakPtr = cache_ptr;
260 };
261
262 auto unset = [&](auto &fe) {
263 fe.tao_ctx = TaoMethod::CTX_TAO_NONE;
264 fe.data_ctx = PetscData::CtxSetNone;
265 };
266
267 for (auto &bit : tao_ctx->preObjective) {
268 bit->vecAssembleSwitch = boost::move(tao_ctx->vecAssembleSwitch);
269 set(*bit);
270 CHKERR tao_ctx->mField.problem_basic_method_preProcess(tao_ctx->problemName,
271 *bit);
272 unset(*bit);
273 }
274
275 for (auto &lit : tao_ctx->loopsObjective) {
276 set(*lit.second);
277 CHKERR tao_ctx->mField.loop_finite_elements(tao_ctx->problemName, lit.first,
278 *lit.second, nullptr, MF_EXIST,
279 cache_ptr);
280 unset(*lit.second);
281 }
282
283 for (auto &bit : tao_ctx->postObjective) {
284 bit->vecAssembleSwitch = boost::move(tao_ctx->vecAssembleSwitch);
285 set(*bit);
286 CHKERR tao_ctx->mField.problem_basic_method_postProcess(
287 tao_ctx->problemName, *bit);
288 unset(*bit);
289 tao_ctx->vecAssembleSwitch = boost::move(bit->vecAssembleSwitch);
290 }
291
292 PetscLogEventEnd(tao_ctx->MOFEM_EVENT_TaoObjective, 0, 0, 0, 0);
294}
295
296PetscErrorCode TaoSetGradient(Tao tao, Vec x, Vec f, void *ctx) {
297 auto *tao_ctx = static_cast<TaoCtx *>(ctx);
299 if (tao_ctx->gradientHook) {
300 CHKERR tao_ctx->gradientHook(tao, x, f);
302 }
303 PetscLogEventBegin(tao_ctx->MOFEM_EVENT_TaoGradient, 0, 0, 0, 0);
304 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
305 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
306 CHKERR tao_ctx->mField.getInterface<VecManager>()->setLocalGhostVector(
307 tao_ctx->problemName, COL, x, INSERT_VALUES, SCATTER_REVERSE);
308
309 auto zero_ghost_vec = [](Vec g) {
311 Vec l;
312 CHKERR VecGhostGetLocalForm(g, &l);
313 double *a;
314 CHKERR VecGetArray(l, &a);
315 int s;
316 CHKERR VecGetLocalSize(l, &s);
317 for (int i = 0; i != s; ++i)
318 a[i] = 0;
319 CHKERR VecRestoreArray(l, &a);
320 CHKERR VecGhostRestoreLocalForm(g, &l);
322 };
323 CHKERR zero_ghost_vec(f);
324
325 tao_ctx->vecAssembleSwitch = boost::movelib::make_unique<bool>(true);
326 auto cache_ptr = boost::make_shared<CacheTuple>();
327 CHKERR tao_ctx->mField.cache_problem_entities(tao_ctx->problemName,
328 cache_ptr);
329
330 auto set = [&](auto &fe) {
331 fe.tao = tao;
332 fe.tao_x = x;
333 fe.tao_f = f;
335 fe.ksp_ctx = KspMethod::CTX_SETFUNCTION;
336 fe.tao_ctx = TaoMethod::CTX_TAO_GRADIENT;
338 fe.cacheWeakPtr = cache_ptr;
339 };
340
341 auto unset = [&](auto &fe) {
342 fe.snes_ctx = SnesMethod::CTX_SNESNONE;
343 fe.ksp_ctx = KspMethod::CTX_KSPNONE;
344 fe.tao_ctx = TaoMethod::CTX_TAO_NONE;
345 fe.data_ctx = PetscData::CtxSetNone;
346 };
347
348 for (auto &bit : tao_ctx->preGradient) {
349 bit->vecAssembleSwitch = boost::move(tao_ctx->vecAssembleSwitch);
350 set(*bit);
351 CHKERR tao_ctx->mField.problem_basic_method_preProcess(tao_ctx->problemName,
352 *bit);
353 unset(*bit);
354 tao_ctx->vecAssembleSwitch = boost::move(bit->vecAssembleSwitch);
355 }
356
357 for (auto &lit : tao_ctx->loopsGradient) {
358 lit.second->vecAssembleSwitch = boost::move(tao_ctx->vecAssembleSwitch);
359 set(*lit.second);
360 CHKERR tao_ctx->mField.loop_finite_elements(tao_ctx->problemName, lit.first,
361 *lit.second, nullptr, MF_EXIST,
362 cache_ptr);
363 unset(*lit.second);
364 tao_ctx->vecAssembleSwitch = boost::move(lit.second->vecAssembleSwitch);
365 }
366
367 for (auto &bit : tao_ctx->postGradient) {
368 bit->vecAssembleSwitch = boost::move(tao_ctx->vecAssembleSwitch);
369 set(*bit);
370 CHKERR tao_ctx->mField.problem_basic_method_postProcess(
371 tao_ctx->problemName, *bit);
372 unset(*bit);
373 tao_ctx->vecAssembleSwitch = boost::move(bit->vecAssembleSwitch);
374 }
375
376 if (*(tao_ctx->vecAssembleSwitch)) {
377 CHKERR VecGhostUpdateBegin(f, ADD_VALUES, SCATTER_REVERSE);
378 CHKERR VecGhostUpdateEnd(f, ADD_VALUES, SCATTER_REVERSE);
379 CHKERR VecAssemblyBegin(f);
380 CHKERR VecAssemblyEnd(f);
381 }
382 PetscLogEventEnd(tao_ctx->MOFEM_EVENT_TaoGradient, 0, 0, 0, 0);
384}
385
386PetscErrorCode TaoSetObjectiveAndGradient(Tao tao, Vec x, PetscReal *f, Vec g,
387 void *ctx) {
389 TaoCtx *tao_ctx = (TaoCtx *)ctx;
390 if (tao_ctx->objectiveAndGradientHook) {
391 CHKERR tao_ctx->objectiveAndGradientHook(tao, x, f, g);
393 }
394 CHKERR TaoSetObjective(tao, x, f, ctx);
395 CHKERR TaoSetGradient(tao, x, g, ctx);
397}
398
399PetscErrorCode TaoSetHessian(Tao tao, Vec x, Mat H, Mat Hpre, void *ctx) {
400 TaoCtx *tao_ctx = (TaoCtx *)ctx;
402 PetscLogEventBegin(tao_ctx->MOFEM_EVENT_TaoHessian, 0, 0, 0, 0);
403
404 tao_ctx->matAssembleSwitch = boost::movelib::make_unique<bool>(true);
405 auto cache_ptr = boost::make_shared<CacheTuple>();
407 cache_ptr);
408
409 auto set = [&](auto &fe) {
410 fe.tao = tao;
411 fe.tao_A = H;
412 fe.tao_B = Hpre;
413 fe.ksp_ctx = KspMethod::CTX_OPERATORS;
415 fe.tao_ctx = TaoMethod::CTX_TAO_HESSIAN;
417 fe.cacheWeakPtr = cache_ptr;
418 };
419
420 auto unset = [&](auto &fe) {
421 fe.snes_ctx = SnesMethod::CTX_SNESNONE;
422 fe.ksp_ctx = KspMethod::CTX_KSPNONE;
423 fe.tao_ctx = TaoMethod::CTX_TAO_NONE;
424 fe.data_ctx = PetscData::CtxSetNone;
425 };
426
427 CHKERR VecGhostUpdateBegin(x, INSERT_VALUES, SCATTER_FORWARD);
428 CHKERR VecGhostUpdateEnd(x, INSERT_VALUES, SCATTER_FORWARD);
429 CHKERR tao_ctx->mField.getInterface<VecManager>()->setLocalGhostVector(
430 tao_ctx->problemName, COL, x, INSERT_VALUES, SCATTER_REVERSE);
431
432 for (auto &bit : tao_ctx->preHessian) {
433 bit->matAssembleSwitch = boost::move(tao_ctx->matAssembleSwitch);
434 set(*bit);
436 *bit);
437 unset(*bit);
438 tao_ctx->matAssembleSwitch = boost::move(bit->matAssembleSwitch);
439 }
440
441 for (auto &lit : tao_ctx->loopsHessian) {
442 lit.second->matAssembleSwitch = boost::move(tao_ctx->matAssembleSwitch);
443 set(*lit.second);
444 CHKERR tao_ctx->mField.loop_finite_elements(tao_ctx->problemName, lit.first,
445 *(lit.second), nullptr,
446 MF_EXIST, cache_ptr);
447 unset(*lit.second);
448 tao_ctx->matAssembleSwitch = boost::move(lit.second->matAssembleSwitch);
449 }
450
451 for (auto &bit : tao_ctx->postHessian) {
452 bit->matAssembleSwitch = boost::move(tao_ctx->matAssembleSwitch);
453 set(*bit);
455 tao_ctx->problemName, *bit);
456 unset(*bit);
457 tao_ctx->matAssembleSwitch = boost::move(bit->matAssembleSwitch);
458 }
459
460 if (*tao_ctx->matAssembleSwitch) {
461 CHKERR MatAssemblyBegin(Hpre, MAT_FINAL_ASSEMBLY);
462 CHKERR MatAssemblyEnd(Hpre, MAT_FINAL_ASSEMBLY);
463 }
464 PetscLogEventEnd(tao_ctx->MOFEM_EVENT_TaoHessian, 0, 0, 0, 0);
466}
467
468PetscErrorCode TaoSetEqualityConstraints(Tao tao, Vec x, Vec c, void *ctx) {
470 auto *tao_ctx = static_cast<TaoCtx *>(ctx);
471 CHKERR tao_ctx->evaluateConstraint(
472 tao, x, c, tao_ctx->loopsEqualityConstraint,
473 tao_ctx->preEqualityConstraint, tao_ctx->postEqualityConstraint,
475 tao_ctx->MOFEM_EVENT_TaoEqualityConstraint);
477}
478
479PetscErrorCode TaoSetInequalityConstraints(Tao tao, Vec x, Vec c, void *ctx) {
481 auto *tao_ctx = static_cast<TaoCtx *>(ctx);
482 CHKERR tao_ctx->evaluateConstraint(
483 tao, x, c, tao_ctx->loopsInequalityConstraint,
484 tao_ctx->preInequalityConstraint, tao_ctx->postInequalityConstraint,
486 tao_ctx->MOFEM_EVENT_TaoInequalityConstraint);
488}
489
490PetscErrorCode TaoSetJacobianEquality(Tao tao, Vec x, Mat J, Mat Jpre,
491 void *ctx) {
493 auto *tao_ctx = static_cast<TaoCtx *>(ctx);
495 tao, x, J, Jpre, tao_ctx->loopsEqualityJacobian,
496 tao_ctx->preEqualityJacobian, tao_ctx->postEqualityJacobian,
498 tao_ctx->MOFEM_EVENT_TaoEqualityJacobian);
500}
501
502PetscErrorCode TaoSetJacobianInequality(Tao tao, Vec x, Mat J, Mat Jpre,
503 void *ctx) {
505 auto *tao_ctx = static_cast<TaoCtx *>(ctx);
507 tao, x, J, Jpre, tao_ctx->loopsInequalityJacobian,
508 tao_ctx->preInequalityJacobian, tao_ctx->postInequalityJacobian,
510 tao_ctx->MOFEM_EVENT_TaoInequalityJacobian);
512}
513
514} // namespace MoFEM
constexpr double a
@ COL
@ MF_EXIST
#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 MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
virtual MoFEMErrorCode problem_basic_method_postProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
auto bit
set bit
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
const double v
phase velocity of light in medium (cm/ns)
FTensor::Index< 'J', DIM1 > J
Definition level_set.cpp:30
FTensor::Index< 'l', 3 > l
const FTensor::Tensor2< T, Dim, Dim > Vec
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
PetscErrorCode TaoSetObjective(Tao tao, Vec x, PetscReal *f, void *ctx)
Sets the objective function value for a TAO optimization context.
Definition TaoCtx.cpp:237
PetscErrorCode TaoSetJacobianInequality(Tao tao, Vec x, Mat J, Mat Jpre, void *ctx)
Assemble the inequality constraint Jacobian.
Definition TaoCtx.cpp:502
PetscErrorCode TaoSetEqualityConstraints(Tao tao, Vec x, Vec c, void *ctx)
Evaluate equality constraints for a TAO optimization context.
Definition TaoCtx.cpp:468
PetscErrorCode TaoSetInequalityConstraints(Tao tao, Vec x, Vec c, void *ctx)
Evaluate inequality constraints for a TAO optimization context.
Definition TaoCtx.cpp:479
PetscErrorCode TaoSetJacobianEquality(Tao tao, Vec x, Mat J, Mat Jpre, void *ctx)
Assemble the equality constraint Jacobian.
Definition TaoCtx.cpp:490
PetscErrorCode TaoSetObjectiveAndGradient(Tao tao, Vec x, PetscReal *f, Vec g, void *ctx)
Sets the objective function value and gradient for a TAO optimization solver.
Definition TaoCtx.cpp:386
PetscErrorCode TaoSetGradient(Tao tao, Vec x, Vec f, void *ctx)
Sets the gradient vector for a TAO optimization context.
Definition TaoCtx.cpp:296
PetscErrorCode TaoSetHessian(Tao tao, Vec x, Mat H, Mat Hpre, void *ctx)
Sets the Hessian matrix for a TAO optimization context.
Definition TaoCtx.cpp:399
double H
Hardening.
Definition plastic.cpp:129
constexpr double g
virtual MoFEMErrorCode cache_problem_entities(const std::string prb_name, CacheTupleWeakPtr cache_ptr)=0
Cache variables.
virtual MoFEMErrorCode problem_basic_method_preProcess(const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)=0
Set data for BasicMethod.
@ CTX_KSPNONE
No specific KSP context.
@ CTX_SETFUNCTION
Setting up the linear system function.
@ CTX_OPERATORS
Setting up linear operators.
static constexpr Switches CtxSetA
Jacobian matrix switch.
static constexpr Switches CtxSetX
Solution vector switch.
static constexpr Switches CtxSetNone
No data switch.
static constexpr Switches CtxSetF
Residual vector switch.
static constexpr Switches CtxSetB
Preconditioner matrix switch.
@ CTX_SNESSETJACOBIAN
Setting up Jacobian matrix computation.
@ CTX_SNESSETFUNCTION
Setting up nonlinear function evaluation.
@ CTX_SNESNONE
No specific SNES context.
Interface for TAO solvers.
Definition TaoCtx.hpp:14
MoFEMErrorCode copyLoops(const TaoCtx &tao_ctx)
Copy sequences from another TaoCtx.
Definition TaoCtx.cpp:41
FEMethodsSequence loopsInequalityJacobian
Definition TaoCtx.hpp:49
boost::movelib::unique_ptr< bool > vecAssembleSwitch
Definition TaoCtx.hpp:256
MoFEM::FEMethodsSequence FEMethodsSequence
Definition TaoCtx.hpp:22
MoFEM::Interface & mField
database Interface
Definition TaoCtx.hpp:16
BasicMethodsSequence postInequalityConstraint
Definition TaoCtx.hpp:77
PetscErrorCode evaluateConstraint(Tao tao, Vec x, Vec c, FEMethodsSequence &loops, BasicMethodsSequence &pre_process, BasicMethodsSequence &post_process, TaoMethod::TAOContext evaluation_context, PetscLogEvent log_event)
Definition TaoCtx.cpp:93
BasicMethodsSequence preEqualityJacobian
Definition TaoCtx.hpp:80
BasicMethodsSequence postObjective
Sequence of methods run after objective is evaluated.
Definition TaoCtx.hpp:61
BasicMethodsSequence preEqualityConstraint
Definition TaoCtx.hpp:68
std::string problemName
problem name
Definition TaoCtx.hpp:18
BasicMethodsSequence preInequalityConstraint
Definition TaoCtx.hpp:74
BasicMethodsSequence postEqualityConstraint
Definition TaoCtx.hpp:71
BasicMethodsSequence postGradient
Sequence of methods run after gradient is assembled.
Definition TaoCtx.hpp:66
PetscLogEvent MOFEM_EVENT_TaoHessian
Log event for TAO Hessian.
Definition TaoCtx.hpp:258
PetscErrorCode evaluateConstraintJacobian(Tao tao, Vec x, Mat J, Mat Jpre, FEMethodsSequence &loops, BasicMethodsSequence &pre_process, BasicMethodsSequence &post_process, TaoMethod::TAOContext evaluation_context, PetscLogEvent log_event)
Definition TaoCtx.cpp:160
boost::movelib::unique_ptr< bool > matAssembleSwitch
Definition TaoCtx.hpp:257
FEMethodsSequence loopsInequalityConstraint
Definition TaoCtx.hpp:43
BasicMethodsSequence preObjective
Sequence of methods run before objective is evaluated.
Definition TaoCtx.hpp:59
FEMethodsSequence loopsObjective
Definition TaoCtx.hpp:35
BasicMethodsSequence preGradient
Sequence of methods run before gradient is assembled.
Definition TaoCtx.hpp:64
GradientHook gradientHook
Definition TaoCtx.hpp:254
BasicMethodsSequence postEqualityJacobian
Definition TaoCtx.hpp:83
FEMethodsSequence loopsEqualityConstraint
Definition TaoCtx.hpp:40
ObjectiveAndGradientHook objectiveAndGradientHook
Definition TaoCtx.hpp:255
MoFEMErrorCode clearLoops()
Clear loops.
Definition TaoCtx.cpp:67
BasicMethodsSequence preInequalityJacobian
Definition TaoCtx.hpp:86
BasicMethodsSequence postHessian
Sequence of methods run after Hessian is assembled.
Definition TaoCtx.hpp:56
ObjectiveHook objectiveHook
Definition TaoCtx.hpp:253
BasicMethodsSequence preHessian
Sequence of methods run before Hessian is assembled.
Definition TaoCtx.hpp:54
FEMethodsSequence loopsEqualityJacobian
Definition TaoCtx.hpp:46
BasicMethodsSequence postInequalityJacobian
Definition TaoCtx.hpp:89
FEMethodsSequence loopsGradient
Definition TaoCtx.hpp:38
MoFEM::BasicMethodsSequence BasicMethodsSequence
Definition TaoCtx.hpp:23
FEMethodsSequence loopsHessian
Definition TaoCtx.hpp:32
TAOContext
Context enumeration for TAO solver phases.
@ CTX_TAO_EQUALITY_CONSTRAINT
Evaluating equality constraints.
@ CTX_TAO_EQUALITY_JACOBIAN
Assembling equality Jacobian.
@ CTX_TAO_HESSIAN
Assembling Hessian matrix.
@ CTX_TAO_NONE
No specific TAO context.
@ CTX_TAO_INEQUALITY_JACOBIAN
Assembling inequality Jacobian.
@ CTX_TAO_INEQUALITY_CONSTRAINT
Evaluating inequality constraints.
@ CTX_TAO_GRADIENT
Computing gradient vector.
@ CTX_TAO_OBJECTIVE
Evaluating objective function.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Vector manager is used to create vectors \mofem_vectors.