From dc5ef8bd7548e3cca7906524f69804d25c9ff478 Mon Sep 17 00:00:00 2001 From: schnetter <> Date: Wed, 31 Mar 2004 10:50:00 +0000 Subject: Handle looping over refinement levels more elegantly. darcs-hash:20040331105058-07bb3-0c0495c75cd248152699703e2e6d1520c9c80052.gz --- Carpet/CarpetInterp/src/interp.cc | 309 +++++++++++++++++++------------------- 1 file changed, 154 insertions(+), 155 deletions(-) diff --git a/Carpet/CarpetInterp/src/interp.cc b/Carpet/CarpetInterp/src/interp.cc index 4c74c67c0..73ee23fc1 100644 --- a/Carpet/CarpetInterp/src/interp.cc +++ b/Carpet/CarpetInterp/src/interp.cc @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.24 2004/03/08 09:12:44 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.25 2004/03/31 12:50:58 schnetter Exp $ #include #include @@ -21,7 +21,7 @@ #include "interp.hh" extern "C" { - static char const * const rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.24 2004/03/08 09:12:44 schnetter Exp $"; + static char const * const rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetInterp/src/interp.cc,v 1.25 2004/03/31 12:50:58 schnetter Exp $"; CCTK_FILEVERSION(Carpet_CarpetInterp_interp_cc); } @@ -300,186 +300,185 @@ namespace CarpetInterp { // int overall_ierr = 0; BEGIN_GLOBAL_MODE(cgh) { - - BEGIN_REFLEVEL_LOOP(cgh) { - if (reflevel>=minrl && refleveltime (0, reflevel, mglevel); - CCTK_REAL const time2 = cgh->cctk_time / cgh->cctk_delta_time; - bool const need_time_interp - = fabs((time1 - time2) / (fabs(time1) + fabs(time2) - + fabs(cgh->cctk_delta_time))) > 1e-12; - int const num_tl - = need_time_interp ? prolongation_order_time + 1 : 1; + for (int rl=minrl; rltime (0, reflevel, mglevel); + CCTK_REAL const time2 = cgh->cctk_time / cgh->cctk_delta_time; + bool const need_time_interp + = fabs((time1 - time2) / (fabs(time1) + fabs(time2) + + fabs(cgh->cctk_delta_time))) > 1e-12; + int const num_tl + = need_time_interp ? prolongation_order_time + 1 : 1; + + BEGIN_MAP_LOOP(cgh, CCTK_GF) { + BEGIN_LOCAL_COMPONENT_LOOP(cgh, CCTK_GF) { - BEGIN_MAP_LOOP(cgh, CCTK_GF) { - BEGIN_LOCAL_COMPONENT_LOOP(cgh, CCTK_GF) { + // Find out about the local geometry + ivect lsh; + rvect coord_origin, coord_delta; + for (int d=0; dcctk_lsh[d]; + coord_delta[d] = cgh->cctk_delta_space[d] / cgh->cctk_levfac[d]; + coord_origin[d] = cgh->cctk_origin_space[d] + (cgh->cctk_lbnd[d] + 1.0 * cgh->cctk_levoff[d] / cgh->cctk_levoffdenom[d]) * coord_delta[d]; - // Find out about the local geometry - ivect lsh; - rvect coord_origin, coord_delta; - for (int d=0; dcctk_lsh[d]; - coord_delta[d] = cgh->cctk_delta_space[d] / cgh->cctk_levfac[d]; - coord_origin[d] = cgh->cctk_origin_space[d] + (cgh->cctk_lbnd[d] + 1.0 * cgh->cctk_levoff[d] / cgh->cctk_levoffdenom[d]) * coord_delta[d]; + } + + + + // Find out about the grid functions + vector input_array_type_codes(N_input_arrays); + vector input_arrays(N_input_arrays); + for (int n=0; n input_array_type_codes(N_input_arrays); - vector input_arrays(N_input_arrays); - for (int n=0; n=0 && vi=0 && gi= num_tl); - - input_array_type_codes.at(n) = group.vartype; - - } - } // for input arrays - - - - // Work on the data from all processors - for (int p=0; p=0 && vi=0 && gi tmp_interp_coords (dim); - for (int d=0; d= num_tl); + input_array_type_codes.at(n) = group.vartype; + + } + } // for input arrays + + + + // Work on the data from all processors + for (int p=0; p tmp_interp_coords (dim); + for (int d=0; d > tmp_output_arrays (num_tl); + + for (int tl=0; tl > tmp_output_arrays (num_tl); + for (int n=0; n=0 && vi=0 && vicctk_time / cgh->cctk_delta_time; - vector times(num_tl); - for (int tl=0; tltime (tl, reflevel, mglevel); - } + // Get interpolation times + CCTK_REAL const time = cgh->cctk_time / cgh->cctk_delta_time; + vector times(num_tl); + for (int tl=0; tltime (tl, reflevel, mglevel); + } - // Calculate interpolation weights - vector tfacs(num_tl); - switch (num_tl) { - case 1: - // no interpolation - assert (fabs((time - times.at(0)) / fabs(time + times.at(0) + cgh->cctk_delta_time)) < 1e-12); - tfacs.at(0) = 1.0; - break; - case 2: - // linear (2-point) interpolation - tfacs.at(0) = (time - times.at(1)) / (times.at(0) - times.at(1)); - tfacs.at(1) = (time - times.at(0)) / (times.at(1) - times.at(0)); - break; - case 3: - // quadratic (3-point) interpolation - tfacs.at(0) = (time - times.at(1)) * (time - times.at(2)) / ((times.at(0) - times.at(1)) * (times.at(0) - times.at(2))); - tfacs.at(1) = (time - times.at(0)) * (time - times.at(2)) / ((times.at(1) - times.at(0)) * (times.at(1) - times.at(2))); - tfacs.at(2) = (time - times.at(0)) * (time - times.at(1)) / ((times.at(2) - times.at(0)) * (times.at(2) - times.at(1))); - break; - default: - assert (0); - } + // Calculate interpolation weights + vector tfacs(num_tl); + switch (num_tl) { + case 1: + // no interpolation + assert (fabs((time - times.at(0)) / fabs(time + times.at(0) + cgh->cctk_delta_time)) < 1e-12); + tfacs.at(0) = 1.0; + break; + case 2: + // linear (2-point) interpolation + tfacs.at(0) = (time - times.at(1)) / (times.at(0) - times.at(1)); + tfacs.at(1) = (time - times.at(0)) / (times.at(1) - times.at(0)); + break; + case 3: + // quadratic (3-point) interpolation + tfacs.at(0) = (time - times.at(1)) * (time - times.at(2)) / ((times.at(0) - times.at(1)) * (times.at(0) - times.at(2))); + tfacs.at(1) = (time - times.at(0)) * (time - times.at(2)) / ((times.at(1) - times.at(0)) * (times.at(1) - times.at(2))); + tfacs.at(2) = (time - times.at(0)) * (time - times.at(1)) / ((times.at(2) - times.at(0)) * (times.at(2) - times.at(1))); + break; + default: + assert (0); + } - // Interpolate - for (int j=0; j