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

This class implements reading and writing meshes in the TetGen format. More...

#include <tetgen_io.h>

Inheritance diagram for libMesh::TetGenIO:
[legend]

Public Member Functions

 TetGenIO (MeshBase &mesh)
 Constructor. More...
 
 TetGenIO (const MeshBase &mesh)
 Constructor. More...
 
virtual void read (const std::string &) override
 This method implements reading a mesh from a specified file in TetGen format. More...
 
virtual void write (const std::string &) override
 This method implements writing a mesh to a specified ".poly" file. More...
 
virtual void write_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=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_discontinuous_equation_systems (const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
 This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object. More...
 
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided. More...
 
virtual void write_nodal_data (const std::string &, const NumericVector< Number > &, const std::vector< std::string > &)
 This method may be overridden by "parallel" output formats for writing nodal data. More...
 
virtual void write_nodal_data (const std::string &, const EquationSystems &, const std::set< std::string > *)
 This method should be overridden by "parallel" output formats for writing nodal data. More...
 
virtual void write_nodal_data_discontinuous (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
 This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided. More...
 
unsigned intascii_precision ()
 Return/set the precision to use when writing ASCII files. More...
 

Public Attributes

std::vector< std::vector< Real > > node_attributes
 Data structure to hold node attributes read in from file. More...
 
std::vector< std::vector< Real > > element_attributes
 Data structure to hold element attributes read in from file. 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_nodes_and_elem (std::istream &node_stream, std::istream &ele_stream)
 Reads a mesh (nodes & elements) from the file provided through node_stream and ele_stream. More...
 
void node_in (std::istream &node_stream)
 Method reads nodes from node_stream and stores them in vector<Node *> nodes in the order they come in. More...
 
void element_in (std::istream &ele_stream)
 Method reads elements and stores them in vector<Elem *> elements in the same order as they come in. More...
 

Private Attributes

std::map< dof_id_type, dof_id_type_assign_nodes
 stores new positions of nodes. More...
 
dof_id_type _num_nodes
 total number of nodes. More...
 
dof_id_type _num_elements
 total number of elements. More...
 
MeshBase_obj
 A pointer to a non-const object object. More...
 
const bool _is_parallel_format
 Flag specifying whether this format is parallel-capable. More...
 
unsigned int _ascii_precision
 Precision to use when writing ASCII files. More...
 

Detailed Description

This class implements reading and writing meshes in the TetGen format.

Format description: cf. TetGen home page.

Author
Benjamin S. Kirk
Date
2004

Definition at line 47 of file tetgen_io.h.

Constructor & Destructor Documentation

◆ TetGenIO() [1/2]

libMesh::TetGenIO::TetGenIO ( MeshBase mesh)
inlineexplicit

Constructor.

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

Definition at line 151 of file tetgen_io.h.

151  :
152  MeshInput<MeshBase> (mesh),
153  MeshOutput<MeshBase>(mesh)
154 {
155 }

◆ TetGenIO() [2/2]

libMesh::TetGenIO::TetGenIO ( const MeshBase mesh)
inlineexplicit

Constructor.

Takes a read-only reference to a mesh object. This is the constructor required to write a mesh.

Definition at line 160 of file tetgen_io.h.

160  :
161  MeshOutput<MeshBase>(mesh)
162 {
163 }

Member Function Documentation

◆ ascii_precision()

unsigned int & libMesh::MeshOutput< MeshBase >::ascii_precision ( )
inlineinherited

Return/set the precision to use when writing ASCII files.

By default we use numeric_limits<Real>::max_digits10, which should be enough to write out to ASCII and get the exact same Real back when reading in.

Definition at line 257 of file mesh_output.h.

258 {
259  return _ascii_precision;
260 }

◆ element_in()

void libMesh::TetGenIO::element_in ( std::istream &  ele_stream)
private

Method reads elements and stores them in vector<Elem *> elements in the same order as they come in.

Within TetGenMeshInterface, element labels are ignored.

Definition at line 184 of file tetgen_io.C.

185 {
186  // Check input buffer
187  libmesh_assert (ele_stream.good());
188 
189  // Get a reference to the mesh
190  MeshBase & mesh = MeshInput<MeshBase>::mesh();
191 
192  // Read the elements from the ele_stream (*.ele file).
193  unsigned int element_lab=0, n_nodes=0, region_attribute=0;
194 
195  ele_stream >> _num_elements // Read the number of tetrahedrons from the stream.
196  >> n_nodes // Read the number of nodes per tetrahedron from the stream (defaults to 4).
197  >> region_attribute; // Read the number of attributes from stream.
198 
199  // According to the Tetgen docs for .ele files:
200  // http://wias-berlin.de/software/tetgen/1.5/doc/manual/manual006.html#ff_ele
201  // region_attribute can either 0 or 1, and specifies whether, for
202  // each tetrahedron, there is an extra integer specifying which
203  // region it belongs to. Normally, this id matches a value in a
204  // corresponding .poly or .smesh file, but here we simply use it to
205  // set the subdomain_id of the element in question.
206  if (region_attribute > 1)
207  libmesh_error_msg("Invalid region_attribute " << region_attribute << " specified in .ele file.");
208 
209  // Vector that assigns element nodes to their correct position.
210  // TetGen is normally 0-based
211  // (right now this is strictly not necessary since it is the identity map,
212  // but in the future TetGen could change their numbering scheme.)
213  static const unsigned int assign_elm_nodes[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
214 
215  for (dof_id_type i=0; i<_num_elements; i++)
216  {
217  libmesh_assert (ele_stream.good());
218 
219  // TetGen only supports Tet4 and Tet10 elements.
220  Elem * elem;
221 
222  if (n_nodes==4)
223  elem = new Tet4;
224 
225  else if (n_nodes==10)
226  elem = new Tet10;
227 
228  else
229  libmesh_error_msg("Elements with " << n_nodes << " nodes are not supported in the LibMesh tetgen module.");
230 
231  elem->set_id(i);
232 
233  mesh.add_elem (elem);
234 
235  libmesh_assert(elem);
236  libmesh_assert_equal_to (elem->n_nodes(), n_nodes);
237 
238  // The first number on the line is the tetrahedron number. We
239  // have previously ignored this, preferring to set our own ids,
240  // but this could be changed to respect the Tetgen numbering if
241  // desired.
242  ele_stream >> element_lab;
243 
244  // Read node labels
245  for (dof_id_type j=0; j<n_nodes; j++)
246  {
247  dof_id_type node_label;
248  ele_stream >> node_label;
249 
250  // Assign node to element
251  elem->set_node(assign_elm_nodes[j]) =
252  mesh.node_ptr(_assign_nodes[node_label]);
253  }
254 
255  // Read the region attribute (if present) and use it to set the subdomain id.
256  if (region_attribute)
257  {
258  unsigned int region;
259  ele_stream >> region;
260 
261  // Make sure that the id we read can be successfully cast to
262  // an integral value of type subdomain_id_type.
263  elem->subdomain_id() = cast_int<subdomain_id_type>(region);
264  }
265  }
266 }

References _assign_nodes, _num_elements, libMesh::MeshBase::add_elem(), libMesh::libmesh_assert(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshInput< MT >::mesh(), n_nodes, and libMesh::MeshBase::node_ptr().

Referenced by read_nodes_and_elem().

◆ mesh() [1/2]

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

Definition at line 169 of file mesh_input.h.

170 {
171  if (_obj == nullptr)
172  libmesh_error_msg("ERROR: _obj should not be nullptr!");
173  return *_obj;
174 }

◆ mesh() [2/2]

const MeshBase & libMesh::MeshOutput< MeshBase >::mesh ( ) const
inlineprotectedinherited
Returns
The object as a read-only reference.

Definition at line 247 of file mesh_output.h.

248 {
250  return *_obj;
251 }

◆ node_in()

void libMesh::TetGenIO::node_in ( std::istream &  node_stream)
private

Method reads nodes from node_stream and stores them in vector<Node *> nodes in the order they come in.

The original node labels are being stored in the map _assign_nodes in order to assign the elements to the right nodes later.

Definition at line 113 of file tetgen_io.C.

114 {
115  // Check input buffer
116  libmesh_assert (node_stream.good());
117 
118  // Get a reference to the mesh
119  MeshBase & mesh = MeshInput<MeshBase>::mesh();
120 
121  unsigned int dimension=0, nAttributes=0, BoundaryMarkers=0;
122 
123  node_stream >> _num_nodes // Read the number of nodes from the stream
124  >> dimension // Read the dimension from the stream
125  >> nAttributes // Read the number of attributes from stream
126  >> BoundaryMarkers; // Read if or not boundary markers are included in *.node (0 or 1)
127 
128  // Read the nodal coordinates from the node_stream (*.node file).
129  unsigned int node_lab=0;
130  Real dummy;
131 
132  // If present, make room for node attributes to be stored.
133  this->node_attributes.resize(nAttributes);
134  for (unsigned i=0; i<nAttributes; ++i)
135  this->node_attributes[i].resize(_num_nodes);
136 
137 
138  for (unsigned int i=0; i<_num_nodes; i++)
139  {
140  // Check input buffer
141  libmesh_assert (node_stream.good());
142 
143  std::array<Real, 3> xyz;
144 
145  node_stream >> node_lab // node number
146  >> xyz[0] // x-coordinate value
147  >> xyz[1] // y-coordinate value
148  >> xyz[2]; // z-coordinate value
149 
150  // Read and store attributes from the stream.
151  for (unsigned int j=0; j<nAttributes; j++)
152  node_stream >> node_attributes[j][i];
153 
154  // Read (and discard) boundary marker if BoundaryMarker=1.
155  // TODO: should we store this somehow?
156  if (BoundaryMarkers == 1)
157  node_stream >> dummy;
158 
159  // Store the new position of the node under its label.
160  //_assign_nodes.insert (std::make_pair(node_lab,i));
161  _assign_nodes[node_lab] = i;
162 
163  Point p(xyz[0]);
164 #if LIBMESH_DIM > 1
165  p(1) = xyz[1];
166 #else
167  libmesh_assert_equal_to(xyz[1], 0);
168 #endif
169 #if LIBMESH_DIM > 2
170  p(2) = xyz[2];
171 #else
172  libmesh_assert_equal_to(xyz[2], 0);
173 #endif
174 
175  // Add this point to the Mesh.
176  mesh.add_point(p, i);
177  }
178 }

References _assign_nodes, _num_nodes, libMesh::MeshBase::add_point(), libMesh::libmesh_assert(), libMesh::MeshInput< MT >::mesh(), libMesh::MeshInput< MeshBase >::mesh(), node_attributes, and libMesh::Real.

Referenced by read_nodes_and_elem().

◆ read()

void libMesh::TetGenIO::read ( const std::string &  name)
overridevirtual

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

Implements libMesh::MeshInput< MeshBase >.

Definition at line 34 of file tetgen_io.C.

35 {
36  // This is a serial-only process for now;
37  // the Mesh should be read on processor 0 and
38  // broadcast later
39  libmesh_assert_equal_to (MeshOutput<MeshBase>::mesh().processor_id(), 0);
40 
41  std::string name_node, name_ele, dummy;
42 
43  // tetgen only works in 3D
44  MeshInput<MeshBase>::mesh().set_mesh_dimension(3);
45 
46 #if LIBMESH_DIM < 3
47  libmesh_error_msg("Cannot open dimension 3 mesh file when configured without 3D support.");
48 #endif
49 
50  // Check name for *.node or *.ele extension.
51  // Set std::istream for node_stream and ele_stream.
52  //
53  if (name.rfind(".node") < name.size())
54  {
55  name_node = name;
56  dummy = name;
57  std::size_t position = dummy.rfind(".node");
58  name_ele = dummy.replace(position, 5, ".ele");
59  }
60  else if (name.rfind(".ele") < name.size())
61  {
62  name_ele = name;
63  dummy = name;
64  std::size_t position = dummy.rfind(".ele");
65  name_node = dummy.replace(position, 4, ".node");
66  }
67  else
68  libmesh_error_msg("ERROR: Unrecognized file name: " << name);
69 
70 
71 
72  // Set the streams from which to read in
73  std::ifstream node_stream (name_node.c_str());
74  std::ifstream ele_stream (name_ele.c_str());
75 
76  if (!node_stream.good() || !ele_stream.good())
77  libmesh_error_msg("Error while opening either " \
78  << name_node \
79  << " or " \
80  << name_ele);
81 
82  libMesh::out<< "TetGenIO found the tetgen files to read " <<std::endl;
83 
84  // Skip the comment lines at the beginning
85  this->skip_comment_lines (node_stream, '#');
86  this->skip_comment_lines (ele_stream, '#');
87 
88  // Read the nodes and elements from the streams
89  this->read_nodes_and_elem (node_stream, ele_stream);
90  libMesh::out<< "TetGenIO read in nodes and elements " <<std::endl;
91 }

References libMesh::MeshInput< MT >::mesh(), libMesh::Quality::name(), libMesh::out, read_nodes_and_elem(), and libMesh::MeshInput< MeshBase >::skip_comment_lines().

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

◆ read_nodes_and_elem()

void libMesh::TetGenIO::read_nodes_and_elem ( std::istream &  node_stream,
std::istream &  ele_stream 
)
private

Reads a mesh (nodes & elements) from the file provided through node_stream and ele_stream.

Definition at line 95 of file tetgen_io.C.

97 {
98  _num_nodes = 0;
99  _num_elements = 0;
100 
101  // Read all the datasets.
102  this->node_in (node_stream);
103  this->element_in (ele_stream);
104 
105  // some more clean-up
106  _assign_nodes.clear();
107 }

References _assign_nodes, _num_elements, _num_nodes, element_in(), and node_in().

Referenced by read().

◆ set_n_partitions()

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.

91 { this->mesh().set_n_partitions() = n_parts; }

◆ skip_comment_lines()

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.

Definition at line 179 of file mesh_input.h.

181 {
182  char c, line[256];
183 
184  while (in.get(c), c==comment_start)
185  in.getline (line, 255);
186 
187  // put back first character of
188  // first non-comment line
189  in.putback (c);
190 }

◆ write()

void libMesh::TetGenIO::write ( const std::string &  fname)
overridevirtual

This method implements writing a mesh to a specified ".poly" file.

".poly" files defines so called Piecewise Linear Complex (PLC).

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 273 of file tetgen_io.C.

274 {
275  // libmesh_assert three dimensions (should be extended later)
276  libmesh_assert_equal_to (MeshOutput<MeshBase>::mesh().mesh_dimension(), 3);
277 
278  if (!(fname.rfind(".poly") < fname.size()))
279  libmesh_error_msg("ERROR: Unrecognized file name: " << fname);
280 
281  // Open the output file stream
282  std::ofstream out_stream (fname.c_str());
283 
284  // Make sure it opened correctly
285  if (!out_stream.good())
286  libmesh_file_error(fname.c_str());
287 
288  // Get a reference to the mesh
289  const MeshBase & mesh = MeshOutput<MeshBase>::mesh();
290 
291  // Begin interfacing with the .poly file
292  {
293  // header:
294  out_stream << "# poly file output generated by libmesh\n"
295  << mesh.n_nodes() << " 3 0 0\n";
296 
297  // write the nodes:
298  for (auto v : IntRange<dof_id_type>(0, mesh.n_nodes()))
299  out_stream << v << " "
300  << mesh.point(v)(0) << " "
301  << mesh.point(v)(1) << " "
302  << mesh.point(v)(2) << "\n";
303  }
304 
305  {
306  // write the connectivity:
307  out_stream << "# Facets:\n"
308  << mesh.n_elem() << " 0\n";
309 
310  for (const auto & elem : mesh.active_element_ptr_range())
311  out_stream << "1\n3 " // no. of facet polygons
312  // << elem->n_nodes() << " "
313  << elem->node_id(0) << " "
314  << elem->node_id(1) << " "
315  << elem->node_id(2) << "\n";
316  }
317 
318  // end of the file
319  out_stream << "0\n"; // no holes output!
320  out_stream << "\n\n# end of file\n";
321 }

References libMesh::MeshBase::active_element_ptr_range(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshOutput< MT >::mesh(), libMesh::MeshBase::n_elem(), libMesh::MeshBase::n_nodes(), and libMesh::MeshBase::point().

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

◆ write_discontinuous_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_discontinuous_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = nullptr 
)
virtualinherited

This method implements writing a mesh with discontinuous data to a specified file where the data is taken from the EquationSystems object.

Definition at line 87 of file mesh_output.C.

90 {
91  LOG_SCOPE("write_discontinuous_equation_systems()", "MeshOutput");
92 
93  // We may need to gather and/or renumber a DistributedMesh to output
94  // it, making that const qualifier in our constructor a dirty lie
95  MT & my_mesh = const_cast<MT &>(*_obj);
96 
97  // If we're asked to write data that's associated with a different
98  // mesh, output files full of garbage are the result.
99  libmesh_assert_equal_to(&es.get_mesh(), _obj);
100 
101  // A non-renumbered mesh may not have a contiguous numbering, and
102  // that needs to be fixed before we can build a solution vector.
103  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
104  my_mesh.max_node_id() != my_mesh.n_nodes())
105  {
106  // If we were allowed to renumber then we should have already
107  // been properly renumbered...
108  libmesh_assert(!my_mesh.allow_renumbering());
109 
110  libmesh_do_once(libMesh::out <<
111  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
112  << std::endl;);
113 
114  my_mesh.allow_renumbering(true);
115 
116  my_mesh.renumber_nodes_and_elements();
117 
118  // Not sure what good going back to false will do here, the
119  // renumbering horses have already left the barn...
120  my_mesh.allow_renumbering(false);
121  }
122 
123  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
124 
125  // Build the list of variable names that will be written.
126  std::vector<std::string> names;
127  es.build_variable_names (names, nullptr, system_names);
128 
129  if (!_is_parallel_format)
130  {
131  // Build the nodal solution values & get the variable
132  // names from the EquationSystems object
133  std::vector<Number> soln;
134  es.build_discontinuous_solution_vector (soln, system_names);
135 
136  this->write_nodal_data_discontinuous (fname, soln, names);
137  }
138  else // _is_parallel_format
139  {
140  libmesh_not_implemented();
141  }
142 }

◆ write_equation_systems()

void libMesh::MeshOutput< MeshBase >::write_equation_systems ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names = 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.

Definition at line 31 of file mesh_output.C.

34 {
35  LOG_SCOPE("write_equation_systems()", "MeshOutput");
36 
37  // We may need to gather and/or renumber a DistributedMesh to output
38  // it, making that const qualifier in our constructor a dirty lie
39  MT & my_mesh = const_cast<MT &>(*_obj);
40 
41  // If we're asked to write data that's associated with a different
42  // mesh, output files full of garbage are the result.
43  libmesh_assert_equal_to(&es.get_mesh(), _obj);
44 
45  // A non-renumbered mesh may not have a contiguous numbering, and
46  // that needs to be fixed before we can build a solution vector.
47  if (my_mesh.max_elem_id() != my_mesh.n_elem() ||
48  my_mesh.max_node_id() != my_mesh.n_nodes())
49  {
50  // If we were allowed to renumber then we should have already
51  // been properly renumbered...
52  libmesh_assert(!my_mesh.allow_renumbering());
53 
54  libmesh_do_once(libMesh::out <<
55  "Warning: This MeshOutput subclass only supports meshes which are contiguously renumbered!"
56  << std::endl;);
57 
58  my_mesh.allow_renumbering(true);
59 
60  my_mesh.renumber_nodes_and_elements();
61 
62  // Not sure what good going back to false will do here, the
63  // renumbering horses have already left the barn...
64  my_mesh.allow_renumbering(false);
65  }
66 
68  {
69  MeshSerializer serialize(const_cast<MT &>(*_obj), !_is_parallel_format, _serial_only_needed_on_proc_0);
70 
71  // Build the list of variable names that will be written.
72  std::vector<std::string> names;
73  es.build_variable_names (names, nullptr, system_names);
74 
75  // Build the nodal solution values & get the variable
76  // names from the EquationSystems object
77  std::vector<Number> soln;
78  es.build_solution_vector (soln, system_names);
79 
80  this->write_nodal_data (fname, soln, names);
81  }
82  else // _is_parallel_format
83  this->write_nodal_data (fname, es, system_names);
84 }

◆ write_nodal_data() [1/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const EquationSystems es,
const std::set< std::string > *  system_names 
)
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 directly uses EquationSystems current_local_solution vectors to look up nodal values.

If not implemented, reorders the solutions into a nodal-only NumericVector and calls the above version of this function.

Reimplemented in libMesh::Nemesis_IO.

Definition at line 158 of file mesh_output.C.

161 {
162  std::vector<std::string> names;
163  es.build_variable_names (names, nullptr, system_names);
164 
165  std::unique_ptr<NumericVector<Number>> parallel_soln =
166  es.build_parallel_solution_vector(system_names);
167 
168  this->write_nodal_data (fname, *parallel_soln, names);
169 }

◆ write_nodal_data() [2/3]

void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  fname,
const NumericVector< Number > &  parallel_soln,
const std::vector< std::string > &  names 
)
virtualinherited

This method may 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.

Definition at line 145 of file mesh_output.C.

148 {
149  // This is the fallback implementation for parallel I/O formats that
150  // do not yet implement proper writing in parallel, and instead rely
151  // on the full solution vector being available on all processors.
152  std::vector<Number> soln;
153  parallel_soln.localize(soln);
154  this->write_nodal_data(fname, soln, names);
155 }

◆ write_nodal_data() [3/3]

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
inlinevirtualinherited

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::Nemesis_IO, libMesh::UCDIO, libMesh::ExodusII_IO, libMesh::GmshIO, libMesh::NameBasedIO, libMesh::GMVIO, libMesh::VTKIO, libMesh::MEDITIO, libMesh::GnuPlotIO, and libMesh::TecplotIO.

Definition at line 105 of file mesh_output.h.

108  { libmesh_not_implemented(); }

◆ write_nodal_data_discontinuous()

virtual void libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous ( const std::string &  ,
const std::vector< Number > &  ,
const std::vector< std::string > &   
)
inlinevirtualinherited

This method implements writing a mesh with discontinuous data to a specified file where the nodal data and variables names are provided.

Reimplemented in libMesh::ExodusII_IO.

Definition at line 114 of file mesh_output.h.

117  { libmesh_not_implemented(); }

Member Data Documentation

◆ _ascii_precision

unsigned int libMesh::MeshOutput< MeshBase >::_ascii_precision
privateinherited

Precision to use when writing ASCII files.

Definition at line 195 of file mesh_output.h.

◆ _assign_nodes

std::map<dof_id_type,dof_id_type> libMesh::TetGenIO::_assign_nodes
private

stores new positions of nodes.

Used when reading.

Definition at line 133 of file tetgen_io.h.

Referenced by element_in(), node_in(), and read_nodes_and_elem().

◆ _is_parallel_format [1/2]

const bool libMesh::MeshInput< MeshBase >::_is_parallel_format
privateinherited

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 121 of file mesh_input.h.

◆ _is_parallel_format [2/2]

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

◆ _num_elements

dof_id_type libMesh::TetGenIO::_num_elements
private

total number of elements.

Primarily used when reading.

Definition at line 143 of file tetgen_io.h.

Referenced by element_in(), and read_nodes_and_elem().

◆ _num_nodes

dof_id_type libMesh::TetGenIO::_num_nodes
private

total number of nodes.

Primarily used when reading.

Definition at line 138 of file tetgen_io.h.

Referenced by node_in(), and read_nodes_and_elem().

◆ _obj

MeshBase * libMesh::MeshInput< MeshBase >::_obj
privateinherited

A pointer to a non-const object object.

This allows us to read the object from file.

Definition at line 114 of file mesh_input.h.

◆ _serial_only_needed_on_proc_0

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

◆ element_attributes

std::vector<std::vector<Real> > libMesh::TetGenIO::element_attributes

Data structure to hold element attributes read in from file.

Note
This vector is no longer filled or used for anything. If region attributes are present in the .ele file, they are used to set the subdomain ids of the elements as they are created.

Definition at line 95 of file tetgen_io.h.

◆ elems_of_dimension

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

A vector of bools describing what dimension elements have been encountered when reading a mesh.

Definition at line 97 of file mesh_input.h.

◆ node_attributes

std::vector<std::vector<Real> > libMesh::TetGenIO::node_attributes

Data structure to hold node attributes read in from file.

What you do with these is up to you!

Definition at line 82 of file tetgen_io.h.

Referenced by node_in().


The documentation for this class was generated from the following files:
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::MeshOutput< MeshBase >::_serial_only_needed_on_proc_0
const bool _serial_only_needed_on_proc_0
Flag specifying whether this format can be written by only serializing the mesh to processor zero.
Definition: mesh_output.h:181
libMesh::MeshBase::set_n_partitions
unsigned int & set_n_partitions()
Definition: mesh_base.h:1667
libMesh::MeshBase::point
virtual const Point & point(const dof_id_type i) const =0
libMesh::MeshInput< MeshBase >::skip_comment_lines
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.
Definition: mesh_input.h:179
libMesh::MeshBase::active_element_ptr_range
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
libMesh::MeshBase::n_elem
virtual dof_id_type n_elem() const =0
libMesh::MeshBase::node_ptr
virtual const Node * node_ptr(const dof_id_type i) const =0
libMesh::TetGenIO::node_attributes
std::vector< std::vector< Real > > node_attributes
Data structure to hold node attributes read in from file.
Definition: tetgen_io.h:82
libMesh::MeshInput< MeshBase >::_obj
MeshBase * _obj
A pointer to a non-const object object.
Definition: mesh_input.h:114
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::NumericVector::localize
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.
libMesh::MeshOutput< MeshBase >::_is_parallel_format
const bool _is_parallel_format
Flag specifying whether this format is parallel-capable.
Definition: mesh_output.h:172
libMesh::TetGenIO::_assign_nodes
std::map< dof_id_type, dof_id_type > _assign_nodes
stores new positions of nodes.
Definition: tetgen_io.h:133
n_nodes
const dof_id_type n_nodes
Definition: tecplot_io.C:68
libMesh::TetGenIO::element_in
void element_in(std::istream &ele_stream)
Method reads elements and stores them in vector<Elem *> elements in the same order as they come in.
Definition: tetgen_io.C:184
libMesh::MeshBase::n_nodes
virtual dof_id_type n_nodes() const =0
libMesh::MeshOutput< MeshBase >::write_nodal_data
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: mesh_output.h:105
libMesh::MeshOutput< MeshBase >::mesh
const MeshBase & mesh() const
Definition: mesh_output.h:247
libMesh::MeshBase::add_elem
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
libMesh::MeshOutput< MeshBase >::write_nodal_data_discontinuous
virtual void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
This method implements writing a mesh with discontinuous data to a specified file where the nodal dat...
Definition: mesh_output.h:114
libMesh::TetGenIO::node_in
void node_in(std::istream &node_stream)
Method reads nodes from node_stream and stores them in vector<Node *> nodes in the order they come in...
Definition: tetgen_io.C:113
libMesh::TetGenIO::_num_nodes
dof_id_type _num_nodes
total number of nodes.
Definition: tetgen_io.h:138
libMesh::MeshInput< MeshBase >::mesh
MeshBase & mesh()
Definition: mesh_input.h:169
libMesh::MeshOutput< MeshBase >::_obj
const MeshBase *const _obj
A pointer to a constant object.
Definition: mesh_output.h:190
libMesh::MeshBase::add_point
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::out
OStreamProxy out
libMesh::TetGenIO::read_nodes_and_elem
void read_nodes_and_elem(std::istream &node_stream, std::istream &ele_stream)
Reads a mesh (nodes & elements) from the file provided through node_stream and ele_stream.
Definition: tetgen_io.C:95
libMesh::TetGenIO::_num_elements
dof_id_type _num_elements
total number of elements.
Definition: tetgen_io.h:143
libMesh::MeshOutput< MeshBase >::_ascii_precision
unsigned int _ascii_precision
Precision to use when writing ASCII files.
Definition: mesh_output.h:195
libMesh::Quality::name
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:42