ThunderEgg  1.0.0
P8estDomainGenerator.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) 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_P8ESTDOMAINGENERATOR_H
22 #define THUNDEREGG_P8ESTDOMAINGENERATOR_H
23 
29 #include <functional>
30 #include <p8est.h>
31 namespace ThunderEgg {
36 {
37 public:
52  using BlockMapFunc = std::function<void(int block_no,
53  double unit_x,
54  double unit_y,
55  double unit_z,
56  double& x,
57  double& y,
58  double& z)>;
59 
60 private:
64  p8est_t* my_p8est;
70  std::list<std::vector<PatchInfo<3>>> domain_patches;
71 
75  std::array<int, 3> ns;
79  int num_ghost_cells;
85  int curr_level;
89  BlockMapFunc bmf;
90 
94  int id = 0;
95 
99  void extractLevel();
100 
104  void coarsenTree();
105 
109  void createPatchInfos();
110 
114  void linkNeighbors();
115 
119  void updateParentRanksOfPreviousDomain();
120 
121 public:
130  P8estDomainGenerator(p8est_t* p8est,
131  const std::array<int, 3>& ns,
132  int num_ghost_cells,
133  const BlockMapFunc& bmf);
136  P8estDomainGenerator& operator=(const P8estDomainGenerator&);
137  P8estDomainGenerator& operator=(P8estDomainGenerator&&) = default;
140  bool hasCoarserDomain();
142 };
143 } // namespace ThunderEgg
144 #endif
ThunderEgg::Domain< 3 >
ThunderEgg::P8estDomainGenerator::BlockMapFunc
std::function< void(int block_no, double unit_x, double unit_y, double unit_z, double &x, double &y, double &z)> BlockMapFunc
Maps coordinate in a block to a coordinate in the domain.
Definition: P8estDomainGenerator.h:58
ThunderEgg::P8estDomainGenerator::getCoarserDomain
Domain< 3 > getCoarserDomain()
Return a new coarser domain.
DomainGenerator.h
DomainGenerator class.
ThunderEgg
The ThunderEgg namespace.
Definition: BiLinearGhostFiller.h:31
ThunderEgg::P8estDomainGenerator::hasCoarserDomain
bool hasCoarserDomain()
return true if there is a coarser domain to be generated.
ThunderEgg::P8estDomainGenerator::getFinestDomain
Domain< 3 > getFinestDomain()
Return the finest domain.
ThunderEgg::P8estDomainGenerator
Generates Domain objects form a given p4est object.
Definition: P8estDomainGenerator.h:35
ThunderEgg::DomainGenerator
Generates Domain objects.
Definition: DomainGenerator.h:39
ThunderEgg::P8estDomainGenerator::P8estDomainGenerator
P8estDomainGenerator(p8est_t *p8est, const std::array< int, 3 > &ns, int num_ghost_cells, const BlockMapFunc &bmf)
Construct a new P8estDomainGenerator object.