libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
libMesh::UCDIO Class Reference

This class implements reading & writing meshes in the AVS's UCD format. More...

#include <ucd_io.h>

Inheritance diagram for libMesh::UCDIO:
[legend]

Public Member Functions

 UCDIO (MeshBase &mesh)
 Constructor. More...
 
 UCDIO (const MeshBase &mesh)
 Constructor. More...
 
virtual void read (const std::string &) libmesh_override
 This method implements reading a mesh from a specified file in UCD format. More...
 
virtual void write (const std::string &) libmesh_override
 This method implements writing a mesh to a specified file in UCD format. More...
 
virtual void write_nodal_data (const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) libmesh_override
 This method implements writing a mesh and solution to a specified file in UCD format. More...
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=libmesh_nullptr)
 This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 

Protected Member Functions

MeshBasemesh ()
 
void set_n_partitions (unsigned int n_parts)
 Sets the number of partitions in the mesh. More...
 
void skip_comment_lines (std::istream &in, const char comment_start)
 Reads input from in, skipping all the lines that start with the character comment_start. More...
 
const MeshBasemesh () const
 

Protected Attributes

std::vector< bool > elems_of_dimension
 A vector of bools describing what dimension elements have been encountered when reading a mesh. More...
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable. More...
 
const bool _serial_only_needed_on_proc_0
 Flag specifying whether this format can be written by only serializing the mesh to processor zero. More...
 

Private Member Functions

void read_implementation (std::istream &in_stream)
 The actual implementation of the read function. More...
 
void write_implementation (std::ostream &out_stream)
 The actual implementation of the write function. More...
 
void write_header (std::ostream &out, const MeshBase &mesh, dof_id_type n_elems, unsigned int n_vars)
 Write UCD format header. More...
 
void write_nodes (std::ostream &out, const MeshBase &mesh)
 Write node information. More...
 
void write_interior_elems (std::ostream &out, const MeshBase &mesh)
 Write element information. More...
 
void write_soln (std::ostream &out, const MeshBase &mesh, const std::vector< std::string > &names, const std::vector< Number > &soln)
 Writes all nodal solution variables. More...
 

Static Private Member Functions

static std::map< ElemType, std::string > build_writing_element_map ()
 
static std::map< std::string, ElemTypebuild_reading_element_map ()
 

Static Private Attributes

static std::map< ElemType, std::string > _writing_element_map = UCDIO::build_writing_element_map()
 
static std::map< std::string, ElemType_reading_element_map = UCDIO::build_reading_element_map()
 

Detailed Description

This class implements reading & writing meshes in the AVS's UCD format.

Author
Benjamin S. Kirk
Date
2004

Definition at line 44 of file ucd_io.h.

Constructor & Destructor Documentation

libMesh::UCDIO::UCDIO ( MeshBase mesh)
explicit

Constructor.

Takes a writable reference to a mesh object. This is the constructor required to read a mesh.

Definition at line 54 of file ucd_io.h.

54  :
55  MeshInput<MeshBase> (mesh),
56  MeshOutput<MeshBase>(mesh)
57  {}
libMesh::UCDIO::UCDIO ( const MeshBase mesh)
explicit

Constructor.

Takes a reference to a constant mesh object. This constructor will only allow us to write the mesh.

Definition at line 64 of file ucd_io.h.

References libMesh::MeshInput< MeshBase >::mesh(), n_vars, libMesh::out, read(), read_implementation(), write(), write_header(), write_implementation(), write_interior_elems(), write_nodal_data(), write_nodes(), and write_soln().

64  :
65  MeshOutput<MeshBase> (mesh)
66  {}

Member Function Documentation

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

std::map< std::string, ElemType > libMesh::UCDIO::build_reading_element_map ( )
staticprivate

Definition at line 64 of file ucd_io.C.

References libMesh::EDGE2, libMesh::HEX8, libMesh::PRISM6, libMesh::PYRAMID5, libMesh::QUAD4, libMesh::TET4, and libMesh::TRI3.

65 {
66  std::map<std::string, ElemType> ret;
67  ret["edge"] = EDGE2;
68  ret["tri"] = TRI3;
69  ret["quad"] = QUAD4;
70  ret["tet"] = TET4;
71  ret["hex"] = HEX8;
72  ret["prism"] = PRISM6;
73  ret["pyramid"] = PYRAMID5;
74  return ret;
75 }
std::map< ElemType, std::string > libMesh::UCDIO::build_writing_element_map ( )
staticprivate

Definition at line 48 of file ucd_io.C.

References libMesh::EDGE2, libMesh::HEX8, libMesh::PRISM6, libMesh::PYRAMID5, libMesh::QUAD4, libMesh::TET4, and libMesh::TRI3.

49 {
50  std::map<ElemType, std::string> ret;
51  ret[EDGE2] = "edge";
52  ret[TRI3] = "tri";
53  ret[QUAD4] = "quad";
54  ret[TET4] = "tet";
55  ret[HEX8] = "hex";
56  ret[PRISM6] = "prism";
57  ret[PYRAMID5] = "pyramid";
58  return ret;
59 }
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::XdrIO::read_header(), 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(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), 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(), write_implementation(), libMesh::GmshIO::write_mesh(), 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().

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
protectedinherited
void libMesh::UCDIO::read ( const std::string &  file_name)
virtual

This method implements reading a mesh from a specified file in UCD format.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 78 of file ucd_io.C.

References read_implementation().

Referenced by libMesh::NameBasedIO::read(), and UCDIO().

79 {
80  if (file_name.rfind(".gz") < file_name.size())
81  {
82 #ifdef LIBMESH_HAVE_GZSTREAM
83  igzstream in_stream (file_name.c_str());
84  this->read_implementation (in_stream);
85 #else
86  libmesh_error_msg("ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
87 #endif
88  }
89 
90  else
91  {
92  std::ifstream in_stream (file_name.c_str());
93  this->read_implementation (in_stream);
94  }
95 }
void read_implementation(std::istream &in_stream)
The actual implementation of the read function.
Definition: ucd_io.C:120
void libMesh::UCDIO::read_implementation ( std::istream &  in_stream)
private

The actual implementation of the read function.

The public read interface simply decides which type of stream to pass the implementation.

Definition at line 120 of file ucd_io.C.

References _reading_element_map, libMesh::Elem::build(), libMesh::Elem::dim(), libMesh::MeshInput< MeshBase >::elems_of_dimension, libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::Elem::n_nodes(), libMesh::processor_id(), libMesh::DofObject::set_id(), libMesh::Elem::set_node(), libMesh::MeshInput< MeshBase >::skip_comment_lines(), and libMesh::Elem::subdomain_id().

Referenced by read(), and UCDIO().

121 {
122  // This is a serial-only process for now;
123  // the Mesh should be read on processor 0 and
124  // broadcast later
125  libmesh_assert_equal_to (MeshOutput<MeshBase>::mesh().processor_id(), 0);
126 
127  // Check input buffer
128  libmesh_assert (in.good());
129 
130  MeshBase & mesh = MeshInput<MeshBase>::mesh();
131 
132  // Keep track of what kinds of elements this file contains
133  elems_of_dimension.clear();
134  elems_of_dimension.resize(4, false);
135 
136  this->skip_comment_lines (in, '#');
137 
138  unsigned int nNodes=0, nElem=0, dummy=0;
139 
140  in >> nNodes // Read the number of nodes from the stream
141  >> nElem // Read the number of elements from the stream
142  >> dummy
143  >> dummy
144  >> dummy;
145 
146 
147  // Read the nodal coordinates. Note that UCD format always
148  // stores (x,y,z), and in 2D z=0. We don't need to store this,
149  // however. So, we read in x,y,z for each node and make a point
150  // in the proper way based on what dimension we're in
151  {
152  Point xyz;
153 
154  for (unsigned int i=0; i<nNodes; i++)
155  {
156  libmesh_assert (in.good());
157 
158  in >> dummy // Point number
159  >> xyz(0) // x-coordinate value
160  >> xyz(1) // y-coordinate value
161  >> xyz(2); // z-coordinate value
162 
163  // Build the node
164  mesh.add_point (xyz, i);
165  }
166  }
167 
168  // Read the elements from the stream. Notice that the UCD node-numbering
169  // scheme is 1-based, and we just created a 0-based scheme above
170  // (which is of course what we want). So, when we read in the nodal
171  // connectivity for each element we need to take 1 off the value of
172  // each node so that we get the right thing.
173  {
174  unsigned int material_id=0, node=0;
175  std::string type;
176 
177  for (unsigned int i=0; i<nElem; i++)
178  {
179  libmesh_assert (in.good());
180 
181  // The cell type can be either tri, quad, tet, hex, or prism.
182  in >> dummy // Cell number, means nothing to us
183  >> material_id // We'll use this for the element subdomain id.
184  >> type; // string describing cell type
185 
186  // Convert the UCD type string to a libmesh ElementType
187  std::map<std::string, ElemType>::iterator it = _reading_element_map.find(type);
188  if (it == _reading_element_map.end())
189  libmesh_error_msg("Unsupported element type = " << type);
190 
191  // Build the required type and release it into our custody.
192  Elem * elem = Elem::build(it->second).release();
193 
194  for (unsigned int n=0; n<elem->n_nodes(); n++)
195  {
196  libmesh_assert (in.good());
197 
198  in >> node; // read the current node
199  node -= 1; // UCD is 1-based, so subtract
200 
201  libmesh_assert_less (node, mesh.n_nodes());
202 
203  // assign the node
204  elem->set_node(n) = mesh.node_ptr(node);
205  }
206 
207  elems_of_dimension[elem->dim()] = true;
208 
209  // Set the element's subdomain ID based on the material_id.
210  elem->subdomain_id() = cast_int<subdomain_id_type>(material_id);
211 
212  // Add the element to the mesh
213  elem->set_id(i);
214  mesh.add_elem (elem);
215  }
216 
217  // Set the mesh dimension to the largest encountered for an element
218  for (unsigned char i=0; i!=4; ++i)
219  if (elems_of_dimension[i])
220  mesh.set_mesh_dimension(i);
221 
222 #if LIBMESH_DIM < 3
223  if (mesh.mesh_dimension() > LIBMESH_DIM)
224  libmesh_error_msg("Cannot open dimension " \
225  << mesh.mesh_dimension() \
226  << " mesh file when configured without " \
227  << mesh.mesh_dimension() \
228  << "D support.");
229 #endif
230  }
231 }
static UniquePtr< Elem > build(const ElemType type, Elem *p=libmesh_nullptr)
Definition: elem.C:238
std::vector< bool > elems_of_dimension
A vector of bools describing what dimension elements have been encountered when reading a mesh...
Definition: mesh_input.h:97
const MeshBase & mesh() const
void skip_comment_lines(std::istream &in, const char comment_start)
Reads input from in, skipping all the lines that start with the character comment_start.
libmesh_assert(j)
static std::map< std::string, ElemType > _reading_element_map
Definition: ucd_io.h:145
processor_id_type processor_id()
Definition: libmesh_base.h:96
void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
protectedinherited

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

91 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1329
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 read_implementation().

void libMesh::UCDIO::write ( const std::string &  file_name)
virtual

This method implements writing a mesh to a specified file in UCD format.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 99 of file ucd_io.C.

References write_implementation().

Referenced by UCDIO(), and libMesh::NameBasedIO::write().

100 {
101  if (file_name.rfind(".gz") < file_name.size())
102  {
103 #ifdef LIBMESH_HAVE_GZSTREAM
104  ogzstream out_stream (file_name.c_str());
105  this->write_implementation (out_stream);
106 #else
107  libmesh_error_msg("ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
108 #endif
109  }
110 
111  else
112  {
113  std::ofstream out_stream (file_name.c_str());
114  this->write_implementation (out_stream);
115  }
116 }
void write_implementation(std::ostream &out_stream)
The actual implementation of the write function.
Definition: ucd_io.C:235
virtual void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  ,
const EquationSystems ,
const std::set< std::string > *  system_names = libmesh_nullptr 
)
virtualinherited

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

void libMesh::UCDIO::write_header ( std::ostream &  out,
const MeshBase mesh,
dof_id_type  n_elems,
unsigned int  n_vars 
)
private

Write UCD format header.

Definition at line 258 of file ucd_io.C.

References libMesh::libmesh_assert(), and libMesh::MeshBase::n_nodes().

Referenced by UCDIO(), write_implementation(), and write_nodal_data().

262 {
263  libmesh_assert (out_stream.good());
264  // TODO: We could print out the libmesh revision used to write this file here.
265  out_stream << "# For a description of the UCD format see the AVS Developer's guide.\n"
266  << "#\n";
267 
268  // Write the mesh info
269  out_stream << mesh.n_nodes() << " "
270  << n_elems << " "
271  << n_vars << " "
272  << " 0 0\n";
273 }
const unsigned int n_vars
Definition: tecplot_io.C:68
libmesh_assert(j)
virtual dof_id_type n_nodes() const =0
void libMesh::UCDIO::write_implementation ( std::ostream &  out_stream)
private

The actual implementation of the write function.

The public write interface simply decides which type of stream to pass the implementation.

Definition at line 235 of file ucd_io.C.

References libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), write_header(), write_interior_elems(), and write_nodes().

Referenced by UCDIO(), and write().

236 {
237  libmesh_assert (out_stream.good());
238 
239  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
240 
241  // UCD doesn't work any dimension except 3?
242  if (mesh.mesh_dimension() != 3)
243  libmesh_error_msg("Error: Can't write boundary elements for meshes of dimension less than 3. " \
244  << "Mesh dimension = " << mesh.mesh_dimension());
245 
246  // Write header
247  this->write_header(out_stream, mesh, mesh.n_elem(), 0);
248 
249  // Write the node coordinates
250  this->write_nodes(out_stream, mesh);
251 
252  // Write the elements
253  this->write_interior_elems(out_stream, mesh);
254 }
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
void write_nodes(std::ostream &out, const MeshBase &mesh)
Write node information.
Definition: ucd_io.C:277
void write_interior_elems(std::ostream &out, const MeshBase &mesh)
Write element information.
Definition: ucd_io.C:295
void write_header(std::ostream &out, const MeshBase &mesh, dof_id_type n_elems, unsigned int n_vars)
Write UCD format header.
Definition: ucd_io.C:258
void libMesh::UCDIO::write_interior_elems ( std::ostream &  out,
const MeshBase mesh 
)
private

Write element information.

Definition at line 295 of file ucd_io.C.

References _writing_element_map, libMesh::MeshBase::element_ptr_range(), libMesh::libmesh_assert(), and libMesh::UCD.

Referenced by UCDIO(), write_implementation(), and write_nodal_data().

297 {
298  // 1-based element number for UCD
299  unsigned int e=1;
300 
301  // Write element information
302  for (const auto & elem : mesh.element_ptr_range())
303  {
304  libmesh_assert (out_stream.good());
305 
306  // Look up the corresponding UCD element type in the static map.
307  const ElemType etype = elem->type();
308  std::map<ElemType, std::string>::iterator it = _writing_element_map.find(etype);
309  if (it == _writing_element_map.end())
310  libmesh_error_msg("Error: Unsupported ElemType " << etype << " for UCDIO.");
311 
312  // Write the element's subdomain ID as the UCD "material_id".
313  out_stream << e++ << " " << elem->subdomain_id() << " " << it->second << "\t";
314  elem->write_connectivity(out_stream, UCD);
315  }
316 }
ElemType
Defines an enum for geometric element types.
static std::map< ElemType, std::string > _writing_element_map
Definition: ucd_io.h:141
libmesh_assert(j)
virtual SimpleRange< element_iterator > element_ptr_range()=0
void libMesh::UCDIO::write_nodal_data ( const std::string &  fname,
const std::vector< Number > &  soln,
const std::vector< std::string > &  names 
)
virtual

This method implements writing a mesh and solution to a specified file in UCD format.

This is internally called by MeshOutput::write_equation_systems

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 320 of file ucd_io.C.

References libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::mesh_dimension(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), libMesh::ParallelObject::processor_id(), write_header(), write_interior_elems(), write_nodes(), and write_soln().

Referenced by UCDIO(), and libMesh::NameBasedIO::write_nodal_data().

323 {
324  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
325 
326  const dof_id_type n_elem = mesh.n_elem();
327 
328  // Only processor 0 does the writing
329  if (mesh.processor_id())
330  return;
331 
332  std::ofstream out_stream(fname.c_str());
333 
334  // UCD doesn't work in 1D
335  libmesh_assert (mesh.mesh_dimension() != 1);
336 
337  // Write header
338  this->write_header(out_stream,mesh,n_elem,
339  cast_int<unsigned int>(names.size()));
340 
341  // Write the node coordinates
342  this->write_nodes(out_stream, mesh);
343 
344  // Write the elements
345  this->write_interior_elems(out_stream, mesh);
346 
347  // Write the solution
348  this->write_soln(out_stream, mesh, names, soln);
349 }
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).
Definition: mesh_tools.C:656
void write_soln(std::ostream &out, const MeshBase &mesh, const std::vector< std::string > &names, const std::vector< Number > &soln)
Writes all nodal solution variables.
Definition: ucd_io.C:353
const MT & mesh() const
Definition: mesh_output.h:216
libmesh_assert(j)
void write_nodes(std::ostream &out, const MeshBase &mesh)
Write node information.
Definition: ucd_io.C:277
void write_interior_elems(std::ostream &out, const MeshBase &mesh)
Write element information.
Definition: ucd_io.C:295
uint8_t dof_id_type
Definition: id_types.h:64
void write_header(std::ostream &out, const MeshBase &mesh, dof_id_type n_elems, unsigned int n_vars)
Write UCD format header.
Definition: ucd_io.C:258
virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const NumericVector< Number > &  ,
const std::vector< std::string > &   
)
virtualinherited

This method should be overridden by "parallel" output formats for writing nodal data.

Instead of getting a localized copy of the nodal solution vector, it is passed a NumericVector of type=PARALLEL which is in node-major order i.e. (u0,v0,w0, u1,v1,w1, u2,v2,w2, u3,v3,w3, ...) and contains n_nodes*n_vars total entries. Then, it is up to the individual I/O class to extract the required solution values from this vector and write them in parallel.

If not implemented, localizes the parallel vector into a std::vector and calls the other version of this function.

Reimplemented in libMesh::Nemesis_IO.

void libMesh::UCDIO::write_nodes ( std::ostream &  out,
const MeshBase mesh 
)
private

Write node information.

Definition at line 277 of file ucd_io.C.

References libMesh::libmesh_assert(), and libMesh::MeshBase::node_ptr_range().

Referenced by UCDIO(), write_implementation(), and write_nodal_data().

279 {
280  // 1-based node number for UCD
281  unsigned int n=1;
282 
283  // Write the node coordinates
284  for (auto & node : mesh.node_ptr_range())
285  {
286  libmesh_assert (out_stream.good());
287 
288  out_stream << n++ << "\t";
289  node->write_unformatted(out_stream);
290  }
291 }
libmesh_assert(j)
virtual SimpleRange< node_iterator > node_ptr_range()=0
void libMesh::UCDIO::write_soln ( std::ostream &  out,
const MeshBase mesh,
const std::vector< std::string > &  names,
const std::vector< Number > &  soln 
)
private

Writes all nodal solution variables.

Definition at line 353 of file ucd_io.C.

References libMesh::MeshTools::Generation::Private::idx(), libMesh::libmesh_assert(), and libMesh::MeshBase::n_nodes().

Referenced by UCDIO(), and write_nodal_data().

357 {
358  libmesh_assert (out_stream.good());
359 
360  // First write out how many variables and how many components per variable
361  out_stream << names.size();
362  for (std::size_t i = 0; i < names.size(); i++)
363  {
364  libmesh_assert (out_stream.good());
365  // Each named variable has only 1 component
366  out_stream << " 1";
367  }
368  out_stream << std::endl;
369 
370  // Now write out variable names and units. Since we don't store units
371  // We just write out dummy.
372  {
373  std::vector<std::string>::const_iterator var = names.begin();
374  for (; var != names.end(); ++var)
375  {
376  libmesh_assert (out_stream.good());
377  out_stream << *var << ", dummy" << std::endl;
378  }
379  }
380 
381  // Now, for each node, write out the solution variables.
382  // We use a 1-based node numbering for UCD.
383  std::size_t nv = names.size();
384  for (std::size_t n = 1; n <= mesh.n_nodes(); n++)
385  {
386  libmesh_assert (out_stream.good());
387  out_stream << n;
388 
389  for (std::size_t var = 0; var != nv; var++)
390  {
391  std::size_t idx = nv*(n-1) + var;
392 
393  out_stream << " " << soln[idx];
394  }
395  out_stream << std::endl;
396  }
397 }
libmesh_assert(j)
virtual dof_id_type n_nodes() const =0
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.

Member Data Documentation

const bool libMesh::MeshOutput< MeshBase >::_is_parallel_format
protectedinherited

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 141 of file mesh_output.h.

Referenced by libMesh::FroIO::write(), libMesh::PostscriptIO::write(), and libMesh::EnsightIO::write().

std::map< std::string, ElemType > libMesh::UCDIO::_reading_element_map = UCDIO::build_reading_element_map()
staticprivate

Definition at line 145 of file ucd_io.h.

Referenced by read_implementation().

const bool libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
protectedinherited

Flag specifying whether this format can be written by only serializing the mesh to processor zero.

If this is false (default) the mesh will be serialized to all processors

Definition at line 150 of file mesh_output.h.

std::map< ElemType, std::string > libMesh::UCDIO::_writing_element_map = UCDIO::build_writing_element_map()
staticprivate

Definition at line 141 of file ucd_io.h.

Referenced by write_interior_elems().

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited

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