Block-Structured AMR Software Framework
AMReX_AmrParGDB.H
Go to the documentation of this file.
1 #ifndef AMREX_AmrParGDB_H
2 #define AMREX_AmrParGDB_H
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_ParGDB.H>
6 #include <AMReX_AmrCore.H>
7 
8 namespace amrex {
9 
10 class AmrParGDB
11  : public ParGDBBase
12 {
13  friend AmrCore;
14 
15 public:
16 
17  explicit AmrParGDB (AmrCore* amr) noexcept
18  : m_amrcore(amr),
19  m_geom(amr->maxLevel()+1),
20  m_has_geom(amr->maxLevel()+1, 0),
21  m_dmap(amr->maxLevel()+1),
22  m_ba(amr->maxLevel()+1)
23  { }
24 
25  [[nodiscard]] const Geometry& ParticleGeom (int level) const override;
26  [[nodiscard]] const Geometry& Geom (int level) const override;
27 
28  [[nodiscard]] const Vector<Geometry>& ParticleGeom () const override;
29  [[nodiscard]] const Vector<Geometry>& Geom () const override;
30 
31  [[nodiscard]] const DistributionMapping& ParticleDistributionMap (int level) const override;
32  [[nodiscard]] const DistributionMapping& DistributionMap (int level) const override;
33 
34  [[nodiscard]] const Vector<DistributionMapping>& ParticleDistributionMap () const override;
35  [[nodiscard]] const Vector<DistributionMapping>& DistributionMap () const override;
36 
37  [[nodiscard]] const BoxArray& ParticleBoxArray (int level) const override;
38  [[nodiscard]] const BoxArray& boxArray (int level) const override;
39 
40  [[nodiscard]] const Vector<BoxArray>& ParticleBoxArray () const override;
41  [[nodiscard]] const Vector<BoxArray>& boxArray () const override;
42 
43  void SetParticleBoxArray (int level, const BoxArray& new_ba) override;
44  void SetParticleDistributionMap (int level, const DistributionMapping& new_dm) override;
45  void SetParticleGeometry (int level, const Geometry& new_geom) override;
46 
47  void ClearParticleBoxArray (int level) override;
48  void ClearParticleDistributionMap (int level) override;
49  void ClearParticleGeometry (int level) override;
50 
51  [[nodiscard]] bool LevelDefined (int level) const override;
52  [[nodiscard]] int finestLevel () const override;
53  [[nodiscard]] int maxLevel () const override;
54 
55  [[nodiscard]] IntVect refRatio (int level) const override;
56  [[nodiscard]] int MaxRefRatio (int level) const override;
57 
58  [[nodiscard]] Vector<IntVect> refRatio () const override;
59 
60 protected:
61 
67 };
68 
69 inline
70 const Geometry&
71 AmrParGDB::ParticleGeom (int level) const
72 {
73  if (! m_has_geom[level]) {
74  return m_amrcore->Geom(level);
75  } else {
76  return m_geom[level];
77  }
78 }
79 
80 inline
81 const Geometry&
82 AmrParGDB::Geom (int level) const
83 {
84  return m_amrcore->Geom(level);
85 }
86 
87 inline
88 const Vector<Geometry>&
90 {
91  if (! m_has_geom[0]) {
92  return m_amrcore->Geom();
93  } else {
94  return m_geom;
95  }
96 }
97 
98 inline
99 const Vector<Geometry>&
101 {
102  return m_amrcore->Geom();
103 }
104 
105 inline
106 const DistributionMapping&
108 {
109  if (m_dmap[level].empty()) {
110  return m_amrcore->DistributionMap(level);
111  } else {
112  return m_dmap[level];
113  }
114 }
115 
116 inline
117 const DistributionMapping&
118 AmrParGDB::DistributionMap (int level) const
119 {
120  return m_amrcore->DistributionMap(level);
121 }
122 
123 inline
126 {
127  if (m_dmap[0].empty()) {
128  return m_amrcore->DistributionMap();
129  } else {
130  return m_dmap;
131  }
132 }
133 
134 inline
137 {
138  return m_amrcore->DistributionMap();
139 }
140 
141 inline
142 const BoxArray&
144 {
145  if (m_ba[level].empty()) {
146  return m_amrcore->boxArray(level);
147  } else {
148  return m_ba[level];
149  }
150 }
151 
152 inline
153 const BoxArray&
154 AmrParGDB::boxArray (int level) const
155 {
156  return m_amrcore->boxArray(level);
157 }
158 
159 inline
160 const Vector<BoxArray>&
162 {
163  if (m_ba[0].empty()) {
164  return m_amrcore->boxArray();
165  } else {
166  return m_ba;
167  }
168 }
169 
170 inline
171 const Vector<BoxArray>&
173 {
174  return m_amrcore->boxArray();
175 }
176 
177 inline
178 void AmrParGDB::SetParticleBoxArray (int level, const BoxArray& new_ba)
179 {
180  m_ba[level] = new_ba;
181 }
182 
183 inline
185 {
186  m_dmap[level] = new_dmap;
187 }
188 
189 inline
190 void AmrParGDB::SetParticleGeometry (int level, const Geometry& new_geom)
191 {
192  m_has_geom[level] = 1;
193  m_geom[level] = new_geom;
194 }
195 
196 inline
198 {
199  m_ba[level] = BoxArray();
200 }
201 
202 inline
204 {
205  m_dmap[level] = DistributionMapping();
206 }
207 
208 inline
210 {
211  m_geom[level] = Geometry();
212  m_has_geom[level] = 0;
213 }
214 
215 inline
216 bool
217 AmrParGDB::LevelDefined (int level) const
218 {
219  return m_amrcore->LevelDefined(level);
220 }
221 
222 inline
223 int
225 {
226  return m_amrcore->finestLevel();
227 }
228 
229 inline
230 int
232 {
233  return m_amrcore->maxLevel();
234 }
235 
236 inline
237 IntVect
238 AmrParGDB::refRatio (int level) const
239 {
240  return m_amrcore->refRatio(level);
241 }
242 
243 inline
246 {
247  return m_amrcore->refRatio();
248 }
249 
250 inline
251 int
252 AmrParGDB::MaxRefRatio (int level) const
253 {
254  return m_amrcore->MaxRefRatio(level);
255 }
256 
257 }
258 
259 #endif
Provide basic functionalities to set up an AMR hierarchy.
Definition: AMReX_AmrCore.H:25
int maxLevel() const noexcept
Return the max level.
Definition: AMReX_AmrMesh.H:92
const Vector< BoxArray > & boxArray() const noexcept
Definition: AMReX_AmrMesh.H:108
const Vector< Geometry > & Geom() const noexcept
Definition: AMReX_AmrMesh.H:106
bool LevelDefined(int lev) const noexcept
Definition: AMReX_AmrMesh.cpp:441
int finestLevel() const noexcept
Return the finest level.
Definition: AMReX_AmrMesh.H:95
IntVect refRatio(int lev) const noexcept
Return the refinement ratio for level lev.
Definition: AMReX_AmrMesh.H:98
int MaxRefRatio(int lev) const noexcept
Return the maximum refinement ratio in any direction.
Definition: AMReX_AmrMesh.cpp:389
const Vector< DistributionMapping > & DistributionMap() const noexcept
Definition: AMReX_AmrMesh.H:107
Definition: AMReX_AmrParGDB.H:12
AmrCore * m_amrcore
Definition: AMReX_AmrParGDB.H:62
const Vector< DistributionMapping > & DistributionMap() const override
Definition: AMReX_AmrParGDB.H:136
const Vector< BoxArray > & ParticleBoxArray() const override
Definition: AMReX_AmrParGDB.H:161
Vector< IntVect > refRatio() const override
Definition: AMReX_AmrParGDB.H:245
Vector< int > m_has_geom
Definition: AMReX_AmrParGDB.H:64
const Vector< Geometry > & Geom() const override
Definition: AMReX_AmrParGDB.H:100
Vector< BoxArray > m_ba
Definition: AMReX_AmrParGDB.H:66
void ClearParticleGeometry(int level) override
Definition: AMReX_AmrParGDB.H:209
const Vector< BoxArray > & boxArray() const override
Definition: AMReX_AmrParGDB.H:172
int maxLevel() const override
Definition: AMReX_AmrParGDB.H:231
void ClearParticleBoxArray(int level) override
Definition: AMReX_AmrParGDB.H:197
void SetParticleDistributionMap(int level, const DistributionMapping &new_dm) override
Definition: AMReX_AmrParGDB.H:184
void SetParticleBoxArray(int level, const BoxArray &new_ba) override
Definition: AMReX_AmrParGDB.H:178
Vector< Geometry > m_geom
Definition: AMReX_AmrParGDB.H:63
void ClearParticleDistributionMap(int level) override
Definition: AMReX_AmrParGDB.H:203
const Vector< DistributionMapping > & ParticleDistributionMap() const override
Definition: AMReX_AmrParGDB.H:125
friend AmrCore
Definition: AMReX_AmrParGDB.H:13
AmrParGDB(AmrCore *amr) noexcept
Definition: AMReX_AmrParGDB.H:17
Vector< DistributionMapping > m_dmap
Definition: AMReX_AmrParGDB.H:65
int finestLevel() const override
Definition: AMReX_AmrParGDB.H:224
bool LevelDefined(int level) const override
Definition: AMReX_AmrParGDB.H:217
void SetParticleGeometry(int level, const Geometry &new_geom) override
Definition: AMReX_AmrParGDB.H:190
int MaxRefRatio(int level) const override
Definition: AMReX_AmrParGDB.H:252
const Vector< Geometry > & ParticleGeom() const override
Definition: AMReX_AmrParGDB.H:89
A collection of Boxes stored in an Array.
Definition: AMReX_BoxArray.H:549
Calculates the distribution of FABs to MPI processes.
Definition: AMReX_DistributionMapping.H:41
Rectangular problem domain geometry.
Definition: AMReX_Geometry.H:73
Definition: AMReX_ParGDB.H:13
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition: AMReX_Vector.H:27
Definition: AMReX_Amr.cpp:49