Poster of Linux kernelThe best gift for a Linux geek
PltLoader

PltLoader

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

PltLoader -  

SYNOPSIS


#include <plt_loader.h>  

Public Types


enum OldZoneType { BLOCK = 0, POINT, FEBLOCK, FEPOINT }

enum NewZoneType { ORDERED = 0, FELINESEG, FETRIANGLE, FEQUADRILATERAL, FETETRAHEDRON, FEBRICK }

enum DataType { FLOAT = 1, DOUBLE, LONGINT, SHORTINT, BYTE, BIT }

enum FEType { TRI = 0, QUAD, TET, HEX }
 

Public Member Functions


PltLoader (const bool v=false)

PltLoader (const std::string &name, const bool v=false)

~PltLoader ()

void clear ()

bool verbose () const

void read (const std::string &name)

void write_dat (const std::string &name, const unsigned int version=10) const

const std::string & version () const

bool is_foreign () const

const std::string & title () const

unsigned int n_vars () const

const std::string & var_name (const unsigned int v) const

unsigned int var_type (const unsigned int v) const

unsigned int n_zones () const

unsigned int zone_type (const unsigned int z) const

const std::string & zone_name (const unsigned int z) const

unsigned int zone_pack (const unsigned int z) const

unsigned int imax (const unsigned int z) const

unsigned int jmax (const unsigned int z) const

unsigned int kmax (const unsigned int z) const

unsigned int n_nodes (const unsigned int z) const

unsigned int n_elem (const unsigned int z) const

FEType elem_type (const unsigned int z) const

const std::vector< std::vector< std::vector< float > > > & get_data () const
 

Static Public Attributes


static const unsigned int NNodes [4] = {3, 4, 4, 8}
 

Private Member Functions


void read_header (std::istream &in)

void read_data (std::istream &in)

void read_block_data (std::istream &in, const unsigned int zn)

void read_point_data (std::istream &in, const unsigned int zn)

void read_feblock_data (std::istream &in, const unsigned int zn)

void read_fepoint_data (std::istream &in, const unsigned int zn)

std::string & version ()

bool & is_foreign ()

std::string & title ()

void set_n_vars (const unsigned int nv)

std::string & var_name (const unsigned int v)

unsigned int & var_type (const unsigned int v)

void set_n_zones (const unsigned int nz)

unsigned int & zone_type (const unsigned int z)

std::string & zone_name (const unsigned int z)

unsigned int & zone_pack (const unsigned int z)

unsigned int & imax (const unsigned int z)

unsigned int & jmax (const unsigned int z)

unsigned int & kmax (const unsigned int z)
 

Private Attributes


const bool _verbose

std::string _version

bool _is_foreign

std::string _title

unsigned int _n_vars

std::vector< std::string > _var_names

std::vector< unsigned int > _var_types

unsigned int _n_zones

std::vector< unsigned int > _zone_types

std::vector< std::string > _zone_names

std::vector< unsigned int > _zone_pack

std::vector< unsigned int > _imax

std::vector< unsigned int > _jmax

std::vector< unsigned int > _kmax

std::vector< std::vector< std::vector< float > > > _data

std::vector< std::vector< int > > _conn

char buf [512]
 

Detailed Description

This class will read a binary .plt file. These types of files are for use with Amtec's Tecplot visualization package.

Author:

Benjamin S. Kirk, 2004.

Definition at line 40 of file plt_loader.h.  

Member Enumeration Documentation

 

enum PltLoader::DataTypeEnum defining the data type of each variable.

Enumerator:

FLOAT
DOUBLE
LONGINT
SHORTINT
BYTE
BIT

Definition at line 133 of file plt_loader.h.

                { FLOAT=1,
                  DOUBLE,
                  LONGINT,
                  SHORTINT,
                  BYTE,
                  BIT};
 

enum PltLoader::FETypeEnum defining the finite element types

Enumerator:

TRI
QUAD
TET
HEX

Definition at line 143 of file plt_loader.h.

              { TRI=0,
                QUAD,
                TET,
                HEX };
 

enum PltLoader::NewZoneTypeEnum defining the zone type in the Tecplot binary file, for use with the new .plt format.

Enumerator:

ORDERED
FELINESEG
FETRIANGLE
FEQUADRILATERAL
FETETRAHEDRON
FEBRICK

Definition at line 123 of file plt_loader.h.

                   { ORDERED=0,
                     FELINESEG,
                     FETRIANGLE,
                     FEQUADRILATERAL,
                     FETETRAHEDRON,
                     FEBRICK };
 

enum PltLoader::OldZoneTypeWrites a plot3d files. The grid will be in basename.g and the solution will be in basename.q. It is assumed that the first three variables from the .plt file are the (x,y,z) locations of the grid points. The optional parameter reverse specifies if the output file will have reversed byte ordering. Writes a Cart3D .tri component file. The number of components will be the number of zones in the .plt file. Enum defining the zone type in the Tecplot binary file, for use with the old .plt format.

Enumerator:

BLOCK
POINT
FEBLOCK
FEPOINT

Definition at line 114 of file plt_loader.h.

                   { BLOCK=0,
                     POINT,
                     FEBLOCK,
                     FEPOINT };
 

Constructor & Destructor Documentation

 

PltLoader::PltLoader (const boolv = false) [inline]Constructor. Initializes data.

Definition at line 446 of file plt_loader.h.

                                  :
  _verbose      (v),
  _is_foreign   (false),
  _n_vars       (0),
  _n_zones      (0)
{
}
 

PltLoader::PltLoader (const std::string &name, const boolv = false) [inline]Constructor. Reads the file specified by name.

Definition at line 457 of file plt_loader.h.

References read().

                                                         :
  _verbose      (v),
  _is_foreign   (false),
  _n_vars       (0),
  _n_zones      (0)
{ 
  this->read (name);
}
 

PltLoader::~PltLoader () [inline]Destructor.

Definition at line 469 of file plt_loader.h.

{
}
 

Member Function Documentation

 

void PltLoader::clear ()Clear all data and return to a pristine state.

Definition at line 33 of file plt_loader.C.

References _conn, _data, _imax, _is_foreign, _jmax, _kmax, _n_vars, _n_zones, _title, _var_names, _var_types, _version, _zone_names, _zone_pack, and _zone_types.

{
  // clear vectors & strings.  Using .erase() for strings instead of .clear()
  // since GCC 2.95.3 does not support .clear().
  _version.erase();
  _title.erase();

  _var_names.clear();
  _var_types.clear();
  _zone_types.clear();
  _zone_names.clear();
  _zone_pack.clear();
  _imax.clear();
  _jmax.clear();
  _kmax.clear();
  _data.clear();
  _conn.clear();

  // reinitialize
  _is_foreign = false;
  _n_vars     = 0;
  _n_zones    = 0;
}
 

PltLoader::FEType PltLoader::elem_type (const unsigned intz) const [inline]Returns:

the element type for the zth zone (for unstructured meshes).

Definition at line 688 of file plt_loader.h.

References kmax(), n_zones(), and zone_type().

{
  libmesh_assert (z < this->n_zones());
  
  // Only for unstructured zones!
  libmesh_assert (this->zone_type(z) > 1);
  
  return static_cast<FEType>(this->kmax(z));
}
 

const std::vector< std::vector< std::vector< float > > > & PltLoader::get_data () const [inline]Returns:

a reference to the data read from the file

Definition at line 701 of file plt_loader.h.

References _data.

{
  return _data;
}
 

unsigned int & PltLoader::imax (const unsigned intz) [inline, private]Returns:

imax for zone z.

Definition at line 607 of file plt_loader.h.

References _imax, and n_zones().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (_imax.size() == this->n_zones());

  return _imax[z];
}
 

unsigned int PltLoader::imax (const unsigned intz) const [inline]Returns:

imax for zone z.

Definition at line 596 of file plt_loader.h.

References _imax, and n_zones().

Referenced by n_nodes(), read_block_data(), read_data(), read_feblock_data(), read_fepoint_data(), read_header(), read_point_data(), and write_dat().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (_imax.size() == this->n_zones());

  return _imax[z];
}
 

bool PltLoader::is_foreign () const [inline]Returns:

true if the binary type of the file is different than the machine that is reading it. If this is the case we must perform an endian-swap on all input data.

Definition at line 167 of file plt_loader.h.

References _is_foreign.

Referenced by read_block_data(), read_data(), read_feblock_data(), read_fepoint_data(), read_header(), and read_point_data().

{ return _is_foreign; }
 

bool& PltLoader::is_foreign () [inline, private]Returns:

true if the binary type of the file is different than the machine that is reading it. If this is the case we must perform an endian-swap on all input data.

Definition at line 299 of file plt_loader.h.

References _is_foreign.

{ return _is_foreign; }
 

unsigned int & PltLoader::jmax (const unsigned intz) [inline, private]Returns:

jmax for zone z.

Definition at line 629 of file plt_loader.h.

References _jmax, and n_zones().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (_jmax.size() == this->n_zones());

  return _jmax[z];
}
 

unsigned int PltLoader::jmax (const unsigned intz) const [inline]Returns:

jmax for zone z.

Definition at line 618 of file plt_loader.h.

References _jmax, and n_zones().

Referenced by n_elem(), read_block_data(), read_data(), read_feblock_data(), read_fepoint_data(), read_header(), read_point_data(), and write_dat().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (_jmax.size() == this->n_zones());

  return _jmax[z];
}
 

unsigned int PltLoader::kmax (const unsigned intz) const [inline]Returns:

kmax for zone z.

Definition at line 640 of file plt_loader.h.

References _kmax, and n_zones().

Referenced by elem_type(), read_block_data(), read_data(), read_feblock_data(), read_fepoint_data(), read_header(), read_point_data(), and write_dat().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (_kmax.size() == this->n_zones());

  return _kmax[z];
}
 

unsigned int & PltLoader::kmax (const unsigned intz) [inline, private]Returns:

kmax for zone z.

Definition at line 651 of file plt_loader.h.

References _kmax, and n_zones().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (_kmax.size() == this->n_zones());

  return _kmax[z];
}
 

unsigned int PltLoader::n_elem (const unsigned intz) const [inline]Returns:

the number of elements in the mesh (for unstructured meshes).

Definition at line 675 of file plt_loader.h.

References jmax(), n_zones(), and zone_type().

Referenced by read_header().

{
  libmesh_assert (z < this->n_zones());
  
  // Only for unstructured zones!
  libmesh_assert (this->zone_type(z) > 1);
  
  return this->jmax(z);
}
 

unsigned int PltLoader::n_nodes (const unsigned intz) const [inline]Returns:

the number of nodes in the mesh (for unstructured meshes).

Definition at line 662 of file plt_loader.h.

References imax(), n_zones(), and zone_type().

Referenced by read_header().

{
  libmesh_assert (z < this->n_zones());
  
  // Only for unstructured zones!
  libmesh_assert (this->zone_type(z) > 1);
  
  return this->imax(z);
}
 

unsigned int PltLoader::n_vars () const [inline]Returns:

the number of variables in the data set.

Definition at line 177 of file plt_loader.h.

References _n_vars.

Referenced by read_block_data(), read_data(), read_feblock_data(), read_fepoint_data(), read_header(), read_point_data(), set_n_vars(), set_n_zones(), var_name(), var_type(), and write_dat().

{ return _n_vars; }
 

unsigned int PltLoader::n_zones () const [inline]Returns:

the number of zones.

Definition at line 192 of file plt_loader.h.

References _n_zones.

Referenced by elem_type(), imax(), jmax(), kmax(), n_elem(), n_nodes(), read_data(), read_feblock_data(), read_header(), set_n_vars(), set_n_zones(), write_dat(), zone_name(), zone_pack(), and zone_type().

{ return _n_zones; }
 

void PltLoader::read (const std::string &name)Reads the .plt file specified by name.

Definition at line 33 of file plt_loader_read.C.

References read_data(), read_header(), and verbose().

Referenced by PltLoader().

{
  std::ifstream in (name.c_str(), std::ios::in|std::ios::binary);

  if (!in.good())
    {
      std::cerr << 'Error reading input file ' << name
                << std::endl;

      libmesh_error();
    }
    

  if (this->verbose())
    std::cout << std::endl
              << 'Reading input file ' << name
              << std::endl
              << '-------------------------------------------------------------------------'
              << std::endl;

  this->read_header (in);
  this->read_data   (in);

  if (this->verbose())
    std::cout << std::endl
              << '-------------------------------------------------------------------------'
              << std::endl;

}
 

void PltLoader::read_block_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in BLOCK structured format.

Definition at line 876 of file plt_loader_read.C.

References _data, DOUBLE, FLOAT, imax(), is_foreign(), jmax(), kmax(), n_vars(), and var_type().

Referenced by read_data().

{
  libmesh_assert (in.good());

  
  // A byte-reverser in case the data is foreign
  Utility::ReverseBytes rb(this->is_foreign());

  
  for (unsigned int var=0; var<this->n_vars(); var++) 
    {
      
      switch (this->var_type(var))
        {
          
          // Read a single-precision variable
        case FLOAT:
          {
            std::vector<float> & data = _data[zone][var];
            
            data.clear();
            data.resize (this->imax(zone)*
                         this->jmax(zone)*
                         this->kmax(zone));
            
            in.read ((char*) &data[0], LIBMESH_SIZEOF_FLOAT*data.size());

            for (unsigned int i=0; i<data.size(); i++)
              rb(data[i]);
            
            break;
          }
          
          // Read a double-precision variable
        case DOUBLE:
          {
            std::vector<double> ddata;
            std::vector<float> & data = _data[zone][var];
            
            data.clear();
            data.resize (this->imax(zone)*
                         this->jmax(zone)*
                         this->kmax(zone));
            
            ddata.resize (this->imax(zone)*
                          this->jmax(zone)*
                          this->kmax(zone));
            
            in.read ((char*) &ddata[0], LIBMESH_SIZEOF_DOUBLE*ddata.size());

            for (unsigned int i=0; i<data.size(); i++)
              data[i] = rb(ddata[i]);
            
            break;
          }
                      
        default:
          {
            std::cerr << 'ERROR: Unsupported data type: '
                      << this->var_type(var)
                      << std::endl;
            libmesh_error();
          }
        }
    }
}
 

void PltLoader::read_data (std::istream &in) [private]Read data from the binary file.

Definition at line 620 of file plt_loader_read.C.

References BLOCK, buf, FEBLOCK, FEPOINT, imax(), is_foreign(), jmax(), kmax(), n_vars(), n_zones(), ORDERED, POINT, read_block_data(), read_feblock_data(), read_fepoint_data(), read_point_data(), var_type(), verbose(), version(), zone_pack(), and zone_type().

Referenced by read().

{
  libmesh_assert (in.good());

  // A byte-reverser in case the data is foreign
  Utility::ReverseBytes rb(this->is_foreign());
  
  //----------------------------------------------------
  // Read the TECPLOT data for each zone
  if (this->verbose())
    {
      std::cout << 'Reading Zones';
      std::cout.flush();
    }
      
  
  for (unsigned int zone=0; zone<this->n_zones(); zone++)
    {
      if (this->verbose())
        {
          std::cout << '.';
          std::cout.flush();
        }


      //----------------------------------------------------
      // Read plt files written by older versions of Tecplot
      if (this->version().rfind('V7') < this->version().size())
        {
          float f = 0.;
          
          // Find the next Zone marker.
          do
            {
              f = 0.;
              in.read (buf, LIBMESH_SIZEOF_FLOAT);
              std::memcpy  (&f, buf, LIBMESH_SIZEOF_FLOAT);
              rb(f);
            }
          while ((f != 299.) && in.good());
        
          // Did we overrun the file?
          if (!in.good())
            {
              std::cerr << 'ERROR: Unexpected end-of-file!'
                        << std::endl;
              libmesh_error();
            }

          // Get the number of repeated vars.
          unsigned int n_rep_vars=0;
          std::vector<int> rep_vars;
        
          {     
            in.read (buf, LIBMESH_SIZEOF_INT);
            std::memcpy  (&n_rep_vars, buf, LIBMESH_SIZEOF_INT);
            rb(n_rep_vars);

            rep_vars.resize (n_rep_vars);
        
            // Get the repeated variables number.
            for (unsigned int v=0; v<n_rep_vars; v++)
              {
                std::cerr << 'ERROR:  I don't understand repeated variables yet!'
                          << std::endl;
                libmesh_error();
            
                in.read (buf, LIBMESH_SIZEOF_INT);
                std::memcpy  (&rep_vars[v], buf, LIBMESH_SIZEOF_INT);
                rb(rep_vars[v]);
              } 
          }

          // Get the variable data type
          //std::cout << 'var_types=';
          for (unsigned int v=0; v<this->n_vars(); v++)
            {
              in.read (buf, LIBMESH_SIZEOF_INT);
              std::memcpy  (&this->var_type(v), buf, LIBMESH_SIZEOF_INT);
              rb(this->var_type(v));

              //std::cout << this->var_type(v) << ' ';
            }
          //std::cout << std::endl;


      
          // Read the data.
          switch (this->zone_type(zone) )
            {
              // Block-based data.  Structured meshes.
            case BLOCK:
              {
                this->read_block_data (in, zone);
                break;
              }
          
              // Point-based data.  Structured meshes.
            case POINT:
              {
                this->read_point_data (in, zone);
                break;
              }
          
              // FE block data.  Unstructured meshes.
            case FEBLOCK:
              {
                this->read_feblock_data (in, zone);
            
                if (this->verbose())
              
                  std::cout << 'Zone ' << zone << ':' << std::endl
                            << '  nnodes   =' << this->imax(zone) << std::endl
                            << '  nelem    =' << this->jmax(zone) << std::endl
                            << '  elem_type=' << this->kmax(zone) << std::endl
                            << std::endl;
                break;
              }

              // FE point data.  Unstructured meshes.
            case FEPOINT:
              {
                this->read_fepoint_data (in, zone);
                break;
              }
          
            default:
              {
                std::cerr << 'ERROR: Unsupported Zone type: '
                          << this->zone_type(zone)
                          << std::endl;
                libmesh_error();
              }
            } // end switch on zone type
        }
  

      //----------------------------------------------------
      // Read plt files written by newer versions of Tecplot
      else if (this->version().rfind('V1') < this->version().size())
        {
          float f = 0.;
          
          // Find the next Zone marker.
          do
            {
              f = 0.;
              in.read (buf, LIBMESH_SIZEOF_FLOAT);
              std::memcpy  (&f, buf, LIBMESH_SIZEOF_FLOAT);
              rb(f);
            }
          while ((f != 299.) && in.good());
        
          // Did we overrun the file?
          if (!in.good())
            {
              std::cerr << 'ERROR: Unexpected end-of-file!'
                        << std::endl;
              libmesh_error();
            }

          // Get the variable data type
          for (unsigned int v=0; v<this->n_vars(); v++)
            {
              in.read (buf, LIBMESH_SIZEOF_INT);
              std::memcpy  (&this->var_type(v), buf, LIBMESH_SIZEOF_INT);
              rb(this->var_type(v));

              //std::cout << this->var_type(v) << ' ';
            }

          // Get the variable sharing flag
          {
            int vs=0;
            int sv=0;

            in.read (buf, LIBMESH_SIZEOF_INT);
            std::memcpy  (&vs, buf, LIBMESH_SIZEOF_INT);
            rb(vs);

            if (vs)
              {
                for (unsigned int v=0; v<this->n_vars(); v++)
                  {
                    in.read (buf, LIBMESH_SIZEOF_INT);
                    std::memcpy  (&sv, buf, LIBMESH_SIZEOF_INT);
                    rb(sv);
                    
                    if (sv != -1)
                      {
                        std::cerr << 'ERROR:  I don't understand variable sharing!'
                                  << std::endl;
                        libmesh_error();
                      }
                  }
              }
          }

          // Get zone to share connectivity with
          {
            int sc=0;
            in.read (buf, LIBMESH_SIZEOF_INT);
            std::memcpy  (&sc, buf, LIBMESH_SIZEOF_INT);
            rb(sc);
            
            libmesh_assert (sc == -1);
          }

      
          // Read the data.
          if (this->zone_type(zone) == ORDERED)
            {
                // Block-based data.  Structured meshes.
              if (this->zone_pack(zone) == 0)
                this->read_block_data (in, zone);
          
              // Point-based data.  Structured meshes.
              else if (this->zone_pack(zone) == 1)
                this->read_point_data (in, zone);

              else
                libmesh_error();
            }
          else
            {
              // Block-based data.  Unstructured meshes.
              if (this->zone_pack(zone) == 0)
                this->read_feblock_data (in, zone);

              // Point-based data.  Unstructured meshes.
              else if (this->zone_pack(zone) == 1)
                this->read_fepoint_data (in, zone);

              else
                libmesh_error();
            }
        }

  

      //----------------------------------------------------
      // Unrecognized Tecplot Version!
      else
        {
          std::cerr << 'ERROR:  This plot file was written by an unrecognized version of Tecplot!:'
                    << std::endl
                    << this->version()
                    << std::endl;
          libmesh_error();
        }
      
    } // end loop on zones
}
 

void PltLoader::read_feblock_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in FEBLOCK unstructured format.

Definition at line 1003 of file plt_loader_read.C.

References _conn, _data, DOUBLE, FLOAT, imax(), is_foreign(), jmax(), kmax(), n_vars(), n_zones(), NNodes, and var_type().

Referenced by read_data().

{
  libmesh_assert (in.good());

  // A byte-reverser in case the data is foreign
  Utility::ReverseBytes rb(this->is_foreign());

  // Read the variable values at each node.
  for (unsigned int var=0; var<this->n_vars(); var++) 
    {      
      switch (this->var_type(var))
        {
          
          // Read a single-precision variable
        case FLOAT:
          {
            std::vector<float> & data = _data[zone][var];
            
            data.clear();
            data.resize (this->imax(zone));
            
            in.read ((char*) &data[0], LIBMESH_SIZEOF_FLOAT*data.size());

            for (unsigned int i=0; i<data.size(); i++)
              rb(data[i]);
            
            break;
          }
          
          // Read a double-precision variable
        case DOUBLE:
          {
            std::vector<double> ddata;
            std::vector<float> & data = _data[zone][var];
            
            data.clear();
            data.resize (this->imax(zone));
            ddata.resize (this->imax(zone));
            
            in.read ((char*) &ddata[0], LIBMESH_SIZEOF_DOUBLE*ddata.size());

            for (unsigned int i=0; i<data.size(); i++)
              data[i] = rb(ddata[i]);
            
            break;
          }
                      
        default:
          {
            std::cerr << 'ERROR: Unsupported data type: '
                      << this->var_type(var)
                      << std::endl;
            libmesh_error();
          }
        }
    }

  // Read the connectivity
  {
    // Get the connectivity repetition flag
    int rep=0;
    in.read ((char*) &rep, LIBMESH_SIZEOF_INT);
    rb(rep);

    if (rep == 1 && this->n_zones() > 1)
      {
        std::cerr << 'ERROR:  Repeated connectivity not supported!'
                  << std::endl;
        libmesh_error();
      }

    // Read the connectivity
    else
      {
        libmesh_assert (zone < _conn.size());
        libmesh_assert (this->kmax(zone) < 4);
        
        _conn[zone].resize (this->jmax(zone)*NNodes[this->kmax(zone)]);
        
        in.read ((char*) &_conn[zone][0], LIBMESH_SIZEOF_INT*_conn[zone].size());

        for (unsigned int i=0; i<_conn[zone].size(); i++)
          rb(_conn[zone][i]);
      }
  }  
}
 

void PltLoader::read_fepoint_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in FEPOINT unstructured format.

Definition at line 1092 of file plt_loader_read.C.

References _conn, _data, buf, DOUBLE, FLOAT, imax(), is_foreign(), jmax(), kmax(), n_vars(), NNodes, and var_type().

Referenced by read_data().

{
  libmesh_assert (in.good());

  // A byte-reverser in case the data is foreign
  Utility::ReverseBytes rb(this->is_foreign());

  // First allocate space
  for (unsigned int var=0; var<this->n_vars(); var++)
    {
      std::vector<float> & data = _data[zone][var];
      
      data.clear();
      data.reserve (this->imax(zone));
    }

  
  for (unsigned int i=0; i<this->imax(zone); i++)
    for (unsigned int var=0; var<this->n_vars(); var++)
      if (this->var_type(var) == FLOAT)
        {
          float f = 0.;
          
          libmesh_assert (in.good());
          
          in.read (buf, LIBMESH_SIZEOF_FLOAT);
          std::memcpy  (&f, buf, LIBMESH_SIZEOF_FLOAT);
          rb(f);
          
          _data[zone][var].push_back(f);                        
        }
      else if (this->var_type(var) == DOUBLE)
        {
          double d = 0.;
          
          libmesh_assert (in.good());
          
          in.read (buf, LIBMESH_SIZEOF_DOUBLE);
          std::memcpy  (&d, buf, LIBMESH_SIZEOF_DOUBLE);
          rb(d);
          
          _data[zone][var].push_back(d);                        
        }
      else
        {
          std::cerr << 'ERROR: unsupported data type: '
                    << this->var_type(var)
                    << std::endl;
          libmesh_error();
        }

  // Read the connectivity
  {
    // Get the connectivity repetition flag
    int rep=0;

    in.read ((char*) &rep, LIBMESH_SIZEOF_INT);
    rb(rep);

    if (rep == 1)
      {
        std::cerr << 'ERROR:  Repeated connectivity not supported!'
                  << std::endl;
        libmesh_error();
      }

    // Read the connectivity
    else
      {
        libmesh_assert (zone < _conn.size());
        libmesh_assert (this->kmax(zone) < 4);
        
        _conn[zone].resize (this->jmax(zone)*NNodes[this->kmax(zone)]);
        
        in.read ((char*) &_conn[zone][0], LIBMESH_SIZEOF_INT*_conn[zone].size());

        for (unsigned int i=0; i<_conn[zone].size(); i++)
          rb(_conn[zone][i]);
      }
  }
}
 

void PltLoader::read_header (std::istream &in) [private]Read the header of the binary file.

Definition at line 65 of file plt_loader_read.C.

References buf, imax(), is_foreign(), jmax(), kmax(), n_elem(), n_nodes(), n_vars(), n_zones(), Quality::name(), ORDERED, set_n_vars(), set_n_zones(), title(), var_name(), var_type(), verbose(), version(), zone_name(), zone_pack(), and zone_type().

Referenced by read().

{
  libmesh_assert (in.good());
  
  //----------------------------------------------------
  // Read the TECPLOT header
  
  // Read the version number
  {
    in.read (buf, 8);

    // Using erase for GCC 2.95.3
    this->version().erase();

    for (unsigned int i=0; i<8; i++)
      this->version() += buf[i];
    
    if (this->verbose())
      std::cout << 'Tecplot Version: '
                << this->version()
                << std::endl;
  }


  //----------------------------------------------------
  // Read plt files written by older versions of Tecplot
  if (this->version().rfind('V7') < this->version().size())
    {
      if (this->verbose())
        std::cout << 'Reading legacy .plt format (<= v9) ...'
                  << std::endl;
      
      // Read the value of 1 to determine byte ordering
      {
        int one = 0;    
        in.read (buf, LIBMESH_SIZEOF_INT);
        std::memcpy  (&one, buf, LIBMESH_SIZEOF_INT);
        
        if (one != 1)
          {
            if (this->verbose())
              std::cout << 'Tecplot data is Foreign!'
                        << std::endl;
            this->is_foreign() = true;

            // Make sure one reversed is one
            Utility::ReverseBytes rb(this->is_foreign());
            libmesh_assert (rb(one) == 1);
          }
      }

      // A byte-reverser in case the data is foreign
      Utility::ReverseBytes rb(this->is_foreign());

      // Read the title
      {
        int i=0;
        
        // Using erase for GCC 2.95.3
        this->title().erase();
        
        do
          {
            in.read (buf, LIBMESH_SIZEOF_INT);
            std::memcpy  (&i, buf, LIBMESH_SIZEOF_INT);
            rb(i);

            // Don't add trailing  
            if (i)
              this->title() += static_cast<char>(i);
          }
        while (i);
      }

      // Read the number of variables in the data set
      {
        int nv;
        in.read (buf, LIBMESH_SIZEOF_INT);
        std::memcpy  (&nv, buf, LIBMESH_SIZEOF_INT);
        rb(nv);
        
        this->set_n_vars (nv);
      }

      // Read the variable names
      for (unsigned int v=0; v<this->n_vars(); v++)
        {
          int i=0;

          // Using erase for GCC 2.95.3
          this->var_name(v).erase();
      
          do
            {
              in.read (buf, LIBMESH_SIZEOF_INT);
              std::memcpy  (&i, buf, LIBMESH_SIZEOF_INT);
              rb(i);
              
              // Don't add trailing  
              if (i)
                this->var_name(v) += static_cast<char>(i);
            }
          while (i);
        }

  
      
      // Read zones from the header.
      // Continue reading until the end-of-header
      // marker (357.) is found.
      int nz=0;
      std::vector<std::string> zname;
      std::vector<int>         ztype, zimax, zjmax, zkmax;
      
      {
        float f=0.;
    
        do
          {
            // find the next Zone marker        
            do
              {
                f = 0.;
                in.read (buf, LIBMESH_SIZEOF_FLOAT);
                std::memcpy  (&f, buf, LIBMESH_SIZEOF_FLOAT);
                rb(f);
              }
            while ((f != 299.) &&
                   (f != 357.) &&
                   in.good());
          
          
            // Did we overrun the file?
            if (!in.good())
              {
                std::cerr << 'ERROR: Unexpected end-of-file!'
                          << std::endl;
                libmesh_error();
              }    
          
            // Found a Zone marker
            else if (f == 299.) 
              {
                // Incriment the Zone counter
                nz++;
          
                // Read the zone name
                {
                  int i=0;
                  std::string name;
            
                  do
                    {
                      in.read (buf, LIBMESH_SIZEOF_INT);
                      std::memcpy  (&i, buf, LIBMESH_SIZEOF_INT);
                      rb(i);
                      
                      // Don't add trailing  
                      if (i)
                        name += static_cast<char>(i);
                    }
                  while (i);
            
                  zname.push_back(name);
                }
              
                // Read the zone format
                {
                  int zt;
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&zt, buf, LIBMESH_SIZEOF_INT);
                  rb(zt);
                  
                  ztype.push_back(zt);
                  //std::cout << 'zone type=' << ztype.back() << std::endl;
                }
              
                // Read the zone color
                {
                  int zc=0;
            
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&zc, buf, LIBMESH_SIZEOF_INT);
                  rb(zc);
                  
                  //std::cout << 'zone color=' << zc << std::endl;
                }
          
                // Read in the block dimensions
                {
                  int
                    imax=0,
                    jmax=0,
                    kmax=0;
            
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&imax, buf, LIBMESH_SIZEOF_INT);
                  rb(imax);
                  
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&jmax, buf, LIBMESH_SIZEOF_INT);
                  rb(jmax);
                  
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&kmax, buf, LIBMESH_SIZEOF_INT);
                  rb(kmax);
                  
                  zimax.push_back (imax);
                  zjmax.push_back (jmax);
                  zkmax.push_back (kmax);
                }
              } // else if (f == 299.)
          }
        while ((f != 357.) && in.good());
      }

      // Set the header data
      this->set_n_zones (nz);

      for (unsigned int z=0; z<this->n_zones(); z++)
        {
          this->zone_type(z) = ztype[z];
          this->zone_name(z) = zname[z];
          this->imax(z)      = zimax[z];
          this->jmax(z)      = zjmax[z];
          this->kmax(z)      = zkmax[z];
        }
    }
  

  //----------------------------------------------------
  // Read plt files written by newer versions of Tecplot
  else if (this->version().rfind('V1') < this->version().size())
    {
      if (this->verbose())
        std::cout << 'Reading new .plt format (>= v10)...'
                  << std::endl;
      
      // Read the value of 1 to determine byte ordering
      {
        int one = 0;
        
        in.read (buf, LIBMESH_SIZEOF_INT);
        std::memcpy  (&one, buf, LIBMESH_SIZEOF_INT);
        
        if (one != 1)
          {
            if (this->verbose())
              std::cerr << 'Tecplot data is Foreign!'
                        << std::endl;
            this->is_foreign() = true;

            // Make sure one reversed is one
            Utility::ReverseBytes rb(this->is_foreign());
            libmesh_assert (rb(one) == 1);
          }
      }

      // A byte-reverser in case the data is foreign
      Utility::ReverseBytes rb(this->is_foreign());

      // Read the title
      {
        int i=0;

        // Using erase() for GCC 2.95.3
        this->title().erase();
        do
          {
            in.read (buf, LIBMESH_SIZEOF_INT);
            std::memcpy  (&i, buf, LIBMESH_SIZEOF_INT);
            rb(i);
            
            // Don't add trailing  
            if (i)
              this->title() += static_cast<char>(i);
          }
        while (i);
      }

      // Read the number of variables in the data set
      {
        int nv;
        in.read (buf, LIBMESH_SIZEOF_INT);
        std::memcpy  (&nv, buf, LIBMESH_SIZEOF_INT);
        rb(nv);
        
        this->set_n_vars (nv);
      }

      // Read the variable names
      for (unsigned int v=0; v<this->n_vars(); v++)
        {
          int i=0;

          // Using erase() for GCC 2.95.3
          this->var_name(v).erase();
      
          do
            {
              in.read (buf, LIBMESH_SIZEOF_INT);
              std::memcpy  (&i, buf, LIBMESH_SIZEOF_INT);
              rb(i);
              
              // Don't add trailing  
              if (i)
                this->var_name(v) += static_cast<char>(i);
            }
          while (i);
        }

  
      
      // Read zones from the header.
      // Continue reading until the end-of-header
      // marker (357.) is found.
      int nz=0;
      std::vector<std::string> zname;
      std::vector<int>         zpack, ztype, zimax, zjmax, zkmax, znelem, znnodes;
      
      {
        float f=0.;
    
        do
          {
            // find the next Zone marker        
            do
              {
                f = 0.;
                in.read (buf, LIBMESH_SIZEOF_FLOAT);
                std::memcpy  (&f, buf, LIBMESH_SIZEOF_FLOAT);
                rb(f);
              }
            while ((f != 299.) &&
                   (f != 357.) &&
                   in.good());
          
          
            // Did we overrun the file?
            if (!in.good())
              {
                std::cerr << 'ERROR: Unexpected end-of-file!'
                          << std::endl;
                libmesh_error();
              }    
          
            // Found a Zone marker
            else if (f == 299.) 
              {
                // Incriment the Zone counter
                nz++;
          
                // Read the zone name
                {
                  int i=0;
                  std::string name;
            
                  do
                    {
                      in.read (buf, LIBMESH_SIZEOF_INT);
                      std::memcpy  (&i, buf, LIBMESH_SIZEOF_INT);
                      rb(i);
                  
                      // Don't add trailing  
                      if (i)
                        name += static_cast<char>(i);
                    }
                  while (i);
            
                  zname.push_back(name);
                }
              
                // Read the zone color
                {
                  int zc=0;         
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&zc, buf, LIBMESH_SIZEOF_INT);
                  rb(zc);
                }
              
                // Read the zone format
                {
                  int zt;
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&zt, buf, LIBMESH_SIZEOF_INT);
                  rb(zt);
                  
                  ztype.push_back(zt);
                }

                // Read the data packing flag
                {
                  int dp=0;
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy (&dp, buf, LIBMESH_SIZEOF_INT);
                  rb(dp);

                  zpack.push_back (dp);
                }

                // Will we specify the variable location?
                {
                  int svl=0;
                  int  vl=0;
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&svl, buf, LIBMESH_SIZEOF_INT);
                  rb(svl);
                  
                  if (svl)
                    for (unsigned int v=0; v<this->n_vars(); v++)
                      {
                        in.read (buf, LIBMESH_SIZEOF_INT);
                        std::memcpy  (&vl, buf, LIBMESH_SIZEOF_INT);
                        rb(vl);
                        libmesh_assert (vl == 0); // Only know about node-based data
                                          // right now
                      }
                    
                }

                // Get the number of user-defined face-neighbors
                {
                  int fn=0;
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&fn, buf, LIBMESH_SIZEOF_INT);
                  rb(fn);
                }
          
                // Read in the block dimensions
                {
                  if (ztype.back() != ORDERED)
                    {
                      int np=0, ne=0;

                      in.read (buf, LIBMESH_SIZEOF_INT);
                      std::memcpy  (&np, buf, LIBMESH_SIZEOF_INT);
                      rb(np);

                      in.read (buf, LIBMESH_SIZEOF_INT);
                      std::memcpy  (&ne, buf, LIBMESH_SIZEOF_INT);
                      rb(ne);

                      zimax.push_back (np);
                      zjmax.push_back (ne);
                      zjmax.push_back (0);
                    }
                  
                  int
                    imax=0,
                    jmax=0,
                    kmax=0;
                  
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&imax, buf, LIBMESH_SIZEOF_INT);
                  rb(imax);
                  
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&jmax, buf, LIBMESH_SIZEOF_INT);
                  rb(jmax);
                  
                  in.read (buf, LIBMESH_SIZEOF_INT);
                  std::memcpy  (&kmax, buf, LIBMESH_SIZEOF_INT);
                  rb(kmax);

                  // These are only useful for orderd data.  Otherwise
                  // we grabbed the relevant values above.
                  if (ztype.back() != ORDERED)
                    {
                      zimax.push_back (imax);
                      zjmax.push_back (jmax);
                      zkmax.push_back (kmax);
                    }
                }
              } // else if (f == 299.)
          }
        while ((f != 357.) && in.good());
      }

      // Set the header data
      this->set_n_zones (nz);

      for (unsigned int z=0; z<this->n_zones(); z++)
        {
          this->zone_type(z) = ztype[z];
          this->zone_name(z) = zname[z];
          this->zone_pack(z) = zpack[z];
          this->imax(z)      = zimax[z];
          this->jmax(z)      = zjmax[z];
          this->kmax(z)      = zkmax[z];
        }
    }

  

  //----------------------------------------------------
  // Unrecognized Tecplot Version!
  else
    {
      std::cerr << 'ERROR:  This plot file was written by an unrecognized version of Tecplot!:'
                << std::endl
                << this->version()
                << std::endl;
      libmesh_error();
    }
  


  




  // Print the data to the screen.
  if (this->verbose())
    {
      std::cout << 'Tecplot Header: '
                << this->title() << std::endl;

      std::cout << 'Variables: ';      
      for (unsigned int v=0; v<this->n_vars(); v++)
        std::cout << ''' << this->var_name (v) << ''' << ' ';  
      std::cout << std::endl;

      std::cout << 'Variable Types: ';      
      for (unsigned int v=0; v<this->n_vars(); v++)
        std::cout << this->var_type (v) << ' ';  
      std::cout << std::endl;

      std::cout << 'Zone Names: ';
      for (unsigned int z=0; z<this->n_zones(); z++)
        std::cout << ''' << this->zone_name (z) << ''' << ' ';
      std::cout << std::endl;

      std::cout << 'Zone Types: ';
      for (unsigned int z=0; z<this->n_zones(); z++)
        {
          std::cout << this->zone_type (z) << ' ';

          if (this->zone_type (z) != ORDERED)
            std::cout << '(' << this->n_nodes(z) << ',' << this->n_elem(z) << ') ';
        }
      std::cout << std::endl;

      std::cout << 'Zone Dimensions: ' << std::endl;
      for (unsigned int z=0; z<this->n_zones(); z++)
        std::cout << '  ('
                  << this->imax(z) << ',' 
                  << this->jmax(z) << ',' 
                  << this->kmax(z) << ')'
                  << std::endl;  
    }
}
 

void PltLoader::read_point_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in POINT structured format.

Definition at line 945 of file plt_loader_read.C.

References _data, buf, DOUBLE, FLOAT, imax(), is_foreign(), jmax(), kmax(), n_vars(), and var_type().

Referenced by read_data().

{
  libmesh_assert (in.good());

  // A byte-reverser in case the data is foreign
  Utility::ReverseBytes rb(this->is_foreign());

  // First allocate space
  for (unsigned int var=0; var<this->n_vars(); var++)
    {
      std::vector<float> & data = _data[zone][var];
      
      data.clear();
      data.reserve (this->imax(zone)*
                    this->jmax(zone)*
                    this->kmax(zone));
    }

  
  for (unsigned int k=0; k<this->kmax(zone); k++)
    for (unsigned int j=0; j<this->jmax(zone); j++)
      for (unsigned int i=0; i<this->imax(zone); i++)
        for (unsigned int var=0; var<this->n_vars(); var++)
          if (this->var_type(var) == FLOAT)
            {
              float f = 0.;
              
              libmesh_assert (in.good());
              
              in.read (buf, LIBMESH_SIZEOF_FLOAT);
              std::memcpy  (&f, buf, LIBMESH_SIZEOF_FLOAT);
              rb(f);
                    
              _data[zone][var].push_back(f);                    
            }
          else if (this->var_type(var) == DOUBLE)
            {
              double d = 0.;
              
              libmesh_assert (in.good());
              
              in.read (buf, LIBMESH_SIZEOF_DOUBLE);
              std::memcpy  (&d, buf, LIBMESH_SIZEOF_DOUBLE);
              rb(d);
              
              _data[zone][var].push_back(d);                    
            }
          else
            {
              std::cerr << 'ERROR: unsupported data type: '
                        << this->var_type(var)
                        << std::endl;
              libmesh_error();
            }
}
 

void PltLoader::set_n_vars (const unsigned intnv) [private]Returns:

the number of variables in the data set.

Definition at line 59 of file plt_loader.C.

References _data, _n_vars, _var_names, _var_types, n_vars(), and n_zones().

Referenced by read_header().

{
  _n_vars = nv;

  _var_types.resize (this->n_vars());
  _var_names.resize (this->n_vars());

  // Default to float data
  std::fill (_var_types.begin(), _var_types.end(), 1);

  // If the number of zones is set, resize the data.
  if (this->n_zones())
    {
      _data.resize  (this->n_zones());

      for (unsigned int z=0; z<this->n_zones(); z++)
        _data[z].resize  (this->n_vars());
    }
}
 

void PltLoader::set_n_zones (const unsigned intnz) [private]Returns:

the number of zones.

Definition at line 81 of file plt_loader.C.

References _conn, _data, _imax, _jmax, _kmax, _n_zones, _zone_names, _zone_pack, _zone_types, n_vars(), and n_zones().

Referenced by read_header().

{
  _n_zones = nz;

  _zone_types.resize (this->n_zones());
  _zone_names.resize (this->n_zones());
  _zone_pack.resize  (this->n_zones());
  
  _imax.resize (this->n_zones());
  _jmax.resize (this->n_zones());
  _kmax.resize (this->n_zones());

  _data.resize (this->n_zones());
  _conn.resize        (this->n_zones());

  // If the number of variables are set, resize the data.
  if (this->n_vars())
    for (unsigned int z=0; z<this->n_zones(); z++)
      _data[z].resize (this->n_vars());
}
 

const std::string& PltLoader::title () const [inline]Returns:

the data set title

Definition at line 172 of file plt_loader.h.

References _title.

Referenced by read_header(), and write_dat().

{ return _title; }
 

std::string& PltLoader::title () [inline, private]Returns:

the data set title

Definition at line 304 of file plt_loader.h.

References _title.

{ return _title; }
 

std::string & PltLoader::var_name (const unsigned intv) [inline, private]Returns:

the name of variable v.

Definition at line 488 of file plt_loader.h.

References _var_names, and n_vars().

{
  libmesh_assert (v < this->n_vars());
  libmesh_assert (v < _var_names.size());
  libmesh_assert (this->n_vars() == _var_names.size());

  return _var_names[v];
}
 

const std::string & PltLoader::var_name (const unsigned intv) const [inline]Returns:

the name of variable v.

Definition at line 476 of file plt_loader.h.

References _var_names, and n_vars().

Referenced by read_header(), and write_dat().

{
  libmesh_assert (v < this->n_vars());
  libmesh_assert (v < _var_names.size());
  libmesh_assert (this->n_vars() == _var_names.size());

  return _var_names[v];
}
 

unsigned int & PltLoader::var_type (const unsigned intv) [inline, private]Returns:

the type of variable v

Definition at line 512 of file plt_loader.h.

References _var_types, and n_vars().

{
  libmesh_assert (v < this->n_vars());
  libmesh_assert (v < _var_types.size());
  libmesh_assert (this->n_vars() == _var_types.size());

  return _var_types[v];
}
 

unsigned int PltLoader::var_type (const unsigned intv) const [inline]Returns:

the type of variable v

Definition at line 500 of file plt_loader.h.

References _var_types, and n_vars().

Referenced by read_block_data(), read_data(), read_feblock_data(), read_fepoint_data(), read_header(), and read_point_data().

{
  libmesh_assert (v < this->n_vars());
  libmesh_assert (v < _var_types.size());
  libmesh_assert (this->n_vars() == _var_types.size());

  return _var_types[v];
}
 

bool PltLoader::verbose () const [inline]Returns the verbosity.

Definition at line 67 of file plt_loader.h.

References _verbose.

Referenced by read(), read_data(), and read_header().

{ return _verbose; }
 

const std::string& PltLoader::version () const [inline]Returns:

the Tecplot version number string. This identifies the version of Tecplot (or preplot) that wrote the binary file. Currently, PltLoader understands versions '#!TDV7X ' and '#!TDV1XX'

Definition at line 160 of file plt_loader.h.

References _version.

Referenced by read_data(), and read_header().

{ return _version; }
 

std::string& PltLoader::version () [inline, private]Returns:

the Tecplot version number string.

Definition at line 292 of file plt_loader.h.

References _version.

{ return _version; }
 

void PltLoader::write_dat (const std::string &name, const unsigned intversion = 10) constWrites an ASCII Tecplot file. The optional parameter version specifies the version format to write.

Definition at line 449 of file plt_loader_write.C.

References _data, BLOCK, imax(), jmax(), kmax(), n_vars(), n_zones(), POINT, title(), var_name(), zone_name(), and zone_type().

{
  std::ofstream out (name.c_str());

  out << 'TITLE=''
      << this->title()
      << '''
      << ';

  out << 'VARIABLES = ';

  for (unsigned int v=0; v<this->n_vars(); v++)
    out << ''' << this->var_name(v) << '';

  for (unsigned int z=0; z<this->n_zones(); z++)
    {
      out << 'ZONE T='' << this->zone_name(z) << '';
      out << ' I='  << this->imax(z)
          << ', J=' << this->jmax(z)
          << ', K=' << this->kmax(z);

      // Write BLOCK data for this zone
      if (this->zone_type(z) == BLOCK)
        {
          if (version < 10)
            {
              out << ', F=BLOCK;
            }
          else
            {
              out << ', ZONETYPE=Ordered
                  << 'DATAPACKING=BLOCK;
            }
      
          out << 'DT=(';
          for (unsigned int v=0; v<this->n_vars(); v++)
            out << 'SINGLE ';
          out << ');

          out.precision(9);
          
          for (unsigned int v=0; v<this->n_vars(); v++)
            {
              unsigned int l=0;
              
              for (unsigned int k=0; k<this->kmax(z); k++)
                for (unsigned int j=0; j<this->jmax(z); j++)
                  for (unsigned int i=0; i<this->imax(z); i++)
                    {
                      // GCC 2.95.3 has scientific in the ios class instead
                      // of in namespace std::
#ifndef LIBMESH_BROKEN_IOSTREAM
                      out << std::scientific
                          << _data[z][v][l++] << ' ';
#else
                      out << std::ios::scientific
                          << _data[z][v][l++] << ' ';
#endif
                      // Throw in a newline every 5 entries to
                      // avoid really long lines.
                      if (l%5 == 0)
                        out << ';
                    }

              if (l%5 != 0)
                out << ';
            }
        } // end if (this->zone_type(z) == BLOCK)

      // Write POINT data for this zone
      else if (this->zone_type(z) == POINT)
        {
          if (version < 10)
            {
              out << ', F=POINT;
            }
          else
            {
              out << ', ZONETYPE=Ordered
                  << 'DATAPACKING=POINT;
            }
          
          out << 'DT=(';
          for (unsigned int v=0; v<this->n_vars(); v++)
            out << 'SINGLE ';
          out << ');
          
          out.precision(9);
          
          {
            unsigned int l=0;
            
            for (unsigned int k=0; k<this->kmax(z); k++)
              for (unsigned int j=0; j<this->jmax(z); j++)
                for (unsigned int i=0; i<this->imax(z); i++)
                  {
                    for (unsigned int v=0; v<this->n_vars(); v++)

                      // GCC 2.95.3 has scientific in the ios class instead
                      // of in namespace std::
#ifndef LIBMESH_BROKEN_IOSTREAM
                      out << std::scientific
                          << _data[z][v][l] << ' ';
#else
                      out << std::ios::scientific
                          << _data[z][v][l] << ' ';
#endif
                    out << ';
                    
                    l++;
                  }
          }
        } // end else if (this->zone_type(z) == POINT)

      // Otherwise, unrecognized zone type
      else
        {
          std::cerr << 'Unrecognized zone type: ';
          std::cerr << 'this->zone_type(z)==' << this->zone_type(z) << std::endl;
          libmesh_error();
        }
    }
}
 

std::string & PltLoader::zone_name (const unsigned intz) [inline, private]Returns:

the name of zone z.

Definition at line 560 of file plt_loader.h.

References _zone_names, and n_zones().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (z < _zone_names.size());
  libmesh_assert (this->n_zones() == _zone_names.size());

  return _zone_names[z];
}
 

const std::string & PltLoader::zone_name (const unsigned intz) const [inline]Returns:

the name of zone z.

Definition at line 548 of file plt_loader.h.

References _zone_names, and n_zones().

Referenced by read_header(), and write_dat().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (z < _zone_names.size());
  libmesh_assert (this->n_zones() == _zone_names.size());

  return _zone_names[z];
}
 

unsigned int PltLoader::zone_pack (const unsigned intz) const [inline]Returns:

the data packing flag for zone z.

Definition at line 572 of file plt_loader.h.

References _zone_pack, and n_zones().

Referenced by read_data(), and read_header().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (z < _zone_pack.size());
  libmesh_assert (this->n_zones() == _zone_pack.size());

  return _zone_pack[z];
}
 

unsigned int & PltLoader::zone_pack (const unsigned intz) [inline, private]Returns:

the data pack flag for zone z.

Definition at line 584 of file plt_loader.h.

References _zone_pack, and n_zones().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (z < _zone_pack.size());
  libmesh_assert (this->n_zones() == _zone_pack.size());

  return _zone_pack[z];
}
 

unsigned int PltLoader::zone_type (const unsigned intz) const [inline]Returns:

the type of zone z

Definition at line 524 of file plt_loader.h.

References _zone_types, and n_zones().

Referenced by elem_type(), n_elem(), n_nodes(), read_data(), read_header(), and write_dat().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (z < _zone_types.size());
  libmesh_assert (this->n_zones() == _zone_types.size());

  return _zone_types[z];
}
 

unsigned int & PltLoader::zone_type (const unsigned intz) [inline, private]Returns:

the type of zone z

Definition at line 536 of file plt_loader.h.

References _zone_types, and n_zones().

{
  libmesh_assert (z < this->n_zones());
  libmesh_assert (z < _zone_types.size());
  libmesh_assert (this->n_zones() == _zone_types.size());

  return _zone_types[z];
}
 

Member Data Documentation

 

std::vector<std::vector<int> > PltLoader::_conn [private]Vectors to hold the connectivity for each zone (only for unstructured files).

Definition at line 433 of file plt_loader.h.

Referenced by clear(), read_feblock_data(), read_fepoint_data(), and set_n_zones().  

std::vector<std::vector<std::vector<float> > > PltLoader::_data [private]Vector to hold the data.

Definition at line 427 of file plt_loader.h.

Referenced by clear(), get_data(), read_block_data(), read_feblock_data(), read_fepoint_data(), read_point_data(), set_n_vars(), set_n_zones(), and write_dat().  

std::vector<unsigned int> PltLoader::_imax [private]The (imax,jmax,kmax) value for each zone.

Definition at line 420 of file plt_loader.h.

Referenced by clear(), imax(), and set_n_zones().  

bool PltLoader::_is_foreign [private]Is the data foreign?

Definition at line 374 of file plt_loader.h.

Referenced by clear(), and is_foreign().  

std::vector<unsigned int> PltLoader::_jmax [private]

Definition at line 421 of file plt_loader.h.

Referenced by clear(), jmax(), and set_n_zones().  

std::vector<unsigned int> PltLoader::_kmax [private]

Definition at line 422 of file plt_loader.h.

Referenced by clear(), kmax(), and set_n_zones().  

unsigned int PltLoader::_n_vars [private]The number of variables in the data set.

Definition at line 384 of file plt_loader.h.

Referenced by clear(), n_vars(), and set_n_vars().  

unsigned int PltLoader::_n_zones [private]The number of zones.

Definition at line 400 of file plt_loader.h.

Referenced by clear(), n_zones(), and set_n_zones().  

std::string PltLoader::_title [private]The Tecplot data set title.

Definition at line 379 of file plt_loader.h.

Referenced by clear(), and title().  

std::vector<std::string> PltLoader::_var_names [private]The name for each variable.

Definition at line 389 of file plt_loader.h.

Referenced by clear(), set_n_vars(), and var_name().  

std::vector<unsigned int> PltLoader::_var_types [private]The type of each variable. Must be one of the enumerated DataType types.

Definition at line 395 of file plt_loader.h.

Referenced by clear(), set_n_vars(), and var_type().  

const bool PltLoader::_verbose [private]Verbosity

Definition at line 364 of file plt_loader.h.

Referenced by verbose().  

std::string PltLoader::_version [private]The Tecplot Version number string.

Definition at line 369 of file plt_loader.h.

Referenced by clear(), and version().  

std::vector<std::string> PltLoader::_zone_names [private]The name of each zone.

Definition at line 410 of file plt_loader.h.

Referenced by clear(), set_n_zones(), and zone_name().  

std::vector<unsigned int> PltLoader::_zone_pack [private]The data packing for each zone (new version only)

Definition at line 415 of file plt_loader.h.

Referenced by clear(), set_n_zones(), and zone_pack().  

std::vector<unsigned int> PltLoader::_zone_types [private]The type of each zone.

Definition at line 405 of file plt_loader.h.

Referenced by clear(), set_n_zones(), and zone_type().  

char PltLoader::buf[512] [mutable, private]Scratch data & relevant sizes.

Definition at line 438 of file plt_loader.h.

Referenced by read_data(), read_fepoint_data(), read_header(), and read_point_data().  

const unsigned int PltLoader::NNodes = {3, 4, 4, 8} [static]Enum defining the number of nodes for each element type.

Definition at line 247 of file plt_loader.h.

Referenced by read_feblock_data(), and read_fepoint_data().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Types
Public Member Functions
Static Public Attributes
Private Member Functions
Private Attributes
Detailed Description
Member Enumeration Documentation
enum PltLoader::DataTypeEnum defining the data type of each variable.
enum PltLoader::FETypeEnum defining the finite element types
enum PltLoader::NewZoneTypeEnum defining the zone type in the Tecplot binary file, for use with the new .plt format.
enum PltLoader::OldZoneTypeWrites a plot3d files. The grid will be in basename.g and the solution will be in basename.q. It is assumed that the first three variables from the .plt file are the (x,y,z) locations of the grid points. The optional parameter reverse specifies if the output file will have reversed byte ordering. Writes a Cart3D .tri component file. The number of components will be the number of zones in the .plt file. Enum defining the zone type in the Tecplot binary file, for use with the old .plt format.
Constructor & Destructor Documentation
PltLoader::PltLoader (const boolv = false) [inline]Constructor. Initializes data.
PltLoader::PltLoader (const std::string &name, const boolv = false) [inline]Constructor. Reads the file specified by name.
PltLoader::~PltLoader () [inline]Destructor.
Member Function Documentation
void PltLoader::clear ()Clear all data and return to a pristine state.
PltLoader::FEType PltLoader::elem_type (const unsigned intz) const [inline]Returns:
const std::vector< std::vector< std::vector< float > > > & PltLoader::get_data () const [inline]Returns:
unsigned int & PltLoader::imax (const unsigned intz) [inline, private]Returns:
unsigned int PltLoader::imax (const unsigned intz) const [inline]Returns:
bool PltLoader::is_foreign () const [inline]Returns:
bool& PltLoader::is_foreign () [inline, private]Returns:
unsigned int & PltLoader::jmax (const unsigned intz) [inline, private]Returns:
unsigned int PltLoader::jmax (const unsigned intz) const [inline]Returns:
unsigned int PltLoader::kmax (const unsigned intz) const [inline]Returns:
unsigned int & PltLoader::kmax (const unsigned intz) [inline, private]Returns:
unsigned int PltLoader::n_elem (const unsigned intz) const [inline]Returns:
unsigned int PltLoader::n_nodes (const unsigned intz) const [inline]Returns:
unsigned int PltLoader::n_vars () const [inline]Returns:
unsigned int PltLoader::n_zones () const [inline]Returns:
void PltLoader::read (const std::string &name)Reads the .plt file specified by name.
void PltLoader::read_block_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in BLOCK structured format.
void PltLoader::read_data (std::istream &in) [private]Read data from the binary file.
void PltLoader::read_feblock_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in FEBLOCK unstructured format.
void PltLoader::read_fepoint_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in FEPOINT unstructured format.
void PltLoader::read_header (std::istream &in) [private]Read the header of the binary file.
void PltLoader::read_point_data (std::istream &in, const unsigned intzn) [private]Read data for the zth zone in POINT structured format.
void PltLoader::set_n_vars (const unsigned intnv) [private]Returns:
void PltLoader::set_n_zones (const unsigned intnz) [private]Returns:
const std::string& PltLoader::title () const [inline]Returns:
std::string& PltLoader::title () [inline, private]Returns:
std::string & PltLoader::var_name (const unsigned intv) [inline, private]Returns:
const std::string & PltLoader::var_name (const unsigned intv) const [inline]Returns:
unsigned int & PltLoader::var_type (const unsigned intv) [inline, private]Returns:
unsigned int PltLoader::var_type (const unsigned intv) const [inline]Returns:
bool PltLoader::verbose () const [inline]Returns the verbosity.
const std::string& PltLoader::version () const [inline]Returns:
std::string& PltLoader::version () [inline, private]Returns:
void PltLoader::write_dat (const std::string &name, const unsigned intversion = 10) constWrites an ASCII Tecplot file. The optional parameter version specifies the version format to write.
std::string & PltLoader::zone_name (const unsigned intz) [inline, private]Returns:
const std::string & PltLoader::zone_name (const unsigned intz) const [inline]Returns:
unsigned int PltLoader::zone_pack (const unsigned intz) const [inline]Returns:
unsigned int & PltLoader::zone_pack (const unsigned intz) [inline, private]Returns:
unsigned int PltLoader::zone_type (const unsigned intz) const [inline]Returns:
unsigned int & PltLoader::zone_type (const unsigned intz) [inline, private]Returns:
Member Data Documentation
std::vector<std::vector<int> > PltLoader::_conn [private]Vectors to hold the connectivity for each zone (only for unstructured files).
std::vector<std::vector<std::vector<float> > > PltLoader::_data [private]Vector to hold the data.
std::vector<unsigned int> PltLoader::_imax [private]The (imax,jmax,kmax) value for each zone.
bool PltLoader::_is_foreign [private]Is the data foreign?
std::vector<unsigned int> PltLoader::_jmax [private]
std::vector<unsigned int> PltLoader::_kmax [private]
unsigned int PltLoader::_n_vars [private]The number of variables in the data set.
unsigned int PltLoader::_n_zones [private]The number of zones.
std::string PltLoader::_title [private]The Tecplot data set title.
std::vector<std::string> PltLoader::_var_names [private]The name for each variable.
std::vector<unsigned int> PltLoader::_var_types [private]The type of each variable. Must be one of the enumerated DataType types.
const bool PltLoader::_verbose [private]Verbosity
std::string PltLoader::_version [private]The Tecplot Version number string.
std::vector<std::string> PltLoader::_zone_names [private]The name of each zone.
std::vector<unsigned int> PltLoader::_zone_pack [private]The data packing for each zone (new version only)
std::vector<unsigned int> PltLoader::_zone_types [private]The type of each zone.
char PltLoader::buf[512] [mutable, private]Scratch data & relevant sizes.
const unsigned int PltLoader::NNodes = {3, 4, 4, 8} [static]Enum defining the number of nodes for each element type.
Author

This document was created by man2html, using the manual pages.
Time: 21:52:33 GMT, April 16, 2011