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