Skip to content

Commit

Permalink
Merge pull request #6115 from knelli2/dc_time_dep_opts_4
Browse files Browse the repository at this point in the history
Use new common time dependent options in Sphere and BCO domains
  • Loading branch information
nilsvu authored Jan 15, 2025
2 parents db753a3 + a212151 commit e1cd936
Show file tree
Hide file tree
Showing 53 changed files with 1,978 additions and 1,961 deletions.
216 changes: 105 additions & 111 deletions src/Domain/Creators/TimeDependentOptions/BinaryCompactObject.cpp

Large diffs are not rendered by default.

128 changes: 27 additions & 101 deletions src/Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
#include "Domain/CoordinateMaps/TimeDependent/Rotation.hpp"
#include "Domain/CoordinateMaps/TimeDependent/Shape.hpp"
#include "Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/ShapeMapTransitionFunction.hpp"
#include "Domain/Creators/TimeDependentOptions/ExpansionMap.hpp"
#include "Domain/Creators/TimeDependentOptions/RotationMap.hpp"
#include "Domain/Creators/TimeDependentOptions/ShapeMap.hpp"
#include "Domain/Creators/TimeDependentOptions/Sphere.hpp"
#include "Domain/Creators/TimeDependentOptions/TranslationMap.hpp"
#include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
#include "Domain/Structure/ObjectLabel.hpp"
#include "Options/Auto.hpp"
Expand Down Expand Up @@ -146,105 +148,30 @@ struct TimeDependentMapOptions {
/// The outer boundary radius of the map is always set to
/// the outer boundary of the Domain, so there is no option
/// here to set the outer boundary radius.
struct ExpansionMapOptions {
using type = Options::Auto<ExpansionMapOptions, Options::AutoLabel::None>;
static std::string name() { return "ExpansionMap"; }
static constexpr Options::String help = {
"Options for the expansion map. Specify 'None' to not use this map."};
struct InitialValues {
using type = std::array<double, 2>;
static constexpr Options::String help = {
"Initial value and deriv of expansion."};
};
struct AsymptoticVelocityOuterBoundary {
using type = double;
static constexpr Options::String help = {
"The asymptotic velocity of the outer boundary."};
};
struct DecayTimescaleOuterBoundaryVelocity {
using type = double;
static constexpr Options::String help = {
"The timescale for how fast the outer boundary velocity approaches "
"its asymptotic value."};
};
using options = tmpl::list<InitialValues, AsymptoticVelocityOuterBoundary,
DecayTimescaleOuterBoundaryVelocity>;
ExpansionMapOptions() = default;
ExpansionMapOptions(std::array<double, 2> initial_values_in,
double outer_boundary_velocity_in,
double outer_boundary_decay_time_in)
: initial_values(initial_values_in),
outer_boundary_velocity(outer_boundary_velocity_in),
outer_boundary_decay_time(outer_boundary_decay_time_in) {}

std::array<double, 2> initial_values{
std::numeric_limits<double>::signaling_NaN(),
std::numeric_limits<double>::signaling_NaN()};
double outer_boundary_velocity{
std::numeric_limits<double>::signaling_NaN()};
double outer_boundary_decay_time{
std::numeric_limits<double>::signaling_NaN()};
};

struct RotationMapOptions {
using type = Options::Auto<RotationMapOptions, Options::AutoLabel::None>;
static std::string name() { return "RotationMap"; }
static constexpr Options::String help = {
"Options for a time-dependent rotation map about an arbitrary axis. "
"Specify 'None' to not use this map."};

struct InitialAngularVelocity {
using type = std::array<double, 3>;
static constexpr Options::String help = {"The initial angular velocity."};
};
using ExpansionMapOptions =
domain::creators::time_dependent_options::ExpansionMapOptions<false>;
using ExpansionMapOptionType = typename ExpansionMapOptions::type::value_type;

using options = tmpl::list<InitialAngularVelocity>;

RotationMapOptions() = default;
explicit RotationMapOptions(
std::array<double, 3> initial_angular_velocity_in)
: initial_angular_velocity(initial_angular_velocity_in) {}

std::array<double, 3> initial_angular_velocity{};
};
/// \brief Options for the rotation map
using RotationMapOptions =
domain::creators::time_dependent_options::RotationMapOptions<false>;
using RotationMapOptionType = typename RotationMapOptions::type::value_type;

/// \brief Options for the Translation Map, the outer radius is always set to
/// the outer boundary of the Domain, so there's no option needed for outer
/// boundary.
struct TranslationMapOptions {
using type = Options::Auto<TranslationMapOptions, Options::AutoLabel::None>;
static std::string name() { return "TranslationMap"; }
static constexpr Options::String help = {
"Options for a time-dependent translation map. Specify 'None' to not "
"use this map."};

struct InitialValues {
using type = std::array<std::array<double, 3>, 3>;
static constexpr Options::String help = {
"Initial position, velocity and acceleration."};
};

using options = tmpl::list<InitialValues>;
TranslationMapOptions() = default;
explicit TranslationMapOptions(
std::array<std::array<double, 3>, 3> initial_values_in)
: initial_values(initial_values_in) {}
using TranslationMapOptions =
domain::creators::time_dependent_options::TranslationMapOptions<3>;
using TranslationMapOptionType =
typename TranslationMapOptions::type::value_type;

std::array<std::array<double, 3>, 3> initial_values{};
};

// We use a type alias here instead of defining the ShapeMapOptions struct
// because there appears to be a bug in clang-10. If the definition of
// ShapeMapOptions is here inside TimeDependentMapOptions, on clang-10 there
// is a linking error that there is an undefined reference to
// Options::Option::parse_as<TimeDependentMapOptions<A>> (and B). This doesn't
// show up for GCC. If we put the definition of ShapeMapOptions outside of
// TimeDependentMapOptions and just use a type alias here, the linking error
// goes away.
/// \brief Options for the shape map
template <domain::ObjectLabel Object>
using ShapeMapOptions =
domain::creators::time_dependent_options::ShapeMapOptions<
not IsCylindrical, Object>;
template <domain::ObjectLabel Object>
using ShapeMapOptionType = typename ShapeMapOptions<Object>::type::value_type;

using options =
tmpl::list<InitialTime, ExpansionMapOptions, RotationMapOptions,
Expand All @@ -257,12 +184,11 @@ struct TimeDependentMapOptions {
TimeDependentMapOptions() = default;

TimeDependentMapOptions(
double initial_time,
std::optional<ExpansionMapOptions> expansion_map_options,
std::optional<RotationMapOptions> rotation_map_options,
std::optional<TranslationMapOptions> translation_map_options,
std::optional<ShapeMapOptions<domain::ObjectLabel::A>> shape_options_A,
std::optional<ShapeMapOptions<domain::ObjectLabel::B>> shape_options_B,
double initial_time, ExpansionMapOptionType expansion_map_options,
RotationMapOptionType rotation_map_options,
TranslationMapOptionType translation_map_options,
ShapeMapOptionType<domain::ObjectLabel::A> shape_options_A,
ShapeMapOptionType<domain::ObjectLabel::B> shape_options_B,
const Options::Context& context = {});

/*!
Expand Down Expand Up @@ -407,11 +333,11 @@ struct TimeDependentMapOptions {
static size_t get_index(domain::ObjectLabel object);

double initial_time_{std::numeric_limits<double>::signaling_NaN()};
std::optional<ExpansionMapOptions> expansion_map_options_{};
std::optional<RotationMapOptions> rotation_map_options_{};
std::optional<TranslationMapOptions> translation_map_options_{};
std::optional<ShapeMapOptions<domain::ObjectLabel::A>> shape_options_A_{};
std::optional<ShapeMapOptions<domain::ObjectLabel::B>> shape_options_B_{};
ExpansionMapOptionType expansion_map_options_;
RotationMapOptionType rotation_map_options_;
TranslationMapOptionType translation_map_options_;
ShapeMapOptionType<domain::ObjectLabel::A> shape_options_A_{};
ShapeMapOptionType<domain::ObjectLabel::B> shape_options_B_{};
std::array<std::optional<double>, 2> deformed_radii_{};

// Maps
Expand Down
Loading

0 comments on commit e1cd936

Please sign in to comment.