ThunderEgg  1.0.0
IfaceType.h
Go to the documentation of this file.
1 /***************************************************************************
2  * ThunderEgg, a library for solvers on adaptively refined block-structured
3  * Cartesian grids.
4  *
5  * Copyright (c) 2017-2021 Scott Aiton
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  ***************************************************************************/
20 
21 #ifndef THUNDEREGG_SCHUR_IFACETYPE_H
22 #define THUNDEREGG_SCHUR_IFACETYPE_H
23 
28 #include <ThunderEgg/Orthant.h>
29 #include <tuple>
30 namespace ThunderEgg {
31 namespace Schur {
37 template<int D>
38 class IfaceType
39 {
40 private:
44  unsigned char val = 10;
48  Orthant<D - 1> orthant = Orthant<D - 1>::null();
49 
57  IfaceType(unsigned char val, Orthant<D - 1> orthant)
58  : val(val)
59  , orthant(orthant)
60  {}
61 
62 public:
74  bool isNormal() const { return val == 0; }
88  bool isCoarseToCoarse() const { return val == 1; }
97  static IfaceType<D> FineToCoarse(Orthant<D - 1> orth_on_coarse)
98  {
99  return IfaceType<D>(2, orth_on_coarse);
100  }
106  bool isFineToCoarse() const { return val == 2; }
117  static IfaceType<D> FineToFine(Orthant<D - 1> orth_on_coarse)
118  {
119  return IfaceType<D>(3, orth_on_coarse);
120  }
126  bool isFineToFine() const { return val == 3; }
137  static IfaceType<D> CoarseToFine(Orthant<D - 1> orthant) { return IfaceType<D>(4, orthant); }
143  bool isCoarseToFine() const { return val == 4; }
147  IfaceType() = default;
151  Orthant<D - 1> getOrthant() const { return orthant; }
155  void setOrthant(Orthant<D - 1> orthant) { this->orthant = orthant; }
159  bool operator<(const IfaceType& b) const
160  {
161  return std::forward_as_tuple(val, orthant) < std::forward_as_tuple(b.val, b.orthant);
162  }
163 };
164 } // namespace Schur
165 } // namespace ThunderEgg
166 #endif
ThunderEgg::Schur::IfaceType::isCoarseToFine
bool isCoarseToFine() const
Check if this type is CoarseToFine.
Definition: IfaceType.h:143
ThunderEgg::Schur::IfaceType::CoarseToCoarse
static IfaceType< D > CoarseToCoarse()
An interface on a side of a patch with neighbors at a finer refinement level.
Definition: IfaceType.h:82
ThunderEgg::Schur::IfaceType::operator<
bool operator<(const IfaceType &b) const
Compare iface type values.
Definition: IfaceType.h:159
ThunderEgg::Orthant::null
static Orthant< D > null()
null value
Definition: Orthant.h:68
ThunderEgg::Orthant
An enum-style class that represents the octants of a cube.
Definition: Orthant.h:43
ThunderEgg::Schur::IfaceType::Normal
static IfaceType< D > Normal()
An interface on a side of a patch with a neighbor at the same refinement level.
Definition: IfaceType.h:68
ThunderEgg::Schur::IfaceType::isCoarseToCoarse
bool isCoarseToCoarse() const
Check if this type is CoarseToCoarse.
Definition: IfaceType.h:88
ThunderEgg::Schur::IfaceType
An enum-style class that represents interface types.
Definition: IfaceType.h:38
ThunderEgg::Schur::IfaceType::getOrthant
Orthant< D - 1 > getOrthant() const
Get the Orthant that the finer patch lies on.
Definition: IfaceType.h:151
ThunderEgg::Schur::IfaceType::CoarseToFine
static IfaceType< D > CoarseToFine(Orthant< D - 1 > orthant)
An interface on a side of a patch with neighbors at a finer refinement level.
Definition: IfaceType.h:137
ThunderEgg::Schur::IfaceType::setOrthant
void setOrthant(Orthant< D - 1 > orthant)
Set the Orthant that the finer patch lies on.
Definition: IfaceType.h:155
ThunderEgg
The ThunderEgg namespace.
Definition: BiLinearGhostFiller.h:31
ThunderEgg::Schur::IfaceType::isFineToFine
bool isFineToFine() const
Check if this type is FineToFine.
Definition: IfaceType.h:126
ThunderEgg::Schur::IfaceType::FineToFine
static IfaceType< D > FineToFine(Orthant< D - 1 > orth_on_coarse)
An interface on a side of a patch with a neighbor at a coarser refinement level.
Definition: IfaceType.h:117
ThunderEgg::Schur::IfaceType::IfaceType
IfaceType()=default
Construct a new Iface Type object with the value set to 10 and the orthant set to null.
ThunderEgg::Schur::IfaceType::isFineToCoarse
bool isFineToCoarse() const
Check if this type is FineToCoarse.
Definition: IfaceType.h:106
ThunderEgg::Schur::IfaceType::isNormal
bool isNormal() const
Check if this type is Normal.
Definition: IfaceType.h:74
ThunderEgg::Schur::IfaceType::FineToCoarse
static IfaceType< D > FineToCoarse(Orthant< D - 1 > orth_on_coarse)
An interface on a side of a patch with a neighbor at a coarser refinement level.
Definition: IfaceType.h:97
Orthant.h
Orthant class.