svMultiPhysics
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
BoundaryCondition Class Reference

Base class for boundary conditions with spatially variable arrays. More...

#include <BoundaryCondition.h>

Inheritance diagram for BoundaryCondition:
[legend]

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.
 
BoundaryConditionoperator= (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 faceTypeface_ = 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< VtkVtpDatavtp_data_
 VTP data object.
 
const SimulationLoggerlogger_ = nullptr
 Logger for warnings/info (not owned by BoundaryCondition)
 

Detailed Description

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:

class MyBoundaryCondition : public BoundaryCondition {
public:
MyBoundaryCondition(const std::string& vtp_file_path, const std::vector<std::string>& array_names, const faceType& face)
: BoundaryCondition(vtp_file_path, array_names, face) {}
MyBoundaryCondition(const std::map<std::string, double>& uniform_values, const faceType& face)
: BoundaryCondition(uniform_values, face) {}
// Add BC-specific functionality here
};
Base class for boundary conditions with spatially variable arrays.
Definition BoundaryCondition.h:48
The face type containing mesh at boundary.
Definition ComMod.h:511

Member Typedef Documentation

◆ StringArrayMap

using BoundaryCondition::StringArrayMap = std::map<std::string, Array<double> >
protected

Type alias for map of array names to array data.

Constructor & Destructor Documentation

◆ BoundaryCondition() [1/5]

BoundaryCondition::BoundaryCondition ( )
default

Default constructor - creates an empty BC.

◆ BoundaryCondition() [2/5]

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.

Parameters
vtp_file_pathPath to VTP file containing arrays
array_namesNames of arrays to read from VTP file
faceFace associated with the BC
loggerSimulation logger used to write warnings
Exceptions
std::runtime_errorif file cannot be read or arrays are missing

◆ BoundaryCondition() [3/5]

BoundaryCondition::BoundaryCondition ( const StringDoubleMap &  uniform_values,
const StringBoolMap &  flags,
const faceType face,
SimulationLogger logger 
)

Constructor for uniform values.

Parameters
uniform_valuesMap of array names to uniform values
faceFace associated with the BC
loggerSimulation logger used to write warnings

◆ BoundaryCondition() [4/5]

BoundaryCondition::BoundaryCondition ( const BoundaryCondition other)

Copy constructor.

◆ BoundaryCondition() [5/5]

BoundaryCondition::BoundaryCondition ( BoundaryCondition &&  other)
noexcept

Move constructor.

◆ ~BoundaryCondition()

virtual BoundaryCondition::~BoundaryCondition ( )
virtualdefaultnoexcept

Virtual destructor.

Member Function Documentation

◆ distribute()

void BoundaryCondition::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.

Parameters
com_modReference to ComMod object for global coordinates
cm_modReference to CmMod object for MPI communication
cmReference to cmType object for MPI communication
faceFace associated with the BC

◆ find_vtp_point_index()

int BoundaryCondition::find_vtp_point_index ( double  x,
double  y,
double  z,
const Array< double > &  vtp_points,
double  mesh_scale_factor 
) const
protected

Find index of a point in the VTP points array.

Parameters
xX coordinate
yY coordinate
zZ coordinate
vtp_pointsVTP points array
mesh_scale_factorScale factor applied to mesh coordinates
Returns
Index of the matching point in the VTP array
Exceptions
std::runtime_errorif no matching point is found

◆ flags_to_string()

std::string BoundaryCondition::flags_to_string ( ) const

Get a string representation of the flags.

Returns
String representation of the flags

◆ get_flag()

bool BoundaryCondition::get_flag ( const std::string &  name) const

Get a boolean flag by name.

Parameters
nameName of the flag
Returns
Value of the flag
Exceptions
std::runtime_errorif flag is not found

◆ get_global_num_nodes()

int BoundaryCondition::get_global_num_nodes ( ) const
inlinenoexcept

Get global number of nodes.

Returns
Global number of nodes on the face

◆ get_local_index()

int BoundaryCondition::get_local_index ( int  global_node_id) const

Get local array index for a global node ID.

Parameters
global_node_idThe global node ID defined on the face
Returns
Local array index for data arrays
Exceptions
std::runtime_errorif global_node_id is not found in the map

◆ get_local_num_nodes()

int BoundaryCondition::get_local_num_nodes ( ) const
inlinenoexcept

Get local number of nodes.

Returns
Local number of nodes on the face on this processor

◆ get_value()

double BoundaryCondition::get_value ( const std::string &  array_name,
int  node_id 
) const

Get value for a specific array and node.

Parameters
array_nameName of the array
node_idNode index on the face
Returns
Value for the array at the specified node
Exceptions
std::runtime_errorif array_name is not found

◆ get_vtp_path()

const std::string & BoundaryCondition::get_vtp_path ( ) const
inlinenoexcept

Get the VTP file path (empty if using uniform values)

Returns
VTP file path

◆ is_from_vtp()

bool BoundaryCondition::is_from_vtp ( ) const
inlinenoexcept

Check if data is loaded from VTP file.

Returns
true if loaded from VTP, false if using uniform values

◆ is_initialized()

bool BoundaryCondition::is_initialized ( ) const
inlinenoexcept

Check if this BC has been properly initialized with data.

Returns
true if BC has data (either global or local arrays are populated)

◆ operator=()

BoundaryCondition & BoundaryCondition::operator= ( BoundaryCondition  other)

Unified assignment operator (handles both copy and move)

◆ read_data_from_vtp_file()

BoundaryCondition::StringArrayMap BoundaryCondition::read_data_from_vtp_file ( const std::string &  vtp_file_path,
const std::vector< std::string > &  array_names 
)
protected

Read data from VTP file.

Parameters
vtp_file_pathPath to VTP file
array_namesNames of arrays to read
Returns
Map of array names to array data

◆ validate_array_value()

virtual void BoundaryCondition::validate_array_value ( const std::string &  array_name,
double  value 
) const
inlineprotectedvirtual

Hook for derived classes to validate array values.

Parameters
array_nameName of the array being validated
valueValue to validate
Exceptions
std::runtime_errorif validation fails

Reimplemented in RobinBoundaryCondition.

Member Data Documentation

◆ array_names_

std::vector<std::string> BoundaryCondition::array_names_
protected

Names of arrays to read from VTP file.

◆ face_

const faceType* BoundaryCondition::face_ = nullptr
protected

Data members for BC.

Face associated with the BC (not owned by BoundaryCondition)

◆ flags_

StringBoolMap BoundaryCondition::flags_
protected

Named boolean flags for BC behavior.

◆ global_data_

StringArrayMap BoundaryCondition::global_data_
protected

Global array values (only populated on master)

◆ global_node_map_

std::map<int, int> BoundaryCondition::global_node_map_
protected

Maps global node IDs to local array indices.

◆ global_num_nodes_

int BoundaryCondition::global_num_nodes_ = 0
protected

Global number of nodes on the face.

◆ local_data_

StringArrayMap BoundaryCondition::local_data_
protected

Local array values for each node on this processor.

◆ local_num_nodes_

int BoundaryCondition::local_num_nodes_ = 0
protected

Local number of nodes on this processor.

◆ logger_

const SimulationLogger* BoundaryCondition::logger_ = nullptr
protected

Logger for warnings/info (not owned by BoundaryCondition)

◆ POINT_MATCH_TOLERANCE

constexpr double BoundaryCondition::POINT_MATCH_TOLERANCE = 1e-12
staticconstexpr

Tolerance for point matching in VTP files.

◆ spatially_variable

bool BoundaryCondition::spatially_variable = false
protected

Flag indicating if data is from VTP file.

◆ vtp_data_

std::unique_ptr<VtkVtpData> BoundaryCondition::vtp_data_
protected

VTP data object.

◆ vtp_file_path_

std::string BoundaryCondition::vtp_file_path_
protected

Path to VTP file (empty if uniform)


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