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<>
void dataStore (std::ostream &stream, torch::Tensor &t, 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, 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<>
void dataLoad (std::istream &stream, torch::Tensor &t, 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 396 of file DataIO.C.

Referenced by dataLoad().

397 {
398  stream.read((char *)&v, sizeof(v));
399 }

◆ dataLoad() [2/27]

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

Definition at line 403 of file DataIO.C.

404 {
405  // Read the size of the string
406  unsigned int size = 0;
407  stream.read((char *)&size, sizeof(size));
408 
409  // Resize the string data
410  v.resize(size);
411 
412  // Read the string
413  stream.read(&v[0], sizeof(char) * size);
414 }

◆ dataLoad() [3/27]

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

Definition at line 418 of file DataIO.C.

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

◆ dataLoad() [4/27]

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

Definition at line 426 of file DataIO.C.

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

◆ dataLoad() [5/27]

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

Definition at line 434 of file DataIO.C.

435 {
436  stream.read((char *)&v, sizeof(v));
437 }

◆ dataLoad() [6/27]

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

Definition at line 441 of file DataIO.C.

442 {
443  int order = 0;
444  dataLoad(stream, order, context);
445  v.order = order;
446 
447  dataLoad(stream, v.family, context);
448 
449 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
450  int radial_order = 0;
451  dataLoad(stream, radial_order, context);
452  v.radial_order = radial_order;
453 
454  dataLoad(stream, v.radial_family, context);
455  dataLoad(stream, v.inf_map, context);
456 #endif
457 
458  dataLoad(stream, v.p_refinement, context);
459 }
OrderWrapper radial_order
OrderWrapper order
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396
InfMapType inf_map
FEFamily radial_family

◆ dataLoad() [7/27]

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

Definition at line 463 of file DataIO.C.

464 {
465  for (bool b : v)
466  dataLoad(stream, b, context);
467 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396

◆ dataLoad() [8/27]

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

Definition at line 471 of file DataIO.C.

472 {
473  dataLoad(stream, dn.value(), context);
474 
475  if (ADReal::do_derivatives)
476  {
477  auto & derivatives = dn.derivatives();
478  std::size_t size = 0;
479  stream.read((char *)&size, sizeof(size));
480  derivatives.resize(size);
481 
482  for (MooseIndex(derivatives) i = 0; i < derivatives.size(); ++i)
483  {
484  dataLoad(stream, derivatives.raw_index(i), context);
485  dataLoad(stream, derivatives.raw_at(i), context);
486  }
487  }
488 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396

◆ dataLoad() [9/27]

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

Definition at line 492 of file DataIO.C.

493 {
494  if (!context)
495  mooseError("Can only load Elem objects using a MooseMesh context!");
496 
497  MooseMesh * mesh = static_cast<MooseMesh *>(context);
498 
499  // TODO: Write out the unique ID of this element
501 
502  loadHelper(stream, id, context);
503 
505  e = mesh->elemPtr(id);
506  else
507  e = NULL;
508 }
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:94
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1057
uint8_t dof_id_type

◆ dataLoad() [10/27]

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

Definition at line 512 of file DataIO.C.

513 {
514  if (!context)
515  mooseError("Can only load Node objects using a MooseMesh context!");
516 
517  MooseMesh * mesh = static_cast<MooseMesh *>(context);
518 
519  // TODO: Write out the unique ID of this nodeent
521 
522  loadHelper(stream, id, context);
523 
525  n = mesh->nodePtr(id);
526  else
527  n = NULL;
528 }
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:94
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1057
uint8_t dof_id_type

◆ dataLoad() [11/27]

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

Definition at line 532 of file DataIO.C.

533 {
534  if (!context)
535  mooseError("Can only load Elem objects using a MooseMesh context!");
536 
537  MooseMesh * mesh = static_cast<MooseMesh *>(context);
538 
539  // TODO: Write out the unique ID of this element
541 
542  loadHelper(stream, id, context);
543 
545  e = mesh->elemPtr(id);
546  else
547  e = NULL;
548 }
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:94
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1057
uint8_t dof_id_type

◆ dataLoad() [12/27]

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

Definition at line 552 of file DataIO.C.

553 {
554  if (!context)
555  mooseError("Can only load Node objects using a MooseMesh context!");
556 
557  MooseMesh * mesh = static_cast<MooseMesh *>(context);
558 
559  // TODO: Write out the unique ID of this nodeent
561 
562  loadHelper(stream, id, context);
563 
565  n = mesh->nodePtr(id);
566  else
567  n = NULL;
568 }
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:94
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1057
uint8_t dof_id_type

◆ dataLoad() [13/27]

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

Definition at line 572 of file DataIO.C.

573 {
574  size_t s_size = 0;
575  stream.read((char *)&s_size, sizeof(s_size));
576 
577  std::unique_ptr<char[]> s_s = std::make_unique<char[]>(s_size);
578  stream.read(s_s.get(), s_size);
579 
580  // Clear the stringstream before loading new data into it.
581  s.str(std::string());
582  s.write(s_s.get(), s_size);
583 }

◆ dataLoad() [14/27]

template<>
void dataLoad ( std::istream &  stream,
torch::Tensor t,
void context 
)

Definition at line 588 of file DataIO.C.

589 {
590  unsigned int rank = 0;
591  dataLoad(stream, rank, nullptr);
592 
593  std::vector<int64_t> sizes(rank);
594  for (unsigned int dim = 0; dim < rank; ++dim)
595  {
596  unsigned int size = 0;
597  dataLoad(stream, size, nullptr);
598  sizes[dim] = size;
599  }
600 
601  t = torch::empty(sizes, at::kDouble);
602  auto flattened = t.reshape({t.numel()});
603  auto t_accessor = flattened.accessor<Real, 1>();
604  for (int64_t i = 0; i < flattened.numel(); ++i)
605  {
606  Real r = 0;
607  dataLoad(stream, r, context);
608  t_accessor[i] = r;
609  }
610 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396
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 615 of file DataIO.C.

616 {
617  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
618  // won't work.
619  for (const auto i : make_range(Moose::dim))
620  for (const auto j : make_range(Moose::dim))
621  {
622  T r = 0;
623  dataLoad(stream, r, context);
624  v(i, j) = r;
625  }
626 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396
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 633 of file DataIO.C.

634 {
635  unsigned int m = 0, n = 0;
636  stream.read((char *)&m, sizeof(m));
637  stream.read((char *)&n, sizeof(n));
638  v.resize(m, n);
639  for (unsigned int i = 0; i < m; i++)
640  for (unsigned int j = 0; j < n; j++)
641  {
642  T r = 0;
643  dataLoad(stream, r, context);
644  v(i, j) = r;
645  }
646 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396
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 653 of file DataIO.C.

654 {
655  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
656  // won't work.
657  for (const auto i : make_range(Moose::dim))
658  {
659  T r = 0;
660  dataLoad(stream, r, context);
661  v(i) = r;
662  }
663 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396
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 669 of file DataIO.C.

670 {
671  for (const auto i : make_range(Moose::dim))
672  {
673  Real r = 0;
674  dataLoad(stream, r, context);
675  p(i) = r;
676  }
677 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396
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 681 of file DataIO.C.

682 {
683  p.clear();
684 
685  // First read the size of the map
686  unsigned int size = 0;
687  stream.read((char *)&size, sizeof(size));
688 
689  for (unsigned int i = 0; i < size; i++)
690  {
691  std::string key, type;
692  loadHelper(stream, key, context);
693  loadHelper(stream, type, context);
694 
695 #define loadscalar(ptype) \
696  else if (type == demangle(typeid(ptype).name())) do \
697  { \
698  ptype & value = p.set<ptype>(key); \
699  loadHelper(stream, value, context); \
700  } \
701  while (0)
702 
703  if (false)
704  ;
705  loadscalar(Real);
706  loadscalar(short);
707  loadscalar(int);
708  loadscalar(long);
709  loadscalar(unsigned short);
710  loadscalar(unsigned int);
711  loadscalar(unsigned long);
712 
713 #undef loadscalar
714  }
715 }
virtual void clear()
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:1057

◆ dataLoad() [26/27]

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

Definition at line 719 of file DataIO.C.

720 {
721  bool have_vector;
722  dataLoad(stream, have_vector, context);
723 
724  if (!have_vector)
725  return;
726 
727  mooseAssert(context, "Needs a context of the communicator");
728  const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
729  if (v)
730  mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
731 
732  // Load the communicator size for consistency checks
733  unsigned int comm_size;
734  dataLoad(stream, comm_size, nullptr);
735  mooseAssert(comm.size() == comm_size, "Inconsistent communicator size");
736 
737  // Load the solver package to build the vector
738  int solver_package_int;
739  dataLoad(stream, solver_package_int, nullptr);
740  libMesh::SolverPackage solver_package = static_cast<libMesh::SolverPackage>(solver_package_int);
741 
742  // Load the sizes
743  dof_id_type size, local_size;
744  dataLoad(stream, size, nullptr);
745  dataLoad(stream, local_size, nullptr);
746 
747  // Construct the vector given the type, only if we need to. v could be non-null here
748  // if we're advancing back and loading a backup
749  if (!v)
750  {
751  v = NumericVector<Number>::build(comm, solver_package);
752  v->init(size, local_size);
753  }
754  else
755  mooseAssert(v->type() != GHOSTED, "Cannot be ghosted");
756 
757  // Make sure that the sizes are consistent; this will happen if we're calling this
758  // on a vector that has already been loaded previously
759  mooseAssert(v->size() == size, "Inconsistent size");
760  mooseAssert(v->local_size() == local_size, "Inconsistent local size");
761 
762  // Now that we have an initialized vector, fill the entries
763  dataLoad(stream, *v, nullptr);
764 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396
GHOSTED
uint8_t dof_id_type

◆ dataLoad() [27/27]

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

Definition at line 768 of file DataIO.C.

769 {
770  PetscInt local_size;
771  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
772  PetscScalar * array;
773  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
774  for (PetscInt i = 0; i < local_size; i++)
775  dataLoad(stream, array[i], context);
776 
777  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
778 }
void dataLoad(std::istream &stream, Real &v, void *)
Definition: DataIO.C:396

◆ dataStore() [1/30]

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

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

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

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

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

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

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

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

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

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

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

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:965
dof_id_type id() const
static constexpr dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [13/30]

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:965
dof_id_type id() const
static constexpr dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [14/30]

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:965
dof_id_type id() const
static constexpr dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [15/30]

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:965
dof_id_type id() const
static constexpr dof_id_type invalid_id
uint8_t dof_id_type

◆ dataStore() [16/30]

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

template<>
void dataStore ( std::ostream &  stream,
torch::Tensor t,
void context 
)

Definition at line 225 of file DataIO.C.

226 {
227  const auto tensor = LibtorchUtils::toCPUContiguous(t);
228  mooseAssert(tensor.scalar_type() == at::kDouble,
229  "Restart storage currently supports only double tensors.");
230 
231  auto rank = cast_int<unsigned int>(tensor.dim());
232  dataStore(stream, rank, nullptr);
233  for (unsigned int dim = 0; dim < rank; ++dim)
234  {
235  auto size = cast_int<unsigned int>(tensor.sizes()[dim]);
236  dataStore(stream, size, nullptr);
237  }
238 
239  const auto flattened = tensor.reshape({tensor.numel()});
240  const auto t_accessor = flattened.accessor<Real, 1>();
241  for (int64_t i = 0; i < flattened.numel(); ++i)
242  {
243  Real r = t_accessor[i];
244  dataStore(stream, r, context);
245  }
246 }
torch::Tensor toCPUContiguous(const torch::Tensor &tensor)
Return a detached contiguous CPU copy of a tensor.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ dataStore() [18/30]

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

Definition at line 251 of file DataIO.C.

252 {
253  for (const auto i : make_range(Moose::dim))
254  for (const auto j : make_range(Moose::dim))
255  {
256  T r = v(i, j);
257  dataStore(stream, r, context);
258  }
259 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
IntRange< T > make_range(T beg, T end)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ 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 266 of file DataIO.C.

267 {
268  unsigned int m = v.m();
269  unsigned int n = v.n();
270  stream.write((char *)&m, sizeof(m));
271  stream.write((char *)&n, sizeof(n));
272  for (unsigned int i = 0; i < m; i++)
273  for (unsigned int j = 0; j < n; j++)
274  {
275  T r = v(i, j);
276  dataStore(stream, r, context);
277  }
278 }
unsigned int m() const
unsigned int n() const
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ 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 285 of file DataIO.C.

286 {
287  // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
288  // won't work.
289  for (const auto i : make_range(Moose::dim))
290  {
291  T r = v(i);
292  dataStore(stream, r, context);
293  }
294 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
IntRange< T > make_range(T beg, T end)
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29

◆ 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 300 of file DataIO.C.

301 {
302  for (const auto i : make_range(Moose::dim))
303  {
304  Real r = p(i);
305  dataStore(stream, r, context);
306  }
307 }
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:165
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() [28/30]

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

Definition at line 311 of file DataIO.C.

312 {
313  // First store the size of the map
314  unsigned int size = p.n_parameters();
315  stream.write((char *)&size, sizeof(size));
316 
317  auto it = p.begin();
318  auto end = p.end();
319 
320  for (; it != end; ++it)
321  {
322  auto & key = const_cast<std::string &>(it->first);
323  auto type = it->second->type();
324 
325  storeHelper(stream, key, context);
326  storeHelper(stream, type, context);
327 
328 #define storescalar(ptype) \
329  else if (it->second->type() == demangle(typeid(ptype).name())) storeHelper( \
330  stream, \
331  (dynamic_cast<libMesh::Parameters::Parameter<ptype> *>(MooseUtils::get(it->second)))->get(), \
332  context)
333 
334  if (false)
335  ;
336  storescalar(Real);
337  storescalar(short);
338  storescalar(int);
339  storescalar(long);
340  storescalar(unsigned short);
341  storescalar(unsigned int);
342  storescalar(unsigned long);
343 
344 #undef storescalar
345  }
346 }
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition: DataIO.h:965
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 350 of file DataIO.C.

353 {
354  // Classes may declare unique pointers to vectors as restartable data and never actually create
355  // vector instances. This happens for example in the `TimeIntegrator` class where subvector
356  // instances are only created if multiple time integrators are present
357  bool have_vector = v.get();
358  dataStore(stream, have_vector, context);
359  if (!have_vector)
360  return;
361 
362  mooseAssert(context, "Needs a context of the communicator");
363  const auto & comm = *static_cast<const libMesh::Parallel::Communicator *>(context);
364  mooseAssert(&comm == &v->comm(), "Inconsistent communicator");
365 
366  if (v->type() == GHOSTED)
367  mooseError("Cannot store ghosted numeric vectors");
368 
369  // Store the communicator size for sanity checking later
370  unsigned int comm_size = comm.size();
371  dataStore(stream, comm_size, nullptr);
372 
373  // Store the solver package so that we know what vector type to construct
374  libMesh::SolverPackage solver_package;
375  if (dynamic_cast<libMesh::PetscVector<Number> *>(v.get()))
376  solver_package = PETSC_SOLVERS;
377  else
378  mooseError("Can only store unique_ptrs of PetscVectors");
379  int solver_package_int = solver_package;
380  dataStore(stream, solver_package_int, nullptr);
381 
382  // Store the sizes
383  dof_id_type size = v->size();
384  dataStore(stream, size, nullptr);
385  dof_id_type local_size = v->local_size();
386  dataStore(stream, local_size, nullptr);
387 
388  // Store the vector itself
389  dataStore(stream, *v, nullptr);
390 }
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() [30/30]

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

Definition at line 782 of file DataIO.C.

783 {
784  PetscInt local_size;
785  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
786  PetscScalar * array;
787  LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
788  for (PetscInt i = 0; i < local_size; i++)
789  dataStore(stream, array[i], context);
790 
791  LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
792 }
void dataStore(std::ostream &stream, Real &v, void *)
Definition: DataIO.C:29