35 #ifdef LIBMESH_HAVE_GZSTREAM 37 # include "gzstream.h" 54 std::map<ElemType, std::string> ret;
70 std::map<std::string, ElemType> ret;
84 if (file_name.rfind(
".gz") < file_name.size())
86 #ifdef LIBMESH_HAVE_GZSTREAM 87 igzstream in_stream (file_name.c_str());
90 libmesh_error_msg(
"ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
96 std::ifstream in_stream (file_name.c_str());
105 if (file_name.rfind(
".gz") < file_name.size())
107 #ifdef LIBMESH_HAVE_GZSTREAM 108 ogzstream out_stream (file_name.c_str());
111 libmesh_error_msg(
"ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
117 std::ofstream out_stream (file_name.c_str());
132 libmesh_assert (in.good());
142 unsigned int nNodes=0, nElem=0, dummy=0;
158 for (
unsigned int i=0; i<nNodes; i++)
160 libmesh_assert (in.good());
178 unsigned int material_id=0, node=0;
181 for (
unsigned int i=0; i<nElem; i++)
183 libmesh_assert (in.good());
193 libmesh_error_msg(
"Unsupported element type = " << type);
198 for (
unsigned int n=0; n<elem->
n_nodes(); n++)
200 libmesh_assert (in.good());
214 elem->
subdomain_id() = cast_int<subdomain_id_type>(material_id);
222 for (
unsigned char i=0; i!=4; ++i)
228 libmesh_error_msg(
"Cannot open dimension " \
230 <<
" mesh file when configured without " \
241 libmesh_assert (out_stream.good());
247 libmesh_error_msg(
"Error: Can't write boundary elements for meshes of dimension less than 3. " \
267 libmesh_assert (out_stream.good());
269 out_stream <<
"# For a description of the UCD format see the AVS Developer's guide.\n" 290 libmesh_assert (out_stream.good());
292 out_stream << n++ <<
"\t";
293 node->write_unformatted(out_stream);
308 libmesh_assert (out_stream.good());
311 const ElemType etype = elem->type();
314 libmesh_error_msg(
"Error: Unsupported ElemType " << etype <<
" for UCDIO.");
317 out_stream << e++ <<
" " << elem->subdomain_id() <<
" " << it->second <<
"\t";
318 elem->write_connectivity(out_stream,
UCD);
325 const std::vector<Number> & soln,
326 const std::vector<std::string> & names)
336 std::ofstream out_stream(fname.c_str());
343 cast_int<unsigned int>(names.size()));
359 const std::vector<std::string> & names,
360 const std::vector<Number> & soln)
362 libmesh_assert (out_stream.good());
365 out_stream << names.size();
366 for (std::size_t i = 0; i < names.size(); i++)
368 libmesh_assert (out_stream.good());
372 out_stream << std::endl;
376 for (
const auto &
name : names)
378 libmesh_assert (out_stream.good());
379 out_stream <<
name <<
", dummy" << std::endl;
384 std::size_t nv = names.size();
387 libmesh_assert (out_stream.good());
390 for (std::size_t var = 0; var != nv; var++)
392 std::size_t
idx = nv*(n-1) + var;
394 out_stream <<
" " << soln[
idx];
396 out_stream << std::endl;
std::string name(const ElemQuality q)
virtual void read(const std::string &) override
virtual Node *& set_node(const unsigned int i)
The base class for all geometric element types.
void write_soln(std::ostream &out, const MeshBase &mesh, const std::vector< std::string > &names, const std::vector< Number > &soln)
static std::map< ElemType, std::string > _writing_element_map
const unsigned int n_vars
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
void read_implementation(std::istream &in_stream)
virtual SimpleRange< element_iterator > element_ptr_range()=0
virtual unsigned int n_nodes() const =0
virtual Elem * add_elem(Elem *e)=0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
static std::map< ElemType, std::string > build_writing_element_map()
virtual SimpleRange< node_iterator > node_ptr_range()=0
void set_mesh_dimension(unsigned char d)
subdomain_id_type subdomain_id() const
virtual unsigned short dim() const =0
void write_nodes(std::ostream &out, const MeshBase &mesh)
static std::map< std::string, ElemType > build_reading_element_map()
unsigned int mesh_dimension() const
void write_interior_elems(std::ostream &out, const MeshBase &mesh)
void write_implementation(std::ostream &out_stream)
static std::map< std::string, ElemType > _reading_element_map
virtual dof_id_type n_elem() const =0
virtual const Node * node_ptr(const dof_id_type i) const =0
processor_id_type processor_id() const
virtual void write_nodal_data(const std::string &fname, const std::vector< Number > &soln, const std::vector< std::string > &names) override
virtual void write(const std::string &) override
A geometric point in (x,y,z) space.
virtual dof_id_type n_nodes() const =0
void write_header(std::ostream &out, const MeshBase &mesh, dof_id_type n_elems, unsigned int n_vars)