https://mooseframework.inl.gov
Loading...
Searching...
No Matches
KokkosMaterialPropertyStorage.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://www.mooseframework.org
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
13
14class FEProblemBase;
15
16void
17dataStore(std::ostream & stream, Moose::Kokkos::MaterialPropertyStorage & storage, void * context);
18void
19dataLoad(std::istream & stream, Moose::Kokkos::MaterialPropertyStorage & storage, void * context);
20
21namespace Moose::Kokkos
22{
23
28{
29 friend void ::dataStore(std::ostream &, MaterialPropertyStorage &, void *);
30 friend void ::dataLoad(std::istream &, MaterialPropertyStorage &, void *);
31
32public:
37
44
45 using ::MaterialPropertyStorage::addConsumer;
46 using ::MaterialPropertyStorage::getConsumers;
47 using ::MaterialPropertyStorage::getMaterialData;
48 using ::MaterialPropertyStorage::getMaterialPropertyRegistry;
49 using ::MaterialPropertyStorage::hasStatefulProperties;
50 using ::MaterialPropertyStorage::setRecovering;
51
52#ifdef MOOSE_KOKKOS_SCOPE
63 MaterialPropertyBase & addKokkosProperty(const std::string & prop_name,
64 const std::type_info & type,
65 const unsigned int state,
66 const ::MaterialBase * declarer,
67 std::shared_ptr<MaterialPropertyBase> shell);
75 MaterialPropertyBase & addKokkosPropertyState(const std::string & prop_name,
76 const unsigned int state,
77 std::shared_ptr<MaterialPropertyBase> shell);
90 MaterialPropertyBase & declareKokkosProperty(const std::string & prop_name,
91 const std::type_info & type,
92 const ::MaterialBase * declarer,
93 const std::vector<unsigned int> & dims,
94 const bool bnd,
95 const bool on_demand,
96 const PropertyConstantOption constant_option,
97 std::shared_ptr<MaterialPropertyBase> shell);
104 MaterialPropertyBase & getKokkosProperty(std::string prop_name, unsigned int state = 0);
111 bool haveKokkosProperty(std::string prop_name, unsigned int state = 0);
118 void registerLoadStore(std::type_index type, PropertyStore store, PropertyLoad load);
123#endif
124
128 void shift();
132 void copy();
133
134private:
138 std::unordered_map<std::string, std::shared_ptr<MaterialPropertyBase>>
143 std::unordered_map<std::string, Moose::Kokkos::PropRecord> _kokkos_prop_records;
148 static std::unordered_map<std::type_index, PropertyStore> _store_functions;
149 static std::unordered_map<std::type_index, PropertyLoad> _load_functions;
151};
152
153} // namespace Moose::Kokkos
void dataStore(std::ostream &stream, Moose::Kokkos::MaterialPropertyStorage &storage, void *context)
void dataLoad(std::istream &stream, Moose::Kokkos::MaterialPropertyStorage &storage, void *context)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
static constexpr unsigned int max_state
The max time state supported (2 = older)
Registry class for material property IDs and names.
Stores the stateful material properties computed by materials.
The base class for Kokkos material properties.
The Kokkos class responsible for allocating and storing Kokkos material properties.
void allocateKokkosProperties()
Allocate all the material property data storages.
void shift()
Shift current, old, and older material property data storages.
MaterialPropertyStorage(MaterialPropertyRegistry &registry, FEProblemBase &problem)
Constructor.
static std::unordered_map< std::type_index, PropertyStore > _store_functions
Function pointer maps for load/store.
MaterialPropertyBase & addKokkosProperty(const std::string &prop_name, const std::type_info &type, const unsigned int state, const ::MaterialBase *declarer, std::shared_ptr< MaterialPropertyBase > shell)
Add a material property.
MaterialPropertyBase & declareKokkosProperty(const std::string &prop_name, const std::type_info &type, const ::MaterialBase *declarer, const std::vector< unsigned int > &dims, const bool bnd, const bool on_demand, const PropertyConstantOption constant_option, std::shared_ptr< MaterialPropertyBase > shell)
Declare a material property.
void copy()
Copy current material properties to old and older.
static std::unordered_map< std::type_index, PropertyLoad > _load_functions
bool haveKokkosProperty(std::string prop_name, unsigned int state=0)
Get whether a material property exists.
static MaterialPropertyStorage & cast(::MaterialPropertyStorage &storage)
Cast the reference of a Kokkos material property storage from the base type to the actual type.
std::unordered_map< std::string, std::shared_ptr< MaterialPropertyBase > > _kokkos_props[MaterialData::max_state+1]
Material properties.
MaterialPropertyBase & getKokkosProperty(std::string prop_name, unsigned int state=0)
Get a material property.
std::unordered_map< std::string, Moose::Kokkos::PropRecord > _kokkos_prop_records
Record of each material property.
void registerLoadStore(std::type_index type, PropertyStore store, PropertyLoad load)
Register the load/store functions.
MaterialPropertyBase & addKokkosPropertyState(const std::string &prop_name, const unsigned int state, std::shared_ptr< MaterialPropertyBase > shell)
Add an old/older material property.
std::function< void(std::istream &, void *)> PropertyLoad
std::function< void(std::ostream &, void *)> PropertyStore
PropertyConstantOption
Property constant options.