aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/ggf.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2009-11-10 15:53:47 -0600
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 16:45:18 +0000
commitc3e01eeda3d2870a81295deea15567c84a4c1f94 (patch)
tree13761e4384a3e94c724218eee9c9e86fbcababe2 /Carpet/CarpetLib/src/ggf.cc
parent69ec8769e53289499784c236253952fa1d39b583 (diff)
CarpetLib: Beautify code for flip_all and fill_all
Diffstat (limited to 'Carpet/CarpetLib/src/ggf.cc')
-rw-r--r--Carpet/CarpetLib/src/ggf.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc
index cb7605517..8fac57de2 100644
--- a/Carpet/CarpetLib/src/ggf.cc
+++ b/Carpet/CarpetLib/src/ggf.cc
@@ -281,13 +281,15 @@ void ggf::cycle_all (int const rl, int const ml) {
void ggf::flip_all (int const rl, int const ml) {
assert (rl>=0 and rl<h.reflevels());
assert (ml>=0 and ml<h.mglevels());
+ int const ntl = timelevels(ml,rl);
+ assert (ntl > 0);
for (int lc=0; lc<(int)storage.AT(ml).AT(rl).size(); ++lc) {
fdata & fdatas = storage.AT(ml).AT(rl).AT(lc);
- for (int tl=0; tl<(timelevels(ml,rl)-1)/2; ++tl) {
- const int tl1 = tl;
- const int tl2 = timelevels(ml,rl)-1 - tl;
+ for (int tl=0; tl<ntl/2; ++tl) {
+ const int tl1 = tl;
+ const int tl2 = ntl-1 - tl;
assert (tl1 < tl2);
- gdata* tmpdata = fdatas.AT(tl1);
+ gdata * const tmpdata = fdatas.AT(tl1);
fdatas.AT(tl1) = fdatas.AT(tl2);
fdatas.AT(tl2) = tmpdata;
}
@@ -300,11 +302,13 @@ void ggf::flip_all (int const rl, int const ml) {
void ggf::fill_all (int const rl, int const ml) {
assert (rl>=0 and rl<h.reflevels());
assert (ml>=0 and ml<h.mglevels());
+ int const ntl = timelevels(ml,rl);
+ assert (ntl > 0);
for (int lc=0; lc<(int)storage.AT(ml).AT(rl).size(); ++lc) {
fdata const & fdatas = storage.AT(ml).AT(rl).AT(lc);
void const * const srcptr = fdatas.AT(0)->storage();
size_t const size = fdatas.AT(0)->size() * fdatas.AT(0)->elementsize();
- for (int tl=1; tl<timelevels(ml,rl); ++tl) {
+ for (int tl=1; tl<ntl; ++tl) {
void * const dstptr = fdatas.AT(tl)->storage();
memcpy (dstptr, srcptr, size);
}