$extrastylesheet
libMesh::XdrMESH Class Reference

#include <xdr_mesh.h>

Inheritance diagram for libMesh::XdrMESH:

List of all members.

Public Types

enum  XdrIO_TYPE {
  UNKNOWN = -1, ENCODE = 0, DECODE, W_ASCII,
  R_ASCII
}

Public Member Functions

 XdrMESH ()
void init (XdrIO_TYPE type, const char *fn, int icnt, int dim=3)
 ~XdrMESH ()
int header (XdrMHEAD *hd)
int Icon (int *array, int numvar, int num)
int coord (Real *array, int dim, int size)
int BC (int *array, int size)
void init (XdrIO_TYPE t, const char *fn, const char *type, int icnt)
void fini ()
int dataBlk (int *array, int numvar, int size)
int dataBlk (Real *array, int numvar, int size)
LegacyXdrIO::FileFormat get_orig_flag () const
void set_orig_flag (LegacyXdrIO::FileFormat in_orig_flag)
void set_num_levels (unsigned int num_levels)
unsigned int get_num_levels ()

Protected Attributes

unsigned int _num_levels
XdrIO_TYPE m_type
XDR * mp_xdr_handle
LegacyXdrIO::FileFormat orig_flag
std::ifstream mp_in
std::ofstream mp_out

Private Attributes

int m_dim

Detailed Description

The XdrMESH class. This class is responsible for reading/writing information about the mesh to xdr style binary files.

Author:
Bill Barth, Robert McLay.

Definition at line 41 of file xdr_mesh.h.


Member Enumeration Documentation

enum libMesh::XdrMGF::XdrIO_TYPE [inherited]

This enum specifies the access permission which will be acquired for the current xdr file. Note that it is only possible to read (DECODE) or write (ENCODE) but not both. For ASCII type files, use WRITE or READ instead!

Enumerator:
UNKNOWN 
ENCODE 
DECODE 
W_ASCII 
R_ASCII 

Definition at line 98 of file xdr_mgf.h.


Constructor & Destructor Documentation

Constructor. Initializes m_dim to -1.

Definition at line 49 of file xdr_mesh.h.

: m_dim(-1) {}

Destructor.

Definition at line 67 of file xdr_mesh.h.

{}

Member Function Documentation

int libMesh::XdrMESH::BC ( int *  array,
int  size 
) [inline]

Read/Write a BC of appropriate size

Parameters:
arrayPointer to an array of Reals
sizeSize of array (number of elements)
Returns:
3*size

Definition at line 105 of file xdr_mesh.h.

References libMesh::XdrMGF::dataBlk().

Referenced by libMesh::LegacyXdrIO::read_mesh(), and libMesh::LegacyXdrIO::write_mesh().

{ return dataBlk(array, 3, size);}
int libMesh::XdrMESH::coord ( Real array,
int  dim,
int  size 
) [inline]

Read/Write a coord of appropriate size.

Parameters:
arrayPointer to an array of Reals
sizeSize of array (number of elements)
Returns:
dim*size

Definition at line 96 of file xdr_mesh.h.

References libMesh::XdrMGF::dataBlk().

Referenced by libMesh::LegacyXdrIO::read_mesh(), and libMesh::LegacyXdrIO::write_mesh().

{ return dataBlk(array, dim, size);}
int libMesh::XdrMGF::dataBlk ( int *  array,
int  numvar,
int  size 
) [inherited]

Reads/Writes a block of ints to/from the current xdr file/file handle.

Parameters:
arrayPointer to data to be read/written
numvarThe total number of variables (size of the array)
sizeThe size of each individual variable in the array

Definition at line 264 of file xdr_mgf.C.

References libMesh::XdrMGF::DECODE, libMesh::XdrMGF::ENCODE, libMesh::libmesh_assert(), libMesh::XdrMGF::m_type, libMesh::XdrMGF::mp_in, libMesh::XdrMGF::mp_out, libMesh::XdrMGF::mp_xdr_handle, libMesh::XdrMGF::R_ASCII, and libMesh::XdrMGF::W_ASCII.

Referenced by BC(), coord(), Icon(), and libMesh::XdrSOLN::values().

{
  int totalSize = numvar*size;

  switch (m_type)
    {

#ifdef LIBMESH_HAVE_XDR

    case (XdrMGF::DECODE):
    case (XdrMGF::ENCODE):
      {
        xdr_vector(mp_xdr_handle,
                   (char *) &array[0],
                   totalSize,
                   sizeof(int),
                   (xdrproc_t) xdr_int);
        break;
      }

#endif

    case (XdrMGF::W_ASCII):
      {
        for (int i=0; i<size; i++)
          {
            for (int j=0; j<numvar; j++)
              mp_out << array[i*numvar + j] << " ";

            mp_out << '\n';
          }

        mp_out.flush();
        break;
      }

    case (XdrMGF::R_ASCII):
      {
        libmesh_assert (mp_in.good());

        for (int i=0; i<size; i++)
          {
            for (int j=0; j<numvar; j++)
              {
                mp_in >> array[i*numvar + j];
              }

            mp_in.ignore(); // Read newline
          }

        break;
      }

    default:
      // Unknown access type
      libmesh_error_msg("Unknown m_type" << m_type);
    }

  return totalSize;
}
int libMesh::XdrMGF::dataBlk ( Real array,
int  numvar,
int  size 
) [inherited]

Read/Writes a block of Reals to/from the current xdr file/file handle.

Definition at line 327 of file xdr_mgf.C.

References libMesh::XdrMGF::DECODE, libMesh::XdrMGF::ENCODE, libMesh::libmesh_assert(), libMesh::XdrMGF::m_type, libMesh::XdrMGF::mp_in, libMesh::XdrMGF::mp_out, libMesh::XdrMGF::mp_xdr_handle, libMesh::XdrMGF::R_ASCII, libMesh::Real, and libMesh::XdrMGF::W_ASCII.

{
  int totalSize = numvar*size;

  // If this function is called by coord(),
  // numvar is the problem dimension, and
  // size is the number of nodes in the problem.

  //libMesh::out << "Total amount of data to be written: " << totalSize << std::endl;

  switch (m_type)
    {

#ifdef LIBMESH_HAVE_XDR

    case (XdrMGF::DECODE):
    case (XdrMGF::ENCODE):
      {
        // FIXME - this is probably broken for Real == long double
        // RHS
        xdr_vector(mp_xdr_handle,
                   (char *) &array[0],
                   totalSize,
                   sizeof(Real),
                   (xdrproc_t) xdr_REAL);
      }

#endif

    case (XdrMGF::W_ASCII):
      {
        // Save stream flags
        std::ios_base::fmtflags out_flags = mp_out.flags();

        // We will use scientific notation with a precision of 16
        // digits in the following output.  The desired precision and
        // format will automatically determine the width.
        mp_out << std::scientific
               << std::setprecision(16);

        for (int i=0; i<size; i++)
          {
            for (int j=0; j<numvar; j++)
              mp_out << array[i*numvar + j] << " \t";

            mp_out << '\n';
          }

        // Restore stream flags
        mp_out.flags(out_flags);

        mp_out.flush();
        break;
      }

    case (XdrMGF::R_ASCII):
      {
        libmesh_assert (mp_in.good());

        for (int i=0; i<size; i++)
          {
            libmesh_assert (mp_in.good());

            for (int j=0; j<numvar; j++)
              mp_in >> array[i*numvar + j];

            mp_in.ignore(); // Read newline
          }

        break;
      }

    default:
      // Unknown access type
      libmesh_error_msg("Unknown m_type" << m_type);
    }

  return totalSize;
}
void libMesh::XdrMGF::fini ( ) [inherited]

Finalizes operations on the current xdr file handle, and closes the xdr file.

Uses xdr_destroy found in rpc/rpc.h.

Definition at line 35 of file xdr_mgf.C.

References libMesh::XdrMGF::mp_fp, and libMesh::XdrMGF::mp_xdr_handle.

Referenced by libMesh::XdrMGF::init(), and libMesh::XdrMGF::~XdrMGF().

{

#ifdef LIBMESH_HAVE_XDR

  if (mp_xdr_handle)
    {
      //libMesh::out << "Destroying XDR file handle." << std::endl;
      xdr_destroy(mp_xdr_handle);
    }

  //libMesh::out << "Deleting the file handle pointer." << std::endl;
  delete mp_xdr_handle;

  mp_xdr_handle = NULL;

#endif

  if (mp_fp)
    {
      //libMesh::out << "Closing file." << std::endl;
      std::fflush(mp_fp);
      std::fclose(mp_fp);
    }

  mp_fp = NULL;
}
unsigned int libMesh::XdrMGF::get_num_levels ( ) [inline, inherited]

Get number of levels

Definition at line 190 of file xdr_mgf.h.

References libMesh::XdrMGF::_num_levels.

Referenced by header(), libMesh::XdrMGF::init(), and libMesh::LegacyXdrIO::read_mesh().

{ return _num_levels; }

Get the originator flag.

Definition at line 174 of file xdr_mgf.h.

References libMesh::XdrMGF::orig_flag.

Referenced by libMesh::XdrMGF::init(), libMesh::LegacyXdrIO::read_mesh(), and libMesh::LegacyXdrIO::write_mesh().

{ return orig_flag; }

Read/Write the mesh_base.header. Uses xdr_int found in rpc/rpc.h.

Parameters:
hdPointer to an xdr mesh_base.header object
Returns:
1 on success

Definition at line 28 of file xdr_mesh.C.

References libMesh::XdrHEAD::cpyString(), libMesh::XdrMGF::DECODE, libMesh::XdrMGF::ENCODE, libMesh::XdrMHEAD::get_block_elt_types(), libMesh::XdrMHEAD::get_n_blocks(), libMesh::XdrMHEAD::get_num_elem_each_block(), libMesh::XdrMGF::get_num_levels(), libMesh::XdrHEAD::getId(), libMesh::XdrHEAD::getTitle(), libMesh::libmesh_assert(), libMesh::XdrHEAD::m_numBCs, libMesh::XdrHEAD::m_numel, libMesh::XdrHEAD::m_numNodes, libMesh::XdrHEAD::m_strSize, libMesh::XdrHEAD::m_sumWghts, libMesh::XdrMGF::m_type, libMesh::XdrHEAD::mp_id, libMesh::XdrMGF::mp_in, libMesh::XdrMGF::mp_out, libMesh::XdrHEAD::mp_title, libMesh::XdrMGF::mp_xdr_handle, libMesh::XdrMGF::orig_flag, libMesh::XdrMGF::R_ASCII, libMesh::XdrMHEAD::set_block_elt_types(), libMesh::XdrMHEAD::set_n_blocks(), libMesh::XdrMHEAD::set_num_elem_each_block(), libMesh::XdrHEAD::setId(), libMesh::XdrHEAD::setTitle(), and libMesh::XdrMGF::W_ASCII.

Referenced by libMesh::LegacyXdrIO::read_mesh(), and libMesh::LegacyXdrIO::write_mesh().

{
  // Temporary variables to facilitate stream reading
  const int comm_len= 256;
  char comment[comm_len];

  switch (m_type)
    {

#ifdef LIBMESH_HAVE_XDR

    case (XdrMGF::DECODE):
    case (XdrMGF::ENCODE):
      {
        xdr_int(mp_xdr_handle, &(hd->m_numel));
        xdr_int(mp_xdr_handle, &(hd->m_numNodes));
        xdr_int(mp_xdr_handle, &(hd->m_sumWghts));
        xdr_int(mp_xdr_handle, &(hd->m_numBCs));
        xdr_int(mp_xdr_handle, &(hd->m_strSize));
        break;
      }

#endif

    case (XdrMGF::W_ASCII):
      {
        mp_out << hd->m_numel    << "\t # Num. Elements\n";
        mp_out << hd->m_numNodes << "\t # Num. Nodes\n";
        mp_out << hd->m_sumWghts << "\t # Sum of Element Weights\n";
        mp_out << hd->m_numBCs   << "\t # Num. Boundary Conds.\n";
        mp_out << hd->m_strSize  << "\t # String Size (ignore)\n";
        break;
      }

    case (XdrMGF::R_ASCII):
      {
        libmesh_assert (mp_in.good());

        mp_in >> hd->m_numel    ; mp_in.getline(comment, comm_len);
        mp_in >> hd->m_numNodes ; mp_in.getline(comment, comm_len);
        mp_in >> hd->m_sumWghts ; mp_in.getline(comment, comm_len);
        mp_in >> hd->m_numBCs   ; mp_in.getline(comment, comm_len);
        mp_in >> hd->m_strSize  ; mp_in.getline(comment, comm_len);

        libmesh_assert(mp_in.good());

        break;
      }

    default:
      // Unknown access type
      libmesh_error_msg("Unknown m_type" << m_type);
    }

  // Let's write the augmented header information
  // before we write the title and id string

  // Both DEAL and LIBM style files have augmented headers.
  if ((orig_flag == 0) || (orig_flag == 2))
    {

      switch (m_type)
        {

#ifdef LIBMESH_HAVE_XDR

        case (XdrMGF::ENCODE):
        case (XdrMGF::DECODE):
          {
            // this used to be 0.  How did that work?
            unsigned int temp_n_blocks = hd->get_n_blocks();
            xdr_u_int(mp_xdr_handle, &temp_n_blocks);
            hd->set_n_blocks(temp_n_blocks);

            // The number of blocks (i.e. the number of element types)
            // for any mesh must always
            // be at least 1.
            libmesh_assert_not_equal_to (hd->get_n_blocks(), 0);
            break;
          }

#endif

        case (XdrMGF::W_ASCII):
          {
            mp_out << hd->get_n_blocks() << "\t # Num. Element Blocks.\n";
            break;
          }

        case (XdrMGF::R_ASCII):
          {
            libmesh_assert (mp_in.good());
            unsigned int temp_n_blocks=0;
            mp_in >> temp_n_blocks;
            hd->set_n_blocks(temp_n_blocks);
            mp_in.getline(comment, comm_len);
            break;
          }

        default:
          // Unknown access type
          libmesh_error_msg("Unknown m_type" << m_type);
        }


      std::vector<ElemType> et;
      hd->get_block_elt_types(et);


      // Note:  If DECODING or READING, allocate space in the vector
      if ((m_type == DECODE) || (m_type == R_ASCII))
        et.resize(hd->get_n_blocks());


      switch (m_type)
        {

#ifdef LIBMESH_HAVE_XDR

        case (XdrMGF::ENCODE):
        case (XdrMGF::DECODE):
          {
            xdr_vector(mp_xdr_handle,
                       (char *) &et[0],
                       cast_int<unsigned int>(et.size()),
                       sizeof(unsigned int),
                       (xdrproc_t) xdr_u_int);
            break;
          }

#endif

        case (XdrMGF::W_ASCII):
          {
            for (unsigned int i=0; i<hd->get_n_blocks(); i++)
              mp_out << et[i] << " ";

            mp_out << "\t # Element types in each block.\n";
            break;
          }

        case (XdrMGF::R_ASCII):
          {
            libmesh_assert (mp_in.good());

            for (unsigned int i=0; i<hd->get_n_blocks(); i++)
              {
                // convoluted way of doing it to
                // satisfy icc
                unsigned int type;

                mp_in >> type ;

                et[i] = static_cast<ElemType>(type) ;
              }
            mp_in.getline(comment, comm_len);
            break;
          }

        default:
          // Unknown access type
          libmesh_error_msg("Unknown m_type" << m_type);
        }



      // Note:  If DECODING or READING, you need to set the value
      // in the header data structure.
      if ((m_type == DECODE) || (m_type == R_ASCII))
        hd->set_block_elt_types(et);


      std::vector<unsigned int> neeb;
      hd->get_num_elem_each_block(neeb);

      // If DECODING or READING, allocate space for the vector
      if ((m_type == DECODE) || (m_type == R_ASCII))
        neeb.resize( hd->get_n_blocks()*(this->get_num_levels()+1) );

      switch (m_type)
        {

#ifdef LIBMESH_HAVE_XDR

        case (XdrMGF::ENCODE):
        case (XdrMGF::DECODE):
          {
            xdr_vector(mp_xdr_handle,
                       (char *) &neeb[0],
                       cast_int<unsigned int>(neeb.size()),
                       sizeof(unsigned int),
                       (xdrproc_t) xdr_u_int);
          }

#endif

        case (XdrMGF::W_ASCII):
          {
            for (unsigned int i=0; i<neeb.size(); i++)
              mp_out << neeb[i] << " ";

            mp_out << "\t # Num. of elements in each block at each level.\n";
            break;
          }

        case (XdrMGF::R_ASCII):
          {

            // We will treat this line as containing
            // 1.) The number of elements in each block OR
            // 2.) The number of elements at each level in each block
            // Therefore, we don't know a-priori how many ints to read.

            // Get the full line from the stream up to the newline
            mp_in.getline(comment, comm_len);

            // Construct a char buffer to hold the tokens as we
            // process them, and construct a std::string object and
            // a std::stringstream object for tokenizing this line.
            char token[comm_len];
            std::string s_temp(comment);
            std::stringstream ss(s_temp);

            // Resize the neeb vector to zero so we can push back
            // values onto it.  Note that we are using a tokenizer
            // scheme again here to read the line, but it's not entirely
            // necessary since we know the size neeb should have.
            neeb.resize(0);

            // Process the tokens one at a time
            while (ss >> token)
              {
                // If you reach the hash, the rest of the line is a comment,
                // so quit reading.
                if (token[0] == '#')
                  break;

                // If you reach an alphabetic character, this is an error
                if (!isdigit(token[0]))
                  libmesh_error_msg("Error: Unrecognized character detected.");

                // Otherwise, add the value to the neeb vector
                neeb.push_back( std::atoi(token) );
              }

            // Be sure you have the right number of entries in neeb
            libmesh_assert_equal_to (neeb.size(), (hd->get_n_blocks() * (this->get_num_levels()+1)));

            break;
          }

        default:
          // Unknown access type
          libmesh_error_msg("Unknown m_type" << m_type);
        }

      if ((m_type == DECODE) || (m_type == R_ASCII))
        hd->set_num_elem_each_block(neeb);
    }

  else if (orig_flag == 1) // MGF originator
    {
    }
  else  // Unknown Originator!
    libmesh_error_msg("Unknown orig_flag " << orig_flag);




  // Write the ID and TITLE strings (can be safely ignored)
  switch (m_type)
    {

#ifdef LIBMESH_HAVE_XDR

    case (XdrMGF::ENCODE):
    case (XdrMGF::DECODE):
      {
        char* temp = hd->cpyString(hd->getId());
        xdr_string(mp_xdr_handle, &temp,
                   ((m_type == XdrMGF::ENCODE) ?
                    cast_int<unsigned int>(std::strlen(temp)) :
                    hd->m_strSize));
        hd->setId(temp);
        delete [] temp;

        temp = hd->cpyString(hd->getTitle());

        xdr_string(mp_xdr_handle, &temp,
                   ((m_type == XdrMGF::ENCODE) ?
                    cast_int<unsigned int>(std::strlen(temp)) :
                    hd->m_strSize));
        hd->setTitle(temp);
        delete [] temp;
        break;
      }

#endif

    case (XdrMGF::W_ASCII):
      {
        mp_out << hd->mp_id    << '\n';
        mp_out << hd->mp_title << '\n';
        break;
      }

    case (XdrMGF::R_ASCII):
      {
        libmesh_assert (mp_in.good());

        mp_in.getline(comment, comm_len);
        hd->setId(comment);

        libmesh_assert (mp_in.good());

        mp_in.getline(comment, comm_len);
        hd->setTitle(comment);

        break;
      }

    default:
      // Unknown access type
      libmesh_error_msg("Unknown m_type" << m_type);
    }

  return 1;
}
int libMesh::XdrMESH::Icon ( int *  array,
int  numvar,
int  num 
) [inline]

Read/Write an integer connectivity array

Parameters:
arrayPointer to an array of ints
numvarTotal number of variables to be read/written
numBasically a dummy parameter
Returns:
numvar*num

Definition at line 87 of file xdr_mesh.h.

References libMesh::XdrMGF::dataBlk().

Referenced by libMesh::LegacyXdrIO::read_mesh(), and libMesh::LegacyXdrIO::write_mesh().

{ return dataBlk(array, numvar, num);}
void libMesh::XdrMESH::init ( XdrIO_TYPE  type,
const char *  fn,
int  icnt,
int  dim = 3 
) [inline]

Calls the init method in the parent class, XdrMGF with the appropriate parameters.

Parameters:
typeOne of: UNKNOWN, ENCODE, DECODE
fnconst char pointer which points to the filename
icntNumber to be appended to file e.g. name.mesh.0000
dimProblem dimension (always three in MGF)

Definition at line 61 of file xdr_mesh.h.

References m_dim.

Referenced by libMesh::LegacyXdrIO::read_mesh(), and libMesh::LegacyXdrIO::write_mesh().

  { XdrMGF::init(type, fn, "mesh", icnt); m_dim = dim;}
void libMesh::XdrMGF::init ( XdrMGF::XdrIO_TYPE  t,
const char *  fn,
const char *  type,
int  icnt 
) [inherited]

Initialization of the xdr file. This function performs the following operations: {itemize} Closes the old xdr file if necessary.

Creates a new xdr file name and opens this file.

Opens the appropriate xdr file handle.

Reads/Writes a signature to the file.

{itemize}

Definition at line 68 of file xdr_mgf.C.

References libMesh::LegacyXdrIO::DEAL, libMesh::XdrMGF::DECODE, libMesh::XdrMGF::ENCODE, libMesh::XdrMGF::fini(), libMesh::XdrMGF::get_num_levels(), libMesh::XdrMGF::get_orig_flag(), libMesh::LegacyXdrIO::LIBM, libMesh::XdrMGF::m_type, libMesh::LegacyXdrIO::MGF, libMesh::XdrMGF::mp_fp, libMesh::XdrMGF::mp_in, libMesh::XdrMGF::mp_out, libMesh::XdrMGF::mp_xdr_handle, libMesh::Quality::name(), libMesh::XdrMGF::orig_flag, libMesh::out, libMesh::XdrMGF::R_ASCII, libMesh::XdrMGF::tokenize_first_line(), and libMesh::XdrMGF::W_ASCII.

{
  m_type=t;

  // Close old file if necessary
  if (mp_fp) this->fini();


  // Open file
  switch (m_type)
    {

#ifdef LIBMESH_HAVE_XDR

    case (XdrMGF::ENCODE):
    case (XdrMGF::DECODE):
      {
        mp_fp = fopen (fn, (m_type == ENCODE) ? "w" : "r");

        // Make sure the file is ready for use
        if (!mp_fp)
          libmesh_error_msg("XDR Error: Accessing file: " << fn << " failed.");

        // Create the XDR handle
        mp_xdr_handle = new XDR;
        xdrstdio_create(mp_xdr_handle,
                        mp_fp,
                        ((m_type == ENCODE) ? XDR_ENCODE : XDR_DECODE));

        break;
      }

#endif

    case (XdrMGF::R_ASCII):
      {
        mp_in.open(fn, std::ios::in);

        // Make sure it opened correctly
        if (!mp_in.good())
          libmesh_file_error(fn);

        break;
      }

    case (XdrMGF::W_ASCII):
      {
        mp_out.open(fn, std::ios::out);

        // Make sure it opened correctly
        if (!mp_out.good())
          libmesh_file_error(fn);

        break;
      }

    default:
      libmesh_error_msg("Unrecognized file access type!");
    }





  // Read/Write the file signature
  const int  bufLen = 12;
  char       buf[bufLen+1];

  switch (m_type)
    {

#ifdef LIBMESH_HAVE_XDR

    case (XdrMGF::ENCODE):
      {
        char* p = &buf[0];
        const LegacyXdrIO::FileFormat orig = this->get_orig_flag();

        std::ostringstream name;
        if (orig == LegacyXdrIO::DEAL)
          name << "DEAL 003:003";

        else if (orig == LegacyXdrIO::MGF)
          name << "MGF  002:000";

        else if (orig == LegacyXdrIO::LIBM)
          name << "LIBM " << this->get_num_levels();

        else
          libmesh_error_msg("Unknown orig " << orig);

        // Fill the buffer
        std::sprintf(&buf[0], "%s", name.str().c_str());

        xdr_string(mp_xdr_handle, &p, bufLen);  // Writes binary signature

        break;
      }

    case (XdrMGF::DECODE):
      {
        char* p = &buf[0];
        xdr_string(mp_xdr_handle, &p, bufLen); // Reads binary signature

        // Set the number of levels used in the mesh
        this->tokenize_first_line(p);

        break;
      }

#endif

    case (XdrMGF::W_ASCII):
      {
        const LegacyXdrIO::FileFormat orig = this->get_orig_flag();

        if (orig == LegacyXdrIO::DEAL)
          std::sprintf(&buf[0], "%s %03d:%03d", "DEAL", 3, 3);

        else if (orig == LegacyXdrIO::MGF)
          std::sprintf(&buf[0], "%s %03d:%03d", "MGF ", 2, 0);

        else if (orig == LegacyXdrIO::LIBM)
          std::sprintf(&buf[0], "%s %d", "LIBM", this->get_num_levels());

        mp_out << buf << '\n';

        break;
      }

    case (XdrMGF::R_ASCII):
      {

#ifdef __HP_aCC
        // weirdly, _only_ here aCC
        // is not fond of mp_in.getline()
        // however, using mp_in.getline()
        // further below is ok...
        std::string buf_buf;
        std::getline (mp_in, buf_buf, '\n');
        libmesh_assert_less_equal (buf_buf.size(), bufLen);

        buf_buf.copy (buf, std::string::npos);
#else

        // Here we first use getline() to grab the very
        // first line of the file into a char buffer.  Then
        // this line is tokenized to look for:
        // 1.) The name LIBM, which specifies the new Mesh style.
        // 2.) The number of levels in the Mesh which is being read.
        // Note that "buf" will be further processed below, here we
        // are just attempting to get the number of levels.
        mp_in.getline(buf, bufLen+1);

#endif

        // Determine the number of levels in this mesh
        this->tokenize_first_line(buf);

        break;
      }

    default:
      libmesh_error_msg("Unknown m_type" << m_type);
    }



  // If you are reading or decoding, process the signature
  if ((m_type == R_ASCII) || (m_type == DECODE))
    {
      char name[5];
      std::strncpy(name, &buf[0], 4);
      name[4] = '\0';

      if (std::strcmp (name, "DEAL") == 0)
        {
          this->orig_flag = LegacyXdrIO::DEAL; // 0 is the DEAL identifier by definition
        }
      else if (std::strcmp (name, "MGF ") == 0)
        {
          this->orig_flag = LegacyXdrIO::MGF; // 1 is the MGF identifier by definition
        }
      else if (std::strcmp (name, "LIBM") == 0)
        {
          this->orig_flag = LegacyXdrIO::LIBM; // the New and Improved XDA
        }

      else
        libmesh_error_msg("ERROR: No originating software can be determined for header string '" << name);
    }

}
void libMesh::XdrMGF::set_num_levels ( unsigned int  num_levels) [inline, inherited]

Set number of levels

Definition at line 185 of file xdr_mgf.h.

References libMesh::XdrMGF::_num_levels.

Referenced by libMesh::LegacyXdrIO::write_mesh().

{ _num_levels = num_levels; }
void libMesh::XdrMGF::set_orig_flag ( LegacyXdrIO::FileFormat  in_orig_flag) [inline, inherited]

Set the originator flag.

Definition at line 179 of file xdr_mgf.h.

References libMesh::XdrMGF::orig_flag.

Referenced by libMesh::LegacyXdrIO::read_mesh(), and libMesh::LegacyXdrIO::write_mesh().

{ orig_flag = in_orig_flag; }

Member Data Documentation

unsigned int libMesh::XdrMGF::_num_levels [protected, inherited]

Number of levels of refinement in the mesh

Definition at line 197 of file xdr_mgf.h.

Referenced by libMesh::XdrMGF::get_num_levels(), libMesh::XdrMGF::set_num_levels(), and libMesh::XdrMGF::tokenize_first_line().

int libMesh::XdrMESH::m_dim [private]

Dimension of the mesh

Definition at line 113 of file xdr_mesh.h.

Referenced by init().

XdrIO_TYPE libMesh::XdrMGF::m_type [protected, inherited]

Specifies the read/write permission for the current xdr file. Possibilities are: {itemize} UNKNOWN = -1 ENCODE = 0 DECODE = 1 {itemize}

Definition at line 210 of file xdr_mgf.h.

Referenced by libMesh::XdrMGF::dataBlk(), libMesh::XdrSOLN::header(), header(), and libMesh::XdrMGF::init().

std::ifstream libMesh::XdrMGF::mp_in [protected, inherited]

An input file stream object

Definition at line 244 of file xdr_mgf.h.

Referenced by libMesh::XdrMGF::dataBlk(), libMesh::XdrSOLN::header(), header(), and libMesh::XdrMGF::init().

std::ofstream libMesh::XdrMGF::mp_out [protected, inherited]

An output file stream object.

Definition at line 249 of file xdr_mgf.h.

Referenced by libMesh::XdrMGF::dataBlk(), libMesh::XdrSOLN::header(), header(), and libMesh::XdrMGF::init().

XDR* libMesh::XdrMGF::mp_xdr_handle [protected, inherited]

Pointer to the standard {xdr} struct. See the standard header file rpc/rpc.h for more information.

Definition at line 220 of file xdr_mgf.h.

Referenced by libMesh::XdrMGF::dataBlk(), libMesh::XdrMGF::fini(), libMesh::XdrSOLN::header(), header(), and libMesh::XdrMGF::init().

Flag indicating how much checking we need to do. We can read in mgf meshes more quickly because there is only one type of element in these meshes. Deal meshes on the other hand will require a check for each element to find out what type it is. Possible values are: {itemize} 0: It's an DEAL style mesh 1: It's a MGF style mesh {itemize}

Definition at line 239 of file xdr_mgf.h.

Referenced by libMesh::XdrMGF::get_orig_flag(), header(), libMesh::XdrMGF::init(), and libMesh::XdrMGF::set_orig_flag().


The documentation for this class was generated from the following files: