Skip to content

Commit

Permalink
Forgot to store improved initial guess in residual
Browse files Browse the repository at this point in the history
Oops!
Seems to be working, so this
is my last commit with this safer version
of improved initial guess.
Further commits will be for another
option that allows for the user to
overwrite ustop itself, which is much more flexible.

Signed-off-by: David Vargas <dvargas2@unm.edu>
  • Loading branch information
cadaverous-lives committed Apr 3, 2024
1 parent 80708e4 commit caddb8b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
26 changes: 17 additions & 9 deletions braid/residual.c
Expand Up @@ -34,15 +34,17 @@ _braid_Residual(braid_Core core,
braid_BaseVector ustop,
braid_BaseVector r)
{
braid_App app = _braid_CoreElt(core, app);
braid_Real tol = _braid_CoreElt(core, tol);
braid_Int iter = _braid_CoreElt(core, niter);
_braid_Grid **grids = _braid_CoreElt(core, grids);
braid_StepStatus status = (braid_StepStatus)core;
braid_Int nrefine = _braid_CoreElt(core, nrefine);
braid_Int gupper = _braid_CoreElt(core, gupper);
braid_Int ilower = _braid_GridElt(grids[level], ilower);
braid_Real *ta = _braid_GridElt(grids[level], ta);
braid_App app = _braid_CoreElt(core, app);
braid_Real tol = _braid_CoreElt(core, tol);
braid_Int iter = _braid_CoreElt(core, niter);
_braid_Grid **grids = _braid_CoreElt(core, grids);
braid_StepStatus status = (braid_StepStatus)core;
braid_Int nrefine = _braid_CoreElt(core, nrefine);
braid_Int gupper = _braid_CoreElt(core, gupper);
braid_Int ilower = _braid_GridElt(grids[level], ilower);
braid_Real *ta = _braid_GridElt(grids[level], ta);
braid_Int storage = _braid_GridElt(grids[level], storage);
braid_BaseVector *wa = _braid_GridElt(grids[level], wa);

/* this decides whether Delta correction needs to be computed on this level
* If step is called from FRestrict, right after restriction to the coarse grid
Expand Down Expand Up @@ -77,6 +79,12 @@ _braid_Residual(braid_Core core,
/* By default: r = ustop - \Phi(ustart)*/
_braid_GetUInit(core, level, index, r, &rstop);
_braid_BaseStep(core, app, rstop, NULL, r, level, status);
if (level > 0 && storage)
{
_braid_BaseFree(core, app, wa[ii]);
_braid_BaseClone(core, app, r, &wa[ii]);
}

_braid_BaseSum(core, app, 1.0, ustop, -1.0, r);
}
else /* can we make residual option compatible with Delta correction? */
Expand Down
6 changes: 3 additions & 3 deletions braid/step.c
Expand Up @@ -110,12 +110,12 @@ _braid_Step(braid_Core core,
/* Store the homogeneous step result */
if (level > 0 && storage)
{
_braid_BaseFree(core, app, wa[ii]);
_braid_BaseClone(core, app, u, &wa[ii]);
// _braid_CoreFcn(core, free)(app, wa[ii]);
// _braid_CoreFcn(core, clone)(app, u, &wa[ii]);
// _braid_BaseFree(core, app, wa[ii]);
// _braid_BaseClone(core, app, u, &wa[ii]);
// _braid_CoreFcn(core, sum)(app, 1., u->userVector, 0., wa[ii]->userVector);
_braid_BaseSum(core, app, 1, u, 0, wa[ii]);
// _braid_BaseSum(core, app, 1, u, 0, wa[ii]);
}

/* now apply the Delta and tau corrections */
Expand Down

0 comments on commit caddb8b

Please sign in to comment.