ThunderEgg  1.0.0
NormalIfaceInfo.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) 2020-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_NORMALIFACEINFO_H
22 #define THUNDEREGG_SCHUR_NORMALIFACEINFO_H
23 
28 #include <ThunderEgg/PatchInfo.h>
30 namespace ThunderEgg {
31 namespace Schur {
37 template<int D>
38 class NormalIfaceInfo : public IfaceInfo<D>
39 {
40 private:
48  static int GetRank(const PatchInfo<D>& pinfo, Side<D> s)
49  {
50  if (s.isLowerOnAxis()) {
51  // lower axis interface belongs to neighboring rank
52  auto nbr_info = pinfo.getNormalNbrInfo(s);
53  return nbr_info.rank;
54  } else {
55  // higher axis interafce belongs to this patch's rank
56  return pinfo.rank;
57  }
58  }
59 
67  static int GetId(const PatchInfo<D>& pinfo, Side<D> s)
68  {
69  if (s.isLowerOnAxis()) {
70  // lower axis interface belongs to neighboring rank
71  auto nbr_info = pinfo.getNormalNbrInfo(s);
72  return (int)(nbr_info.id * Side<D>::number_of + s.opposite().getIndex());
73  } else {
74  // higher axis interafce belongs to this patch's rank
75  return (int)(pinfo.id * Side<D>::number_of + s.getIndex());
76  }
77  }
78 
79 public:
87  : IfaceInfo<D>(GetRank(pinfo, s), GetId(pinfo, s))
88  {}
89 };
90 } // namespace Schur
91 } // namespace ThunderEgg
92 #endif
ThunderEgg::Schur::NormalIfaceInfo::NormalIfaceInfo
NormalIfaceInfo(const PatchInfo< D > &pinfo, Side< D > s)
Construct a new NormalIfaceInfo object.
Definition: NormalIfaceInfo.h:86
ThunderEgg::Schur::NormalIfaceInfo
This represents an interface where the neighbor is at the same refinement level.
Definition: NormalIfaceInfo.h:38
ThunderEgg::PatchInfo::getNormalNbrInfo
NormalNbrInfo< M > & getNormalNbrInfo(Face< D, M > s) const
Get the NormalNbrInfo object for a side.
Definition: PatchInfo.h:245
ThunderEgg::Face::isLowerOnAxis
auto isLowerOnAxis() const -> typename std::enable_if< D<=3 &&D >=1 &&M==D - 1 &&N==N, bool >::type
Return if this side is lower on it's axis.
Definition: Face.h:468
ThunderEgg
The ThunderEgg namespace.
Definition: BiLinearGhostFiller.h:31
ThunderEgg::PatchInfo::id
int id
The globally unique ID of the patch This ID only needs to be unique within a Domain.
Definition: PatchInfo.h:65
ThunderEgg::Face::getIndex
size_t getIndex() const
Get the index for this Face.
Definition: Face.h:452
PatchInfo.h
PatchInfo class.
ThunderEgg::Schur::IfaceInfo
The IfaceInfo class represents the information for an interface on a given side of the patch.
Definition: IfaceInfo.h:43
ThunderEgg::PatchInfo
Contains metadata for a patch.
Definition: PatchInfo.h:51
ThunderEgg::PatchInfo::rank
int rank
MPI rank of this patch.
Definition: PatchInfo.h:107
IfaceInfo.h
IfaceInfo class.
ThunderEgg::Face
Enum-style class for the faces of an n-dimensional cube.
Definition: Face.h:41
ThunderEgg::Face::opposite
Face< D, M > opposite() const
Get the face on the opposite side of the hypercube.
Definition: Face.h:489