$extrastylesheet
#include <diva_io.h>

Public Member Functions | |
| DivaIO (const MeshBase &) | |
| virtual void | write (const std::string &) |
| 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 | |
| const MeshBase & | mesh () const |
Protected Attributes | |
| const bool | _is_parallel_format |
Private Member Functions | |
| virtual void | write_stream (std::ostream &out) |
This class implements writing meshes in the Diva format. This is a scientific visualization program created by Kelly Gaither. More information on Diva can be found here: http://www.erc.msstate.edu/simcenter/docs/diva/
| libMesh::DivaIO::DivaIO | ( | const MeshBase & | mesh_in | ) | [inline, explicit] |
| unsigned int& libMesh::MeshOutput< MeshBase >::ascii_precision | ( | ) | [inherited] |
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.
Referenced by libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().
| const MeshBase & libMesh::MeshOutput< MeshBase >::mesh | ( | ) | const [protected, inherited] |
Returns the object as a read-only reference.
Referenced by libMesh::TecplotIO::elem_dimension(), libMesh::FroIO::write(), write(), libMesh::TecplotIO::write(), libMesh::PostscriptIO::write(), libMesh::MEDITIO::write(), libMesh::EnsightIO::write(), libMesh::MEDITIO::write_ascii(), libMesh::TecplotIO::write_ascii(), libMesh::TecplotIO::write_binary(), libMesh::EnsightIO::write_geometry_ascii(), libMesh::TecplotIO::write_nodal_data(), libMesh::MEDITIO::write_nodal_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::GnuPlotIO::write_solution(), write_stream(), and libMesh::EnsightIO::write_vector_ascii().
| void libMesh::DivaIO::write | ( | const std::string & | fname | ) | [virtual] |
This method implements writing a mesh to a specified file.
Implements libMesh::MeshOutput< MeshBase >.
Definition at line 34 of file diva_io.C.
References libMesh::MeshOutput< MeshBase >::_is_parallel_format, libMesh::MeshOutput< MeshBase >::mesh(), and write_stream().
Referenced by libMesh::NameBasedIO::write().
{
// We may need to gather a ParallelMesh to output it, making that
// const qualifier in our constructor a dirty lie
MeshSerializer serialize(const_cast<MeshBase&>(this->mesh()), !_is_parallel_format);
// Open the output file stream
std::ofstream out_file(fname.c_str());
// Make sure it opened correctly
if (!out_file.good())
libmesh_file_error(fname.c_str());
this->write_stream (out_file);
}
| virtual void libMesh::MeshOutput< MeshBase >::write_equation_systems | ( | const std::string & | , |
| const EquationSystems & | , | ||
| const std::set< std::string > * | system_names = NULL |
||
| ) | [virtual, inherited] |
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.
Referenced by libMesh::Nemesis_IO::write_timestep(), and libMesh::ExodusII_IO::write_timestep().
| virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data | ( | const std::string & | , |
| const std::vector< Number > & | , | ||
| const std::vector< std::string > & | |||
| ) | [inline, virtual, inherited] |
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(); }
| void libMesh::DivaIO::write_stream | ( | std::ostream & | out | ) | [private, virtual] |
The actual implementation of writing the diva file. This file is called by the public interface file after it constructs an ofstream.
Write the header
Write the nodes
Write the BC faces
Write the triangles
Write the quadrilaterals
Write the BC IDs
Write the triangles
Write the quadrilaterals
Write all the Tets
Write all the Pyramids
Write all the Prisms
Write all the Hexes
Definition at line 53 of file diva_io.C.
References libMesh::Elem::active(), libMesh::BoundaryInfo::boundary_id(), libMesh::Elem::build_side(), libMesh::ParallelMesh::clear(), libMesh::ParallelObject::comm(), libMesh::Elem::connectivity(), libMesh::MeshBase::elem(), libMesh::err, libMesh::MeshBase::get_boundary_info(), libMesh::HEX20, libMesh::HEX27, libMesh::HEX8, libMesh::libmesh_assert(), libMesh::MeshOutput< MeshBase >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshTools::n_active_elem_of_type(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), libMesh::Elem::n_sides(), libMesh::Elem::n_sub_elem(), libMesh::Elem::neighbor(), libMesh::Elem::node(), libMesh::MeshBase::point(), libMesh::PRISM18, libMesh::PRISM6, libMesh::PYRAMID5, libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, side, libMesh::BoundaryInfo::sync(), libMesh::TECPLOT, libMesh::TET10, libMesh::TET4, libMesh::TRI3, libMesh::TRI6, libMesh::Elem::type(), and libMesh::TypeVector< T >::write_unformatted().
Referenced by write().
{
/*
From Kelly: (kelly@tacc.utexas.edu)
Ok, the following is the format:
#points #triangles #quads #tets #prisms #pyramids #hexs
loop over all points (written out x y z x y z ...)
loop over all triangles (written out i1 i2 i3) (These are indices into
the points going from
1 to #points)
loop over all quads (written out i1 i2 i3 i4) (Same numbering scheme)
loop over all triangles and quads (write out b1) (This is a boundary
condition for each
triangle and each
hex. You can put
anything you want
here)
loop over all tets (written out i1 i2 i3 i4) (Same)
loop over all pyramids (written out i1 i2 i3 i4 i5) (Same)
loop over all prisms (written out i1 i2 i3 i4 i5 i6) (Same)
loop over all hexs (written out i1 i2 i3 i4 i5 i6 i7 i8) (Same)
*/
// Be sure the stream has been created successfully.
libmesh_assert (out_file.good());
// Can't use a constant mesh reference since we have to
// sync the boundary info.
libmesh_here();
libMesh::err << "WARNING... Sure you want to do this?"
<< std::endl;
MeshBase& the_mesh = const_cast<MeshBase&>
(MeshOutput<MeshBase>::mesh());
if (the_mesh.mesh_dimension() < 3)
{
libMesh::err << "WARNING: DIVA only supports 3D meshes.\n\n"
<< "Exiting without producing output.\n";
return;
}
BoundaryMesh boundary_mesh
(the_mesh.comm(),
cast_int<unsigned char>(the_mesh.mesh_dimension()-1));
the_mesh.get_boundary_info().sync(boundary_mesh);
out_file << the_mesh.n_nodes()
<< ' '
<< (MeshTools::n_active_elem_of_type(boundary_mesh,TRI3) +
MeshTools::n_active_elem_of_type(boundary_mesh,TRI6)*4)
<< ' '
<< (MeshTools::n_active_elem_of_type(boundary_mesh, QUAD4) +
MeshTools::n_active_elem_of_type(boundary_mesh, QUAD8) +
MeshTools::n_active_elem_of_type(boundary_mesh, QUAD9)*4)
<< ' '
<< (MeshTools::n_active_elem_of_type(the_mesh, TET4) +
MeshTools::n_active_elem_of_type(the_mesh, TET10)*8)
<< ' '
<< MeshTools::n_active_elem_of_type(the_mesh, PYRAMID5)
<< ' '
<< (MeshTools::n_active_elem_of_type(the_mesh, PRISM6) +
MeshTools::n_active_elem_of_type(the_mesh, PRISM18)*8)
<< ' '
<< (MeshTools::n_active_elem_of_type(the_mesh, HEX8) +
MeshTools::n_active_elem_of_type(the_mesh, HEX20) +
MeshTools::n_active_elem_of_type(the_mesh, HEX27)*8)
<< ' '
<< '\n';
boundary_mesh.clear();
for (unsigned int v=0; v<the_mesh.n_nodes(); v++)
the_mesh.point(v).write_unformatted(out_file);
{
for(unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
for (unsigned int s=0; s<the_mesh.elem(e)->n_sides(); s++)
if (the_mesh.elem(e)->neighbor(s) == NULL)
{
const UniquePtr<Elem> side(the_mesh.elem(e)->build_side(s));
if (side->type() == TRI3)
{
out_file << side->node(0)+1 << " "
<< side->node(1)+1 << " "
<< side->node(2)+1 << '\n';
}
else if (side->type() == TRI6)
{
out_file << side->node(0)+1 << " "
<< side->node(3)+1 << " "
<< side->node(5)+1 << '\n'
<< side->node(3)+1 << " "
<< side->node(1)+1 << " "
<< side->node(4)+1 << '\n'
<< side->node(5)+1 << " "
<< side->node(4)+1 << " "
<< side->node(2)+1 << '\n'
<< side->node(3)+1 << " "
<< side->node(4)+1 << " "
<< side->node(5)+1 << '\n';
}
}
for(unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
for (unsigned int s=0; s<the_mesh.elem(e)->n_sides(); s++)
if (the_mesh.elem(e)->neighbor(s) == NULL)
{
const UniquePtr<Elem> side(the_mesh.elem(e)->build_side(s));
if ((side->type() == QUAD4) ||
(side->type() == QUAD8) )
{
out_file << side->node(0)+1 << " "
<< side->node(1)+1 << " "
<< side->node(2)+1 << " "
<< side->node(3)+1 << '\n';
}
else if (side->type() == QUAD9)
{
out_file << side->node(0)+1 << " "
<< side->node(4)+1 << " "
<< side->node(8)+1 << " "
<< side->node(7)+1 << '\n'
<< side->node(4)+1 << " "
<< side->node(1)+1 << " "
<< side->node(5)+1 << " "
<< side->node(8)+1 << '\n'
<< side->node(7)+1 << " "
<< side->node(8)+1 << " "
<< side->node(6)+1 << " "
<< side->node(3)+1 << '\n'
<< side->node(8)+1 << " "
<< side->node(5)+1 << " "
<< side->node(2)+1 << " "
<< side->node(6)+1 << '\n';
}
}
}
{
for(unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
for (unsigned short s=0; s<the_mesh.elem(e)->n_sides(); s++)
if (the_mesh.elem(e)->neighbor(s) == NULL)
{
const UniquePtr<Elem> side(the_mesh.elem(e)->build_side(s));
if ((side->type() == TRI3) ||
(side->type() == TRI6) )
out_file << the_mesh.get_boundary_info().boundary_id(the_mesh.elem(e), s)
<< '\n';
}
for(unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
for (unsigned short s=0; s<the_mesh.elem(e)->n_sides(); s++)
if (the_mesh.elem(e)->neighbor(s) == NULL)
{
const UniquePtr<Elem> side(the_mesh.elem(e)->build_side(s));
if ((side->type() == QUAD4) ||
(side->type() == QUAD8) ||
(side->type() == QUAD9))
out_file << the_mesh.get_boundary_info().boundary_id(the_mesh.elem(e), s);
}
}
for (unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
{
if (the_mesh.elem(e)->type() == TET4)
{
out_file << the_mesh.elem(e)->node(0)+1 << " "
<< the_mesh.elem(e)->node(1)+1 << " "
<< the_mesh.elem(e)->node(2)+1 << " "
<< the_mesh.elem(e)->node(3)+1 << '\n';
}
else if (the_mesh.elem(e)->type() == TET10)
{
out_file << the_mesh.elem(e)->node(0)+1 << " "
<< the_mesh.elem(e)->node(4)+1 << " "
<< the_mesh.elem(e)->node(6)+1 << " "
<< the_mesh.elem(e)->node(7)+1 << '\n';
out_file << the_mesh.elem(e)->node(4)+1 << " "
<< the_mesh.elem(e)->node(1)+1 << " "
<< the_mesh.elem(e)->node(5)+1 << " "
<< the_mesh.elem(e)->node(8)+1 << '\n';
out_file << the_mesh.elem(e)->node(6)+1 << " "
<< the_mesh.elem(e)->node(5)+1 << " "
<< the_mesh.elem(e)->node(2)+1 << " "
<< the_mesh.elem(e)->node(9)+1 << '\n';
out_file << the_mesh.elem(e)->node(7)+1 << " "
<< the_mesh.elem(e)->node(8)+1 << " "
<< the_mesh.elem(e)->node(9)+1 << " "
<< the_mesh.elem(e)->node(3)+1 << '\n';
out_file << the_mesh.elem(e)->node(4)+1 << " "
<< the_mesh.elem(e)->node(8)+1 << " "
<< the_mesh.elem(e)->node(6)+1 << " "
<< the_mesh.elem(e)->node(7)+1 << '\n';
out_file << the_mesh.elem(e)->node(4)+1 << " "
<< the_mesh.elem(e)->node(5)+1 << " "
<< the_mesh.elem(e)->node(6)+1 << " "
<< the_mesh.elem(e)->node(8)+1 << '\n';
out_file << the_mesh.elem(e)->node(6)+1 << " "
<< the_mesh.elem(e)->node(5)+1 << " "
<< the_mesh.elem(e)->node(9)+1 << " "
<< the_mesh.elem(e)->node(8)+1 << '\n';
out_file << the_mesh.elem(e)->node(6)+1 << " "
<< the_mesh.elem(e)->node(8)+1 << " "
<< the_mesh.elem(e)->node(9)+1 << " "
<< the_mesh.elem(e)->node(7)+1 << '\n';
}
}
for (unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
if (the_mesh.elem(e)->type() == PYRAMID5)
{
out_file << the_mesh.elem(e)->node(0)+1 << " "
<< the_mesh.elem(e)->node(1)+1 << " "
<< the_mesh.elem(e)->node(2)+1 << " "
<< the_mesh.elem(e)->node(3)+1 << " "
<< the_mesh.elem(e)->node(4)+1 << '\n';
}
for (unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
{
if (the_mesh.elem(e)->type() == PRISM6)
{
out_file << the_mesh.elem(e)->node(0)+1 << " "
<< the_mesh.elem(e)->node(1)+1 << " "
<< the_mesh.elem(e)->node(2)+1 << " "
<< the_mesh.elem(e)->node(3)+1 << " "
<< the_mesh.elem(e)->node(4)+1 << " "
<< the_mesh.elem(e)->node(5)+1 << '\n';
}
else if (the_mesh.elem(e)->type() == PRISM18)
libmesh_error_msg("PRISM18 element type not supported.");
}
for (unsigned int e=0; e<the_mesh.n_elem(); e++)
if (the_mesh.elem(e)->active())
if ((the_mesh.elem(e)->type() == HEX8) ||
(the_mesh.elem(e)->type() == HEX20) ||
(the_mesh.elem(e)->type() == HEX27) )
{
std::vector<dof_id_type> conn;
for (unsigned int se=0; se<the_mesh.elem(e)->n_sub_elem(); se++)
{
the_mesh.elem(e)->connectivity(se, TECPLOT, conn);
out_file << conn[0] << ' '
<< conn[1] << ' '
<< conn[2] << ' '
<< conn[3] << ' '
<< conn[4] << ' '
<< conn[5] << ' '
<< conn[6] << ' '
<< conn[7] << '\n';
}
}
}
const bool libMesh::MeshOutput< MeshBase >::_is_parallel_format [protected, inherited] |
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::FroIO::write(), write(), libMesh::PostscriptIO::write(), and libMesh::EnsightIO::write().