Poster of Linux kernelThe best gift for a Linux geek
OFFIO

OFFIO

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

NAME

OFFIO -  

SYNOPSIS


#include <off_io.h>

Inherits MeshInput< MeshBase >.  

Public Member Functions


OFFIO (MeshBase &)

virtual void read (const std::string &name)
 

Protected Member Functions


MeshBase & mesh ()

void skip_comment_lines (std::istream &in, const char comment_start)
 

Private Member Functions


virtual void read_stream (std::istream &in)
 

Detailed Description

This class is repsonsible for reading an unstructured, triangulated surface in the standard OFF OOGL format.

Definition at line 40 of file off_io.h.  

Constructor & Destructor Documentation

 

OFFIO::OFFIO (MeshBase &mesh) [inline]Constructor. Takes a non-const Mesh reference which it will fill up with elements.

Definition at line 68 of file off_io.h.

                            :
  MeshInput<MeshBase> (mesh)
{}
 

Member Function Documentation

 

MeshBase & MeshInput< MeshBase >::mesh () [protected, inherited]Returns the object as a writeable reference.

Referenced by GMVIO::_read_materials(), GMVIO::_read_nodes(), GMVIO::_read_one_cell(), GMVIO::add_cell_centered_data(), GMVIO::copy_nodal_solution(), UNVIO::element_in(), TetGenIO::element_in(), UNVIO::element_out(), UNVIO::node_in(), TetGenIO::node_in(), UNVIO::node_out(), XdrIO::read(), VTKIO::read(), GMVIO::read(), ExodusII_IO::read(), LegacyXdrIO::read_ascii(), LegacyXdrIO::read_binary(), UCDIO::read_implementation(), LegacyXdrIO::read_mesh(), GmshIO::read_mesh(), XdrIO::read_serialized_bcs(), XdrIO::read_serialized_connectivity(), XdrIO::read_serialized_nodes(), read_stream(), MatlabIO::read_stream(), VTKIO::solution_to_vtk(), XdrIO::write(), VTKIO::write(), TetGenIO::write(), GMVIO::write_ascii_new_impl(), GMVIO::write_ascii_old_impl(), GMVIO::write_binary(), GMVIO::write_discontinuous_gmv(), UNVIO::write_implementation(), UCDIO::write_implementation(), LegacyXdrIO::write_mesh(), GmshIO::write_mesh(), GmshIO::write_post(), XdrIO::write_serialized_bcs(), XdrIO::write_serialized_connectivity(), XdrIO::write_serialized_nodes(), and LegacyXdrIO::write_soln().  

void OFFIO::read (const std::string &name) [virtual]Reads in an OFF OOGL data file based on the string you pass it.

Implements MeshInput< MeshBase >.

Definition at line 33 of file off_io.C.

References read_stream().

Referenced by UnstructuredMesh::read().

{
  std::ifstream in (name.c_str());

  read_stream(in);
}
 

void OFFIO::read_stream (std::istream &in) [private, virtual]Implementation of the read() function. This function is called by the public interface function and implements reading the file.

Definition at line 42 of file off_io.C.

References MeshBase::add_elem(), MeshBase::add_point(), MeshBase::clear(), MeshInput< MeshBase >::mesh(), MeshBase::mesh_dimension(), MeshBase::node_ptr(), libMesh::processor_id(), and DofObject::set_id().

Referenced by read().

{
  // This is a serial-only process for now;
  // the Mesh should be read on processor 0 and
  // broadcast later
  libmesh_assert(libMesh::processor_id() == 0);

  // Get a reference to the mesh
  MeshBase& mesh = MeshInput<MeshBase>::mesh();
  
  // Clear any existing mesh data
  mesh.clear();
  
  // STL only works in 2D
  libmesh_assert (mesh.mesh_dimension() == 2);

  // Check the input buffer
  libmesh_assert (in.good());

  unsigned int nn, ne, nf;

  std::string label;

  // Read the first string.  It should say 'OFF'
  in >> label;

  libmesh_assert (label == 'OFF');

  // read the number of nodes, faces, and edges
  in >> nn >> nf >> ne;

  // resize local vectors.
  //  _nodes.resize(nn);
  //_elements.resize(nf);

  
  Real x=0., y=0., z=0.;
  
  // Read the nodes
  for (unsigned int n=0; n<nn; n++)
    {
      libmesh_assert (in.good());

      in >> x
         >> y
         >> z;
      
      mesh.add_point ( Point(x,y,z), n );
    }

  unsigned int dummy, n0, n1, n2;
  
  // Read the triangles
  for (unsigned int e=0; e<nf; e++)
    {
      libmesh_assert (in.good());
      
      // _elements[e] = new Tri3;
      // _elements[e]->set_id (e);
      Elem* elem = new Tri3;
      elem->set_id(e);
      mesh.add_elem (elem);

      // The number of nodes in the object
      in >> dummy;

      libmesh_assert (dummy == 3);

      in >> n0
         >> n1
         >> n2;
      
      elem->set_node(0) = mesh.node_ptr(n0);
      elem->set_node(1) = mesh.node_ptr(n1);
      elem->set_node(2) = mesh.node_ptr(n2);
    }  
}
 

void MeshInput< MeshBase >::skip_comment_lines (std::istream &in, const charcomment_start) [protected, inherited]Reads input from in, skipping all the lines that start with the character comment_start.

Referenced by TetGenIO::read(), and UCDIO::read_implementation().

 

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
OFFIO::OFFIO (MeshBase &mesh) [inline]Constructor. Takes a non-const Mesh reference which it will fill up with elements.
Member Function Documentation
MeshBase & MeshInput< MeshBase >::mesh () [protected, inherited]Returns the object as a writeable reference.
void OFFIO::read (const std::string &name) [virtual]Reads in an OFF OOGL data file based on the string you pass it.
void OFFIO::read_stream (std::istream &in) [private, virtual]Implementation of the read() function. This function is called by the public interface function and implements reading the file.
void MeshInput< MeshBase >::skip_comment_lines (std::istream &in, const charcomment_start) [protected, inherited]Reads input from in, skipping all the lines that start with the character comment_start.
Author

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