$extrastylesheet
libMesh::MeshOutput< MT > Class Template Reference

#include <mesh_output.h>

List of all members.

Public Member Functions

virtual ~MeshOutput ()
virtual void write (const std::string &)=0
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=NULL)
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
unsigned int & ascii_precision ()

Protected Member Functions

 MeshOutput (const bool is_parallel_format=false)
 MeshOutput (const MT &, const bool is_parallel_format=false)
const MT & mesh () const

Protected Attributes

const bool _is_parallel_format

Private Member Functions

void _build_variable_names_and_solution_vector (const EquationSystems &es, std::vector< Number > &soln, std::vector< std::string > &names, const std::set< std::string > *system_names=NULL)

Private Attributes

const MT *const _obj
unsigned int _ascii_precision

Detailed Description

template<class MT>
class libMesh::MeshOutput< MT >

This class defines an abstract interface for Mesh output. Specific classes derived from this class actually implement writing various mesh formats.

Author:
Benjamin S. Kirk
Date:
2004

Definition at line 55 of file mesh_output.h.


Constructor & Destructor Documentation

template<class MT >
libMesh::MeshOutput< MT >::MeshOutput ( const bool  is_parallel_format = false) [inline, explicit, protected]

Default constructor. Will set the _obj to NULL, effectively rendering this object useless.

Definition at line 164 of file mesh_output.h.

                                                         :
  _is_parallel_format(is_parallel_format),
  _obj(NULL),
  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
{}
template<class MT>
libMesh::MeshOutput< MT >::MeshOutput ( const MT &  obj,
const bool  is_parallel_format = false 
) [inline, explicit, protected]

Constructor. Takes a reference to a constant object. This constructor will only allow us to write the object.

Definition at line 174 of file mesh_output.h.

References libMesh::MeshOutput< MT >::_is_parallel_format, libMesh::MeshOutput< MT >::mesh(), libMesh::out, and libMesh::processor_id().

                                                                        :
  _is_parallel_format(is_parallel_format),
  _obj (&obj),
  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
{
  if (!_is_parallel_format && !this->mesh().is_serial())
    {
      if (this->mesh().processor_id() == 0)
        {
          libmesh_do_once(libMesh::out <<
                          "Warning:  This MeshOutput subclass only supports meshes which have been serialized!"
                          << std::endl;);
        }
    }
}
template<class MT >
libMesh::MeshOutput< MT >::~MeshOutput ( ) [inline, virtual]

Destructor.

Definition at line 194 of file mesh_output.h.

{
}

Member Function Documentation

template<class MT >
void libMesh::MeshOutput< MT >::_build_variable_names_and_solution_vector ( const EquationSystems es,
std::vector< Number > &  soln,
std::vector< std::string > &  names,
const std::set< std::string > *  system_names = NULL 
) [private]

A helper function which allows us to fill temporary name and solution vectors with an EquationSystems object. Only generate names and solution data corresponding to systems specified in system_names.

Definition at line 86 of file mesh_output.C.

References libMesh::Parallel::allgather(), libMesh::EquationSystems::build_solution_vector(), and libMesh::EquationSystems::build_variable_names().

{
  if(!_is_parallel_format)
    {
      // We need a serial mesh for MeshOutput for now
      const_cast<EquationSystems&>(es).allgather();
    }

  es.build_variable_names  (names, NULL, system_names);
  es.build_solution_vector (soln, system_names);

  // For now, if we're doing a parallel format we're going to broadcast the vector from processor 0
  // to all of the processors to mimic what build_solution_vector used to do.
  // this is TERRIBLE and WASTEFUL but it's only temporary until we redesign the output of build_solution_vector
  // and the inputs to the I/O... both of which should actually be NumericVectors....
  if(_is_parallel_format)
    {
      size_t size = soln.size();
      _obj->comm().broadcast(size);

      if(_obj->comm().rank())
        soln.resize(size);

      _obj->comm().broadcast(soln);
    }
}
template<class MT >
unsigned int & libMesh::MeshOutput< MT >::ascii_precision ( ) [inline]

Return/set the precision to use when writing ASCII files.

By default we use numeric_limits<Real>::digits10 + 2, which should be enough to write out to ASCII and get the exact same Real back when reading in.

Definition at line 212 of file mesh_output.h.

{
  return _ascii_precision;
}
template<class MT >
const MT & libMesh::MeshOutput< MT >::mesh ( ) const [inline, protected]

Returns the object as a read-only reference.

Definition at line 202 of file mesh_output.h.

References libMesh::libmesh_assert().

Referenced by libMesh::MeshOutput< MT >::MeshOutput().

{
  libmesh_assert(_obj);
  return *_obj;
}
template<class MT >
void libMesh::MeshOutput< MT >::write_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = NULL 
) [virtual]

This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object.

Reimplemented in libMesh::NameBasedIO.

Definition at line 30 of file mesh_output.C.

References libMesh::EquationSystems::get_mesh(), libMesh::libmesh_assert(), libMesh::out, and libMesh::START_LOG().

Referenced by libMesh::ErrorVector::plot_error().

{
  START_LOG("write_equation_systems()", "MeshOutput");

  // We may need to gather and/or renumber a ParallelMesh to output
  // it, making that const qualifier in our constructor a dirty lie
  MT& my_mesh = const_cast<MT&>(*_obj);

  // If we're asked to write data that's associated with a different
  // mesh, output files full of garbage are the result.
  libmesh_assert_equal_to(&es.get_mesh(), _obj);

  // A non-renumbered mesh may not have a contiguous numbering, and
  // that needs to be fixed before we can build a solution vector.
  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
      my_mesh.max_node_id() != my_mesh.n_nodes())
    {
      // If we were allowed to renumber then we should have already
      // been properly renumbered...
      libmesh_assert(!my_mesh.allow_renumbering());

      libmesh_do_once(libMesh::out <<
                      "Warning:  This MeshOutput subclass only supports meshes which are contiguously renumbered!"
                      << std::endl;);

      my_mesh.allow_renumbering(true);

      my_mesh.renumber_nodes_and_elements();

      // Not sure what good going back to false will do here, the
      // renumbering horses have already left the barn...
      my_mesh.allow_renumbering(false);
    }

  MeshSerializer serialize(const_cast<MT&>(*_obj), !_is_parallel_format);

  // Build the nodal solution values & get the variable
  // names from the EquationSystems object
  std::vector<Number>      soln;
  std::vector<std::string> names;

  this->_build_variable_names_and_solution_vector(es, soln, names, system_names);
  //es.build_variable_names  (names);
  //es.build_solution_vector (soln);

  this->write_nodal_data (fname, soln, names);

  STOP_LOG("write_equation_systems()", "MeshOutput");
}
template<class MT>
virtual void libMesh::MeshOutput< MT >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
) [inline, virtual]

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided.

Reimplemented in libMesh::ExodusII_IO, libMesh::GMVIO, libMesh::NameBasedIO, libMesh::GmshIO, libMesh::Nemesis_IO, libMesh::VTKIO, libMesh::UCDIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 98 of file mesh_output.h.

  { libmesh_not_implemented(); }

Member Data Documentation

template<class MT>
unsigned int libMesh::MeshOutput< MT >::_ascii_precision [private]

Precision to use when writing ASCII files.

Definition at line 141 of file mesh_output.h.

template<class MT>
const bool libMesh::MeshOutput< MT >::_is_parallel_format [protected]

Flag specifying whether this format is parallel-capable. If this is false (default) I/O is only permitted when the mesh has been serialized.

Definition at line 126 of file mesh_output.h.

Referenced by libMesh::MeshOutput< MT >::MeshOutput().

template<class MT>
const MT* const libMesh::MeshOutput< MT >::_obj [private]

A pointer to a constant object. This allows us to write the object to file.

Definition at line 136 of file mesh_output.h.


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