MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / WriteMultiLevelPlotfile

Function WriteMultiLevelPlotfile

Src/Base/AMReX_PlotFileUtil.cpp:159–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157
158
159void
160WriteMultiLevelPlotfile (const std::string& plotfilename, int nlevels,
161 const Vector<const MultiFab*>& mf,
162 const Vector<std::string>& varnames,
163 const Vector<Geometry>& geom, Real time,
164 const Vector<int>& level_steps,
165 const Vector<IntVect>& ref_ratio,
166 const std::string &versionName,
167 const std::string &levelPrefix,
168 const std::string &mfPrefix,
169 const Vector<std::string>& extra_dirs)
170{
171 BL_PROFILE("WriteMultiLevelPlotfile()");
172
173 BL_ASSERT(nlevels <= mf.size());
174 BL_ASSERT(nlevels <= geom.size());
175 BL_ASSERT(nlevels <= ref_ratio.size()+1);
176 BL_ASSERT(nlevels <= level_steps.size());
177 BL_ASSERT(mf[0]->nComp() == varnames.size());
178
179 int finest_level = nlevels-1;
180
181 bool callBarrier(false);
182 PreBuildDirectorHierarchy(plotfilename, levelPrefix, nlevels, callBarrier);
183 if (!extra_dirs.empty()) {
184 for (const auto& d : extra_dirs) {
185 std::string ed = plotfilename;
186 ed.append("/").append(d);
187 amrex::PreBuildDirectorHierarchy(ed, levelPrefix, nlevels, callBarrier);
188 }
189 }
190 ParallelDescriptor::Barrier();
191
192 if (ParallelDescriptor::MyProc() == ParallelDescriptor::NProcs()-1) {
193 Vector<BoxArray> boxArrays(nlevels);
194 for(int level(0); level < boxArrays.size(); ++level) {
195 boxArrays[level] = mf[level]->boxArray();
196 }
197
198 auto f = [=]() {
199 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
200 std::string HeaderFileName(plotfilename + "/Header");
201 std::ofstream HeaderFile;
202 HeaderFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
203 HeaderFile.open(HeaderFileName.c_str(), std::ofstream::out |
204 std::ofstream::trunc |
205 std::ofstream::binary);
206 if( ! HeaderFile.good()) { FileOpenFailed(HeaderFileName); }
207 WriteGenericPlotfileHeader(HeaderFile, nlevels, boxArrays, varnames,
208 geom, time, level_steps, ref_ratio, versionName,
209 levelPrefix, mfPrefix);
210 };
211
212 if (AsyncOut::UseAsyncOut()) {
213 AsyncOut::Submit(std::move(f));
214 } else {
215 f();
216 }

Callers 15

test_assign_densityFunction · 0.85
testParticleMeshFunction · 0.85
testFunction · 0.85
test_async_ioFunction · 0.85
testFunction · 0.85
testFunction · 0.85
WritePlotfilesFunction · 0.85
writePlotfileMethod · 0.85
writePlotfileMethod · 0.85
writePlotfileMethod · 0.85
writePlotfileMethod · 0.85
writePlotfileMethod · 0.85

Calls 15

BarrierFunction · 0.85
UseAsyncOutFunction · 0.85
SubmitFunction · 0.85
MultiFabFileFullPrefixFunction · 0.85
MFInfoClass · 0.85
CopyFunction · 0.85
DistributionMapMethod · 0.80
FactoryMethod · 0.80
MyProcFunction · 0.70
NProcsFunction · 0.70

Tested by 11

test_assign_densityFunction · 0.68
test_async_ioFunction · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68
writePlotfileMethod · 0.68