From 097c294fd9102e4d528ca37fe9bae74d90d97232 Mon Sep 17 00:00:00 2001 From: swhite Date: Mon, 29 Nov 2004 17:57:00 +0000 Subject: data_fill_box_arrays Pulled out repeated code into single routine data::fill_box_arrays. While this is an improvement, I don't like the fact that I've had to expose the ugly funciton in the data.hh interface, even as private. It was necessary because the inappropriate declaration of ibbox as an internal type (of inexplicit access) of the data class. Down the road, make a separate ibbox declaration. darcs-hash:20041129175753-32473-a0f983bbaf22ff404cd89a0db814faca0a8f0a7b.gz --- Carpet/CarpetLib/src/data.cc | 98 +++++++++++++++----------------------------- Carpet/CarpetLib/src/data.hh | 3 ++ 2 files changed, 37 insertions(+), 64 deletions(-) (limited to 'Carpet/CarpetLib') diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc index d5d6d78f1..4acc32e39 100644 --- a/Carpet/CarpetLib/src/data.cc +++ b/Carpet/CarpetLib/src/data.cc @@ -522,6 +522,32 @@ extern "C" { const int regbbox[3][3]); } +template +void data +::fill_box_arrays( int *srcshp, int *dstshp, + int srcbbox[3][D], int dstbbox[3][D], int regbbox[3][D], + const data::ibbox & box, + const data::ibbox & sext, + const data::ibbox & dext ) +{ + for (int d=0; d void data ::copy_from_innerloop (const gdata<3>* gsrc, const ibbox& box) @@ -549,22 +575,8 @@ void data int srcshp[3], dstshp[3]; int srcbbox[3][3], dstbbox[3][3], regbbox[3][3]; - for (int d=0; d<3; ++d) { - srcshp[d] = (sext.shape() / sext.stride())[d]; - dstshp[d] = (dext.shape() / dext.stride())[d]; - - srcbbox[0][d] = sext.lower()[d]; - srcbbox[1][d] = sext.upper()[d]; - srcbbox[2][d] = sext.stride()[d]; - - dstbbox[0][d] = dext.lower()[d]; - dstbbox[1][d] = dext.upper()[d]; - dstbbox[2][d] = dext.stride()[d]; - - regbbox[0][d] = box.lower()[d]; - regbbox[1][d] = box.upper()[d]; - regbbox[2][d] = box.stride()[d]; - } + fill_box_arrays( srcshp, dstshp, srcbbox, dstbbox, regbbox, + box, sext, dext ); assert (all(dext.stride() == box.stride())); if (all(sext.stride() == dext.stride())) { @@ -608,22 +620,8 @@ void data int srcshp[3], dstshp[3]; int srcbbox[3][3], dstbbox[3][3], regbbox[3][3]; - for (int d=0; d<3; ++d) { - srcshp[d] = (sext.shape() / sext.stride())[d]; - dstshp[d] = (dext.shape() / dext.stride())[d]; - - srcbbox[0][d] = sext.lower()[d]; - srcbbox[1][d] = sext.upper()[d]; - srcbbox[2][d] = sext.stride()[d]; - - dstbbox[0][d] = dext.lower()[d]; - dstbbox[1][d] = dext.upper()[d]; - dstbbox[2][d] = dext.stride()[d]; - - regbbox[0][d] = box.lower()[d]; - regbbox[1][d] = box.upper()[d]; - regbbox[2][d] = box.stride()[d]; - } + fill_box_arrays( srcshp, dstshp, srcbbox, dstbbox, regbbox, + box, sext, dext ); assert (all(dext.stride() == box.stride())); if (all(sext.stride() == dext.stride())) { @@ -667,22 +665,8 @@ void data int srcshp[3], dstshp[3]; int srcbbox[3][3], dstbbox[3][3], regbbox[3][3]; - for (int d=0; d<3; ++d) { - srcshp[d] = (sext.shape() / sext.stride())[d]; - dstshp[d] = (dext.shape() / dext.stride())[d]; - - srcbbox[0][d] = sext.lower()[d]; - srcbbox[1][d] = sext.upper()[d]; - srcbbox[2][d] = sext.stride()[d]; - - dstbbox[0][d] = dext.lower()[d]; - dstbbox[1][d] = dext.upper()[d]; - dstbbox[2][d] = dext.stride()[d]; - - regbbox[0][d] = box.lower()[d]; - regbbox[1][d] = box.upper()[d]; - regbbox[2][d] = box.stride()[d]; - } + fill_box_arrays( srcshp, dstshp, srcbbox, dstbbox, regbbox, + box, sext, dext ); assert (all(dext.stride() == box.stride())); if (all(sext.stride() == dext.stride())) { @@ -951,22 +935,8 @@ void data int srcshp[3], dstshp[3]; int srcbbox[3][3], dstbbox[3][3], regbbox[3][3]; - for (int d=0; d<3; ++d) { - srcshp[d] = (sext.shape() / sext.stride())[d]; - dstshp[d] = (dext.shape() / dext.stride())[d]; - - srcbbox[0][d] = sext.lower()[d]; - srcbbox[1][d] = sext.upper()[d]; - srcbbox[2][d] = sext.stride()[d]; - - dstbbox[0][d] = dext.lower()[d]; - dstbbox[1][d] = dext.upper()[d]; - dstbbox[2][d] = dext.stride()[d]; - - regbbox[0][d] = box.lower()[d]; - regbbox[1][d] = box.upper()[d]; - regbbox[2][d] = box.stride()[d]; - } + fill_box_arrays( srcshp, dstshp, srcbbox, dstbbox, regbbox, + box, sext, dext ); // Check that the times are consistent assert (times.size() > 0); diff --git a/Carpet/CarpetLib/src/data.hh b/Carpet/CarpetLib/src/data.hh index 524f77c4c..f08463ff6 100644 --- a/Carpet/CarpetLib/src/data.hh +++ b/Carpet/CarpetLib/src/data.hh @@ -90,6 +90,9 @@ private: virtual void change_processor_wait (comm_state& state, const int newproc, void* const mem=0); + virtual void fill_box_arrays( int *srcshp, int *dstshp, + int srcbbox[3][D], int dstbbox[3][D], int regbbox[3][D], + const ibbox & box, const ibbox & sext, const ibbox & dext ); public: // Accessors -- cgit v1.2.3