| 194 | } |
| 195 | |
| 196 | void |
| 197 | TracerParticleContainer::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); |
nothing calls this directly
no test coverage detected