29 #ifdef LIBMESH_HAVE_GZSTREAM
30 # include "gzstream.h"
61 if (file_name.rfind(
".gz") < file_name.size())
63 #ifdef LIBMESH_HAVE_GZSTREAM
64 igzstream in_stream(file_name.c_str());
67 libmesh_error_msg(
"ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
74 std::ifstream in_stream(file_name.c_str());
94 if ( !in_file.good() )
95 libmesh_error_msg(
"ERROR: Input file not good.");
97 const std::string _label_dataset_mesh_data =
"2414";
104 std::string olds, news;
108 in_file >> olds >> news;
116 go_and_find_the_next_dataset:
122 while( ((olds !=
"-1") || (news ==
"-1") ) && !in_file.eof() )
134 if (news == _label_dataset_mesh_data)
143 unsigned int dataset_location;
167 for(
unsigned int i=0; i<3; i++)
168 in_file.ignore(256,
'\n');
176 in_file >> dataset_location;
181 for(
unsigned int i=0; i<6; i++)
182 in_file.ignore(256,
'\n');
187 unsigned int model_type,
195 in_file >> model_type
197 >> data_characteristic
207 for (
unsigned int i=0; i<3; i++)
208 in_file.ignore(256,
'\n');
217 std::string dummy_Real;
218 for (
unsigned int i=0; i<12; i++)
219 in_file >> dummy_Real;
253 goto go_and_find_the_next_dataset;
261 if (dataset_location != 1)
262 libmesh_error_msg(
"ERROR: Currently only Data at nodes is supported.");
269 std::vector<Number> values;
285 values.resize(NVALDC);
290 for (
unsigned int data_cnt=0; data_cnt<NVALDC; data_cnt++)
300 if (data_type == 2 || data_type == 4)
305 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
306 values[data_cnt] =
Complex(std::atof(buf.c_str()), 0.);
308 values[data_cnt] = std::atof(buf.c_str());
312 else if(data_type == 5 || data_type == 6)
315 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
323 re_val = std::atof(buf.c_str());
326 im_val = std::atof(buf.c_str());
330 re_val = std::atof(buf.c_str());
334 values[data_cnt] =
Complex(re_val,im_val);
337 libmesh_error_msg(
"ERROR: Complex data only supported when libMesh is configured with --enable-complex!");
342 libmesh_error_msg(
"ERROR: Data type not supported.");
350 _node_data.insert (std::make_pair(node, values));
399 if (file_name.rfind(
".gz") < file_name.size())
401 #ifdef LIBMESH_HAVE_GZSTREAM
402 ogzstream out_stream(file_name.c_str());
405 libmesh_error_msg(
"ERROR: You must have the zlib.h header files and libraries to read and write compressed streams.");
413 std::ofstream out_stream(file_name.c_str());
430 if ( !out_file.good() )
431 libmesh_error_msg(
"ERROR: Output file not good.");
439 const std::string _label_dataset_mesh_data =
"2414";
447 libMesh::err <<
"WARNING: MeshData currently only supports nodal data for Universal files."
449 <<
" Will proceed writing only nodal data, ignoring element data."
458 << _label_dataset_mesh_data
486 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
497 my_header.
write (out_file);
508 <<
" of attached MeshDataUnvHeader object not valid!" << std::endl
520 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
521 const unsigned int my_data_type = 5;
523 const unsigned int my_data_type = 2;
528 <<
" of attached MeshDataUnvHeader differs from" << std::endl
529 <<
" default value=" << my_data_type
530 <<
" Perhaps the user wanted this," << std::endl
531 <<
" so I use the value from the MeshDataUnvHeader."
541 std::map<
const Node *,
542 std::vector<Number> >::const_iterator nit =
_node_data.begin();
547 const Node * node = (*nit).first;
550 std::sprintf(buf,
"%10u\n", f_n_id);
559 const std::vector<Number> & values = this->
get_data(node);
561 for (
unsigned int v_cnt=0; v_cnt<values.size(); v_cnt++)
563 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
564 std::sprintf(buf,
"%13.5E%13.5E", values[v_cnt].real(),
565 values[v_cnt].imag());
568 std::sprintf(buf,
"%13.5E",
569 static_cast<double>(values[v_cnt]));
593 dataset_name (
"libMesh mesh data"),
594 dataset_location (1),
597 data_characteristic (0),
599 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
653 in_file.ignore(256,
'\n');
657 in_file.ignore(256,
'\n');
660 for (
unsigned int n=0; n<5; n++)
671 for (
unsigned int i=0; i<8; i++)
674 for (
unsigned int i=0; i<2; i++)
690 this->
record_12[0] = std::atof(buf.c_str());
692 for (
unsigned int i=1; i<6; i++)
696 this->
record_12[i] = std::atof(buf.c_str());
699 for (
unsigned int i=0; i<6; i++)
703 this->
record_13[i] = std::atof(buf.c_str());
709 this->
record_12[0] = std::atof(buf.c_str());
711 for (
unsigned int i=1; i<6; i++)
714 for (
unsigned int i=0; i<6; i++)
745 for (
unsigned int n=0; n<5; n++)
748 std::sprintf(buf,
"%10i%10i%10i%10i%10i%10i\n",
754 std::sprintf(buf,
"%10i%10i%10i%10i%10i%10i%10i%10i\n",
763 std::sprintf(buf,
"%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E\n",
773 std::sprintf(buf,
"%13.5E%13.5E%13.5E%13.5E%13.5E%13.5E\n",
792 std::string::size_type position = number.find(
"D",6);
794 if(position!=std::string::npos)
797 number.replace(position,1,
"e");
826 #ifdef LIBMESH_USE_COMPLEX_NUMBERS
837 libMesh::err <<
"WARNING: MeshDataUnvHeader::operator=(): Other object has data_type for" << std::endl
838 <<
" real values. Will use default data_type=5 during assignment." << std::endl
856 libMesh::err <<
"WARNING: Other MeshDataUnvHeader has data_type for complex values." << std::endl
857 <<
" Data import will likely _not_ work and result in infinite loop," << std::endl
858 <<
" provided the user forgot to re-size nvaldc to 2*nvaldc_old!" << std::endl
892 this->nvaldc == omduh.
nvaldc &&
const std::vector< Number > & get_data(const Node *node) const
void read_unv_implementation(std::istream &in_file)
A geometric point in (x,y,z) space associated with a DOF.
const unsigned int invalid_uint
bool has_data(const Node *node) const
libmesh_assert(remote_elem)
const class libmesh_nullptr_t libmesh_nullptr
unsigned int node_to_foreign_id(const Node *n) const
void read_unv(const std::string &file_name)
OStreamProxy err(std::cerr)
std::complex< Real > Complex
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void write_unv(const std::string &file_name)
MeshDataUnvHeader * _unv_header
unsigned int n_val_per_node() const
const Node * foreign_id_to_node(const unsigned int fid) const
std::map< const Node *, std::vector< Number > > _node_data
std::map< const Elem *, std::vector< Number > > _elem_data
void write_unv_implementation(std::ostream &out_file)