https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
DataIO.h File Reference

Go to the source code of this file.

Classes

struct  Moose::MFEM::SolutionState
 
class  libMesh::Parallel::Packing< std::basic_string< T > >
 

Namespaces

namespace  libMesh
 The following methods are specializations for using the libMesh::Parallel::packed_range_* routines for std::strings.
 
namespace  Moose
 MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to address this in their environment if C++17 compatibility isn't found.
 
namespace  Moose::MFEM
 Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
 
namespace  libMesh::Parallel
 

Functions

template<typename P >
void storeHelper (std::ostream &stream, P &data, void *context)
 Scalar helper routine.
 
template<typename P >
void storeHelper (std::ostream &stream, std::vector< P > &data, void *context)
 Vector helper routine.
 
template<typename P >
void storeHelper (std::ostream &stream, std::shared_ptr< P > &data, void *context)
 Shared pointer helper routine.
 
template<typename P >
void storeHelper (std::ostream &stream, std::unique_ptr< P > &data, void *context)
 Unique pointer helper routine.
 
template<typename P >
void storeHelper (std::ostream &stream, std::set< P > &data, void *context)
 Set helper routine.
 
template<typename P , typename Q >
void storeHelper (std::ostream &stream, std::map< P, Q > &data, void *context)
 Map helper routine.
 
template<typename P , typename Q >
void storeHelper (std::ostream &stream, std::unordered_map< P, Q > &data, void *context)
 Unordered_map helper routine.
 
template<typename P >
void storeHelper (std::ostream &stream, std::optional< P > &data, void *context)
 Optional helper routine.
 
template<typename P , typename Q >
void storeHelper (std::ostream &stream, HashMap< P, Q > &data, void *context)
 HashMap helper routine.
 
template<typename T >
void storeHelper (std::ostream &stream, UniqueStorage< T > &data, void *context)
 UniqueStorage helper routine.
 
template<typename P >
void loadHelper (std::istream &stream, P &data, void *context)
 Scalar helper routine.
 
template<typename P >
void loadHelper (std::istream &stream, std::vector< P > &data, void *context)
 Vector helper routine.
 
template<typename P >
void loadHelper (std::istream &stream, std::shared_ptr< P > &data, void *context)
 Shared Pointer helper routine.
 
template<typename P >
void loadHelper (std::istream &stream, std::unique_ptr< P > &data, void *context)
 Unique Pointer helper routine.
 
template<typename P >
void loadHelper (std::istream &stream, std::set< P > &data, void *context)
 Set helper routine.
 
template<typename P , typename Q >
void loadHelper (std::istream &stream, std::map< P, Q > &data, void *context)
 Map helper routine.
 
template<typename P , typename Q >
void loadHelper (std::istream &stream, std::unordered_map< P, Q > &data, void *context)
 Unordered_map helper routine.
 
template<typename P >
void loadHelper (std::istream &stream, std::optional< P > &data, void *context)
 Optional helper routine.
 
template<typename P , typename Q >
void loadHelper (std::istream &stream, HashMap< P, Q > &data, void *context)
 Hashmap helper routine.
 
template<typename T >
void loadHelper (std::istream &stream, UniqueStorage< T > &data, void *context)
 UniqueStorage helper routine.
 
template<typename T >
void dataStore (std::ostream &stream, T &v, void *)
 
template<typename T >
void dataStore (std::ostream &, T *&, void *)
 
void dataStore (std::ostream &stream, Point &p, void *context)
 
void dataStore (std::ostream &stream, libMesh::BoundingBox &p, void *context)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, std::pair< T, U > &p, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::vector< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::shared_ptr< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::unique_ptr< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::set< T > &s, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::list< T > &l, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::deque< T > &l, void *context)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, std::map< T, U > &m, void *context)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, std::unordered_map< T, U > &m, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::unordered_set< T > &s, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, std::optional< T > &m, void *context)
 
template<typename T , typename U >
void dataStore (std::ostream &stream, HashMap< T, U > &m, void *context)
 
template<typename T , int Rows, int Cols>
void dataStore (std::ostream &stream, Eigen::Matrix< T, Rows, Cols > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, GenericTwoVector< T > &v, void *context)
 
template<>
void dataStore (std::ostream &stream, Real &v, void *context)
 
template<>
void dataStore (std::ostream &stream, std::string &v, void *context)
 
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 *context)
 
template<>
void dataStore (std::ostream &stream, libMesh::FEType &v, void *context)
 
template<>
void dataStore (std::ostream &stream, std::vector< bool > &v, 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 *context)
 
template<>
void dataStore (std::ostream &stream, ADReal &dn, void *context)
 
template<>
void dataStore (std::ostream &stream, torch::Tensor &t, void *context)
 
template<>
void dataStore (std::ostream &stream, libMesh::Parameters &p, void *context)
 
template<>
void dataStore (std::ostream &stream, Moose::MFEM::SolutionState &state, void *context)
 
template<>
void dataStore (std::ostream &stream, std::unique_ptr< libMesh::NumericVector< libMesh::Number > > &v, void *context)
 Stores an owned numeric vector.
 
template<std::size_t N>
void dataStore (std::ostream &stream, std::array< ADReal, N > &dn, void *context)
 
template<std::size_t N>
void dataStore (std::ostream &stream, ADReal(&dn)[N], void *context)
 
template<typename T >
void dataStore (std::ostream &stream, libMesh::NumericVector< T > &v, void *context)
 
template<>
void dataStore (std::ostream &stream, Vec &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, DenseVector< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, libMesh::TensorValue< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, libMesh::DenseMatrix< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, libMesh::VectorValue< T > &v, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, RankTwoTensorTempl< T > &rtt, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, RankThreeTensorTempl< T > &rtt, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, RankFourTensorTempl< T > &rft, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, SymmetricRankTwoTensorTempl< T > &srtt, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, SymmetricRankFourTensorTempl< T > &srft, void *context)
 
template<typename T >
void dataStore (std::ostream &stream, ColumnMajorMatrixTempl< T > &cmm, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, T &v, void *)
 
template<typename T >
void dataLoad (std::istream &, T *&, void *)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, std::pair< T, U > &p, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::vector< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::shared_ptr< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::unique_ptr< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::set< T > &s, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::list< T > &l, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::deque< T > &l, void *context)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, std::map< T, U > &m, void *context)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, std::unordered_map< T, U > &m, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::unordered_set< T > &s, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, std::optional< T > &m, void *context)
 
template<typename T , typename U >
void dataLoad (std::istream &stream, HashMap< T, U > &m, void *context)
 
template<typename T , int Rows, int Cols>
void dataLoad (std::istream &stream, Eigen::Matrix< T, Rows, Cols > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, GenericTwoVector< T > &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 *)
 
template<>
void dataLoad (std::istream &stream, UserObjectName &v, void *)
 
template<>
void dataLoad (std::istream &stream, bool &v, void *)
 
template<>
void dataLoad (std::istream &stream, libMesh::FEType &v, void *)
 
template<>
void dataLoad (std::istream &stream, std::vector< bool > &v, void *)
 
template<>
void dataLoad (std::istream &stream, const Elem *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, const Node *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, Elem *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, Node *&e, void *context)
 
template<>
void dataLoad (std::istream &stream, std::stringstream &s, void *context)
 
template<>
void dataLoad (std::istream &stream, ADReal &dn, void *context)
 
template<>
void dataLoad (std::istream &stream, torch::Tensor &t, void *context)
 
template<>
void dataLoad (std::istream &stream, libMesh::Parameters &p, void *context)
 
template<>
void dataLoad (std::istream &stream, Moose::MFEM::SolutionState &state, void *context)
 
template<>
void dataLoad (std::istream &stream, std::unique_ptr< libMesh::NumericVector< libMesh::Number > > &v, void *context)
 Loads an owned numeric vector.
 
template<std::size_t N>
void dataLoad (std::istream &stream, std::array< ADReal, N > &dn, void *context)
 
template<std::size_t N>
void dataLoad (std::istream &stream, ADReal(&dn)[N], void *context)
 
template<typename T >
void dataLoad (std::istream &stream, libMesh::NumericVector< T > &v, void *context)
 
template<>
void dataLoad (std::istream &stream, Vec &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, DenseVector< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, libMesh::TensorValue< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, libMesh::DenseMatrix< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, libMesh::VectorValue< T > &v, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, RankTwoTensorTempl< T > &rtt, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, RankThreeTensorTempl< T > &rtt, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, RankFourTensorTempl< T > &rft, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, SymmetricRankTwoTensorTempl< T > &rtt, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, SymmetricRankFourTensorTempl< T > &rft, void *context)
 
template<typename T >
void dataLoad (std::istream &stream, ColumnMajorMatrixTempl< T > &cmm, void *context)
 
void dataLoad (std::istream &stream, Point &p, void *context)
 
void dataLoad (std::istream &stream, libMesh::BoundingBox &p, void *context)
 

Function Documentation

◆ dataLoad() [1/49]

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

Definition at line 613 of file DataIO.h.

614{
615 mooseError("Attempting to load a raw pointer type: \"",
616 libMesh::demangle(typeid(T).name()),
617 " *\" as restartable data!\nWrite a custom dataLoad() template specialization!\n\n");
618}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::string name(const ElemQuality q)
std::string demangle(const char *name)

◆ dataLoad() [2/49]

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

Definition at line 475 of file DataIO.C.

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

◆ dataLoad() [3/49]

template<std::size_t N>
void dataLoad ( std::istream &  stream,
ADReal(&)  dn[N],
void *  context 
)
inline

Definition at line 897 of file DataIO.h.

898{
899 for (std::size_t i = 0; i < N; ++i)
900 dataLoad(stream, dn[i], context);
901}
void dataLoad(std::istream &stream, T &v, void *)
Definition DataIO.h:594

◆ dataLoad() [4/49]

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

Definition at line 438 of file DataIO.C.

439{
440 stream.read((char *)&v, sizeof(v));
441}

◆ dataLoad() [5/49]

template<typename T >
void dataLoad ( std::istream &  stream,
ColumnMajorMatrixTempl< T > &  cmm,
void *  context 
)

Definition at line 981 of file DataIO.h.

982{
983 dataLoad(stream, cmm._values, context);
984}

◆ dataLoad() [6/49]

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

◆ dataLoad() [7/49]

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

◆ dataLoad() [8/49]

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

Definition at line 922 of file DataIO.h.

923{
924 unsigned int n = 0;
925 dataLoad(stream, n, nullptr);
926 v.resize(n);
927 for (unsigned int i = 0; i < n; i++)
928 {
929 T r = 0;
930 dataLoad(stream, r, context);
931 v(i) = r;
932 }
933}
void resize(const unsigned int n)

◆ dataLoad() [9/49]

template<typename T , int Rows, int Cols>
void dataLoad ( std::istream &  stream,
Eigen::Matrix< T, Rows, Cols > &  v,
void *  context 
)

Definition at line 803 of file DataIO.h.

804{
805 unsigned int m = 0;
806 dataLoad(stream, m, context);
807 unsigned int n = 0;
808 dataLoad(stream, n, context);
809 v.resize(m, n);
810 for (const auto i : make_range(m))
811 for (const auto j : make_range(n))
812 {
813 T r{};
814 dataLoad(stream, r, context);
815 v(i, j) = r;
816 }
817}
for(PetscInt i=0;i< nvars;++i)
IntRange< T > make_range(T beg, T end)

◆ dataLoad() [10/49]

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

◆ dataLoad() [11/49]

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

Definition at line 821 of file DataIO.h.

822{
823 dataLoad(stream, static_cast<Eigen::Matrix<T, 2, 1> &>(v), context);
824}

◆ dataLoad() [12/49]

template<typename T , typename U >
void dataLoad ( std::istream &  stream,
HashMap< T, U > &  m,
void *  context 
)
inline

Definition at line 785 of file DataIO.h.

786{
787 // First read the size of the map
788 unsigned int size = 0;
789 dataLoad(stream, size, nullptr);
790
791 for (unsigned int i = 0; i < size; i++)
792 {
793 T key;
794 loadHelper(stream, key, context);
795
796 U & value = m[key];
797 loadHelper(stream, value, context);
798 }
799}
void loadHelper(std::istream &stream, P &data, void *context)
Scalar helper routine.
Definition DataIO.h:1081
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ dataLoad() [13/49]

void dataLoad ( std::istream &  stream,
libMesh::BoundingBox p,
void *  context 
)

Definition at line 680 of file DataIO.C.

681{
682 loadHelper(stream, static_cast<std::pair<Point, Point> &>(bbox), context);
683}

◆ dataLoad() [14/49]

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

Definition at line 637 of file DataIO.C.

638{
639 unsigned int m = 0, n = 0;
640 stream.read((char *)&m, sizeof(m));
641 stream.read((char *)&n, sizeof(n));
642 v.resize(m, n);
643 for (unsigned int i = 0; i < m; i++)
644 for (unsigned int j = 0; j < n; j++)
645 {
646 T r = 0;
647 dataLoad(stream, r, context);
648 v(i, j) = r;
649 }
650}
void resize(const unsigned int new_m, const unsigned int new_n)

◆ dataLoad() [15/49]

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

Definition at line 445 of file DataIO.C.

446{
447 int order = 0;
448 dataLoad(stream, order, context);
449 v.order = order;
450
451 dataLoad(stream, v.family, context);
452
453#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
454 int radial_order = 0;
455 dataLoad(stream, radial_order, context);
456 v.radial_order = radial_order;
457
458 dataLoad(stream, v.radial_family, context);
459 dataLoad(stream, v.inf_map, context);
460#endif
461
462 dataLoad(stream, v.p_refinement, context);
463}
InfMapType inf_map
OrderWrapper radial_order
OrderWrapper order
FEFamily radial_family

◆ dataLoad() [16/49]

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

Definition at line 905 of file DataIO.h.

906{
908 for (numeric_index_type i = v.first_local_index(); i < v.first_local_index() + size; i++)
909 {
910 T r = 0;
911 dataLoad(stream, r, context);
912 v.set(i, r);
913 }
914 v.close();
915}
virtual void set(const numeric_index_type i, const T value)=0
virtual void close()=0
virtual numeric_index_type local_size() const=0
virtual numeric_index_type first_local_index() const=0
dof_id_type numeric_index_type

◆ dataLoad() [17/49]

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

Definition at line 687 of file DataIO.C.

688{
689 p.clear();
690
691 // First read the size of the map
692 unsigned int size = 0;
693 stream.read((char *)&size, sizeof(size));
694
695 for (unsigned int i = 0; i < size; i++)
696 {
697 std::string key, type;
698 loadHelper(stream, key, context);
699 loadHelper(stream, type, context);
700
701#define loadscalar(ptype) \
702 else if (type == demangle(typeid(ptype).name())) do \
703 { \
704 ptype & value = p.set<ptype>(key); \
705 loadHelper(stream, value, context); \
706 } \
707 while (0)
708
709 if (false)
710 ;
711 loadscalar(Real);
712 loadscalar(short);
713 loadscalar(int);
714 loadscalar(long);
715 loadscalar(unsigned short);
716 loadscalar(unsigned int);
717 loadscalar(unsigned long);
718
719#undef loadscalar
720 }
721}
virtual void clear()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ dataLoad() [18/49]

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

Definition at line 619 of file DataIO.C.

620{
621 // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
622 // won't work.
623 for (const auto i : make_range(Moose::dim))
624 for (const auto j : make_range(Moose::dim))
625 {
626 T r = 0;
627 dataLoad(stream, r, context);
628 v(i, j) = r;
629 }
630}
unsigned int dim
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...

◆ dataLoad() [19/49]

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

Definition at line 657 of file DataIO.C.

658{
659 // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
660 // won't work.
661 for (const auto i : make_range(Moose::dim))
662 {
663 T r = 0;
664 dataLoad(stream, r, context);
665 v(i) = r;
666 }
667}

◆ dataLoad() [20/49]

template<>
void dataLoad ( std::istream &  stream,
Moose::MFEM::SolutionState state,
void *  context 
)

Definition at line 73 of file SolutionStateData.C.

74{
75 auto * const data = static_cast<MFEMProblemData *>(context);
76
77 int num_gridfunctions = 0;
78 dataLoad(stream, num_gridfunctions, context);
79 for ([[maybe_unused]] const auto i : make_range(num_gridfunctions))
80 {
81 std::string name;
82 dataLoad(stream, name, context);
83 auto & gf = data->gridfunctions.GetRef(name);
84 loadGridFunction(stream, gf, context);
85 }
86
87 int num_complex_gridfunctions = 0;
88 dataLoad(stream, num_complex_gridfunctions, context);
89 for ([[maybe_unused]] const auto i : make_range(num_complex_gridfunctions))
90 {
91 std::string name;
92 dataLoad(stream, name, context);
93 auto & gf = data->cmplx_gridfunctions.GetRef(name);
94 loadGridFunction(stream, gf.real(), context);
95 loadGridFunction(stream, gf.imag(), context);
96 }
97}
void dataLoad(std::istream &stream, Moose::MFEM::SolutionState &, void *context)
Base problem data struct.

Referenced by dataLoad().

◆ dataLoad() [21/49]

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

◆ dataLoad() [22/49]

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

◆ dataLoad() [23/49]

template<typename T >
void dataLoad ( std::istream &  stream,
RankFourTensorTempl< T > &  rft,
void *  context 
)

Definition at line 960 of file DataIO.h.

961{
962 dataLoad(stream, rft._vals, context);
963}
T _vals[N4]
The values of the rank-four tensor stored by index=(((i * LIBMESH_DIM + j) * LIBMESH_DIM + k) * LIBME...

◆ dataLoad() [24/49]

template<typename T >
void dataLoad ( std::istream &  stream,
RankThreeTensorTempl< T > &  rtt,
void *  context 
)

Definition at line 953 of file DataIO.h.

954{
955 dataLoad(stream, rtt._vals, context);
956}
T _vals[N3]
The values of the rank-three tensor stored by index=((i * LIBMESH_DIM + j) * LIBMESH_DIM + k)

◆ dataLoad() [25/49]

template<typename T >
void dataLoad ( std::istream &  stream,
RankTwoTensorTempl< T > &  rtt,
void *  context 
)

Definition at line 946 of file DataIO.h.

947{
948 dataLoad(stream, rtt._coords, context);
949}
T _coords[LIBMESH_DIM *LIBMESH_DIM]

◆ dataLoad() [26/49]

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

Definition at line 400 of file DataIO.C.

401{
402 stream.read((char *)&v, sizeof(v));
403}

Referenced by dataLoad(), dataLoad(), dataLoad(), dataLoad(), dataLoad(), dataLoad(), dataLoad(), dataLoad(), dataLoad(), dataLoad(), dataLoad(), and dataLoad().

◆ dataLoad() [27/49]

template<std::size_t N>
void dataLoad ( std::istream &  stream,
std::array< ADReal, N > &  dn,
void *  context 
)
inline

Definition at line 889 of file DataIO.h.

890{
891 for (std::size_t i = 0; i < N; ++i)
892 dataLoad(stream, dn[i], context);
893}

◆ dataLoad() [28/49]

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

Definition at line 694 of file DataIO.h.

695{
696 // First read the size of the container
697 unsigned int size = 0;
698 dataLoad(stream, size, nullptr);
699
700 for (unsigned int i = 0; i < size; i++)
701 {
702 T data;
703 loadHelper(stream, data, context);
704 l.push_back(std::move(data));
705 }
706}

◆ dataLoad() [29/49]

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

Definition at line 678 of file DataIO.h.

679{
680 // First read the size of the set
681 unsigned int size = 0;
682 dataLoad(stream, size, nullptr);
683
684 for (unsigned int i = 0; i < size; i++)
685 {
686 T data;
687 loadHelper(stream, data, context);
688 l.push_back(std::move(data));
689 }
690}

◆ dataLoad() [30/49]

template<typename T , typename U >
void dataLoad ( std::istream &  stream,
std::map< T, U > &  m,
void *  context 
)
inline

Definition at line 710 of file DataIO.h.

711{
712 m.clear();
713
714 // First read the size of the map
715 unsigned int size = 0;
716 dataLoad(stream, size, nullptr);
717
718 for (unsigned int i = 0; i < size; i++)
719 {
720 T key;
721 loadHelper(stream, key, context);
722
723 U & value = m[key];
724 loadHelper(stream, value, context);
725 }
726}

◆ dataLoad() [31/49]

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

Definition at line 769 of file DataIO.h.

770{
771 bool has_value;
772 dataLoad(stream, has_value, nullptr);
773
774 if (has_value)
775 {
776 m = T{};
777 loadHelper(stream, *m, context);
778 }
779 else
780 m.reset();
781}

◆ dataLoad() [32/49]

template<typename T , typename U >
void dataLoad ( std::istream &  stream,
std::pair< T, U > &  p,
void *  context 
)
inline

Definition at line 622 of file DataIO.h.

623{
624 loadHelper(stream, p.first, context);
625 loadHelper(stream, p.second, context);
626}

◆ dataLoad() [33/49]

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

Definition at line 662 of file DataIO.h.

663{
664 // First read the size of the set
665 unsigned int size = 0;
666 dataLoad(stream, size, nullptr);
667
668 for (unsigned int i = 0; i < size; i++)
669 {
670 T data;
671 loadHelper(stream, data, context);
672 s.insert(std::move(data));
673 }
674}

◆ dataLoad() [34/49]

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

Definition at line 644 of file DataIO.h.

645{
646 T * tmp = v.get();
647
648 loadHelper(stream, tmp, context);
649}

◆ dataLoad() [35/49]

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

Definition at line 407 of file DataIO.C.

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

◆ dataLoad() [36/49]

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

Definition at line 576 of file DataIO.C.

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

◆ dataLoad() [37/49]

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

Loads an owned numeric vector.

This is used in lieu of the NumericVector<double> & implementation when the vector may not necessarily be initialized yet on the loading of the data.

If is not null, it must have the same global and local sizes that it was stored with. In this case, the data is simply filled into the vector.

If is null, it will be constructed with the type (currently just a PetscVector) stored and initialized with the global and local sizes stored. The data will then be filled after initialization.

Requirements: the vector cannot be ghosted, the provided context must be the Communicator, and if v is initialized, it must have the same global and local sizes that the vector was stored with.

◆ dataLoad() [38/49]

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

Definition at line 653 of file DataIO.h.

654{
655 T * tmp = v.get();
656
657 loadHelper(stream, tmp, context);
658}

◆ dataLoad() [39/49]

template<typename T , typename U >
void dataLoad ( std::istream &  stream,
std::unordered_map< T, U > &  m,
void *  context 
)
inline

Definition at line 730 of file DataIO.h.

731{
732 m.clear();
733
734 // First read the size of the map
735 unsigned int size = 0;
736 dataLoad(stream, size, nullptr);
737
738 for (unsigned int i = 0; i < size; i++)
739 {
740 T key;
741 loadHelper(stream, key, context);
742
743 U & value = m[key];
744 loadHelper(stream, value, context);
745 }
746}

◆ dataLoad() [40/49]

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

Definition at line 750 of file DataIO.h.

751{
752 s.clear();
753
754 // First read the size of the set
755 std::size_t size = 0;
756 dataLoad(stream, size, nullptr);
757 s.reserve(size);
758
759 for (std::size_t i = 0; i < size; i++)
760 {
761 T element;
762 dataLoad(stream, element, context);
763 s.insert(element);
764 }
765}

◆ dataLoad() [41/49]

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

Definition at line 467 of file DataIO.C.

468{
469 for (bool b : v)
470 dataLoad(stream, b, context);
471}

◆ dataLoad() [42/49]

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

Definition at line 630 of file DataIO.h.

631{
632 // First read the size of the vector
633 unsigned int size = 0;
634 dataLoad(stream, size, nullptr);
635
636 v.resize(size);
637
638 for (unsigned int i = 0; i < size; i++)
639 loadHelper(stream, v[i], context);
640}

◆ dataLoad() [43/49]

template<typename T >
void dataLoad ( std::istream &  stream,
SymmetricRankFourTensorTempl< T > &  rft,
void *  context 
)

Definition at line 974 of file DataIO.h.

975{
976 dataLoad(stream, rft._vals, context);
977}
std::array< T, N2 > _vals
The values of the rank-four tensor.

◆ dataLoad() [44/49]

template<typename T >
void dataLoad ( std::istream &  stream,
SymmetricRankTwoTensorTempl< T > &  rtt,
void *  context 
)

Definition at line 967 of file DataIO.h.

968{
969 dataLoad(stream, rtt._vals, context);
970}

◆ dataLoad() [45/49]

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

◆ dataLoad() [46/49]

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

Definition at line 592 of file DataIO.C.

593{
594 unsigned int rank = 0;
595 dataLoad(stream, rank, nullptr);
596
597 std::vector<int64_t> sizes(rank);
598 for (unsigned int dim = 0; dim < rank; ++dim)
599 {
600 unsigned int size = 0;
601 dataLoad(stream, size, nullptr);
602 sizes[dim] = size;
603 }
604
605 t = torch::empty(sizes, at::kDouble);
606 auto flattened = t.reshape({t.numel()});
607 auto t_accessor = flattened.accessor<Real, 1>();
608 for (int64_t i = 0; i < flattened.numel(); ++i)
609 {
610 Real r = 0;
611 dataLoad(stream, r, context);
612 t_accessor[i] = r;
613 }
614}

◆ dataLoad() [47/49]

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

Definition at line 430 of file DataIO.C.

431{
432 auto & name = static_cast<std::string &>(v);
433 dataLoad(stream, name, context);
434}

◆ dataLoad() [48/49]

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

Definition at line 422 of file DataIO.C.

423{
424 auto & name = static_cast<std::string &>(v);
425 dataLoad(stream, name, context);
426}

◆ dataLoad() [49/49]

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

Definition at line 774 of file DataIO.C.

775{
776 PetscInt local_size;
777 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
778 PetscScalar * array;
779 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
780 for (PetscInt i = 0; i < local_size; i++)
781 dataLoad(stream, array[i], context);
782
783 LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
784}

◆ dataStore() [1/49]

template<typename T >
void dataStore ( std::ostream &  ,
T *&  ,
void *   
)
inline

Definition at line 225 of file DataIO.h.

226{
227 mooseError("Attempting to store a raw pointer type: \"",
228 libMesh::demangle(typeid(T).name()),
229 " *\" as restartable data!\nWrite a custom dataStore() template specialization!\n\n");
230}

◆ dataStore() [2/49]

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

Definition at line 126 of file DataIO.C.

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

◆ dataStore() [3/49]

template<std::size_t N>
void dataStore ( std::ostream &  stream,
ADReal(&)  dn[N],
void *  context 
)
inline

Definition at line 502 of file DataIO.h.

503{
504 for (std::size_t i = 0; i < N; ++i)
505 dataStore(stream, dn[i], context);
506}
void dataStore(std::ostream &stream, T &v, void *)
Definition DataIO.h:197

◆ dataStore() [4/49]

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

Definition at line 65 of file DataIO.C.

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

◆ dataStore() [5/49]

template<typename T >
void dataStore ( std::ostream &  stream,
ColumnMajorMatrixTempl< T > &  cmm,
void *  context 
)

Definition at line 585 of file DataIO.h.

586{
587 dataStore(stream, cmm._values, context);
588}

◆ dataStore() [6/49]

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

◆ dataStore() [7/49]

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

◆ dataStore() [8/49]

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

Definition at line 528 of file DataIO.h.

529{
530 unsigned int m = v.size();
531 dataStore(stream, m, nullptr);
532 for (unsigned int i = 0; i < v.size(); i++)
533 {
534 T r = v(i);
535 dataStore(stream, r, context);
536 }
537}
virtual unsigned int size() const override final

◆ dataStore() [9/49]

template<typename T , int Rows, int Cols>
void dataStore ( std::ostream &  stream,
Eigen::Matrix< T, Rows, Cols > &  v,
void *  context 
)

Definition at line 416 of file DataIO.h.

417{
418 auto m = cast_int<unsigned int>(v.rows());
419 dataStore(stream, m, context);
420 auto n = cast_int<unsigned int>(v.cols());
421 dataStore(stream, n, context);
422 for (const auto i : make_range(m))
423 for (const auto j : make_range(n))
424 {
425 auto & r = v(i, j);
426 dataStore(stream, r, context);
427 }
428}

◆ dataStore() [10/49]

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

◆ dataStore() [11/49]

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

Definition at line 432 of file DataIO.h.

433{
434 dataStore(stream, static_cast<Eigen::Matrix<T, 2, 1> &>(v), context);
435}

◆ dataStore() [12/49]

template<typename T , typename U >
void dataStore ( std::ostream &  stream,
HashMap< T, U > &  m,
void *  context 
)
inline

Definition at line 395 of file DataIO.h.

396{
397 // First store the size of the map
398 unsigned int size = m.size();
399 dataStore(stream, size, nullptr);
400
401 typename HashMap<T, U>::iterator it = m.begin();
402 typename HashMap<T, U>::iterator end = m.end();
403
404 for (; it != end; ++it)
405 {
406 T & key = const_cast<T &>(it->first);
407
408 storeHelper(stream, key, context);
409
410 storeHelper(stream, it->second, context);
411 }
412}
void storeHelper(std::ostream &stream, P &data, void *context)
Scalar helper routine.
Definition DataIO.h:989
HashMap is an abstraction for dictionary data type, we make it thread-safe by locking inserts.
Definition HashMap.h:19

◆ dataStore() [13/49]

void dataStore ( std::ostream &  stream,
libMesh::BoundingBox p,
void *  context 
)

Definition at line 308 of file DataIO.C.

309{
310 storeHelper(stream, static_cast<std::pair<Point, Point> &>(bbox), context);
311}

◆ dataStore() [14/49]

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

Definition at line 267 of file DataIO.C.

268{
269 unsigned int m = v.m();
270 unsigned int n = v.n();
271 stream.write((char *)&m, sizeof(m));
272 stream.write((char *)&n, sizeof(n));
273 for (unsigned int i = 0; i < m; i++)
274 for (unsigned int j = 0; j < n; j++)
275 {
276 T r = v(i, j);
277 dataStore(stream, r, context);
278 }
279}
unsigned int n() const
unsigned int m() const

◆ dataStore() [15/49]

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

Definition at line 72 of file DataIO.C.

73{
74 auto order = v.order.get_order();
75 dataStore(stream, order, context);
76
77 auto family = v.family;
78 dataStore(stream, family, context);
79
80#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
81 auto radial_order = v.radial_order.get_order();
82 dataStore(stream, radial_order, context);
83
84 auto radial_family = v.radial_family;
85 dataStore(stream, radial_family, context);
86
87 auto inf_map = v.inf_map;
88 dataStore(stream, inf_map, context);
89#endif
90
91 auto p_refinement = v.p_refinement;
92 dataStore(stream, p_refinement, context);
93}

◆ dataStore() [16/49]

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

Definition at line 510 of file DataIO.h.

511{
512 v.close();
513
515
516 for (numeric_index_type i = v.first_local_index(); i < v.first_local_index() + size; i++)
517 {
518 T r = v(i);
519 dataStore(stream, r, context);
520 }
521}

◆ dataStore() [17/49]

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

Definition at line 315 of file DataIO.C.

316{
317 // First store the size of the map
318 unsigned int size = p.n_parameters();
319 stream.write((char *)&size, sizeof(size));
320
321 auto it = p.begin();
322 auto end = p.end();
323
324 for (; it != end; ++it)
325 {
326 auto & key = const_cast<std::string &>(it->first);
327 auto type = it->second->type();
328
329 storeHelper(stream, key, context);
330 storeHelper(stream, type, context);
331
332#define storescalar(ptype) \
333 else if (it->second->type() == demangle(typeid(ptype).name())) storeHelper( \
334 stream, \
335 (dynamic_cast<libMesh::Parameters::Parameter<ptype> *>(MooseUtils::get(it->second)))->get(), \
336 context)
337
338 if (false)
339 ;
340 storescalar(Real);
341 storescalar(short);
342 storescalar(int);
343 storescalar(long);
344 storescalar(unsigned short);
345 storescalar(unsigned int);
346 storescalar(unsigned long);
347
348#undef storescalar
349 }
350}
std::size_t n_parameters() const

◆ dataStore() [18/49]

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

Definition at line 252 of file DataIO.C.

253{
254 for (const auto i : make_range(Moose::dim))
255 for (const auto j : make_range(Moose::dim))
256 {
257 T r = v(i, j);
258 dataStore(stream, r, context);
259 }
260}

◆ dataStore() [19/49]

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

Definition at line 286 of file DataIO.C.

287{
288 // Obviously if someone loads data with different LIBMESH_DIM than was used for saving them, it
289 // won't work.
290 for (const auto i : make_range(Moose::dim))
291 {
292 T r = v(i);
293 dataStore(stream, r, context);
294 }
295}

◆ dataStore() [20/49]

template<>
void dataStore ( std::ostream &  stream,
Moose::MFEM::SolutionState state,
void *  context 
)

Definition at line 47 of file SolutionStateData.C.

48{
49 auto * const data = static_cast<MFEMProblemData *>(context);
50
51 auto num_gridfunctions = data->gridfunctions.size();
52 dataStore(stream, num_gridfunctions, context);
53 for (const auto & [name, gridfunction] : data->gridfunctions)
54 {
55 auto stored_name = name;
56 dataStore(stream, stored_name, context);
57 storeGridFunction(stream, *gridfunction, context);
58 }
59
60 auto num_complex_gridfunctions = data->cmplx_gridfunctions.size();
61 dataStore(stream, num_complex_gridfunctions, context);
62 for (const auto & [name, gridfunction] : data->cmplx_gridfunctions)
63 {
64 auto stored_name = name;
65 dataStore(stream, stored_name, context);
66 storeGridFunction(stream, gridfunction->real(), context);
67 storeGridFunction(stream, gridfunction->imag(), context);
68 }
69}
void dataStore(std::ostream &stream, Moose::MFEM::SolutionState &, void *context)
int size()
Returns the number of elements in the map.
Moose::MFEM::GridFunctions gridfunctions

Referenced by dataStore().

◆ dataStore() [21/49]

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

◆ dataStore() [22/49]

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

◆ dataStore() [23/49]

template<typename T >
void dataStore ( std::ostream &  stream,
RankFourTensorTempl< T > &  rft,
void *  context 
)

Definition at line 564 of file DataIO.h.

565{
566 dataStore(stream, rft._vals, context);
567}

◆ dataStore() [24/49]

template<typename T >
void dataStore ( std::ostream &  stream,
RankThreeTensorTempl< T > &  rtt,
void *  context 
)

Definition at line 557 of file DataIO.h.

558{
559 dataStore(stream, rtt._vals, context);
560}

◆ dataStore() [25/49]

template<typename T >
void dataStore ( std::ostream &  stream,
RankTwoTensorTempl< T > &  rtt,
void *  context 
)

Definition at line 550 of file DataIO.h.

551{
552 dataStore(stream, rtt._coords, context);
553}

◆ dataStore() [26/49]

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

Definition at line 30 of file DataIO.C.

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

Referenced by dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), and dataStore().

◆ dataStore() [27/49]

template<std::size_t N>
void dataStore ( std::ostream &  stream,
std::array< ADReal, N > &  dn,
void *  context 
)
inline

Definition at line 494 of file DataIO.h.

495{
496 for (std::size_t i = 0; i < N; ++i)
497 dataStore(stream, dn[i], context);
498}

◆ dataStore() [28/49]

template<typename T >
void dataStore ( std::ostream &  stream,
std::deque< T > &  l,
void *  context 
)
inline

Definition at line 312 of file DataIO.h.

313{
314 // First store the size of the container
315 unsigned int size = l.size();
316 dataStore(stream, size, nullptr);
317
318 typename std::deque<T>::iterator it = l.begin();
319 typename std::deque<T>::iterator end = l.end();
320
321 for (; it != end; ++it)
322 {
323 T & x = const_cast<T &>(*it);
324 storeHelper(stream, x, context);
325 }
326}

◆ dataStore() [29/49]

template<typename T >
void dataStore ( std::ostream &  stream,
std::list< T > &  l,
void *  context 
)
inline

Definition at line 294 of file DataIO.h.

295{
296 // First store the size of the set
297 unsigned int size = l.size();
298 dataStore(stream, size, nullptr);
299
300 typename std::list<T>::iterator it = l.begin();
301 typename std::list<T>::iterator end = l.end();
302
303 for (; it != end; ++it)
304 {
305 T & x = const_cast<T &>(*it);
306 storeHelper(stream, x, context);
307 }
308}

◆ dataStore() [30/49]

template<typename T , typename U >
void dataStore ( std::ostream &  stream,
std::map< T, U > &  m,
void *  context 
)
inline

Definition at line 330 of file DataIO.h.

331{
332 // First store the size of the map
333 unsigned int size = m.size();
334 dataStore(stream, size, nullptr);
335
336 typename std::map<T, U>::iterator it = m.begin();
337 typename std::map<T, U>::iterator end = m.end();
338
339 for (; it != end; ++it)
340 {
341 T & key = const_cast<T &>(it->first);
342
343 storeHelper(stream, key, context);
344
345 storeHelper(stream, it->second, context);
346 }
347}

◆ dataStore() [31/49]

template<typename T >
void dataStore ( std::ostream &  stream,
std::optional< T > &  m,
void *  context 
)
inline

Definition at line 384 of file DataIO.h.

385{
386 bool has_value = m.has_value();
387 dataStore(stream, has_value, nullptr);
388
389 if (has_value)
390 storeHelper(stream, *m, context);
391}

◆ dataStore() [32/49]

template<typename T , typename U >
void dataStore ( std::ostream &  stream,
std::pair< T, U > &  p,
void *  context 
)
inline

Definition at line 238 of file DataIO.h.

239{
240 storeHelper(stream, p.first, context);
241 storeHelper(stream, p.second, context);
242}

◆ dataStore() [33/49]

template<typename T >
void dataStore ( std::ostream &  stream,
std::set< T > &  s,
void *  context 
)
inline

Definition at line 276 of file DataIO.h.

277{
278 // First store the size of the set
279 unsigned int size = s.size();
280 dataStore(stream, size, nullptr);
281
282 typename std::set<T>::iterator it = s.begin();
283 typename std::set<T>::iterator end = s.end();
284
285 for (; it != end; ++it)
286 {
287 T & x = const_cast<T &>(*it);
288 storeHelper(stream, x, context);
289 }
290}

◆ dataStore() [34/49]

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

Definition at line 258 of file DataIO.h.

259{
260 T * tmp = v.get();
261
262 storeHelper(stream, tmp, context);
263}

◆ dataStore() [35/49]

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

Definition at line 37 of file DataIO.C.

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

◆ dataStore() [36/49]

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

Definition at line 213 of file DataIO.C.

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

◆ dataStore() [37/49]

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

Stores an owned numeric vector.

This should be used in lieu of the NumericVector<Number> & implementation when the vector may not necessarily be initialized yet on the loading of the data. It stores the partitioning (total and local number of entries).

Requirements: the unique_ptr must exist (cannot be null), the vector cannot be ghosted, and the provided context must be the Communicator.

◆ dataStore() [38/49]

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

Definition at line 267 of file DataIO.h.

268{
269 T * tmp = v.get();
270
271 storeHelper(stream, tmp, context);
272}

◆ dataStore() [39/49]

template<typename T , typename U >
void dataStore ( std::ostream &  stream,
std::unordered_map< T, U > &  m,
void *  context 
)
inline

Definition at line 351 of file DataIO.h.

352{
353 // First store the size of the map
354 unsigned int size = m.size();
355 dataStore(stream, size, nullptr);
356
357 typename std::unordered_map<T, U>::iterator it = m.begin();
358 typename std::unordered_map<T, U>::iterator end = m.end();
359
360 for (; it != end; ++it)
361 {
362 T & key = const_cast<T &>(it->first);
363
364 storeHelper(stream, key, context);
365
366 storeHelper(stream, it->second, context);
367 }
368}

◆ dataStore() [40/49]

template<typename T >
void dataStore ( std::ostream &  stream,
std::unordered_set< T > &  s,
void *  context 
)
inline

Definition at line 372 of file DataIO.h.

373{
374 // First store the size of the set
375 std::size_t size = s.size();
376 dataStore(stream, size, nullptr);
377
378 for (auto & element : s)
379 dataStore(stream, element, context);
380}

◆ dataStore() [41/49]

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

Definition at line 97 of file DataIO.C.

98{
99 for (bool b : v)
100 dataStore(stream, b, context);
101}

◆ dataStore() [42/49]

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

Definition at line 246 of file DataIO.h.

247{
248 // First store the size of the vector
249 unsigned int size = v.size();
250 dataStore(stream, size, nullptr);
251
252 for (unsigned int i = 0; i < size; i++)
253 storeHelper(stream, v[i], context);
254}

◆ dataStore() [43/49]

template<typename T >
void dataStore ( std::ostream &  stream,
SymmetricRankFourTensorTempl< T > &  srft,
void *  context 
)

Definition at line 578 of file DataIO.h.

579{
580 dataStore(stream, srft._vals, context);
581}

◆ dataStore() [44/49]

template<typename T >
void dataStore ( std::ostream &  stream,
SymmetricRankTwoTensorTempl< T > &  srtt,
void *  context 
)

Definition at line 571 of file DataIO.h.

572{
573 dataStore(stream, srtt._vals, context);
574}

◆ dataStore() [45/49]

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

Definition at line 197 of file DataIO.h.

198{
199#ifdef LIBMESH_HAVE_CXX11_TYPE_TRAITS
200 static_assert(std::is_polymorphic<T>::value == false,
201 "Cannot serialize a class that has virtual "
202 "members!\nWrite a custom dataStore() "
203 "template specialization!\n\n");
204 static_assert(std::is_trivially_copyable<T>::value,
205 "Cannot serialize a class that is not trivially copyable!\nWrite a custom "
206 "dataStore() template specialization!\n\n");
207#endif
208
209 stream.write((char *)&v, sizeof(v));
210 mooseAssert(!stream.bad(), "Failed to store");
211}

Referenced by dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), dataStore(), storeHelper(), storeHelper(), storeHelper(), storeHelper(), storeHelper(), storeHelper(), storeHelper(), storeHelper(), and storeHelper().

◆ dataStore() [46/49]

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

Definition at line 226 of file DataIO.C.

227{
228 const auto tensor = LibtorchUtils::toCPUContiguous(t);
229 mooseAssert(tensor.scalar_type() == at::kDouble,
230 "Restart storage currently supports only double tensors.");
231
232 auto rank = cast_int<unsigned int>(tensor.dim());
233 dataStore(stream, rank, nullptr);
234 for (unsigned int dim = 0; dim < rank; ++dim)
235 {
236 auto size = cast_int<unsigned int>(tensor.sizes()[dim]);
237 dataStore(stream, size, nullptr);
238 }
239
240 const auto flattened = tensor.reshape({tensor.numel()});
241 const auto t_accessor = flattened.accessor<Real, 1>();
242 for (int64_t i = 0; i < flattened.numel(); ++i)
243 {
244 Real r = t_accessor[i];
245 dataStore(stream, r, context);
246 }
247}
torch::Tensor toCPUContiguous(const torch::Tensor &tensor)
Return a detached contiguous CPU copy of a tensor.

◆ dataStore() [47/49]

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

Definition at line 57 of file DataIO.C.

58{
59 auto & name = static_cast<std::string &>(v);
60 dataStore(stream, name, context);
61}

◆ dataStore() [48/49]

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

Definition at line 49 of file DataIO.C.

50{
51 auto & name = static_cast<std::string &>(v);
52 dataStore(stream, name, context);
53}

◆ dataStore() [49/49]

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

Definition at line 788 of file DataIO.C.

789{
790 PetscInt local_size;
791 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetLocalSize(v, &local_size));
792 PetscScalar * array;
793 LibmeshPetscCallA(PETSC_COMM_WORLD, VecGetArray(v, &array));
794 for (PetscInt i = 0; i < local_size; i++)
795 dataStore(stream, array[i], context);
796
797 LibmeshPetscCallA(PETSC_COMM_WORLD, VecRestoreArray(v, &array));
798}

◆ loadHelper() [1/10]

template<typename P , typename Q >
void loadHelper ( std::istream &  stream,
HashMap< P, Q > &  data,
void *  context 
)
inline

Hashmap helper routine.

Definition at line 1145 of file DataIO.h.

1146{
1147 dataLoad(stream, data, context);
1148}

◆ loadHelper() [2/10]

template<typename P >
void loadHelper ( std::istream &  stream,
P data,
void *  context 
)
inline

◆ loadHelper() [3/10]

template<typename P , typename Q >
void loadHelper ( std::istream &  stream,
std::map< P, Q > &  data,
void *  context 
)
inline

Map helper routine.

Definition at line 1121 of file DataIO.h.

1122{
1123 dataLoad(stream, data, context);
1124}

◆ loadHelper() [4/10]

template<typename P >
void loadHelper ( std::istream &  stream,
std::optional< P > &  data,
void *  context 
)
inline

Optional helper routine.

Definition at line 1137 of file DataIO.h.

1138{
1139 dataLoad(stream, data, context);
1140}

◆ loadHelper() [5/10]

template<typename P >
void loadHelper ( std::istream &  stream,
std::set< P > &  data,
void *  context 
)
inline

Set helper routine.

Definition at line 1113 of file DataIO.h.

1114{
1115 dataLoad(stream, data, context);
1116}

◆ loadHelper() [6/10]

template<typename P >
void loadHelper ( std::istream &  stream,
std::shared_ptr< P > &  data,
void *  context 
)
inline

Shared Pointer helper routine.

Definition at line 1097 of file DataIO.h.

1098{
1099 dataLoad(stream, data, context);
1100}

◆ loadHelper() [7/10]

template<typename P >
void loadHelper ( std::istream &  stream,
std::unique_ptr< P > &  data,
void *  context 
)
inline

Unique Pointer helper routine.

Definition at line 1105 of file DataIO.h.

1106{
1107 dataLoad(stream, data, context);
1108}

◆ loadHelper() [8/10]

template<typename P , typename Q >
void loadHelper ( std::istream &  stream,
std::unordered_map< P, Q > &  data,
void *  context 
)
inline

Unordered_map helper routine.

Definition at line 1129 of file DataIO.h.

1130{
1131 dataLoad(stream, data, context);
1132}

◆ loadHelper() [9/10]

template<typename P >
void loadHelper ( std::istream &  stream,
std::vector< P > &  data,
void *  context 
)
inline

Vector helper routine.

Definition at line 1089 of file DataIO.h.

1090{
1091 dataLoad(stream, data, context);
1092}

◆ loadHelper() [10/10]

template<typename T >
void loadHelper ( std::istream &  stream,
UniqueStorage< T > &  data,
void *  context 
)
inline

UniqueStorage helper routine.

UniqueStorage Helper Function.

The unique_ptr<T> loader is called to load the data. That is, you will likely need a specialization of unique_ptr<T> that will appropriately construct and then fill the piece of data.

Definition at line 1159 of file DataIO.h.

1160{
1161 std::size_t size;
1162 dataLoad(stream, size, nullptr);
1163 data.resize(size);
1164
1165 for (const auto i : index_range(data))
1166 loadHelper(stream, data.pointerValue(i), context);
1167}
void resize(const std::size_t size)
Resizes the underlying vector.
auto index_range(const T &sizable)

◆ storeHelper() [1/10]

template<typename P , typename Q >
void storeHelper ( std::ostream &  stream,
HashMap< P, Q > &  data,
void *  context 
)
inline

HashMap helper routine.

Definition at line 1053 of file DataIO.h.

1054{
1055 dataStore(stream, data, context);
1056}

◆ storeHelper() [2/10]

template<typename P >
void storeHelper ( std::ostream &  stream,
P data,
void *  context 
)
inline

◆ storeHelper() [3/10]

template<typename P , typename Q >
void storeHelper ( std::ostream &  stream,
std::map< P, Q > &  data,
void *  context 
)
inline

Map helper routine.

Definition at line 1029 of file DataIO.h.

1030{
1031 dataStore(stream, data, context);
1032}

◆ storeHelper() [4/10]

template<typename P >
void storeHelper ( std::ostream &  stream,
std::optional< P > &  data,
void *  context 
)
inline

Optional helper routine.

Definition at line 1045 of file DataIO.h.

1046{
1047 dataStore(stream, data, context);
1048}

◆ storeHelper() [5/10]

template<typename P >
void storeHelper ( std::ostream &  stream,
std::set< P > &  data,
void *  context 
)
inline

Set helper routine.

Definition at line 1021 of file DataIO.h.

1022{
1023 dataStore(stream, data, context);
1024}

◆ storeHelper() [6/10]

template<typename P >
void storeHelper ( std::ostream &  stream,
std::shared_ptr< P > &  data,
void *  context 
)
inline

Shared pointer helper routine.

Definition at line 1005 of file DataIO.h.

1006{
1007 dataStore(stream, data, context);
1008}

◆ storeHelper() [7/10]

template<typename P >
void storeHelper ( std::ostream &  stream,
std::unique_ptr< P > &  data,
void *  context 
)
inline

Unique pointer helper routine.

Definition at line 1013 of file DataIO.h.

1014{
1015 dataStore(stream, data, context);
1016}

◆ storeHelper() [8/10]

template<typename P , typename Q >
void storeHelper ( std::ostream &  stream,
std::unordered_map< P, Q > &  data,
void *  context 
)
inline

Unordered_map helper routine.

Definition at line 1037 of file DataIO.h.

1038{
1039 dataStore(stream, data, context);
1040}

◆ storeHelper() [9/10]

template<typename P >
void storeHelper ( std::ostream &  stream,
std::vector< P > &  data,
void *  context 
)
inline

Vector helper routine.

Definition at line 997 of file DataIO.h.

998{
999 dataStore(stream, data, context);
1000}

◆ storeHelper() [10/10]

template<typename T >
void storeHelper ( std::ostream &  stream,
UniqueStorage< T > &  data,
void *  context 
)
inline

UniqueStorage helper routine.

The data within the UniqueStorage object cannot be null. The helper for unique_ptr<T> is called to store the data.

Definition at line 1066 of file DataIO.h.

1067{
1068 std::size_t size = data.size();
1069 dataStore(stream, size, nullptr);
1070
1071 for (const auto i : index_range(data))
1072 {
1073 mooseAssert(data.hasValue(i), "Data doesn't have a value");
1074 storeHelper(stream, data.pointerValue(i), context);
1075 }
1076}
std::size_t size() const
bool hasValue(const std::size_t i) const
const std::unique_ptr< T > & pointerValue(const std::size_t i) const
Returns a read-only reference to the underlying unique pointer at index i.