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<>
void dataStore (std::ostream &stream, RealEigenVector &v, void *context)
 
template<>
void dataStore (std::ostream &stream, RealEigenMatrix &v, void *context)
 
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<>
void dataLoad (std::istream &stream, RealEigenVector &v, void *context)
 
template<>
void dataLoad (std::istream &stream, RealEigenMatrix &v, void *context)
 
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/27]

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

Definition at line 372 of file DataIO.C.

Referenced by dataLoad().

373 {
374  stream.read((char *)&v, sizeof(v));
375 }

◆ dataLoad() [2/27]

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

Definition at line 379 of file DataIO.C.

380 {
381  // Read the size of the string
382  unsigned int size = 0;
383  stream.read((char *)&size, sizeof(size));
384 
385  // Resize the string data
386  v.resize(size);
387 
388  // Read the string
389  stream.read(&v[0], sizeof(char) * size);
390 }

◆ dataLoad() [3/27]

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

Definition at line 394 of file DataIO.C.

395 {
396  auto & name = static_cast<std::string &>(v);
397  dataLoad(stream, name, context);
398 }
std::string name(const ElemQuality q)
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372

◆ dataLoad() [4/27]

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

Definition at line 402 of file DataIO.C.

403 {
404  auto & name = static_cast<std::string &>(v);
405  dataLoad(stream, name, context);
406 }
std::string name(const ElemQuality q)
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372

◆ dataLoad() [5/27]

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

Definition at line 410 of file DataIO.C.

411 {
412  stream.read((char *)&v, sizeof(v));
413 }

◆ dataLoad() [6/27]

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

Definition at line 417 of file DataIO.C.

418 {
419  for (bool b : v)
420  dataLoad(stream, b, context);
421 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372

◆ dataLoad() [7/27]

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

Definition at line 425 of file DataIO.C.

426 {
427  dataLoad(stream, dn.value(), context);
428 
429  if (ADReal::do_derivatives)
430  {
431  auto & derivatives = dn.derivatives();
432  std::size_t size = 0;
433  stream.read((char *)&size, sizeof(size));
434  derivatives.resize(size);
435 
436  for (MooseIndex(derivatives) i = 0; i < derivatives.size(); ++i)
437  {
438  dataLoad(stream, derivatives.raw_index(i), context);
439  dataLoad(stream, derivatives.raw_at(i), context);
440  }
441  }
442 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372

◆ dataLoad() [8/27]

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

Definition at line 446 of file DataIO.C.

447 {
448  if (!context)
449  mooseError("Can only load Elem objects using a MooseMesh context!");
450 
451  MooseMesh * mesh = static_cast<MooseMesh *>(context);
452 
453  // TODO: Write out the unique ID of this element
455 
456  loadHelper(stream, id, context);
457 
459  e = mesh->elemPtr(id);
460  else
461  e = NULL;
462 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
MeshBase & mesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
static const dof_id_type invalid_id
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:985
uint8_t dof_id_type

◆ dataLoad() [9/27]

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

Definition at line 466 of file DataIO.C.

467 {
468  if (!context)
469  mooseError("Can only load Node objects using a MooseMesh context!");
470 
471  MooseMesh * mesh = static_cast<MooseMesh *>(context);
472 
473  // TODO: Write out the unique ID of this nodeent
475 
476  loadHelper(stream, id, context);
477 
479  n = mesh->nodePtr(id);
480  else
481  n = NULL;
482 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
MeshBase & mesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
static const dof_id_type invalid_id
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:985
uint8_t dof_id_type

◆ dataLoad() [10/27]

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

Definition at line 486 of file DataIO.C.

487 {
488  if (!context)
489  mooseError("Can only load Elem objects using a MooseMesh context!");
490 
491  MooseMesh * mesh = static_cast<MooseMesh *>(context);
492 
493  // TODO: Write out the unique ID of this element
495 
496  loadHelper(stream, id, context);
497 
499  e = mesh->elemPtr(id);
500  else
501  e = NULL;
502 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
MeshBase & mesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
static const dof_id_type invalid_id
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:985
uint8_t dof_id_type

◆ dataLoad() [11/27]

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

Definition at line 506 of file DataIO.C.

507 {
508  if (!context)
509  mooseError("Can only load Node objects using a MooseMesh context!");
510 
511  MooseMesh * mesh = static_cast<MooseMesh *>(context);
512 
513  // TODO: Write out the unique ID of this nodeent
515 
516  loadHelper(stream, id, context);
517 
519  n = mesh->nodePtr(id);
520  else
521  n = NULL;
522 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
MeshBase & mesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:88
static const dof_id_type invalid_id
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:985
uint8_t dof_id_type

◆ dataLoad() [12/27]

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

Definition at line 526 of file DataIO.C.

527 {
528  size_t s_size = 0;
529  stream.read((char *)&s_size, sizeof(s_size));
530 
531  std::unique_ptr<char[]> s_s = std::make_unique<char[]>(s_size);
532  stream.read(s_s.get(), s_size);
533 
534  // Clear the stringstream before loading new data into it.
535  s.str(std::string());
536  s.write(s_s.get(), s_size);
537 }

◆ dataLoad() [13/27]

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

Definition at line 541 of file DataIO.C.

542 {
543  unsigned int n = 0;
544  stream.read((char *)&n, sizeof(n));
545  v.resize(n);
546  for (unsigned int i = 0; i < n; i++)
547  {
548  Real r = 0;
549  dataLoad(stream, r, context);
550  v(i) = r;
551  }
552 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ dataLoad() [14/27]

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

Definition at line 556 of file DataIO.C.

557 {
558  unsigned int m = 0;
559  stream.read((char *)&m, sizeof(m));
560  unsigned int n = 0;
561  stream.read((char *)&n, sizeof(n));
562  v.resize(m, n);
563  for (unsigned int i = 0; i < m; i++)
564  for (unsigned int j = 0; j < n; j++)
565  {
566  Real r = 0;
567  dataLoad(stream, r, context);
568  v(i, j) = r;
569  }
570 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ dataLoad() [15/27]

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

Definition at line 574 of file DataIO.C.

575 {
576  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
577  // won't work.
578  for (const auto i : make_range(Moose::dim))
579  for (const auto j : make_range(Moose::dim))
580  {
581  T r = 0;
582  dataLoad(stream, r, context);
583  v(i, j) = r;
584  }
585 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:154
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [16/27]

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

◆ dataLoad() [17/27]

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

◆ dataLoad() [18/27]

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

Definition at line 592 of file DataIO.C.

593 {
594  unsigned int m = 0, n = 0;
595  stream.read((char *)&m, sizeof(m));
596  stream.read((char *)&n, sizeof(n));
597  v.resize(m, n);
598  for (unsigned int i = 0; i < m; i++)
599  for (unsigned int j = 0; j < n; j++)
600  {
601  T r = 0;
602  dataLoad(stream, r, context);
603  v(i, j) = r;
604  }
605 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372
void resize(const unsigned int new_m, const unsigned int new_n)

◆ dataLoad() [19/27]

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

◆ dataLoad() [20/27]

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

◆ dataLoad() [21/27]

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

Definition at line 612 of file DataIO.C.

613 {
614  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
615  // won't work.
616  for (const auto i : make_range(Moose::dim))
617  {
618  T r = 0;
619  dataLoad(stream, r, context);
620  v(i) = r;
621  }
622 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:154
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [22/27]

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

◆ dataLoad() [23/27]

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

◆ dataLoad() [24/27]

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

Definition at line 628 of file DataIO.C.

629 {
630  for (const auto i : make_range(Moose::dim))
631  {
632  Real r = 0;
633  dataLoad(stream, r, context);
634  p(i) = r;
635  }
636 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:154
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [25/27]

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

Definition at line 640 of file DataIO.C.

641 {
642  p.clear();
643 
644  // First read the size of the map
645  unsigned int size = 0;
646  stream.read((char *)&size, sizeof(size));
647 
648  for (unsigned int i = 0; i < size; i++)
649  {
650  std::string key, type;
651  loadHelper(stream, key, context);
652  loadHelper(stream, type, context);
653 
654 #define loadscalar(ptype) \
655  else if (type == demangle(typeid(ptype).name())) do \
656  { \
657  ptype & value = p.set<ptype>(key); \
658  loadHelper(stream, value, context); \
659  } \
660  while (0)
661 
662  if (false)
663  ;
664  loadscalar(Real);
665  loadscalar(short);
666  loadscalar(int);
667  loadscalar(long);
668  loadscalar(unsigned short);
669  loadscalar(unsigned int);
670  loadscalar(unsigned long);
671 
672 #undef loadscalar
673  }
674 }
virtual void clear()
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:985

◆ dataLoad() [26/27]

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

Definition at line 678 of file DataIO.C.

679 {
680  bool have_vector;
681  dataLoad(stream, have_vector, context);
682 
683  if (!have_vector)
684  return;
685 
686  mooseAssert(context, "Needs a context of the communicator");
687  const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
688  if (v)
689  mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
690 
691  // Load the communicator size for consistency checks
692  unsigned int comm_size;
693  dataLoad(stream, comm_size, nullptr);
694  mooseAssert(comm.size() == comm_size, "Inconsistent communicator size");
695 
696  // Load the solver package to build the vector
697  int solver_package_int;
698  dataLoad(stream, solver_package_int, nullptr);
699  libMesh::SolverPackage solver_package = static_cast<libMesh::SolverPackage>(solver_package_int);
700 
701  // Load the sizes
702  dof_id_type size, local_size;
703  dataLoad(stream, size, nullptr);
704  dataLoad(stream, local_size, nullptr);
705 
706  // Construct the vector given the type, only if we need to. v could be non-null here
707  // if we're advancing back and loading a backup
708  if (!v)
709  {
710  v = NumericVector<Number>::build(comm, solver_package);
711  v->init(size, local_size);
712  }
713  else
714  mooseAssert(v->type() != GHOSTED, "Cannot be ghosted");
715 
716  // Make sure that the sizes are consistent; this will happen if we're calling this
717  // on a vector that has already been loaded previously
718  mooseAssert(v->size() == size, "Inconsistent size");
719  mooseAssert(v->local_size() == local_size, "Inconsistent local size");
720 
721  // Now that we have an initialized vector, fill the entries
722  dataLoad(stream, *v, nullptr);
723 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372
GHOSTED
uint8_t dof_id_type

◆ dataLoad() [27/27]

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

Definition at line 727 of file DataIO.C.

728 {
729  PetscInt local_size;
730  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
731  PetscScalar * array;
732  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
733  for (PetscInt i = 0; i < local_size; i++)
734  dataLoad(stream, array[i], context);
735 
736  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
737 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:372

◆ dataStore() [1/30]

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/30]

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/30]

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/30]

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/30]

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/30]

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/30]

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/30]

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/30]

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/30]

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/30]

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:302
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:893
dof_id_type id() const
static const dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [12/30]

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:302
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:893
dof_id_type id() const
static const dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [13/30]

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:302
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:893
dof_id_type id() const
static const dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [14/30]

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:302
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:893
dof_id_type id() const
static const dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [15/30]

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/30]

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

Definition at line 198 of file DataIO.C.

199 {
200  unsigned int m = v.size();
201  stream.write((char *)&m, sizeof(m));
202  for (unsigned int i = 0; i < v.size(); i++)
203  {
204  Real r = v(i);
205  dataStore(stream, r, context);
206  }
207 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [17/30]

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

Definition at line 211 of file DataIO.C.

212 {
213  unsigned int m = v.rows();
214  stream.write((char *)&m, sizeof(m));
215  unsigned int n = v.cols();
216  stream.write((char *)&n, sizeof(n));
217  for (unsigned int i = 0; i < m; i++)
218  for (unsigned int j = 0; j < n; j++)
219  {
220  Real r = v(i, j);
221  dataStore(stream, r, context);
222  }
223 }
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [18/30]

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

Definition at line 227 of file DataIO.C.

228 {
229  for (const auto i : make_range(Moose::dim))
230  for (const auto j : make_range(Moose::dim))
231  {
232  T r = v(i, j);
233  dataStore(stream, r, context);
234  }
235 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:154
IntRange< T > make_range(T beg, T end)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [19/30]

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

◆ dataStore() [20/30]

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

◆ dataStore() [21/30]

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

Definition at line 242 of file DataIO.C.

243 {
244  unsigned int m = v.m();
245  unsigned int n = v.n();
246  stream.write((char *)&m, sizeof(m));
247  stream.write((char *)&n, sizeof(n));
248  for (unsigned int i = 0; i < m; i++)
249  for (unsigned int j = 0; j < n; j++)
250  {
251  T r = v(i, j);
252  dataStore(stream, r, context);
253  }
254 }
unsigned int m() const
unsigned int n() const
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [22/30]

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

◆ dataStore() [23/30]

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

◆ dataStore() [24/30]

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

Definition at line 261 of file DataIO.C.

262 {
263  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
264  // won't work.
265  for (const auto i : make_range(Moose::dim))
266  {
267  T r = v(i);
268  dataStore(stream, r, context);
269  }
270 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:154
IntRange< T > make_range(T beg, T end)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28

◆ dataStore() [25/30]

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

◆ dataStore() [26/30]

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

◆ dataStore() [27/30]

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

Definition at line 276 of file DataIO.C.

277 {
278  for (const auto i : make_range(Moose::dim))
279  {
280  Real r = p(i);
281  dataStore(stream, r, context);
282  }
283 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:154
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() [28/30]

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

Definition at line 287 of file DataIO.C.

288 {
289  // First store the size of the map
290  unsigned int size = p.n_parameters();
291  stream.write((char *)&size, sizeof(size));
292 
293  auto it = p.begin();
294  auto end = p.end();
295 
296  for (; it != end; ++it)
297  {
298  auto & key = const_cast<std::string &>(it->first);
299  auto type = it->second->type();
300 
301  storeHelper(stream, key, context);
302  storeHelper(stream, type, context);
303 
304 #define storescalar(ptype) \
305  else if (it->second->type() == demangle(typeid(ptype).name())) storeHelper( \
306  stream, \
307  (dynamic_cast<libMesh::Parameters::Parameter<ptype> *>(MooseUtils::get(it->second)))->get(), \
308  context)
309 
310  if (false)
311  ;
312  storescalar(Real);
313  storescalar(short);
314  storescalar(int);
315  storescalar(long);
316  storescalar(unsigned short);
317  storescalar(unsigned int);
318  storescalar(unsigned long);
319 
320 #undef storescalar
321  }
322 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:893
std::size_t n_parameters() const

◆ dataStore() [29/30]

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

Definition at line 326 of file DataIO.C.

329 {
330  // Classes may declare unique pointers to vectors as restartable data and never actually create
331  // vector instances. This happens for example in the `TimeIntegrator` class where subvector
332  // instances are only created if multiple time integrators are present
333  bool have_vector = v.get();
334  dataStore(stream, have_vector, context);
335  if (!have_vector)
336  return;
337 
338  mooseAssert(context, "Needs a context of the communicator");
339  const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
340  mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
341 
342  if (v->type() == GHOSTED)
343  mooseError("Cannot store ghosted numeric vectors");
344 
345  // Store the communicator size for sanity checking later
346  unsigned int comm_size = comm.size();
347  dataStore(stream, comm_size, nullptr);
348 
349  // Store the solver package so that we know what vector type to construct
350  libMesh::SolverPackage solver_package;
351  if (dynamic_cast<libMesh::PetscVector<Number> *>(v.get()))
352  solver_package = PETSC_SOLVERS;
353  else
354  mooseError("Can only store unique_ptrs of PetscVectors");
355  int solver_package_int = solver_package;
356  dataStore(stream, solver_package_int, nullptr);
357 
358  // Store the sizes
359  dof_id_type size = v->size();
360  dataStore(stream, size, nullptr);
361  dof_id_type local_size = v->local_size();
362  dataStore(stream, local_size, nullptr);
363 
364  // Store the vector itself
365  dataStore(stream, *v, nullptr);
366 }
PETSC_SOLVERS
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
GHOSTED
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28
uint8_t dof_id_type

◆ dataStore() [30/30]

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

Definition at line 741 of file DataIO.C.

742 {
743  PetscInt local_size;
744  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
745  PetscScalar * array;
746  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
747  for (PetscInt i = 0; i < local_size; i++)
748  dataStore(stream, array[i], context);
749 
750  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
751 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:28