https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MaterialPropertyRegistry.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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
12#include <string>
13#include <unordered_map>
14#include <vector>
15#include <optional>
16
17#include "libmesh/simple_range.h"
18
20
27{
28public:
32 bool hasProperty(const std::string & name) const { return _name_to_id.count(name); }
33
37 bool hasProperty(const unsigned int id) const { return id < _id_to_name.size(); }
38
43 {
46 WriteKey(const WriteKey &) {}
47 };
48
55 unsigned int addOrGetID(const std::string & name, const WriteKey);
56
62 unsigned int getID(const std::string & name) const;
63
68 std::optional<unsigned int> queryID(const std::string & name) const;
69
73 const std::string & getName(const unsigned int id) const;
74
78 auto idsToNamesBegin() const { return _id_to_name.begin(); }
82 auto idsToNamesEnd() const { return _id_to_name.end(); }
87
91 std::size_t size() const { return _id_to_name.size(); }
92
93private:
95 std::unordered_map<std::string, unsigned int> _name_to_id;
97 std::vector<std::string> _id_to_name;
98};
Key that restricts writing data to the registry.
Registry class for material property IDs and names.
unsigned int getID(const std::string &name) const
std::vector< std::string > _id_to_name
Map of material property id -> material property name.
std::unordered_map< std::string, unsigned int > _name_to_id
Map of material property name -> material property id.
std::optional< unsigned int > queryID(const std::string &name) const
unsigned int addOrGetID(const std::string &name, const WriteKey)
bool hasProperty(const unsigned int id) const
bool hasProperty(const std::string &name) const
const std::string & getName(const unsigned int id) const
Stores the stateful material properties computed by materials.