Factory class for creating material objects and associated property functions. More...
#include <cl_MaterialFactory.hpp>
Public Types | |
| enum class | BuiltinKind { Iron , OtherKnown , Unknown } |
Public Member Functions | |
| MaterialFactory ()=default | |
| MaterialFactory (const input::Section *aSection, const bool aBuildTables=true) | |
| Build every material a 'materials' deck section defines. | |
| ~MaterialFactory ()=default | |
| Material * | create_material (const string &aLabel, const real aRRR=BELFEM_QUIET_NAN, const bool aBuildTables=true) |
| Create a material by label. | |
| void | print_material_list (std::ostream &aStream) |
| Material * | create_material (const string &aLibraryPath, const string &aLabel) |
| Create a user-defined material from shared library. | |
| Map< string, Material * > & | materials () |
| material::BhCurve * | create_bh_curve (const string &aPath, const string &aLabel) |
| Create a B-H curve from file for ferromagnetic materials. | |
| material::JcFunction * | create_jc_function (const real aJc0, const real aB, const real aBc, const real aK) |
| Create a Jc function using the modified Kim analytical model. | |
| material::JcFunction * | create_jc_function (const string &aPath, const string &aLabel) |
| Create a Jc (or n) function from database file. | |
| void | check_unused_input (const input::Section *aSection, const string &aLabel, const string &aShape, const Cell< string > &aKeys, const Cell< string > &aSections) |
| refuse any key or subsection the resolved material shape does not read | |
Static Public Member Functions | |
| static BuiltinKind | builtin_kind (const string &aName) |
| Classify a builtin name the way create_material() resolves it. | |
| static bool | curve_tolerates_builtin (const string &aValue) |
| Whether a 'builtin' value may stand beside a b-h curve. | |
| static bool | is_pure_metal_label (const string &aLabel) |
| Whether a name is an alias of a builtin pure metal. | |
Factory class for creating material objects and associated property functions.
The MaterialFactory provides a centralized interface for creating:
IMPORTANT USAGE NOTES:
Example usage:
|
strong |
| Enumerator | |
|---|---|
| Iron | an iron alias: iron, ferro, fe |
| OtherKnown | any other alias, or an alloy formula of pure metals |
| Unknown | a name create_material() cannot resolve to either |
|
default |
| belfem::MaterialFactory::MaterialFactory | ( | const input::Section * | aSection, |
| const bool | aBuildTables = true ) |
Build every material a 'materials' deck section defines.
| aSection | the 'materials' section of the input file |
| aBuildTables | build the rho database on construction; off writes no database to the cwd, the temperature splines are built either way |
|
default |
|
static |
Classify a builtin name the way create_material() resolves it.
Case-insensitive; builds no material. An alloy formula counts as known only if its to_pair() labels are at least one pure-metal alias and nothing but pure-metal aliases and the rrr token, so a nameplate such as aisi305 is Unknown even though create_material() would hand it to the Alloy constructor.
| void belfem::MaterialFactory::check_unused_input | ( | const input::Section * | aSection, |
| const string & | aLabel, | ||
| const string & | aShape, | ||
| const Cell< string > & | aKeys, | ||
| const Cell< string > & | aSections ) |
refuse any key or subsection the resolved material shape does not read
A material section selects exactly one shape – a b-h curve, a builtin, or a plugin – and each shape consumes a different set of keys. Everything else used to be dropped without a word, so a misspelled key, a key belonging to another shape, or a constant that lost to a file all behaved as if the deck had never mentioned them.
This is an ALLOW-LIST rather than a record of what happened to be read, because the two are not the same predicate: RRR on a ybco IS read here and then dropped by the constructor, so only an explicit per-shape contract catches it.
| aSection | the material section, or one of its subsections |
| aLabel | material name, for the error message |
| aShape | shape name, for the error message |
| aKeys | keys this shape reads |
| aSections | subsection types this shape enters |
| material::BhCurve * belfem::MaterialFactory::create_bh_curve | ( | const string & | aPath, |
| const string & | aLabel ) |
Create a B-H curve from file for ferromagnetic materials.
Creates a B-H curve object by loading data from a file. This curve defines the relationship between magnetic flux density (B) and magnetic field strength (H) for ferromagnetic materials.
IMPORTANT: This function only CREATES the B-H curve. You must manually assign it to a material using material->load_bh_curve(). Once assigned, the material takes ownership and will delete the curve.
| aPath | Path to the B-H curve data file, resolved through material::data_file(): the run directory first, then $BELFEM_DATA/material |
| aLabel | Identifier label for this B-H curve |
Example:
| material::JcFunction * belfem::MaterialFactory::create_jc_function | ( | const real | aJc0, |
| const real | aB, | ||
| const real | aBc, | ||
| const real | aK ) |
Create a Jc function using the modified Kim analytical model.
Creates a critical current density function for superconductors using the modified Kim model. This is an analytical model suitable for quick calculations when experimental data is not available.
The modified Kim model expresses Jc as a function of magnetic field.
IMPORTANT: This function only CREATES the Jc function. You must manually assign it to a material using material->set_jc_function() or material->set_n_function(). Once assigned, the material takes ownership and will delete the function.
| aJc0 | Critical current density at zero field [A/m²] |
| aB | Characteristic field scale B0 [T] |
| aBc | Anisotropy parameter k² (dimensionless) |
| aK | Field-dependence exponent α (dimensionless) |
Example:
| material::JcFunction * belfem::MaterialFactory::create_jc_function | ( | const string & | aPath, |
| const string & | aLabel ) |
Create a Jc (or n) function from database file.
Creates a critical current density function (or power law exponent function) by loading experimental data from a file. This provides more accurate results than analytical models when experimental data is available.
The function can represent:
IMPORTANT: This function only CREATES the function object. You must manually assign it to a material using material->set_jc_function() or material->set_n_function(). Once assigned, the material takes ownership and will delete the function.
NOTE: If Jc or n are constant, do NOT create a function. Instead, store the constant value directly in the material using set_constant().
| aPath | Path to the database file containing Jc or n data, resolved through material::data_file(): the run directory first, then $BELFEM_DATA/material |
| aLabel | Identifier label for this function |
Example:
| Material * belfem::MaterialFactory::create_material | ( | const string & | aLabel, |
| const real | aRRR = BELFEM_QUIET_NAN, | ||
| const bool | aBuildTables = true ) |
Create a material by label.
Creates a material object from a predefined material database. The label is case-insensitive.
Currently supported labels ( aliases in parentheses ):
| aLabel | Material label (case-insensitive) |
| aRRR | Residual resistivity ratio; NaN keeps the material default |
| aBuildTables | Build the property lookup tables on construction |
| Error | if material label is not recognized |
Example:
| Material * belfem::MaterialFactory::create_material | ( | const string & | aLibraryPath, |
| const string & | aLabel ) |
Create a user-defined material from shared library.
Loads a user-defined material from an external shared library (.so, .dylib, .dll). The library must contain an initialization function with the signature:
Within the init function, users define material properties using:
| aLibraryPath | Path to shared library file |
| aLabel | Material label (must match the init function name: <aLabel>_init) |
| Error | if library cannot be loaded or init function not found |
Example user library (myalloy.cpp):
Compile: g++ -shared -fPIC myalloy.cpp -o libmyalloy.so -I/path/to/belfem/include
The library path is resolved through material::data_file(): the run directory first, then $BELFEM_DATA/material. A name that matches nothing is still passed to dlopen, which searches $LD_LIBRARY_PATH.
Usage:
|
static |
Whether a 'builtin' value may stand beside a b-h curve.
Case-insensitive; builds no material. The valueless marker ( stored as "true" ), an iron alias, or a name the factory does not know pass; a known non-iron builtin or a formula of known pure metals is refused, since the curve always builds an iron.
|
static |
Whether a name is an alias of a builtin pure metal.
Case-insensitive; builds no material. An alloy formula is not a pure metal, even though create_material() types it PureMetal.
| void belfem::MaterialFactory::print_material_list | ( | std::ostream & | aStream | ) |