25 #include "libmesh/utility.h" 26 #include "libmesh/plt_loader.h" 37 std::ifstream in (
name.c_str(), std::ios::in|std::ios::binary);
39 libmesh_error_msg_if(!in.good(),
"Error reading input file " <<
name);
43 <<
"Reading input file " <<
name 45 <<
"-------------------------------------------------------------------------" 53 <<
"-------------------------------------------------------------------------" 73 for (
unsigned int i=0; i<8; i++)
94 in.read (
buf, LIBMESH_SIZEOF_INT);
95 std::memcpy (&one,
buf, LIBMESH_SIZEOF_INT);
106 libmesh_assert_equal_to (rb(one), 1);
117 this->
title().clear();
121 in.read (
buf, LIBMESH_SIZEOF_INT);
122 std::memcpy (&i,
buf, LIBMESH_SIZEOF_INT);
127 this->
title() +=
static_cast<char>(i);
135 in.read (
buf, LIBMESH_SIZEOF_INT);
136 std::memcpy (&nv,
buf, LIBMESH_SIZEOF_INT);
143 for (
unsigned int v=0; v<this->
n_vars(); v++)
151 in.read (
buf, LIBMESH_SIZEOF_INT);
152 std::memcpy (&i,
buf, LIBMESH_SIZEOF_INT);
157 this->
var_name(v) +=
static_cast<char>(i);
168 std::vector<std::string> zname;
169 std::vector<int> ztype, zimax, zjmax, zkmax;
180 in.read (
buf, LIBMESH_SIZEOF_FLOAT);
181 std::memcpy (&f,
buf, LIBMESH_SIZEOF_FLOAT);
184 while ((f != 299.) &&
190 libmesh_error_msg_if(!in.good(),
"ERROR: Unexpected end-of-file!");
205 in.read (
buf, LIBMESH_SIZEOF_INT);
206 std::memcpy (&i,
buf, LIBMESH_SIZEOF_INT);
211 name +=
static_cast<char>(i);
215 zname.push_back(
name);
221 in.read (
buf, LIBMESH_SIZEOF_INT);
222 std::memcpy (&zt,
buf, LIBMESH_SIZEOF_INT);
233 in.read (
buf, LIBMESH_SIZEOF_INT);
234 std::memcpy (&zc,
buf, LIBMESH_SIZEOF_INT);
247 in.read (
buf, LIBMESH_SIZEOF_INT);
248 std::memcpy (&i_max,
buf, LIBMESH_SIZEOF_INT);
251 in.read (
buf, LIBMESH_SIZEOF_INT);
252 std::memcpy (&j_max,
buf, LIBMESH_SIZEOF_INT);
255 in.read (
buf, LIBMESH_SIZEOF_INT);
256 std::memcpy (&k_max,
buf, LIBMESH_SIZEOF_INT);
259 zimax.push_back (i_max);
260 zjmax.push_back (j_max);
261 zkmax.push_back (k_max);
265 while ((f != 357.) && in.good());
271 for (
unsigned int z=0; z<this->
n_zones(); z++)
275 this->
imax(z) = zimax[z];
276 this->
jmax(z) = zjmax[z];
277 this->
kmax(z) = zkmax[z];
294 in.read (
buf, LIBMESH_SIZEOF_INT);
295 std::memcpy (&one,
buf, LIBMESH_SIZEOF_INT);
306 libmesh_assert_equal_to (rb(one), 1);
317 this->
title().clear();
320 in.read (
buf, LIBMESH_SIZEOF_INT);
321 std::memcpy (&i,
buf, LIBMESH_SIZEOF_INT);
326 this->
title() +=
static_cast<char>(i);
334 in.read (
buf, LIBMESH_SIZEOF_INT);
335 std::memcpy (&nv,
buf, LIBMESH_SIZEOF_INT);
342 for (
unsigned int v=0; v<this->
n_vars(); v++)
350 in.read (
buf, LIBMESH_SIZEOF_INT);
351 std::memcpy (&i,
buf, LIBMESH_SIZEOF_INT);
356 this->
var_name(v) +=
static_cast<char>(i);
367 std::vector<std::string> zname;
368 std::vector<int> zpack, ztype, zimax, zjmax, zkmax;
379 in.read (
buf, LIBMESH_SIZEOF_FLOAT);
380 std::memcpy (&f,
buf, LIBMESH_SIZEOF_FLOAT);
383 while ((f != 299.) &&
388 libmesh_error_msg_if(!in.good(),
"ERROR: Unexpected end-of-file!");
403 in.read (
buf, LIBMESH_SIZEOF_INT);
404 std::memcpy (&i,
buf, LIBMESH_SIZEOF_INT);
409 name +=
static_cast<char>(i);
413 zname.push_back(
name);
419 in.read (
buf, LIBMESH_SIZEOF_INT);
420 std::memcpy (&zc,
buf, LIBMESH_SIZEOF_INT);
427 in.read (
buf, LIBMESH_SIZEOF_INT);
428 std::memcpy (&zt,
buf, LIBMESH_SIZEOF_INT);
437 in.read (
buf, LIBMESH_SIZEOF_INT);
438 std::memcpy (&dp,
buf, LIBMESH_SIZEOF_INT);
441 zpack.push_back (dp);
448 in.read (
buf, LIBMESH_SIZEOF_INT);
449 std::memcpy (&svl,
buf, LIBMESH_SIZEOF_INT);
453 for (
unsigned int v=0; v<this->
n_vars(); v++)
455 in.read (
buf, LIBMESH_SIZEOF_INT);
456 std::memcpy (&vl,
buf, LIBMESH_SIZEOF_INT);
458 libmesh_assert_equal_to (vl, 0);
467 in.read (
buf, LIBMESH_SIZEOF_INT);
468 std::memcpy (&fn,
buf, LIBMESH_SIZEOF_INT);
478 in.read (
buf, LIBMESH_SIZEOF_INT);
479 std::memcpy (&np,
buf, LIBMESH_SIZEOF_INT);
482 in.read (
buf, LIBMESH_SIZEOF_INT);
483 std::memcpy (&ne,
buf, LIBMESH_SIZEOF_INT);
486 zimax.push_back (np);
487 zjmax.push_back (ne);
496 in.read (
buf, LIBMESH_SIZEOF_INT);
497 std::memcpy (&i_max,
buf, LIBMESH_SIZEOF_INT);
500 in.read (
buf, LIBMESH_SIZEOF_INT);
501 std::memcpy (&j_max,
buf, LIBMESH_SIZEOF_INT);
504 in.read (
buf, LIBMESH_SIZEOF_INT);
505 std::memcpy (&k_max,
buf, LIBMESH_SIZEOF_INT);
512 zimax.push_back (i_max);
513 zjmax.push_back (j_max);
514 zkmax.push_back (k_max);
519 while ((f != 357.) && in.good());
525 for (
unsigned int z=0; z<this->
n_zones(); z++)
530 this->
imax(z) = zimax[z];
531 this->
jmax(z) = zjmax[z];
532 this->
kmax(z) = zkmax[z];
541 libmesh_error_msg(
"ERROR: This plot file was written by an unrecognized version of Tecplot!:\n" << this->
version());
554 << this->
title() << std::endl;
557 for (
unsigned int v=0; v<this->
n_vars(); v++)
562 for (
unsigned int v=0; v<this->
n_vars(); v++)
567 for (
unsigned int z=0; z<this->
n_zones(); z++)
572 for (
unsigned int z=0; z<this->
n_zones(); z++)
582 for (
unsigned int z=0; z<this->
n_zones(); z++)
584 << this->
imax(z) <<
"," 585 << this->
jmax(z) <<
"," 586 << this->
kmax(z) <<
")" 609 for (
unsigned int zone=0; zone<this->
n_zones(); zone++)
628 in.read (
buf, LIBMESH_SIZEOF_FLOAT);
629 std::memcpy (&f,
buf, LIBMESH_SIZEOF_FLOAT);
632 while ((f != 299.) && in.good());
635 libmesh_error_msg_if(!in.good(),
"ERROR: Unexpected end-of-file!");
638 unsigned int n_rep_vars=0;
639 std::vector<int> rep_vars;
642 in.read (
buf, LIBMESH_SIZEOF_INT);
643 std::memcpy (&n_rep_vars,
buf, LIBMESH_SIZEOF_INT);
646 rep_vars.resize (n_rep_vars);
649 for (
unsigned int v=0; v<n_rep_vars; v++)
651 libmesh_error_msg(
"ERROR: I don't understand repeated variables yet!");
653 in.read (
buf, LIBMESH_SIZEOF_INT);
654 std::memcpy (&rep_vars[v],
buf, LIBMESH_SIZEOF_INT);
661 for (
unsigned int v=0; v<this->
n_vars(); v++)
663 in.read (
buf, LIBMESH_SIZEOF_INT);
664 std::memcpy (&this->
var_type(v),
buf, LIBMESH_SIZEOF_INT);
698 <<
" nnodes =" << this->
imax(zone) << std::endl
699 <<
" nelem =" << this->
jmax(zone) << std::endl
700 <<
" elem_type=" << this->
kmax(zone) << std::endl
713 libmesh_error_msg(
"ERROR: Unsupported Zone type: " << this->
zone_type(zone));
728 in.read (
buf, LIBMESH_SIZEOF_FLOAT);
729 std::memcpy (&f,
buf, LIBMESH_SIZEOF_FLOAT);
732 while ((f != 299.) && in.good());
735 libmesh_error_msg_if(!in.good(),
"ERROR: Unexpected end-of-file!");
738 for (
unsigned int v=0; v<this->
n_vars(); v++)
740 in.read (
buf, LIBMESH_SIZEOF_INT);
741 std::memcpy (&this->
var_type(v),
buf, LIBMESH_SIZEOF_INT);
752 in.read (
buf, LIBMESH_SIZEOF_INT);
753 std::memcpy (&vs,
buf, LIBMESH_SIZEOF_INT);
758 for (
unsigned int v=0; v<this->
n_vars(); v++)
760 in.read (
buf, LIBMESH_SIZEOF_INT);
761 std::memcpy (&sv,
buf, LIBMESH_SIZEOF_INT);
764 libmesh_error_msg_if(sv != -1,
"ERROR: I don't understand variable sharing!");
772 in.read (
buf, LIBMESH_SIZEOF_INT);
773 std::memcpy (&sc,
buf, LIBMESH_SIZEOF_INT);
776 libmesh_assert_equal_to (sc, -1);
792 libmesh_error_msg(
"Unrecognized zone_pack(zone) = " << this->
zone_pack(zone));
805 libmesh_error_msg(
"Unrecognized zone_pack(zone) = " << this->
zone_pack(zone));
814 libmesh_error_msg(
"ERROR: This plot file was written by an unrecognized version of Tecplot!:\n" << this->
version());
830 for (
unsigned int var=0; var<this->
n_vars(); var++)
839 std::vector<float> & data =
_data[zone][var];
842 data.resize (this->
imax(zone)*
846 in.read (reinterpret_cast<char *>(data.data()), LIBMESH_SIZEOF_FLOAT*data.size());
848 for (std::size_t i=0; i<data.size(); i++)
857 std::vector<double> ddata;
858 std::vector<float> & data =
_data[zone][var];
861 data.resize (this->
imax(zone)*
865 ddata.resize (this->
imax(zone)*
869 in.read (reinterpret_cast<char *>(ddata.data()), LIBMESH_SIZEOF_DOUBLE*ddata.size());
871 for (std::size_t i=0; i<data.size(); i++)
872 data[i] =
float(rb(ddata[i]));
878 libmesh_error_msg(
"ERROR: Unsupported data type: " << this->
var_type(var));
893 for (
unsigned int var=0; var<this->
n_vars(); var++)
895 std::vector<float> & data =
_data[zone][var];
898 data.reserve (this->
imax(zone)*
904 for (
unsigned int k=0; k<this->
kmax(zone); k++)
905 for (
unsigned int j=0; j<this->
jmax(zone); j++)
906 for (
unsigned int i=0; i<this->
imax(zone); i++)
907 for (
unsigned int var=0; var<this->
n_vars(); var++)
914 in.read (
buf, LIBMESH_SIZEOF_FLOAT);
915 std::memcpy (&f,
buf, LIBMESH_SIZEOF_FLOAT);
918 _data[zone][var].push_back(f);
926 in.read (
buf, LIBMESH_SIZEOF_DOUBLE);
927 std::memcpy (&d,
buf, LIBMESH_SIZEOF_DOUBLE);
930 _data[zone][var].push_back(
float(d));
933 libmesh_error_msg(
"ERROR: unsupported data type: " << this->
var_type(var));
946 for (
unsigned int var=0; var<this->
n_vars(); var++)
954 std::vector<float> & data =
_data[zone][var];
957 data.resize (this->
imax(zone));
959 in.read (reinterpret_cast<char *>(data.data()), LIBMESH_SIZEOF_FLOAT*data.size());
961 for (std::size_t i=0; i<data.size(); i++)
970 std::vector<double> ddata;
971 std::vector<float> & data =
_data[zone][var];
974 data.resize (this->
imax(zone));
975 ddata.resize (this->
imax(zone));
977 in.read (reinterpret_cast<char *>(ddata.data()), LIBMESH_SIZEOF_DOUBLE*ddata.size());
979 for (std::size_t i=0; i<data.size(); i++)
980 data[i] =
float(rb(ddata[i]));
986 libmesh_error_msg(
"ERROR: Unsupported data type: " << this->
var_type(var));
994 in.read ((
char *) &rep, LIBMESH_SIZEOF_INT);
997 libmesh_error_msg_if(rep == 1 && this->
n_zones() > 1,
"ERROR: Repeated connectivity not supported!");
1000 libmesh_assert_less (zone,
_conn.size());
1001 libmesh_assert_less (this->
kmax(zone), 4);
1005 in.read (reinterpret_cast<char *>(
_conn[zone].data()), LIBMESH_SIZEOF_INT*
_conn[zone].size());
1007 for (std::size_t i=0; i<
_conn[zone].size(); i++)
1022 for (
unsigned int var=0; var<this->
n_vars(); var++)
1024 std::vector<float> & data =
_data[zone][var];
1027 data.reserve (this->
imax(zone));
1031 for (
unsigned int i=0; i<this->
imax(zone); i++)
1032 for (
unsigned int var=0; var<this->
n_vars(); var++)
1039 in.read (
buf, LIBMESH_SIZEOF_FLOAT);
1040 std::memcpy (&f,
buf, LIBMESH_SIZEOF_FLOAT);
1043 _data[zone][var].push_back(f);
1051 in.read (
buf, LIBMESH_SIZEOF_DOUBLE);
1052 std::memcpy (&d,
buf, LIBMESH_SIZEOF_DOUBLE);
1055 _data[zone][var].push_back(
float(d));
1058 libmesh_error_msg(
"ERROR: unsupported data type: " << this->
var_type(var));
1065 in.read ((
char *) &rep, LIBMESH_SIZEOF_INT);
1068 libmesh_error_msg_if(rep == 1,
"ERROR: Repeated connectivity not supported!");
1071 libmesh_assert_less (zone,
_conn.size());
1072 libmesh_assert_less (this->
kmax(zone), 4);
1076 in.read (reinterpret_cast<char *>(
_conn[zone].data()), LIBMESH_SIZEOF_INT*
_conn[zone].size());
1078 for (std::size_t i=0; i<
_conn[zone].size(); i++)
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
void set_n_zones(const unsigned int nz)
This Functor simply takes an object and reverses its byte representation.
unsigned int n_vars() const
std::vector< std::vector< int > > _conn
Vectors to hold the connectivity for each zone (only for unstructured files).
std::vector< std::vector< std::vector< float > > > _data
Vector to hold the data.
void read_point_data(std::istream &in, const unsigned int zn)
Read data for the zth zone in POINT structured format.
void set_n_vars(const unsigned int nv)
The libMesh namespace provides an interface to certain functionality in the library.
const std::string & var_name(const unsigned int v) const
void read(const std::string &name)
Reads the .plt file specified by name.
static const unsigned int NNodes[4]
Enum defining the number of nodes for each element type.
unsigned int imax(const unsigned int z) const
const std::string & zone_name(const unsigned int z) const
unsigned int jmax(const unsigned int z) const
unsigned int zone_pack(const unsigned int z) const
void read_fepoint_data(std::istream &in, const unsigned int zn)
Read data for the zth zone in FEPOINT unstructured format.
unsigned int n_nodes(const unsigned int z) const
BasicOStreamProxy & flush()
Flush the associated stream buffer.
unsigned int var_type(const unsigned int v) const
char buf[512]
Scratch data & relevant sizes.
const std::string & title() const
unsigned int n_zones() const
unsigned int kmax(const unsigned int z) const
void read_header(std::istream &in)
Read the header of the binary file.
void read_block_data(std::istream &in, const unsigned int zn)
Read data for the zth zone in BLOCK structured format.
const std::string & version() const
unsigned int n_elem(const unsigned int z) const
void read_data(std::istream &in)
Read data from the binary file.
void read_feblock_data(std::istream &in, const unsigned int zn)
Read data for the zth zone in FEBLOCK unstructured format.
unsigned int zone_type(const unsigned int z) const