Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <mutex>
8 : #include <string>
9 :
10 : #include "DataStructures/DataVector.hpp"
11 : #include "DataStructures/TaggedTuple.hpp"
12 : #include "DataStructures/Tensor/Tensor.hpp"
13 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
14 : #include "PointwiseFunctions/Hydro/Tags.hpp"
15 : #include "Utilities/TMPL.hpp"
16 :
17 : namespace io {
18 :
19 : /// Type of FUKA initial data
20 0 : enum class FukaIdType { Bh, Bbh, Ns, Bns, Bhns };
21 :
22 : namespace detail {
23 : using fuka_gr_tags =
24 : tmpl::list<gr::Tags::Lapse<DataVector>, gr::Tags::Shift<DataVector, 3>,
25 : gr::Tags::SpatialMetric<DataVector, 3>,
26 : gr::Tags::ExtrinsicCurvature<DataVector, 3>>;
27 : using fuka_hydro_tags =
28 : tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
29 : hydro::Tags::SpecificInternalEnergy<DataVector>,
30 : hydro::Tags::Pressure<DataVector>,
31 : hydro::Tags::SpatialVelocity<DataVector, 3>>;
32 : template <FukaIdType IdType>
33 : struct FukaTags {
34 : using type =
35 : tmpl::conditional_t<IdType <= FukaIdType::Bh or IdType == FukaIdType::Bbh,
36 : fuka_gr_tags,
37 : tmpl::append<fuka_gr_tags, fuka_hydro_tags>>;
38 : };
39 : } // namespace detail
40 :
41 : /// List of tags supplied by FUKA initial data
42 : template <FukaIdType IdType>
43 1 : using fuka_tags = typename detail::FukaTags<IdType>::type;
44 :
45 : /*!
46 : * \brief Interpolate numerical FUKA initial data to arbitrary points
47 : *
48 : * \tparam IdType Type of FUKA initial data
49 : * \param fuka_lock Lock for accessing FUKA data. This is needed because
50 : * FUKA is not thread-safe. Pass in a lock that is shared with other
51 : * threads that are also calling this function.
52 : * \param info_filename Path to the FUKA info file to load
53 : * \param x Coordinates of points to interpolate to
54 : * \param interpolation_offset See FUKA documentation for export functions
55 : * \param interp_order See FUKA documentation for export functions
56 : * \param delta_r_rel See FUKA documentation for export functions
57 : * \return Data interpolated to the given points
58 : */
59 : template <FukaIdType IdType>
60 1 : tuples::tagged_tuple_from_typelist<fuka_tags<IdType>> interpolate_from_fuka(
61 : gsl::not_null<std::mutex*> fuka_lock, const std::string& info_filename,
62 : const tnsr::I<DataVector, 3, Frame::Inertial>& x,
63 : double interpolation_offset = 0., int interp_order = 8,
64 : double delta_r_rel = 0.3);
65 :
66 : } // namespace io
|