Skip to content

Commit

Permalink
fixup change to CubeScale
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexCarpenter46 committed Sep 6, 2024
1 parent 0a339b2 commit 8e8fe3f
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 63 deletions.
8 changes: 4 additions & 4 deletions src/Domain/Creators/BinaryCompactObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ template <bool UseWorldtube>
BinaryCompactObject<UseWorldtube>::BinaryCompactObject(
typename ObjectA::type object_A, typename ObjectB::type object_B,
std::array<double, 2> center_of_mass_offset, const double envelope_radius,
const double outer_radius, const std::optional<double> cube_length,
const double outer_radius, const double cube_scale,
const typename InitialRefinement::type& initial_refinement,
const typename InitialGridPoints::type& initial_number_of_grid_points,
const bool use_equiangular_map,
Expand Down Expand Up @@ -114,7 +114,7 @@ BinaryCompactObject<UseWorldtube>::BinaryCompactObject(
// Determination of parameters for domain construction:
const double tan_half_opening_angle = tan(0.5 * opening_angle_);
translation_ = 0.5 * (x_coord_a_ + x_coord_b_);
length_inner_cube_ = cube_length.value_or(x_coord_a_ - x_coord_b_);
length_inner_cube_ = cube_scale * (x_coord_a_ - x_coord_b_);
if (length_inner_cube_ < (x_coord_a_ - x_coord_b_)) {
PARSE_ERROR(
context,
Expand Down Expand Up @@ -229,8 +229,8 @@ BinaryCompactObject<UseWorldtube>::BinaryCompactObject(
if ((filled_excision_a or filled_excision_b) and
not equal_within_roundoff(offset_x_coord_a_, 0.0)) {
PARSE_ERROR(context,
"Setting CubeLength > X_Coord_A - X_Coord_B is not supported "
"for domains with ExciseInterior = False. Consider using "
"Setting CubeScale > 1.0 is not supported for domains with "
"ExciseInterior = False. Consider using "
"CartesianCubeAtX for the Object without an excised interior.");
}

Expand Down
27 changes: 14 additions & 13 deletions src/Domain/Creators/BinaryCompactObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ create_grid_anchors(const std::array<double, 3>& center_a,
* - The cubes are first constructed at the origin. Then, they are translated
* left/right by their Object's x-coordinate and offset depending on the cube
* length.
* - The CubeLength option describes the length of the cube surrounding object
* A/B. It must be greater than or equal to the physical separation between
* the two objects. If CubeLength is greater than the physical separation, the
* centers of the two objects will be offset relative to the centers of the
* cubes.
* - The CubeScale option describes how to scale the length of the cube
* surrounding object A/B. It must be greater than or equal to 1.0 with 1.0
* meaning the side length of the cube is the initial physical separation
* between the two objects. If CubeScale is greater than 1.0, the centers of
* the two objects will be offset relative to the centers of the cubes.
* - Alternatively, one can replace the inner shell and cube blocks of each
* object with a single cartesian cube. This is less efficient, but allows
* testing of methods only coded on cartesian grids.
Expand Down Expand Up @@ -384,13 +384,14 @@ class BinaryCompactObject : public DomainCreator<3> {
" outer shell into six Blocks of equal angular size."};
};

struct CubeLength {
using type = Options::Auto<double>;
struct CubeScale {
using type = double;
static constexpr Options::String help = {
"Specify the desired cube length that must be greater than or equal to "
"the initial separation between the two objects. The cube is that "
"which surrounds each object. Setting to 'Auto' makes the CubeLength "
"equal to the initial separation."};
"Specify the desired cube scale that must be greater than or equal to "
"1.0. The initial separation is multiplied by this cube scale to "
"produce larger cubes around each object which is desirable when "
"closer to merger."};
static double lower_bound() { return 1.0; }
};

struct InitialRefinement {
Expand Down Expand Up @@ -458,7 +459,7 @@ class BinaryCompactObject : public DomainCreator<3> {
template <typename Metavariables>
using options = tmpl::append<
tmpl::list<ObjectA, ObjectB, CenterOfMassOffset, EnvelopeRadius,
OuterRadius, CubeLength, InitialRefinement, InitialGridPoints,
OuterRadius, CubeScale, InitialRefinement, InitialGridPoints,
UseEquiangularMap, RadialDistributionEnvelope,
RadialDistributionOuterShell, OpeningAngle, TimeDependentMaps>,
tmpl::conditional_t<
Expand Down Expand Up @@ -497,7 +498,7 @@ class BinaryCompactObject : public DomainCreator<3> {
BinaryCompactObject(
typename ObjectA::type object_A, typename ObjectB::type object_B,
std::array<double, 2> center_of_mass_offset, double envelope_radius,
double outer_radius, std::optional<double> cube_length,
double outer_radius, double cube_scale,
const typename InitialRefinement::type& initial_refinement,
const typename InitialGridPoints::type& initial_number_of_grid_points,
bool use_equiangular_map = true,
Expand Down
2 changes: 1 addition & 1 deletion support/Pipelines/Bbh/InitialData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ DomainCreator:
OpeningAngle: 120.0
BoundaryCondition: Robin
UseEquiangularMap: True
CubeLength: Auto
CubeScale: 1.0
InitialRefinement:
ObjectAShell: [{{ L }}, {{ L }}, {{ L }}]
ObjectBShell: [{{ L }}, {{ L }}, {{ L }}]
Expand Down
2 changes: 1 addition & 1 deletion support/Pipelines/Bbh/Inspiral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ DomainCreator:
ConstraintPreservingBjorhus:
Type: ConstraintPreservingPhysical
UseEquiangularMap: True
CubeLength: Auto
CubeScale: 1.0
# These values have been tested to be stable for full equal mass mergers
# with constraints ~10^-7 for L=1, P=10
InitialRefinement:
Expand Down
2 changes: 1 addition & 1 deletion tests/InputFiles/CurvedScalarWave/WorldtubeKerrSchild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ DomainCreator:
ExciseWithBoundaryCondition: Worldtube
UseLogarithmicMap: false
CenterOfMassOffset: [0., 0.]
CubeLength: Auto
CubeScale: 1.0
Envelope:
RadialDistribution: Linear
Radius: 50.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DomainCreator:
RadialDistribution: Linear
OpeningAngle: 90.0
UseEquiangularMap: True
CubeLength: Auto
CubeScale: 1.0
InitialRefinement:
ObjectAShell: [1, 1, 1]
ObjectBShell: [1, 1, 1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ DomainCreator:
ConstraintPreservingFreeOutflow:
Type: ConstraintPreservingPhysical
UseEquiangularMap: False
CubeLength: Auto
CubeScale: 1.0
InitialRefinement:
ObjectA: [4, 4, 4]
ObjectB: [4, 4, 4]
Expand Down
2 changes: 1 addition & 1 deletion tests/InputFiles/Xcts/BinaryBlackHole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ DomainCreator:
OpeningAngle: 120.0
BoundaryCondition: Flatness
UseEquiangularMap: True
CubeLength: Auto
CubeScale: 1.0
InitialRefinement:
ObjectAShell: [0, 0, 0]
ObjectBShell: [0, 0, 0]
Expand Down
2 changes: 1 addition & 1 deletion tests/InputFiles/Xcts/HeadOnBns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DomainCreator:
OpeningAngle: 90.0
BoundaryCondition: Flatness
UseEquiangularMap: True
CubeLength: Auto
CubeScale: 1.0
# This h-refinement is set up so spherical wedges have equal angular size.
# Once the domain supports equatorial compression (or similar) this
# h-refinement will simplify considerably.
Expand Down
58 changes: 27 additions & 31 deletions tests/Unit/Domain/Creators/Test_BinaryCompactObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,13 @@ void test_connectivity() {
constexpr double outer_radius = 32.4;

// Cube length array with and without offsets:
const std::array<double, 2> cube_lengths = {
{xcoord_objectA - xcoord_objectB,
1.5 * (xcoord_objectA - xcoord_objectB)}};
const std::array<double, 2> cube_scales = {{1.0, 1.5}};

// Misc.:
constexpr size_t grid_points = 3;
constexpr bool use_equiangular_map = true;

for (const auto& cube_length : cube_lengths) {
for (const auto& cube_scale : cube_scales) {
for (const auto& [with_boundary_conditions, excise_interiorA,
excise_interiorB, opening_angle,
radial_distribution_envelope,
Expand All @@ -136,7 +134,7 @@ void test_connectivity() {
CAPTURE(excise_interiorA);
CAPTURE(excise_interiorB);
CAPTURE(opening_angle);
CAPTURE(cube_length);
CAPTURE(cube_scale);
CAPTURE(inner_radius_objectA);
CAPTURE(outer_radius_objectA);
CAPTURE(inner_radius_objectB);
Expand Down Expand Up @@ -176,8 +174,8 @@ void test_connectivity() {
envelope_radius,
outer_radius,
(excise_interiorA and excise_interiorB and opening_angle == 90)
? cube_length
: cube_lengths[0],
? cube_scale
: cube_scales[0],
refinement,
grid_points,
use_equiangular_map,
Expand Down Expand Up @@ -299,8 +297,8 @@ void test_connectivity() {
: std::nullopt,
false},
center_of_mass_offset, envelope_radius, outer_radius,
(excise_interiorA and excise_interiorB) ? cube_length
: cube_lengths[0],
(excise_interiorA and excise_interiorB) ? cube_scale
: cube_scales[0],
refinement, grid_points, use_equiangular_map,
radial_distribution_envelope, radial_distribution_outer_shell,
opening_angle, std::nullopt, std::make_unique<PeriodicBc>(),
Expand All @@ -324,8 +322,8 @@ void test_connectivity() {
: std::nullopt,
false},
center_of_mass_offset, envelope_radius, outer_radius,
(excise_interiorA and excise_interiorB) ? cube_length
: cube_lengths[0],
(excise_interiorA and excise_interiorB) ? cube_scale
: cube_scales[0],
refinement, grid_points, use_equiangular_map,
radial_distribution_envelope, radial_distribution_outer_shell,
opening_angle, std::nullopt,
Expand All @@ -351,8 +349,8 @@ void test_connectivity() {
: std::nullopt,
false},
center_of_mass_offset, envelope_radius, outer_radius,
(excise_interiorA and excise_interiorB) ? cube_length
: cube_lengths[0],
(excise_interiorA and excise_interiorB) ? cube_scale
: cube_scales[0],
refinement, grid_points, use_equiangular_map,
radial_distribution_envelope, radial_distribution_outer_shell,
opening_angle, std::nullopt, nullptr,
Expand All @@ -375,8 +373,8 @@ void test_connectivity() {
: std::nullopt,
false},
center_of_mass_offset, envelope_radius, outer_radius,
(excise_interiorA and excise_interiorB) ? cube_length
: cube_lengths[0],
(excise_interiorA and excise_interiorB) ? cube_scale
: cube_scales[0],
refinement, grid_points, use_equiangular_map,
radial_distribution_envelope, radial_distribution_outer_shell,
opening_angle, std::nullopt,
Expand All @@ -400,7 +398,7 @@ std::string create_option_string(
const size_t additional_refinement_A, const size_t additional_refinement_B,
const double opening_angle, const bool add_boundary_condition) {
const std::string cube_length =
(excise_A and excise_B and opening_angle == 90) ? "7.5" : "Auto";
(excise_A and excise_B and opening_angle == 90) ? "1.5" : "1.0";
const std::string time_dependence{
add_time_dependence
? " TimeDependentMaps:\n"
Expand Down Expand Up @@ -492,7 +490,7 @@ std::string create_option_string(
std::to_string(1 + additional_refinement_outer) +
"]\n"
" InitialGridPoints: 3\n" +
" CubeLength: " + cube_length +
" CubeScale: " + cube_length +
"\n"
" UseEquiangularMap: " +
stringize(use_equiangular_map) + "\n" + time_dependence;
Expand Down Expand Up @@ -521,9 +519,7 @@ void test_bns_domain_with_cubes() {
constexpr double opening_angle = 90.0;

// Cube length array with and without offsets:
const std::array<double, 2> cube_lengths = {
{xcoord_objectA - xcoord_objectB,
1.25 * (xcoord_objectA - xcoord_objectB)}};
const std::array<double, 2> cube_scales = {{1.0, 1.5}};

// Misc.:
constexpr size_t grid_points = 3;
Expand All @@ -537,14 +533,14 @@ void test_bns_domain_with_cubes() {
{"Envelope", {{1, 1, 1}}},
{"OuterShell", {{1, 1, 4}}}};

for (const auto cube_length : cube_lengths) {
for (const auto cube_scale : cube_scales) {
const domain::creators::BinaryCompactObject binary_compact_object{
CartesianCubeAtXCoord{xcoord_objectA},
CartesianCubeAtXCoord{xcoord_objectB},
center_of_mass_offset,
envelope_radius,
outer_radius,
cube_length,
cube_scale,
refinement,
grid_points,
use_equiangular_map,
Expand Down Expand Up @@ -758,7 +754,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{0.3, 1.0, 8.0, {{create_inner_boundary_condition()}}, false},
Object{0.5, 1.0, -7.0, {{create_inner_boundary_condition()}}, false},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 15.0, 2_st, 6_st, true,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 1.0, 2_st, 6_st, true,
Distribution::Projective, Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::ContainsSubstring(
Expand All @@ -768,7 +764,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{0.3, 1.0, 8.0, {{create_inner_boundary_condition()}}, false},
Object{0.5, 1.0, -7.0, {{create_inner_boundary_condition()}}, false},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 10.0, 2_st, 6_st, true,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 0.5, 2_st, 6_st, true,
Distribution::Projective, Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::ContainsSubstring(
Expand All @@ -778,7 +774,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{0.3, 1.0, 1.0, {{create_inner_boundary_condition()}}, false},
Object{1.5, 1.0, -1.0, {{create_inner_boundary_condition()}}, false},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 2.0, 2_st, 6_st, true,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 1.0, 2_st, 6_st, true,
Distribution::Projective, Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::ContainsSubstring(
Expand All @@ -787,7 +783,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{3.3, 1.0, 1.0, {{create_inner_boundary_condition()}}, false},
Object{0.5, 1.0, -1.0, {{create_inner_boundary_condition()}}, false},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 2.0, 2_st, 6_st, true,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 1.0, 2_st, 6_st, true,
Distribution::Projective, Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::ContainsSubstring(
Expand All @@ -796,7 +792,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{0.3, 1.0, 1.0, {{create_inner_boundary_condition()}}, false},
Object{0.5, 1.0, -1.0, std::nullopt, true},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 2.0, 2_st, true, 6_st,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 1.0, 2_st, true, 6_st,
Distribution::Projective, Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::ContainsSubstring(
Expand All @@ -807,7 +803,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{0.3, 1.0, 1.0, std::nullopt, true},
Object{0.5, 1.0, -1.0, {{create_inner_boundary_condition()}}, false},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 2.0, 2_st, 6_st, true,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 1.0, 2_st, 6_st, true,
Distribution::Projective, Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::ContainsSubstring(
Expand All @@ -818,7 +814,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{0.3, 1.0, 1.0, {{create_inner_boundary_condition()}}, false},
Object{0.5, 1.0, -1.0, {{create_inner_boundary_condition()}}, false},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 2.0,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 1.0,
std::vector<std::array<size_t, 3>>{}, 6_st, true,
Distribution::Projective, Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Expand All @@ -827,7 +823,7 @@ void test_parse_errors() {
domain::creators::BinaryCompactObject(
Object{0.3, 1.0, 1.0, {{create_inner_boundary_condition()}}, false},
Object{0.5, 1.0, -1.0, {{create_inner_boundary_condition()}}, false},
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 2.0, 2_st,
std::array<double, 2>{{0.1, 0.2}}, 25.5, 32.4, 1.0, 2_st,
std::vector<std::array<size_t, 3>>{}, true, Distribution::Projective,
Distribution::Linear, 120.0, std::nullopt,
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Expand Down Expand Up @@ -857,7 +853,7 @@ void test_kerr_horizon_conforming() {
std::array<double, 2>{{0.1, 0.2}},
40.,
200.,
16.0,
1.0,
0_st,
6_st,
true,
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/Domain/Creators/Test_Tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ void test_center_tags() {
const std::unique_ptr<DomainCreator<3>> domain_creator =
std::make_unique<domain::creators::BinaryCompactObject<false>>(
Object{0.2, 5.0, 8.0, true, true}, Object{0.6, 4.0, -5.5, true, true},
std::array<double, 2>{{0.1, 0.2}}, 100.0, 500.0, std::nullopt, 1_st,
5_st);
std::array<double, 2>{{0.1, 0.2}}, 100.0, 500.0, 1.0, 1_st, 5_st);

const auto grid_center_A =
Tags::ObjectCenter<ObjectLabel::A>::create_from_options(domain_creator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ SPECTRE_TEST_CASE(
std::array<double, 2>{{0.1, 0.2}},
30.,
50.,
std::nullopt,
1.0,
initial_refinement,
initial_extents};
test_initialize_element_faces_coordinates_map(binary_compact_object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::unique_ptr<DomainCreator<3>> worldtube_binary_compact_object(
" InitialRefinement: 0\n"
" InitialGridPoints: 3\n"
" UseEquiangularMap: true\n"
" CubeLength: Auto\n"
" CubeScale: 1.0\n"
" TimeDependentMaps:\n"
" InitialTime: 0.0\n"
" ExpansionMap: \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ void test_interpolate_on_element(
return std::make_unique<BCO>(
BCO::Object{0.9, 2.9, 4.0, true, true},
BCO::Object{0.9, 2.9, -4.0, true, true},
std::array<double, 2>{{0.1, 0.2}}, 20.0, 100.0, std::nullopt,
std::array<double, 2>{{0.1, 0.2}}, 20.0, 100.0, 1.0,
// Only object B needs to have the refinement for this test
std::unordered_map<std::string, std::array<size_t, 3>>{
{"ObjectAShell", std::array{0_st, 0_st, 0_st}},
Expand Down
Loading

0 comments on commit 8e8fe3f

Please sign in to comment.