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

Linear MGRIT implementation #88

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions braid/braid.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#ifndef braid_HEADER
#define braid_HEADER

#define braid_LINEAR 1

/* To enable XBraid without MPI, re-compile with
* make sequential=yes
* This will compile using the mpistubs.h */
Expand Down
5 changes: 5 additions & 0 deletions braid/hierarchy.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,11 @@ _braid_CopyFineToCoarse(braid_Core core)
_braid_MapCoarseToFine(index, f_cfactor, f_index);
_braid_UGetVector(core, level-1, f_index, &u);
_braid_Coarsen(core, level, f_index, index, u, &va[index-ilower]);
if (braid_LINEAR)
{
/* Set initial guess to zero on coarse grids */
_braid_BaseSum(core, app, -1.0, va[index-ilower], 1.0, va[index-ilower]);
}

_braid_BaseFree(core, app, u);
_braid_BaseClone(core, app, va[index-ilower], &u);
Expand Down
24 changes: 24 additions & 0 deletions braid/restrict.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,22 @@ _braid_FRestrict(braid_Core core,
_braid_MapFineToCoarse(ci, cfactor, c_index);
_braid_Coarsen(core, c_level, ci, c_index, u, &c_va[c_index-c_ilower]);
_braid_Coarsen(core, c_level, ci, c_index, r, &c_fa[c_index-c_ilower]);
if (braid_LINEAR)
{
/* Set initial guess to zero on coarse grids */
_braid_BaseSum(core, app, -1.0, c_va[c_index-c_ilower], 1.0, c_va[c_index-c_ilower]);
}
}
else if (ci == 0)
{
/* Restrict initial condition, coarsening in space if needed */
_braid_UGetVectorRef(core, level, 0, &u);
_braid_Coarsen(core, c_level, 0, 0, u, &c_va[0]);
if (braid_LINEAR)
{
/* Set initial guess to zero on coarse grids */
_braid_BaseSum(core, app, -1.0, c_va[0], 1.0, c_va[0]);
}
}

if ((flo <= fhi) || (ci > _braid_CoreElt(core, initiali)))
Expand All @@ -222,6 +232,12 @@ _braid_FRestrict(braid_Core core,
/* Set initial guess on coarse level */
_braid_InitGuess(core, c_level);

if (braid_LINEAR)
{
/* Don't need to update the rhs in the linear case (no Richardson either) */
}
else
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we indent this code block?

/* Initialize update of c_va[-1] boundary */
if (c_ilower <= c_iupper)
{
Expand Down Expand Up @@ -329,6 +345,7 @@ _braid_FRestrict(braid_Core core,
}
}
_braid_CommWait(core, &send_handle);
}

/* Compute global rnorm (only on level 0) */
if (level == 0)
Expand Down Expand Up @@ -359,12 +376,19 @@ _braid_FRestrict(braid_Core core,
_braid_PrintSpatialNorms(core, tnorm_a, ncpoints);
}

if (braid_LINEAR)
{
/* Don't need to update the rhs in the linear case (no Richardson either) */
}
else
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we indent this code block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I wanted the diffs to be clear when I first implemented this.

/* Need to finalize the error estimates at the F-points */
if ( level == 0 && est_error )
{
_braid_FinalizeErrorEstimates( core, estimate , c_iupper-c_ilower + 1 );
_braid_TFree(estimate);
}
}

return _braid_error_flag;
}
Expand Down