Skip to content

Commit 2ee5605

Browse files
committed
Use std::any for DataIO context (#32302)
1 parent 3bd3e8c commit 2ee5605

File tree

81 files changed

+539
-513
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+539
-513
lines changed

framework/doc/content/source/restart/DataIO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Foo
7474
// Definition
7575
template <>
7676
void
77-
dataStore(std::ostream & stream, Foo & foo, void * context)
77+
dataStore(std::ostream & stream, Foo & foo, std::any context)
7878
{
7979
// Defined in terms of the simple types that MOOSE already knows how to store
8080
storeHelper(stream, foo.bar, context);
@@ -84,7 +84,7 @@ dataStore(std::ostream & stream, Foo & foo, void * context)
8484
8585
template <>
8686
void
87-
dataLoad(std::istream & stream, Foo & foo, void * context)
87+
dataLoad(std::istream & stream, Foo & foo, std::any context)
8888
{
8989
// Defined in terms of the simple types that MOOSE already knows how to read.
9090
// Note the order of the calls, they should match the dataStore routine since each

framework/include/geomsearch/PenetrationInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ class PenetrationInfo
109109

110110
// Used for Restart
111111
template <>
112-
void dataStore(std::ostream & stream, PenetrationInfo *& pinfo, void * context);
112+
void dataStore(std::ostream & stream, PenetrationInfo *& pinfo, std::any context);
113113
template <>
114-
void dataLoad(std::istream & stream, PenetrationInfo *& pinfo, void * context);
114+
void dataLoad(std::istream & stream, PenetrationInfo *& pinfo, std::any context);

framework/include/geomsearch/PenetrationLocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class PenetrationLocator : Restartable, public PerfGraphInterface
112112
*/
113113
template <>
114114
inline void
115-
dataLoad(std::istream & stream, std::map<dof_id_type, PenetrationInfo *> & m, void * context)
115+
dataLoad(std::istream & stream, std::map<dof_id_type, PenetrationInfo *> & m, std::any context)
116116
{
117117
std::map<dof_id_type, PenetrationInfo *>::iterator it = m.begin();
118118
std::map<dof_id_type, PenetrationInfo *>::iterator end = m.end();

framework/include/kokkos/base/KokkosArray.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ ArrayBase<T, dimension, index_type>::operator=(const T & scalar)
956956

957957
template <typename T, unsigned int dimension, typename index_type, LayoutType layout>
958958
void
959-
dataStore(std::ostream & stream, Array<T, dimension, index_type, layout> & array, void * context)
959+
dataStore(std::ostream & stream, Array<T, dimension, index_type, layout> & array, std::any context)
960960
{
961961
using ::dataStore;
962962

@@ -1000,7 +1000,7 @@ dataStore(std::ostream & stream, Array<T, dimension, index_type, layout> & array
10001000

10011001
template <typename T, unsigned int dimension, typename index_type, LayoutType layout>
10021002
void
1003-
dataLoad(std::istream & stream, Array<T, dimension, index_type, layout> & array, void * context)
1003+
dataLoad(std::istream & stream, Array<T, dimension, index_type, layout> & array, std::any context)
10041004
{
10051005
using ::dataLoad;
10061006

framework/include/kokkos/base/KokkosMap.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ template <typename T1, typename T2>
5858
class Map;
5959

6060
template <typename T1, typename T2>
61-
void dataStore(std::ostream & stream, Map<T1, T2> & map, void * context);
61+
void dataStore(std::ostream & stream, Map<T1, T2> & map, std::any context);
6262
template <typename T1, typename T2>
63-
void dataLoad(std::istream & stream, Map<T1, T2> & map, void * context);
63+
void dataLoad(std::istream & stream, Map<T1, T2> & map, std::any context);
6464

6565
/**
6666
* The Kokkos wrapper class for standard map.
@@ -231,8 +231,8 @@ class Map
231231
*/
232232
Array<dof_id_type> _offset;
233233

234-
friend void dataStore<T1, T2>(std::ostream &, Map<T1, T2> &, void *);
235-
friend void dataLoad<T1, T2>(std::istream &, Map<T1, T2> &, void *);
234+
friend void dataStore<T1, T2>(std::ostream &, Map<T1, T2> &, std::any);
235+
friend void dataLoad<T1, T2>(std::istream &, Map<T1, T2> &, std::any);
236236
};
237237

238238
#ifdef MOOSE_KOKKOS_SCOPE
@@ -318,7 +318,7 @@ Map<T1, T2>::find(const T1 & key) const
318318

319319
template <typename T1, typename T2>
320320
void
321-
dataStore(std::ostream & stream, Map<T1, T2> & map, void * context)
321+
dataStore(std::ostream & stream, Map<T1, T2> & map, std::any context)
322322
{
323323
using ::dataStore;
324324

@@ -330,7 +330,7 @@ dataStore(std::ostream & stream, Map<T1, T2> & map, void * context)
330330

331331
template <typename T1, typename T2>
332332
void
333-
dataLoad(std::istream & stream, Map<T1, T2> & map, void * context)
333+
dataLoad(std::istream & stream, Map<T1, T2> & map, std::any context)
334334
{
335335
using ::dataLoad;
336336

framework/include/kokkos/materials/KokkosMaterialPropertyStorage.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
class FEProblemBase;
1515

16+
void dataStore(std::ostream & stream,
17+
Moose::Kokkos::MaterialPropertyStorage & storage,
18+
std::any context);
1619
void
17-
dataStore(std::ostream & stream, Moose::Kokkos::MaterialPropertyStorage & storage, void * context);
18-
void
19-
dataLoad(std::istream & stream, Moose::Kokkos::MaterialPropertyStorage & storage, void * context);
20+
dataLoad(std::istream & stream, Moose::Kokkos::MaterialPropertyStorage & storage, std::any context);
2021

2122
namespace Moose::Kokkos
2223
{
@@ -26,8 +27,8 @@ namespace Moose::Kokkos
2627
*/
2728
class MaterialPropertyStorage : protected ::MaterialPropertyStorage
2829
{
29-
friend void ::dataStore(std::ostream &, MaterialPropertyStorage &, void *);
30-
friend void ::dataLoad(std::istream &, MaterialPropertyStorage &, void *);
30+
friend void ::dataStore(std::ostream &, MaterialPropertyStorage &, std::any);
31+
friend void ::dataLoad(std::istream &, MaterialPropertyStorage &, std::any);
3132

3233
public:
3334
/**

framework/include/libtorch/utils/LibtorchArtificialNeuralNet.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,23 @@ template <>
114114
void dataStore<Moose::LibtorchArtificialNeuralNet>(
115115
std::ostream & stream,
116116
std::shared_ptr<Moose::LibtorchArtificialNeuralNet> & nn,
117-
void * context);
117+
std::any context);
118118

119119
template <>
120120
void dataLoad<Moose::LibtorchArtificialNeuralNet>(
121121
std::istream & stream,
122122
std::shared_ptr<Moose::LibtorchArtificialNeuralNet> & nn,
123-
void * context);
123+
std::any context);
124124

125125
// This is needed because the reporter which is used to ouput the neural net parameters to JSON
126126
// requires a dataStore/dataLoad. However, these functions will be empty due to the fact that
127127
// we are only interested in the JSON output and we don't want to output everything
128128
template <>
129129
void dataStore<Moose::LibtorchArtificialNeuralNet const>(
130-
std::ostream & stream, Moose::LibtorchArtificialNeuralNet const *& nn, void * context);
130+
std::ostream & stream, Moose::LibtorchArtificialNeuralNet const *& nn, std::any context);
131131

132132
template <>
133133
void dataLoad<Moose::LibtorchArtificialNeuralNet const>(
134-
std::istream & stream, Moose::LibtorchArtificialNeuralNet const *& nn, void * context);
134+
std::istream & stream, Moose::LibtorchArtificialNeuralNet const *& nn, std::any context);
135135

136136
#endif

framework/include/materials/MaterialProperty.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class MaterialProperties : public UniqueStorage<PropertyValue>
396396
{
397397
friend class MaterialData;
398398
friend class MaterialPropertyStorage;
399-
friend void dataLoad(std::istream &, MaterialPropertyStorage &, void *);
399+
friend void dataLoad(std::istream &, MaterialPropertyStorage &, std::any);
400400

401401
WriteKey() {}
402402
WriteKey(const WriteKey &) {}
@@ -503,11 +503,11 @@ class GenericOptionalMaterialProperty : public GenericOptionalMaterialPropertyBa
503503
friend class OptionalMaterialPropertyProxy<MaterialPropertyInterface, T, is_ad>;
504504
};
505505

506-
void dataStore(std::ostream & stream, PropertyValue & p, void * context);
507-
void dataLoad(std::istream & stream, PropertyValue & p, void * context);
506+
void dataStore(std::ostream & stream, PropertyValue & p, std::any context);
507+
void dataLoad(std::istream & stream, PropertyValue & p, std::any context);
508508

509-
void dataStore(std::ostream & stream, MaterialProperties & v, void * context);
510-
void dataLoad(std::istream & stream, MaterialProperties & v, void * context);
509+
void dataStore(std::ostream & stream, MaterialProperties & v, std::any context);
510+
void dataLoad(std::istream & stream, MaterialProperties & v, std::any context);
511511

512512
template <typename T>
513513
using OptionalMaterialProperty = GenericOptionalMaterialProperty<T, false>;

framework/include/materials/MaterialPropertyStorage.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class Elem;
3232

3333
class MaterialPropertyStorage;
3434

35-
void dataStore(std::ostream & stream, MaterialPropertyStorage & storage, void * context);
36-
void dataLoad(std::istream & stream, MaterialPropertyStorage & storage, void * context);
35+
void dataStore(std::ostream & stream, MaterialPropertyStorage & storage, std::any context);
36+
void dataLoad(std::istream & stream, MaterialPropertyStorage & storage, std::any context);
3737

3838
/**
3939
* Stores the stateful material properties computed by materials.
@@ -466,8 +466,8 @@ class MaterialPropertyStorage
466466
friend class RedistributeProperties;
467467

468468
// Need non-const props from here
469-
friend void dataLoad(std::istream &, MaterialPropertyStorage &, void *);
470-
friend void dataStore(std::ostream &, MaterialPropertyStorage &, void *);
469+
friend void dataLoad(std::istream &, MaterialPropertyStorage &, std::any);
470+
friend void dataStore(std::ostream &, MaterialPropertyStorage &, std::any);
471471
};
472472

473473
inline const MaterialPropertyStorage::PropsType &
@@ -507,5 +507,7 @@ MaterialPropertyStorage::setProps(const unsigned int state)
507507
return const_cast<MaterialPropertyStorage::PropsType &>(std::as_const(*this).props(state));
508508
}
509509

510-
void dataStore(std::ostream & stream, MaterialPropertyStorage::PropRecord & record, void * context);
511-
void dataLoad(std::istream & stream, MaterialPropertyStorage::PropRecord & record, void * context);
510+
void
511+
dataStore(std::ostream & stream, MaterialPropertyStorage::PropRecord & record, std::any context);
512+
void
513+
dataLoad(std::istream & stream, MaterialPropertyStorage::PropRecord & record, std::any context);

framework/include/multiapps/MultiApp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,5 +634,5 @@ class MultiApp : public MooseObject,
634634
mutable std::optional<std::string> _cli_args_param;
635635
};
636636

637-
void dataStore(std::ostream & stream, SubAppBackups & backups, void * context);
638-
void dataLoad(std::istream & stream, SubAppBackups & backups, void * context);
637+
void dataStore(std::ostream & stream, SubAppBackups & backups, std::any context);
638+
void dataLoad(std::istream & stream, SubAppBackups & backups, std::any context);

0 commit comments

Comments
 (0)