Poster of Linux kernelThe best gift for a Linux geek
DivaIO

DivaIO

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

NAME

DivaIO -  

SYNOPSIS


#include <diva_io.h>

Inherits MeshOutput< MeshBase >.  

Public Member Functions


DivaIO (const MeshBase &)

virtual void write (const std::string &)

virtual void write_equation_systems (const std::string &, const EquationSystems &)

virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 

Protected Member Functions


const MeshBase & mesh () const
 

Private Member Functions


virtual void write_stream (std::ostream &out)
 

Detailed Description

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/

Author:

John W. Peterson, 2004

Definition at line 44 of file diva_io.h.  

Constructor & Destructor Documentation

 

DivaIO::DivaIO (const MeshBase &mesh) [inline]Note that only writing diva files is supported since Diva is not a mesh generator.

Definition at line 75 of file diva_io.h.

                                    :
  MeshOutput<MeshBase>  (mesh)
{}
 

Member Function Documentation

 

const MeshBase & MeshOutput< MeshBase >::mesh () const [protected, inherited]Returns the object as a read-only reference.

Referenced by PostscriptIO::write(), FroIO::write(), MEDITIO::write_ascii(), EnsightIO::write_geometry_ascii(), EnsightIO::write_scalar_ascii(), GnuPlotIO::write_solution(), write_stream(), and EnsightIO::write_vector_ascii().  

void DivaIO::write (const std::string &fname) [virtual]This method implements writing a mesh to a specified file.

Implements MeshOutput< MeshBase >.

Definition at line 33 of file diva_io.C.

References write_stream().

Referenced by UnstructuredMesh::write().

{
  // Open the output file stream
  std::ofstream out(fname.c_str());

  // Make sure it opened correctly
  if (!out.good())
    libmesh_file_error(fname.c_str());

  this->write_stream (out);
}
 

virtual void MeshOutput< MeshBase >::write_equation_systems (const std::string &, const EquationSystems &) [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 VTKIO.  

virtual void 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 ExodusII_IO, GmshIO, GMVIO, GnuPlotIO, MEDITIO, and TecplotIO.

Definition at line 91 of file mesh_output.h.

  { libmesh_error(); }
 

void 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 48 of file diva_io.C.

References Elem::active(), MeshBase::boundary_info, Elem::build_side(), Elem::connectivity(), MeshBase::elem(), libMeshEnums::HEX20, libMeshEnums::HEX27, libMeshEnums::HEX8, MeshOutput< MeshBase >::mesh(), MeshBase::mesh_dimension(), MeshTools::n_active_elem_of_type(), MeshBase::n_elem(), MeshBase::n_nodes(), Elem::n_sides(), Elem::n_sub_elem(), Elem::neighbor(), Elem::node(), MeshBase::point(), libMeshEnums::PRISM18, libMeshEnums::PRISM6, libMeshEnums::PYRAMID5, libMeshEnums::QUAD4, libMeshEnums::QUAD8, libMeshEnums::QUAD9, libMeshEnums::TECPLOT, libMeshEnums::TET10, libMeshEnums::TET4, libMeshEnums::TRI3, libMeshEnums::TRI6, Elem::type(), and 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.good());
  
  // Can't use a constant mesh reference since we have to
  // sync the boundary info.
  libmesh_here();
  std::cerr << 'WARNING...  Sure you want to do this?'
            << std::endl;
  MeshBase& mesh = const_cast<MeshBase&>
    (MeshOutput<MeshBase>::mesh());

  if (mesh.mesh_dimension() < 3)
    {
      std::cerr << 'WARNING: DIVA only supports 3D meshes.n'
                << 'Exiting without producing output.;
      return;
    }
  


  BoundaryMesh boundary_mesh (mesh.mesh_dimension()-1);
  mesh.boundary_info->sync(boundary_mesh);
  

  out << 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(mesh, TET4) +
          MeshTools::n_active_elem_of_type(mesh, TET10)*8) << ' '
    
      << MeshTools::n_active_elem_of_type(mesh, PYRAMID5) << ' '
    
      << (MeshTools::n_active_elem_of_type(mesh, PRISM6) +
          MeshTools::n_active_elem_of_type(mesh, PRISM18)*8) << ' '

      << (MeshTools::n_active_elem_of_type(mesh, HEX8)   +
          MeshTools::n_active_elem_of_type(mesh, HEX20) +
          MeshTools::n_active_elem_of_type(mesh, HEX27)*8) << ' '
    
      << ';
  

  boundary_mesh.clear();

  
  for (unsigned int v=0; v<mesh.n_nodes(); v++)
    mesh.point(v).write_unformatted(out);
  
  
  {
    for(unsigned int e=0; e<mesh.n_elem(); e++)
      if (mesh.elem(e)->active())
        for (unsigned int s=0; s<mesh.elem(e)->n_sides(); s++)
          if (mesh.elem(e)->neighbor(s) == NULL)
            {
              const AutoPtr<Elem> side(mesh.elem(e)->build_side(s));

              if (side->type() == TRI3)
                {
                  out << side->node(0)+1 << ' '
                      << side->node(1)+1 << ' '
                      << side->node(2)+1 << ';
                }
              else if (side->type() == TRI6)
                {
                  out << side->node(0)+1 << ' '
                      << side->node(3)+1 << ' '
                      << side->node(5)+1 << '

                      << side->node(3)+1 << ' '
                      << side->node(1)+1 << ' '
                      << side->node(4)+1 << '

                      << side->node(5)+1 << ' '
                      << side->node(4)+1 << ' '
                      << side->node(2)+1 << '

                      << side->node(3)+1 << ' '
                      << side->node(4)+1 << ' '
                      << side->node(5)+1 << ';
                }
            }

    
    for(unsigned int e=0; e<mesh.n_elem(); e++)
      if (mesh.elem(e)->active())
        for (unsigned int s=0; s<mesh.elem(e)->n_sides(); s++)
          if (mesh.elem(e)->neighbor(s) == NULL)
            {
              const AutoPtr<Elem> side(mesh.elem(e)->build_side(s));

              if ((side->type() == QUAD4) ||
                  (side->type() == QUAD8)  )            
                {
                  out << side->node(0)+1 << ' '
                      << side->node(1)+1 << ' '
                      << side->node(2)+1 << ' '
                      << side->node(3)+1 << ';
                }
              else if (side->type() == QUAD9)
                {
                  out << side->node(0)+1 << ' '
                      << side->node(4)+1 << ' '
                      << side->node(8)+1 << ' '
                      << side->node(7)+1 << '

                      << side->node(4)+1 << ' '
                      << side->node(1)+1 << ' '
                      << side->node(5)+1 << ' '
                      << side->node(8)+1 << '

                      << side->node(7)+1 << ' '
                      << side->node(8)+1 << ' '
                      << side->node(6)+1 << ' '
                      << side->node(3)+1 << '

                      << side->node(8)+1 << ' '
                      << side->node(5)+1 << ' '
                      << side->node(2)+1 << ' '
                      << side->node(6)+1 << ';
                }
            }
  }
  
          

  {
    for(unsigned int e=0; e<mesh.n_elem(); e++)
      if (mesh.elem(e)->active())
        for (unsigned int s=0; s<mesh.elem(e)->n_sides(); s++)
          if (mesh.elem(e)->neighbor(s) == NULL)
            {
              const AutoPtr<Elem> side(mesh.elem(e)->build_side(s));
              
              if ((side->type() == TRI3) ||
                  (side->type() == TRI6)  )

                out << mesh.boundary_info->boundary_id(mesh.elem(e), s)
                    << ';
            }

    
    for(unsigned int e=0; e<mesh.n_elem(); e++)
      if (mesh.elem(e)->active())
        for (unsigned int s=0; s<mesh.elem(e)->n_sides(); s++)
          if (mesh.elem(e)->neighbor(s) == NULL)
            {
              const AutoPtr<Elem> side(mesh.elem(e)->build_side(s));
              
              if ((side->type() == QUAD4)  ||
                  (side->type() == QUAD8) ||
                  (side->type() == QUAD9)  )
                
                out << mesh.boundary_info->boundary_id(mesh.elem(e), s);
            }
  }


  
  for (unsigned int e=0; e<mesh.n_elem(); e++)
    if (mesh.elem(e)->active())
      {
        if (mesh.elem(e)->type() == TET4)
          {
            out << mesh.elem(e)->node(0)+1 << ' '
                << mesh.elem(e)->node(1)+1 << ' '
                << mesh.elem(e)->node(2)+1 << ' '
                << mesh.elem(e)->node(3)+1 << ';
          }
        else if (mesh.elem(e)->type() == TET10)
          {
            out << mesh.elem(e)->node(0)+1 << ' '
                << mesh.elem(e)->node(4)+1 << ' '
                << mesh.elem(e)->node(6)+1 << ' '
                << mesh.elem(e)->node(7)+1 << ';
            
            out << mesh.elem(e)->node(4)+1 << ' '
                << mesh.elem(e)->node(1)+1 << ' '
                << mesh.elem(e)->node(5)+1 << ' '
                << mesh.elem(e)->node(8)+1 << ';     
            
          out << mesh.elem(e)->node(6)+1 << ' '
              << mesh.elem(e)->node(5)+1 << ' '
              << mesh.elem(e)->node(2)+1 << ' '
              << mesh.elem(e)->node(9)+1 << ';       
            
          out << mesh.elem(e)->node(7)+1 << ' '
              << mesh.elem(e)->node(8)+1 << ' '
              << mesh.elem(e)->node(9)+1 << ' '
              << mesh.elem(e)->node(3)+1 << ';       
            
          out << mesh.elem(e)->node(4)+1 << ' '
              << mesh.elem(e)->node(8)+1 << ' '
              << mesh.elem(e)->node(6)+1 << ' '
              << mesh.elem(e)->node(7)+1 << ';       
            
          out << mesh.elem(e)->node(4)+1 << ' '
              << mesh.elem(e)->node(5)+1 << ' '
              << mesh.elem(e)->node(6)+1 << ' '
              << mesh.elem(e)->node(8)+1 << ';       
            
          out << mesh.elem(e)->node(6)+1 << ' '
              << mesh.elem(e)->node(5)+1 << ' '
              << mesh.elem(e)->node(9)+1 << ' '
              << mesh.elem(e)->node(8)+1 << ';       
          
          out << mesh.elem(e)->node(6)+1 << ' '
              << mesh.elem(e)->node(8)+1 << ' '
              << mesh.elem(e)->node(9)+1 << ' '
              << mesh.elem(e)->node(7)+1 << ';       
        }
      }


  for (unsigned int e=0; e<mesh.n_elem(); e++)
    if (mesh.elem(e)->active())
      if (mesh.elem(e)->type() == PYRAMID5)
        {
          out << mesh.elem(e)->node(0)+1 << ' '
              << mesh.elem(e)->node(1)+1 << ' '
              << mesh.elem(e)->node(2)+1 << ' '
              << mesh.elem(e)->node(3)+1 << ' '
              << mesh.elem(e)->node(4)+1 << ';
        }



  for (unsigned int e=0; e<mesh.n_elem(); e++)
    if (mesh.elem(e)->active())
      {
        if (mesh.elem(e)->type() == PRISM6)
          {
            out << mesh.elem(e)->node(0)+1 << ' '
                << mesh.elem(e)->node(1)+1 << ' '
                << mesh.elem(e)->node(2)+1 << ' '
                << mesh.elem(e)->node(3)+1 << ' '
                << mesh.elem(e)->node(4)+1 << ' '
                << mesh.elem(e)->node(5)+1 << ';
          }
        else if (mesh.elem(e)->type() == PRISM18)
          {
            libmesh_error();
          }
      }


  for (unsigned int e=0; e<mesh.n_elem(); e++)
    if (mesh.elem(e)->active())
      if ((mesh.elem(e)->type() == HEX8)   ||
          (mesh.elem(e)->type() == HEX20) ||
          (mesh.elem(e)->type() == HEX27)   )
        {
          std::vector<unsigned int> conn;
          for (unsigned int se=0; se<mesh.elem(e)->n_sub_elem(); se++)
            {
              mesh.elem(e)->connectivity(se, TECPLOT, conn);

              out << conn[0] << ' '
                  << conn[1] << ' '
                  << conn[2] << ' '
                  << conn[3] << ' '
                  << conn[4] << ' '
                  << conn[5] << ' '
                  << conn[6] << ' '
                  << conn[7] << ';
            }
        }
}

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Protected Member Functions
Private Member Functions
Detailed Description
Constructor & Destructor Documentation
DivaIO::DivaIO (const MeshBase &mesh) [inline]Note that only writing diva files is supported since Diva is not a mesh generator.
Member Function Documentation
const MeshBase & MeshOutput< MeshBase >::mesh () const [protected, inherited]Returns the object as a read-only reference.
void DivaIO::write (const std::string &fname) [virtual]This method implements writing a mesh to a specified file.
virtual void MeshOutput< MeshBase >::write_equation_systems (const std::string &, const EquationSystems &) [virtual, inherited]This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object.
virtual void 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.
void 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.
Author

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