8 #define ZONEMARKER 299.0
9 #define EOHMARKER 357.0
17 template<
typename T >
21 const unsigned len =
sizeof(
v);
24 for (
unsigned i=0; i<len; ++i)
25 r_buffer[i] = p[len-1-i];
26 for (
unsigned i=0; i<len; ++i)
29 size_t s = fwrite(&v,
sizeof(v),1,F);
37 for (
unsigned i=0; i<v.size(); ++i)
38 bwrite< int >(F,v[i],reverse);
39 bwrite< int >(
F,0,reverse);
43 template<
typename T >
47 F.read((
char*)(&v),
sizeof(
T));
57 const char c = bread< int >(
F);
69 MeshWriter::MeshWriter(
const std::string& fname,
const DataType _datatype,
const bool _reverse,
const unsigned _version,
const double _solutiontime) :
71 m_datatype(_datatype),
74 m_solutiontime(_solutiontime)
77 m_file = fopen(fname.c_str(),
"wb");
79 throw "SmURF: error accessing file!";
94 m_nvars = (unsigned) vnames.size();
99 fprintf(
m_file,
"%s",s.str().c_str());
106 for (
unsigned i=0; i<
m_nvars; ++i)
115 const std::string& title,
116 const unsigned I,
const unsigned J,
const unsigned K,
117 const int& strand_id)
142 cerr <<
"SmURF: error FEPOLYGON and FEPOLYHEDRON are not implemented!" << endl;
144 const unsigned L = 9,
179 const bool isshared = (sharefrom>=0);
183 bwrite< int >(m_file,sharefrom,
m_reverse);
188 const unsigned Nnode = vv[0].size();
198 for (
unsigned i=0; i<Nnode; ++i)
207 for (
unsigned i=0; i<Nnode; ++i)
219 cerr <<
"SmURF: error FEPOLYGON and FEPOLYHEDRON are not implemented!" << endl;
230 const unsigned Nelem = ve.size();
231 const unsigned L = ve[0].size();
232 for (
unsigned j=0; j<Nelem; ++j)
233 for (
unsigned i=0; i<L; ++i)
234 bwrite< unsigned >(m_file,ve[j][i],
m_reverse);
245 m_file.open(fname.c_str(),ios::binary);
247 throw "SmURF: error accessing file!";
263 for (
unsigned i=0; i<8; ++i)
265 istringstream ss(s.substr(5));
274 htitle = bread< string >(
m_file);
278 hvnames.resize(m_nvars);
279 for (
unsigned i=0; i<hvnames.size(); ++i)
280 hvnames[i] = bread< string >(
m_file);
286 vector< TecZone > vzones;
306 z.
i = (unsigned) bread< int >(
m_file);
307 z.
j = (unsigned) bread< int >(
m_file);
308 z.
k = (unsigned) bread< int >(
m_file);
311 z.
i = (unsigned) bread< int >(
m_file);
312 z.
j = (unsigned) bread< int >(
m_file);
318 while (bread< int >(
m_file)) {
327 if (marker!=
EOHMARKER) { std::cout <<
"SmURF: did not detect EOHMARKER!" << std::endl; exit(666); }
337 const float marker = bread< float >(
m_file);
339 cerr <<
"SmURF: corrupt file!" << endl;
344 for (
unsigned j=0; j<
m_nvars; ++j)
345 vtypes[j] = bread< DataType >(
m_file);
349 const bool isshared = (bread< int >(
m_file)!=0);
353 sharefrom = bread< int >(
m_file);
358 const unsigned Nnode = z.
i;
359 vv.assign(m_nvars,vector< double >(Nnode,0.));
363 d = bread< double >(
m_file);
364 d = bread< double >(
m_file);
370 for (
unsigned i=0; i<Nnode; ++i)
372 else vv[
N][i] = (double) bread< float >(
m_file);
377 for (
unsigned i=0; i<Nnode; ++i)
380 else vv[
N][i] = (double) bread< float >(
m_file);
387 const unsigned Nelem = z.
j;
393 ve.assign(Nelem,vector< unsigned >(L,0));
394 for (
unsigned j=0; j<Nelem; ++j)
395 for (
unsigned i=0; i<L; ++i)
396 ve[j][i] = bread< unsigned >(
m_file);
boost::proto::terminal< SFOp< ShapeFunctionOp > >::type const N
CGAL::Exact_predicates_inexact_constructions_kernel K
void writeZoneData(const ZoneType &type, const ZonePack &pack, const std::vector< std::vector< unsigned > > &ve, const std::vector< std::vector< double > > &vv=std::vector< std::vector< double > >(), const int sharefrom=0)
void writeMainHeader(const std::string &htitle, const std::vector< std::string > &hvnames)
void bwrite< string >(FILE *F, string v, bool reverse)
void writeZoneHeader(const ZoneType &type, const ZonePack &pack, const std::string &title, const unsigned I=1, const unsigned J=1, const unsigned K=1, const int &strand_id=int(-2))
MeshReader(const std::string &fname)
string bread(ifstream &F)
void readMainHeader(std::string &htitle, std::vector< std::string > &hvnames)
std::vector< TecZone > readZoneHeaders()
const DataType m_datatype
void bwrite(FILE *F, T v, bool reverse)
const double m_solutiontime
void readZoneData(const TecZone &z, std::vector< std::vector< unsigned > > &ve, std::vector< std::vector< double > > &vv)