SpECTRE  v2024.09.29
Mesh< Dim > Class Template Reference

Holds the number of grid points, basis, and quadrature in each direction of the computational grid. More...

#include <Mesh.hpp>

Classes

struct  Basis
 
struct  Extents
 
struct  Quadrature
 

Public Types

using options = tmpl::list< Extents, Basis, Quadrature >
 

Public Member Functions

 Mesh (size_t isotropic_extents, Spectral::Basis basis, Spectral::Quadrature quadrature)
 Construct a computational grid with the same number of collocation points in each dimension. More...
 
 Mesh (const std::array< size_t, Dim > &extents, Spectral::Basis basis, Spectral::Quadrature quadrature)
 Construct a computational grid where each dimension can have a different number of collocation points. More...
 
 Mesh (const std::array< size_t, Dim > &extents, const std::array< Spectral::Basis, Dim > &bases, const std::array< Spectral::Quadrature, Dim > &quadratures)
 Construct a computational grid where each dimension can have both a different number and placement of collocation points. More...
 
Index< Dim > extents () const
 The number of grid points in each dimension of the grid.
 
size_t extents (size_t d) const
 The number of grid points in dimension d of the grid (zero-indexed).
 
size_t number_of_grid_points () const
 The total number of grid points in all dimensions. More...
 
size_t storage_index (const Index< Dim > &index) const
 Returns the 1-dimensional index corresponding to the Dim dimensional index. More...
 
std::array< Spectral::Basis, Dim > basis () const
 The basis chosen in each dimension of the grid.
 
Spectral::Basis basis (size_t d) const
 The basis chosen in dimension d of the grid (zero-indexed).
 
std::array< Spectral::Quadrature, Dim > quadrature () const
 The quadrature chosen in each dimension of the grid.
 
Spectral::Quadrature quadrature (size_t d) const
 The quadrature chosen in dimension d of the grid (zero-indexed).
 
template<size_t N = Dim, Requires<(N > 0 and N==Dim)> = nullptr>
Mesh< Dim - 1 > slice_away (size_t d) const
 Returns a Mesh with dimension d removed (zero-indexed). More...
 
template<typename... D, Requires<(sizeof...(D)<=Dim)> = nullptr>
Mesh< sizeof...(D)> slice_through (D... d) const
 Returns a Mesh with the dimensions d, ... present (zero-indexed). More...
 
template<size_t SliceDim, Requires<(SliceDim<=Dim)> = nullptr>
Mesh< SliceDim > slice_through (const std::array< size_t, SliceDim > &dims) const
 Returns a Mesh with the dimensions dims present (zero-indexed). More...
 
std::array< Mesh< 1 >, Dim > slices () const
 Returns the Meshes representing 1D slices of this Mesh. More...
 
void pup (PUP::er &p)
 

Static Public Attributes

static constexpr size_t dim = Dim
 
static constexpr Options::String help
 

Friends

template<size_t LocalDim>
bool operator== (const Mesh< LocalDim > &lhs, const Mesh< LocalDim > &rhs)
 

Detailed Description

template<size_t Dim>
class Mesh< Dim >

Holds the number of grid points, basis, and quadrature in each direction of the computational grid.

Details

A mesh encapsulates all information necessary to construct the placement of grid points in the computational domain. It does so through a choice of basis functions, quadrature and number of points \(N\) in each dimension. The grid points are the associated collocation points and can be obtained from Spectral::collocation_points(const Mesh<1>&):

const Mesh<2> mesh2d{
{{3, 4}},
{{Spectral::Basis::Legendre, Spectral::Basis::Legendre}},
{{Spectral::Quadrature::Gauss, Spectral::Quadrature::GaussLobatto}}};
const auto collocation_points_in_first_dim =
Spectral::collocation_points(mesh2d.slice_through(0));
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:53
const DataVector & collocation_points(size_t num_points)
Collocation points.

A simulated physical field can be represented by a DataVector of length number_of_grid_points() that holds the field value on each point of the computational grid. These values are identical to the field's nodal expansion coefficients. They approximate the field by a polynomial of degree \(p=N-1\) through a linear combination of Lagrange polynomials.

Note
Because we use a compact bit representation for the mesh, the number of grid points/extents must be fewer than 256 per dimension.
Template Parameters
Dimthe number of dimensions of the computational grid.

Constructor & Destructor Documentation

◆ Mesh() [1/3]

template<size_t Dim>
Mesh< Dim >::Mesh ( size_t  isotropic_extents,
Spectral::Basis  basis,
Spectral::Quadrature  quadrature 
)

Construct a computational grid with the same number of collocation points in each dimension.

Parameters
isotropic_extentsThe number of collocation points in each dimension.
basisThe choice of spectral basis to compute the collocation points
quadratureThe choice of quadrature to compute the collocation points
Note
Because a Mesh<0> extends over no dimensions, it has 1 grid point independent of the value of isotropic_extents.

◆ Mesh() [2/3]

template<size_t Dim>
Mesh< Dim >::Mesh ( const std::array< size_t, Dim > &  extents,
Spectral::Basis  basis,
Spectral::Quadrature  quadrature 
)

Construct a computational grid where each dimension can have a different number of collocation points.

Parameters
extentsThe number of collocation points per dimension
basisThe choice of spectral basis to compute the collocation points
quadratureThe choice of quadrature to compute the collocation points

◆ Mesh() [3/3]

template<size_t Dim>
Mesh< Dim >::Mesh ( const std::array< size_t, Dim > &  extents,
const std::array< Spectral::Basis, Dim > &  bases,
const std::array< Spectral::Quadrature, Dim > &  quadratures 
)

Construct a computational grid where each dimension can have both a different number and placement of collocation points.

Parameters
extentsThe number of collocation points per dimension
basesThe choice of spectral bases to compute the collocation points per dimension
quadraturesThe choice of quadratures to compute the collocation points per dimension

Member Function Documentation

◆ number_of_grid_points()

template<size_t Dim>
size_t Mesh< Dim >::number_of_grid_points ( ) const

The total number of grid points in all dimensions.

Details

DataVectors that represent field values on the grid have this many entries.

Note
A zero-dimensional mesh has one grid point, since it is the slice through a one-dimensional mesh (a line).

◆ slice_away()

template<size_t Dim>
template<size_t N = Dim, Requires<(N > 0 and N==Dim)> = nullptr>
Mesh< Dim - 1 > Mesh< Dim >::slice_away ( size_t  d) const

Returns a Mesh with dimension d removed (zero-indexed).

See also
slice_through()

◆ slice_through() [1/2]

template<size_t Dim>
template<size_t SliceDim, Requires<(SliceDim<=Dim)> = nullptr>
Mesh< SliceDim > Mesh< Dim >::slice_through ( const std::array< size_t, SliceDim > &  dims) const

Returns a Mesh with the dimensions dims present (zero-indexed).

See also
slice_through() The templated overload of this function

◆ slice_through() [2/2]

template<size_t Dim>
template<typename... D, Requires<(sizeof...(D)<=Dim)> = nullptr>
Mesh< sizeof...(D)> Mesh< Dim >::slice_through ( D...  d) const
inline

Returns a Mesh with the dimensions d, ... present (zero-indexed).

Details

Generally you use this method to obtain a lower-dimensional Mesh by slicing through a subset of the dimensions. However, you can also reorder dimensions using this method by slicing through the dimensions in an order you choose.

See also
slice_away()

◆ slices()

template<size_t Dim>
std::array< Mesh< 1 >, Dim > Mesh< Dim >::slices ( ) const

Returns the Meshes representing 1D slices of this Mesh.

The is the same as the array filled with slice_through(d) for d from 0 to Dim - 1 except in dimension 0 where slice_through(d) is not defined.

◆ storage_index()

template<size_t Dim>
size_t Mesh< Dim >::storage_index ( const Index< Dim > &  index) const

Returns the 1-dimensional index corresponding to the Dim dimensional index.

The first dimension varies fastest.

See also
collapsed_index()

Member Data Documentation

◆ help

template<size_t Dim>
constexpr Options::String Mesh< Dim >::help
staticconstexpr
Initial value:
=
"Holds the number of grid points, basis, and quadrature in each "
"direction of the computational grid. "
"A mesh encapsulates all information necessary to construct the "
"placement of grid points in the computational domain. It does so "
"through a choice of basis functions, quadrature and number of points "
"in each dimension."

The documentation for this class was generated from the following file: