Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix upon restart #16

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/JacRes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1930,9 +1930,11 @@ PetscErrorCode JacResCopyPres(JacRes *jr, Vec x)
PetscFunctionReturn(0);
}
//---------------------------------------------------------------------------
PetscErrorCode JacResInitPres(JacRes *jr)
PetscErrorCode JacResInitPres(JacRes *jr,TSSol *ts)

{
FDSTAG *fs;

BCCtx *bc;
SolVarCell *svCell;
const PetscScalar *p;
Expand All @@ -1949,7 +1951,7 @@ PetscErrorCode JacResInitPres(JacRes *jr)
fixPhase = bc->fixPhase;

// check activation
if(!bc->initPres) PetscFunctionReturn(0);
if(!bc->initPres || ts->istep>0) PetscFunctionReturn(0);

// get grid coordinate bounds in z-direction
ierr = FDSTAGGetGlobalBox(fs, NULL, NULL, &bz, NULL, NULL, &ez); CHKERRQ(ierr);
Expand Down Expand Up @@ -1999,7 +2001,7 @@ PetscErrorCode JacResInitPres(JacRes *jr)
PetscFunctionReturn(0);
}
//---------------------------------------------------------------------------
PetscErrorCode JacResInitLithPres(JacRes *jr, AdvCtx *actx)
PetscErrorCode JacResInitLithPres(JacRes *jr, AdvCtx *actx,TSSol *ts)
{
FDSTAG *fs;
SolVarCell *svCell;
Expand All @@ -2015,7 +2017,7 @@ PetscErrorCode JacResInitLithPres(JacRes *jr, AdvCtx *actx)
PetscFunctionBeginUser;

// check activation
if(!jr->ctrl.initLithPres) PetscFunctionReturn(0);
if(!jr->ctrl.initLithPres || ts->istep >0) PetscFunctionReturn(0);

// print
PrintStart(&t, "Initializing pressure with lithostatic pressure", NULL);
Expand Down
4 changes: 2 additions & 2 deletions src/JacRes.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,10 @@ PetscErrorCode JacResCopyVel(JacRes *jr, Vec x);
PetscErrorCode JacResCopyPres(JacRes *jr, Vec x);

// initialize pressure
PetscErrorCode JacResInitPres(JacRes *jr);
PetscErrorCode JacResInitPres(JacRes *jr,TSSol *ts);

// initialize pressure to lithostatic pressure
PetscErrorCode JacResInitLithPres(JacRes *jr, AdvCtx *actx);
PetscErrorCode JacResInitLithPres(JacRes *jr, AdvCtx *actx, TSSol *ts);

// copy residuals from local to global vectors, enforce boundary constraints
PetscErrorCode JacResCopyRes(JacRes *jr, Vec f);
Expand Down
12 changes: 7 additions & 5 deletions src/LaMEMLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ PetscErrorCode LaMEMLibSolve(LaMEMLib *lm, void *param, PetscLogStage stages[4])
PetscCall(PetscLogStagePush(stages[0])); /* Start profiling stage*/

ierr = LaMEMLibInitGuess(lm, snes); CHKERRQ(ierr);

PetscCall(PetscLogStagePop()); /* Stop profiling stage*/

if (param)
Expand Down Expand Up @@ -822,10 +822,10 @@ PetscErrorCode LaMEMLibInitGuess(LaMEMLib *lm, SNES snes)
ierr = LaMEMLibDiffuseTemp(lm); CHKERRQ(ierr);

// initialize pressure
ierr = JacResInitPres(&lm->jr); CHKERRQ(ierr);
ierr = JacResInitPres(&lm->jr,&lm->ts); CHKERRQ(ierr);

// lithostatic pressure initializtaion
ierr = JacResInitLithPres(&lm->jr, &lm->actx); CHKERRQ(ierr);
ierr = JacResInitLithPres(&lm->jr, &lm->actx, &lm->ts); CHKERRQ(ierr);

// compute inverse elastic parameters (dependent on dt)
ierr = JacResGetI2Gdt(&lm->jr); CHKERRQ(ierr);
Expand Down Expand Up @@ -864,6 +864,7 @@ PetscErrorCode LaMEMLibInitGuess(LaMEMLib *lm, SNES snes)
PetscErrorCode LaMEMLibDiffuseTemp(LaMEMLib *lm)
{
JacRes *jr;
TSSol *ts;
Controls *ctrl;
AdvCtx *actx;
PetscLogDouble t;
Expand All @@ -874,12 +875,13 @@ PetscErrorCode LaMEMLibDiffuseTemp(LaMEMLib *lm)
PetscFunctionBeginUser;

// access context
ts = &lm->ts;
jr = &lm->jr;
ctrl = &jr->ctrl;
actx = &lm->actx;

// check for infinite diffusion
if (ctrl->actTemp && ctrl->actSteadyTemp)
if (ctrl->actTemp && ctrl->actSteadyTemp && ts->istep==0)
{
PrintStart(&t,"Computing steady-state temperature distribution", NULL);

Expand All @@ -903,7 +905,7 @@ PetscErrorCode LaMEMLibDiffuseTemp(LaMEMLib *lm)
}

// check for additional limited diffusion
if (ctrl->actTemp && ctrl->steadyTempStep)
if (ctrl->actTemp && ctrl->steadyTempStep && ts->istep==0)
{
PrintStart(&t,"Diffusing temperature", NULL);

Expand Down
Loading