https://mooseframework.inl.gov
Functions
DataIO.C File Reference

Go to the source code of this file.

Functions

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, VariableName &v, void *context)
 
template<>
void dataStore (std::ostream &stream, UserObjectName &v, void *context)
 
template<>
void dataStore (std::ostream &stream, bool &v, void *)
 
template<>
void dataStore (std::ostream &stream, std::vector< bool > &v, void *context)
 
template<>
void dataStore (std::ostream &stream, RankTwoTensor &rtt, void *context)
 
template<>
void dataStore (std::ostream &stream, RankThreeTensor &rtht, void *context)
 
template<>
void dataStore (std::ostream &stream, RankFourTensor &rft, void *context)
 
template<>
void dataStore (std::ostream &stream, ADReal &dn, void *context)
 
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 *)
 
template<typename T >
void dataStore (std::ostream &stream, TensorValue< T > &v, void *context)
 
template void dataStore (std::ostream &stream, TensorValue< Real > &v, void *context)
 
template void dataStore (std::ostream &stream, TensorValue< ADReal > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, DenseMatrix< T > &v, void *context)
 
template void dataStore (std::ostream &stream, DenseMatrix< Real > &v, void *context)
 
template void dataStore (std::ostream &stream, DenseMatrix< ADReal > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, VectorValue< T > &v, void *context)
 
template void dataStore (std::ostream &stream, VectorValue< Real > &v, void *context)
 
template void dataStore (std::ostream &stream, VectorValue< ADReal > &v, void *context)
 
void dataStore (std::ostream &stream, Point &p, void *context)
 
template<>
void dataStore (std::ostream &stream, libMesh::Parameters &p, void *context)
 
template<>
void dataStore (std::ostream &stream, std::unique_ptr< libMesh::NumericVector< Number >> &v, 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, VariableName &v, void *context)
 
template<>
void dataLoad (std::istream &stream, UserObjectName &v, void *context)
 
template<>
void dataLoad (std::istream &stream, bool &v, void *)
 
template<>
void dataLoad (std::istream &stream, std::vector< bool > &v, void *context)
 
template<>
void dataLoad (std::istream &stream, ADReal &dn, void *context)
 
template<>
void dataLoad (std::istream &stream, const Elem *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, const Node *&n, void *context)
 
template<>
void dataLoad (std::istream &stream, Elem *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, Node *&n, void *context)
 
template<>
void dataLoad (std::istream &stream, std::stringstream &s, void *)
 
template<typename T >
void dataLoad (std::istream &stream, TensorValue< T > &v, void *context)
 
template void dataLoad (std::istream &stream, TensorValue< Real > &v, void *context)
 
template void dataLoad (std::istream &stream, TensorValue< ADReal > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, DenseMatrix< T > &v, void *context)
 
template void dataLoad (std::istream &stream, DenseMatrix< Real > &v, void *context)
 
template void dataLoad (std::istream &stream, DenseMatrix< ADReal > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, VectorValue< T > &v, void *context)
 
template void dataLoad (std::istream &stream, VectorValue< Real > &v, void *context)
 
template void dataLoad (std::istream &stream, VectorValue< ADReal > &v, void *context)
 
void dataLoad (std::istream &stream, Point &p, void *context)
 
template<>
void dataLoad (std::istream &stream, libMesh::Parameters &p, void *context)
 
template<>
void dataLoad (std::istream &stream, std::unique_ptr< libMesh::NumericVector< Number >> &v, void *context)
 
template<>
void dataLoad (std::istream &stream, Vec &v, void *context)
 
template<>
void dataStore (std::ostream &stream, Vec &v, void *context)
 

Function Documentation

◆ dataLoad() [1/25]

template<>
void dataLoad ( std::istream &  stream,
Real v,
void  
)

Definition at line 343 of file DataIO.C.

Referenced by dataLoad().

344 {
345  stream.read((char *)&v, sizeof(v));
346 }

◆ dataLoad() [2/25]

template<>
void dataLoad ( std::istream &  stream,
std::string &  v,
void  
)

Definition at line 350 of file DataIO.C.

351 {
352  // Read the size of the string
353  unsigned int size = 0;
354  stream.read((char *)&size, sizeof(size));
355 
356  // Resize the string data
357  v.resize(size);
358 
359  // Read the string
360  stream.read(&v[0], sizeof(char) * size);
361 }

◆ dataLoad() [3/25]

template<>
void dataLoad ( std::istream &  stream,
VariableName &  v,
void context 
)

Definition at line 365 of file DataIO.C.

366 {
367  auto & name = static_cast<std::string &>(v);
368  dataLoad(stream, name, context);
369 }
std::string name(const ElemQuality q)
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343

◆ dataLoad() [4/25]

template<>
void dataLoad ( std::istream &  stream,
UserObjectName &  v,
void context 
)

Definition at line 373 of file DataIO.C.

374 {
375  auto & name = static_cast<std::string &>(v);
376  dataLoad(stream, name, context);
377 }
std::string name(const ElemQuality q)
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343

◆ dataLoad() [5/25]

template<>
void dataLoad ( std::istream &  stream,
bool &  v,
void  
)

Definition at line 381 of file DataIO.C.

382 {
383  stream.read((char *)&v, sizeof(v));
384 }

◆ dataLoad() [6/25]

template<>
void dataLoad ( std::istream &  stream,
std::vector< bool > &  v,
void context 
)

Definition at line 388 of file DataIO.C.

389 {
390  for (bool b : v)
391  dataLoad(stream, b, context);
392 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343

◆ dataLoad() [7/25]

template<>
void dataLoad ( std::istream &  stream,
ADReal dn,
void context 
)

Definition at line 396 of file DataIO.C.

397 {
398  dataLoad(stream, dn.value(), context);
399 
400  if (ADReal::do_derivatives)
401  {
402  auto & derivatives = dn.derivatives();
403  std::size_t size = 0;
404  stream.read((char *)&size, sizeof(size));
405  derivatives.resize(size);
406 
407  for (MooseIndex(derivatives) i = 0; i < derivatives.size(); ++i)
408  {
409  dataLoad(stream, derivatives.raw_index(i), context);
410  dataLoad(stream, derivatives.raw_at(i), context);
411  }
412  }
413 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343

◆ dataLoad() [8/25]

template<>
void dataLoad ( std::istream &  stream,
const Elem *&  e,
void context 
)

Definition at line 417 of file DataIO.C.

418 {
419  if (!context)
420  mooseError("Can only load Elem objects using a MooseMesh context!");
421 
422  MooseMesh * mesh = static_cast<MooseMesh *>(context);
423 
424  // TODO: Write out the unique ID of this element
426 
427  loadHelper(stream, id, context);
428 
430  e = mesh->elemPtr(id);
431  else
432  e = NULL;
433 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
MeshBase & mesh
static constexpr dof_id_type invalid_id
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1010
uint8_t dof_id_type

◆ dataLoad() [9/25]

template<>
void dataLoad ( std::istream &  stream,
const Node *&  n,
void context 
)

Definition at line 437 of file DataIO.C.

438 {
439  if (!context)
440  mooseError("Can only load Node objects using a MooseMesh context!");
441 
442  MooseMesh * mesh = static_cast<MooseMesh *>(context);
443 
444  // TODO: Write out the unique ID of this nodeent
446 
447  loadHelper(stream, id, context);
448 
450  n = mesh->nodePtr(id);
451  else
452  n = NULL;
453 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
MeshBase & mesh
static constexpr dof_id_type invalid_id
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1010
uint8_t dof_id_type

◆ dataLoad() [10/25]

template<>
void dataLoad ( std::istream &  stream,
Elem *&  e,
void context 
)

Definition at line 457 of file DataIO.C.

458 {
459  if (!context)
460  mooseError("Can only load Elem objects using a MooseMesh context!");
461 
462  MooseMesh * mesh = static_cast<MooseMesh *>(context);
463 
464  // TODO: Write out the unique ID of this element
466 
467  loadHelper(stream, id, context);
468 
470  e = mesh->elemPtr(id);
471  else
472  e = NULL;
473 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
MeshBase & mesh
static constexpr dof_id_type invalid_id
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1010
uint8_t dof_id_type

◆ dataLoad() [11/25]

template<>
void dataLoad ( std::istream &  stream,
Node *&  n,
void context 
)

Definition at line 477 of file DataIO.C.

478 {
479  if (!context)
480  mooseError("Can only load Node objects using a MooseMesh context!");
481 
482  MooseMesh * mesh = static_cast<MooseMesh *>(context);
483 
484  // TODO: Write out the unique ID of this nodeent
486 
487  loadHelper(stream, id, context);
488 
490  n = mesh->nodePtr(id);
491  else
492  n = NULL;
493 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
MeshBase & mesh
static constexpr dof_id_type invalid_id
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1010
uint8_t dof_id_type

◆ dataLoad() [12/25]

template<>
void dataLoad ( std::istream &  stream,
std::stringstream &  s,
void  
)

Definition at line 497 of file DataIO.C.

498 {
499  size_t s_size = 0;
500  stream.read((char *)&s_size, sizeof(s_size));
501 
502  std::unique_ptr<char[]> s_s = std::make_unique<char[]>(s_size);
503  stream.read(s_s.get(), s_size);
504 
505  // Clear the stringstream before loading new data into it.
506  s.str(std::string());
507  s.write(s_s.get(), s_size);
508 }

◆ dataLoad() [13/25]

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

Definition at line 512 of file DataIO.C.

513 {
514  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
515  // won't work.
516  for (const auto i : make_range(Moose::dim))
517  for (const auto j : make_range(Moose::dim))
518  {
519  T r = 0;
520  dataLoad(stream, r, context);
521  v(i, j) = r;
522  }
523 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:162
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [14/25]

template void dataLoad ( std::istream &  stream,
TensorValue< Real > &  v,
void context 
)

◆ dataLoad() [15/25]

template void dataLoad ( std::istream &  stream,
TensorValue< ADReal > &  v,
void context 
)

◆ dataLoad() [16/25]

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

Definition at line 530 of file DataIO.C.

531 {
532  unsigned int m = 0, n = 0;
533  stream.read((char *)&m, sizeof(m));
534  stream.read((char *)&n, sizeof(n));
535  v.resize(m, n);
536  for (unsigned int i = 0; i < m; i++)
537  for (unsigned int j = 0; j < n; j++)
538  {
539  T r = 0;
540  dataLoad(stream, r, context);
541  v(i, j) = r;
542  }
543 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343
void resize(const unsigned int new_m, const unsigned int new_n)

◆ dataLoad() [17/25]

template void dataLoad ( std::istream &  stream,
DenseMatrix< Real > &  v,
void context 
)

◆ dataLoad() [18/25]

template void dataLoad ( std::istream &  stream,
DenseMatrix< ADReal > &  v,
void context 
)

◆ dataLoad() [19/25]

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

Definition at line 550 of file DataIO.C.

551 {
552  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
553  // won't work.
554  for (const auto i : make_range(Moose::dim))
555  {
556  T r = 0;
557  dataLoad(stream, r, context);
558  v(i) = r;
559  }
560 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:162
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [20/25]

template void dataLoad ( std::istream &  stream,
VectorValue< Real > &  v,
void context 
)

◆ dataLoad() [21/25]

template void dataLoad ( std::istream &  stream,
VectorValue< ADReal > &  v,
void context 
)

◆ dataLoad() [22/25]

void dataLoad ( std::istream &  stream,
Point p,
void context 
)

Definition at line 566 of file DataIO.C.

567 {
568  for (const auto i : make_range(Moose::dim))
569  {
570  Real r = 0;
571  dataLoad(stream, r, context);
572  p(i) = r;
573  }
574 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:162
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [23/25]

template<>
void dataLoad ( std::istream &  stream,
libMesh::Parameters p,
void context 
)

Definition at line 578 of file DataIO.C.

579 {
580  p.clear();
581 
582  // First read the size of the map
583  unsigned int size = 0;
584  stream.read((char *)&size, sizeof(size));
585 
586  for (unsigned int i = 0; i < size; i++)
587  {
588  std::string key, type;
589  loadHelper(stream, key, context);
590  loadHelper(stream, type, context);
591 
592 #define loadscalar(ptype) \
593  else if (type == demangle(typeid(ptype).name())) do \
594  { \
595  ptype & value = p.set<ptype>(key); \
596  loadHelper(stream, value, context); \
597  } \
598  while (0)
599 
600  if (false)
601  ;
602  loadscalar(Real);
603  loadscalar(short);
604  loadscalar(int);
605  loadscalar(long);
606  loadscalar(unsigned short);
607  loadscalar(unsigned int);
608  loadscalar(unsigned long);
609 
610 #undef loadscalar
611  }
612 }
virtual void clear()
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1010

◆ dataLoad() [24/25]

template<>
void dataLoad ( std::istream &  stream,
std::unique_ptr< libMesh::NumericVector< Number >> &  v,
void context 
)

Definition at line 616 of file DataIO.C.

617 {
618  bool have_vector;
619  dataLoad(stream, have_vector, context);
620 
621  if (!have_vector)
622  return;
623 
624  mooseAssert(context, "Needs a context of the communicator");
625  const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
626  if (v)
627  mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
628 
629  // Load the communicator size for consistency checks
630  unsigned int comm_size;
631  dataLoad(stream, comm_size, nullptr);
632  mooseAssert(comm.size() == comm_size, "Inconsistent communicator size");
633 
634  // Load the solver package to build the vector
635  int solver_package_int;
636  dataLoad(stream, solver_package_int, nullptr);
637  libMesh::SolverPackage solver_package = static_cast<libMesh::SolverPackage>(solver_package_int);
638 
639  // Load the sizes
640  dof_id_type size, local_size;
641  dataLoad(stream, size, nullptr);
642  dataLoad(stream, local_size, nullptr);
643 
644  // Construct the vector given the type, only if we need to. v could be non-null here
645  // if we're advancing back and loading a backup
646  if (!v)
647  {
648  v = NumericVector<Number>::build(comm, solver_package);
649  v->init(size, local_size);
650  }
651  else
652  mooseAssert(v->type() != GHOSTED, "Cannot be ghosted");
653 
654  // Make sure that the sizes are consistent; this will happen if we're calling this
655  // on a vector that has already been loaded previously
656  mooseAssert(v->size() == size, "Inconsistent size");
657  mooseAssert(v->local_size() == local_size, "Inconsistent local size");
658 
659  // Now that we have an initialized vector, fill the entries
660  dataLoad(stream, *v, nullptr);
661 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343
GHOSTED
uint8_t dof_id_type

◆ dataLoad() [25/25]

template<>
void dataLoad ( std::istream &  stream,
Vec &  v,
void context 
)

Definition at line 665 of file DataIO.C.

666 {
667  PetscInt local_size;
668  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
669  PetscScalar * array;
670  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
671  for (PetscInt i = 0; i < local_size; i++)
672  dataLoad(stream, array[i], context);
673 
674  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
675 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:343

◆ dataStore() [1/28]

template<>
void dataStore ( std::ostream &  stream,
Real v,
void  
)

Definition at line 28 of file DataIO.C.

Referenced by dataStore().

29 {
30  stream.write((char *)&v, sizeof(v));
31 }

◆ dataStore() [2/28]

template<>
void dataStore ( std::ostream &  stream,
std::string &  v,
void  
)

Definition at line 35 of file DataIO.C.

36 {
37  // Write the size of the string
38  unsigned int size = v.size();
39  stream.write((char *)&size, sizeof(size));
40 
41  // Write the string (Do not store the null byte)
42  stream.write(v.c_str(), sizeof(char) * size);
43 }

◆ dataStore() [3/28]

template<>
void dataStore ( std::ostream &  stream,
VariableName &  v,
void context 
)

Definition at line 47 of file DataIO.C.

48 {
49  auto & name = static_cast<std::string &>(v);
50  dataStore(stream, name, context);
51 }
std::string name(const ElemQuality q)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [4/28]

template<>
void dataStore ( std::ostream &  stream,
UserObjectName &  v,
void context 
)

Definition at line 55 of file DataIO.C.

56 {
57  auto & name = static_cast<std::string &>(v);
58  dataStore(stream, name, context);
59 }
std::string name(const ElemQuality q)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [5/28]

template<>
void dataStore ( std::ostream &  stream,
bool &  v,
void  
)

Definition at line 63 of file DataIO.C.

64 {
65  stream.write((char *)&v, sizeof(v));
66 }

◆ dataStore() [6/28]

template<>
void dataStore ( std::ostream &  stream,
std::vector< bool > &  v,
void context 
)

Definition at line 70 of file DataIO.C.

71 {
72  for (bool b : v)
73  dataStore(stream, b, context);
74 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [7/28]

template<>
void dataStore ( std::ostream &  stream,
RankTwoTensor rtt,
void context 
)

Definition at line 78 of file DataIO.C.

79 {
80  dataStore(stream, rtt._coords, context);
81 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [8/28]

template<>
void dataStore ( std::ostream &  stream,
RankThreeTensor rtht,
void context 
)

Definition at line 85 of file DataIO.C.

86 {
87  dataStore(stream, rtht._vals, context);
88 }
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) ...
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [9/28]

template<>
void dataStore ( std::ostream &  stream,
RankFourTensor rft,
void context 
)

Definition at line 92 of file DataIO.C.

93 {
94  dataStore(stream, rft._vals, context);
95 }
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [10/28]

template<>
void dataStore ( std::ostream &  stream,
ADReal dn,
void context 
)

Definition at line 99 of file DataIO.C.

100 {
101  dataStore(stream, dn.value(), context);
102 
103  if (ADReal::do_derivatives)
104  {
105  auto & derivatives = dn.derivatives();
106  std::size_t size = derivatives.size();
107  dataStore(stream, size, context);
108  for (MooseIndex(size) i = 0; i < size; ++i)
109  {
110  dataStore(stream, derivatives.raw_index(i), context);
111  dataStore(stream, derivatives.raw_at(i), context);
112  }
113  }
114 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [11/28]

template<>
void dataStore ( std::ostream &  stream,
const Elem *&  e,
void context 
)

Definition at line 118 of file DataIO.C.

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

◆ dataStore() [12/28]

template<>
void dataStore ( std::ostream &  stream,
const Node *&  n,
void context 
)

Definition at line 135 of file DataIO.C.

136 {
137  // TODO: Write out the unique ID of this node
139 
140  if (n)
141  {
142  id = n->id();
144  mooseError("Can't output Nodes with invalid ids!");
145  }
146 
147  storeHelper(stream, id, context);
148 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:918
dof_id_type id() const
static constexpr dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [13/28]

template<>
void dataStore ( std::ostream &  stream,
Elem *&  e,
void context 
)

Definition at line 152 of file DataIO.C.

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

◆ dataStore() [14/28]

template<>
void dataStore ( std::ostream &  stream,
Node *&  n,
void context 
)

Definition at line 169 of file DataIO.C.

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

◆ dataStore() [15/28]

template<>
void dataStore ( std::ostream &  stream,
std::stringstream &  s,
void  
)

Definition at line 186 of file DataIO.C.

187 {
188  const std::string & s_str = s.str();
189 
190  size_t s_size = s_str.size();
191  stream.write((char *)&s_size, sizeof(s_size));
192 
193  stream.write(s_str.c_str(), sizeof(char) * (s_str.size()));
194 }

◆ dataStore() [16/28]

template<typename T >
void dataStore ( std::ostream &  stream,
TensorValue< T > &  v,
void context 
)

Definition at line 198 of file DataIO.C.

199 {
200  for (const auto i : make_range(Moose::dim))
201  for (const auto j : make_range(Moose::dim))
202  {
203  T r = v(i, j);
204  dataStore(stream, r, context);
205  }
206 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:162
IntRange< T > make_range(T beg, T end)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [17/28]

template void dataStore ( std::ostream &  stream,
TensorValue< Real > &  v,
void context 
)

◆ dataStore() [18/28]

template void dataStore ( std::ostream &  stream,
TensorValue< ADReal > &  v,
void context 
)

◆ dataStore() [19/28]

template<typename T >
void dataStore ( std::ostream &  stream,
DenseMatrix< T > &  v,
void context 
)

Definition at line 213 of file DataIO.C.

214 {
215  unsigned int m = v.m();
216  unsigned int n = v.n();
217  stream.write((char *)&m, sizeof(m));
218  stream.write((char *)&n, sizeof(n));
219  for (unsigned int i = 0; i < m; i++)
220  for (unsigned int j = 0; j < n; j++)
221  {
222  T r = v(i, j);
223  dataStore(stream, r, context);
224  }
225 }
unsigned int m() const
unsigned int n() const
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [20/28]

template void dataStore ( std::ostream &  stream,
DenseMatrix< Real > &  v,
void context 
)

◆ dataStore() [21/28]

template void dataStore ( std::ostream &  stream,
DenseMatrix< ADReal > &  v,
void context 
)

◆ dataStore() [22/28]

template<typename T >
void dataStore ( std::ostream &  stream,
VectorValue< T > &  v,
void context 
)

Definition at line 232 of file DataIO.C.

233 {
234  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
235  // won't work.
236  for (const auto i : make_range(Moose::dim))
237  {
238  T r = v(i);
239  dataStore(stream, r, context);
240  }
241 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:162
IntRange< T > make_range(T beg, T end)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [23/28]

template void dataStore ( std::ostream &  stream,
VectorValue< Real > &  v,
void context 
)

◆ dataStore() [24/28]

template void dataStore ( std::ostream &  stream,
VectorValue< ADReal > &  v,
void context 
)

◆ dataStore() [25/28]

void dataStore ( std::ostream &  stream,
Point p,
void context 
)

Definition at line 247 of file DataIO.C.

248 {
249  for (const auto i : make_range(Moose::dim))
250  {
251  Real r = p(i);
252  dataStore(stream, r, context);
253  }
254 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:162
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [26/28]

template<>
void dataStore ( std::ostream &  stream,
libMesh::Parameters p,
void context 
)

Definition at line 258 of file DataIO.C.

259 {
260  // First store the size of the map
261  unsigned int size = p.n_parameters();
262  stream.write((char *)&size, sizeof(size));
263 
264  auto it = p.begin();
265  auto end = p.end();
266 
267  for (; it != end; ++it)
268  {
269  auto & key = const_cast<std::string &>(it->first);
270  auto type = it->second->type();
271 
272  storeHelper(stream, key, context);
273  storeHelper(stream, type, context);
274 
275 #define storescalar(ptype) \
276  else if (it->second->type() == demangle(typeid(ptype).name())) storeHelper( \
277  stream, \
278  (dynamic_cast<libMesh::Parameters::Parameter<ptype> *>(MooseUtils::get(it->second)))->get(), \
279  context)
280 
281  if (false)
282  ;
283  storescalar(Real);
284  storescalar(short);
285  storescalar(int);
286  storescalar(long);
287  storescalar(unsigned short);
288  storescalar(unsigned int);
289  storescalar(unsigned long);
290 
291 #undef storescalar
292  }
293 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:918
std::size_t n_parameters() const

◆ dataStore() [27/28]

template<>
void dataStore ( std::ostream &  stream,
std::unique_ptr< libMesh::NumericVector< Number >> &  v,
void context 
)

Definition at line 297 of file DataIO.C.

300 {
301  // Classes may declare unique pointers to vectors as restartable data and never actually create
302  // vector instances. This happens for example in the `TimeIntegrator` class where subvector
303  // instances are only created if multiple time integrators are present
304  bool have_vector = v.get();
305  dataStore(stream, have_vector, context);
306  if (!have_vector)
307  return;
308 
309  mooseAssert(context, "Needs a context of the communicator");
310  const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
311  mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
312 
313  if (v->type() == GHOSTED)
314  mooseError("Cannot store ghosted numeric vectors");
315 
316  // Store the communicator size for sanity checking later
317  unsigned int comm_size = comm.size();
318  dataStore(stream, comm_size, nullptr);
319 
320  // Store the solver package so that we know what vector type to construct
321  libMesh::SolverPackage solver_package;
322  if (dynamic_cast<libMesh::PetscVector<Number> *>(v.get()))
323  solver_package = PETSC_SOLVERS;
324  else
325  mooseError("Can only store unique_ptrs of PetscVectors");
326  int solver_package_int = solver_package;
327  dataStore(stream, solver_package_int, nullptr);
328 
329  // Store the sizes
330  dof_id_type size = v->size();
331  dataStore(stream, size, nullptr);
332  dof_id_type local_size = v->local_size();
333  dataStore(stream, local_size, nullptr);
334 
335  // Store the vector itself
336  dataStore(stream, *v, nullptr);
337 }
PETSC_SOLVERS
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
GHOSTED
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28
uint8_t dof_id_type

◆ dataStore() [28/28]

template<>
void dataStore ( std::ostream &  stream,
Vec &  v,
void context 
)

Definition at line 679 of file DataIO.C.

680 {
681  PetscInt local_size;
682  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
683  PetscScalar * array;
684  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
685  for (PetscInt i = 0; i < local_size; i++)
686  dataStore(stream, array[i], context);
687 
688  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
689 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28