https://mooseframework.inl.gov
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 
14 class FEProblemBase;
15 
16 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 
21 namespace Moose::Kokkos
22 {
23 
28 {
29  friend void ::dataStore(std::ostream &, MaterialPropertyStorage &, void *);
30  friend void ::dataLoad(std::istream &, MaterialPropertyStorage &, void *);
31 
32 public:
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
53 
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 
134 private:
138  std::unordered_map<std::string, std::shared_ptr<MaterialPropertyBase>>
143  std::unordered_map<std::string, Moose::Kokkos::PropRecord> _kokkos_prop_records;
147  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
The base class for Kokkos material properties.
MaterialPropertyBase & addKokkosPropertyState(const std::string &prop_name, const unsigned int state, std::shared_ptr< MaterialPropertyBase > shell)
Add an old/older material property.
static std::unordered_map< std::type_index, PropertyLoad > _load_functions
static MaterialPropertyStorage & cast(::MaterialPropertyStorage &storage)
Cast the reference of a Kokkos material property storage from the base type to the actual type...
void shift()
Shift current, old, and older material property data storages.
Registry class for material property IDs and names.
static Moose::ParameterRegistry & registry
void allocateKokkosProperties()
Allocate all the material property data storages.
static std::unordered_map< std::type_index, PropertyStore > _store_functions
Function pointer maps for load/store.
std::function< void(std::istream &, void *)> PropertyLoad
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.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
void dataLoad(std::istream &stream, Moose::Kokkos::MaterialPropertyStorage &storage, void *context)
std::unordered_map< std::string, std::shared_ptr< MaterialPropertyBase > > _kokkos_props[MaterialData::max_state+1]
Material properties.
PropertyConstantOption
Property constant options.
std::function< void(std::ostream &, void *)> PropertyStore
MaterialPropertyBase & getKokkosProperty(std::string prop_name, unsigned int state=0)
Get a material property.
The Kokkos class responsible for allocating and storing Kokkos material properties.
static constexpr unsigned int max_state
The max time state supported (2 = older)
Definition: MaterialData.h:43
void dataStore(std::ostream &stream, Moose::Kokkos::MaterialPropertyStorage &storage, void *context)
bool haveKokkosProperty(std::string prop_name, unsigned int state=0)
Get whether a material property exists.
void registerLoadStore(std::type_index type, PropertyStore store, PropertyLoad load)
Register the load/store functions.
MaterialPropertyStorage(MaterialPropertyRegistry &registry, FEProblemBase &problem)
Constructor.
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.
std::unordered_map< std::string, Moose::Kokkos::PropRecord > _kokkos_prop_records
Record of each material property.
void copy()
Copy current material properties to old and older.