24 #include <sys/types.h> 69 if (
name.rfind(
".nem") + 4 ==
name.size() ||
72 std::ostringstream full_name;
76 int field_width = cast_int<int>(full_name.str().size());
84 <<
'.' << std::setfill(
'0') << std::setw(field_width) << mymesh.
processor_id();
86 std::ifstream in (full_name.str().c_str());
89 libmesh_error_msg(
"ERROR: cannot locate specified file:\n\t" << full_name.str());
91 else if (
name.rfind(
".cp")) {}
94 std::ifstream in (
name.c_str());
97 libmesh_error_msg(
"ERROR: cannot locate specified file:\n\t" <<
name);
104 if ((
name.rfind(
".xda") <
name.size()) ||
107 XdrIO xdr_io(mymesh);
110 if (
name.rfind(
".xda") <
name.size())
140 #ifdef LIBMESH_HAVE_LIBHILBERT 147 else if (
name.rfind(
".nem") <
name.size() ||
150 else if (
name.rfind(
".cp") <
name.size())
152 if (
name.rfind(
".cpa") <
name.size())
167 LOG_SCOPE(
"read()",
"NameBasedIO");
169 std::ostringstream pid_suffix;
170 pid_suffix <<
'_' << getpid();
172 std::string new_name =
name;
173 if (
name.size() -
name.rfind(
".bz2") == 4)
175 #ifdef LIBMESH_HAVE_BZIP 176 new_name.erase(new_name.end() - 4, new_name.end());
177 new_name += pid_suffix.str();
178 std::string system_string =
"bunzip2 -f -k -c ";
179 system_string +=
name +
" > " + new_name;
180 LOG_SCOPE(
"system(bunzip2)",
"NameBasedIO");
181 if (std::system(system_string.c_str()))
182 libmesh_file_error(system_string);
184 libmesh_error_msg(
"ERROR: need bzip2/bunzip2 to open .bz2 file " <<
name);
187 else if (
name.size() -
name.rfind(
".xz") == 3)
189 #ifdef LIBMESH_HAVE_XZ 190 new_name.erase(new_name.end() - 3, new_name.end());
191 new_name += pid_suffix.str();
192 std::string system_string =
"xz -f -d -k -c ";
193 system_string +=
name +
" > " + new_name;
194 LOG_SCOPE(
"system(xz -d)",
"XdrIO");
195 if (std::system(system_string.c_str()))
196 libmesh_file_error(system_string);
198 libmesh_error_msg(
"ERROR: need xz to open .xz file " <<
name);
202 if (new_name.rfind(
".mat") < new_name.size())
205 else if (new_name.rfind(
".ucd") < new_name.size())
208 else if ((new_name.rfind(
".off") < new_name.size()) ||
209 (new_name.rfind(
".ogl") < new_name.size()) ||
210 (new_name.rfind(
".oogl") < new_name.size()))
213 else if (new_name.rfind(
".unv") < new_name.size())
216 else if ((new_name.rfind(
".node") < new_name.size()) ||
217 (new_name.rfind(
".ele") < new_name.size()))
220 else if (new_name.rfind(
".exd") < new_name.size() ||
221 new_name.rfind(
".e") < new_name.size())
224 else if (new_name.rfind(
".msh") < new_name.size())
227 else if (new_name.rfind(
".gmv") < new_name.size())
230 else if (new_name.rfind(
".vtu") < new_name.size())
233 else if (new_name.rfind(
".inp") < new_name.size())
238 libmesh_error_msg(
" ERROR: Unrecognized file extension: " \
240 <<
"\n I understand the following:\n\n" \
241 <<
" *.e -- Sandia's ExodusII format\n" \
242 <<
" *.exd -- Sandia's ExodusII format\n" \
243 <<
" *.gmv -- LANL's General Mesh Viewer format\n" \
244 <<
" *.mat -- Matlab triangular ASCII file\n" \
245 <<
" *.n -- Sandia's Nemesis format\n" \
246 <<
" *.nem -- Sandia's Nemesis format\n" \
247 <<
" *.off -- OOGL OFF surface format\n" \
248 <<
" *.ucd -- AVS's ASCII UCD format\n" \
249 <<
" *.unv -- I-deas Universal format\n" \
250 <<
" *.vtu -- Paraview VTK format\n" \
251 <<
" *.inp -- Abaqus .inp format\n" \
252 <<
" *.xda -- libMesh ASCII format\n" \
253 <<
" *.xdr -- libMesh binary format\n" \
254 <<
" *.gz -- any above format gzipped\n" \
255 <<
" *.bz2 -- any above format bzip2'ed\n" \
256 <<
" *.xz -- any above format xzipped\n" \
257 <<
" *.cpa -- libMesh Checkpoint ASCII format\n" \
258 <<
" *.cpr -- libMesh Checkpoint binary format\n");
263 if (
name.size() -
name.rfind(
".bz2") == 4)
264 std::remove(new_name.c_str());
265 if (
name.size() -
name.rfind(
".xz") == 3)
266 std::remove(new_name.c_str());
285 if (
name.rfind(
".xda") <
name.size())
288 else if (
name.rfind(
".xdr") <
name.size())
291 else if (
name.rfind(
".nem") <
name.size() ||
300 std::string new_name =
name;
305 std::ostringstream pid_suffix;
306 pid_suffix <<
'_' << pid_0;
308 if (
name.size() -
name.rfind(
".bz2") == 4)
310 new_name.erase(new_name.end() - 4, new_name.end());
311 new_name += pid_suffix.str();
313 else if (
name.size() -
name.rfind(
".xz") == 3)
315 new_name.erase(new_name.end() - 3, new_name.end());
316 new_name += pid_suffix.str();
322 if (new_name.rfind(
".dat") < new_name.size())
325 else if (new_name.rfind(
".plt") < new_name.size())
328 else if (new_name.rfind(
".ucd") < new_name.size())
331 else if (new_name.rfind(
".gmv") < new_name.size())
341 else if (new_name.rfind(
".e") < new_name.size())
344 else if (new_name.rfind(
".unv") < new_name.size())
347 else if (new_name.rfind(
".mesh") < new_name.size())
350 else if (new_name.rfind(
".poly") < new_name.size())
353 else if (new_name.rfind(
".msh") < new_name.size())
356 else if (new_name.rfind(
".fro") < new_name.size())
359 else if (new_name.rfind(
".vtu") < new_name.size())
365 <<
" ERROR: Unrecognized file extension: " <<
name 366 <<
"\n I understand the following:\n\n" 367 <<
" *.dat -- Tecplot ASCII file\n" 368 <<
" *.e -- Sandia's ExodusII format\n" 369 <<
" *.exd -- Sandia's ExodusII format\n" 370 <<
" *.fro -- ACDL's surface triangulation file\n" 371 <<
" *.gmv -- LANL's GMV (General Mesh Viewer) format\n" 372 <<
" *.mesh -- MEdit mesh format\n" 373 <<
" *.mgf -- MGF binary mesh format\n" 374 <<
" *.msh -- GMSH ASCII file\n" 375 <<
" *.n -- Sandia's Nemesis format\n" 376 <<
" *.nem -- Sandia's Nemesis format\n" 377 <<
" *.plt -- Tecplot binary file\n" 378 <<
" *.poly -- TetGen ASCII file\n" 379 <<
" *.ucd -- AVS's ASCII UCD format\n" 380 <<
" *.ugrid -- Kelly's DIVA ASCII format\n" 381 <<
" *.unv -- I-deas Universal format\n" 382 <<
" *.vtu -- VTK (paraview-readable) format\n" 383 <<
" *.xda -- libMesh ASCII format\n" 384 <<
" *.xdr -- libMesh binary format,\n" 386 <<
"\n Exiting without writing output\n";
391 if (
name.size() -
name.rfind(
".bz2") == 4)
393 LOG_SCOPE(
"system(bzip2)",
"NameBasedIO");
396 std::string system_string =
"bzip2 -f -c ";
397 system_string += new_name +
" > " +
name;
398 if (std::system(system_string.c_str()))
399 libmesh_file_error(system_string);
400 std::remove(new_name.c_str());
404 if (
name.size() -
name.rfind(
".xz") == 3)
406 LOG_SCOPE(
"system(xz)",
"NameBasedIO");
409 std::string system_string =
"xz -f -c ";
410 system_string += new_name +
" > " +
name;
411 if (std::system(system_string.c_str()))
412 libmesh_file_error(system_string);
413 std::remove(new_name.c_str());
423 const std::vector<Number> & v,
424 const std::vector<std::string> & vn)
429 if (
name.rfind(
".dat") <
name.size())
432 else if (
name.rfind(
".e") <
name.size())
435 else if (
name.rfind(
".gmv") <
name.size())
447 else if (
name.rfind(
".mesh") <
name.size())
450 else if (
name.rfind(
".msh") <
name.size())
453 else if (
name.rfind(
".nem") <
name.size() ||
457 else if (
name.rfind(
".plt") <
name.size())
460 else if (
name.rfind(
".pvtu") <
name.size())
463 else if (
name.rfind(
".ucd") <
name.size())
469 <<
" ERROR: Unrecognized file extension: " <<
name 470 <<
"\n I understand the following:\n\n" 471 <<
" *.dat -- Tecplot ASCII file\n" 472 <<
" *.e -- Sandia's ExodusII format\n" 473 <<
" *.exd -- Sandia's ExodusII format\n" 474 <<
" *.gmv -- LANL's GMV (General Mesh Viewer) format\n" 475 <<
" *.mesh -- MEdit mesh format\n" 476 <<
" *.msh -- GMSH ASCII file\n" 477 <<
" *.n -- Sandia's Nemesis format\n" 478 <<
" *.nem -- Sandia's Nemesis format\n" 479 <<
" *.plt -- Tecplot binary file\n" 480 <<
" *.pvtu -- Paraview VTK file\n" 481 <<
" *.ucd -- AVS's ASCII UCD format\n" 482 <<
"\n Exiting without writing output\n";
489 const std::set<std::string> * system_names)
495 if (filename.rfind(
".xda") < filename.size())
502 else if (filename.rfind(
".xdr") < filename.size())
513 (filename, es, system_names);
virtual void read(const std::string &name) override
std::string name(const ElemQuality q)
virtual void read(const std::string &mesh_file) override
virtual void read(const std::string &) override
virtual void write_equation_systems(const std::string &filename, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Manages multiples systems of equations.
virtual void write(const std::string &name) override
virtual void read(const std::string &base_filename) override
virtual void read(const std::string &) override
virtual void read(const std::string &mesh_file) override
virtual void write(const std::string &) override
void allow_renumbering(bool allow)
virtual void write(const std::string &) override
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
Handles reading and writing of Exodus binary files.
virtual void read(const std::string &input_name) override
virtual void read(const std::string &name) override
virtual void write(const std::string &) override
const Parallel::Communicator & comm() const
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
virtual void read(const std::string &) override
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
void write(const std::string &name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
virtual void write(const std::string &) override
processor_id_type n_processors() const
Reads OOF OOGL triangulated surface files.
virtual void write(const std::string &) override
virtual void write(const std::string &mesh_file) override
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
OStreamProxy err(std::cerr)
virtual void write(const std::string &) override
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
virtual void read(const std::string &name) override
virtual void write(const std::string &) override
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) override
unsigned int n_partitions() const
subdomain_id_type n_subdomains() const
virtual void read(const std::string &name) override
virtual void write(const std::string &fname) override
void broadcast(MeshBase &) const
virtual void write(const std::string &) override
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
virtual void write(const std::string &base_filename) override
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
virtual void read(const std::string &name) override
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
processor_id_type processor_id() const
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) override
virtual void write(const std::string &) override
virtual void read(const std::string &) override
void broadcast(T &data, const unsigned int root_id=0) const
virtual void read(const std::string &) override
bool is_parallel_file_format(const std::string &filename)