|
svMultiPhysics
|
Base class for boundary conditions with spatially variable arrays. More...
#include <BoundaryCondition.h>
Public Member Functions | |
| BoundaryCondition ()=default | |
| Default constructor - creates an empty BC. | |
| BoundaryCondition (const std::string &vtp_file_path, const std::vector< std::string > &array_names, const StringBoolMap &flags, const faceType &face, SimulationLogger &logger) | |
| Constructor - reads data from VTP file. | |
| BoundaryCondition (const StringDoubleMap &uniform_values, const StringBoolMap &flags, const faceType &face, SimulationLogger &logger) | |
| Constructor for uniform values. | |
| BoundaryCondition (const BoundaryCondition &other) | |
| Copy constructor. | |
| BoundaryCondition & | operator= (BoundaryCondition other) |
| Unified assignment operator (handles both copy and move) | |
| BoundaryCondition (BoundaryCondition &&other) noexcept | |
| Move constructor. | |
| virtual | ~BoundaryCondition () noexcept=default |
| Virtual destructor. | |
| double | get_value (const std::string &array_name, int node_id) const |
| Get value for a specific array and node. | |
| bool | get_flag (const std::string &name) const |
| Get a boolean flag by name. | |
| std::string | flags_to_string () const |
| Get a string representation of the flags. | |
| int | get_global_num_nodes () const noexcept |
| Get global number of nodes. | |
| int | get_local_num_nodes () const noexcept |
| Get local number of nodes. | |
| int | get_local_index (int global_node_id) const |
| Get local array index for a global node ID. | |
| bool | is_from_vtp () const noexcept |
| Check if data is loaded from VTP file. | |
| const std::string & | get_vtp_path () const noexcept |
| Get the VTP file path (empty if using uniform values) | |
| bool | is_initialized () const noexcept |
| Check if this BC has been properly initialized with data. | |
| void | distribute (const ComMod &com_mod, const CmMod &cm_mod, const cmType &cm, const faceType &face) |
| Distribute BC data from the master process to the slave processes. | |
Static Public Attributes | |
| static constexpr double | POINT_MATCH_TOLERANCE = 1e-12 |
| Tolerance for point matching in VTP files. | |
Protected Types | |
| using | StringArrayMap = std::map< std::string, Array< double > > |
| Type alias for map of array names to array data. | |
| using | StringBoolMap = std::map< std::string, bool > |
| using | StringDoubleMap = std::map< std::string, double > |
Protected Member Functions | |
| StringArrayMap | read_data_from_vtp_file (const std::string &vtp_file_path, const std::vector< std::string > &array_names) |
| Read data from VTP file. | |
| int | find_vtp_point_index (double x, double y, double z, const Array< double > &vtp_points, double mesh_scale_factor) const |
| Find index of a point in the VTP points array. | |
| virtual void | validate_array_value (const std::string &array_name, double value) const |
| Hook for derived classes to validate array values. | |
| void | distribute_metadata (const CmMod &cm_mod, const cmType &cm, bool is_slave) |
| void | distribute_spatially_variable (const ComMod &com_mod, const CmMod &cm_mod, const cmType &cm, bool is_slave) |
| void | distribute_uniform (const CmMod &cm_mod, const cmType &cm, bool is_slave) |
| void | distribute_flags (const CmMod &cm_mod, const cmType &cm, bool is_slave) |
Protected Attributes | |
| const faceType * | face_ = nullptr |
| Data members for BC. | |
| int | global_num_nodes_ = 0 |
| Global number of nodes on the face. | |
| int | local_num_nodes_ = 0 |
| Local number of nodes on this processor. | |
| std::vector< std::string > | array_names_ |
| Names of arrays to read from VTP file. | |
| StringArrayMap | local_data_ |
| Local array values for each node on this processor. | |
| StringArrayMap | global_data_ |
| Global array values (only populated on master) | |
| StringBoolMap | flags_ |
| Named boolean flags for BC behavior. | |
| bool | spatially_variable = false |
| Flag indicating if data is from VTP file. | |
| std::string | vtp_file_path_ |
| Path to VTP file (empty if uniform) | |
| std::map< int, int > | global_node_map_ |
| Maps global node IDs to local array indices. | |
| std::unique_ptr< VtkVtpData > | vtp_data_ |
| VTP data object. | |
| const SimulationLogger * | logger_ = nullptr |
| Logger for warnings/info (not owned by BoundaryCondition) | |
Base class for boundary conditions with spatially variable arrays.
This class provides common functionality for boundary conditions that need to read and manage arrays of values from VTP files or uniform values. It handles distribution of data across processes and provides efficient access to values.
This class is intended to be subclassed by specific boundary condition types.
Development note: this class is intended to eventually be an object-oriented replacement of the existing bcType, although it is not yet complete.
Example usage:
|
protected |
Type alias for map of array names to array data.
|
default |
Default constructor - creates an empty BC.
| BoundaryCondition::BoundaryCondition | ( | const std::string & | vtp_file_path, |
| const std::vector< std::string > & | array_names, | ||
| const StringBoolMap & | flags, | ||
| const faceType & | face, | ||
| SimulationLogger & | logger | ||
| ) |
Constructor - reads data from VTP file.
| vtp_file_path | Path to VTP file containing arrays |
| array_names | Names of arrays to read from VTP file |
| face | Face associated with the BC |
| logger | Simulation logger used to write warnings |
| std::runtime_error | if file cannot be read or arrays are missing |
| BoundaryCondition::BoundaryCondition | ( | const StringDoubleMap & | uniform_values, |
| const StringBoolMap & | flags, | ||
| const faceType & | face, | ||
| SimulationLogger & | logger | ||
| ) |
Constructor for uniform values.
| uniform_values | Map of array names to uniform values |
| face | Face associated with the BC |
| logger | Simulation logger used to write warnings |
| BoundaryCondition::BoundaryCondition | ( | const BoundaryCondition & | other | ) |
Copy constructor.
|
noexcept |
Move constructor.
|
virtualdefaultnoexcept |
Virtual destructor.
|
protected |
Find index of a point in the VTP points array.
| x | X coordinate |
| y | Y coordinate |
| z | Z coordinate |
| vtp_points | VTP points array |
| mesh_scale_factor | Scale factor applied to mesh coordinates |
| std::runtime_error | if no matching point is found |
| std::string BoundaryCondition::flags_to_string | ( | ) | const |
Get a string representation of the flags.
| bool BoundaryCondition::get_flag | ( | const std::string & | name | ) | const |
Get a boolean flag by name.
| name | Name of the flag |
| std::runtime_error | if flag is not found |
|
inlinenoexcept |
Get global number of nodes.
| int BoundaryCondition::get_local_index | ( | int | global_node_id | ) | const |
Get local array index for a global node ID.
| global_node_id | The global node ID defined on the face |
| std::runtime_error | if global_node_id is not found in the map |
|
inlinenoexcept |
Get local number of nodes.
| double BoundaryCondition::get_value | ( | const std::string & | array_name, |
| int | node_id | ||
| ) | const |
Get value for a specific array and node.
| array_name | Name of the array |
| node_id | Node index on the face |
| std::runtime_error | if array_name is not found |
|
inlinenoexcept |
Get the VTP file path (empty if using uniform values)
|
inlinenoexcept |
Check if data is loaded from VTP file.
|
inlinenoexcept |
Check if this BC has been properly initialized with data.
| BoundaryCondition & BoundaryCondition::operator= | ( | BoundaryCondition | other | ) |
Unified assignment operator (handles both copy and move)
|
protected |
Read data from VTP file.
| vtp_file_path | Path to VTP file |
| array_names | Names of arrays to read |
|
inlineprotectedvirtual |
Hook for derived classes to validate array values.
| array_name | Name of the array being validated |
| value | Value to validate |
| std::runtime_error | if validation fails |
Reimplemented in RobinBoundaryCondition.
|
protected |
Names of arrays to read from VTP file.
|
protected |
Data members for BC.
Face associated with the BC (not owned by BoundaryCondition)
|
protected |
Named boolean flags for BC behavior.
|
protected |
Global array values (only populated on master)
|
protected |
Maps global node IDs to local array indices.
|
protected |
Global number of nodes on the face.
|
protected |
Local array values for each node on this processor.
|
protected |
Local number of nodes on this processor.
|
protected |
Logger for warnings/info (not owned by BoundaryCondition)
|
staticconstexpr |
Tolerance for point matching in VTP files.
|
protected |
Flag indicating if data is from VTP file.
|
protected |
VTP data object.
|
protected |
Path to VTP file (empty if uniform)