diff --git a/braid/braid.h b/braid/braid.h index 3606ed0c..b1edd1db 100644 --- a/braid/braid.h +++ b/braid/braid.h @@ -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 */ diff --git a/braid/hierarchy.c b/braid/hierarchy.c index 43ee4305..a14f5f95 100644 --- a/braid/hierarchy.c +++ b/braid/hierarchy.c @@ -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); diff --git a/braid/restrict.c b/braid/restrict.c index 8c4a3f8c..5effce87 100644 --- a/braid/restrict.c +++ b/braid/restrict.c @@ -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))) @@ -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 + { /* Initialize update of c_va[-1] boundary */ if (c_ilower <= c_iupper) { @@ -329,6 +345,7 @@ _braid_FRestrict(braid_Core core, } } _braid_CommWait(core, &send_handle); + } /* Compute global rnorm (only on level 0) */ if (level == 0) @@ -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 + { /* 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; }