Line data Source code
1 1 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : /// \file 5 : /// Defines class ExcisionSphere. 6 : 7 : #pragma once 8 : 9 : #include <cstddef> 10 : #include <iosfwd> 11 : #include <limits> 12 : #include <memory> 13 : #include <optional> 14 : #include <unordered_map> 15 : 16 : #include "DataStructures/Tensor/Tensor.hpp" 17 : #include "Domain/CoordinateMaps/CoordinateMap.hpp" 18 : #include "Domain/CoordinateMaps/CoordinateMap.tpp" 19 : #include "Domain/Structure/Direction.hpp" 20 : #include "Domain/Structure/ElementId.hpp" 21 : 22 : /// \cond 23 : namespace Frame { 24 : struct Grid; 25 : struct Inertial; 26 : } // namespace Frame 27 : namespace PUP { 28 : class er; 29 : } // namespace PUP 30 : /// \endcond 31 : 32 : /// \ingroup ComputationalDomainGroup 33 : /// The excision sphere information of a computational domain. 34 : /// The excision sphere is assumed to be a coordinate sphere in the 35 : /// grid frame. 36 : /// 37 : /// \tparam VolumeDim the volume dimension. 38 : template <size_t VolumeDim> 39 1 : class ExcisionSphere { 40 : public: 41 : /// Constructor 42 : /// 43 : /// \param radius the radius of the excision sphere in the 44 : /// computational domain. 45 : /// \param center the coordinate center of the excision sphere 46 : /// in the computational domain. 47 : /// \param abutting_directions the set of blocks that touch the excision 48 : /// sphere, along with the direction in which they touch it. 49 1 : ExcisionSphere( 50 : double radius, tnsr::I<double, VolumeDim, Frame::Grid> center, 51 : std::unordered_map<size_t, Direction<VolumeDim>> abutting_directions); 52 : 53 : /// Default constructor needed for Charm++ serialization. 54 1 : ExcisionSphere() = default; 55 0 : ~ExcisionSphere() = default; 56 0 : ExcisionSphere(const ExcisionSphere<VolumeDim>& /*rhs*/); 57 0 : ExcisionSphere(ExcisionSphere<VolumeDim>&& /*rhs*/) = default; 58 0 : ExcisionSphere<VolumeDim>& operator=( 59 : const ExcisionSphere<VolumeDim>& /*rhs*/); 60 0 : ExcisionSphere<VolumeDim>& operator=(ExcisionSphere<VolumeDim>&& /*rhs*/) = 61 : default; 62 : 63 : /// \brief Add time dependent coordinate maps to the ExcisionSphere 64 : /// 65 : /// \note There is no actual mesh that is inside an excision sphere, but this 66 : /// region moves along with the domain just the same. Meaning that we 67 : /// should be able to take a point inside the excision sphere and map it to 68 : /// the Inertial frame. 69 1 : void inject_time_dependent_maps( 70 : std::unique_ptr< 71 : domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, VolumeDim>> 72 : moving_mesh_grid_to_inertial_map); 73 : 74 : /// \brief The map going from the last time independent frame to the frame in 75 : /// which the equations are solved. Only used when `is_time_dependent()` is 76 : /// true. 77 : const domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, VolumeDim>& 78 1 : moving_mesh_grid_to_inertial_map() const; 79 : 80 : /// \brief Return whether or not time dependent maps have been injected 81 1 : bool is_time_dependent() const { return grid_to_inertial_map_ != nullptr; } 82 : 83 : /// The radius of the ExcisionSphere. 84 1 : double radius() const { return radius_; } 85 : 86 : /// The coordinate center of the ExcisionSphere. 87 1 : const tnsr::I<double, VolumeDim, Frame::Grid>& center() const { 88 : return center_; 89 : } 90 : 91 : /// The set of blocks that touch the excision sphere, along with the direction 92 : /// in which they touch it 93 1 : const std::unordered_map<size_t, Direction<VolumeDim>>& abutting_directions() 94 : const { 95 : return abutting_directions_; 96 : } 97 : /// Checks whether an element abuts the excision sphere. If it does, returns 98 : /// the corresponding direction. Else, `nullopt` is returned. 99 1 : std::optional<Direction<VolumeDim>> abutting_direction( 100 : const ElementId<VolumeDim>& element_id) const; 101 : 102 : // NOLINTNEXTLINE(google-runtime-references) 103 0 : void pup(PUP::er& p); 104 : 105 : private: 106 : template <size_t LocalVolumeDim> 107 : // NOLINTNEXTLINE(readability-redundant-declaration) 108 0 : friend bool operator==(const ExcisionSphere<LocalVolumeDim>& lhs, 109 : const ExcisionSphere<LocalVolumeDim>& rhs); 110 : 111 0 : double radius_{std::numeric_limits<double>::signaling_NaN()}; 112 0 : tnsr::I<double, VolumeDim, Frame::Grid> center_{ 113 : std::numeric_limits<double>::signaling_NaN()}; 114 0 : std::unordered_map<size_t, Direction<VolumeDim>> abutting_directions_{}; 115 : std::unique_ptr< 116 : domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, VolumeDim>> 117 0 : grid_to_inertial_map_{}; 118 : }; 119 : 120 : template <size_t VolumeDim> 121 0 : std::ostream& operator<<(std::ostream& os, 122 : const ExcisionSphere<VolumeDim>& excision_sphere); 123 : 124 : template <size_t VolumeDim> 125 0 : bool operator!=(const ExcisionSphere<VolumeDim>& lhs, 126 : const ExcisionSphere<VolumeDim>& rhs);