6 : mField(m_field), moab(m_field.get_moab()), problemName(problem_name),
17 auto core_log = logging::core::get();
61 CHKERR VecGhostUpdateBegin(u, INSERT_VALUES, SCATTER_FORWARD);
62 CHKERR VecGhostUpdateEnd(u, INSERT_VALUES, SCATTER_FORWARD);
63 CHKERR VecGhostUpdateBegin(u_t, INSERT_VALUES, SCATTER_FORWARD);
64 CHKERR VecGhostUpdateEnd(u_t, INSERT_VALUES, SCATTER_FORWARD);
68 auto zero_ghost_vec = [](
Vec g) {
76 for (
int i = 0;
i != s; ++
i)
79 CHKERR VecGhostRestoreLocalForm(
g, &
l);
87 #if PETSC_VERSION_GE(3, 8, 0)
88 CHKERR TSGetStepNumber(ts, &step);
90 CHKERR TSGetTimeStepNumber(ts, &step);
93 auto cache_ptr = boost::make_shared<CacheTuple>();
96 auto set = [&](
auto &fe) {
109 CHKERR TSGetSNES(ts, &fe.snes);
110 CHKERR SNESGetKSP(fe.snes, &fe.ksp);
112 fe.cacheWeakPtr = cache_ptr;
116 auto unset = [&](
auto &fe) {
138 *(lit.second),
nullptr,
155 CHKERR VecGhostUpdateBegin(
F, ADD_VALUES, SCATTER_REVERSE);
156 CHKERR VecGhostUpdateEnd(
F, ADD_VALUES, SCATTER_REVERSE);
166 Mat
A, Mat B,
void *ctx) {
171 CHKERR VecGhostUpdateBegin(u, INSERT_VALUES, SCATTER_FORWARD);
172 CHKERR VecGhostUpdateEnd(u, INSERT_VALUES, SCATTER_FORWARD);
173 CHKERR VecGhostUpdateBegin(u_t, INSERT_VALUES, SCATTER_FORWARD);
174 CHKERR VecGhostUpdateEnd(u_t, INSERT_VALUES, SCATTER_FORWARD);
181 #if PETSC_VERSION_GE(3, 8, 0)
182 CHKERR TSGetStepNumber(ts, &step);
184 CHKERR TSGetTimeStepNumber(ts, &step);
189 auto cache_ptr = boost::make_shared<CacheTuple>();
192 auto set = [&](
auto &fe) {
207 CHKERR TSGetSNES(ts, &fe.snes);
208 CHKERR SNESGetKSP(fe.snes, &fe.ksp);
210 fe.cacheWeakPtr = cache_ptr;
214 auto unset = [&](
auto &fe) {
235 *(lit.second),
nullptr,
252 CHKERR MatAssemblyBegin(B, MAT_FINAL_ASSEMBLY);
253 CHKERR MatAssemblyEnd(B, MAT_FINAL_ASSEMBLY);
264 CHKERR VecGhostUpdateBegin(u, INSERT_VALUES, SCATTER_FORWARD);
265 CHKERR VecGhostUpdateEnd(u, INSERT_VALUES, SCATTER_FORWARD);
269 auto cache_ptr = boost::make_shared<CacheTuple>();
272 auto set = [&](
auto &fe) {
277 fe.ts_F = PETSC_NULL;
283 CHKERR TSGetSNES(ts, &fe.snes);
284 CHKERR SNESGetKSP(fe.snes, &fe.ksp);
286 fe.cacheWeakPtr = cache_ptr;
290 auto unset = [&](
auto &fe) {
306 *(lit.second),
nullptr,
327 CHKERR VecGhostUpdateBegin(u, INSERT_VALUES, SCATTER_FORWARD);
328 CHKERR VecGhostUpdateEnd(u, INSERT_VALUES, SCATTER_FORWARD);
332 auto zero_ghost_vec = [](
Vec g) {
340 for (
int i = 0;
i != s; ++
i)
343 CHKERR VecGhostRestoreLocalForm(
g, &
l);
349 auto cache_ptr = boost::make_shared<CacheTuple>();
353 #if PETSC_VERSION_GE(3, 8, 0)
354 CHKERR TSGetStepNumber(ts, &step);
356 CHKERR TSGetTimeStepNumber(ts, &step);
359 auto set = [&](
auto &fe) {
370 fe.cacheWeakPtr = cache_ptr;
374 auto unset = [&](
auto &fe) {
395 *(lit.second),
nullptr,
412 CHKERR VecGhostUpdateBegin(
F, ADD_VALUES, SCATTER_REVERSE);
413 CHKERR VecGhostUpdateEnd(
F, ADD_VALUES, SCATTER_REVERSE);
427 CHKERR VecGhostUpdateBegin(u, INSERT_VALUES, SCATTER_FORWARD);
428 CHKERR VecGhostUpdateEnd(u, INSERT_VALUES, SCATTER_FORWARD);
438 auto cache_ptr = boost::make_shared<CacheTuple>();
442 #if PETSC_VERSION_GE(3, 8, 0)
443 CHKERR TSGetStepNumber(ts, &step);
445 CHKERR TSGetTimeStepNumber(ts, &step);
448 auto set = [&](
auto &fe) {
460 fe.cacheWeakPtr = cache_ptr;
464 auto unset = [&](
auto &fe) {
486 *(lit.second),
nullptr,
503 CHKERR MatAssemblyBegin(B, MAT_FINAL_ASSEMBLY);
504 CHKERR MatAssemblyEnd(B, MAT_FINAL_ASSEMBLY);
512 PetscReal
a, PetscReal aa, Mat
A, Mat B,
518 CHKERR VecGhostUpdateBegin(u, INSERT_VALUES, SCATTER_FORWARD);
519 CHKERR VecGhostUpdateEnd(u, INSERT_VALUES, SCATTER_FORWARD);
520 CHKERR VecGhostUpdateBegin(u_t, INSERT_VALUES, SCATTER_FORWARD);
521 CHKERR VecGhostUpdateEnd(u_t, INSERT_VALUES, SCATTER_FORWARD);
522 CHKERR VecGhostUpdateBegin(u_tt, INSERT_VALUES, SCATTER_FORWARD);
523 CHKERR VecGhostUpdateEnd(u_tt, INSERT_VALUES, SCATTER_FORWARD);
530 #if PETSC_VERSION_GE(3, 8, 0)
531 CHKERR TSGetStepNumber(ts, &step);
533 CHKERR TSGetTimeStepNumber(ts, &step);
538 auto cache_ptr = boost::make_shared<CacheTuple>();
541 auto set = [&](
auto &fe) {
559 CHKERR TSGetSNES(ts, &fe.snes);
560 CHKERR SNESGetKSP(fe.snes, &fe.ksp);
563 fe.cacheWeakPtr = cache_ptr;
567 auto unset = [&](
auto &fe) {
588 *(lit.second),
nullptr,
605 CHKERR MatAssemblyBegin(B, MAT_FINAL_ASSEMBLY);
606 CHKERR MatAssemblyEnd(B, MAT_FINAL_ASSEMBLY);
617 CHKERR VecGhostUpdateBegin(u, INSERT_VALUES, SCATTER_FORWARD);
618 CHKERR VecGhostUpdateEnd(u, INSERT_VALUES, SCATTER_FORWARD);
619 CHKERR VecGhostUpdateBegin(u_t, INSERT_VALUES, SCATTER_FORWARD);
620 CHKERR VecGhostUpdateEnd(u_t, INSERT_VALUES, SCATTER_FORWARD);
621 CHKERR VecGhostUpdateBegin(u_tt, INSERT_VALUES, SCATTER_FORWARD);
622 CHKERR VecGhostUpdateEnd(u_tt, INSERT_VALUES, SCATTER_FORWARD);
626 auto zero_ghost_vec = [](
Vec g) {
634 for (
int i = 0;
i != s; ++
i)
637 CHKERR VecGhostRestoreLocalForm(
g, &
l);
643 auto cache_ptr = boost::make_shared<CacheTuple>();
647 #if PETSC_VERSION_GE(3, 8, 0)
648 CHKERR TSGetStepNumber(ts, &step);
650 CHKERR TSGetTimeStepNumber(ts, &step);
653 auto set = [&](
auto &fe) {
667 CHKERR TSGetSNES(ts, &fe.snes);
668 CHKERR SNESGetKSP(fe.snes, &fe.ksp);
671 fe.cacheWeakPtr = cache_ptr;
675 auto unset = [&](
auto &fe) {
697 *(lit.second),
nullptr,
714 CHKERR VecGhostUpdateBegin(
F, ADD_VALUES, SCATTER_REVERSE);
715 CHKERR VecGhostUpdateEnd(
F, ADD_VALUES, SCATTER_REVERSE);
725 : alpha(0.75), gamma(0.5), desiredIt(6), offApat(PETSC_FALSE) {
733 <<
"TS adaptivity: alpha = " <<
alpha <<
", gamma = " <<
gamma
738 PetscInt *next_sc, PetscReal *next_h,
739 PetscBool *accept, PetscReal *wlte,
740 PetscReal *wltea, PetscReal *wlter) {
743 auto ts_adapt_mofem = boost::make_shared<TSAdaptMoFEM>();
750 *accept = PETSC_TRUE;
753 if (!ts_adapt_mofem->offApat) {
756 CHKERR TSGetSNES(ts, &snes);
758 SNESConvergedReason reason;
759 CHKERR SNESGetConvergedReason(snes, &reason);
762 CHKERR SNESGetIterationNumber(snes, &it);
765 h *= ts_adapt_mofem->alpha;
768 "TSWORLD", Sev::warning,
769 "\tDiverged set step length: it = %d, h = %3.4g set h = %3.4g \n", it,
771 }
else if (reason > 0) {
772 h *= pow((
static_cast<double>(ts_adapt_mofem->desiredIt) /
773 static_cast<double>(it + 1)),
774 static_cast<double>(ts_adapt_mofem->gamma));
775 *next_h = PetscClipInterval(
h, adapt->dt_min, adapt->dt_max);
777 "TSWORLD", Sev::inform,
778 "\tConverged set step length: it = %d, h = %3.4g set h = %3.4g \n",
788 PetscFunctionReturn(0);
802 PetscFunctionReturn(0);