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

Function WritePlotFile

Src/Extern/amrdata/AMReX_WritePlotFile.cpp:292–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292void WritePlotFile(const Vector<MultiFab*>& mfa,
293 const Vector<Box>& probDomain,
294 AmrData& amrdToMimic,
295 const std::string& oFile,
296 bool verbose,
297 const Vector<std::string>& varNames)
298{
299 // If varnames not provided, use names in original plotfile
300 const Vector<std::string>& derives = (varNames.size()==0 ? amrdToMimic.PlotVarNames() : varNames);
301 AMREX_ASSERT(derives.size()==(*mfa[0]).nComp());
302 int ntype = derives.size();
303 int finestLevel = mfa.size() - 1;
304 AMREX_ALWAYS_ASSERT(finestLevel >= 0);
305
306 if (ParallelDescriptor::IOProcessor())
307 if (!amrex::UtilCreateDirectory(oFile,0755))
308 amrex::CreateDirectoryFailed(oFile);
309 //
310 // Force other processors to wait till directory is built.
311 //
312 ParallelDescriptor::Barrier();
313
314 std::string oFileHeader(oFile);
315 oFileHeader += "/Header";
316
317 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
318
319 std::ofstream os;
320
321 os.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
322
323 if (verbose && ParallelDescriptor::IOProcessor())
324 std::cout << "Opening file = " << oFileHeader << '\n';
325
326 os.open(oFileHeader.c_str(), std::ios::out|std::ios::binary);
327
328 if (os.fail())
329 amrex::FileOpenFailed(oFileHeader);
330 //
331 // Start writing plotfile.
332 //
333 os << amrdToMimic.PlotFileVersion() << '\n';
334 int n_var = ntype;
335 os << n_var << '\n';
336 for (int n = 0; n < ntype; n++) os << derives[n] << '\n';
337 os << BL_SPACEDIM << '\n';
338 os << amrdToMimic.Time() << '\n';
339 os << finestLevel << '\n';
340 int i;
341 for (i = 0; i < BL_SPACEDIM; i++) os << amrdToMimic.ProbLo()[i] << ' ';
342 os << '\n';
343 for (i = 0; i < BL_SPACEDIM; i++) os << amrdToMimic.ProbHi()[i] << ' ';
344 os << '\n';
345 for (i = 0; i < finestLevel; i++) os << amrdToMimic.RefRatio()[i] << ' ';
346 os << '\n';
347 for (i = 0; i <= finestLevel; i++) os << probDomain[i] << ' ';
348 os << '\n';
349 for (i = 0; i <= finestLevel; i++) os << 0 << ' ';

Callers 13

EvolveMethod · 0.85
InitDataMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
ComputeAmrDataNormsFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
getErrorNormsFunction · 0.85

Calls 13

IOProcessorFunction · 0.85
BarrierFunction · 0.85
ConcatenateFunction · 0.85
TimeMethod · 0.80
CoordSysMethod · 0.80
ProbDomainMethod · 0.80
WriteFunction · 0.50
sizeMethod · 0.45
nCompMethod · 0.45
dataPtrMethod · 0.45
ProbLoMethod · 0.45
ProbHiMethod · 0.45

Tested by 1

getErrorNormsFunction · 0.68