aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--par/misner1.2-025-init-mask.par3
-rw-r--r--param.ccl16
-rw-r--r--src/driver/driver.hh23
-rw-r--r--src/driver/find_horizons.cc2
-rw-r--r--src/driver/mask.cc102
-rw-r--r--src/driver/setup.cc80
6 files changed, 81 insertions, 145 deletions
diff --git a/par/misner1.2-025-init-mask.par b/par/misner1.2-025-init-mask.par
index 45c5c97..11d6f2e 100644
--- a/par/misner1.2-025-init-mask.par
+++ b/par/misner1.2-025-init-mask.par
@@ -79,7 +79,8 @@ AHFinderDirect::print_timing_stats = "true"
##AHFinderDirect::verbose_level = "algorithm details"
AHFinderDirect::set_horizon_mask = "true"
-AHFinderDirect::mask_type = "old-style (CCTK_REAL)"
+AHFinderDirect::set_old_style_mask = "true"
+AHFinderDirect::set_new_style_mask = "false"
# have mask directly show horizon position for testing (no buffer zone)
AHFinderDirect::mask_radius_multiplier[1] = 1.0
AHFinderDirect::mask_radius_multiplier[2] = 1.0
diff --git a/param.ccl b/param.ccl
index eb09922..1ad824d 100644
--- a/param.ccl
+++ b/param.ccl
@@ -395,7 +395,8 @@ string Jacobian_base_file_name "base file name for Jacobian output file(s)"
# ***** based on each apparent horizon shape *****
#
-boolean set_horizon_mask "should we set a mask grid function for each horizon?"
+boolean set_horizon_mask \
+ "should we set a mask grid function (or functions) for each horizon?"
{
} "false"
@@ -434,13 +435,16 @@ real mask_radius_offset[5] \
# * the "new" style is that defined by CactusEinstein/SpaceMask:
# the mask is a CCTK_INT grid function, with a specified bit field
# set to specified values inside/outside the (adjusted) horizon
+# You can choose to set either (or even both!) of these.
#
-keyword mask_type "what type of mask should we set?"
+boolean set_old_style_mask \
+ "if we're setting a mask, should we set an old-style (CCTK_REAL) mask gridfn?"
{
-"old-style (CCTK_REAL)" :: "some CCTK_REAL grid function"
-"new-style (CCTK_INT)" :: \
- "some CCTK_INT grid function, using named bit fields via the SpaceMask thorn"
-} "old-style (CCTK_REAL)"
+} "true"
+boolean set_new_style_mask \
+ "if we're setting a mask, should we set an new-style (CCTK_INT) mask gridfn?"
+{
+} "true"
#
# mask info for mask_type = "old-style (CCTK_REAL)"
diff --git a/src/driver/driver.hh b/src/driver/driver.hh
index 5a45278..4511208 100644
--- a/src/driver/driver.hh
+++ b/src/driver/driver.hh
@@ -62,17 +62,6 @@ enum horizon_file_format
horizon_file_format__HDF5 // no comma
};
-//
-// this enum holds the decoded mask_type parameter, i.e. it specifies
-// what type of mask grid function to use (if we're going to set a mask
-// at all)
-//
-enum mask_type
- {
- mask_type__old_style,
- mask_type__new_style // no comma
- };
-
//******************************************************************************
//
@@ -176,17 +165,19 @@ struct mask_info
bool do_mask;
const fp* radius_multiplier; // --> array [hn] which we do *not* own
const fp* radius_offset; // ditto
- enum mask_type mask_type;
- const char* mask_gridfn_name;
- int mask_gridfn_varindex;
+ bool set_old_style_mask, set_new_style_mask;
struct old_style_mask_info
{
- CCTK_REAL* mask_gridfn_data;
+ const char* mask_gridfn_name;
+ int mask_gridfn_varindex;
+ CCTK_REAL* mask_gridfn_data;
CCTK_REAL inside_value, outside_value;
} old_style_mask_info;
struct new_style_mask_info
{
- CCTK_INT* mask_gridfn_data;
+ const char* mask_gridfn_name;
+ int mask_gridfn_varindex;
+ CCTK_INT* mask_gridfn_data;
CCTK_INT bitfield_mask, inside_value, outside_value;
} new_style_mask_info;
};
diff --git a/src/driver/find_horizons.cc b/src/driver/find_horizons.cc
index a6f9d5f..6bf80ad 100644
--- a/src/driver/find_horizons.cc
+++ b/src/driver/find_horizons.cc
@@ -88,7 +88,7 @@ void do_test_expansion_Jacobians(int my_proc, int N_horizons,
//
// This function is called by the Cactus scheduler to find the apparent
// horizon or horizons in the current slice, and optionally set a mask
-// grid function based on each horizon shape.
+// grid function (or functions) based on each horizon shape.
//
extern "C"
void AHFinderDirect_find_horizons(CCTK_ARGUMENTS)
diff --git a/src/driver/mask.cc b/src/driver/mask.cc
index 8378ebf..a3578db 100644
--- a/src/driver/mask.cc
+++ b/src/driver/mask.cc
@@ -2,7 +2,7 @@
// $Header$
//
// <<<prototypes for functions local to this file>>>
-// set_mask_gridfn - set mask gridfn based on each horizon's shape
+// set_mask_gridfn - set mask gridfn(s) based on each horizon's shape
//
#include <stdio.h>
@@ -54,15 +54,24 @@ void set_mask_gridfn(int N_horizons,
const struct mask_info& mask_info,
const struct verbose_info& verbose_info)
{
+const bool set_old_style_mask = mask_info.set_old_style_mask;
+const bool set_new_style_mask = mask_info.set_new_style_mask;
const struct mask_info::old_style_mask_info& old_style_mask_info
= mask_info.old_style_mask_info;
const struct mask_info::new_style_mask_info& new_style_mask_info
= mask_info.new_style_mask_info;
if (verbose_info.print_algorithm_highlights)
- then CCTK_VInfo(CCTK_THORNSTRING,
- "setting mask grid function %s",
- mask_info.mask_gridfn_name);
+ then {
+ if (set_old_style_mask)
+ then CCTK_VInfo(CCTK_THORNSTRING,
+ "setting old-style (CCTK_REAL) mask grid function %s",
+ old_style_mask_info.mask_gridfn_name);
+ if (set_new_style_mask)
+ then CCTK_VInfo(CCTK_THORNSTRING,
+ "setting new-style (CCTK_INT) mask grid function %s",
+ new_style_mask_info.mask_gridfn_name);
+ }
if (verbose_info.print_algorithm_debug)
then {
@@ -84,33 +93,20 @@ if (verbose_info.print_algorithm_debug)
//
// set up the gridfn data pointers
//
-CCTK_REAL* old_style_mask_gridfn_data_ptr = NULL;
-CCTK_INT * new_style_mask_gridfn_data_ptr = NULL;
-switch (mask_info.mask_type)
- {
-case mask_type__old_style:
- old_style_mask_gridfn_data_ptr
- = Cactus_gridfn_data_ptr<CCTK_REAL>
- (cgi.GH,
- mask_info.mask_gridfn_varindex,
- mask_info.mask_gridfn_name);
- break;
-case mask_type__new_style:
- new_style_mask_gridfn_data_ptr
- = Cactus_gridfn_data_ptr<CCTK_INT>
- (cgi.GH,
- mask_info.mask_gridfn_varindex,
- mask_info.mask_gridfn_name);
- break;
-default:
- CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
-"\n"
-" set_mask_gridfn(): unknown mask_info.mask_type=(int)%d\n"
-" when precomputing gridfn data pointers!\n"
-" (this should never happen!)"
- ,
- int(mask_info.mask_type)); /*NOTREACHED*/
- }
+CCTK_REAL* old_style_mask_gridfn_data_ptr
+ = set_old_style_mask
+ ? Cactus_gridfn_data_ptr<CCTK_REAL>
+ (cgi.GH,
+ old_style_mask_info.mask_gridfn_varindex,
+ old_style_mask_info.mask_gridfn_name)
+ : NULL;
+CCTK_INT * new_style_mask_gridfn_data_ptr
+ = set_new_style_mask
+ ? Cactus_gridfn_data_ptr<CCTK_INT>
+ (cgi.GH,
+ new_style_mask_info.mask_gridfn_varindex,
+ new_style_mask_info.mask_gridfn_name)
+ : NULL;
//
@@ -128,25 +124,13 @@ if (verbose_info.print_algorithm_details)
for (int i = 0 ; i < cgi.local_gridfn_dims[X_AXIS] ; ++i)
{
const int posn = CCTK_GFINDEX3D(cgi.GH, i,j,k);
- switch (mask_info.mask_type)
- {
- case mask_type__old_style:
- old_style_mask_gridfn_data_ptr[posn] = old_style_mask_info
+ if (set_old_style_mask)
+ then old_style_mask_gridfn_data_ptr[posn] = old_style_mask_info
.outside_value;
- break;
- case mask_type__new_style:
- SpaceMask_SetStateBits(new_style_mask_gridfn_data_ptr, posn,
+ if (set_new_style_mask)
+ then SpaceMask_SetStateBits(new_style_mask_gridfn_data_ptr, posn,
new_style_mask_info.bitfield_mask,
new_style_mask_info.inside_value);
- break;
- CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
-"\n"
-" set_mask_gridfn(): unknown mask_info.mask_type=(int)%d\n"
-" when setting mask to outside value!\n"
-" (this should never happen!)"
- ,
- int(mask_info.mask_type)); /*NOTREACHED*/
- }
}
}
}
@@ -303,28 +287,12 @@ if (verbose_info.print_algorithm_details)
}
// set the mask
- switch (mask_info.mask_type)
- {
- case mask_type__old_style:
- old_style_mask_gridfn_data_ptr[posn]
- = old_style_mask_value;
- break;
- case mask_type__new_style:
- SpaceMask_SetStateBits(new_style_mask_gridfn_data_ptr,
- posn,
+ if (set_old_style_mask)
+ then old_style_mask_gridfn_data_ptr[posn] = old_style_mask_value;
+ if (set_new_style_mask)
+ then SpaceMask_SetStateBits(new_style_mask_gridfn_data_ptr, posn,
new_style_mask_info.bitfield_mask,
new_style_mask_value);
- break;
- default:
- CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__,
- CCTK_THORNSTRING,
-"\n"
-" set_mask_gridfn(): unknown mask_info.mask_type=(int)%d!\n"
-" when setting value for horizon!\n"
-" (this should never happen!)"
- ,
- int(mask_info.mask_type)); /*NOTREACHED*/
- }
}
}
}
diff --git a/src/driver/setup.cc b/src/driver/setup.cc
index dcb5445..af97e9a 100644
--- a/src/driver/setup.cc
+++ b/src/driver/setup.cc
@@ -9,7 +9,6 @@
/// decode_method - decode the method parameter
/// decode_verbose_level - decode the verbose_level parameter
/// decode_horizon_file_format - decode the horizon_file_format parameter
-/// decode_mask_type - decode the mask_type parameter
///
/// allocate_horizons_to_processor - choose which horizons this proc will find
///
@@ -70,8 +69,6 @@ enum verbose_level
decode_verbose_level(const char verbose_level_string[]);
enum horizon_file_format
decode_horizon_file_format(const char horizon_file_format_string[]);
-enum mask_type
- decode_mask_type(const char mask_type_string[]);
int allocate_horizons_to_processor(int N_procs, int my_proc,
int N_horizons, bool multiproc_flag,
@@ -328,43 +325,38 @@ struct mask_info& mask_info = state.mask_info;
mask_info.do_mask = (set_horizon_mask != 0);
if (mask_info.do_mask)
then {
- mask_info.radius_multiplier = mask_radius_multiplier;
- mask_info.radius_offset = mask_radius_offset;
- mask_info.mask_type = decode_mask_type(mask_type);
-
- switch (mask_info.mask_type)
- {
- case mask_type__old_style:
- mask_info.mask_gridfn_name = old_style_mask_gridfn_name;
- mask_info.old_style_mask_info.mask_gridfn_data = NULL;
- mask_info.old_style_mask_info.inside_value
- = old_style_mask_inside_value;
- mask_info.old_style_mask_info.outside_value
- = old_style_mask_outside_value;
- break;
- case mask_type__new_style:
- mask_info.mask_gridfn_name = new_style_mask_gridfn_name;
- mask_info.new_style_mask_info.mask_gridfn_data = NULL;
- mask_info.new_style_mask_info.bitfield_mask
+ mask_info.radius_multiplier = mask_radius_multiplier;
+ mask_info.radius_offset = mask_radius_offset;
+ mask_info.set_old_style_mask = (set_old_style_mask != 0);
+ mask_info.set_new_style_mask = (set_new_style_mask != 0);
+ if (mask_info.set_old_style_mask)
+ then {
+ struct mask_info::old_style_mask_info& osmi
+ = mask_info.old_style_mask_info;
+ osmi.mask_gridfn_name = old_style_mask_gridfn_name;
+ osmi.mask_gridfn_varindex
+ = Cactus_gridfn_varindex(osmi.mask_gridfn_name);
+ osmi.mask_gridfn_data = NULL;
+ osmi.inside_value = old_style_mask_inside_value;
+ osmi.outside_value = old_style_mask_outside_value;
+ }
+ if (mask_info.set_new_style_mask)
+ then {
+ struct mask_info::new_style_mask_info& nsmi
+ = mask_info.new_style_mask_info;
+ nsmi.mask_gridfn_name = new_style_mask_gridfn_name;
+ nsmi.mask_gridfn_varindex
+ = Cactus_gridfn_varindex(nsmi.mask_gridfn_name);
+ nsmi.mask_gridfn_data = NULL;
+ nsmi.bitfield_mask
= SpaceMask_GetTypeBits(new_style_mask_bitfield_name);
- mask_info.new_style_mask_info.inside_value
+ nsmi.inside_value
= SpaceMask_GetStateBits(new_style_mask_bitfield_name,
new_style_mask_inside_state_name);
- mask_info.new_style_mask_info.outside_value
+ nsmi.outside_value
= SpaceMask_GetStateBits(new_style_mask_bitfield_name,
new_style_mask_outside_state_name);
- break;
- default:
- CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
-"\n"
-" AHFinderDirect_setup(): unknown mask_info.mask_type=(int)%d!\n"
-" (this should never happen!)"
- ,
- int(mask_info.mask_type)); /*NOTREACHED*/
}
-
- mask_info.mask_gridfn_varindex
- = Cactus_gridfn_varindex(mask_info.mask_gridfn_name);
}
@@ -627,26 +619,6 @@ else CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
}
//******************************************************************************
-
-//
-// This function decodes the mask_type parameter (string) into an
-// internal enum for future use.
-//
-namespace {
-enum mask_type
- decode_mask_type(const char mask_type_string[])
-{
-if (STRING_EQUAL(mask_type_string, "old-style (CCTK_REAL)"))
- then return mask_type__old_style;
-else if (STRING_EQUAL(mask_type_string, "new-style (CCTK_INT)"))
- then return mask_type__new_style;
-else CCTK_VWarn(FATAL_ERROR, __LINE__, __FILE__, CCTK_THORNSTRING,
-"decode_mask_type(): unknown mask_type_string=\"%s\"!",
- mask_type_string); /*NOTREACHED*/
-}
- }
-
-//******************************************************************************
//******************************************************************************
//******************************************************************************