Advanced Multi-Physics (AMP)
On-Line Documentation
Material.h
Go to the documentation of this file.
1#ifndef included_AMP_Material
2#define included_AMP_Material
3
4#include "AMP/materials/Property.h"
5
6#include <map>
7#include <memory>
8#include <string>
9#include <string_view>
10#include <vector>
11
12
13namespace AMP::Materials {
14
15
21{
22public:
24 Material() = default;
25
27 virtual ~Material() = default;
28
29public:
31 bool hasProperty( const std::string &type ) const;
32
34 virtual std::string materialName() const = 0;
35
42 std::shared_ptr<Property> property( const std::string &type );
43
50 std::shared_ptr<const Property> property( const std::string &type ) const;
51
53 std::vector<std::string> list() const;
54
55public:
57 template<class PROPERTY>
58 void addProperty( std::string_view name, std::shared_ptr<PROPERTY> property )
59 {
60 d_propertyMap[std::string( name )] = property;
61 }
62 template<class PROPERTY, typename... Args>
63 void addProperty( std::string_view name, Args &&...args )
64 {
65 auto name2 = materialName() + "::" + std::string( name );
66 d_propertyMap[std::string( name )] =
67 std::make_shared<PROPERTY>( name2, std::forward<Args>( args )... );
68 }
69
71 void
72 addStringProperty( std::string_view name, std::string value, std::string_view source = "" );
73
75 void addScalarProperty( std::string_view name,
76 double value,
77 const AMP::Units &unit = AMP::Units(),
78 std::string_view source = "" );
79
81 void addScalarProperty( std::string_view name,
83 const AMP::Units &unit = AMP::Units(),
84 std::string_view source = "" );
85
87 void addPolynomialProperty( std::string_view name,
88 const AMP::Units &unit = {},
89 std::vector<double> params = {},
90 std::vector<std::string> args = {},
91 std::vector<std::array<double, 2>> ranges = {},
92 std::vector<AMP::Units> argUnits = {},
93 std::string_view source = "" );
94
96 void addEquationProperty( std::string_view name,
97 const AMP::Units &unit,
98 std::string expression,
99 std::vector<std::string> args = {},
100 std::vector<std::array<double, 2>> ranges = {},
101 std::vector<AMP::Units> argUnits = {},
102 std::string_view source = "" );
103
104
105protected:
107 std::map<std::string, std::shared_ptr<Property>> d_propertyMap;
108};
109
110
113{
114public:
116 DatabaseMaterial( std::string_view name, std::shared_ptr<Database> db );
117
119 std::string materialName() const override { return d_name; }
120
121private:
122 std::string d_name;
123};
124
125
127void registerMaterial( const std::string &name, std::function<std::unique_ptr<Material>()> fun );
128
130std::unique_ptr<Material> getMaterial( const std::string &name );
131
133std::vector<std::string> getMaterialList();
134
136bool isMaterial( const std::string &name );
137
138
139} // namespace AMP::Materials
140
141
142#endif
Construct a material from a database.
Definition Material.h:113
std::string d_name
Name of material.
Definition Material.h:122
std::string materialName() const override
Return the name of the material.
Definition Material.h:119
DatabaseMaterial(std::string_view name, std::shared_ptr< Database > db)
Construct a material from the database.
std::vector< std::string > list() const
return a list of all properties in this material
void addProperty(std::string_view name, std::shared_ptr< PROPERTY > property)
Add a property.
Definition Material.h:58
void addScalarProperty(std::string_view name, AMP::Array< double > value, const AMP::Units &unit=AMP::Units(), std::string_view source="")
Add a constant-value fixed property.
std::map< std::string, std::shared_ptr< Property > > d_propertyMap
database of scalar properties
Definition Material.h:107
void addEquationProperty(std::string_view name, const AMP::Units &unit, std::string expression, std::vector< std::string > args={}, std::vector< std::array< double, 2 > > ranges={}, std::vector< AMP::Units > argUnits={}, std::string_view source="")
Add an equation based propoerty.
void addProperty(std::string_view name, Args &&...args)
Definition Material.h:63
std::shared_ptr< Property > property(const std::string &type)
Get the desired property.
void addScalarProperty(std::string_view name, double value, const AMP::Units &unit=AMP::Units(), std::string_view source="")
Add a constant-value fixed property.
bool hasProperty(const std::string &type) const
check if a property exists in the material
virtual std::string materialName() const =0
Return the name of the material.
void addPolynomialProperty(std::string_view name, const AMP::Units &unit={}, std::vector< double > params={}, std::vector< std::string > args={}, std::vector< std::array< double, 2 > > ranges={}, std::vector< AMP::Units > argUnits={}, std::string_view source="")
Add a polynomial based property.
Material()=default
Default constructor.
void addStringProperty(std::string_view name, std::string value, std::string_view source="")
Add a constant-value fixed property.
std::shared_ptr< const Property > property(const std::string &type) const
Get the desired property.
virtual ~Material()=default
Default destructor.
Provides a class for storing units.
Definition Units.h:101
std::unique_ptr< Material > getMaterial(const std::string &name)
Get a material.
std::vector< std::string > getMaterialList()
Get the list of materials available.
bool isMaterial(const std::string &name)
Check if the given material exists (is registered)
void registerMaterial(const std::string &name, std::function< std::unique_ptr< Material >()> fun)
Register a material with the factory.



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:40.
Comments on this page