Block-Structured AMR Software Framework
AMReX_PlotFileUtil.H
Go to the documentation of this file.
1 #ifndef AMREX_PLOTFILEUTIL_H_
2 #define AMREX_PLOTFILEUTIL_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_Array.H>
6 #include <AMReX_Geometry.H>
7 #include <AMReX_MultiFab.H>
9 #include <AMReX_Vector.H>
10 
11 #ifdef AMREX_USE_HDF5
12 #include <AMReX_PlotFileUtilHDF5.H>
13 #endif
14 
15 #include <ostream>
16 #include <string>
17 #include <memory>
18 
19 namespace amrex
20 {
22  std::string LevelPath (int level, const std::string &levelPrefix = "Level_");
23 
25  std::string MultiFabHeaderPath (int level,
26  const std::string &levelPrefix = "Level_",
27  const std::string &mfPrefix = "Cell");
28 
30  std::string LevelFullPath (int level,
31  const std::string &plotfilename,
32  const std::string &levelPrefix = "Level_");
33 
35  std::string MultiFabFileFullPrefix (int level,
36  const std::string &plotfilename,
37  const std::string &levelPrefix = "Level_",
38  const std::string &mfPrefix = "Cell");
39 
40 
54  void PreBuildDirectorHierarchy (const std::string &dirName,
55  const std::string &subDirPrefix,
56  int nSubDirs,
57  bool callBarrier);
58 
63  void WriteGenericPlotfileHeader (std::ostream &HeaderFile,
64  int nlevels,
65  const Vector<BoxArray> &bArray,
66  const Vector<std::string> &varnames,
67  const Vector<Geometry> &geom,
68  Real time,
69  const Vector<int> &level_steps,
70  const Vector<IntVect> &ref_ratio,
71  const std::string &versionName = "HyperCLaw-V1.1",
72  const std::string &levelPrefix = "Level_",
73  const std::string &mfPrefix = "Cell");
74 
75  void WriteSingleLevelPlotfile (const std::string &plotfilename,
76  const MultiFab &mf,
77  const Vector<std::string> &varnames,
78  const Geometry &geom,
79  Real t,
80  int level_step,
81  const std::string &versionName = "HyperCLaw-V1.1",
82  const std::string &levelPrefix = "Level_",
83  const std::string &mfPrefix = "Cell",
84  const Vector<std::string>& extra_dirs = Vector<std::string>());
85 
86  void WriteMultiLevelPlotfile (const std::string &plotfilename,
87  int nlevels,
88  const Vector<const MultiFab*> &mf,
89  const Vector<std::string> &varnames,
90  const Vector<Geometry> &geom,
91  Real time,
92  const Vector<int> &level_steps,
93  const Vector<IntVect> &ref_ratio,
94  const std::string &versionName = "HyperCLaw-V1.1",
95  const std::string &levelPrefix = "Level_",
96  const std::string &mfPrefix = "Cell",
97  const Vector<std::string>& extra_dirs = Vector<std::string>());
98 
112  void WriteMLMF (const std::string &plotfilename,
113  const Vector<const MultiFab*>& mf,
114  const Vector<Geometry> &geom);
115 
116  void WriteMultiLevelPlotfileHeaders (const std::string& plotfilename, int nlevels,
117  const Vector<const MultiFab*>& mf,
118  const Vector<std::string>& varnames,
119  const Vector<Geometry>& geom, Real time, const Vector<int>& level_steps,
120  const Vector<IntVect>& ref_ratio,
121  const std::string &versionName = "HyperCLaw-V1.1",
122  const std::string &levelPrefix = "Level_",
123  const std::string &mfPrefix = "Cell",
124  const Vector<std::string>& extra_dirs = Vector<std::string>());
125 
126 
127 #ifdef AMREX_USE_EB
128  void EB_WriteSingleLevelPlotfile (const std::string &plotfilename,
129  const MultiFab &mf,
130  const Vector<std::string> &varnames,
131  const Geometry &geom,
132  Real t,
133  int level_step,
134  const std::string &versionName = "HyperCLaw-V1.1",
135  const std::string &levelPrefix = "Level_",
136  const std::string &mfPrefix = "Cell",
137  const Vector<std::string>& extra_dirs = Vector<std::string>());
138 
139  void EB_WriteMultiLevelPlotfile (const std::string &plotfilename,
140  int nlevels,
141  const Vector<const MultiFab*> &mf,
142  const Vector<std::string> &varnames,
143  const Vector<Geometry> &geom,
144  Real time,
145  const Vector<int> &level_steps,
146  const Vector<IntVect> &ref_ratio,
147  const std::string &versionName = "HyperCLaw-V1.1",
148  const std::string &levelPrefix = "Level_",
149  const std::string &mfPrefix = "Cell",
150  const Vector<std::string>& extra_dirs = Vector<std::string>());
151 
152 #endif
153 
154  // helper class for reading plotfile
156  {
157  public:
158  PlotFileData (std::string const& plotfile_name) : m_impl(new PlotFileDataImpl(plotfile_name)) {}
159 
160  [[nodiscard]] int spaceDim () const noexcept { return m_impl->spaceDim(); }
161 
162  [[nodiscard]] Real time () const noexcept { return m_impl->time(); }
163 
164  [[nodiscard]] int finestLevel () const noexcept { return m_impl->finestLevel(); }
165 
166  [[nodiscard]] int refRatio (int level) const noexcept { return m_impl->refRatio(level); }
167 
168  [[nodiscard]] int levelStep (int level) const noexcept { return m_impl->levelStep(level); }
169 
170  [[nodiscard]] const BoxArray& boxArray (int level) const noexcept { return m_impl->boxArray(level); }
171 
172  [[nodiscard]] const DistributionMapping& DistributionMap (int level) const noexcept { return m_impl->DistributionMap(level); }
173 
174  void syncDistributionMap (PlotFileData const& src) noexcept { m_impl->syncDistributionMap(*src.m_impl); }
175 
176  void syncDistributionMap (int level, PlotFileData const& src) noexcept { m_impl->syncDistributionMap(level, *src.m_impl); }
177 
178  [[nodiscard]] int coordSys () const noexcept { return m_impl->coordSys(); }
179 
180  [[nodiscard]] Box probDomain (int level) const noexcept { return m_impl->probDomain(level); }
181 
182  [[nodiscard]] Array<Real,AMREX_SPACEDIM> probSize () const noexcept { return m_impl->probSize(); }
183  [[nodiscard]] Array<Real,AMREX_SPACEDIM> probLo () const noexcept { return m_impl->probLo(); }
184  [[nodiscard]] Array<Real,AMREX_SPACEDIM> probHi () const noexcept { return m_impl->probHi(); }
185  [[nodiscard]] Array<Real,AMREX_SPACEDIM> cellSize (int level) const noexcept { return m_impl->cellSize(level); }
186 
187  [[nodiscard]] const Vector<std::string>& varNames () const noexcept { return m_impl->varNames(); }
188 
189  [[nodiscard]] int nComp () const noexcept { return m_impl->nComp(); }
190  [[nodiscard]] IntVect nGrowVect (int level) const noexcept { return m_impl->nGrowVect(level); }
191 
192  MultiFab get (int level) noexcept { return m_impl->get(level); }
193  MultiFab get (int level, std::string const& varname) noexcept { return m_impl->get(level, varname); }
194 
195  private:
196  std::unique_ptr<PlotFileDataImpl> m_impl;
197  };
198 }
199 
200 #endif
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
A collection (stored as an array) of FArrayBox objects.
Definition: AMReX_MultiFab.H:38
Definition: AMReX_PlotFileDataImpl.H:12
Definition: AMReX_PlotFileUtil.H:156
void syncDistributionMap(int level, PlotFileData const &src) noexcept
Definition: AMReX_PlotFileUtil.H:176
const DistributionMapping & DistributionMap(int level) const noexcept
Definition: AMReX_PlotFileUtil.H:172
Array< Real, AMREX_SPACEDIM > probSize() const noexcept
Definition: AMReX_PlotFileUtil.H:182
std::unique_ptr< PlotFileDataImpl > m_impl
Definition: AMReX_PlotFileUtil.H:196
Array< Real, AMREX_SPACEDIM > probHi() const noexcept
Definition: AMReX_PlotFileUtil.H:184
int coordSys() const noexcept
Definition: AMReX_PlotFileUtil.H:178
const BoxArray & boxArray(int level) const noexcept
Definition: AMReX_PlotFileUtil.H:170
MultiFab get(int level) noexcept
Definition: AMReX_PlotFileUtil.H:192
Box probDomain(int level) const noexcept
Definition: AMReX_PlotFileUtil.H:180
PlotFileData(std::string const &plotfile_name)
Definition: AMReX_PlotFileUtil.H:158
IntVect nGrowVect(int level) const noexcept
Definition: AMReX_PlotFileUtil.H:190
void syncDistributionMap(PlotFileData const &src) noexcept
Definition: AMReX_PlotFileUtil.H:174
Array< Real, AMREX_SPACEDIM > probLo() const noexcept
Definition: AMReX_PlotFileUtil.H:183
MultiFab get(int level, std::string const &varname) noexcept
Definition: AMReX_PlotFileUtil.H:193
int finestLevel() const noexcept
Definition: AMReX_PlotFileUtil.H:164
int spaceDim() const noexcept
Definition: AMReX_PlotFileUtil.H:160
int refRatio(int level) const noexcept
Definition: AMReX_PlotFileUtil.H:166
const Vector< std::string > & varNames() const noexcept
Definition: AMReX_PlotFileUtil.H:187
Real time() const noexcept
Definition: AMReX_PlotFileUtil.H:162
int nComp() const noexcept
Definition: AMReX_PlotFileUtil.H:189
Array< Real, AMREX_SPACEDIM > cellSize(int level) const noexcept
Definition: AMReX_PlotFileUtil.H:185
int levelStep(int level) const noexcept
Definition: AMReX_PlotFileUtil.H:168
Definition: AMReX_Amr.cpp:49
std::string LevelFullPath(int level, const std::string &plotfilename, const std::string &levelPrefix)
return the full path of the level directory, e.g., plt00005/Level_5
Definition: AMReX_PlotFileUtil.cpp:29
std::string LevelPath(int level, const std::string &levelPrefix)
return the name of the level directory, e.g., Level_5
Definition: AMReX_PlotFileUtil.cpp:17
std::string MultiFabFileFullPrefix(int level, const std::string &plotfilename, const std::string &levelPrefix, const std::string &mfPrefix)
return the full path multifab prefix, e.g., plt00005/Level_5/Cell
Definition: AMReX_PlotFileUtil.cpp:41
void WriteMLMF(const std::string &plotfilename, const Vector< const MultiFab * > &mf, const Vector< Geometry > &geom)
write a plotfile to disk given: -plotfile name -vector of MultiFabs -vector of Geometrys variable nam...
Definition: AMReX_PlotFileUtil.cpp:249
void PreBuildDirectorHierarchy(const std::string &dirName, const std::string &, int nSubDirs, bool callBarrier)
prebuild a hierarchy of directories dirName is built first. if dirName exists, it is renamed....
Definition: AMReX_PlotFileUtil.cpp:56
void WriteSingleLevelPlotfile(const std::string &plotfilename, const MultiFab &mf, const Vector< std::string > &varnames, const Geometry &geom, Real time, int level_step, const std::string &versionName, const std::string &levelPrefix, const std::string &mfPrefix, const Vector< std::string > &extra_dirs)
Definition: AMReX_PlotFileUtil.cpp:341
void WriteMultiLevelPlotfile(const std::string &plotfilename, int nlevels, const Vector< const MultiFab * > &mf, const Vector< std::string > &varnames, const Vector< Geometry > &geom, Real time, const Vector< int > &level_steps, const Vector< IntVect > &ref_ratio, const std::string &versionName, const std::string &levelPrefix, const std::string &mfPrefix, const Vector< std::string > &extra_dirs)
Definition: AMReX_PlotFileUtil.cpp:159
std::string MultiFabHeaderPath(int level, const std::string &levelPrefix, const std::string &mfPrefix)
return the path of the multifab to write to the header, e.g., Level_5/Cell
Definition: AMReX_PlotFileUtil.cpp:22
void WriteMultiLevelPlotfileHeaders(const std::string &plotfilename, int nlevels, const Vector< const MultiFab * > &mf, const Vector< std::string > &varnames, const Vector< Geometry > &geom, Real time, const Vector< int > &level_steps, const Vector< IntVect > &ref_ratio, const std::string &versionName, const std::string &levelPrefix, const std::string &mfPrefix, const Vector< std::string > &extra_dirs)
Definition: AMReX_PlotFileUtil.cpp:285
void WriteGenericPlotfileHeader(std::ostream &HeaderFile, int nlevels, const Vector< BoxArray > &bArray, const Vector< std::string > &varnames, const Vector< Geometry > &geom, Real time, const Vector< int > &level_steps, const Vector< IntVect > &ref_ratio, const std::string &versionName, const std::string &levelPrefix, const std::string &mfPrefix)
Definition: AMReX_PlotFileUtil.cpp:73
std::array< T, N > Array
Definition: AMReX_Array.H:24