Skip to content

Commit

Permalink
CylBinaryCompactObject: add equiangular map.
Browse files Browse the repository at this point in the history
  • Loading branch information
markscheel committed Feb 6, 2023
1 parent 8ac60c0 commit b87e8d7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
15 changes: 9 additions & 6 deletions src/Domain/Creators/CylindricalBinaryCompactObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ CylindricalBinaryCompactObject::CylindricalBinaryCompactObject(
typename IncludeInnerSphereB::type include_inner_sphere_B,
typename IncludeOuterSphere::type include_outer_sphere,
typename OuterRadius::type outer_radius,
typename UseEquiangularMap::type use_equiangular_map,
const typename InitialRefinement::type& initial_refinement,
const typename InitialGridPoints::type& initial_grid_points,
std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
Expand All @@ -78,6 +79,7 @@ CylindricalBinaryCompactObject::CylindricalBinaryCompactObject(
include_inner_sphere_B_(include_inner_sphere_B),
include_outer_sphere_(include_outer_sphere),
outer_radius_(outer_radius),
use_equiangular_map_(use_equiangular_map),
inner_boundary_condition_(std::move(inner_boundary_condition)),
outer_boundary_condition_(std::move(outer_boundary_condition)) {
if (center_A_[2] <= 0.0) {
Expand Down Expand Up @@ -372,6 +374,7 @@ CylindricalBinaryCompactObject::CylindricalBinaryCompactObject(
typename IncludeInnerSphereB::type include_inner_sphere_B,
typename IncludeOuterSphere::type include_outer_sphere,
typename OuterRadius::type outer_radius,
typename UseEquiangularMap::type use_equiangular_map,
const typename InitialRefinement::type& initial_refinement,
const typename InitialGridPoints::type& initial_grid_points,
std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
Expand All @@ -382,7 +385,7 @@ CylindricalBinaryCompactObject::CylindricalBinaryCompactObject(
: CylindricalBinaryCompactObject(
center_A, center_B, radius_A, radius_B, include_inner_sphere_A,
include_inner_sphere_B, include_outer_sphere, outer_radius,
initial_refinement, initial_grid_points,
use_equiangular_map, initial_refinement, initial_grid_points,
std::move(inner_boundary_condition),
std::move(outer_boundary_condition), context) {
is_time_dependent_ = true;
Expand Down Expand Up @@ -442,13 +445,13 @@ Domain<3> CylindricalBinaryCompactObject::create_domain() const {
const double cylinder_lower_bound_z = -1.0;
const double cylinder_upper_bound_z = 1.0;
const auto logical_to_cylinder_center_maps =
cyl_wedge_coord_map_center_blocks(cylinder_inner_radius,
cylinder_lower_bound_z,
cylinder_upper_bound_z, false);
cyl_wedge_coord_map_center_blocks(
cylinder_inner_radius, cylinder_lower_bound_z, cylinder_upper_bound_z,
use_equiangular_map_);
const auto logical_to_cylinder_surrounding_maps =
cyl_wedge_coord_map_surrounding_blocks(
cylinder_inner_radius, cylinder_outer_radius, cylinder_lower_bound_z,
cylinder_upper_bound_z, false, 0.0);
cylinder_upper_bound_z, use_equiangular_map_, 0.0);

// Lambda that takes a UniformCylindricalEndcap map and a
// DiscreteRotation map, composes it with the logical-to-cylinder
Expand Down Expand Up @@ -526,7 +529,7 @@ Domain<3> CylindricalBinaryCompactObject::create_domain() const {
cyl_wedge_coord_map_surrounding_blocks(
cylindrical_shell_inner_radius, cylindrical_shell_outer_radius,
cylindrical_shell_lower_bound_z, cylindrical_shell_upper_bound_z,
false, 1.0);
use_equiangular_map_, 1.0);

// Lambda that takes a UniformCylindricalSide map and a DiscreteRotation
// map, composes it with the logical-to-cylinder maps, and adds it
Expand Down
10 changes: 10 additions & 0 deletions src/Domain/Creators/CylindricalBinaryCompactObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ class CylindricalBinaryCompactObject : public DomainCreator<3> {
static constexpr Options::String help = {
"Grid-coordinate radius of outer boundary."};
};
struct UseEquiangularMap {
using type = bool;
static constexpr Options::String help = {
"Distribute grid points equiangularly in 2d wedges."};
static bool suggested_value() { return false; }
};

struct InitialRefinement {
using type =
Expand Down Expand Up @@ -334,6 +340,7 @@ class CylindricalBinaryCompactObject : public DomainCreator<3> {
using time_independent_options =
tmpl::list<CenterA, CenterB, RadiusA, RadiusB, IncludeInnerSphereA,
IncludeInnerSphereB, IncludeOuterSphere, OuterRadius,
UseEquiangularMap,
InitialRefinement, InitialGridPoints>;
using time_dependent_options =
tmpl::list<InitialTime, ExpansionMap, InitialAngularVelocity>;
Expand Down Expand Up @@ -371,6 +378,7 @@ class CylindricalBinaryCompactObject : public DomainCreator<3> {
typename IncludeInnerSphereB::type include_inner_sphere_B,
typename IncludeOuterSphere::type include_outer_sphere,
typename OuterRadius::type outer_radius,
typename UseEquiangularMap::type use_equiangular_map,
const typename InitialRefinement::type& initial_refinement,
const typename InitialGridPoints::type& initial_grid_points,
std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
Expand All @@ -388,6 +396,7 @@ class CylindricalBinaryCompactObject : public DomainCreator<3> {
typename IncludeInnerSphereB::type include_inner_sphere_B,
typename IncludeOuterSphere::type include_outer_sphere,
typename OuterRadius::type outer_radius,
typename UseEquiangularMap::type use_equiangular_map,
const typename InitialRefinement::type& initial_refinement,
const typename InitialGridPoints::type& initial_grid_points,
std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
Expand Down Expand Up @@ -443,6 +452,7 @@ class CylindricalBinaryCompactObject : public DomainCreator<3> {
typename IncludeInnerSphereB::type include_inner_sphere_B_{};
typename IncludeOuterSphere::type include_outer_sphere_{};
typename OuterRadius::type outer_radius_{};
bool use_equiangular_map_{false};
typename std::vector<std::array<size_t, 3>> initial_refinement_{};
typename std::vector<std::array<size_t, 3>> initial_grid_points_{};
// cut_spheres_offset_factor_ is eta in Eq. (A.9) of
Expand Down
38 changes: 23 additions & 15 deletions tests/Unit/Domain/Creators/Test_CylindricalBinaryCompactObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ create_outer_boundary_condition() {
void test_connectivity_once(const bool with_sphere_e,
const bool include_inner_sphere_A,
const bool include_inner_sphere_B,
const bool include_outer_sphere) {
const bool include_outer_sphere,
const bool use_equiangular_map) {
// Misc.:
constexpr size_t refinement = 1;
constexpr size_t grid_points = 3;
Expand Down Expand Up @@ -130,6 +131,7 @@ void test_connectivity_once(const bool with_sphere_e,
include_inner_sphere_B,
include_outer_sphere,
outer_radius,
use_equiangular_map,
refinement,
grid_points,
with_boundary_conditions ? create_inner_boundary_condition()
Expand Down Expand Up @@ -310,7 +312,8 @@ void test_connectivity_once(const bool with_sphere_e,
center_objectA, center_objectB, inner_radius_objectA,
inner_radius_objectB, include_inner_sphere_A,
include_inner_sphere_B, include_outer_sphere, outer_radius,
refinement, grid_points, create_inner_boundary_condition(),
use_equiangular_map, refinement, grid_points,
create_inner_boundary_condition(),
std::make_unique<TestHelpers::domain::BoundaryConditions::
TestPeriodicBoundaryCondition<3>>(),
Options::Context{false, {}, 1, 1}),
Expand All @@ -321,7 +324,7 @@ void test_connectivity_once(const bool with_sphere_e,
center_objectA, center_objectB, inner_radius_objectA,
inner_radius_objectB, include_inner_sphere_A,
include_inner_sphere_B, include_outer_sphere, outer_radius,
refinement, grid_points,
use_equiangular_map, refinement, grid_points,
std::make_unique<TestHelpers::domain::BoundaryConditions::
TestPeriodicBoundaryCondition<3>>(),
create_outer_boundary_condition(),
Expand All @@ -333,7 +336,7 @@ void test_connectivity_once(const bool with_sphere_e,
center_objectA, center_objectB, inner_radius_objectA,
inner_radius_objectB, include_inner_sphere_A,
include_inner_sphere_B, include_outer_sphere, outer_radius,
refinement, grid_points, nullptr,
use_equiangular_map, refinement, grid_points, nullptr,
create_outer_boundary_condition(),
Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains(
Expand All @@ -344,8 +347,9 @@ void test_connectivity_once(const bool with_sphere_e,
center_objectA, center_objectB, inner_radius_objectA,
inner_radius_objectB, include_inner_sphere_A,
include_inner_sphere_B, include_outer_sphere, outer_radius,
refinement, grid_points, create_inner_boundary_condition(),
nullptr, Options::Context{false, {}, 1, 1}),
use_equiangular_map, refinement, grid_points,
create_inner_boundary_condition(), nullptr,
Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains(
"Must specify either both inner and outer boundary "
"conditions or neither."));
Expand All @@ -364,8 +368,11 @@ void test_connectivity() {
CAPTURE(include_inner_sphere_A);
for (const bool include_inner_sphere_B : {true, false}) {
CAPTURE(include_inner_sphere_B);
test_connectivity_once(with_sphere_e, include_inner_sphere_A,
include_inner_sphere_B, include_outer_sphere);
for (const bool use_equiangular_map : {true, false}) {
test_connectivity_once(with_sphere_e, include_inner_sphere_A,
include_inner_sphere_B, include_outer_sphere,
use_equiangular_map);
}
}
}
}
Expand Down Expand Up @@ -403,6 +410,7 @@ std::string create_option_string(
" CenterB: [-3.0, 0.05, 0.0]\n"
" RadiusB: 1.0\n"
" OuterRadius: 25.0\n"
" UseEquiangularMap: false\n"
" IncludeInnerSphereA: False\n"
" IncludeInnerSphereB: False\n"
" IncludeOuterSphere: False\n"
Expand Down Expand Up @@ -559,47 +567,47 @@ void test_parse_errors() {
CHECK_THROWS_WITH(
domain::creators::CylindricalBinaryCompactObject(
{{2.0, 0.05, 0.0}}, {-5.0, 0.05, 0.0}, 1.0, 0.4, false, false, false,
1.0, 1_st, 3_st, create_inner_boundary_condition(),
1.0, false, 1_st, 3_st, create_inner_boundary_condition(),
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains("OuterRadius is too small"));
CHECK_THROWS_WITH(
domain::creators::CylindricalBinaryCompactObject(
{{-2.0, 0.05, 0.0}}, {-5.0, 0.05, 0.0}, 1.0, 0.4, false, false, false,
25.0, 1_st, 3_st, create_inner_boundary_condition(),
25.0, false, 1_st, 3_st, create_inner_boundary_condition(),
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains(
"The x-coordinate of the input CenterA is expected to be positive"));
CHECK_THROWS_WITH(
domain::creators::CylindricalBinaryCompactObject(
{{2.0, 0.05, 0.0}}, {5.0, 0.05, 0.0}, 1.0, 0.4, false, false, false,
25.0, 1_st, 3_st, create_inner_boundary_condition(),
25.0, false, 1_st, 3_st, create_inner_boundary_condition(),
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains(
"The x-coordinate of the input CenterB is expected to be negative"));
CHECK_THROWS_WITH(
domain::creators::CylindricalBinaryCompactObject(
{{2.0, 0.05, 0.0}}, {-5.0, 0.05, 0.0}, -1.0, 0.4, false, false, false,
25.0, 1_st, 3_st, create_inner_boundary_condition(),
25.0, false, 1_st, 3_st, create_inner_boundary_condition(),
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains("RadiusA and RadiusB are expected "
"to be positive"));
CHECK_THROWS_WITH(
domain::creators::CylindricalBinaryCompactObject(
{{2.0, 0.05, 0.0}}, {-5.0, 0.05, 0.0}, 1.0, -0.4, false, false, false,
25.0, 1_st, 3_st, create_inner_boundary_condition(),
25.0, false, 1_st, 3_st, create_inner_boundary_condition(),
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains("RadiusA and RadiusB are expected "
"to be positive"));
CHECK_THROWS_WITH(
domain::creators::CylindricalBinaryCompactObject(
{{2.0, 0.05, 0.0}}, {-5.0, 0.05, 0.0}, 0.15, 0.4, false, false, false,
25.0, 1_st, 3_st, create_inner_boundary_condition(),
25.0, false, 1_st, 3_st, create_inner_boundary_condition(),
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains("RadiusA should not be smaller than RadiusB"));
CHECK_THROWS_WITH(
domain::creators::CylindricalBinaryCompactObject(
{{2.0, 0.05, 0.0}}, {-1.0, 0.05, 0.0}, 1.0, 0.4, false, false, false,
25.0, 1_st, 3_st, create_inner_boundary_condition(),
25.0, false, 1_st, 3_st, create_inner_boundary_condition(),
create_outer_boundary_condition(), Options::Context{false, {}, 1, 1}),
Catch::Matchers::Contains("We expect |x_A| <= |x_B|"));
// Note: the boundary condition-related parse errors are checked in the
Expand Down

0 comments on commit b87e8d7

Please sign in to comment.