Poster of Linux kernelThe best gift for a Linux geek
MeshData

MeshData

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

NAME

MeshData -  

SYNOPSIS


#include <mesh_data.h>  

Public Types


typedef std::map< const Node *, std::vector< Number > >::const_iterator const_node_data_iterator

typedef std::map< const Elem *, std::vector< Number > >::const_iterator const_elem_data_iterator
 

Public Member Functions


MeshData (const MeshBase &m)

~MeshData ()

void activate (const std::string &descriptor='')

void enable_compatibility_mode (const std::string &descriptor='')

void clear ()

void slim (const bool node_id_map=true, const bool elem_id_map=true)

void translate (const MeshBase &out_mesh, std::vector< Number > &data_values, std::vector< std::string > &data_names) const

void read (const std::string &name)

void write (const std::string &name)

std::string get_info () const

void print_info (std::ostream &os=std::cout) const

Number operator() (const Node *node, const unsigned int i=0) const

bool has_data (const Node *node) const

const std::vector< Number > & get_data (const Node *node) const

void set_data (const Node *node, const std::vector< Number > &val)

unsigned int n_val_per_node () const

unsigned int n_node_data () const

const_node_data_iterator node_data_begin () const

const_node_data_iterator node_data_end () const

void insert_node_data (std::map< const Node *, std::vector< Number > > &nd, const bool close_elem_data=true)

Number operator() (const Elem *elem, const unsigned int i=0) const

bool has_data (const Elem *elem) const

const std::vector< Number > & get_data (const Elem *elem) const

void set_data (const Elem *elem, const std::vector< Number > &val)

unsigned int n_val_per_elem () const

unsigned int n_elem_data () const

const_elem_data_iterator elem_data_begin () const

const_elem_data_iterator elem_data_end () const

void insert_elem_data (std::map< const Elem *, std::vector< Number > > &ed, const bool close_node_data=true)

bool active () const

bool compatibility_mode () const

bool elem_initialized () const

bool node_initialized () const

const Node * foreign_id_to_node (const unsigned int fid) const

const Elem * foreign_id_to_elem (const unsigned int fid) const

unsigned int node_to_foreign_id (const Node *n) const

unsigned int elem_to_foreign_id (const Elem *n) const

const MeshDataUnvHeader & get_unv_header () const

void set_unv_header (MeshDataUnvHeader *unv_header)

void assign (const MeshData &omd)

void add_foreign_node_id (const Node *node, const unsigned int foreign_node_id)

void add_foreign_elem_id (const Elem *elem, const unsigned int foreign_elem_id)

void close_foreign_id_maps ()
 

Protected Member Functions


void read_tetgen (const std::string &name)

void read_unv (const std::string &file_name)

void read_unv_implementation (std::istream &in_file)

void write_unv (const std::string &file_name)

void write_unv_implementation (std::ostream &out_file)

void read_xdr (const std::string &name, const XdrMODE mode=READ)

void write_xdr (const std::string &name, const XdrMODE mode=WRITE)
 

Protected Attributes


const MeshBase & _mesh

std::string _data_descriptor

std::map< const Node *, std::vector< Number > > _node_data

std::map< const Node *, unsigned int > _node_id

std::map< unsigned int, const Node * > _id_node

std::map< const Elem *, std::vector< Number > > _elem_data

std::map< const Elem *, unsigned int > _elem_id

std::map< unsigned int, const Elem * > _id_elem

bool _node_id_map_closed

bool _node_data_closed

bool _elem_id_map_closed

bool _elem_data_closed

bool _active

bool _compatibility_mode

MeshDataUnvHeader * _unv_header
 

Friends


class MeshDataUnvHeader

std::ostream & operator<< (std::ostream &os, const MeshData &m)
 

Detailed Description

The MeshData class handles actual data and the corresponding I/O on entities (nodes, elements) of meshes. The MeshData can be used when dealing with files that contain nodal or element-oriented data, numbered in the same format as a corresponding mesh file (when activated) or with the libMesh element and node indices (when in compatibility mode). To use MeshData, it has to be either activated or the compatibility mode has to be enabled.

Author:

Daniel Dreyer, 2003

Definition at line 56 of file mesh_data.h.  

Member Typedef Documentation

 

typedef std::map<const Elem*, std::vector<Number> >::const_iterator MeshData::const_elem_data_iteratorA const iterator over the element-associated data entries of MeshData. Use this when a loop over all Node* in the MeshData is wanted. Note that only const versions are provided. Also these iterators should not be confused with the node_iterators provided for the Mesh classes!

Definition at line 81 of file mesh_data.h.  

typedef std::map<const Node*, std::vector<Number> >::const_iterator MeshData::const_node_data_iteratorA const iterator over the nodal data entries of MeshData. Use this when a loop over all Node* in the MeshData is wanted. Note that only const versions are provided. Also these iterators should not be confused with the node_iterators provided for the Mesh classes!

Definition at line 71 of file mesh_data.h.  

Constructor & Destructor Documentation

 

MeshData::MeshData (const MeshBase &m)Default Constructor. Takes const reference to the mesh it belongs to.

Definition at line 34 of file mesh_data.C.

                                    :
  _mesh               (m),
  _data_descriptor    (''),
  _node_id_map_closed (false),
  _node_data_closed   (false),
  _elem_id_map_closed (false),
  _elem_data_closed   (false),
  _active             (false),
  _compatibility_mode (false),
  _unv_header         (NULL)
{
}
 

MeshData::~MeshData ()Destructor.

Definition at line 50 of file mesh_data.C.

References clear().

{
  clear();
}
 

Member Function Documentation

 

void MeshData::activate (const std::string &descriptor = '')When MeshData should be used, it has to be activated first, prior to reading in a mesh with the Mesh::read() methods. This will ensure that element and node ids given in the mesh file, i.e. the foreign node and element ids, are stored in the corresponding id maps. Optionally takes a string that should help the user in identifying the data later on.

Definition at line 59 of file mesh_data.C.

References _active, _compatibility_mode, and _data_descriptor.

{
#ifdef DEBUG
  if (_compatibility_mode)
      std::cerr << 'WARNING: MeshData was in compatibility mode, now being activated.'
                << std::endl;
#endif

  _compatibility_mode = false;
  _active = true;
  _data_descriptor = descriptor;
}
 

bool MeshData::active () const [inline]Returns:

true when this object is active and working. Use activate() to bring this object alive.

Definition at line 1002 of file mesh_data.h.

References _active.

Referenced by UNVIO::element_out(), get_info(), UNVIO::node_out(), LegacyXdrIO::read_mesh(), slim(), and UNVIO::write_implementation().

{
  return _active;
}
 

void MeshData::add_foreign_elem_id (const Elem *elem, const unsigned intforeign_elem_id) [inline]In general, MeshData gathers element-associated data from file, but it needs to relate this data with the Elem* of the current mesh. Mesh importers simply use this method to add such a map.

Definition at line 1060 of file mesh_data.h.

References _active, _elem_id, _elem_id_map_closed, and _id_elem.

Referenced by assign(), UNVIO::element_in(), TetGenIO::element_in(), and LegacyXdrIO::read_mesh().

{
  if (_active)
    {
      libmesh_assert (!_elem_id_map_closed);
      libmesh_assert (elem                             != NULL);
      libmesh_assert (_elem_id.find(elem)              == _elem_id.end());
      libmesh_assert (_id_elem.find(foreign_elem_id)   == _id_elem.end());

      _elem_id.insert(std::make_pair(elem, foreign_elem_id));
      _id_elem.insert(std::make_pair(foreign_elem_id, elem));
    }
}
 

void MeshData::add_foreign_node_id (const Node *node, const unsigned intforeign_node_id) [inline]In general, MeshData gathers nodal data from a file, but it needs to relate this data with the Node* of the current mesh. Mesh importers simply use this method to add such a map.

Definition at line 1034 of file mesh_data.h.

References _active, _id_node, _node_id, and _node_id_map_closed.

Referenced by UNVIO::node_in(), TetGenIO::node_in(), VTKIO::read(), and LegacyXdrIO::read_mesh().

{
  if (_active)
    {
      libmesh_assert (!_node_id_map_closed);
      libmesh_assert (node                             != NULL);
      libmesh_assert (_node_id.find(node)              == _node_id.end());
      libmesh_assert (_id_node.find(foreign_node_id)   == _id_node.end());

      /*
       * _always_ insert in _id_node and _node_id.  If we would 
       * use the mesh.node(unsigned int) method or the node.id()
       * to get Node* and unsigned int, respectively, we would not
       * be safe any more when the mesh gets refined or re-numbered
       * within libMesh. And we could get in big trouble that would
       * be hard to find when importing data _after_ having refined...
       */
      _node_id.insert(std::make_pair(node, foreign_node_id));
      _id_node.insert(std::make_pair(foreign_node_id, node));
    }
}
 

void MeshData::assign (const MeshData &omd)Assign to this the data from the other MeshData. Used by BoundaryInfo when copying the MeshData from the d dimensional mesh to the d-1 dimensional mesh (the boundary mesh).

Definition at line 717 of file mesh_data.C.

References _active, _compatibility_mode, _data_descriptor, _elem_data, _elem_data_closed, _elem_id, _elem_id_map_closed, _id_node, _mesh, _node_data, _node_data_closed, _node_id, _node_id_map_closed, _unv_header, add_foreign_elem_id(), MeshBase::elements_begin(), MeshBase::elements_end(), and DofObject::id().

Referenced by BoundaryInfo::sync().

{
  this->_data_descriptor    = omd._data_descriptor;
  this->_node_id_map_closed = omd._node_id_map_closed;
  this->_node_data_closed   = omd._node_data_closed;

  // we have to be able to modify our elem id maps
  libmesh_assert (!this->_elem_id_map_closed);

  this->_elem_data_closed   = omd._elem_data_closed;
  this->_active             = omd._active;
  this->_compatibility_mode = omd._compatibility_mode;

  // this is ok because we do not manage the UnvHeader
  // in terms of memory, but only hold a pointer to it...
  this->_unv_header         = omd._unv_header;

  // Now copy the foreign id maps -- but only for the 
  // nodes.  The nodes of the boundary mesh are actually
  // nodes of the volume mesh.
  this->_node_id = omd._node_id;
  this->_id_node = omd._id_node;

  // The element vector of the boundary mesh contains elements
  // that are new, and there _cannot_ be any associated
  // foreign id in the maps.  Therefore, fill the maps with
  // the libMesh id's.  But only when the other MeshData
  // has element ids.
  if ((this->_active) && (omd._elem_id.size() != 0))
    {

      MeshBase::const_element_iterator       elem_it  = _mesh.elements_begin();
      const MeshBase::const_element_iterator elem_end = _mesh.elements_end();

      for (; elem_it != elem_end; ++elem_it)
        {
          const Elem* elem = *elem_it;  
          this->add_foreign_elem_id(elem, elem->id());
        }
    }

  // now we can safely assign omd's value
  this->_elem_id_map_closed   = omd._elem_id_map_closed;
  

  // and finally the node- and element-associated data
  this->_node_data = omd._node_data;
  this->_elem_data = omd._elem_data;
}
 

void MeshData::clear ()Clears the data fields, but leaves the id maps untouched. Useful for clearing data for a new data file. Use slim() to delete the maps.

Definition at line 104 of file mesh_data.C.

References _data_descriptor, _elem_data, _elem_data_closed, _node_data, and _node_data_closed.

Referenced by read_unv(), read_xdr(), and ~MeshData().

{
  _data_descriptor    = '';
  _node_data.clear();
  _elem_data.clear();
  _node_data_closed   = false;
  _elem_data_closed   = false;
}
 

void MeshData::close_foreign_id_maps ()Signal to this object that the mesh importer finished adding node and element foreign-id maps.

Definition at line 214 of file mesh_data.C.

References _active, _elem_id, _elem_id_map_closed, _id_elem, _id_node, _node_id, and _node_id_map_closed.

Referenced by UNVIO::read_implementation(), LegacyXdrIO::read_mesh(), and TetGenIO::read_nodes_and_elem().

{
  if (_active)
    {
      libmesh_assert (!_elem_id.empty());
      libmesh_assert (!_id_elem.empty());
      libmesh_assert (!_node_id.empty());
      libmesh_assert (!_id_node.empty());

      _elem_id_map_closed = true;
      _node_id_map_closed = true;
    }
}
 

bool MeshData::compatibility_mode () const [inline]Returns:

true when this object is in compatibility mode. See enable_compatibility_mode() for details.

Definition at line 1010 of file mesh_data.h.

References _compatibility_mode.

Referenced by UNVIO::element_out(), get_info(), UNVIO::node_out(), read(), slim(), write(), and UNVIO::write_implementation().

{
  return _compatibility_mode;
}
 

MeshData::const_elem_data_iterator MeshData::elem_data_begin () const [inline]Returns a MeshData::const_elem_data_iterators which points to the beginning of the Elem* data containers used here.

Definition at line 984 of file mesh_data.h.

References _elem_data.

{
  return _elem_data.begin();
}
 

MeshData::const_elem_data_iterator MeshData::elem_data_end () const [inline]Returns a MeshData::const_elem_data_iterators which points to the end of the Elem* data containers used here.

Definition at line 992 of file mesh_data.h.

References _elem_data.

{
  return _elem_data.end();
}
 

bool MeshData::elem_initialized () const [inline]Returns:

true when this object is properly initialized and ready for use for element associated data, false otherwise.

Definition at line 1018 of file mesh_data.h.

References _active, and _elem_data_closed.

Referenced by get_info().

{
  return (_active && _elem_data_closed);
}
 

unsigned int MeshData::elem_to_foreign_id (const Elem *n) constReturns:

the foreign id this Elem* maps to.

Definition at line 494 of file mesh_data.C.

References _active, _compatibility_mode, _elem_id, _elem_id_map_closed, and DofObject::id().

Referenced by UNVIO::element_out(), and write_xdr().

{
  libmesh_assert (e != NULL);

  if (_active)
    {
      // when active, use our _id_elem map
      libmesh_assert (_elem_id_map_closed);

             // look it up in the map
             std::map<const Elem*,
               unsigned int>::const_iterator pos = _elem_id.find(e);

      if (pos == _elem_id.end())
        {
          std::cerr << 'ERROR: No foreign id stored for the element '
                    << 'with the libMesh id = '
                    << e->id()
                    << std::endl;
          libmesh_error();
          return 0;
        }
      else
          return pos->second;
    }
  else if (_compatibility_mode)
    // when only in compatibility mode, 
    // return libMesh's element id
    return e->id();

  // should never get here
  libmesh_error();
  return 0;
}
 

void MeshData::enable_compatibility_mode (const std::string &descriptor = '')When the MeshData should be used, but was not activated prior to reading in a mesh, then the compatibility mode enables to still use this object as if the MeshData was active. The foreign node and element ids are simply assigned the indices used in libMesh. Note that the compatibility mode should be used with caution, since the node and element indices in libMesh may be renumbered any time. This MeshData always employs the current node and element ids, it does not create an image of ids when compatibility mode was activated.

Definition at line 76 of file mesh_data.C.

References _active, _compatibility_mode, _data_descriptor, _elem_id, _elem_id_map_closed, _id_elem, _id_node, _node_id, and _node_id_map_closed.

Referenced by UNVIO::write_implementation().

{
  if (!_active)
    {
      _compatibility_mode = true;
      _active = false;
      // do as if the id maps are already closed
      _node_id_map_closed = true;
      _elem_id_map_closed = true;
      _data_descriptor = descriptor;
      // we can safely clear the id maps
      _node_id.clear();
      _id_node.clear();
      _elem_id.clear();
      _id_elem.clear();
    }
#ifdef DEBUG
  else
      std::cerr << 'WARNING: MeshData was in compatibility mode, now being activated.'
                << std::endl;
#endif
}
 

const Elem * MeshData::foreign_id_to_elem (const unsigned intfid) constReturns:

the Elem* that this foreign id maps to.

Definition at line 459 of file mesh_data.C.

References _active, _compatibility_mode, _elem_id_map_closed, _id_elem, _mesh, and MeshBase::elem().

Referenced by read_tetgen(), and read_xdr().

{
  if (_active)
    {
      // when active, use our _id_elem map
      libmesh_assert (_elem_id_map_closed);
      
      std::map<unsigned int,
               const Elem*>::const_iterator pos = _id_elem.find(fid);
      
      if (pos == _id_elem.end())
        {
          std::cerr << 'ERROR: Have no Elem* associated with the foreign id = '
                    << fid
                    << std::endl;
          libmesh_error();
          return NULL;
        }
      else
          return pos->second;
    }
  else if (_compatibility_mode)
    // when only in compatibility mode, 
    // return element using the libMesh id
    return this->_mesh.elem(fid);

  // should never get here
  libmesh_error();
  return NULL;
}
 

const Node * MeshData::foreign_id_to_node (const unsigned intfid) constReturns:

the Node* that this foreign id maps to.

Definition at line 381 of file mesh_data.C.

References _active, _compatibility_mode, _id_node, _mesh, _node_id_map_closed, and MeshBase::node_ptr().

Referenced by read_tetgen(), read_unv_implementation(), and read_xdr().

{
  if (_active)
    {
      // when active, use our _id_node map
      libmesh_assert (_node_id_map_closed);

      std::map<unsigned int,
               const Node*>::const_iterator pos = _id_node.find(fid);

      if (pos == _id_node.end())
        {
          std::cerr << 'ERROR: Have no Node* associated with the foreign id = '
                    << fid
                    << std::endl;
          libmesh_error();
          return NULL;
        }
      else
          return pos->second;
    }
  else if (_compatibility_mode)
      // when only in compatibility mode, 
      // return the node stored in the MeshBase 
      // under its current id
      return this->_mesh.node_ptr(fid);

  // should never get here
  libmesh_error();
  return NULL;
}
 

const std::vector< Number > & MeshData::get_data (const Elem *elem) const [inline]Returns:

a const reference to the values associated with the element elem. Beware: this method will crash when there is no data associated with the element elem! Check existence through has_data() first.

Definition at line 953 of file mesh_data.h.

References _active, _compatibility_mode, _elem_data, and _elem_data_closed.

{
  libmesh_assert (_active || _compatibility_mode);
  libmesh_assert (_elem_data_closed);

  std::map<const Elem*, 
           std::vector<Number> >::const_iterator pos = _elem_data.find(elem);

#ifdef DEBUG
  if (pos == _elem_data.end())
    {
      std::cerr << 'ERROR: No data for this element.  Use has_data() first!' << std::endl;
      libmesh_error();
    }
#endif

  return pos->second;
}
 

const std::vector< Number > & MeshData::get_data (const Node *node) const [inline]Returns:

a const reference to the values associated with the node node. Beware: this method will crash when there is no data associated with the node node! Check existence through has_data() first.

Definition at line 870 of file mesh_data.h.

References _active, _compatibility_mode, _node_data, and _node_data_closed.

Referenced by write_unv_implementation(), and write_xdr().

{
  libmesh_assert (_active || _compatibility_mode);
  libmesh_assert (_node_data_closed);

  std::map<const Node*, 
           std::vector<Number> >::const_iterator pos = _node_data.find(node);

#ifdef DEBUG
  if (pos == _node_data.end())
    {
      std::cerr << 'ERROR: No data for this node.  Use has_data() first!' << std::endl;
      libmesh_error();
    }
#endif

  return pos->second;
}
 

std::string MeshData::get_info () constReturns:

a string containing relevant information about the mesh.

Definition at line 334 of file mesh_data.C.

References _data_descriptor, active(), compatibility_mode(), elem_initialized(), n_elem_data(), n_node_data(), n_val_per_elem(), n_val_per_node(), and node_initialized().

Referenced by print_info().

{
  std::ostringstream out;

  if (this->active() || this->compatibility_mode())
    {
      out << ' MeshData Information:;
      if (this->active())
          out << '  object activated.;
      if (this->compatibility_mode())
          out << '  object in compatibility mode.;
      if (this->_data_descriptor != '')
          out << '  descriptor=' << this->_data_descriptor << ';
      if (this->elem_initialized())
          out << '  Element associated data initialized.
              << '   n_val_per_elem()=' << this->n_val_per_elem() << '
              << '   n_elem_data()=' << this->n_elem_data() << ';
      if (this->node_initialized())
          out << '  Node associated data initialized.
              << '   n_val_per_node()=' << this->n_val_per_node() << '
              << '   n_node_data()=' << this->n_node_data() << ';
    }
  else
      out << ' MeshData neither active nor in compatibility mode.;

  return out.str();
}
 

const MeshDataUnvHeader & MeshData::get_unv_header () const [inline]Read access to the MeshDataUnvHeader data structure.

Definition at line 1077 of file mesh_data.h.

References _unv_header.

{
  libmesh_assert (this->_unv_header != NULL);
  return *this->_unv_header;
}
 

bool MeshData::has_data (const Node *node) const [inline]Returns:

true when the node node has data, false otherwise.

Definition at line 856 of file mesh_data.h.

References _active, _compatibility_mode, _node_data, and _node_data_closed.

Referenced by write_unv_implementation(), and write_xdr().

{
  libmesh_assert (_active || _compatibility_mode);
  libmesh_assert (_node_data_closed);

  std::map<const Node*, 
           std::vector<Number> >::const_iterator pos = _node_data.find(node);

  return (pos != _node_data.end());
}
 

bool MeshData::has_data (const Elem *elem) const [inline]Returns:

true when the element elem has data, false otherwise.

Definition at line 939 of file mesh_data.h.

References _active, _compatibility_mode, _elem_data, and _elem_data_closed.

{
  libmesh_assert (_active || _compatibility_mode);
  libmesh_assert (_elem_data_closed);

  std::map<const Elem*, 
           std::vector<Number> >::const_iterator pos = _elem_data.find(elem);

  return (pos != _elem_data.end());
}
 

void MeshData::insert_elem_data (std::map< const Elem *, std::vector< Number > > &ed, const boolclose_node_data = true)For the desperate user, element-associated boundary conditions may be inserted directly through the map ed. Similar to the version for nodal data, it is imperative that the local _elem_data is empty, that the id maps are closed, that the size of the std::vector's of each map have identical length and that the Elem* point to elements of the associated mesh. Note that this method takes a non-const reference and essentially clears the passed-in data. If close_node_data is true (default), then this MeshData is ready for use: write to file, use the operator() methods etc. If false, the user has to add nodal data, too.

Definition at line 599 of file mesh_data.C.

References _active, _compatibility_mode, _elem_data, _elem_data_closed, _elem_id_map_closed, _node_data_closed, and _node_id_map_closed.

{
  libmesh_assert (this->_active || this->_compatibility_mode);
  // these are also true in compatibility mode
  libmesh_assert (this->_elem_id_map_closed);

  if (this->_elem_data_closed)
    {
      std::cerr << 'ERROR: Element data already closed!  Use clear() first!'
                << std::endl;
      libmesh_error();
    }

  libmesh_assert (this->_elem_data.empty());

#ifdef DEBUG
  std::map<const Elem*, 
           std::vector<Number> >::const_iterator ed_pos = ed.begin();
  std::map<const Elem*, 
           std::vector<Number> >::const_iterator ed_end = ed.end();

  // Compare entity-by-entity that the
  // sizes of the std::vector's are identical.
  const unsigned int reference_length = (*ed_pos).second.size();
  ++ed_pos;

  for (; ed_pos != ed_end; ++ed_pos)
    if ( (*ed_pos).second.size() != reference_length) 
      {
        std::cerr << 'ERROR: Size mismatch.'
                  << std::endl;
        libmesh_error();
      }
#endif

  // copy over
  _elem_data = ed;

  // we may freely trash the ed
  ed.clear();

  // close elem data
  this->_elem_data_closed = true;

  // if user wants to, then close node data, too
  if (close_node_data)
    {
      libmesh_assert((this->_node_id_map_closed));
      this->_node_data_closed = true;
    }
}
 

void MeshData::insert_node_data (std::map< const Node *, std::vector< Number > > &nd, const boolclose_elem_data = true)For the desperate user, nodal boundary conditions may be inserted directly through the map nd. It is mandatory that there does not yet exist any other node data in this object, that the id maps are closed, that the size of the std::vector's of each map have identical length and that the Node* point to nodes of the associated mesh. Note that this method takes a non-const reference and essentially clears the passed-in data. If close_elem_data is true (default), then this MeshData is ready for use: write to file, use the operator() methods etc. If false, the user has to add element-associated data, too.

Definition at line 535 of file mesh_data.C.

References _active, _compatibility_mode, _elem_data_closed, _elem_id_map_closed, _node_data, _node_data_closed, and _node_id_map_closed.

{
  libmesh_assert (this->_active || this->_compatibility_mode);
  // these are also true in compatibility mode
  libmesh_assert (this->_node_id_map_closed);

  if (this->_node_data_closed)
    {
      std::cerr << 'ERROR: Nodal data already closed!  Use clear() first!'
                << std::endl;
      libmesh_error();
    }

  libmesh_assert (this->_node_data.empty());

#ifdef DEBUG
  std::map<const Node*, 
           std::vector<Number> >::const_iterator nd_pos = nd.begin();
  std::map<const Node*, 
           std::vector<Number> >::const_iterator nd_end = nd.end();

  // Compare entity-by-entity that the
  // sizes of the std::vector's are identical.
  // For this, simply take the length of the 0th
  // entry as reference length, and compare this
  // with the length of the 1st, 2nd...
  libmesh_assert (nd_pos != nd_end);
  const unsigned int reference_length = (*nd_pos).second.size();

  // advance, so that we compare with the 1st
  ++nd_pos;

  for (; nd_pos != nd_end; ++nd_pos)
    if ( (*nd_pos).second.size() != reference_length) 
      {
        std::cerr << 'ERROR: Size mismatch.'
                  << std::endl;
        libmesh_error();
      }
#endif

  // copy over
  _node_data = nd;

  // we may freely trash the nd
  nd.clear();

  // close node data
  this->_node_data_closed = true;

  // if user wants to, then close elem data, too
  if (close_elem_data)
    {
      libmesh_assert((this->_elem_id_map_closed));
      this->_elem_data_closed = true;
    }
}
 

unsigned int MeshData::n_elem_data () constReturns:

the number of elements for which this MeshData has data stored.

Definition at line 706 of file mesh_data.C.

References _active, _compatibility_mode, _elem_data, and _elem_data_closed.

Referenced by get_info().

{
  libmesh_assert (this->_active || this->_compatibility_mode);
  libmesh_assert (this->_elem_data_closed);

  return _elem_data.size();
}
 

unsigned int MeshData::n_node_data () constReturns:

the number of nodes for which this MeshData has data stored.

Definition at line 676 of file mesh_data.C.

References _active, _compatibility_mode, _node_data, and _node_data_closed.

Referenced by get_info().

{
  libmesh_assert (this->_active || this->_compatibility_mode);
  libmesh_assert (this->_node_data_closed);

  return this->_node_data.size();
}
 

unsigned int MeshData::n_val_per_elem () constReturns:

the number of Number -type data (i.e., the size of the std::vector<Number> returned through the operator() methods) associated with an element. Returns 0 when there is no element-associated data.

Definition at line 687 of file mesh_data.C.

References _active, _compatibility_mode, _elem_data, and _elem_data_closed.

Referenced by get_info().

{
  libmesh_assert (this->_active || this->_compatibility_mode);
  libmesh_assert (this->_elem_data_closed);

  if (!_elem_data.empty())
    {
      std::map<const Elem*, 
               std::vector<Number> >::const_iterator pos = _elem_data.begin();
      libmesh_assert (pos != _elem_data.end());
      return (pos->second.size());
    }
  else
      return 0;
}
 

unsigned int MeshData::n_val_per_node () constReturns:

the number of Number -type data (i.e., the size of the std::vector<Number> returned through the operator() methods) associated with a node. Returns 0 when no nodal data exists.

Definition at line 657 of file mesh_data.C.

References _active, _compatibility_mode, _node_data, and _node_data_closed.

Referenced by get_info(), translate(), and write_unv_implementation().

{
  libmesh_assert (this->_active || this->_compatibility_mode);
  libmesh_assert (this->_node_data_closed);

  if (!this->_node_data.empty())
    {
      std::map<const Node*, 
               std::vector<Number> >::const_iterator pos = _node_data.begin();
      libmesh_assert (pos != _node_data.end());
      return (pos->second.size());
    }
  else
      return 0;
}
 

MeshData::const_node_data_iterator MeshData::node_data_begin () const [inline]Returns the MeshData::const_node_data_iterator which points to the beginning of the Node* data containers used here.

Definition at line 901 of file mesh_data.h.

References _node_data.

{
  return _node_data.begin();
}
 

MeshData::const_node_data_iterator MeshData::node_data_end () const [inline]Returns the MeshData::const_node_data_iterator which points to the end of the Node* data containers used here.

Definition at line 909 of file mesh_data.h.

References _node_data.

{
  return _node_data.end();
}
 

bool MeshData::node_initialized () const [inline]Returns:

true when this object is properly initialized and ready for use for nodal data, false otherwise.

Definition at line 1026 of file mesh_data.h.

References _active, and _node_data_closed.

Referenced by get_info().

{
  return (_active && _node_data_closed);
}
 

unsigned int MeshData::node_to_foreign_id (const Node *n) constReturns:

the foreign id this Node* maps to.

Definition at line 417 of file mesh_data.C.

References _active, _compatibility_mode, _node_id, _node_id_map_closed, and DofObject::id().

Referenced by UNVIO::element_out(), UNVIO::node_out(), write_unv_implementation(), and write_xdr().

{
  libmesh_assert (n != NULL);

  if (_active)
    {
      // when active, use our _node_id map
      libmesh_assert (_node_id_map_closed);

      // look it up in the map
      std::map<const Node*,
               unsigned int>::const_iterator pos = _node_id.find(n);
      
      if (pos == _node_id.end())
        {
          std::cerr << 'ERROR: No foreign id stored for the node '
                    << 'with the libMesh id = '
                    << n->id()
                    << std::endl;
          libmesh_error();
          return 0;
        }
      else
          return pos->second;
    }
  else if (_compatibility_mode)
    // when only in compatibility mode, 
    // return libMesh's node id
    return n->id();

  // should never get here
  libmesh_error();
  return 0;
}
 

Number MeshData::operator() (const Elem *elem, const unsigned inti = 0) const [inline]Returns:

the $ i^{th} $ value (defaults to 0) associated with element elem. Returns libMesh::zero when there is no data for elem in the map.

Definition at line 919 of file mesh_data.h.

References _active, _compatibility_mode, _elem_data, _elem_data_closed, and libMesh::zero.

{
  libmesh_assert (_active || _compatibility_mode);
  libmesh_assert (_elem_data_closed);

  std::map<const Elem*, 
           std::vector<Number> >::const_iterator pos = _elem_data.find(elem);

  if (pos == _elem_data.end())
    return libMesh::zero;
  
  // we only get here when pos != _elem_data.end()  
  libmesh_assert (i < pos->second.size());
  return pos->second[i];
}
 

Number MeshData::operator() (const Node *node, const unsigned inti = 0) const [inline]Returns:

the $ i^{th} $ value (defaults to 0) associated with node node. Returns libMesh::zero when there is no such node in the map.

Definition at line 836 of file mesh_data.h.

References _active, _compatibility_mode, _node_data, _node_data_closed, and libMesh::zero.

{
  libmesh_assert (_active || _compatibility_mode);
  libmesh_assert (_node_data_closed);

  std::map<const Node*, 
           std::vector<Number> >::const_iterator pos = _node_data.find(node);

  if (pos == _node_data.end())
      return libMesh::zero;

  // we only get here when pos != _node_data.end()
  libmesh_assert (i < pos->second.size());
  return pos->second[i];
}
 

void MeshData::print_info (std::ostream &os = std::cout) constPrints relevant information about the mesh.

Definition at line 365 of file mesh_data.C.

References get_info().

Referenced by operator<<().

{
  os << this->get_info()
     << std::endl;
}
 

void MeshData::read (const std::string &name)Read mesh data from file named name. Guess format from the file extension. Note that prior to this you have to at least either close_node_map() or close_elem_map().

Definition at line 232 of file mesh_data.C.

References _active, _compatibility_mode, _elem_id_map_closed, _node_id_map_closed, compatibility_mode(), libMeshEnums::DECODE, libMeshEnums::READ, read_tetgen(), read_unv(), and read_xdr().

{
  START_LOG('read()', 'MeshData');

  libmesh_assert (_active || _compatibility_mode);

  // the id maps have to be closed before reading
  // (note that in compatibility mode these are also true)
  libmesh_assert (_elem_id_map_closed && _node_id_map_closed);

#ifdef DEBUG
  if (this->compatibility_mode())
      std::cerr << 'WARNING: MeshData in compatibility mode, node and element ids' << std::endl
                << '         stored in file may be totally different from libMesh ids!' << std::endl;
#endif

  // Read the file based on extension.  We let all processors read the
  // data because it would be inaccurate to let only one processor
  // have it and we're too lazy to code up a proper parallel read or
  // read+broadcast right now.

  //if (libMesh::processor_id() == 0)
  //  {
      if (name.rfind('.xta') < name.size())
        this->read_xdr (name, READ);
      
      else if (name.rfind('.xtr')  < name.size())
        this->read_xdr (name, DECODE);
      
      else if (name.rfind('.unv') < name.size())
        this->read_unv (name);
      
      else if ((name.rfind('.node') < name.size()) ||
               (name.rfind('.ele') < name.size()))
        this->read_tetgen (name);
      
      else
        {
          std::cerr << ' ERROR: Unrecognized file extension: ' << name
                    << '  I understand the following:n'
                    << '     *.xta  -- Internal ASCII data format
                    << '     *.xtr  -- Internal binary data format
                    << '     *.unv  -- I-deas format
                    << std::endl;
          libmesh_error();
          
        }    
    //}
  STOP_LOG('read()', 'MeshData');
}
 

void MeshData::read_tetgen (const std::string &name) [protected]Read nodal/element oriented data in TetGen format.

Definition at line 33 of file mesh_data_tetgen_support.C.

References _data_descriptor, _elem_data, _elem_data_closed, _node_data, _node_data_closed, foreign_id_to_elem(), foreign_id_to_node(), MeshTools::n_elem(), MeshTools::n_nodes(), and Quality::name().

Referenced by read().

{
  std::string name_node, name_ele, dummy;
  std::string desc = name;
  
  
  // Check name for *.node or *.ele extension.
  // Set std::istream for node_stream and ele_stream.
  if (name.rfind('.node') < name.size()) 
    {
      name_node = name;
      dummy     = name;
      int position = dummy.rfind('.node');
      name_ele     = dummy.replace(position, 5, '.ele');
      desc.erase(position);
    }
  else if (name.rfind('.ele') < name.size()) 
    {
      name_ele = name;
      dummy    = name;
      int position = dummy.rfind('.ele');
      name_node    = dummy.replace(position, 4, '.node');
      desc.erase(position);
    }
  else
    {
      std::cerr << 'ERROR: Unrecognized file name: '
                << name << std::endl;
      libmesh_error();
    }
  
  // Set the streams from which to read in.
  std::ifstream node_stream (name_node.c_str());
  std::ifstream ele_stream  (name_ele.c_str());

  if ( !node_stream.good() || !ele_stream.good() )
    {
      std::cerr << 'ERROR: One or both Input file(s) not good.' << std::endl
                << 'Error checking files '
                << name_node << ' and '
                << name_ele  << std::endl;
      libmesh_error();
    }

  
  // Set the descriptive name.
  // TetGen won't give a name, so we use the filename.
  this->_data_descriptor = desc;

  
  //--------------------------------------------------
  // Read in the data associated with the nodes.
  {
    unsigned int n_node=0, f_n_id=0, nAttri=0, BoundMark=0;
    Real dummy=0.0;
    std::vector<Number> AttriValue;

    // Read the parameters from the node_stream.
    node_stream >> n_node     // Read the number of nodes
                >> dummy      // Read the dimension
                >> nAttri     // Read the number of attributes
                >> BoundMark; // (0 or 1) boundary markers are in the stream or not.

    // Resize the values vector.
    AttriValue.resize(nAttri);

    for (unsigned int i=0; i<n_node; i++)
      {
        node_stream >> f_n_id;

        
        // Read the nodal coordinates for this node into dummy,
        // since we don't need them.
        for (unsigned int j=0; j<3; j++)
          node_stream >> dummy;

        // Read the attributes from the stream.
        for (unsigned int j=0; j<nAttri; j++)
          node_stream >> AttriValue[j];

        // Read boundary marker if BoundaryMarker=1.
        if (BoundMark == 1)
          node_stream >> dummy;

        // For the foreign node id locate the Node*.
        const Node* node = foreign_id_to_node(f_n_id);
                                
        // Insert this node and the values in our _node_data.
        _node_data.insert (std::make_pair(node, AttriValue));
      }
  }

  
  //--------------------------------------------------
  // Read in the data associated with the elements.
  {
    unsigned int n_elem, f_e_id, n_nodes, nAttri=0;
    Real dummy=0.0;
    std::vector<Number> AttriValue;

    // Read the parameters from the ele_stream.
    ele_stream >> n_elem   // Read the number of tetrahedrons
               >> n_nodes  // Read the points per tetrahedron
               >> nAttri;  // Read the number of attributes

    // Resize the values vector.
    AttriValue.resize(nAttri);

    for (unsigned int i=0; i<n_elem; i++)
      {
        ele_stream >> f_e_id;


        // For the number of nodes for this element read them into dummy,
        // since we don't need them.
        for (unsigned int n=0; n<n_nodes; n++)
          {
            ele_stream >> dummy;
          }

        // Read the attributes from the stream.
        for (unsigned int j=0; j<nAttri; j++)
          {
            ele_stream >> AttriValue[j];
          }

        // For the foreign elem id locate the Elem*.
        const Elem* elem = foreign_id_to_elem(f_e_id);
                                
        // Insert this elem and the values in our _elem_data.
        _elem_data.insert (std::make_pair(elem, AttriValue));
      }
  }
  
  //--------------------------------------------------
  // Finished reading.  Now ready for use.
  this->_node_data_closed = true;
  this->_elem_data_closed = true;

  node_stream.close();
  ele_stream.close();
}
 

void MeshData::read_unv (const std::string &file_name) [protected]Read nodal/element oriented data in UNV format, either from an ASCII file or from a gzip'ed ASCII file, using the C++ wrapper gzstream to zlib.h.

Definition at line 38 of file mesh_data_unv_support.C.

References _active, _compatibility_mode, _elem_id_map_closed, _node_id_map_closed, clear(), and read_unv_implementation().

Referenced by read().

{
  /*
   * we should better be active or in compatibility mode
   */
  libmesh_assert (this->_active || this->_compatibility_mode);

  /*
   * When reading data, make sure the id maps are ok
   */
  libmesh_assert (this->_node_id_map_closed);
  libmesh_assert (this->_elem_id_map_closed);

  /*
   * clear the data, but keep the id maps
   */
  this->clear();

  /*
   * We can read either '.unv', or '.unv.gz'
   * files, provided zlib.h is there
   */
  if (file_name.rfind('.gz') < file_name.size())
    {
#ifdef LIBMESH_HAVE_GZSTREAM
      igzstream in_stream(file_name.c_str());
      this->read_unv_implementation (in_stream);
#else
      std::cerr << 'ERROR:  You must have the zlib.h header '
                << 'files and libraries to read and write '
                << 'compressed streams.'
                << std::endl;
      libmesh_error();
#endif
      return;
    }
  
  else
    {
      std::ifstream in_stream(file_name.c_str());
      this->read_unv_implementation (in_stream);
      return;
    }
}
 

void MeshData::read_unv_implementation (std::istream &in_file) [protected]Actual implementation of reading nodal/element oriented data in UNV format. This has to be decoupled from read_unv() in order to allow reading both .unv and .unv.gz files.

Definition at line 88 of file mesh_data_unv_support.C.

References _elem_data, _elem_data_closed, _node_data, _node_data_closed, _unv_header, MeshDataUnvHeader::data_type, MeshDataUnvHeader::dataset_location, foreign_id_to_node(), MeshDataUnvHeader::need_D_to_e(), MeshDataUnvHeader::nvaldc, and MeshDataUnvHeader::read().

Referenced by read_unv().

{
  /*
   * This is the actual implementation of
   * reading in UNV format.  This enables
   * to read either through the conventional
   * C++ stream, or through a stream that
   * allows to read .gz'ed files.
   */
  if ( !in_file.good() )
    {
      std::cerr << 'ERROR: Input file not good.' 
                << std::endl;
      libmesh_error();
    }

  const std::string _label_dataset_mesh_data = '2414';

  /*
   * locate the beginning of data set
   * and read it.
   */
  {
    std::string olds, news;

    while (true)
    {
      in_file >> olds >> news;

      /*
       * Yes, really dirty:
       *
       * When we found a dataset, and the user does
       * not want this dataset, we jump back here
       */
    go_and_find_the_next_dataset:

      /*
       * a '-1' followed by a number means the beginning of a dataset
       * stop combing at the end of the file
       */
      while( ((olds != '-1') || (news == '-1') ) && !in_file.eof() )
        {
          olds = news;
          in_file >> news;
        }

      if(in_file.eof())
        break;

      /*
       * if beginning of dataset
       */
      if (news == _label_dataset_mesh_data)
        {

          /*
           * Now read the data of interest.
           * Start with the header.  For 
           * explanation of the variable
           * dataset_location, see below.
           */
          unsigned int dataset_location;
              
          /*
           * the type of data (complex, real,
           * float, double etc, see below)
           */
          unsigned int data_type;

          /*
           * the number of floating-point values per entity
           */
          unsigned int NVALDC;


          /*
           * If there is no MeshDataUnvHeader object
           * attached
           */
          if (_unv_header==NULL)
            {
              /*
               * Ignore the first lines that stand for
               * analysis dataset label and name.
               */ 
              for(unsigned int i=0; i<3; i++)
                in_file.ignore(256,');             
              
              /*
               * Read the dataset location, where
               * 1: Data at nodes
               * 2: Data on elements
               * other sets are currently not supported.
               */
              in_file >> dataset_location;

              /*
               * Ignore five ID lines.
               */ 
              for(unsigned int i=0; i<6; i++)
                in_file.ignore(256,');
              
              /*
               * These data are all of no interest to us...
               */
              unsigned int model_type,          
                  analysis_type,
                  data_characteristic,
                  result_type;

              /*
               * Read record 9.
               */
              in_file >> model_type           // not used here
                      >> analysis_type        // not used here
                      >> data_characteristic  // not used here
                      >> result_type          // not used here
                      >> data_type
                      >> NVALDC;
              
              
              /*
               * Ignore record 10 and 11
               * (Integer analysis type specific data).
               */ 
              for (unsigned int i=0; i<3; i++)
                in_file.ignore(256,');
              
              /*
               * Ignore record 12 and record 13.  Since there
               * exist UNV files with 'D' instead of 'e' as 
               * 10th-power char, it is safer to use a string
               * to read the dummy reals.
               */
              {
                std::string dummy_Real;
                for (unsigned int i=0; i<12; i++)
                    in_file >> dummy_Real;
              }

            }
          else
            {

              /*
               * the read() method returns false when
               * the user wanted a special header, and
               * when the current header is _not_ the correct
               * header
               */
              if (_unv_header->read(in_file))
                {
                  dataset_location = _unv_header->dataset_location;
                  NVALDC = _unv_header->nvaldc;
                  data_type = _unv_header->data_type;
                }
              else
                {
                  /*
                   * This is not the correct header.  Go
                   * and find the next.  For this to
                   * work correctly, shift to the 
                   * next line, so that the '-1'
                   * disappears from olds 
                   */
                  olds = news;
                  in_file >> news;

                  /*
                   * No good style, i know...
                   */
                  goto go_and_find_the_next_dataset;
                }

            }

          /*
           * Check the location of the dataset.
           */
          if (dataset_location != 1)
            {
              std::cerr << 'ERROR: Currently only Data at nodes is supported.' 
                        << std::endl;
              libmesh_error();
            }


          /*
           * Now get the foreign node id number and the respective nodal data.
           */
          int f_n_id;
          std::vector<Number> values;

          while(true)
            {
              in_file >> f_n_id;
          
              /*
               * if node_nr = -1 then we have reached the end of the dataset.
               */
              if (f_n_id==-1)
                  break;

              /*
               * Resize the values vector (usually data in three
               * principle directions, i.e. NVALDC = 3).
               */
              values.resize(NVALDC);
          
              /*
               * Read the meshdata for the respective node.
               */              
              for (unsigned int data_cnt=0; data_cnt<NVALDC; data_cnt++)
                {
                  /*
                   * Check what data type we are reading.
                   * 2,4: Real
                   * 5,6: Complex
                   * other data types are not supported yet.
                   * As again, these floats may also be written
                   * using a 'D' instead of an 'e'.
                   */
                  if (data_type == 2 || data_type == 4)
                    {
                      std::string buf;
                      in_file >> buf;
                      MeshDataUnvHeader::need_D_to_e(buf);
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
                      values[data_cnt] = Complex(std::atof(buf.c_str()), 0.);
#else
                      values[data_cnt] = std::atof(buf.c_str());
#endif
                    }

                  else if(data_type == 5 || data_type == 6)

                    {
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
                      Real re_val, im_val;

                      std::string buf;
                      in_file >> buf;

                      if (MeshDataUnvHeader::need_D_to_e(buf))
                        {
                          re_val = std::atof(buf.c_str());
                          in_file >> buf;
                          MeshDataUnvHeader::need_D_to_e(buf);
                          im_val = std::atof(buf.c_str()); 
                        }
                      else
                        {
                          re_val = std::atof(buf.c_str());
                          in_file >> im_val;
                        }

                      values[data_cnt] = Complex(re_val,im_val);
#else

                      std::cerr << 'ERROR: Complex data only supported' << std::endl
                                << 'when libMesh is configured with --enable-complex!'
                                << std::endl;
                      libmesh_error();
#endif
                    }

                  else
                    {
                      std::cerr << 'ERROR: Data type not supported.' 
                                << std::endl;
                      libmesh_error();
                    }

                } // end loop data_cnt

              /*
               * Add the values vector to the MeshData data structure.
               */
              const Node* node = foreign_id_to_node(f_n_id);
              _node_data.insert (std::make_pair(node, values));

            } // while(true)
        }


      else
        {
          /*
           * all other datasets are ignored
           */
        }

    }
  }


  /*
   * finished reading.  Ready for use, provided
   * there was any data contained in the file.
   */
  libmesh_assert ((this->_node_data.size() != 0) || (this->_elem_data.size() != 0));

  this->_node_data_closed = true;
  this->_elem_data_closed = true;
}
 

void MeshData::read_xdr (const std::string &name, const XdrMODEmode = READ) [protected]Read nodal/element oriented data using the Xdr class that enables both ASCII and binary format through the same interface. By default uses ASCII format, but may easily be changed setting mode to DECODE.

This code implements the output of the MeshData object in XDR format. This warrants some documentation. The output consists of 8 sections:

1.) The name of the data stored, if provided (string)

2.) A switch whether real or complex data is stored (string)

3.) The number of nodes for which values are stored (unsigned int)

4.) The number of elements for which values are stored (unsigned int)

for each node

5.) The foreign node id (unsigned int)

6.) The actual values (vector of real/complex)

end node loop

for each element

7.) The foreign element id (unsigned int)

8.) The actual values (vector of real/complex)

end node loop

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will write XDR or ASCII files with no changes.

clear the data, but keep the id maps

1.)

Read the descriptive name

2.)

Read: either real or complex

3.)

Read the number of nodes for which data is there

4.)

Read the number of elements for which data is there

5.)

Read the foreign node id, locate the Node* associated with this foreign id

6.)

the actual values for this node, Xdr knows the length

insert this node and the values in the _node_data

7.)

Read the foreign elem id, locate the Elem*

8.)

the actual values for this elem, Xdr knows how many

insert this elem and the values in our _elem_data only when we own this element!

Definition at line 34 of file mesh_data_xdr_support.C.

References _active, _compatibility_mode, _data_descriptor, _elem_data, _elem_data_closed, _elem_id_map_closed, _mesh, _node_data, _node_data_closed, _node_id_map_closed, clear(), Xdr::data(), foreign_id_to_elem(), foreign_id_to_node(), MeshTools::n_elem(), DofObject::processor_id(), and MeshBase::processor_id().

Referenced by read().

{
  // we should better be active or in compatibility mode
  libmesh_assert (_active || _compatibility_mode);


  // make sure the id maps are ready
  libmesh_assert (_node_id_map_closed);
  libmesh_assert (_elem_id_map_closed);


  this->clear();


  Xdr io(name, mode);


  /*
   * all processors read the data in the same format,
   * but only the processor that owns the element stores
   * element-associated data.  For nodes, i haven't come
   * up with such asmart idea, yet... :-P
   */
  const unsigned int proc_id = _mesh.processor_id();



  {
    std::string desc = '';
    io.data (desc);
    this->_data_descriptor = desc;
  }



  {
    std::string vtype='';
    io.data (vtype);
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
    if (vtype != 'COMPLEX')
      {
        std::cerr << 'ERROR: File does not contain complex-valued data!'
                  << std::endl;
        libmesh_error();
      }
#elif LIBMESH_USE_REAL_NUMBERS
    if (vtype != 'REAL')
      {
        std::cerr << 'ERROR: File does not contain real-valued data!'
                  << std::endl;
        libmesh_error();
      }
#else
    /*
     * What number type is this?
     */
    libmesh_error();
#endif
  }



  unsigned int n_node = 0;
  io.data (n_node);


  unsigned int n_elem = 0;
  io.data (n_elem);

  unsigned int previous_values_size = 0;

  for (unsigned int n_cnt=0; n_cnt < n_node; n_cnt++)
    {
      unsigned int f_id = 0;
      io.data (f_id);

      const Node* node = foreign_id_to_node(f_id);


      {
        std::vector<Number> values;
        io.data (values);


#ifdef DEBUG
        /*
         * make sure the size of the values vectors
         * are identical for all nodes
         */
        if (n_cnt == 0)
            previous_values_size = values.size();
        else
          {
            if (previous_values_size != values.size())
              {
                std::cerr << 'ERROR: Size mismatch for n_cnt = ' << n_cnt << std::endl;
                libmesh_error();
              }
          }
#endif


        _node_data.insert (std::make_pair(node, values));
      }
    }



  previous_values_size = 0;

  for (unsigned int n_cnt=0; n_cnt < n_elem; n_cnt++)
    {
      unsigned int f_id = 0;
      io.data (f_id);

      const Elem* elem = foreign_id_to_elem(f_id);


      {
        std::vector<Number> values;
        io.data (values);


#ifdef DEBUG
        /*
         * make sure the size of the values vectors
         * are identical for all elements
         */
        if (n_cnt == 0)
            previous_values_size = values.size();
        else
          {
            if (previous_values_size != values.size())
              {
                std::cerr << 'ERROR: Size mismatch for n_cnt = ' << n_cnt << std::endl;
                libmesh_error();
              }
          }
#endif


        if (elem->processor_id() == proc_id)
          _elem_data.insert (std::make_pair(elem, values));
      }
    }


  /*
   * finished reading.  Now ready for use, provided
   * there was any data contained in the file.
   */
  libmesh_assert ((this->_node_data.size() != 0) || (this->_elem_data.size() != 0));

  this->_node_data_closed = true;
  this->_elem_data_closed = true;
}
 

void MeshData::set_data (const Elem *elem, const std::vector< Number > &val) [inline]all the data values associated with the element elem, overwriting any existing vector

Definition at line 975 of file mesh_data.h.

References _elem_data.

{
  this->_elem_data[elem] = val;
}
 

void MeshData::set_data (const Node *node, const std::vector< Number > &val) [inline]all the data values associated with the node node, overwriting any existing vector

Definition at line 892 of file mesh_data.h.

References _node_data.

{
  this->_node_data[node] = val;
}
 

void MeshData::set_unv_header (MeshDataUnvHeader *unv_header) [inline]Set the MeshDataUnvHeader data structure that will be used for output.

Definition at line 1085 of file mesh_data.h.

References _unv_header.

{
  libmesh_assert (unv_header != NULL);
  this->_unv_header = unv_header;
}
 

void MeshData::slim (const boolnode_id_map = true, const boolelem_id_map = true)Once the data is properly read from file, the id maps can safely be cleared. However, if this object should remain able to write nodal or element oriented data to file, this method should better not be used. Use the appropriate bool to select the id map that should be cleared. By default, both id maps are deleted.

Definition at line 117 of file mesh_data.C.

References _elem_id, _elem_id_map_closed, _id_elem, _id_node, _node_id, _node_id_map_closed, active(), and compatibility_mode().

{
  if (this->active())
    {

      if (node_id_map)
        {
          // dumb check
          libmesh_assert (_node_id_map_closed);

          _node_id_map_closed = false;
          _node_id.clear();
          _id_node.clear();
        }

      if (elem_id_map)
        {
          // dumb check
          libmesh_assert (_elem_id_map_closed);

          _elem_id_map_closed = false;
          _elem_id.clear();
          _id_elem.clear();
        }
    }

#ifdef DEBUG
  else if (this->compatibility_mode())
    {
      std::cerr << 'WARNING: No need for MeshData::slim() in compatibility mode.' << std::endl;
    }
#endif
}
 

void MeshData::translate (const MeshBase &out_mesh, std::vector< Number > &data_values, std::vector< std::string > &data_names) constTranslates the nodal data contained in this object to data_values and data_names. These two vectors are particularly suitable for use with the MeshBase::write method that takes nodal data. E.g., the export method may be used for inspecting boundary conditions. A reference to the mesh for which the data should be written has to be provided. Note that this mesh has to contain the nodes for which this MeshData holds data. I.e., out_mesh may only refer to the MeshBase itself (that this MeshData belongs to), or its BoundaryMesh, cf. Mesh.

Definition at line 155 of file mesh_data.C.

References _active, _compatibility_mode, MeshBase::n_nodes(), n_val_per_node(), MeshBase::nodes_begin(), and MeshBase::nodes_end().

{
  libmesh_assert (_active || _compatibility_mode);

  START_LOG('translate()', 'MeshData');

  const unsigned int n_comp = this->n_val_per_node();

  // transfer our nodal data to a vector
  // that may be written concurrently
  // with the 
out_mesh. { // reserve memory for the nodal data values.reserve(n_comp*out_mesh.n_nodes()); // iterate over the mesh's nodes MeshBase::const_node_iterator nodes_it = out_mesh.nodes_begin(); const MeshBase::const_node_iterator nodes_end = out_mesh.nodes_end(); // Do not use the
get_data() method, but the operator() // method, since this returns by default a zero value, // when there is no nodal data. for (; nodes_it != nodes_end; ++nodes_it) { const Node* node = *nodes_it; for (unsigned int c= 0; c<n_comp; c++) values.push_back(this->operator()(node, c)); } } // Now we have the data, nicely stored in
values. // It remains to give names to the data, then write to // file. { names.reserve(n_comp); // this naming scheme only works up to n_comp=100 // (at least for gmv-accepted variable names) libmesh_assert(n_comp < 100); for (unsigned int n=0; n<n_comp; n++) { std::ostringstream name_buf; name_buf << 'bc_' << n; names.push_back(name_buf.str()); } } STOP_LOG('translate()', 'MeshData'); }
 

void MeshData::write (const std::string &name)Write mesh data to file named name. Guess format from the file extension.

Definition at line 288 of file mesh_data.C.

References _active, _compatibility_mode, _elem_id_map_closed, _node_id_map_closed, compatibility_mode(), libMeshEnums::ENCODE, libMeshEnums::WRITE, write_unv(), and write_xdr().

{
  START_LOG('write()', 'MeshData');

  libmesh_assert (_active || _compatibility_mode);

  // the id maps have to be closed before writing
  // (note that in compatibility mode these are also true)
  libmesh_assert (_elem_id_map_closed && _node_id_map_closed);
  
#ifdef DEBUG
  if (this->compatibility_mode())
      std::cerr << 'WARNING: MeshData in compatibility mode.  Node and element ids' << std::endl
                << '         written to file may differ from libMesh numbering' << std::endl
                << '         next time this file is read!' << std::endl;
#endif

  // Read the file based on extension
  {
    if (name.rfind('.xta') < name.size())
      write_xdr (name, WRITE);

    else if (name.rfind('.xtr')  < name.size())
      write_xdr (name, ENCODE);

    else if (name.rfind('.unv') < name.size())
      write_unv (name);

    else
      {
        std::cerr << ' ERROR: Unrecognized file extension: ' << name
                  << '  I understand the following:n'
                  << '     *.xta  -- Internal ASCII data format
                  << '     *.xtr  -- Internal binary data format
                  << '     *.unv  -- I-deas format
                  << std::endl;
        libmesh_error();

      }    
  }
  STOP_LOG('write()', 'MeshData');
}
 

void MeshData::write_unv (const std::string &file_name) [protected]Write nodal/element oriented data in UNV format, either to an ASCII file or to a gzip'ed ASCII file, using the C++ wrapper gzstream to zlib.h.

Definition at line 400 of file mesh_data_unv_support.C.

References _active, _compatibility_mode, _elem_data_closed, _elem_id_map_closed, _node_data_closed, _node_id_map_closed, and write_unv_implementation().

Referenced by write().

{
  /*
   * we should better be active or in compatibility mode
   */
  libmesh_assert (this->_active || this->_compatibility_mode);

  /*
   * make sure the id maps are ready
   * and that we have data to write
   */
  libmesh_assert (this->_node_id_map_closed);
  libmesh_assert (this->_elem_id_map_closed);

  libmesh_assert (this->_node_data_closed);
  libmesh_assert (this->_elem_data_closed);

  if (file_name.rfind('.gz') < file_name.size())
    {
#ifdef LIBMESH_HAVE_GZSTREAM
      ogzstream out_stream(file_name.c_str());
      this->write_unv_implementation (out_stream);
#else
      std::cerr << 'ERROR:  You must have the zlib.h header '
                << 'files and libraries to read and write '
                << 'compressed streams.'
                << std::endl;
      libmesh_error();
#endif
      return;
      
    }
  
  else
    {
      std::ofstream out_stream(file_name.c_str());
      this->write_unv_implementation (out_stream);
      return;
    }
}
 

void MeshData::write_unv_implementation (std::ostream &out_file) [protected]Actual implementation of writing nodal/element oriented data in UNV format. This has to be decoupled from write_unv() in order to allow writing both .unv and .unv.gz files.

Definition at line 446 of file mesh_data_unv_support.C.

References _elem_data, _node_data, _unv_header, MeshDataUnvHeader::data_type, get_data(), has_data(), n_val_per_node(), node_to_foreign_id(), MeshDataUnvHeader::nvaldc, and MeshDataUnvHeader::write().

Referenced by write_unv().

{
  /*
   * This is the actual implementation of writing
   * unv files, either as .unv or as .unv.gz file
   */
  if ( !out_file.good() )
    {
      std::cerr << 'ERROR: Output file not good.' 
                << std::endl;
      libmesh_error();
    }


  /*
   * the beginning marker of the dataset block for
   * nodal/element-associated data (not to be confused
   * with _desired_dataset_label!)
   */
  const std::string  _label_dataset_mesh_data    = '2414';

  /*
   * Currently this function handles only nodal data.
   */
  libmesh_assert (!_node_data.empty());

  if (!_elem_data.empty())
      std::cerr << 'WARNING: MeshData currently only supports nodal data for Universal files.'
                << std::endl
                << '         Will proceed writing only nodal data, ignoring element data.'
                << std::endl;


  /*
   * Write the beginning of the dataset.
   */
  out_file << '    -1
           << '  ' 
           << _label_dataset_mesh_data
           << ';

  /*
   * Write the header
   */
  if (_unv_header==NULL)
    {
      /*
       * create a header that holds at
       * least sufficient data to specify
       * what this data set currently holds.
       * 
       * The empty constructor automatically
       * takes care of 
dataset_location * and
data_type. */ MeshDataUnvHeader my_header; /* * It remains to set the correct nvaldc... */ my_header.nvaldc = this->n_val_per_node(); /* * and the correct data type. By default * only distinguish complex or real data. */ #ifdef LIBMESH_USE_COMPLEX_NUMBERS my_header.data_type = 5; #else my_header.data_type = 2; #endif /* * write this default header, then let * the AutoPtr go out of scope. This * will take care of memory management. */ my_header.write (out_file); } else { /* * make sure our nvaldc coincide. */ if (this->n_val_per_node() != _unv_header->nvaldc) { std::cerr << 'WARNING: nvaldc=' << _unv_header->nvaldc << ' of attached MeshDataUnvHeader object not valid!' << std::endl << ' re-set nvaldc to ' << this->n_val_per_node() << std::endl; _unv_header->nvaldc = this->n_val_per_node(); } /* * only issue a warning when data_type does * not coincide. Perhaps user provided some * other header in order to convert complex * to real... */ #ifdef LIBMESH_USE_COMPLEX_NUMBERS const unsigned int my_data_type = 5; #else const unsigned int my_data_type = 2; #endif if (my_data_type != _unv_header->data_type) { std::cerr << 'WARNING: data_type=' << _unv_header->data_type << ' of attached MeshDataUnvHeader differs from' << std::endl << ' default value=' << my_data_type << ' Perhaps the user wanted this,' << std::endl << ' so I use the value from the MeshDataUnvHeader.' << std::endl; } _unv_header->write (out_file); } /* * Write the foreign node number and the respective data. */ std::map<const Node*, std::vector<Number> >::const_iterator nit = _node_data.begin(); char buf[27]; for (; nit != _node_data.end(); ++nit) { const Node* node = (*nit).first; unsigned int f_n_id = node_to_foreign_id (node); std::sprintf(buf, '%10i, f_n_id); out_file << buf; /* since we are iterating over our own map, this libmesh_assert * should never break... */ libmesh_assert (this->has_data(node)); // const reference to the nodal values const std::vector<Number>& values = this->get_data(node); for (unsigned int v_cnt=0; v_cnt<values.size(); v_cnt++) { #ifdef LIBMESH_USE_COMPLEX_NUMBERS std::sprintf(buf, '%13.5E%13.5E', values[v_cnt].real(), values[v_cnt].imag()); out_file << buf; #else std::sprintf(buf, '%13.5E', static_cast<double>(values[v_cnt])); out_file << buf; #endif } out_file << '; } /* * Write end of the dataset. */ out_file << ' -1; }
 

void MeshData::write_xdr (const std::string &name, const XdrMODEmode = WRITE) [protected]Write nodal data in format comparable to the XDR format already known from Mesh. By default uses ASCII format, but may easily be changed setting mode to ENCODE.

This code implements the output of the MeshData object in XDR format. This warrants some documentation. The output consists of 8 sections:

1.) The name of the data stored, if provided (string)

2.) A switch whether real or complex data is stored (string)

3.) The number of nodes for which values are stored (unsigned int)

4.) The number of elements for which values are stored (unsigned int)

for each node

5.) The foreign node id (unsigned int)

6.) The actual values (vector of real/complex)

end node loop

for each element

7.) The foreign element id (unsigned int)

8.) The actual values (vector of real/complex)

end node loop

Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will write XDR or ASCII files with no changes.

1.)

Write the descriptive name

2.)

Write: either real or complex

3.)

Write the number of nodes for which data is there

4.)

Write the number of elements for which data is there

5.)

Write the foreign node id

6.)

the actual values for this node

7.)

Write the foreign element id

8.)

the actual values for this element

Definition at line 289 of file mesh_data_xdr_support.C.

References _data_descriptor, _elem_data, _elem_data_closed, _elem_id_map_closed, _node_data, _node_data_closed, _node_id_map_closed, Xdr::data(), elem_to_foreign_id(), get_data(), has_data(), MeshTools::n_elem(), and node_to_foreign_id().

Referenced by write().

{
  /*
   * make sure the id maps are ready
   * and that we have data to write
   */
  libmesh_assert (_node_id_map_closed);
  libmesh_assert (_elem_id_map_closed);

  libmesh_assert (_node_data_closed);
  libmesh_assert (_elem_data_closed);
  

  Xdr io(name, mode);


  // all processors write the data in the same format
  //const unsigned int proc_id = _mesh.processor_id();

  {
    std::string desc = this->_data_descriptor;
    io.data (desc, '# Data description');
  }



  {
#ifdef LIBMESH_USE_COMPLEX_NUMBERS
    std::string desc = 'COMPLEX';
#elif LIBMESH_USE_REAL_NUMBERS
    std::string desc = 'REAL';
#else
better_you_choke_this...
#endif
    io.data (desc, '# type of values');
  }



  {
    unsigned int n_node = this->_node_data.size();
    io.data (n_node, '# No. of nodes for which data is stored');
  }


  {
    unsigned int n_elem = this->_elem_data.size();
    io.data (n_elem, '# No. of elements for which data is stored');
  }




  std::map<const Node*, 
           std::vector<Number> >::const_iterator nit = _node_data.begin ();

  for (; nit != _node_data.end(); ++nit)
    {
      const Node* node = (*nit).first;

      {
        unsigned int f_id = node_to_foreign_id (node);
        io.data (f_id, '# Foreign node id');
      }


      {
        /* 
         * since we are iterating over our @e own 
         * map, this libmesh_assert should never break...
         */
        libmesh_assert (this->has_data(node));

        const std::vector<Number>& values = this->get_data(node);
        
        /*
         * copy the data to a local buf, since
         * the Xdr class needs write access, even
         * when only reading data
         */
        std::vector<Number> buf = values;
        io.data (buf, '# Values');
      }
    }







  std::map<const Elem*, 
           std::vector<Number> >::const_iterator eit = _elem_data.begin ();

  for (; eit != _elem_data.end(); ++eit)
    {
      const Elem* elem = (*eit).first;

      {
        unsigned int f_id = elem_to_foreign_id (elem);
        io.data (f_id, '# Foreign element id');
      }


      {
        /* 
         * since we are iterating over our @e own 
         * map, this libmesh_assert should never break...
         */
        libmesh_assert (this->has_data(elem));

        const std::vector<Number>& values = this->get_data(elem);
        
        /*
         * copy the data to a local buf, since
         * the Xdr class needs write access, even
         * when only reading data
         */
        std::vector<Number> buf = values;
        io.data (buf, '# Values');
      }
    }
}
 

Friends And Related Function Documentation

 

friend class MeshDataUnvHeader [friend]Make the MeshDataUnvHeader class a friend.

Definition at line 629 of file mesh_data.h.  

std::ostream& operator<< (std::ostream &os, const MeshData &m) [friend]Same as above, but allows you to use the stream syntax.

Definition at line 372 of file mesh_data.C.

{
  m.print_info(os);
  return os;
}
 

Member Data Documentation

 

bool MeshData::_active [protected]true when this object is set active (to gather data during mesh import).

Definition at line 612 of file mesh_data.h.

Referenced by activate(), active(), add_foreign_elem_id(), add_foreign_node_id(), assign(), close_foreign_id_maps(), elem_initialized(), elem_to_foreign_id(), enable_compatibility_mode(), foreign_id_to_elem(), foreign_id_to_node(), get_data(), has_data(), insert_elem_data(), insert_node_data(), n_elem_data(), n_node_data(), n_val_per_elem(), n_val_per_node(), node_initialized(), node_to_foreign_id(), operator()(), read(), read_unv(), read_xdr(), translate(), write(), and write_unv().  

bool MeshData::_compatibility_mode [protected]true when this object is in compatibility mode (use libMesh's node and element numbers as fake foreign id's)

Definition at line 619 of file mesh_data.h.

Referenced by activate(), assign(), compatibility_mode(), elem_to_foreign_id(), enable_compatibility_mode(), foreign_id_to_elem(), foreign_id_to_node(), get_data(), has_data(), insert_elem_data(), insert_node_data(), n_elem_data(), n_node_data(), n_val_per_elem(), n_val_per_node(), node_to_foreign_id(), operator()(), read(), read_unv(), read_xdr(), translate(), write(), and write_unv().  

std::string MeshData::_data_descriptor [protected]Some name the user gave to the data when this object got activated

Definition at line 520 of file mesh_data.h.

Referenced by activate(), assign(), clear(), enable_compatibility_mode(), get_info(), read_tetgen(), read_xdr(), and write_xdr().  

std::map<const Elem*, std::vector<Number> > MeshData::_elem_data [protected]Maps element pointers to the element-associated data

Definition at line 554 of file mesh_data.h.

Referenced by assign(), clear(), elem_data_begin(), elem_data_end(), get_data(), has_data(), insert_elem_data(), n_elem_data(), n_val_per_elem(), operator()(), read_tetgen(), read_unv_implementation(), read_xdr(), set_data(), write_unv_implementation(), and write_xdr().  

bool MeshData::_elem_data_closed [protected]true when the element based data are properly initialized, false otherwise.

Definition at line 604 of file mesh_data.h.

Referenced by assign(), clear(), elem_initialized(), get_data(), has_data(), insert_elem_data(), insert_node_data(), n_elem_data(), n_val_per_elem(), operator()(), read_tetgen(), read_unv_implementation(), read_xdr(), write_unv(), and write_xdr().  

std::map<const Elem*, unsigned int> MeshData::_elem_id [protected]Maps element pointers to element labels in the foreign format.

Definition at line 561 of file mesh_data.h.

Referenced by add_foreign_elem_id(), assign(), close_foreign_id_maps(), elem_to_foreign_id(), enable_compatibility_mode(), and slim().  

bool MeshData::_elem_id_map_closed [protected]true when the mesh importer finished adding element-id maps, and the element-id maps exist. Note that these maps may be deleted through slim() to save memory. Then the data is still accessible through the Elem*, but the foreign element id's are lost.

Definition at line 598 of file mesh_data.h.

Referenced by add_foreign_elem_id(), assign(), close_foreign_id_maps(), elem_to_foreign_id(), enable_compatibility_mode(), foreign_id_to_elem(), insert_elem_data(), insert_node_data(), read(), read_unv(), read_xdr(), slim(), write(), write_unv(), and write_xdr().  

std::map<unsigned int, const Elem*> MeshData::_id_elem [protected]Maps foreign element labels to element pointers of the current mesh.

Definition at line 567 of file mesh_data.h.

Referenced by add_foreign_elem_id(), close_foreign_id_maps(), enable_compatibility_mode(), foreign_id_to_elem(), and slim().  

std::map<unsigned int, const Node*> MeshData::_id_node [protected]Maps foreign node ids to node pointers of the current mesh.

Definition at line 544 of file mesh_data.h.

Referenced by add_foreign_node_id(), assign(), close_foreign_id_maps(), enable_compatibility_mode(), foreign_id_to_node(), and slim().  

const MeshBase& MeshData::_mesh [protected]The mesh this object belongs to

Definition at line 514 of file mesh_data.h.

Referenced by assign(), foreign_id_to_elem(), foreign_id_to_node(), and read_xdr().  

std::map<const Node*, std::vector<Number> > MeshData::_node_data [protected]The map containing pointers to nodes in the mesh and the corresponding data.

Definition at line 530 of file mesh_data.h.

Referenced by assign(), clear(), get_data(), has_data(), insert_node_data(), n_node_data(), n_val_per_node(), node_data_begin(), node_data_end(), operator()(), read_tetgen(), read_unv_implementation(), read_xdr(), set_data(), write_unv_implementation(), and write_xdr().  

bool MeshData::_node_data_closed [protected]true when the nodal data are properly initialized, false otherwise.

Definition at line 586 of file mesh_data.h.

Referenced by assign(), clear(), get_data(), has_data(), insert_elem_data(), insert_node_data(), n_node_data(), n_val_per_node(), node_initialized(), operator()(), read_tetgen(), read_unv_implementation(), read_xdr(), write_unv(), and write_xdr().  

std::map<const Node*, unsigned int> MeshData::_node_id [protected]Maps node pointers to node numbers in the foreign format.

Definition at line 537 of file mesh_data.h.

Referenced by add_foreign_node_id(), assign(), close_foreign_id_maps(), enable_compatibility_mode(), node_to_foreign_id(), and slim().  

bool MeshData::_node_id_map_closed [protected]true when the mesh importer finished adding node-foreign-id maps, and the node-foreign-id maps exist. Note that these maps may be deleted through slim() to save memory. Then the data is still accessible through the Node* or Elem*, but the foreign id's are lost.

Definition at line 580 of file mesh_data.h.

Referenced by add_foreign_node_id(), assign(), close_foreign_id_maps(), enable_compatibility_mode(), foreign_id_to_node(), insert_elem_data(), insert_node_data(), node_to_foreign_id(), read(), read_unv(), read_xdr(), slim(), write(), write_unv(), and write_xdr().  

MeshDataUnvHeader* MeshData::_unv_header [protected]The header information of universal files.

Definition at line 624 of file mesh_data.h.

Referenced by assign(), get_unv_header(), read_unv_implementation(), set_unv_header(), and write_unv_implementation().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Types
Public Member Functions
Protected Member Functions
Protected Attributes
Friends
Detailed Description
Member Typedef Documentation
typedef std::map<const Elem*, std::vector<Number> >::const_iterator MeshData::const_elem_data_iteratorA const iterator over the element-associated data entries of MeshData. Use this when a loop over all Node* in the MeshData is wanted. Note that only const versions are provided. Also these iterators should not be confused with the node_iterators provided for the Mesh classes!
typedef std::map<const Node*, std::vector<Number> >::const_iterator MeshData::const_node_data_iteratorA const iterator over the nodal data entries of MeshData. Use this when a loop over all Node* in the MeshData is wanted. Note that only const versions are provided. Also these iterators should not be confused with the node_iterators provided for the Mesh classes!
Constructor & Destructor Documentation
MeshData::MeshData (const MeshBase &m)Default Constructor. Takes const reference to the mesh it belongs to.
MeshData::~MeshData ()Destructor.
Member Function Documentation
void MeshData::activate (const std::string &descriptor = '')When MeshData should be used, it has to be activated first, prior to reading in a mesh with the Mesh::read() methods. This will ensure that element and node ids given in the mesh file, i.e. the foreign node and element ids, are stored in the corresponding id maps. Optionally takes a string that should help the user in identifying the data later on.
bool MeshData::active () const [inline]Returns:
void MeshData::add_foreign_elem_id (const Elem *elem, const unsigned intforeign_elem_id) [inline]In general, MeshData gathers element-associated data from file, but it needs to relate this data with the Elem* of the current mesh. Mesh importers simply use this method to add such a map.
void MeshData::add_foreign_node_id (const Node *node, const unsigned intforeign_node_id) [inline]In general, MeshData gathers nodal data from a file, but it needs to relate this data with the Node* of the current mesh. Mesh importers simply use this method to add such a map.
void MeshData::assign (const MeshData &omd)Assign to this the data from the other MeshData. Used by BoundaryInfo when copying the MeshData from the d dimensional mesh to the d-1 dimensional mesh (the boundary mesh).
void MeshData::clear ()Clears the data fields, but leaves the id maps untouched. Useful for clearing data for a new data file. Use slim() to delete the maps.
void MeshData::close_foreign_id_maps ()Signal to this object that the mesh importer finished adding node and element foreign-id maps.
bool MeshData::compatibility_mode () const [inline]Returns:
MeshData::const_elem_data_iterator MeshData::elem_data_begin () const [inline]Returns a MeshData::const_elem_data_iterators which points to the beginning of the Elem* data containers used here.
MeshData::const_elem_data_iterator MeshData::elem_data_end () const [inline]Returns a MeshData::const_elem_data_iterators which points to the end of the Elem* data containers used here.
bool MeshData::elem_initialized () const [inline]Returns:
unsigned int MeshData::elem_to_foreign_id (const Elem *n) constReturns:
void MeshData::enable_compatibility_mode (const std::string &descriptor = '')When the MeshData should be used, but was not activated prior to reading in a mesh, then the compatibility mode enables to still use this object as if the MeshData was active. The foreign node and element ids are simply assigned the indices used in libMesh. Note that the compatibility mode should be used with caution, since the node and element indices in libMesh may be renumbered any time. This MeshData always employs the current node and element ids, it does not create an image of ids when compatibility mode was activated.
const Elem * MeshData::foreign_id_to_elem (const unsigned intfid) constReturns:
const Node * MeshData::foreign_id_to_node (const unsigned intfid) constReturns:
const std::vector< Number > & MeshData::get_data (const Elem *elem) const [inline]Returns:
const std::vector< Number > & MeshData::get_data (const Node *node) const [inline]Returns:
std::string MeshData::get_info () constReturns:
const MeshDataUnvHeader & MeshData::get_unv_header () const [inline]Read access to the MeshDataUnvHeader data structure.
bool MeshData::has_data (const Node *node) const [inline]Returns:
bool MeshData::has_data (const Elem *elem) const [inline]Returns:
void MeshData::insert_elem_data (std::map< const Elem *, std::vector< Number > > &ed, const boolclose_node_data = true)For the desperate user, element-associated boundary conditions may be inserted directly through the map ed. Similar to the version for nodal data, it is imperative that the local _elem_data is empty, that the id maps are closed, that the size of the std::vector's of each map have identical length and that the Elem* point to elements of the associated mesh. Note that this method takes a non-const reference and essentially clears the passed-in data. If close_node_data is true (default), then this MeshData is ready for use: write to file, use the operator() methods etc. If false, the user has to add nodal data, too.
void MeshData::insert_node_data (std::map< const Node *, std::vector< Number > > &nd, const boolclose_elem_data = true)For the desperate user, nodal boundary conditions may be inserted directly through the map nd. It is mandatory that there does not yet exist any other node data in this object, that the id maps are closed, that the size of the std::vector's of each map have identical length and that the Node* point to nodes of the associated mesh. Note that this method takes a non-const reference and essentially clears the passed-in data. If close_elem_data is true (default), then this MeshData is ready for use: write to file, use the operator() methods etc. If false, the user has to add element-associated data, too.
unsigned int MeshData::n_elem_data () constReturns:
unsigned int MeshData::n_node_data () constReturns:
unsigned int MeshData::n_val_per_elem () constReturns:
unsigned int MeshData::n_val_per_node () constReturns:
MeshData::const_node_data_iterator MeshData::node_data_begin () const [inline]Returns the MeshData::const_node_data_iterator which points to the beginning of the Node* data containers used here.
MeshData::const_node_data_iterator MeshData::node_data_end () const [inline]Returns the MeshData::const_node_data_iterator which points to the end of the Node* data containers used here.
bool MeshData::node_initialized () const [inline]Returns:
unsigned int MeshData::node_to_foreign_id (const Node *n) constReturns:
Number MeshData::operator() (const Elem *elem, const unsigned inti = 0) const [inline]Returns:
Number MeshData::operator() (const Node *node, const unsigned inti = 0) const [inline]Returns:
void MeshData::print_info (std::ostream &os = std::cout) constPrints relevant information about the mesh.
void MeshData::read (const std::string &name)Read mesh data from file named name. Guess format from the file extension. Note that prior to this you have to at least either close_node_map() or close_elem_map().
void MeshData::read_tetgen (const std::string &name) [protected]Read nodal/element oriented data in TetGen format.
void MeshData::read_unv (const std::string &file_name) [protected]Read nodal/element oriented data in UNV format, either from an ASCII file or from a gzip'ed ASCII file, using the C++ wrapper gzstream to zlib.h.
void MeshData::read_unv_implementation (std::istream &in_file) [protected]Actual implementation of reading nodal/element oriented data in UNV format. This has to be decoupled from read_unv() in order to allow reading both .unv and .unv.gz files.
void MeshData::read_xdr (const std::string &name, const XdrMODEmode = READ) [protected]Read nodal/element oriented data using the Xdr class that enables both ASCII and binary format through the same interface. By default uses ASCII format, but may easily be changed setting mode to DECODE.
void MeshData::set_data (const Elem *elem, const std::vector< Number > &val) [inline]all the data values associated with the element elem, overwriting any existing vector
void MeshData::set_data (const Node *node, const std::vector< Number > &val) [inline]all the data values associated with the node node, overwriting any existing vector
void MeshData::set_unv_header (MeshDataUnvHeader *unv_header) [inline]Set the MeshDataUnvHeader data structure that will be used for output.
void MeshData::slim (const boolnode_id_map = true, const boolelem_id_map = true)Once the data is properly read from file, the id maps can safely be cleared. However, if this object should remain able to write nodal or element oriented data to file, this method should better not be used. Use the appropriate bool to select the id map that should be cleared. By default, both id maps are deleted.
void MeshData::translate (const MeshBase &out_mesh, std::vector< Number > &data_values, std::vector< std::string > &data_names) constTranslates the nodal data contained in this object to data_values and data_names. These two vectors are particularly suitable for use with the MeshBase::write method that takes nodal data. E.g., the export method may be used for inspecting boundary conditions. A reference to the mesh for which the data should be written has to be provided. Note that this mesh has to contain the nodes for which this MeshData holds data. I.e., out_mesh may only refer to the MeshBase itself (that this MeshData belongs to), or its BoundaryMesh, cf. Mesh.
void MeshData::write (const std::string &name)Write mesh data to file named name. Guess format from the file extension.
void MeshData::write_unv (const std::string &file_name) [protected]Write nodal/element oriented data in UNV format, either to an ASCII file or to a gzip'ed ASCII file, using the C++ wrapper gzstream to zlib.h.
void MeshData::write_unv_implementation (std::ostream &out_file) [protected]Actual implementation of writing nodal/element oriented data in UNV format. This has to be decoupled from write_unv() in order to allow writing both .unv and .unv.gz files.
void MeshData::write_xdr (const std::string &name, const XdrMODEmode = WRITE) [protected]Write nodal data in format comparable to the XDR format already known from Mesh. By default uses ASCII format, but may easily be changed setting mode to ENCODE.
Friends And Related Function Documentation
friend class MeshDataUnvHeader [friend]Make the MeshDataUnvHeader class a friend.
std::ostream& operator<< (std::ostream &os, const MeshData &m) [friend]Same as above, but allows you to use the stream syntax.
Member Data Documentation
bool MeshData::_active [protected]true when this object is set active (to gather data during mesh import).
bool MeshData::_compatibility_mode [protected]true when this object is in compatibility mode (use libMesh's node and element numbers as fake foreign id's)
std::string MeshData::_data_descriptor [protected]Some name the user gave to the data when this object got activated
std::map<const Elem*, std::vector<Number> > MeshData::_elem_data [protected]Maps element pointers to the element-associated data
bool MeshData::_elem_data_closed [protected]true when the element based data are properly initialized, false otherwise.
std::map<const Elem*, unsigned int> MeshData::_elem_id [protected]Maps element pointers to element labels in the foreign format.
bool MeshData::_elem_id_map_closed [protected]true when the mesh importer finished adding element-id maps, and the element-id maps exist. Note that these maps may be deleted through slim() to save memory. Then the data is still accessible through the Elem*, but the foreign element id's are lost.
std::map<unsigned int, const Elem*> MeshData::_id_elem [protected]Maps foreign element labels to element pointers of the current mesh.
std::map<unsigned int, const Node*> MeshData::_id_node [protected]Maps foreign node ids to node pointers of the current mesh.
const MeshBase& MeshData::_mesh [protected]The mesh this object belongs to
std::map<const Node*, std::vector<Number> > MeshData::_node_data [protected]The map containing pointers to nodes in the mesh and the corresponding data.
bool MeshData::_node_data_closed [protected]true when the nodal data are properly initialized, false otherwise.
std::map<const Node*, unsigned int> MeshData::_node_id [protected]Maps node pointers to node numbers in the foreign format.
bool MeshData::_node_id_map_closed [protected]true when the mesh importer finished adding node-foreign-id maps, and the node-foreign-id maps exist. Note that these maps may be deleted through slim() to save memory. Then the data is still accessible through the Node* or Elem*, but the foreign id's are lost.
MeshDataUnvHeader* MeshData::_unv_header [protected]The header information of universal files.
Author

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