SpECTRE Documentation Coverage Report
Current view: top level - Elliptic/Systems/Poisson - FirstOrderSystem.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 18.2 % 11 2
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            Line data    Source code
       1            1 : // Distributed under the MIT License.
       2              : // See LICENSE.txt for details.
       3              : 
       4              : /// \file
       5              : /// Defines class Poisson::FirstOrderSystem
       6              : 
       7              : #pragma once
       8              : 
       9              : #include <cstddef>
      10              : 
      11              : #include "DataStructures/DataBox/PrefixHelpers.hpp"
      12              : #include "DataStructures/DataBox/Prefixes.hpp"
      13              : #include "Elliptic/BoundaryConditions/BoundaryCondition.hpp"
      14              : #include "Elliptic/Protocols/FirstOrderSystem.hpp"
      15              : #include "Elliptic/Systems/Poisson/Equations.hpp"
      16              : #include "Elliptic/Systems/Poisson/Geometry.hpp"
      17              : #include "Elliptic/Systems/Poisson/Tags.hpp"
      18              : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
      19              : #include "PointwiseFunctions/GeneralRelativity/TagsDeclarations.hpp"
      20              : #include "Utilities/ProtocolHelpers.hpp"
      21              : #include "Utilities/TMPL.hpp"
      22              : 
      23              : namespace Poisson {
      24              : 
      25              : /*!
      26              :  * \brief The Poisson equation formulated as a set of coupled first-order PDEs.
      27              :  *
      28              :  * \details This system formulates the Poisson equation \f$-\Delta_\gamma u(x) =
      29              :  * f(x)\f$ on a background metric \f$\gamma_{ij}\f$ as the set of coupled
      30              :  * first-order PDEs
      31              :  *
      32              :  * \f{align*}
      33              :  * -\partial_i v^i - \Gamma^i_{ij} v^j = f(x) \\
      34              :  * v^i = \gamma^{ij} \partial_j u(x)
      35              :  * \f}
      36              :  *
      37              :  * where \f$\Gamma^i_{jk}=\frac{1}{2}\gamma^{il}\left(\partial_j\gamma_{kl}
      38              :  * +\partial_k\gamma_{jl}-\partial_l\gamma_{jk}\right)\f$ are the Christoffel
      39              :  * symbols of the second kind of the background metric \f$\gamma_{ij}\f$. The
      40              :  * background metric \f$\gamma_{ij}\f$ and the Christoffel symbols derived from
      41              :  * it are assumed to be independent of the variables \f$u\f$, i.e.
      42              :  * constant throughout an iterative elliptic solve.
      43              :  *
      44              :  * The system can be formulated in terms of these fluxes and sources (see
      45              :  * `elliptic::protocols::FirstOrderSystem`):
      46              :  *
      47              :  * \f{align*}
      48              :  * F^i &= v^i = \gamma^{ij} \partial_j u \\
      49              :  * S &= -\Gamma^i_{ij} v^j \\
      50              :  * f &= f(x) \text{.}
      51              :  * \f}
      52              :  *
      53              :  * The fluxes and sources simplify significantly when the background metric is
      54              :  * flat and we employ Cartesian coordinates so \f$\gamma_{ij} = \delta_{ij}\f$
      55              :  * and \f$\Gamma^i_{jk} = 0\f$. Set the template parameter `BackgroundGeometry`
      56              :  * to `Poisson::Geometry::FlatCartesian` to specialize the system for this case.
      57              :  * Set it to `Poisson::Geometry::Curved` for the general case.
      58              :  *
      59              :  * ## Complex Poisson equation
      60              :  *
      61              :  * This system can also be used to solve the complex Poisson equation where
      62              :  * $u(x)$ and $f(x)$ are complex-valued, by setting the `DataType` template
      63              :  * parameter to `ComplexDataVector`. Note that the real and imaginary sectors of
      64              :  * the equations decouple, so they are essentially two independent Poisson
      65              :  * equations. This is useful for testing the elliptic solver with complex-valued
      66              :  * fields, and also as building blocks for other Poisson-like systems of
      67              :  * equations that have additional complex-valued source terms.
      68              :  */
      69              : template <size_t Dim, Geometry BackgroundGeometry,
      70              :           typename DataType = DataVector>
      71            1 : struct FirstOrderSystem
      72              :     : tt::ConformsTo<elliptic::protocols::FirstOrderSystem> {
      73            0 :   static constexpr size_t volume_dim = Dim;
      74              : 
      75            0 :   using primal_fields = tmpl::list<Tags::Field<DataType>>;
      76              :   // We just use the standard `Flux` prefix because the fluxes don't have
      77              :   // symmetries and we don't need to give them a particular meaning.
      78            0 :   using primal_fluxes = tmpl::list<
      79              :       ::Tags::Flux<Tags::Field<DataType>, tmpl::size_t<Dim>, Frame::Inertial>>;
      80              : 
      81            0 :   using background_fields = tmpl::conditional_t<
      82              :       BackgroundGeometry == Geometry::FlatCartesian, tmpl::list<>,
      83              :       tmpl::list<
      84              :           gr::Tags::InverseSpatialMetric<DataVector, Dim>,
      85              :           gr::Tags::SpatialChristoffelSecondKindContracted<DataVector, Dim>>>;
      86            0 :   using inv_metric_tag =
      87              :       tmpl::conditional_t<BackgroundGeometry == Geometry::FlatCartesian, void,
      88              :                           gr::Tags::InverseSpatialMetric<DataVector, Dim>>;
      89              : 
      90            0 :   using fluxes_computer = Fluxes<Dim, BackgroundGeometry, DataType>;
      91            0 :   using sources_computer =
      92              :       tmpl::conditional_t<BackgroundGeometry == Geometry::FlatCartesian, void,
      93              :                           Sources<Dim, BackgroundGeometry, DataType>>;
      94              : 
      95            0 :   using boundary_conditions_base =
      96              :       elliptic::BoundaryConditions::BoundaryCondition<Dim>;
      97            0 :   using modify_boundary_data = void;
      98              : };
      99              : }  // namespace Poisson
        

Generated by: LCOV version 2.0-1