From a6ee3eb5ca009faad301c918a720dc72dcc9632d Mon Sep 17 00:00:00 2001 From: schnetter <> Date: Wed, 23 Jul 2003 07:46:00 +0000 Subject: Don't allow component!=-1 for non-local component loops. Don't allow component!=-1 for non-local component loops. Save and restore component around local component loops. Fix bug in component loops when looping over grid array components. darcs-hash:20030723074641-07bb3-3de5ffbd23a7da9c88a3d7bd3ef13b05f3c45664.gz --- Carpet/Carpet/src/carpet_public.hh | 68 ++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/Carpet/Carpet/src/carpet_public.hh b/Carpet/Carpet/src/carpet_public.hh index c7e0aa216..d4e31afa2 100644 --- a/Carpet/Carpet/src/carpet_public.hh +++ b/Carpet/Carpet/src/carpet_public.hh @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet_public.hh,v 1.33 2003/07/20 21:03:43 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet_public.hh,v 1.34 2003/07/23 09:46:41 schnetter Exp $ // It is assumed that the number of components of all arrays is equal // to the number of components of the grid functions, and that their @@ -220,29 +220,30 @@ namespace Carpet { // Component iterator -#define BEGIN_COMPONENT_LOOP(cgh, grouptype) \ - do { \ - int _cl; \ - cGH * const _cgh = const_cast(cgh); \ - int const _grouptype = (grouptype); \ - int _mincl, _maxcl; \ - if (_grouptype == CCTK_GF) { \ - assert (reflevel>=0 && reflevelreflevels()); \ - assert (mglevel>=0 && mglevellocal_components(reflevel)==1 || component==-1); \ - _mincl=0; \ - _maxcl=hh->components(reflevel); \ - } else { \ - _mincl=component; \ - _maxcl=component; \ - } \ - for (int _c=_mincl; _c<_maxcl; ++_c) { \ - if (_grouptype==CCTK_GF) set_component (_cgh, _c); \ +#define BEGIN_COMPONENT_LOOP(cgh, grouptype) \ + do { \ + int _cl; \ + cGH * const _cgh = const_cast(cgh); \ + int const _grouptype = (grouptype); \ + int const _savec = (component); \ + int _minc, _maxc; \ + if (_grouptype == CCTK_GF) { \ + assert (reflevel>=0 && reflevelreflevels()); \ + assert (mglevel>=0 && mglevelcomponents(reflevel); \ + } else { \ + _minc=component; \ + _maxc=component+1; \ + } \ + for (int _c=_minc; _c<_maxc; ++_c) { \ + if (component!=_c) set_component (_cgh, _c); \ { #define END_COMPONENT_LOOP \ } \ } \ - if (_grouptype==CCTK_GF) set_component (_cgh, -1); \ + if (component!=_savec) set_component (_cgh, -1); \ _cl = 0; \ } while (0) @@ -253,27 +254,28 @@ namespace Carpet { int _lcl; \ cGH * const _cgh = const_cast(cgh); \ int const _grouptype = (grouptype); \ - int _mincl, _maxcl; \ + int const _savec = (component); \ + int _minc, _maxc; \ if (_grouptype == CCTK_GF) { \ assert (reflevel>=0 && reflevelreflevels()); \ assert (mglevel>=0 && mglevellocal_components(reflevel)==1 || component==-1); \ - _mincl=0; \ - _maxcl=hh->components(reflevel); \ + _minc=0; \ + _maxc=hh->components(reflevel); \ } else { \ - _mincl=component; \ - _maxcl=component; \ + _minc=component; \ + _maxc=component+1; \ } \ - for (int _c=_mincl; _c<_maxcl; ++_c) { \ + for (int _c=_minc; _c<_maxc; ++_c) { \ if (_grouptype!=CCTK_GF || hh->is_local(reflevel,_c)) { \ - if (_grouptype==CCTK_GF) set_component (_cgh, _c); \ + if (component!=_c) set_component (_cgh, _c); \ { -#define END_LOCAL_COMPONENT_LOOP \ - } \ - } \ - } \ - if (_grouptype==CCTK_GF) set_component (_cgh, -1); \ - _lcl = 0; \ +#define END_LOCAL_COMPONENT_LOOP \ + } \ + } \ + } \ + if (component!=_savec) set_component (_cgh, _savec); \ + _lcl = 0; \ } while (0) } // namespace Carpet -- cgit v1.2.3