libMesh::OFFIO Class Reference

Reads OOF OOGL triangulated surface files. More...

#include <off_io.h>

Inheritance diagram for libMesh::OFFIO:

Public Member Functions

 OFFIO (MeshBase &)
 
virtual void read (const std::string &name) libmesh_override
 

Protected Member Functions

MeshBasemesh ()
 
void set_n_partitions (unsigned int n_parts)
 
void skip_comment_lines (std::istream &in, const char comment_start)
 

Protected Attributes

std::vector< bool > elems_of_dimension
 

Private Member Functions

void read_stream (std::istream &in)
 

Detailed Description

Reads OOF OOGL triangulated surface files.

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

Author
John W. Peterson
Date
2004

Definition at line 39 of file off_io.h.

Constructor & Destructor Documentation

libMesh::OFFIO::OFFIO ( MeshBase mesh_in)
inlineexplicit

Constructor. Takes a non-const Mesh reference which it will fill up with elements.

Definition at line 68 of file off_io.h.

68  :
69  MeshInput<MeshBase> (mesh_in)
70 {}

Member Function Documentation

MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited
Returns
The object as a writable reference.

Referenced by libMesh::GMVIO::_read_one_cell(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::UNVIO::elements_out(), libMesh::UNVIO::groups_in(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::UNVIO::nodes_out(), libMesh::GMVIO::read(), libMesh::ExodusII_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::CheckpointIO::read_header(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::CheckpointIO::read_remote_elem(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), libMesh::UCDIO::UCDIO(), libMesh::VTKIO::VTKIO(), libMesh::TetGenIO::write(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::CheckpointIO::write_bcs(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::UCDIO::write_implementation(), libMesh::GmshIO::write_mesh(), libMesh::UCDIO::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_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), and libMesh::CheckpointIO::write_subdomain_names().

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

Reads in an OFF OOGL data file based on the string you pass it.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 35 of file off_io.C.

References read_stream().

Referenced by libMesh::NameBasedIO::read().

36 {
37  std::ifstream in (name.c_str());
38 
39  read_stream(in);
40 }
std::string name(const ElemQuality q)
Definition: elem_quality.C:39
void read_stream(std::istream &in)
Definition: off_io.C:44
void libMesh::OFFIO::read_stream ( std::istream &  in)
private

Implementation of the read() function. This function is called by the public interface function and implements reading the file.

Definition at line 44 of file off_io.C.

References libMesh::MeshBase::add_elem(), libMesh::MeshBase::add_point(), libMesh::MeshBase::clear(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshBase::node_ptr(), libMesh::processor_id(), libMesh::Real, libMesh::DofObject::set_id(), libMesh::MeshBase::set_mesh_dimension(), libMesh::Elem::set_node(), and libMesh::x.

Referenced by read().

45 {
46  // This is a serial-only process for now;
47  // the Mesh should be read on processor 0 and
48  // broadcast later
49  libmesh_assert_equal_to (this->mesh().processor_id(), 0);
50 
51  // Get a reference to the mesh
52  MeshBase & the_mesh = MeshInput<MeshBase>::mesh();
53 
54  // Clear any existing mesh data
55  the_mesh.clear();
56 
57  // Check the input buffer
58  libmesh_assert (in.good());
59 
60  unsigned int nn, ne, nf;
61 
62  std::string label;
63 
64  // Read the first string. It should say "OFF"
65  in >> label;
66 
67  libmesh_assert_equal_to (label, "OFF");
68 
69  // read the number of nodes, faces, and edges
70  in >> nn >> nf >> ne;
71 
72 
73  Real x=0., y=0., z=0.;
74 
75  // Read the nodes
76  for (unsigned int n=0; n<nn; n++)
77  {
78  libmesh_assert (in.good());
79 
80  in >> x
81  >> y
82  >> z;
83 
84  the_mesh.add_point ( Point(x,y,z), n );
85  }
86 
87  unsigned int nv, nid;
88 
89  // Read the elements
90  for (unsigned int e=0; e<nf; e++)
91  {
92  libmesh_assert (in.good());
93 
94  // The number of vertices in the element
95  in >> nv;
96 
97  libmesh_assert(nv == 2 || nv == 3);
98  if (e == 0)
99  {
100  the_mesh.set_mesh_dimension(cast_int<unsigned char>(nv-1));
101  if (nv == 3)
102  {
103 #if LIBMESH_DIM < 2
104  libmesh_error_msg("Cannot open dimension 2 mesh file when configured without 2D support.");
105 #endif
106  }
107  }
108 
109  Elem * elem;
110  switch (nv)
111  {
112  case 2:
113  elem = new Edge2;
114  break;
115 
116  case 3:
117  elem = new Tri3;
118  break;
119 
120  default:
121  libmesh_error_msg("Unsupported nv = " << nv);
122  }
123 
124  elem->set_id(e);
125  the_mesh.add_elem (elem);
126 
127  for (unsigned int i=0; i<nv; i++)
128  {
129  in >> nid;
130  elem->set_node(i) = the_mesh.node_ptr(nid);
131  }
132  }
133 }
libmesh_assert(j)
PetscErrorCode Vec x
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
processor_id_type processor_id()
Definition: libmesh_base.h:96
void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
inlineprotectedinherited

Sets the number of partitions in the mesh. Typically this gets done by the partitioner, but some parallel file formats begin "pre-partitioned".

Definition at line 91 of file mesh_input.h.

References libMesh::MeshInput< MT >::mesh().

Referenced by libMesh::Nemesis_IO::read(), and libMesh::XdrIO::read().

91 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1302
void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
)
protectedinherited

Reads input from in, skipping all the lines that start with the character comment_start.

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

Member Data Documentation


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