Phyth v0.1.0
A dimensional safe C++ header-only mechanics and electromagnetics simulation library.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Phyth::Mechanics::Material::MaterialDatabase Class Reference

Database for managing and retrieving material properties. More...

#include <Materials.hpp>

Public Member Functions

IsotropicMaterial Get (const std::string &name) const
 Retrieve a material by its registered name.
 
std::vector< std::string > ListMaterials () const
 Get a list of all registered material names.
 
void RegisterMaterial (const std::string &name, const IsotropicMaterial &material)
 Register a new material in the database.
 

Static Public Member Functions

static MaterialDatabase FromINI (const std::string &path)
 Create a MaterialDatabase from an INI configuration file.
 

Private Attributes

std::unordered_map< std::string, IsotropicMaterial > materials_
 Internal storage mapping names to materials.
 

Detailed Description

Database for managing and retrieving material properties.

Provides a central registry for isotropic materials, supporting registration, lookup, and loading from configuration files.

The database stores materials by name and returns IsotropicMaterial objects for use in structural analysis computations.

Definition at line 145 of file Materials.hpp.

Member Function Documentation

◆ FromINI()

static MaterialDatabase Phyth::Mechanics::Material::MaterialDatabase::FromINI ( const std::string &  path)
inlinestatic

Create a MaterialDatabase from an INI configuration file.

Parses the specified INI file and registers all materials found.

Parameters
pathPath to the INI configuration file
Returns
MaterialDatabase& Reference to the constructed database
Exceptions
std::runtime_errorIf the file cannot be opened or parsed
INI File Format:
youngs_modulus = 210e9 # E in Pa
poisson_ratio = 0.3 # nu (dimensionless)
constexpr bool is_unit_v
Definition Unit.hpp:79
or
E = 210e9 # E in Pa
nu = 0.3 # nu (dimensionless)

Supported keys: youngs_modulus/E and poisson_ratio/nu Comments start with # or ;

Example:
auto& db = MaterialDatabase::FromINI("standard.ini");
auto steel = db.Get("Steel");
static MaterialDatabase FromINI(const std::string &path)
Create a MaterialDatabase from an INI configuration file.

Definition at line 239 of file Materials.hpp.

◆ Get()

IsotropicMaterial Phyth::Mechanics::Material::MaterialDatabase::Get ( const std::string &  name) const
inline

Retrieve a material by its registered name.

Parameters
nameName of the material to retrieve
Returns
IsotropicMaterial Material properties
Exceptions
std::runtime_errorIf material name is not found in database
Note
Case-sensitive matching
Warning
Throws exception if material does not exist

Example: auto material = db.Get("Aluminum"); auto nu = material.GetPoissonRatio();

Definition at line 162 of file Materials.hpp.

◆ ListMaterials()

std::vector< std::string > Phyth::Mechanics::Material::MaterialDatabase::ListMaterials ( ) const
inline

Get a list of all registered material names.

Returns
std::vector<std::string> Vector containing all material names
Note
Order is not guaranteed (unordered_map iteration order)

Example: auto names = db.ListMaterials(); for (const auto& name : names) { std::cout << "Available: " << name << std::endl; }

Definition at line 183 of file Materials.hpp.

◆ RegisterMaterial()

void Phyth::Mechanics::Material::MaterialDatabase::RegisterMaterial ( const std::string &  name,
const IsotropicMaterial &  material 
)
inline

Register a new material in the database.

Parameters
nameUnique identifier for the material
materialIsotropicMaterial object containing properties
Note
If a material with the same name exists, it will be overwritten
Warning
Overwriting existing materials may cause unexpected behavior

Example: db.RegisterMaterial("CustomSteel", IsotropicMaterial(210e9_Pa, 0.3_));

Definition at line 204 of file Materials.hpp.

Member Data Documentation

◆ materials_

std::unordered_map<std::string, IsotropicMaterial> Phyth::Mechanics::Material::MaterialDatabase::materials_
private

Internal storage mapping names to materials.

Definition at line 250 of file Materials.hpp.


The documentation for this class was generated from the following file: