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, FEType &v, void *context)
 
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, FEType &v, void *context)
 
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/26]

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

Definition at line 369 of file DataIO.C.

Referenced by dataLoad().

370 {
371  stream.read((char *)&v, sizeof(v));
372 }

◆ dataLoad() [2/26]

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

Definition at line 376 of file DataIO.C.

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

◆ dataLoad() [3/26]

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

Definition at line 391 of file DataIO.C.

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

◆ dataLoad() [4/26]

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

Definition at line 399 of file DataIO.C.

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

◆ dataLoad() [5/26]

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

Definition at line 407 of file DataIO.C.

408 {
409  stream.read((char *)&v, sizeof(v));
410 }

◆ dataLoad() [6/26]

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

Definition at line 414 of file DataIO.C.

415 {
416  int order = 0;
417  dataLoad(stream, order, context);
418  v.order = order;
419 
420  dataLoad(stream, v.family, context);
421 
422 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
423  int radial_order = 0;
424  dataLoad(stream, radial_order, context);
425  v.radial_order = radial_order;
426 
427  dataLoad(stream, v.radial_family, context);
428  dataLoad(stream, v.inf_map, context);
429 #endif
430 
431  dataLoad(stream, v.p_refinement, context);
432 }
OrderWrapper radial_order
OrderWrapper order
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369
InfMapType inf_map
FEFamily radial_family

◆ dataLoad() [7/26]

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

Definition at line 436 of file DataIO.C.

437 {
438  for (bool b : v)
439  dataLoad(stream, b, context);
440 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369

◆ dataLoad() [8/26]

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

Definition at line 444 of file DataIO.C.

445 {
446  dataLoad(stream, dn.value(), context);
447 
448  if (ADReal::do_derivatives)
449  {
450  auto & derivatives = dn.derivatives();
451  std::size_t size = 0;
452  stream.read((char *)&size, sizeof(size));
453  derivatives.resize(size);
454 
455  for (MooseIndex(derivatives) i = 0; i < derivatives.size(); ++i)
456  {
457  dataLoad(stream, derivatives.raw_index(i), context);
458  dataLoad(stream, derivatives.raw_at(i), context);
459  }
460  }
461 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369

◆ dataLoad() [9/26]

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

Definition at line 465 of file DataIO.C.

466 {
467  if (!context)
468  mooseError("Can only load Elem objects using a MooseMesh context!");
469 
470  MooseMesh * mesh = static_cast<MooseMesh *>(context);
471 
472  // TODO: Write out the unique ID of this element
474 
475  loadHelper(stream, id, context);
476 
478  e = mesh->elemPtr(id);
479  else
480  e = NULL;
481 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
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:93
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1030
uint8_t dof_id_type

◆ dataLoad() [10/26]

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

Definition at line 485 of file DataIO.C.

486 {
487  if (!context)
488  mooseError("Can only load Node objects using a MooseMesh context!");
489 
490  MooseMesh * mesh = static_cast<MooseMesh *>(context);
491 
492  // TODO: Write out the unique ID of this nodeent
494 
495  loadHelper(stream, id, context);
496 
498  n = mesh->nodePtr(id);
499  else
500  n = NULL;
501 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
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:93
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1030
uint8_t dof_id_type

◆ dataLoad() [11/26]

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

Definition at line 505 of file DataIO.C.

506 {
507  if (!context)
508  mooseError("Can only load Elem objects using a MooseMesh context!");
509 
510  MooseMesh * mesh = static_cast<MooseMesh *>(context);
511 
512  // TODO: Write out the unique ID of this element
514 
515  loadHelper(stream, id, context);
516 
518  e = mesh->elemPtr(id);
519  else
520  e = NULL;
521 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
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:93
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1030
uint8_t dof_id_type

◆ dataLoad() [12/26]

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

Definition at line 525 of file DataIO.C.

526 {
527  if (!context)
528  mooseError("Can only load Node objects using a MooseMesh context!");
529 
530  MooseMesh * mesh = static_cast<MooseMesh *>(context);
531 
532  // TODO: Write out the unique ID of this nodeent
534 
535  loadHelper(stream, id, context);
536 
538  n = mesh->nodePtr(id);
539  else
540  n = NULL;
541 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
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:93
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1030
uint8_t dof_id_type

◆ dataLoad() [13/26]

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

Definition at line 545 of file DataIO.C.

546 {
547  size_t s_size = 0;
548  stream.read((char *)&s_size, sizeof(s_size));
549 
550  std::unique_ptr<char[]> s_s = std::make_unique<char[]>(s_size);
551  stream.read(s_s.get(), s_size);
552 
553  // Clear the stringstream before loading new data into it.
554  s.str(std::string());
555  s.write(s_s.get(), s_size);
556 }

◆ dataLoad() [14/26]

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

Definition at line 560 of file DataIO.C.

561 {
562  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
563  // won't work.
564  for (const auto i : make_range(Moose::dim))
565  for (const auto j : make_range(Moose::dim))
566  {
567  T r = 0;
568  dataLoad(stream, r, context);
569  v(i, j) = r;
570  }
571 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:163
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [15/26]

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

◆ dataLoad() [16/26]

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

◆ dataLoad() [17/26]

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

Definition at line 578 of file DataIO.C.

579 {
580  unsigned int m = 0, n = 0;
581  stream.read((char *)&m, sizeof(m));
582  stream.read((char *)&n, sizeof(n));
583  v.resize(m, n);
584  for (unsigned int i = 0; i < m; i++)
585  for (unsigned int j = 0; j < n; j++)
586  {
587  T r = 0;
588  dataLoad(stream, r, context);
589  v(i, j) = r;
590  }
591 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369
void resize(const unsigned int new_m, const unsigned int new_n)

◆ dataLoad() [18/26]

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

◆ dataLoad() [19/26]

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

◆ dataLoad() [20/26]

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

Definition at line 598 of file DataIO.C.

599 {
600  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
601  // won't work.
602  for (const auto i : make_range(Moose::dim))
603  {
604  T r = 0;
605  dataLoad(stream, r, context);
606  v(i) = r;
607  }
608 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:163
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [21/26]

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

◆ dataLoad() [22/26]

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

◆ dataLoad() [23/26]

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

Definition at line 614 of file DataIO.C.

615 {
616  for (const auto i : make_range(Moose::dim))
617  {
618  Real r = 0;
619  dataLoad(stream, r, context);
620  p(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:163
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [24/26]

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

Definition at line 626 of file DataIO.C.

627 {
628  p.clear();
629 
630  // First read the size of the map
631  unsigned int size = 0;
632  stream.read((char *)&size, sizeof(size));
633 
634  for (unsigned int i = 0; i < size; i++)
635  {
636  std::string key, type;
637  loadHelper(stream, key, context);
638  loadHelper(stream, type, context);
639 
640 #define loadscalar(ptype) \
641  else if (type == demangle(typeid(ptype).name())) do \
642  { \
643  ptype & value = p.set<ptype>(key); \
644  loadHelper(stream, value, context); \
645  } \
646  while (0)
647 
648  if (false)
649  ;
650  loadscalar(Real);
651  loadscalar(short);
652  loadscalar(int);
653  loadscalar(long);
654  loadscalar(unsigned short);
655  loadscalar(unsigned int);
656  loadscalar(unsigned long);
657 
658 #undef loadscalar
659  }
660 }
virtual void clear()
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1030

◆ dataLoad() [25/26]

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

Definition at line 664 of file DataIO.C.

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

◆ dataLoad() [26/26]

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

Definition at line 713 of file DataIO.C.

714 {
715  PetscInt local_size;
716  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
717  PetscScalar * array;
718  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
719  for (PetscInt i = 0; i < local_size; i++)
720  dataLoad(stream, array[i], context);
721 
722  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
723 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:369

◆ dataStore() [1/29]

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

Definition at line 29 of file DataIO.C.

Referenced by dataStore().

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

◆ dataStore() [2/29]

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

Definition at line 36 of file DataIO.C.

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

◆ dataStore() [3/29]

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

Definition at line 48 of file DataIO.C.

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

◆ dataStore() [4/29]

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

Definition at line 56 of file DataIO.C.

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

◆ dataStore() [5/29]

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

Definition at line 64 of file DataIO.C.

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

◆ dataStore() [6/29]

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

Definition at line 71 of file DataIO.C.

72 {
73  auto order = v.order.get_order();
74  dataStore(stream, order, context);
75 
76  auto family = v.family;
77  dataStore(stream, family, context);
78 
79 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
80  auto radial_order = v.radial_order.get_order();
81  dataStore(stream, radial_order, context);
82 
83  auto radial_family = v.radial_family;
84  dataStore(stream, radial_family, context);
85 
86  auto inf_map = v.inf_map;
87  dataStore(stream, inf_map, context);
88 #endif
89 
90  auto p_refinement = v.p_refinement;
91  dataStore(stream, p_refinement, context);
92 }
OrderWrapper radial_order
OrderWrapper order
InfMapType inf_map
FEFamily radial_family
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ dataStore() [7/29]

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

Definition at line 96 of file DataIO.C.

97 {
98  for (bool b : v)
99  dataStore(stream, b, context);
100 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ dataStore() [8/29]

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

Definition at line 104 of file DataIO.C.

105 {
106  dataStore(stream, rtt._coords, context);
107 }
T _coords[LIBMESH_DIM *LIBMESH_DIM]
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ dataStore() [9/29]

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

Definition at line 111 of file DataIO.C.

112 {
113  dataStore(stream, rtht._vals, context);
114 }
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:29

◆ dataStore() [10/29]

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

Definition at line 118 of file DataIO.C.

119 {
120  dataStore(stream, rft._vals, context);
121 }
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:29

◆ dataStore() [11/29]

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

Definition at line 125 of file DataIO.C.

126 {
127  dataStore(stream, dn.value(), context);
128 
129  if (ADReal::do_derivatives)
130  {
131  auto & derivatives = dn.derivatives();
132  std::size_t size = derivatives.size();
133  dataStore(stream, size, context);
134  for (MooseIndex(size) i = 0; i < size; ++i)
135  {
136  dataStore(stream, derivatives.raw_index(i), context);
137  dataStore(stream, derivatives.raw_at(i), context);
138  }
139  }
140 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ dataStore() [12/29]

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

Definition at line 144 of file DataIO.C.

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

◆ dataStore() [13/29]

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

Definition at line 161 of file DataIO.C.

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

◆ dataStore() [14/29]

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

Definition at line 178 of file DataIO.C.

179 {
180  // TODO: Write out the unique ID of this elem
182 
183  if (e)
184  {
185  id = e->id();
187  mooseError("Can't output Elems with invalid ids!");
188  }
189 
190  storeHelper(stream, id, context);
191 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:938
dof_id_type id() const
static constexpr dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [15/29]

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

Definition at line 195 of file DataIO.C.

196 {
197  // TODO: Write out the unique ID of this node
199 
200  if (n)
201  {
202  id = n->id();
204  mooseError("Can't output Nodes with invalid ids!");
205  }
206 
207  storeHelper(stream, id, context);
208 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:938
dof_id_type id() const
static constexpr dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [16/29]

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

Definition at line 212 of file DataIO.C.

213 {
214  const std::string & s_str = s.str();
215 
216  size_t s_size = s_str.size();
217  stream.write((char *)&s_size, sizeof(s_size));
218 
219  stream.write(s_str.c_str(), sizeof(char) * (s_str.size()));
220 }

◆ dataStore() [17/29]

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

Definition at line 224 of file DataIO.C.

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

◆ dataStore() [18/29]

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

◆ dataStore() [19/29]

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

◆ dataStore() [20/29]

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

Definition at line 239 of file DataIO.C.

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

◆ dataStore() [21/29]

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

◆ dataStore() [22/29]

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

◆ dataStore() [23/29]

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

Definition at line 258 of file DataIO.C.

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

◆ dataStore() [24/29]

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

◆ dataStore() [25/29]

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

◆ dataStore() [26/29]

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

Definition at line 273 of file DataIO.C.

274 {
275  for (const auto i : make_range(Moose::dim))
276  {
277  Real r = p(i);
278  dataStore(stream, r, context);
279  }
280 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:163
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:29

◆ dataStore() [27/29]

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

Definition at line 284 of file DataIO.C.

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

◆ dataStore() [28/29]

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

Definition at line 323 of file DataIO.C.

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

◆ dataStore() [29/29]

template<>
void dataStore ( std::ostream &  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  dataStore(stream, array[i], context);
735 
736  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
737 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29