aboutsummaryrefslogtreecommitdiff
path: root/src/patch/test_patch_system.cc
diff options
context:
space:
mode:
authorjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-07-08 13:54:33 +0000
committerjthorn <jthorn@f88db872-0e4f-0410-b76b-b9085cfa78c5>2002-07-08 13:54:33 +0000
commit5ccdd47a1d256a8566f9787b02d42c144a8d02b8 (patch)
tree9cc815f279f86c71fcfb5a75f55a454e91186b2c /src/patch/test_patch_system.cc
parentfd0040fdf14053440eb0a2d237a009c2f54e5429 (diff)
add a test for the 0-origin grid point number across patches
<--> (patch,irho,isigma) conversions git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@615 f88db872-0e4f-0410-b76b-b9085cfa78c5
Diffstat (limited to 'src/patch/test_patch_system.cc')
-rw-r--r--src/patch/test_patch_system.cc98
1 files changed, 89 insertions, 9 deletions
diff --git a/src/patch/test_patch_system.cc b/src/patch/test_patch_system.cc
index dbde22b..5866a9d 100644
--- a/src/patch/test_patch_system.cc
+++ b/src/patch/test_patch_system.cc
@@ -6,7 +6,10 @@
// <<<prototypes>>>
//
// driver - Cactus interface
+/// test_synchronize_Jacobians - test Jacobian of ghost zone synchronization ops
//
+/// verify_gpn - verify gpn <--> (patch,irho,isigma) conversions
+///
/// setup_sym_fn_xyz - set up symmetrized test function fn(global_[xyz])
/// setup_fn_rho_sigma - set up test function fn(rho,sigma)
/// finite_diff - compute linear combination of finite differences
@@ -104,6 +107,8 @@ void test_synchronize_Jacobians(patch_system& ps,
bool perturb_all_y_patch_points,
const char Jacobian_file_name[]);
+void verify_gpn(const patch_system& ps);
+
void setup_sym_fn_xyz(patch_system& ps, int ghosted_gfn, bool want_ghost_zones);
void setup_fn_rho_sigma(patch_system& ps, int ghosted_gfn);
void finite_diff(patch_system& ps,
@@ -173,18 +178,21 @@ CCTK_VInfo(CCTK_THORNSTRING, "patch system created ok");
//
if (STRING_EQUAL(which_test, "gridfn"))
then {
+ verify_gpn(ps);
setup_sym_fn_xyz(ps, test_fn_gfn, true);
ps.print_ghosted_gridfn(test_fn_gfn, "test_fn.dat");
}
else if (STRING_EQUAL(which_test, "read gridfn"))
then {
+ verify_gpn(ps);
ps.read_ghosted_gridfn(test_fn_gfn, "test_fn.dat");
ps.print_ghosted_gridfn(test_fn_gfn, "test_fn2.dat");
}
else if (STRING_EQUAL(which_test, "synchronize"))
then {
+ verify_gpn(ps);
setup_sym_fn_xyz(ps, test_fn_gfn, false);
ps.print_ghosted_gridfn(test_fn_gfn, "test_fn_init.dat");
@@ -201,14 +209,18 @@ else if (STRING_EQUAL(which_test, "synchronize"))
}
else if (STRING_EQUAL(which_test, "synchronize Jacobian"))
- then test_synchronize_Jacobians(ps,
+ then {
+ verify_gpn(ps);
+ test_synchronize_Jacobians(ps,
test_fn_gfn, test_fn_copy_gfn,
NP_Jacobian__perturbation_amplitude,
(NP_Jacobian__perturb_all_y_patch_points != 0),
Jacobian_file_name);
+ }
else if (STRING_EQUAL(which_test, "derivatives"))
then {
+ verify_gpn(ps);
setup_fn_rho_sigma(ps, test_fn_gfn);
ps.print_ghosted_gridfn(test_fn_gfn, "test_fn.dat");
finite_diff(ps, test_fn_gfn, FD_derivs_gfn, which_derivs);
@@ -234,7 +246,8 @@ CCTK_VInfo(CCTK_THORNSTRING, "destroying patch system");
//
// This function tests the computation of the Jacobian of the
-// patch_system::synchronize() operation. In outline, it does the following:
+// patch_system::synchronize_ghost_zones() operation. In outline, it
+// does the following:
//
// set up a test function in test_gfn on the nominal grid
// synchronize test_gfn
@@ -350,10 +363,9 @@ fprintf(fileptr, "# column 17 = Jacobian error\n");
" y patch %s, edge %s",
yp.name(), ye.name());
- xgz.compute_Jacobian(test_gfn, test_gfn,
- true, true, true); // want *all* of ghost zone
- const int Jacobian_y_min_ipar_m = xgz.Jacobian_y_min_ipar_m();
- const int Jacobian_y_max_ipar_m = xgz.Jacobian_y_max_ipar_m();
+ xgz.compute_Jacobian(test_gfn, test_gfn);
+ const int Jacobian_min_y_ipar_m = xgz.Jacobian_min_y_ipar_m();
+ const int Jacobian_max_y_ipar_m = xgz.Jacobian_max_y_ipar_m();
//*** for each point x in (p,xgz)
for (int x_iperp = xgz.min_iperp() ;
@@ -403,8 +415,8 @@ fprintf(fileptr, "# column 17 = Jacobian error\n");
const int y_ipar_m = y_ipar - Jacobian_y_ipar_posn;
const bool m_in_molecule
= (y_iperp == Jacobian_y_iperp)
- && (y_ipar_m >= Jacobian_y_min_ipar_m)
- && (y_ipar_m <= Jacobian_y_max_ipar_m);
+ && (y_ipar_m >= Jacobian_min_y_ipar_m)
+ && (y_ipar_m <= Jacobian_max_y_ipar_m);
const fp Jacobian = m_in_molecule
? xgz.Jacobian(x_iperp, x_ipar, y_ipar_m)
: 0.0;
@@ -467,7 +479,7 @@ fprintf(fileptr, "# column 17 = Jacobian error\n");
double(error));
printf("Jacobian_y_[min,max]_ipar_m=[%d,%d]\n",
- Jacobian_y_min_ipar_m, Jacobian_y_max_ipar_m);
+ Jacobian_min_y_ipar_m, Jacobian_max_y_ipar_m);
printf("Jacobian_y_iperp=%d Jacobian_y_ipar_posn=%d\n",
Jacobian_y_iperp, Jacobian_y_ipar_posn);
printf("y_ipar_m=%d\n", y_ipar_m);
@@ -494,6 +506,74 @@ fclose(fileptr);
//******************************************************************************
//
+// This function verifies the nominal- and ghosted-grid
+// gpn <--> (patch,irho,isigma) conversions.
+//
+namespace {
+void verify_gpn(const patch_system& ps)
+{
+CCTK_VInfo(CCTK_THORNSTRING,
+ "testing gpn <--> (patch,irho,isigma) conversions");
+int gpn = 0;
+int ghosted_gpn = 0;
+
+ for (int pn = 0 ; pn < ps.N_patches() ; ++pn)
+ {
+ const patch& p = ps.ith_patch(pn);
+
+ // nominal grid
+ for (int irho = p.min_irho() ; irho <= p.max_irho() ; ++irho)
+ {
+ for (int isigma = p.min_isigma() ;
+ isigma <= p.max_isigma() ;
+ ++isigma)
+ {
+ assert( ps.gpn_of_patch_irho_isigma(p,irho,isigma) == gpn );
+ int gpn_irho, gpn_isigma;
+ const patch& gpn_p
+ = ps.patch_irho_isigma_of_gpn(gpn, gpn_irho, gpn_isigma);
+ assert( gpn_p == p );
+ assert( gpn_irho == irho );
+ assert( gpn_isigma == isigma );
+
+ ++gpn;
+ }
+ }
+
+ // ghosted grid
+ for (int irho = p.ghosted_min_irho() ;
+ irho <= p.ghosted_max_irho() ;
+ ++irho)
+ {
+ for (int isigma = p.ghosted_min_isigma() ;
+ isigma <= p.ghosted_max_isigma() ;
+ ++isigma)
+ {
+ assert( ps.ghosted_gpn_of_patch_irho_isigma(p,irho,isigma)
+ == ghosted_gpn );
+ int gpn_irho, gpn_isigma;
+ const patch& gpn_p
+ = ps.ghosted_patch_irho_isigma_of_gpn(ghosted_gpn,
+ gpn_irho, gpn_isigma);
+ assert( gpn_p == p );
+ assert( gpn_irho == irho );
+ assert( gpn_isigma == isigma );
+
+ ++ghosted_gpn;
+ }
+ }
+ }
+
+assert( gpn == ps. N_grid_points() );
+assert( ghosted_gpn == ps.ghosted_N_grid_points() );
+}
+ }
+
+//******************************************************************************
+//******************************************************************************
+//******************************************************************************
+
+//
// This function sets up the ghosted test function for the gridfn and
// synchronize tests, symmetrizing the test function to match the
// symmetry of the patch system.