OverlapHelpers.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <boost/functional/hash.hpp>
7 #include <tuple>
8
9 #include "DataStructures/DataVector.hpp"
10 #include "DataStructures/FixedHashMap.hpp"
11 #include "DataStructures/Index.hpp"
14 #include "Domain/Structure/MaxNumberOfNeighbors.hpp"
15
16 namespace LinearSolver::Schwarz {
17
18 /// Identifies a subdomain region that overlaps with another element
19 template <size_t Dim>
21
22 /// Data structure that can store the ValueType on each possible overlap of an
23 /// element-centered subdomain with its neighbors. Overlaps are identified by
24 /// their OverlapId.
25 template <size_t Dim, typename ValueType>
26 using OverlapMap =
28  boost::hash<OverlapId<Dim>>>;
29
30 /*!
31  * \brief The number of points that an overlap extends into the volume_extent
32  *
33  * In a dimension where an element has volume_extent points, the overlap
34  * extent is the largest number under these constraints:
35  *
36  * - It is at most max_overlap.
37  * - It is smaller than the volume_extent.
38  *
39  * This means the overlap extent is always smaller than the volume_extent. The
40  * reason for this constraint is that we define the _width_ of the overlap as
41  * the element-logical coordinate distance from the face of the element to the
42  * first collocation point _outside_ the overlap extent. Therefore, even an
43  * overlap region that covers the full element in width does not include the
44  * collocation point on the opposite side of the element.
45  *
46  * Here's a few notes on the definition of the overlap extent and width:
47  *
48  * - A typical smooth weighting function goes to zero at the overlap width, so
49  * if the grid points located at the overlap width were included in the
50  * subdomain, their solutions would not contribute to the weighted sum of
51  * subdomain solutions.
52  * - Defining the overlap width as the distance to the first point _outside_ the
53  * overlap extent makes it non-zero even for a single point of overlap into a
54  * Gauss-Lobatto grid (which has points located at the element face).
55  * - Boundary contributions for many (but not all) discontinuous Galerkin
56  * schemes on Gauss-Lobatto grids are limited to the grid points on the
57  * element face, e.g. for a DG operator that is pre-multiplied by the mass
58  * matrix, or one where boundary contributions are lifted using the diagonal
59  * mass-matrix approximation. Not including the grid points facing away from
60  * the subdomain in the overlap allows to ignore that face altogether in the
61  * subdomain operator.
62  */
63 size_t overlap_extent(size_t volume_extent, size_t max_overlap) noexcept;
64
65 /*!
66  * \brief Total number of grid points in an overlap region that extends
67  * overlap_extent points into the volume_extents from either side in the
68  * overlap_dimension
69  *
70  * The overlap region has overlap_extent points in the overlap_dimension,
71  * and volume_extents points in the other dimensions. The number of grid
72  * points returned by this function is the product of these extents.
73  */
74 template <size_t Dim>
75 size_t overlap_num_points(const Index<Dim>& volume_extents,
76  size_t overlap_extent,
77  size_t overlap_dimension) noexcept;
78
79 /*!
80  * \brief Width of an overlap extending overlap_extent points into the
81  * collocation_points from either side.
82  *
83  * The "width" of an overlap is the element-logical coordinate distance from the
84  * element boundary to the first collocation point outside the overlap region in
85  * the overlap dimension, i.e. the dimension perpendicular to the element face.
86  * See LinearSolver::Schwarz::overlap_extent for details.
87  *
88  * This function assumes the collocation_points are mirrored around 0.
89  */
90 double overlap_width(size_t overlap_extent,
91  const DataVector& collocation_points) noexcept;
92
93 } // namespace LinearSolver::Schwarz
maximum_number_of_neighbors
constexpr size_t maximum_number_of_neighbors(const size_t dim)
Definition: MaxNumberOfNeighbors.hpp:15
LinearSolver::Schwarz::overlap_extent
size_t overlap_extent(const size_t volume_extent, const size_t max_overlap) noexcept
The number of points that an overlap extends into the volume_extent
Definition: OverlapHelpers.cpp:17
std::pair
tuple
Index
Definition: Index.hpp:31
LinearSolver::Schwarz
Items related to the Schwarz linear solver.
Definition: OverlapHelpers.cpp:15
ElementId< Dim >
ElementId.hpp
LinearSolver::Schwarz::overlap_width
double overlap_width(const size_t overlap_extent, const DataVector &collocation_points) noexcept
Width of an overlap extending overlap_extent points into the collocation_points from either side.
Definition: OverlapHelpers.cpp:45
Index.hpp
LinearSolver::Schwarz::overlap_num_points
size_t overlap_num_points(const Index< Dim > &volume_extents, const size_t overlap_extent, const size_t overlap_dimension) noexcept
Total number of grid points in an overlap region that extends overlap_extent points into the volume_e...
Definition: OverlapHelpers.cpp:37
DataVector
Stores a collection of function values.
Definition: DataVector.hpp:42
Spectral::collocation_points
const DataVector & collocation_points(const Mesh< 1 > &mesh) noexcept
Collocation points for a one-dimensional mesh.
Direction.hpp
FixedHashMap
A hash table with a compile-time specified maximum size and ability to efficiently handle perfect has...
Definition: FixedHashMap.hpp:81