aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib
diff options
context:
space:
mode:
authorswhite <schnetter@cct.lsu.edu>2004-11-29 17:57:00 +0000
committerswhite <schnetter@cct.lsu.edu>2004-11-29 17:57:00 +0000
commit097c294fd9102e4d528ca37fe9bae74d90d97232 (patch)
tree43213124e7933f78f2b2bb4973c636f998613bb4 /Carpet/CarpetLib
parente2793e05bf32fee729ce3e93d5f69a494370c7c6 (diff)
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
Diffstat (limited to 'Carpet/CarpetLib')
-rw-r--r--Carpet/CarpetLib/src/data.cc98
-rw-r--r--Carpet/CarpetLib/src/data.hh3
2 files changed, 37 insertions, 64 deletions
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<class T,int D>
+void data<T,D>
+::fill_box_arrays( int *srcshp, int *dstshp,
+ int srcbbox[3][D], int dstbbox[3][D], int regbbox[3][D],
+ const data<T,D>::ibbox & box,
+ const data<T,D>::ibbox & sext,
+ const data<T,D>::ibbox & dext )
+{
+ for (int d=0; d<D; ++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];
+ }
+}
+
template<>
void data<CCTK_INT4,3>
::copy_from_innerloop (const gdata<3>* gsrc, const ibbox& box)
@@ -549,22 +575,8 @@ void data<CCTK_INT4,3>
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<CCTK_REAL8,3>
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<CCTK_COMPLEX16,3>
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<CCTK_REAL8,3>
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<D>& 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