4#ifndef BOUNDARY_CONDITION_H
5#define BOUNDARY_CONDITION_H
12#include "SimulationLogger.h"
52 using StringBoolMap = std::map<std::string, bool>;
53 using StringDoubleMap = std::map<std::string, double>;
111 double get_value(const std::
string& array_name,
int node_id) const;
117 bool get_flag(const std::
string& name) const;
181 int find_vtp_point_index(
double x,
double y,
double z,
const Array<double>& vtp_points,
double mesh_scale_factor)
const;
190 void distribute_metadata(
const CmMod& cm_mod,
const cmType& cm,
bool is_slave);
191 void distribute_spatially_variable(
const ComMod& com_mod,
const CmMod& cm_mod,
const cmType& cm,
bool is_slave);
192 void distribute_uniform(
const CmMod& cm_mod,
const cmType& cm,
bool is_slave);
193 void distribute_flags(
const CmMod& cm_mod,
const cmType& cm,
bool is_slave);
209 const char*
what() const noexcept
override {
210 return message_.c_str();
214 std::string message_;
234 "' does not match number of nodes on face '" + face_name +
"'") {}
245 " for array '" + array_name +
"'") {}
274 " is out of range [0, " + std::to_string(max_node_id - 1) +
"]") {}
282 " not found in global-to-local map") {}
296 int expected_rows,
int expected_cols,
int actual_rows,
int actual_cols)
298 "' has incorrect dimensions. Expected " + std::to_string(expected_rows) +
299 " x " + std::to_string(expected_cols) +
", got " + std::to_string(actual_rows) +
300 " x " + std::to_string(actual_cols)) {}
315 std::to_string(x) +
", " + std::to_string(y) +
", " + std::to_string(z) +
")") {}
Exception thrown when a requested array is not found.
Definition BoundaryCondition.h:256
Base exception class for BC errors.
Definition BoundaryCondition.h:201
BoundaryConditionBaseException(const std::string &msg)
Constructor.
Definition BoundaryCondition.h:205
const char * what() const noexcept override
Get error message.
Definition BoundaryCondition.h:209
Exception thrown when VTP file cannot be read or is invalid.
Definition BoundaryCondition.h:218
BoundaryConditionFileException(const std::string &file)
Constructor.
Definition BoundaryCondition.h:222
Exception thrown when a requested flag is not defined.
Definition BoundaryCondition.h:249
Exception thrown when a global node ID is not found in the global-to-local map.
Definition BoundaryCondition.h:278
Base class for boundary conditions with spatially variable arrays.
Definition BoundaryCondition.h:48
StringBoolMap flags_
Named boolean flags for BC behavior.
Definition BoundaryCondition.h:62
virtual ~BoundaryCondition() noexcept=default
Virtual destructor.
std::unique_ptr< VtkVtpData > vtp_data_
VTP data object.
Definition BoundaryCondition.h:66
bool is_from_vtp() const noexcept
Check if data is loaded from VTP file.
Definition BoundaryCondition.h:143
int local_num_nodes_
Local number of nodes on this processor.
Definition BoundaryCondition.h:58
BoundaryCondition()=default
Default constructor - creates an empty BC.
BoundaryCondition & operator=(BoundaryCondition other)
Unified assignment operator (handles both copy and move)
Definition BoundaryCondition.cpp:108
StringArrayMap read_data_from_vtp_file(const std::string &vtp_file_path, const std::vector< std::string > &array_names)
Read data from VTP file.
Definition BoundaryCondition.cpp:134
const faceType * face_
Data members for BC.
Definition BoundaryCondition.h:56
std::map< int, int > global_node_map_
Maps global node IDs to local array indices.
Definition BoundaryCondition.h:65
double get_value(const std::string &array_name, int node_id) const
Get value for a specific array and node.
Definition BoundaryCondition.cpp:192
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.
Definition BoundaryCondition.cpp:237
bool get_flag(const std::string &name) const
Get a boolean flag by name.
Definition BoundaryCondition.cpp:211
static constexpr double POINT_MATCH_TOLERANCE
Tolerance for point matching in VTP files.
Definition BoundaryCondition.h:71
virtual void validate_array_value(const std::string &array_name, double value) const
Hook for derived classes to validate array values.
Definition BoundaryCondition.h:187
std::vector< std::string > array_names_
Names of arrays to read from VTP file.
Definition BoundaryCondition.h:59
bool spatially_variable
Flag indicating if data is from VTP file.
Definition BoundaryCondition.h:63
int global_num_nodes_
Global number of nodes on the face.
Definition BoundaryCondition.h:57
std::string flags_to_string() const
Get a string representation of the flags.
Definition BoundaryCondition.cpp:499
int get_local_index(int global_node_id) const
Get local array index for a global node ID.
Definition BoundaryCondition.cpp:224
int get_global_num_nodes() const noexcept
Get global number of nodes.
Definition BoundaryCondition.h:125
std::string vtp_file_path_
Path to VTP file (empty if uniform)
Definition BoundaryCondition.h:64
StringArrayMap global_data_
Global array values (only populated on master)
Definition BoundaryCondition.h:61
StringArrayMap local_data_
Local array values for each node on this processor.
Definition BoundaryCondition.h:60
int get_local_num_nodes() const noexcept
Get local number of nodes.
Definition BoundaryCondition.h:131
friend void swap(BoundaryCondition &lhs, BoundaryCondition &rhs) noexcept
Swap function for copy-and-swap idiom (friend function)
Definition BoundaryCondition.cpp:92
const SimulationLogger * logger_
Logger for warnings/info (not owned by BoundaryCondition)
Definition BoundaryCondition.h:67
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.
Definition BoundaryCondition.cpp:468
const std::string & get_vtp_path() const noexcept
Get the VTP file path (empty if using uniform values)
Definition BoundaryCondition.h:149
std::map< std::string, Array< double > > StringArrayMap
Type alias for map of array names to array data.
Definition BoundaryCondition.h:51
bool is_initialized() const noexcept
Check if this BC has been properly initialized with data.
Definition BoundaryCondition.h:155
Exception thrown when node count mismatch between VTP and face.
Definition BoundaryCondition.h:227
BoundaryConditionNodeCountException(const std::string &vtp_file, const std::string &face_name)
Constructor.
Definition BoundaryCondition.h:232
Exception thrown when a node ID is out of range.
Definition BoundaryCondition.h:270
Exception thrown when BoundaryCondition is not properly initialized.
Definition BoundaryCondition.h:263
Exception thrown when face_ is nullptr during distribute.
Definition BoundaryCondition.h:304
Exception thrown when a point cannot be found in VTP file.
Definition BoundaryCondition.h:311
Exception thrown when array validation fails.
Definition BoundaryCondition.h:238
BoundaryConditionValidationException(const std::string &array_name, double value)
Constructor.
Definition BoundaryCondition.h:243
Exception thrown when a VTP array has incorrect dimensions.
Definition BoundaryCondition.h:293
Exception thrown when a VTP file doesn't contain a required array.
Definition BoundaryCondition.h:286
The CmMod class duplicates the data structures in the Fortran CMMOD module defined in COMU....
Definition CmMod.h:35
The ComMod class duplicates the data structures in the Fortran COMMOD module defined in MOD....
Definition ComMod.h:1514
The SimulationLogger class is used to write information to a text file and optionally to cout.
Definition SimulationLogger.h:13
The cmType class stores data and defines methods used for mpi communication.
Definition CmMod.h:55
The face type containing mesh at boundary.
Definition ComMod.h:511