Skip to content

Commit

Permalink
Create spherical shell in Sphere domain
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsvu committed Dec 9, 2024
1 parent fa8604b commit a9e4305
Show file tree
Hide file tree
Showing 14 changed files with 469 additions and 254 deletions.
1 change: 1 addition & 0 deletions src/Domain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ spectre_target_headers(
CreateInitialElement.hpp
Domain.hpp
DomainHelpers.hpp
DomainHelpers.tpp
ElementDistribution.hpp
ElementLogicalCoordinates.hpp
ElementMap.hpp
Expand Down
2 changes: 2 additions & 0 deletions src/Domain/CoordinateMaps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ spectre_target_sources(
Interval.cpp
KerrHorizonConforming.cpp
Rotation.cpp
ShellType.cpp
SpecialMobius.cpp
SphericalToCartesian.cpp
UniformCylindricalEndcap.cpp
Expand Down Expand Up @@ -72,6 +73,7 @@ spectre_target_headers(
ProductMaps.hpp
ProductMaps.tpp
Rotation.hpp
ShellType.hpp
SpecialMobius.hpp
SphericalToCartesian.hpp
Tags.hpp
Expand Down
39 changes: 39 additions & 0 deletions src/Domain/CoordinateMaps/ShellType.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#include "Domain/CoordinateMaps/ShellType.hpp"

#include <ostream>
#include <string>

#include "Options/Options.hpp"
#include "Options/ParseOptions.hpp"
#include "Utilities/ErrorHandling/Error.hpp"

namespace domain::CoordinateMaps {

std::ostream& operator<<(std::ostream& os, const ShellType shell_type) {
switch (shell_type) {
case ShellType::Cubed:
return os << "Cubed";
case ShellType::Spherical:
return os << "Spherical";
default:
ERROR("Unknown domain::CoordinateMaps::ShellType");
}
}

} // namespace domain::CoordinateMaps

template <>
domain::CoordinateMaps::ShellType
Options::create_from_yaml<domain::CoordinateMaps::ShellType>::create<void>(
const Options::Option& options) {
const auto shell_type = options.parse_as<std::string>();
if (shell_type == "Cubed") {
return domain::CoordinateMaps::ShellType::Cubed;
} else if (shell_type == "Spherical") {
return domain::CoordinateMaps::ShellType::Spherical;
}
PARSE_ERROR(options.context(), "ShellType must be 'Cubed' or 'Spherical'.");
}
44 changes: 44 additions & 0 deletions src/Domain/CoordinateMaps/ShellType.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#pragma once

#include <ostream>

/// \cond
namespace Options {
class Option;
template <typename T>
struct create_from_yaml;
} // namespace Options
/// \endcond

namespace domain::CoordinateMaps {

/*!
* \brief Type of spherical shell: built from four (2D) or six (3D) wedges
* ("cubed") or from a single spherical shell ("spherical").
*
* Used to select the shell type in the input file.
*/
enum class ShellType {
Cubed,
Spherical,
};

std::ostream& operator<<(std::ostream& os, ShellType shell_type);

} // namespace domain::CoordinateMaps

template <>
struct Options::create_from_yaml<domain::CoordinateMaps::ShellType> {
template <typename Metavariables>
static domain::CoordinateMaps::ShellType create(
const Options::Option& options) {
return create<void>(options);
}
};
template <>
domain::CoordinateMaps::ShellType
Options::create_from_yaml<domain::CoordinateMaps::ShellType>::create<void>(
const Options::Option& options);
60 changes: 28 additions & 32 deletions src/Domain/Creators/BinaryCompactObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp"
#include "Domain/Domain.hpp"
#include "Domain/DomainHelpers.hpp"
#include "Domain/DomainHelpers.tpp"
#include "Domain/ExcisionSphere.hpp"
#include "Domain/FunctionsOfTime/FixedSpeedCubic.hpp"
#include "Domain/FunctionsOfTime/PiecewisePolynomial.hpp"
Expand Down Expand Up @@ -459,20 +460,18 @@ Domain<3> BinaryCompactObject<UseWorldtube>::create_domain() const {
length_inner_cube_ * 0.5,
std::array<double, 3>{{offset_x_coord_a_, 0.0, 0.0}}));
Maps maps_center_A =
domain::make_vector_coordinate_map_base<Frame::BlockLogical,
Frame::Inertial, 3>(
sph_wedge_coordinate_maps(
object_a.inner_radius, object_a.outer_radius,
inner_sphericity_A, 1.0, use_equiangular_map_,
offset_a_optional, false, {}, object_A_radial_distribution),
translation_A);
spherical_shells_coordinate_maps<Frame::BlockLogical, Frame::Inertial>(
object_a.inner_radius, object_a.outer_radius, inner_sphericity_A,
1.0, use_equiangular_map_, false, {}, object_A_radial_distribution,
{domain::CoordinateMaps::ShellType::Cubed}, ShellWedges::All,
M_PI_2, translation_A);
Maps maps_cube_A =
domain::make_vector_coordinate_map_base<Frame::BlockLogical,
Frame::Inertial, 3>(
sph_wedge_coordinate_maps(
object_a.outer_radius, sqrt(3.0) * 0.5 * length_inner_cube_,
1.0, 0.0, use_equiangular_map_, offset_a_optional),
translation_A);
spherical_shells_coordinate_maps<Frame::BlockLogical, Frame::Inertial>(
object_a.outer_radius, sqrt(3.0) * 0.5 * length_inner_cube_, 1.0,
0.0, use_equiangular_map_, false, {},
{domain::CoordinateMaps::Distribution::Linear},
{domain::CoordinateMaps::ShellType::Cubed}, ShellWedges::All,
M_PI_2, translation_A);
std::move(maps_center_A.begin(), maps_center_A.end(),
std::back_inserter(maps));
std::move(maps_cube_A.begin(), maps_cube_A.end(), std::back_inserter(maps));
Expand Down Expand Up @@ -502,20 +501,18 @@ Domain<3> BinaryCompactObject<UseWorldtube>::create_domain() const {
length_inner_cube_ * 0.5,
std::array<double, 3>{{offset_x_coord_b_, 0.0, 0.0}}));
Maps maps_center_B =
domain::make_vector_coordinate_map_base<Frame::BlockLogical,
Frame::Inertial, 3>(
sph_wedge_coordinate_maps(
object_b.inner_radius, object_b.outer_radius,
inner_sphericity_B, 1.0, use_equiangular_map_,
offset_b_optional, false, {}, object_B_radial_distribution),
translation_B);
spherical_shells_coordinate_maps<Frame::BlockLogical, Frame::Inertial>(
object_b.inner_radius, object_b.outer_radius, inner_sphericity_B,
1.0, use_equiangular_map_, false, {}, object_B_radial_distribution,
{domain::CoordinateMaps::ShellType::Cubed}, ShellWedges::All,
M_PI_2, translation_B);
Maps maps_cube_B =
domain::make_vector_coordinate_map_base<Frame::BlockLogical,
Frame::Inertial, 3>(
sph_wedge_coordinate_maps(
object_b.outer_radius, sqrt(3.0) * 0.5 * length_inner_cube_,
1.0, 0.0, use_equiangular_map_, offset_b_optional),
translation_B);
spherical_shells_coordinate_maps<Frame::BlockLogical, Frame::Inertial>(
object_b.outer_radius, sqrt(3.0) * 0.5 * length_inner_cube_, 1.0,
0.0, use_equiangular_map_, false, {},
{domain::CoordinateMaps::Distribution::Linear},
{domain::CoordinateMaps::ShellType::Cubed}, ShellWedges::All,
M_PI_2, translation_B);
std::move(maps_center_B.begin(), maps_center_B.end(),
std::back_inserter(maps));
std::move(maps_cube_B.begin(), maps_cube_B.end(), std::back_inserter(maps));
Expand Down Expand Up @@ -545,12 +542,11 @@ Domain<3> BinaryCompactObject<UseWorldtube>::create_domain() const {

// --- Outer spherical shell (10 blocks) ---
Maps maps_outer_shell =
domain::make_vector_coordinate_map_base<Frame::BlockLogical,
Frame::Inertial, 3>(
sph_wedge_coordinate_maps(envelope_radius_, outer_radius_, 1.0, 1.0,
use_equiangular_map_, std::nullopt, true,
{}, {radial_distribution_outer_shell_},
ShellWedges::All, opening_angle_));
spherical_shells_coordinate_maps<Frame::BlockLogical, Frame::Inertial>(
envelope_radius_, outer_radius_, 1.0, 1.0, use_equiangular_map_, true,
{}, {radial_distribution_outer_shell_},
{domain::CoordinateMaps::ShellType::Cubed}, ShellWedges::All,
opening_angle_);
std::move(maps_outer_shell.begin(), maps_outer_shell.end(),
std::back_inserter(maps));

Expand Down
Loading

0 comments on commit a9e4305

Please sign in to comment.