ThunderEgg  1.0.0
P4estDomainGenerator.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) 2019-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_P4ESTDOMAINGENERATOR_H
22 #define THUNDEREGG_P4ESTDOMAINGENERATOR_H
23 
29 #include <functional>
30 #include <list>
31 #include <p4est_extended.h>
32 namespace ThunderEgg {
37 {
38 public:
51  using BlockMapFunc =
52  std::function<void(int block_no, double unit_x, double unit_y, double& x, double& y)>;
53 
54 private:
58  p4est_t* my_p4est;
64  std::list<std::vector<PatchInfo<2>>> domain_patches;
65 
69  std::array<int, 2> ns;
73  int num_ghost_cells;
79  int curr_level;
83  BlockMapFunc bmf;
84 
88  int id = 0;
89 
93  void extractLevel();
94 
98  void coarsenTree();
99 
103  void createPatchInfos();
104 
108  void linkNeighbors();
109 
113  void updateParentRanksOfPreviousDomain();
114 
115 public:
124  P4estDomainGenerator(p4est_t* p4est,
125  const std::array<int, 2>& ns,
126  int num_ghost_cells,
127  const BlockMapFunc& bmf);
131  P4estDomainGenerator& operator=(const P4estDomainGenerator&);
132  P4estDomainGenerator& operator=(P4estDomainGenerator&&) = default;
134  bool hasCoarserDomain();
136 };
137 } // namespace ThunderEgg
138 #endif
ThunderEgg::P4estDomainGenerator::P4estDomainGenerator
P4estDomainGenerator(p4est_t *p4est, const std::array< int, 2 > &ns, int num_ghost_cells, const BlockMapFunc &bmf)
Construct a new P4estDomainGenerator object.
ThunderEgg::Domain< 2 >
ThunderEgg::P4estDomainGenerator
Generates Domain objects form a given p4est object.
Definition: P4estDomainGenerator.h:36
DomainGenerator.h
DomainGenerator class.
ThunderEgg
The ThunderEgg namespace.
Definition: BiLinearGhostFiller.h:31
ThunderEgg::P4estDomainGenerator::BlockMapFunc
std::function< void(int block_no, double unit_x, double unit_y, double &x, double &y)> BlockMapFunc
Maps coordinate in a block to a coordinate in the domain.
Definition: P4estDomainGenerator.h:52
ThunderEgg::P4estDomainGenerator::getFinestDomain
Domain< 2 > getFinestDomain()
Return the finest domain.
ThunderEgg::P4estDomainGenerator::hasCoarserDomain
bool hasCoarserDomain()
return true if there is a coarser domain to be generated.
ThunderEgg::DomainGenerator
Generates Domain objects.
Definition: DomainGenerator.h:39
ThunderEgg::P4estDomainGenerator::getCoarserDomain
Domain< 2 > getCoarserDomain()
Return a new coarser domain.