Factory class for creating material objects and associated property functions. More...
#include <cl_MaterialFactory.hpp>
Public Member Functions | |
| MaterialFactory ()=default | |
| Default constructor. | |
| MaterialFactory (const input::Section *aSection) | |
| Constructor with input section. | |
| ~MaterialFactory ()=default | |
| Default destructor. | |
| 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 | |
Factory class for creating material objects and associated property functions.
The MaterialFactory provides a centralized interface for creating:
IMPORTANT USAGE NOTES:
Example usage:
|
default |
Default constructor.
| belfem::MaterialFactory::MaterialFactory | ( | const input::Section * | aSection | ) |
Constructor with input section.
|
default |
Default destructor.
| 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:
| void belfem::MaterialFactory::print_material_list | ( | std::ostream & | aStream | ) |