Skip to content

Commit

Permalink
Merge pull request #6109 from knelli2/dc_time_dep_opts_1
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsvu committed Jul 4, 2024
2 parents 8cf7a09 + 07b5152 commit b4fd44e
Show file tree
Hide file tree
Showing 36 changed files with 1,024 additions and 167 deletions.
18 changes: 16 additions & 2 deletions src/Domain/Creators/BinaryCompactObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#include "Domain/CoordinateMaps/ProductMaps.hpp"
#include "Domain/CoordinateMaps/ProductMaps.tpp"
#include "Domain/CoordinateMaps/Wedge.hpp"
#include "Domain/Creators/BinaryCompactObjectHelpers.hpp"
#include "Domain/Creators/DomainCreator.hpp" // IWYU pragma: keep
#include "Domain/Creators/ExpandOverBlocks.hpp"
#include "Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp"
#include "Domain/Domain.hpp"
#include "Domain/DomainHelpers.hpp"
#include "Domain/ExcisionSphere.hpp"
Expand All @@ -50,6 +50,20 @@ struct BlockLogical;
} // namespace Frame

namespace domain::creators {
namespace bco {
std::unordered_map<std::string, tnsr::I<double, 3, Frame::Grid>>
create_grid_anchors(const std::array<double, 3>& center_a,
const std::array<double, 3>& center_b) {
std::unordered_map<std::string, tnsr::I<double, 3, Frame::Grid>> result{};
result["Center" + get_output(ObjectLabel::A)] =
tnsr::I<double, 3, Frame::Grid>{center_a};
result["Center" + get_output(ObjectLabel::B)] =
tnsr::I<double, 3, Frame::Grid>{center_b};
result["Center"] = tnsr::I<double, 3, Frame::Grid>{std::array{0.0, 0.0, 0.0}};

return result;
}
} // namespace bco

bool BinaryCompactObject::Object::is_excised() const {
return inner_boundary_condition.has_value();
Expand Down Expand Up @@ -261,7 +275,7 @@ BinaryCompactObject::BinaryCompactObject(
add_object_region("ObjectB", "Cube"); // 6 blocks
first_outer_shell_block_ += 12;
}
add_outer_region("Envelope"); // 10 blocks
add_outer_region("Envelope"); // 10 blocks
first_outer_shell_block_ += 10;
add_outer_region("OuterShell"); // 10 blocks

Expand Down
18 changes: 17 additions & 1 deletion src/Domain/Creators/BinaryCompactObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp"
#include "Domain/CoordinateMaps/CoordinateMap.hpp"
#include "Domain/CoordinateMaps/Distribution.hpp"
#include "Domain/Creators/BinaryCompactObjectHelpers.hpp"
#include "Domain/Creators/DomainCreator.hpp"
#include "Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp"
#include "Domain/Domain.hpp"
#include "Domain/Structure/DirectionMap.hpp"
#include "Options/Auto.hpp"
Expand Down Expand Up @@ -66,6 +66,22 @@ struct BlockLogical;

namespace domain {
namespace creators {
namespace bco {
/*!
* \brief Create a set of centers of objects for the binary domains.
*
* \details Will add the following centers to the set:
*
* - Center: The origin
* - CenterA: Center of object A
* - CenterB: Center of object B
*
* \return Object required by the DomainCreator%s
*/
std::unordered_map<std::string, tnsr::I<double, 3, Frame::Grid>>
create_grid_anchors(const std::array<double, 3>& center_a,
const std::array<double, 3>& center_b);
} // namespace bco

/*!
* \ingroup ComputationalDomainGroup
Expand Down
8 changes: 2 additions & 6 deletions src/Domain/Creators/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ spectre_target_sources(
PRIVATE
AlignedLattice.cpp
BinaryCompactObject.cpp
BinaryCompactObjectHelpers.cpp
BlockGroups.cpp
Brick.cpp
Cylinder.cpp
Expand All @@ -24,9 +23,7 @@ spectre_target_sources(
RotatedBricks.cpp
RotatedIntervals.cpp
RotatedRectangles.cpp
ShapeMapOptions.cpp
Sphere.cpp
SphereTimeDependentMaps.cpp
)

spectre_target_headers(
Expand All @@ -35,7 +32,6 @@ spectre_target_headers(
HEADERS
AlignedLattice.hpp
BinaryCompactObject.hpp
BinaryCompactObjectHelpers.hpp
BlockGroups.hpp
Brick.hpp
Cylinder.hpp
Expand All @@ -56,15 +52,14 @@ spectre_target_headers(
RotatedBricks.hpp
RotatedIntervals.hpp
RotatedRectangles.hpp
ShapeMapOptions.hpp
Sphere.hpp
SphereTimeDependentMaps.hpp
)

target_link_libraries(
${LIBRARY}
PRIVATE
DomainStructure
H5
PUBLIC
CoordinateMaps
DataStructures
Expand All @@ -82,3 +77,4 @@ target_link_libraries(
add_subdirectory(Python)
add_subdirectory(Tags)
add_subdirectory(TimeDependence)
add_subdirectory(TimeDependentOptions)
3 changes: 2 additions & 1 deletion src/Domain/Creators/CylindricalBinaryCompactObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
#include "Domain/CoordinateMaps/UniformCylindricalFlatEndcap.hpp"
#include "Domain/CoordinateMaps/UniformCylindricalSide.hpp"
#include "Domain/CoordinateMaps/Wedge.hpp"
#include "Domain/Creators/BinaryCompactObjectHelpers.hpp"
#include "Domain/Creators/BinaryCompactObject.hpp"
#include "Domain/Creators/ExpandOverBlocks.hpp"
#include "Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp"
#include "Domain/DomainHelpers.hpp"
#include "Domain/ExcisionSphere.hpp"
#include "Domain/FunctionsOfTime/FixedSpeedCubic.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Creators/CylindricalBinaryCompactObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "Domain/BoundaryConditions/BoundaryCondition.hpp"
#include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp"
#include "Domain/CoordinateMaps/CoordinateMap.hpp"
#include "Domain/Creators/BinaryCompactObjectHelpers.hpp"
#include "Domain/Creators/DomainCreator.hpp"
#include "Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp"
#include "Domain/Domain.hpp"
#include "Domain/Structure/DirectionMap.hpp"
#include "Domain/Structure/ObjectLabel.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/Domain/Creators/Sphere.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp"
#include "Domain/CoordinateMaps/Distribution.hpp"
#include "Domain/Creators/DomainCreator.hpp"
#include "Domain/Creators/SphereTimeDependentMaps.hpp"
#include "Domain/Creators/TimeDependence/TimeDependence.hpp"
#include "Domain/Creators/TimeDependentOptions/Sphere.hpp"
#include "Domain/Domain.hpp"
#include "Domain/Structure/DirectionMap.hpp"
#include "Options/Auto.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#include "Domain/Creators/BinaryCompactObjectHelpers.hpp"
#include "Domain/Creators/TimeDependentOptions/BinaryCompactObject.hpp"

#include <array>
#include <limits>
Expand All @@ -16,7 +16,7 @@
#include "Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/ShapeMapTransitionFunction.hpp"
#include "Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/SphereTransition.hpp"
#include "Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/Wedge.hpp"
#include "Domain/Creators/ShapeMapOptions.hpp"
#include "Domain/Creators/TimeDependentOptions/ShapeMap.hpp"
#include "Domain/FunctionsOfTime/FixedSpeedCubic.hpp"
#include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
#include "Domain/FunctionsOfTime/PiecewisePolynomial.hpp"
Expand All @@ -31,37 +31,25 @@
#include "Utilities/StdArrayHelpers.hpp"

namespace domain::creators::bco {
std::unordered_map<std::string, tnsr::I<double, 3, Frame::Grid>>
create_grid_anchors(const std::array<double, 3>& center_a,
const std::array<double, 3>& center_b) {
std::unordered_map<std::string, tnsr::I<double, 3, Frame::Grid>> result{};
result["Center" + get_output(ObjectLabel::A)] =
tnsr::I<double, 3, Frame::Grid>{center_a};
result["Center" + get_output(ObjectLabel::B)] =
tnsr::I<double, 3, Frame::Grid>{center_b};
result["Center"] = tnsr::I<double, 3, Frame::Grid>{std::array{0.0, 0.0, 0.0}};

return result;
}

template <bool IsCylindrical>
TimeDependentMapOptions<IsCylindrical>::TimeDependentMapOptions(
double initial_time,
std::optional<ExpansionMapOptions> expansion_map_options,
std::optional<RotationMapOptions> rotation_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,
const Options::Context& context)
: initial_time_(initial_time),
expansion_map_options_(expansion_map_options),
rotation_options_(rotation_options),
translation_options_(translation_map_options),
rotation_map_options_(rotation_map_options),
translation_map_options_(translation_map_options),
shape_options_A_(shape_options_A),
shape_options_B_(shape_options_B) {
if (not(expansion_map_options_.has_value() or rotation_options_.has_value() or
translation_options_.has_value() or shape_options_A_.has_value() or
shape_options_B_.has_value())) {
if (not(expansion_map_options_.has_value() or
rotation_map_options_.has_value() or
translation_map_options_.has_value() or
shape_options_A_.has_value() or shape_options_B_.has_value())) {
PARSE_ERROR(context,
"Time dependent map options were specified, but all options "
"were 'None'. If you don't want time dependent maps, specify "
Expand Down Expand Up @@ -136,37 +124,40 @@ TimeDependentMapOptions<IsCylindrical>::create_functions_of_time(
// (omega) to determine map parameters. In theory we could determine
// each initial angle from the input axis-angle representation, but
// we don't need to.
if (rotation_options_.has_value()) {
if (rotation_map_options_.has_value()) {
result[rotation_name] = std::make_unique<
FunctionsOfTime::QuaternionFunctionOfTime<3>>(
initial_time_,
std::array<DataVector, 1>{DataVector{1.0, 0.0, 0.0, 0.0}},
std::array<DataVector, 4>{
{{3, 0.0},
{gsl::at(rotation_options_.value().initial_angular_velocity, 0),
gsl::at(rotation_options_.value().initial_angular_velocity, 1),
gsl::at(rotation_options_.value().initial_angular_velocity, 2)},
{gsl::at(rotation_map_options_.value().initial_angular_velocity,
0),
gsl::at(rotation_map_options_.value().initial_angular_velocity,
1),
gsl::at(rotation_map_options_.value().initial_angular_velocity,
2)},
{3, 0.0},
{3, 0.0}}},
expiration_times.at(rotation_name));
}

// TranslationMap FunctionOfTime
if (translation_options_.has_value()) {
result[translation_name] =
std::make_unique<FunctionsOfTime::PiecewisePolynomial<2>>(
initial_time_,
std::array<DataVector, 3>{
{{gsl::at(translation_options_.value().initial_values, 0)[0],
gsl::at(translation_options_.value().initial_values, 0)[1],
gsl::at(translation_options_.value().initial_values, 0)[2]},
{gsl::at(translation_options_.value().initial_values, 1)[0],
gsl::at(translation_options_.value().initial_values, 1)[1],
gsl::at(translation_options_.value().initial_values, 1)[2]},
{gsl::at(translation_options_.value().initial_values, 2)[0],
gsl::at(translation_options_.value().initial_values, 2)[1],
gsl::at(translation_options_.value().initial_values, 2)[2]}}},
expiration_times.at(translation_name));
if (translation_map_options_.has_value()) {
result[translation_name] = std::make_unique<
FunctionsOfTime::PiecewisePolynomial<2>>(
initial_time_,
std::array<DataVector, 3>{
{{gsl::at(translation_map_options_.value().initial_values, 0)[0],
gsl::at(translation_map_options_.value().initial_values, 0)[1],
gsl::at(translation_map_options_.value().initial_values, 0)[2]},
{gsl::at(translation_map_options_.value().initial_values, 1)[0],
gsl::at(translation_map_options_.value().initial_values, 1)[1],
gsl::at(translation_map_options_.value().initial_values, 1)[2]},
{gsl::at(translation_map_options_.value().initial_values, 2)[0],
gsl::at(translation_map_options_.value().initial_values, 2)[1],
gsl::at(translation_map_options_.value().initial_values, 2)[2]}}},
expiration_times.at(translation_name));
}

// Size and Shape FunctionOfTime for objects A and B
Expand Down Expand Up @@ -218,28 +209,28 @@ void TimeDependentMapOptions<IsCylindrical>::build_maps(
const std::optional<std::array<double, IsCylindrical ? 2 : 3>>&
object_B_radii,
const double envelope_radius, const double domain_outer_radius) {
if (expansion_map_options_.has_value() or rotation_options_.has_value() or
translation_options_.has_value()) {
if (expansion_map_options_.has_value() or rotation_map_options_.has_value() or
translation_map_options_.has_value()) {
rot_scale_trans_map_ = std::make_pair(
RotScaleTrans{
expansion_map_options_.has_value()
? std::make_pair(expansion_name, expansion_outer_boundary_name)
: std::optional<std::pair<std::string, std::string>>{},
rotation_options_.has_value() ? rotation_name
: std::optional<std::string>{},
translation_options_.has_value() ? translation_name
: std::optional<std::string>{},
rotation_map_options_.has_value() ? rotation_name
: std::optional<std::string>{},
translation_map_options_.has_value() ? translation_name
: std::optional<std::string>{},
envelope_radius, domain_outer_radius,
domain::CoordinateMaps::TimeDependent::RotScaleTrans<
3>::BlockRegion::Inner},
RotScaleTrans{
expansion_map_options_.has_value()
? std::make_pair(expansion_name, expansion_outer_boundary_name)
: std::optional<std::pair<std::string, std::string>>{},
rotation_options_.has_value() ? rotation_name
: std::optional<std::string>{},
translation_options_.has_value() ? translation_name
: std::optional<std::string>{},
rotation_map_options_.has_value() ? rotation_name
: std::optional<std::string>{},
translation_map_options_.has_value() ? translation_name
: std::optional<std::string>{},
envelope_radius, domain_outer_radius,
domain::CoordinateMaps::TimeDependent::RotScaleTrans<
3>::BlockRegion::Transition});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "Domain/CoordinateMaps/TimeDependent/Rotation.hpp"
#include "Domain/CoordinateMaps/TimeDependent/Shape.hpp"
#include "Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/ShapeMapTransitionFunction.hpp"
#include "Domain/Creators/ShapeMapOptions.hpp"
#include "Domain/Creators/SphereTimeDependentMaps.hpp"
#include "Domain/Creators/TimeDependentOptions/ShapeMap.hpp"
#include "Domain/Creators/TimeDependentOptions/Sphere.hpp"
#include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
#include "Domain/Structure/ObjectLabel.hpp"
#include "Options/Auto.hpp"
Expand All @@ -39,22 +39,6 @@ struct Inertial;
/// Namespace used to hold things used in both the BinaryCompactObject and
/// CylindricalBinaryCompactObject domain creators.
namespace domain::creators::bco {

/*!
* \brief Create a set of centers of objects for the binary domains.
*
* \details Will add the following centers to the set:
*
* - Center: The origin
* - CenterA: Center of object A
* - CenterB: Center of object B
*
* \return Object required by the DomainCreator%s
*/
std::unordered_map<std::string, tnsr::I<double, 3, Frame::Grid>>
create_grid_anchors(const std::array<double, 3>& center_a,
const std::array<double, 3>& center_b);

namespace detail {
// Convenience type alias
template <typename... Maps>
Expand Down Expand Up @@ -259,8 +243,8 @@ struct TimeDependentMapOptions {
TimeDependentMapOptions(
double initial_time,
std::optional<ExpansionMapOptions> expansion_map_options,
std::optional<RotationMapOptions> rotation_options,
std::optional<TranslationMapOptions> translation_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,
const Options::Context& context = {});
Expand Down Expand Up @@ -384,8 +368,8 @@ struct TimeDependentMapOptions {

double initial_time_{std::numeric_limits<double>::signaling_NaN()};
std::optional<ExpansionMapOptions> expansion_map_options_{};
std::optional<RotationMapOptions> rotation_options_{};
std::optional<TranslationMapOptions> translation_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_{};
std::array<std::optional<double>, 2> inner_radii_{};
Expand Down
21 changes: 21 additions & 0 deletions src/Domain/Creators/TimeDependentOptions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Distributed under the MIT License.
# See LICENSE.txt for details.

spectre_target_sources(
${LIBRARY}
PRIVATE
BinaryCompactObject.cpp
FromVolumeFile.cpp
ShapeMap.cpp
Sphere.cpp
)

spectre_target_headers(
${LIBRARY}
INCLUDE_DIRECTORY ${CMAKE_SOURCE_DIR}/src
HEADERS
BinaryCompactObject.hpp
FromVolumeFile.hpp
ShapeMap.hpp
Sphere.hpp
)
Loading

0 comments on commit b4fd44e

Please sign in to comment.