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

Method Timestamp

Src/Particle/AMReX_TracerParticles.cpp:196–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196void
197TracerParticleContainer::Timestamp (const std::string& basename,
198 const MultiFab& mf,
199 int lev,
200 Real time,
201 const std::vector<int>& indices)
202{
203 BL_PROFILE("TracerParticleContainer::Timestamp()");
204 //
205 // basename -> base filename for the output file
206 // mf -> the multifab
207 // lev -> level to check for particles
208 // time -> simulation time (will be recorded in Timestamp file)
209 // indices -> indices into mf that we output
210 //
211 AMREX_ASSERT(lev >= 0);
212 AMREX_ASSERT(time >= 0);
213 AMREX_ASSERT(!basename.empty());
214 AMREX_ASSERT(lev <= m_gdb->finestLevel());
215
216 const auto strttime = amrex::second();
217 const Geometry& geom = m_gdb->Geom(lev);
218 const auto plo = geom.ProbLoArray();
219 const auto dxi = geom.InvCellSizeArray();
220
221 const int MyProc = ParallelDescriptor::MyProc();
222 const int NProcs = ParallelContext::NProcsSub();
223 // We'll spread the output over this many files.
224 int nOutFiles(64);
225 ParmParse pp("particles");
226 pp.query("particles_nfiles",nOutFiles);
227 if(nOutFiles == -1) {
228 nOutFiles = NProcs;
229 }
230 nOutFiles = std::max(1, std::min(nOutFiles,NProcs));
231 const int nSets = ((NProcs + (nOutFiles - 1)) / nOutFiles);
232 const int mySet = (MyProc / nOutFiles);
233
234 for (int iSet = 0; iSet < nSets; ++iSet)
235 {
236 if (mySet == iSet)
237 {
238 //
239 // Do we have any particles at this level that need writing?
240 //
241 bool gotwork = NumberOfParticlesAtLevel(lev, true, true) > 0;
242
243 if (gotwork)
244 {
245 std::string FileName = amrex::Concatenate(basename + '_', MyProc % nOutFiles, 2);
246
247 VisMF::IO_Buffer io_buffer(VisMF::IO_Buffer_Size);
248
249 std::ofstream TimeStampFile;
250
251 TimeStampFile.rdbuf()->pubsetbuf(io_buffer.dataPtr(), io_buffer.size());
252
253 TimeStampFile.open(FileName.c_str(), std::ios::out|std::ios::app|std::ios::binary);

Callers

nothing calls this directly

Calls 15

secondFunction · 0.85
NProcsSubFunction · 0.85
ConcatenateFunction · 0.85
copyParticlesFunction · 0.85
The_Pinned_ArenaFunction · 0.85
dtoh_memcpy_asyncFunction · 0.85
streamSynchronizeFunction · 0.85
SendFunction · 0.85
RecvFunction · 0.85
QueueReductionFunction · 0.85
IOProcessorNumberFunction · 0.85
PrintClass · 0.85

Tested by

no test coverage detected