Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : #pragma once 4 : 5 : #include <cstddef> 6 : #include <cstdint> 7 : 8 : /// \cond 9 : class DataVector; 10 : template <size_t Dim> 11 : class Index; 12 : class Matrix; 13 : template <size_t Dim> 14 : class Mesh; 15 : enum class Side : uint8_t; 16 : namespace Spectral { 17 : enum class Quadrature : uint8_t; 18 : } // namespace Spectral 19 : /// \endcond 20 : 21 : namespace evolution::dg::subcell::fd { 22 : /*! 23 : * \ingroup DgSubcellGroup 24 : * \brief Computes the projection matrix in 1 dimension going from a DG 25 : * mesh to a conservative finite difference subcell mesh. 26 : */ 27 1 : const Matrix& projection_matrix(const Mesh<1>& dg_mesh, size_t subcell_extents, 28 : const Spectral::Quadrature& subcell_quadrature); 29 : 30 : /*! 31 : * \ingroup DgSubcellGroup 32 : * \brief Computes the matrix needed for reconstructing the DG solution from 33 : * the subcell solution. 34 : * 35 : * Reconstructing the DG solution from the FD solution is a bit more 36 : * involved than projecting the DG solution to the FD subcells. Denoting the 37 : * projection operator by \f$\mathcal{P}\f$ and the reconstruction operator by 38 : * \f$\mathcal{R}\f$, we desire the property 39 : * 40 : * \f{align*}{ 41 : * \mathcal{R}(\mathcal{P}(u_{\breve{\imath}} 42 : * J_{\breve{\imath}}))=u_{\breve{\imath}} J_{\breve{\imath}}, 43 : * \f} 44 : * 45 : * where \f$\breve{\imath}\f$ denotes a grid point on the DG grid, \f$u\f$ is 46 : * the solution on the DG grid, and \f$J\f$ is the determinant of the Jacobian 47 : * on the DG grid. We also require that the integral of the conserved variables 48 : * over the subcells is equal to the integral over the DG element. That is, 49 : * 50 : * \f{align*}{ 51 : * \int_{\Omega}u \,d^3x =\int_{\Omega} \underline{u} \,d^3x \Longrightarrow 52 : * \int_{\Omega}u J \,d^3\xi=\int_{\Omega} \underline{u} J \,d^3\xi, 53 : * \f} 54 : * 55 : * where \f$\underline{u}\f$ is the solution on the subcells. Because the number 56 : * of subcell points is larger than the number of DG points, we need to solve a 57 : * constrained linear least squares problem to reconstruct the DG solution from 58 : * the subcells. 59 : * 60 : * The final reconstruction matrix is given by 61 : * 62 : * \f{align*}{ 63 : * R_{\breve{\jmath}\underline{i}} 64 : * &=\left\{(2 \mathcal{P}\otimes\mathcal{P})^{-1}2\mathcal{P} - (2 65 : * \mathcal{P}\otimes\mathcal{P})^{-1}\vec{w}\left[\mathbf{w}(2 66 : * \mathcal{P}\otimes\mathcal{P})^{-1}\vec{w}\right]^{-1}\mathbf{w}(2 67 : * \mathcal{P}\otimes\mathcal{P})^{-1}2\mathcal{P} 68 : * + (2 \mathcal{P}\otimes\mathcal{P})^{-1}\vec{w}\left[\mathbf{w}(2 69 : * \mathcal{P}\otimes\mathcal{P})^{-1}\vec{w}\right]^{-1}\vec{\underline{w}} 70 : * \right\}_{\breve{\jmath}\underline{i}}, 71 : * \f} 72 : * 73 : * where \f$\vec{w}\f$ is the vector of integration weights on the DG element, 74 : * \f$\mathbf{w}=w_{\breve{l}}\delta_{\breve{l}\breve{\jmath}}\f$, and 75 : * \f$\vec{\underline{w}}\f$ is the vector of integration weights over the 76 : * subcells. The integration weights \f$\vec{\underline{w}}\f$ on the subcells 77 : * are those for 6th-order integration on a uniform mesh. 78 : */ 79 : template <size_t Dim> 80 1 : const Matrix& reconstruction_matrix(const Mesh<Dim>& dg_mesh, 81 : const Index<Dim>& subcell_extents); 82 : 83 : /*! 84 : * \ingroup DgSubcellGroup 85 : * \brief Computes the projection matrix in 1 dimension going from a DG 86 : * mesh to a conservative finite difference subcell mesh for only the ghost 87 : * zones. 88 : * 89 : * This is used when a neighbor sends DG volume data and we need to switch to 90 : * FD. In this case we need to project the DG volume data onto the ghost zone 91 : * cells. 92 : * 93 : * \note Currently assumes a max ghost zone size of `5` and a minimum ghost zone 94 : * size of 2. 95 : */ 96 1 : const Matrix& projection_matrix(const Mesh<1>& dg_mesh, size_t subcell_extents, 97 : size_t ghost_zone_size, Side side); 98 : } // namespace evolution::dg::subcellfd