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 :
8 : #include "DataStructures/Tensor/Tensor.hpp"
9 : #include "Elliptic/Systems/Poisson/Geometry.hpp"
10 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
11 : #include "Utilities/Gsl.hpp"
12 : #include "Utilities/MakeWithValue.hpp"
13 : #include "Utilities/TMPL.hpp"
14 :
15 : /// \cond
16 : class DataVector;
17 : namespace PUP {
18 : class er;
19 : } // namespace PUP
20 : namespace Poisson {
21 : template <size_t Dim, Geometry BackgroundGeometry,
22 : typename DataType = DataVector>
23 : struct Fluxes;
24 : template <size_t Dim, Geometry BackgroundGeometry,
25 : typename DataType = DataVector>
26 : struct Sources;
27 : } // namespace Poisson
28 : /// \endcond
29 :
30 : namespace Poisson {
31 :
32 : /*!
33 : * \brief Compute the fluxes \f$F^i=\partial_i u(x)\f$ for the Poisson
34 : * equation on a flat spatial metric in Cartesian coordinates.
35 : */
36 : template <typename DataType, size_t Dim>
37 1 : void flat_cartesian_fluxes(
38 : gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
39 : const tnsr::i<DataType, Dim>& field_gradient);
40 :
41 : /*!
42 : * \brief Compute the fluxes \f$F^i=\gamma^{ij}\partial_j u(x)\f$
43 : * for the curved-space Poisson equation on a spatial metric \f$\gamma_{ij}\f$.
44 : */
45 : template <typename DataType, size_t Dim>
46 1 : void curved_fluxes(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
47 : const tnsr::II<DataVector, Dim>& inv_spatial_metric,
48 : const tnsr::i<DataType, Dim>& field_gradient);
49 :
50 : /*!
51 : * \brief Compute the fluxes $F^i=\gamma^{ij} n_j u$ where $n_j$ is the
52 : * `face_normal`.
53 : *
54 : * The `face_normal_vector` is $\gamma^{ij} n_j$.
55 : */
56 : template <typename DataType, size_t Dim>
57 1 : void fluxes_on_face(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
58 : const tnsr::I<DataVector, Dim>& face_normal_vector,
59 : const Scalar<DataType>& field);
60 :
61 : /*!
62 : * \brief Add the sources \f$S=-\Gamma^i_{ij}v^j\f$
63 : * for the curved-space Poisson equation on a spatial metric \f$\gamma_{ij}\f$.
64 : *
65 : * These sources arise from the non-principal part of the Laplacian on a
66 : * non-Euclidean background.
67 : */
68 : template <typename DataType, size_t Dim>
69 1 : void add_curved_sources(gsl::not_null<Scalar<DataType>*> source_for_field,
70 : const tnsr::i<DataVector, Dim>& christoffel_contracted,
71 : const tnsr::I<DataType, Dim>& flux_for_field);
72 :
73 : /*!
74 : * \brief Compute the fluxes \f$F^i\f$ for the Poisson equation on a flat
75 : * metric in Cartesian coordinates.
76 : *
77 : * \see Poisson::FirstOrderSystem
78 : */
79 : template <size_t Dim, typename DataType>
80 1 : struct Fluxes<Dim, Geometry::FlatCartesian, DataType> {
81 0 : using argument_tags = tmpl::list<>;
82 0 : using volume_tags = tmpl::list<>;
83 0 : using const_global_cache_tags = tmpl::list<>;
84 0 : static constexpr bool is_trivial = true;
85 0 : static constexpr bool is_discontinuous = false;
86 0 : static void apply(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
87 : const Scalar<DataType>& field,
88 : const tnsr::i<DataType, Dim>& field_gradient);
89 0 : static void apply(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
90 : const tnsr::i<DataVector, Dim>& face_normal,
91 : const tnsr::I<DataVector, Dim>& face_normal_vector,
92 : const Scalar<DataType>& field);
93 : };
94 :
95 : /*!
96 : * \brief Compute the fluxes \f$F^i\f$ for the curved-space Poisson equation
97 : * on a spatial metric \f$\gamma_{ij}\f$.
98 : *
99 : * \see Poisson::FirstOrderSystem
100 : */
101 : template <size_t Dim, typename DataType>
102 1 : struct Fluxes<Dim, Geometry::Curved, DataType> {
103 0 : using argument_tags =
104 : tmpl::list<gr::Tags::InverseSpatialMetric<DataVector, Dim>>;
105 0 : using volume_tags = tmpl::list<>;
106 0 : using const_global_cache_tags = tmpl::list<>;
107 0 : static constexpr bool is_trivial = true;
108 0 : static constexpr bool is_discontinuous = false;
109 0 : static void apply(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
110 : const tnsr::II<DataVector, Dim>& inv_spatial_metric,
111 : const Scalar<DataType>& field,
112 : const tnsr::i<DataType, Dim>& field_gradient);
113 0 : static void apply(gsl::not_null<tnsr::I<DataType, Dim>*> flux_for_field,
114 : const tnsr::II<DataVector, Dim>& inv_spatial_metric,
115 : const tnsr::i<DataVector, Dim>& face_normal,
116 : const tnsr::I<DataVector, Dim>& face_normal_vector,
117 : const Scalar<DataType>& field);
118 : };
119 :
120 : /*!
121 : * \brief Add the sources \f$S\f$ for the curved-space Poisson equation
122 : * on a spatial metric \f$\gamma_{ij}\f$.
123 : *
124 : * \see Poisson::FirstOrderSystem
125 : */
126 : template <size_t Dim, typename DataType>
127 1 : struct Sources<Dim, Geometry::Curved, DataType> {
128 0 : using argument_tags = tmpl::list<
129 : gr::Tags::SpatialChristoffelSecondKindContracted<DataVector, Dim>>;
130 0 : using const_global_cache_tags = tmpl::list<>;
131 0 : static void apply(gsl::not_null<Scalar<DataType>*> equation_for_field,
132 : const tnsr::i<DataVector, Dim>& christoffel_contracted,
133 : const Scalar<DataType>& field,
134 : const tnsr::I<DataType, Dim>& field_flux);
135 : };
136 :
137 : } // namespace Poisson
|