libMesh::MeshOutput< MT > Class Template Referenceabstract

#include <mesh_output.h>

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)
inlineexplicitprotected

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

Definition at line 164 of file mesh_output.h.

164  :
165  _is_parallel_format(is_parallel_format),
166  _obj(NULL),
167  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
168 {}
template<class MT>
libMesh::MeshOutput< MT >::MeshOutput ( const MT &  obj,
const bool  is_parallel_format = false 
)
inlineexplicitprotected

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().

174  :
175  _is_parallel_format(is_parallel_format),
176  _obj (&obj),
177  _ascii_precision (std::numeric_limits<Real>::digits10 + 2)
178 {
179  if (!_is_parallel_format && !this->mesh().is_serial())
180  {
181  if (this->mesh().processor_id() == 0)
182  {
183  libmesh_do_once(libMesh::out <<
184  "Warning: This MeshOutput subclass only supports meshes which have been serialized!"
185  << std::endl;);
186  }
187 // libmesh_error();
188  }
189 }
template<class MT >
libMesh::MeshOutput< MT >::~MeshOutput ( )
inlinevirtual

Destructor.

Definition at line 195 of file mesh_output.h.

196 {
197 }

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 31 of file mesh_output.C.

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

35 {
37  {
38  // We need a serial mesh for MeshOutput for now
39  const_cast<EquationSystems&>(es).allgather();
40  }
41 
42  es.build_variable_names (names, NULL, system_names);
43  es.build_solution_vector (soln, system_names);
44 
45  // For now, if we're doing a parallel format we're going to broadcast the vector from processor 0
46  // to all of the processors to mimic what build_solution_vector used to do.
47  // this is TERRIBLE and WASTEFUL but it's only temporary until we redesign the output of build_solution_vector
48  // and the inputs to the I/O... both of which should actually be NumericVectors....
50  {
51  size_t size = soln.size();
52  _obj->comm().broadcast(size);
53 
54  if(_obj->comm().rank())
55  soln.resize(size);
56 
57  _obj->comm().broadcast(soln);
58  }
59 }
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 265 of file mesh_output.h.

266 {
267  return _ascii_precision;
268 }
template<class MT >
const MT & libMesh::MeshOutput< MT >::mesh ( ) const
inlineprotected

Returns the object as a read-only reference.

Definition at line 255 of file mesh_output.h.

References libMesh::libmesh_assert().

Referenced by libMesh::VTKIO::cells_to_vtk(), libMesh::UNVIO::element_out(), libMesh::MeshOutput< MT >::MeshOutput(), libMesh::UNVIO::node_out(), libMesh::VTKIO::nodes_to_vtk(), libMesh::FroIO::write(), libMesh::PostscriptIO::write(), libMesh::TetGenIO::write(), libMesh::ExodusII_IO::write(), libMesh::Nemesis_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::CheckpointIO::write_bcs(), libMesh::TecplotIO::write_binary(), libMesh::GMVIO::write_binary(), libMesh::CheckpointIO::write_connectivity(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::EnsightIO::write_geometry_ascii(), libMesh::UCDIO::write_implementation(), libMesh::GmshIO::write_mesh(), libMesh::LegacyXdrIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::Nemesis_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::CheckpointIO::write_nodes(), libMesh::CheckpointIO::write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::XdrIO::write_serialized_bcs(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::LegacyXdrIO::write_soln(), libMesh::GnuPlotIO::write_solution(), libMesh::DivaIO::write_stream(), libMesh::CheckpointIO::write_subdomain_names(), and libMesh::EnsightIO::write_vector_ascii().

256 {
258  return *_obj;
259 }
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 
)
inlinevirtual

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

Definition at line 203 of file mesh_output.h.

References libMesh::libmesh_assert(), libMesh::out, libMesh::START_LOG(), and libMesh::STOP_LOG().

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

206 {
207  START_LOG("write_equation_systems()", "MeshOutput");
208 
209  // We may need to gather and/or renumber a ParallelMesh to output
210  // it, making that const qualifier in our constructor a dirty lie
211  MT& my_mesh = const_cast<MT&>(*_obj);
212 
213  // A non-renumbered mesh may not have a contiguous numbering, and
214  // that needs to be fixed before we can build a solution vector.
215  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
216  my_mesh.max_node_id() != my_mesh.n_nodes())
217  {
218  // If we were allowed to renumber then we should have already
219  // been properly renumbered...
220  libmesh_assert(!my_mesh.allow_renumbering());
221 
222  libmesh_do_once(libMesh::out <<
223  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
224  << std::endl;);
225 
226  my_mesh.allow_renumbering(true);
227 
228  my_mesh.renumber_nodes_and_elements();
229 
230  // Not sure what good going back to false will do here, the
231  // renumbering horses have already left the barn...
232  my_mesh.allow_renumbering(false);
233  }
234 
235  MeshSerializer serialize(const_cast<MT&>(*_obj), !_is_parallel_format);
236 
237  // Build the nodal solution values & get the variable
238  // names from the EquationSystems object
239  std::vector<Number> soln;
240  std::vector<std::string> names;
241 
242  this->_build_variable_names_and_solution_vector(es, soln, names, system_names);
243  //es.build_variable_names (names);
244  //es.build_solution_vector (soln);
245 
246  this->write_nodal_data (fname, soln, names);
247 
248  STOP_LOG("write_equation_systems()", "MeshOutput");
249 }
template<class MT>
virtual void libMesh::MeshOutput< MT >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
inlinevirtual

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::Nemesis_IO, libMesh::GmshIO, libMesh::VTKIO, libMesh::UCDIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 98 of file mesh_output.h.

101  { libmesh_error(); }

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:

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:27 UTC

Hosted By:
SourceForge.net Logo