| 1179 | } // setPlotDirectory |
| 1180 | |
| 1181 | void |
| 1182 | IBInstrumentPanel::writePlotData(const int timestep_num, const double simulation_time) |
| 1183 | { |
| 1184 | if (d_num_meters == 0) return; |
| 1185 | |
| 1186 | IBAMR_TIMER_START(t_write_plot_data); |
| 1187 | #if defined(IBAMR_HAVE_SILO) |
| 1188 | #if !defined(NDEBUG) |
| 1189 | TBOX_ASSERT(timestep_num >= 0); |
| 1190 | TBOX_ASSERT(!d_plot_directory_name.empty()); |
| 1191 | #endif |
| 1192 | |
| 1193 | if (timestep_num != d_instrument_read_timestep_num) |
| 1194 | { |
| 1195 | TBOX_ERROR(d_object_name << "::writePlotData():\n" |
| 1196 | << " time step number: " << timestep_num |
| 1197 | << " is != last time step number: " << d_instrument_read_timestep_num << std::endl); |
| 1198 | } |
| 1199 | |
| 1200 | if (d_plot_directory_name.empty()) |
| 1201 | { |
| 1202 | TBOX_ERROR(d_object_name << "::writePlotData():\n" |
| 1203 | << " dump directory name is empty" << std::endl); |
| 1204 | } |
| 1205 | |
| 1206 | char temp_buf[SILO_NAME_BUFSIZE]; |
| 1207 | std::string current_file_name; |
| 1208 | DBfile* dbfile; |
| 1209 | const int mpi_rank = IBTK_MPI::getRank(); |
| 1210 | const int mpi_nodes = IBTK_MPI::getNodes(); |
| 1211 | |
| 1212 | // Create the working directory. |
| 1213 | snprintf(temp_buf, sizeof(temp_buf), "%06d", d_instrument_read_timestep_num); |
| 1214 | std::string current_dump_directory_name = SILO_DUMP_DIR_PREFIX + temp_buf; |
| 1215 | std::string dump_dirname = d_plot_directory_name + "/" + current_dump_directory_name; |
| 1216 | |
| 1217 | Utilities::recursiveMkdir(dump_dirname); |
| 1218 | |
| 1219 | // Create one local DBfile per MPI process. |
| 1220 | snprintf(temp_buf, sizeof(temp_buf), "%04d", mpi_rank); |
| 1221 | current_file_name = dump_dirname + "/" + SILO_PROCESSOR_FILE_PREFIX; |
| 1222 | current_file_name += temp_buf; |
| 1223 | current_file_name += SILO_PROCESSOR_FILE_POSTFIX; |
| 1224 | |
| 1225 | if (!(dbfile = DBCreate(current_file_name.c_str(), DB_CLOBBER, DB_LOCAL, nullptr, DB_PDB))) |
| 1226 | { |
| 1227 | TBOX_ERROR(d_object_name + "::writePlotData():\n" |
| 1228 | << " Could not create DBfile named " << current_file_name << std::endl); |
| 1229 | } |
| 1230 | |
| 1231 | // Output the web data on the available MPI processes. |
| 1232 | for (unsigned int meter = 0; meter < d_num_meters; ++meter) |
| 1233 | { |
| 1234 | if (static_cast<int>(meter) % mpi_nodes == mpi_rank) |
| 1235 | { |
| 1236 | std::string dirname = d_instrument_names[meter]; |
| 1237 | if (DBMkDir(dbfile, dirname.c_str()) == -1) |
| 1238 | { |