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
22 {
23 namespace Kokkos
24 {
25 
30 {
31  friend void ::dataStore(std::ostream &, MaterialPropertyStorage &, void *);
32  friend void ::dataLoad(std::istream &, MaterialPropertyStorage &, void *);
33 
34 public:
39 
46 
47  using ::MaterialPropertyStorage::addConsumer;
48  using ::MaterialPropertyStorage::getConsumers;
49  using ::MaterialPropertyStorage::getMaterialData;
50  using ::MaterialPropertyStorage::getMaterialPropertyRegistry;
51  using ::MaterialPropertyStorage::hasStatefulProperties;
52  using ::MaterialPropertyStorage::setRecovering;
53 
54 #ifdef MOOSE_KOKKOS_SCOPE
55 
65  MaterialPropertyBase & addKokkosProperty(const std::string & prop_name,
66  const std::type_info & type,
67  const unsigned int state,
68  const ::MaterialBase * declarer,
69  std::shared_ptr<MaterialPropertyBase> shell);
77  MaterialPropertyBase & addKokkosPropertyState(const std::string & prop_name,
78  const unsigned int state,
79  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  std::shared_ptr<MaterialPropertyBase> shell);
102  MaterialPropertyBase & getKokkosProperty(std::string prop_name, unsigned int state = 0);
109  bool haveKokkosProperty(std::string prop_name, unsigned int state = 0);
116  void registerLoadStore(std::type_index type, PropertyStore store, PropertyLoad load);
121 #endif
122 
126  void shift();
130  void copy();
131 
132 private:
136  std::unordered_map<std::string, std::shared_ptr<MaterialPropertyBase>>
141  std::unordered_map<std::string, Moose::Kokkos::PropRecord> _kokkos_prop_records;
145  static std::unordered_map<std::type_index, PropertyStore> _store_functions;
147  static std::unordered_map<std::type_index, PropertyLoad> _load_functions;
149 };
150 
151 } // namespace Kokkos
152 } // namespace Moose
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.
MaterialPropertyBase & declareKokkosProperty(const std::string &prop_name, const std::type_info &type, const ::MaterialBase *declarer, const std::vector< unsigned int > &dims, const bool bnd, std::shared_ptr< MaterialPropertyBase > shell)
Declare a material property.
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.
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.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
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.