4#ifndef COUPLED_BOUNDARY_CONDITION_H
5#define COUPLED_BOUNDARY_CONDITION_H
11#include <unordered_map>
15#include "SolutionStates.h"
22namespace fsi_linear_solver {
55 const char* what()
const noexcept override {
return message_.c_str(); }
81 "' has no GlobalNodeID entries in common with coupled face '" +
82 coupled_face_name +
"'. The cap must share at least one mesh node with that face.") {}
90 std::to_string(vtk_cell_type) +
". Only VTK_TRIANGLE (TRI3) is supported.") {}
98 std::to_string(eNoN) +
" (expected " + std::to_string(expected) +
").") {}
106 "functions: " + nested) {}
125 const std::string& coupled_face_name);
135 consts::MechanicalConfigurationType cfg);
145 const Array<double>&
valM()
const {
return valM_; }
149 std::unique_ptr<faceType> face_;
153 Array<double> normals_;
156 static constexpr int cap_nsd_ = 3;
158 static constexpr int cap_insd_ = 2;
161 Array<double> update_element_position_global(
int e, consts::MechanicalConfigurationType cfg,
162 const Array<double>& mesh_x,
const Array<double>& mesh_Do,
163 const Array<double>& mesh_Dn,
164 const std::unordered_map<int, int>& gn_to_cap_local)
const;
167 std::pair<double, Vector<double>> compute_jacobian_and_normal(
const Array<double>& xl,
int e,
int g)
const;
170 mutable Array<double> valM_;
186 std::string cap_face_vtp_file_;
189 consts::BoundaryConditionType bc_type_ = consts::BoundaryConditionType::bType_Neu;
192 std::string block_name_;
193 std::string face_name_;
202 double pressure_ = 0.0;
205 int flow_sol_id_ = -1;
206 int pressure_sol_id_ = -1;
207 double in_out_sign_ = 1.0;
210 bool follower_pressure_load_ =
false;
211 consts::EquationType phys_ = consts::EquationType::phys_NA;
212 consts::MechanicalConfigurationType flowrate_cfg_o_ = consts::MechanicalConfigurationType::reference;
213 consts::MechanicalConfigurationType flowrate_cfg_n_ = consts::MechanicalConfigurationType::reference;
216 bool has_cap_ =
false;
218 bool owns_cap_ =
false;
224 std::unordered_map<int, int> cap_g_to_cap_col_;
226 std::optional<CappingSurface> cap_;
234 void rebuild_cap_global_to_col_map();
237 void gather_global_mesh_state(
ComMod& com_mod,
const CmMod& cm_mod,
const SolutionStates& solutions,
bool gather_Y)
const;
267 const std::string& block_name, consts::EquationType phys,
bool follower_pressure_load);
278 const std::string& block_name,
const std::string& cap_face_vtp_file,
279 consts::EquationType phys,
bool follower_pressure_load);
282 consts::BoundaryConditionType
get_bc_type()
const {
return bc_type_; }
324 consts::MechanicalConfigurationType cfg,
330 consts::MechanicalConfigurationType cfg_o,
331 consts::MechanicalConfigurationType cfg_n);
382 double pressure = 0.0;
Base exception for capping surface (cap VTP) errors.
Definition CoupledBoundaryCondition.h:51
Cap mesh shares no nodes with the coupled boundary face.
Definition CoupledBoundaryCondition.h:77
Cap VTP file cannot be opened.
Definition CoupledBoundaryCondition.h:62
Capping surface geometry and integration for a coupled boundary.
Definition CoupledBoundaryCondition.h:110
void compute_valM(consts::MechanicalConfigurationType cfg, const CapGlobalMeshState &st) const
Compute the cap contribution to the linear solver face (fills valM_; safe under const *this).
Definition CoupledBoundaryCondition.cpp:1159
void load_from_vtp(const std::string &vtp_file_path, const faceType &coupled_face, const std::string &coupled_face_name)
Load the cap face from a VTP file.
Definition CoupledBoundaryCondition.cpp:902
void initialize_valM()
Initialize the cap contribution storage.
Definition CoupledBoundaryCondition.cpp:1013
const Array< double > & valM() const
Get the cap contribution.
Definition CoupledBoundaryCondition.h:145
CappingSurface()=default
Default constructor.
CappingSurface & operator=(CappingSurface &&other) noexcept=default
Move assignment operator.
CappingSurface & operator=(const CappingSurface &other)
Copy assignment operator.
Definition CoupledBoundaryCondition.cpp:883
faceType * face()
Get the cap face.
Definition CoupledBoundaryCondition.h:141
double integrate_velocity_flux(const CapGlobalMeshState &st, bool use_Yn_velocity, consts::MechanicalConfigurationType cfg)
Surface velocity flux through the cap using st columns indexed by cap IEN / GlobalNodeID (master / se...
Definition CoupledBoundaryCondition.cpp:1124
CappingSurface(CappingSurface &&other) noexcept=default
Move constructor.
void init_cap_face_quadrature(const ComMod &com_mod)
Initialize the cap face quadrature.
Definition CoupledBoundaryCondition.cpp:982
Cap VTP connectivity does not match expected TRI3 topology.
Definition CoupledBoundaryCondition.h:94
Cap face quadrature (shape functions on TRI3) setup failed.
Definition CoupledBoundaryCondition.h:102
Cap VTP uses an unsupported cell type (only TRI3 is supported).
Definition CoupledBoundaryCondition.h:86
VTP read, parse, or validation error during cap load.
Definition CoupledBoundaryCondition.h:70
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:1563
Object-oriented Coupled boundary condition.
Definition CoupledBoundaryCondition.h:182
double get_pressure() const
Get the current pressure value.
Definition CoupledBoundaryCondition.cpp:334
void perturb_flowrate(double diff)
Perturb the new timestep flowrate by a given amount.
Definition CoupledBoundaryCondition.cpp:320
std::pair< double, double > calculate_cap_contribution(ComMod &com_mod, const CmMod &cm_mod, const SolutionStates &solutions, consts::MechanicalConfigurationType cfg_o, consts::MechanicalConfigurationType cfg_n)
Extra volumetric flux through the cap (old/new timestep); {0,0} if no cap; MPI-safe on all ranks.
Definition CoupledBoundaryCondition.cpp:717
double get_Qn() const
Get the flowrate at new timestep.
Definition CoupledBoundaryCondition.cpp:309
double get_Po() const
Get the pressure at old timestep.
Definition CoupledBoundaryCondition.cpp:339
CoupledBoundaryCondition & operator=(const CoupledBoundaryCondition &other)
Copy assignment operator.
Definition CoupledBoundaryCondition.cpp:48
bool has_cap() const
Check if this BC has a cap (broadcast in distribute so all ranks agree).
Definition CoupledBoundaryCondition.h:409
CoupledBoundaryCondition()=default
Default constructor - creates an uninitialized object.
~CoupledBoundaryCondition()=default
Destructor.
void initialize_cap(ComMod &com_mod)
Initialize cap quadrature on the master (call from baf_ini after partition).
Definition CoupledBoundaryCondition.cpp:490
void copy_cap_surface_to_linear_solver_face(ComMod &com_mod, fsi_linear_solver::FSILS_faceType &lhs_face, consts::MechanicalConfigurationType cfg, const SolutionStates &solutions) const
Compute cap valM from current cap mesh state on owner and copy/broadcast cap data to FSILS face.
Definition CoupledBoundaryCondition.cpp:1267
const std::string & get_block_name() const
Get the svZeroD block name.
Definition CoupledBoundaryCondition.cpp:206
void set_flowrates(double Qo, double Qn)
Set the flowrates directly.
Definition CoupledBoundaryCondition.cpp:314
void compute_pressures(ComMod &com_mod, const CmMod &cm_mod, const SolutionStates &solutions)
Compute average pressures at the boundary face at old and new timesteps (for Dirichlet BCs)
Definition CoupledBoundaryCondition.cpp:288
void set_pressure(double pressure)
Set the pressure value from 0D solver.
Definition CoupledBoundaryCondition.cpp:329
int get_flow_sol_id() const
Get the flow solution ID.
Definition CoupledBoundaryCondition.cpp:218
double get_in_out_sign() const
Get the inlet/outlet sign.
Definition CoupledBoundaryCondition.cpp:228
void distribute(const ComMod &com_mod, const CmMod &cm_mod, const cmType &cm, const faceType &face)
Distribute BC metadata from master to slave processes.
Definition CoupledBoundaryCondition.cpp:383
void restore_state(const State &state)
Restore state from a saved state.
Definition CoupledBoundaryCondition.cpp:358
double get_Qo() const
Get the flowrate at old timestep.
Definition CoupledBoundaryCondition.cpp:304
int get_pressure_sol_id() const
Get the pressure solution ID.
Definition CoupledBoundaryCondition.cpp:223
bool owns_cap() const
True if this rank stores the cap mesh / quadrature in cap_.
Definition CoupledBoundaryCondition.h:412
void load_cap_face_vtp(const std::string &vtp_file_path)
Load the cap face VTP file and associate it with this boundary condition.
Definition CoupledBoundaryCondition.cpp:448
void set_flowrate_mechanical_configurations(consts::EquationType phys, bool follower_pressure_load)
Set follower load flag and mechanical configs used for flowrate integration (also run from the face c...
Definition CoupledBoundaryCondition.cpp:240
void set_solution_ids(int flow_id, int pressure_id, double in_out_sign)
Set the svZeroD solution IDs for flow and pressure.
Definition CoupledBoundaryCondition.cpp:211
State save_state() const
Save current state (Qn and pressure)
Definition CoupledBoundaryCondition.cpp:353
double get_Pn() const
Get the pressure at new timestep.
Definition CoupledBoundaryCondition.cpp:344
consts::BoundaryConditionType get_bc_type() const
Get the 3D BC type for this Coupled boundary condition.
Definition CoupledBoundaryCondition.h:282
void compute_flowrates(ComMod &com_mod, const CmMod &cm_mod, const SolutionStates &solutions)
Compute flowrates at the boundary face at old and new timesteps.
Definition CoupledBoundaryCondition.cpp:262
void bcast_coupled_neumann_pressure(const CmMod &cm_mod, cmType &cm)
Master reads Neumann pressure, one scalar MPI_Bcast, all ranks set pressure (svZeroD sync).
Definition CoupledBoundaryCondition.cpp:1298
Definition LPNSolverInterface.h:18
The Vector template class is used for storing int and double data.
Definition Vector.h:24
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:524
Cap-surface nodal state: n_cap columns, column a is cap node a (same order as cap face gN / broadcast...
Definition CoupledBoundaryCondition.h:27
State struct for saving/restoring Qn and pressure.
Definition CoupledBoundaryCondition.h:380
Holds solution state at old, current, and intermediate time levels.
Definition SolutionStates.h:39