www.mooseframework.org
Classes | Namespaces | Functions
DataIO.h File Reference

Go to the source code of this file.

Classes

class  libMesh::NumericVector< T >
 
class  libMesh::DenseMatrix< T >
 
class  libMesh::DenseVector< T >
 
class  libMesh::Parallel::Packing< std::basic_string< T > >
 

Namespaces

 libMesh
 The following methods are specializations for using the libMesh::Parallel::packed_range_* routines for std::strings.
 
 libMesh::Parallel
 

Functions

template<typename P >
void storeHelper (std::ostream &stream, P &data, void *context)
 Scalar helper routine. More...
 
template<typename P >
void storeHelper (std::ostream &stream, std::vector< P > &data, void *context)
 Vector helper routine. More...
 
template<typename P >
void storeHelper (std::ostream &stream, std::shared_ptr< P > &data, void *context)
 Shared pointer helper routine. More...
 
template<typename P >
void storeHelper (std::ostream &stream, std::unique_ptr< P > &data, void *context)
 Unique pointer helper routine. More...
 
template<typename P >
void storeHelper (std::ostream &stream, std::set< P > &data, void *context)
 Set helper routine. More...
 
template<typename P , typename Q >
void storeHelper (std::ostream &stream, std::map< P, Q > &data, void *context)
 Map helper routine. More...
 
template<typename P , typename Q >
void storeHelper (std::ostream &stream, std::unordered_map< P, Q > &data, void *context)
 Unordered_map helper routine. More...
 
template<typename P , typename Q >
void storeHelper (std::ostream &stream, HashMap< P, Q > &data, void *context)
 HashMap helper routine. More...
 
template<typename P >
void loadHelper (std::istream &stream, P &data, void *context)
 Scalar helper routine. More...
 
template<typename P >
void loadHelper (std::istream &stream, std::vector< P > &data, void *context)
 Vector helper routine. More...
 
template<typename P >
void loadHelper (std::istream &stream, std::shared_ptr< P > &data, void *context)
 Shared Pointer helper routine. More...
 
template<typename P >
void loadHelper (std::istream &stream, std::unique_ptr< P > &data, void *context)
 Unique Pointer helper routine. More...
 
template<typename P >
void loadHelper (std::istream &stream, std::set< P > &data, void *context)
 Set helper routine. More...
 
template<typename P , typename Q >
void loadHelper (std::istream &stream, std::map< P, Q > &data, void *context)
 Map helper routine. More...
 
template<typename P , typename Q >
void loadHelper (std::istream &stream, std::unordered_map< P, Q > &data, void *context)
 Unordered_map helper routine. More...
 
template<typename P , typename Q >
void loadHelper (std::istream &stream, HashMap< P, Q > &data, void *context)
 Hashmap helper routine. More...
 
template<typename T >
void dataStore (std::ostream &stream, T &v, void *)
 
template<typename T >
void dataStore (std::ostream &, T *&, void *)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, std::pair< T, U > &p, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::vector< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::shared_ptr< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::unique_ptr< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::set< T > &s, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::list< T > &l, void *context)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, std::map< T, U > &m, void *context)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, std::unordered_map< T, U > &m, void *context)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, HashMap< T, U > &m, void *context)
 
template<>
void dataStore (std::ostream &stream, Real &v, void *)
 
template<>
void dataStore (std::ostream &stream, std::string &v, void *)
 
template<>
void dataStore (std::ostream &stream, NumericVector< Real > &v, void *)
 
template<>
void dataStore (std::ostream &stream, DenseVector< Real > &v, void *)
 
template<>
void dataStore (std::ostream &stream, DenseMatrix< Real > &v, void *)
 
template<>
void dataStore (std::ostream &stream, ColumnMajorMatrix &v, void *)
 
template<>
void dataStore (std::ostream &stream, RealTensorValue &v, void *)
 
template<>
void dataStore (std::ostream &stream, RealVectorValue &v, void *)
 
template<>
void dataStore (std::ostream &stream, const Elem *&e, void *context)
 
template<>
void dataStore (std::ostream &stream, const Node *&n, void *context)
 
template<>
void dataStore (std::ostream &stream, Elem *&e, void *context)
 
template<>
void dataStore (std::ostream &stream, Node *&n, void *context)
 
template<>
void dataStore (std::ostream &stream, std::stringstream &s, void *context)
 
template<>
void dataStore (std::ostream &stream, std::stringstream *&s, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, T &v, void *)
 
template<typename T >
void dataLoad (std::istream &, T *&, void *)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, std::pair< T, U > &p, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::vector< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::shared_ptr< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::unique_ptr< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::set< T > &s, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::list< T > &l, void *context)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, std::map< T, U > &m, void *context)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, std::unordered_map< T, U > &m, void *context)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, HashMap< T, U > &m, void *context)
 
template<>
void dataLoad (std::istream &stream, Real &v, void *)
 
template<>
void dataLoad (std::istream &stream, std::string &v, void *)
 
template<>
void dataLoad (std::istream &stream, NumericVector< Real > &v, void *)
 
template<>
void dataLoad (std::istream &stream, DenseVector< Real > &v, void *)
 
template<>
void dataLoad (std::istream &stream, DenseMatrix< Real > &v, void *)
 
template<>
void dataLoad (std::istream &stream, ColumnMajorMatrix &v, void *)
 
template<>
void dataLoad (std::istream &stream, RealTensorValue &v, void *)
 
template<>
void dataLoad (std::istream &stream, RealVectorValue &v, void *)
 
template<>
void dataLoad (std::istream &stream, const Elem *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, const Node *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, Elem *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, Node *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, std::stringstream &s, void *context)
 
template<>
void dataLoad (std::istream &stream, std::stringstream *&s, void *context)
 
template<>
void dataStore (std::ostream &stream, Backup *&backup, void *context)
 
template<>
void dataLoad (std::istream &stream, Backup *&backup, void *context)
 

Function Documentation

template<typename T >
void dataLoad ( std::istream &  stream,
T &  v,
void *   
)
inline

Definition at line 351 of file DataIO.h.

Referenced by dataLoad(), and loadHelper().

352 {
353  stream.read((char *)&v, sizeof(v));
354 }
template<typename T >
void dataLoad ( std::istream &  ,
T *&  ,
void *   
)

Definition at line 358 of file DataIO.h.

359 {
360  mooseError("Attempting to load a raw pointer type: \"",
361  demangle(typeid(T).name()),
362  " *\" as restartable data!\nWrite a custom dataLoad() template specialization!\n\n");
363 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
template<typename T , typename U >
void dataLoad ( std::istream &  stream,
std::pair< T, U > &  p,
void *  context 
)
inline

Definition at line 367 of file DataIO.h.

368 {
369  loadHelper(stream, p.first, context);
370  loadHelper(stream, p.second, context);
371 }
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T >
void dataLoad ( std::istream &  stream,
std::vector< T > &  v,
void *  context 
)
inline

Definition at line 375 of file DataIO.h.

376 {
377  // First read the size of the vector
378  unsigned int size = 0;
379  stream.read((char *)&size, sizeof(size));
380 
381  v.resize(size);
382 
383  for (unsigned int i = 0; i < size; i++)
384  loadHelper(stream, v[i], context);
385 }
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T >
void dataLoad ( std::istream &  stream,
std::shared_ptr< T > &  v,
void *  context 
)
inline

Definition at line 389 of file DataIO.h.

390 {
391  T * tmp = v.get();
392 
393  loadHelper(stream, tmp, context);
394 }
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T >
void dataLoad ( std::istream &  stream,
std::unique_ptr< T > &  v,
void *  context 
)
inline

Definition at line 398 of file DataIO.h.

399 {
400  T * tmp = v.get();
401 
402  loadHelper(stream, tmp, context);
403 }
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T >
void dataLoad ( std::istream &  stream,
std::set< T > &  s,
void *  context 
)
inline

Definition at line 407 of file DataIO.h.

408 {
409  // First read the size of the set
410  unsigned int size = 0;
411  stream.read((char *)&size, sizeof(size));
412 
413  for (unsigned int i = 0; i < size; i++)
414  {
415  T data;
416  loadHelper(stream, data, context);
417  s.insert(std::move(data));
418  }
419 }
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T >
void dataLoad ( std::istream &  stream,
std::list< T > &  l,
void *  context 
)
inline

Definition at line 423 of file DataIO.h.

424 {
425  // First read the size of the set
426  unsigned int size = 0;
427  stream.read((char *)&size, sizeof(size));
428 
429  for (unsigned int i = 0; i < size; i++)
430  {
431  T data;
432  loadHelper(stream, data, context);
433  l.push_back(std::move(data));
434  }
435 }
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T , typename U >
void dataLoad ( std::istream &  stream,
std::map< T, U > &  m,
void *  context 
)
inline

Definition at line 439 of file DataIO.h.

440 {
441  m.clear();
442 
443  // First read the size of the map
444  unsigned int size = 0;
445  stream.read((char *)&size, sizeof(size));
446 
447  for (unsigned int i = 0; i < size; i++)
448  {
449  T key;
450  loadHelper(stream, key, context);
451 
452  U & value = m[key];
453  loadHelper(stream, value, context);
454  }
455 }
PetscInt m
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T , typename U >
void dataLoad ( std::istream &  stream,
std::unordered_map< T, U > &  m,
void *  context 
)
inline

Definition at line 459 of file DataIO.h.

460 {
461  m.clear();
462 
463  // First read the size of the map
464  unsigned int size = 0;
465  stream.read((char *)&size, sizeof(size));
466 
467  for (unsigned int i = 0; i < size; i++)
468  {
469  T key;
470  loadHelper(stream, key, context);
471 
472  U & value = m[key];
473  loadHelper(stream, value, context);
474  }
475 }
PetscInt m
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<typename T , typename U >
void dataLoad ( std::istream &  stream,
HashMap< T, U > &  m,
void *  context 
)
inline

Definition at line 479 of file DataIO.h.

480 {
481  // First read the size of the map
482  unsigned int size = 0;
483  stream.read((char *)&size, sizeof(size));
484 
485  for (unsigned int i = 0; i < size; i++)
486  {
487  T key;
488  loadHelper(stream, key, context);
489 
490  U & value = m[key];
491  loadHelper(stream, value, context);
492  }
493 }
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<>
void dataLoad ( std::istream &  stream,
Real &  v,
void *   
)

Definition at line 208 of file DataIO.C.

Referenced by dataLoad().

209 {
210  stream.read((char *)&v, sizeof(v));
211 }
template<>
void dataLoad ( std::istream &  stream,
std::string &  v,
void *   
)

Definition at line 215 of file DataIO.C.

216 {
217  // Read the size of the string
218  unsigned int size = 0;
219  stream.read((char *)&size, sizeof(size));
220 
221  // Resize the string data
222  v.resize(size);
223 
224  // Read the string
225  stream.read(&v[0], sizeof(char) * size);
226 }
template<>
void dataLoad ( std::istream &  stream,
NumericVector< Real > &  v,
void *   
)

Definition at line 230 of file DataIO.C.

231 {
232  numeric_index_type size = v.local_size();
233 
234  for (numeric_index_type i = v.first_local_index(); i < v.first_local_index() + size; i++)
235  {
236  Real r = 0;
237  stream.read((char *)&r, sizeof(r));
238  v.set(i, r);
239  }
240 
241  v.close();
242 }
template<>
void dataLoad ( std::istream &  stream,
DenseVector< Real > &  v,
void *   
)

Definition at line 246 of file DataIO.C.

247 {
248  unsigned int n = 0;
249  stream.read((char *)&n, sizeof(n));
250  v.resize(n);
251  for (unsigned int i = 0; i < n; i++)
252  {
253  Real r = 0;
254  stream.read((char *)&r, sizeof(r));
255  v(i) = r;
256  }
257 }
PetscInt n
template<>
void dataLoad ( std::istream &  stream,
DenseMatrix< Real > &  v,
void *   
)

Definition at line 261 of file DataIO.C.

262 {
263  unsigned int nr = 0, nc = 0;
264  stream.read((char *)&nr, sizeof(nr));
265  stream.read((char *)&nc, sizeof(nc));
266  v.resize(nr, nc);
267  for (unsigned int i = 0; i < v.m(); i++)
268  for (unsigned int j = 0; j < v.n(); j++)
269  {
270  Real r = 0;
271  stream.read((char *)&r, sizeof(r));
272  v(i, j) = r;
273  }
274 }
template<>
void dataLoad ( std::istream &  stream,
ColumnMajorMatrix v,
void *   
)

Definition at line 278 of file DataIO.C.

279 {
280  for (unsigned int i = 0; i < v.m(); i++)
281  for (unsigned int j = 0; j < v.n(); j++)
282  {
283  Real r = 0;
284  stream.read((char *)&r, sizeof(r));
285  v(i, j) = r;
286  }
287 }
unsigned int n() const
Returns the number of rows.
unsigned int m() const
Returns the number of columns.
template<>
void dataLoad ( std::istream &  stream,
RealTensorValue &  v,
void *   
)

Definition at line 291 of file DataIO.C.

292 {
293  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
294  // won't work.
295  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
296  for (unsigned int j = 0; i < LIBMESH_DIM; i++)
297  {
298  Real r = 0;
299  stream.read((char *)&r, sizeof(r));
300  v(i, j) = r;
301  }
302 }
template<>
void dataLoad ( std::istream &  stream,
RealVectorValue &  v,
void *   
)

Definition at line 306 of file DataIO.C.

307 {
308  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
309  // won't work.
310  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
311  {
312  Real r = 0;
313  stream.read((char *)&r, sizeof(r));
314  v(i) = r;
315  }
316 }
template<>
void dataLoad ( std::istream &  stream,
const Elem *&  e,
void *  context 
)

Definition at line 320 of file DataIO.C.

321 {
322  if (!context)
323  mooseError("Can only load Elem objects using a MooseMesh context!");
324 
325  MooseMesh * mesh = static_cast<MooseMesh *>(context);
326 
327  // TODO: Write out the unique ID of this element
328  dof_id_type id = libMesh::DofObject::invalid_id;
329 
330  loadHelper(stream, id, context);
331 
332  if (id != libMesh::DofObject::invalid_id)
333  e = mesh->elemPtr(id);
334  else
335  e = NULL;
336 }
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:2062
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<>
void dataLoad ( std::istream &  stream,
const Node *&  e,
void *  context 
)

Definition at line 340 of file DataIO.C.

341 {
342  if (!context)
343  mooseError("Can only load Node objects using a MooseMesh context!");
344 
345  MooseMesh * mesh = static_cast<MooseMesh *>(context);
346 
347  // TODO: Write out the unique ID of this nodeent
348  dof_id_type id = libMesh::DofObject::invalid_id;
349 
350  loadHelper(stream, id, context);
351 
352  if (id != libMesh::DofObject::invalid_id)
353  n = mesh->nodePtr(id);
354  else
355  n = NULL;
356 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
virtual const Node * nodePtr(const dof_id_type i) const
Definition: MooseMesh.C:416
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
PetscInt n
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<>
void dataLoad ( std::istream &  stream,
Elem *&  e,
void *  context 
)

Definition at line 360 of file DataIO.C.

361 {
362  if (!context)
363  mooseError("Can only load Elem objects using a MooseMesh context!");
364 
365  MooseMesh * mesh = static_cast<MooseMesh *>(context);
366 
367  // TODO: Write out the unique ID of this element
368  dof_id_type id = libMesh::DofObject::invalid_id;
369 
370  loadHelper(stream, id, context);
371 
372  if (id != libMesh::DofObject::invalid_id)
373  e = mesh->elemPtr(id);
374  else
375  e = NULL;
376 }
virtual Elem * elemPtr(const dof_id_type i)
Definition: MooseMesh.C:2062
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<>
void dataLoad ( std::istream &  stream,
Node *&  e,
void *  context 
)

Definition at line 380 of file DataIO.C.

381 {
382  if (!context)
383  mooseError("Can only load Node objects using a MooseMesh context!");
384 
385  MooseMesh * mesh = static_cast<MooseMesh *>(context);
386 
387  // TODO: Write out the unique ID of this nodeent
388  dof_id_type id = libMesh::DofObject::invalid_id;
389 
390  loadHelper(stream, id, context);
391 
392  if (id != libMesh::DofObject::invalid_id)
393  n = mesh->nodePtr(id);
394  else
395  n = NULL;
396 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
virtual const Node * nodePtr(const dof_id_type i) const
Definition: MooseMesh.C:416
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
PetscInt n
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:592
template<>
void dataLoad ( std::istream &  stream,
std::stringstream &  s,
void *  context 
)

Definition at line 400 of file DataIO.C.

401 {
402  size_t s_size = 0;
403 
404  stream.read((char *)&s_size, sizeof(s_size));
405 
406  char * s_s = new char[s_size];
407 
408  stream.read(s_s, s_size);
409 
410  s.write(s_s, s_size);
411  delete[] s_s;
412 }
template<>
void dataLoad ( std::istream &  stream,
std::stringstream *&  s,
void *  context 
)

Definition at line 416 of file DataIO.C.

417 {
418  dataLoad(stream, *s, context);
419 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:208
template<>
void dataLoad ( std::istream &  stream,
Backup *&  backup,
void *  context 
)
inline

Definition at line 666 of file DataIO.h.

667 {
668  dataLoad(stream, backup->_system_data, context);
669 
670  for (unsigned int i = 0; i < backup->_restartable_data.size(); i++)
671  dataLoad(stream, backup->_restartable_data[i], context);
672 }
std::stringstream _system_data
Definition: Backup.h:32
std::vector< std::stringstream * > _restartable_data
Definition: Backup.h:34
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename T >
void dataStore ( std::ostream &  stream,
T &  v,
void *   
)
inline

Definition at line 155 of file DataIO.h.

Referenced by dataStore(), and storeHelper().

156 {
157 #ifdef LIBMESH_HAVE_CXX11_TYPE_TRAITS
158  static_assert(std::is_polymorphic<T>::value == false,
159  "Cannot serialize a class that has virtual "
160  "members!\nWrite a custom dataStore() "
161  "template specialization!\n\n");
162  static_assert(std::is_trivially_copyable<T>::value || std::is_same<T, Point>::value,
163  "Cannot serialize a class that is not trivially copyable!\nWrite a custom "
164  "dataStore() template specialization!\n\n");
165 #endif
166 
167  // Moose::out<<"Generic dataStore"<<std::endl;
168  stream.write((char *)&v, sizeof(v));
169 }
template<typename T >
void dataStore ( std::ostream &  ,
T *&  ,
void *   
)
inline

Definition at line 173 of file DataIO.h.

174 {
175  mooseError("Attempting to store a raw pointer type: \"",
176  demangle(typeid(T).name()),
177  " *\" as restartable data!\nWrite a custom dataStore() template specialization!\n\n");
178 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
template<typename T , typename U >
void dataStore ( std::ostream &  stream,
std::pair< T, U > &  p,
void *  context 
)
inline

Definition at line 182 of file DataIO.h.

183 {
184  storeHelper(stream, p.first, context);
185  storeHelper(stream, p.second, context);
186 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<typename T >
void dataStore ( std::ostream &  stream,
std::vector< T > &  v,
void *  context 
)
inline

Definition at line 190 of file DataIO.h.

191 {
192  // First store the size of the vector
193  unsigned int size = v.size();
194  stream.write((char *)&size, sizeof(size));
195 
196  for (unsigned int i = 0; i < size; i++)
197  storeHelper(stream, v[i], context);
198 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<typename T >
void dataStore ( std::ostream &  stream,
std::shared_ptr< T > &  v,
void *  context 
)
inline

Definition at line 202 of file DataIO.h.

203 {
204  T * tmp = v.get();
205 
206  storeHelper(stream, tmp, context);
207 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<typename T >
void dataStore ( std::ostream &  stream,
std::unique_ptr< T > &  v,
void *  context 
)
inline

Definition at line 211 of file DataIO.h.

212 {
213  T * tmp = v.get();
214 
215  storeHelper(stream, tmp, context);
216 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<typename T >
void dataStore ( std::ostream &  stream,
std::set< T > &  s,
void *  context 
)
inline

Definition at line 220 of file DataIO.h.

221 {
222  // First store the size of the set
223  unsigned int size = s.size();
224  stream.write((char *)&size, sizeof(size));
225 
226  typename std::set<T>::iterator it = s.begin();
227  typename std::set<T>::iterator end = s.end();
228 
229  for (; it != end; ++it)
230  {
231  T & x = const_cast<T &>(*it);
232  storeHelper(stream, x, context);
233  }
234 }
static PetscErrorCode Vec x
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<typename T >
void dataStore ( std::ostream &  stream,
std::list< T > &  l,
void *  context 
)
inline

Definition at line 238 of file DataIO.h.

239 {
240  // First store the size of the set
241  unsigned int size = l.size();
242  stream.write((char *)&size, sizeof(size));
243 
244  typename std::list<T>::iterator it = l.begin();
245  typename std::list<T>::iterator end = l.end();
246 
247  for (; it != end; ++it)
248  {
249  T & x = const_cast<T &>(*it);
250  storeHelper(stream, x, context);
251  }
252 }
static PetscErrorCode Vec x
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<typename T , typename U >
void dataStore ( std::ostream &  stream,
std::map< T, U > &  m,
void *  context 
)
inline

Definition at line 256 of file DataIO.h.

257 {
258  // First store the size of the map
259  unsigned int size = m.size();
260  stream.write((char *)&size, sizeof(size));
261 
262  typename std::map<T, U>::iterator it = m.begin();
263  typename std::map<T, U>::iterator end = m.end();
264 
265  for (; it != end; ++it)
266  {
267  T & key = const_cast<T &>(it->first);
268 
269  storeHelper(stream, key, context);
270 
271  storeHelper(stream, it->second, context);
272  }
273 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
PetscInt m
template<typename T , typename U >
void dataStore ( std::ostream &  stream,
std::unordered_map< T, U > &  m,
void *  context 
)
inline

Definition at line 277 of file DataIO.h.

278 {
279  // First store the size of the map
280  unsigned int size = m.size();
281  stream.write((char *)&size, sizeof(size));
282 
283  typename std::unordered_map<T, U>::iterator it = m.begin();
284  typename std::unordered_map<T, U>::iterator end = m.end();
285 
286  for (; it != end; ++it)
287  {
288  T & key = const_cast<T &>(it->first);
289 
290  storeHelper(stream, key, context);
291 
292  storeHelper(stream, it->second, context);
293  }
294 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
PetscInt m
template<typename T , typename U >
void dataStore ( std::ostream &  stream,
HashMap< T, U > &  m,
void *  context 
)
inline

Definition at line 298 of file DataIO.h.

299 {
300  // First store the size of the map
301  unsigned int size = m.size();
302  stream.write((char *)&size, sizeof(size));
303 
304  typename HashMap<T, U>::iterator it = m.begin();
305  typename HashMap<T, U>::iterator end = m.end();
306 
307  for (; it != end; ++it)
308  {
309  T & key = const_cast<T &>(it->first);
310 
311  storeHelper(stream, key, context);
312 
313  storeHelper(stream, it->second, context);
314  }
315 }
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts...
Definition: HashMap.h:24
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<>
void dataStore ( std::ostream &  stream,
Real &  v,
void *   
)

Definition at line 25 of file DataIO.C.

Referenced by dataStore().

26 {
27  stream.write((char *)&v, sizeof(v));
28 }
template<>
void dataStore ( std::ostream &  stream,
std::string &  v,
void *   
)

Definition at line 32 of file DataIO.C.

33 {
34  // Write the size of the string
35  unsigned int size = v.size();
36  stream.write((char *)&size, sizeof(size));
37 
38  // Write the string (Do not store the null byte)
39  stream.write(v.c_str(), sizeof(char) * size);
40 }
template<>
void dataStore ( std::ostream &  stream,
NumericVector< Real > &  v,
void *   
)

Definition at line 44 of file DataIO.C.

45 {
46  v.close();
47 
48  numeric_index_type size = v.local_size();
49 
50  for (numeric_index_type i = v.first_local_index(); i < v.first_local_index() + size; i++)
51  {
52  Real r = v(i);
53  stream.write((char *)&r, sizeof(r));
54  }
55 }
template<>
void dataStore ( std::ostream &  stream,
DenseVector< Real > &  v,
void *   
)

Definition at line 59 of file DataIO.C.

60 {
61  unsigned int m = v.size();
62  stream.write((char *)&m, sizeof(m));
63  for (unsigned int i = 0; i < v.size(); i++)
64  {
65  Real r = v(i);
66  stream.write((char *)&r, sizeof(r));
67  }
68 }
PetscInt m
template<>
void dataStore ( std::ostream &  stream,
DenseMatrix< Real > &  v,
void *   
)

Definition at line 72 of file DataIO.C.

73 {
74  unsigned int m = v.m();
75  unsigned int n = v.n();
76  stream.write((char *)&m, sizeof(m));
77  stream.write((char *)&n, sizeof(n));
78  for (unsigned int i = 0; i < v.m(); i++)
79  for (unsigned int j = 0; j < v.n(); j++)
80  {
81  Real r = v(i, j);
82  stream.write((char *)&r, sizeof(r));
83  }
84 }
PetscInt m
PetscInt n
template<>
void dataStore ( std::ostream &  stream,
ColumnMajorMatrix v,
void *   
)

Definition at line 88 of file DataIO.C.

89 {
90  for (unsigned int i = 0; i < v.m(); i++)
91  for (unsigned int j = 0; j < v.n(); j++)
92  {
93  Real r = v(i, j);
94  stream.write((char *)&r, sizeof(r));
95  }
96 }
unsigned int n() const
Returns the number of rows.
unsigned int m() const
Returns the number of columns.
template<>
void dataStore ( std::ostream &  stream,
RealTensorValue &  v,
void *   
)

Definition at line 100 of file DataIO.C.

101 {
102  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
103  for (unsigned int j = 0; i < LIBMESH_DIM; i++)
104  stream.write((char *)&v(i, j), sizeof(v(i, j)));
105 }
template<>
void dataStore ( std::ostream &  stream,
RealVectorValue &  v,
void *   
)

Definition at line 109 of file DataIO.C.

110 {
111  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
112  // won't work.
113  for (unsigned int i = 0; i < LIBMESH_DIM; i++)
114  stream.write((char *)&v(i), sizeof(v(i)));
115 }
template<>
void dataStore ( std::ostream &  stream,
const Elem *&  e,
void *  context 
)

Definition at line 119 of file DataIO.C.

120 {
121  // TODO: Write out the unique ID of this elem
122  dof_id_type id = libMesh::DofObject::invalid_id;
123 
124  if (e)
125  {
126  id = e->id();
127  if (id == libMesh::DofObject::invalid_id)
128  mooseError("Can't output Elems with invalid ids!");
129  }
130 
131  storeHelper(stream, id, context);
132 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<>
void dataStore ( std::ostream &  stream,
const Node *&  n,
void *  context 
)

Definition at line 136 of file DataIO.C.

137 {
138  // TODO: Write out the unique ID of this node
139  dof_id_type id = libMesh::DofObject::invalid_id;
140 
141  if (n)
142  {
143  id = n->id();
144  if (id == libMesh::DofObject::invalid_id)
145  mooseError("Can't output Nodes with invalid ids!");
146  }
147 
148  storeHelper(stream, id, context);
149 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
PetscInt n
template<>
void dataStore ( std::ostream &  stream,
Elem *&  e,
void *  context 
)

Definition at line 153 of file DataIO.C.

154 {
155  // TODO: Write out the unique ID of this elem
156  dof_id_type id = libMesh::DofObject::invalid_id;
157 
158  if (e)
159  {
160  id = e->id();
161  if (id == libMesh::DofObject::invalid_id)
162  mooseError("Can't output Elems with invalid ids!");
163  }
164 
165  storeHelper(stream, id, context);
166 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
template<>
void dataStore ( std::ostream &  stream,
Node *&  n,
void *  context 
)

Definition at line 170 of file DataIO.C.

171 {
172  // TODO: Write out the unique ID of this node
173  dof_id_type id = libMesh::DofObject::invalid_id;
174 
175  if (n)
176  {
177  id = n->id();
178  if (id == libMesh::DofObject::invalid_id)
179  mooseError("Can't output Nodes with invalid ids!");
180  }
181 
182  storeHelper(stream, id, context);
183 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:528
PetscInt n
template<>
void dataStore ( std::ostream &  stream,
std::stringstream &  s,
void *  context 
)

Definition at line 187 of file DataIO.C.

188 {
189  const std::string & s_str = s.str();
190 
191  size_t s_size = s_str.size();
192  stream.write((char *)&s_size, sizeof(s_size));
193 
194  stream.write(s_str.c_str(), sizeof(char) * (s_str.size()));
195 }
template<>
void dataStore ( std::ostream &  stream,
std::stringstream *&  s,
void *  context 
)

Definition at line 199 of file DataIO.C.

200 {
201  dataStore(stream, *s, context);
202 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:25
template<>
void dataStore ( std::ostream &  stream,
Backup *&  backup,
void *  context 
)
inline

Definition at line 656 of file DataIO.h.

657 {
658  dataStore(stream, backup->_system_data, context);
659 
660  for (unsigned int i = 0; i < backup->_restartable_data.size(); i++)
661  dataStore(stream, backup->_restartable_data[i], context);
662 }
std::stringstream _system_data
Definition: Backup.h:32
std::vector< std::stringstream * > _restartable_data
Definition: Backup.h:34
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P >
void loadHelper ( std::istream &  stream,
P &  data,
void *  context 
)
inline

Scalar helper routine.

Definition at line 592 of file DataIO.h.

Referenced by dataLoad(), RestartableDataIO::deserializeSystems(), RestartableData< T >::load(), and MaterialProperty< T >::load().

593 {
594  dataLoad(stream, data, context);
595 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P >
void loadHelper ( std::istream &  stream,
std::vector< P > &  data,
void *  context 
)
inline

Vector helper routine.

Definition at line 600 of file DataIO.h.

601 {
602  dataLoad(stream, data, context);
603 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P >
void loadHelper ( std::istream &  stream,
std::shared_ptr< P > &  data,
void *  context 
)
inline

Shared Pointer helper routine.

Definition at line 608 of file DataIO.h.

609 {
610  dataLoad(stream, data, context);
611 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P >
void loadHelper ( std::istream &  stream,
std::unique_ptr< P > &  data,
void *  context 
)
inline

Unique Pointer helper routine.

Definition at line 616 of file DataIO.h.

617 {
618  dataLoad(stream, data, context);
619 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P >
void loadHelper ( std::istream &  stream,
std::set< P > &  data,
void *  context 
)
inline

Set helper routine.

Definition at line 624 of file DataIO.h.

625 {
626  dataLoad(stream, data, context);
627 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P , typename Q >
void loadHelper ( std::istream &  stream,
std::map< P, Q > &  data,
void *  context 
)
inline

Map helper routine.

Definition at line 632 of file DataIO.h.

633 {
634  dataLoad(stream, data, context);
635 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P , typename Q >
void loadHelper ( std::istream &  stream,
std::unordered_map< P, Q > &  data,
void *  context 
)
inline

Unordered_map helper routine.

Definition at line 640 of file DataIO.h.

641 {
642  dataLoad(stream, data, context);
643 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P , typename Q >
void loadHelper ( std::istream &  stream,
HashMap< P, Q > &  data,
void *  context 
)
inline

Hashmap helper routine.

Definition at line 648 of file DataIO.h.

649 {
650  dataLoad(stream, data, context);
651 }
void dataLoad(std::istream &stream, T &v, void *)
Definition: DataIO.h:351
template<typename P >
void storeHelper ( std::ostream &  stream,
P &  data,
void *  context 
)
inline

Scalar helper routine.

Definition at line 528 of file DataIO.h.

Referenced by dataStore(), RestartableDataIO::serializeSystems(), RestartableData< T >::store(), and MaterialProperty< T >::store().

529 {
530  dataStore(stream, data, context);
531 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P >
void storeHelper ( std::ostream &  stream,
std::vector< P > &  data,
void *  context 
)
inline

Vector helper routine.

Definition at line 536 of file DataIO.h.

537 {
538  dataStore(stream, data, context);
539 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P >
void storeHelper ( std::ostream &  stream,
std::shared_ptr< P > &  data,
void *  context 
)
inline

Shared pointer helper routine.

Definition at line 544 of file DataIO.h.

545 {
546  dataStore(stream, data, context);
547 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P >
void storeHelper ( std::ostream &  stream,
std::unique_ptr< P > &  data,
void *  context 
)
inline

Unique pointer helper routine.

Definition at line 552 of file DataIO.h.

553 {
554  dataStore(stream, data, context);
555 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P >
void storeHelper ( std::ostream &  stream,
std::set< P > &  data,
void *  context 
)
inline

Set helper routine.

Definition at line 560 of file DataIO.h.

561 {
562  dataStore(stream, data, context);
563 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P , typename Q >
void storeHelper ( std::ostream &  stream,
std::map< P, Q > &  data,
void *  context 
)
inline

Map helper routine.

Definition at line 568 of file DataIO.h.

569 {
570  dataStore(stream, data, context);
571 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P , typename Q >
void storeHelper ( std::ostream &  stream,
std::unordered_map< P, Q > &  data,
void *  context 
)
inline

Unordered_map helper routine.

Definition at line 576 of file DataIO.h.

577 {
578  dataStore(stream, data, context);
579 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155
template<typename P , typename Q >
void storeHelper ( std::ostream &  stream,
HashMap< P, Q > &  data,
void *  context 
)
inline

HashMap helper routine.

Definition at line 584 of file DataIO.h.

585 {
586  dataStore(stream, data, context);
587 }
void dataStore(std::ostream &stream, T &v, void *)
Definition: DataIO.h:155