|
svMultiPhysics
|
Wrapper class for dynamically loading and calling the 1D solver shared library. More...
#include <OneDSolverInterface.h>
Public Member Functions | |
| void | load_library (const std::string &interface_lib) |
| Load the 1D solver shared library from the given path. | |
| void | initialize (const std::string &input_file, int &problem_id, int &system_size, const std::string &coupling_type) |
| Initialize the 1D solver from an input file. | |
| void | set_external_step_size (int problem_id, double dt) |
| Synchronize the 1D solver's internal time step with the 3D solver. | |
| void | return_solution (int problem_id, double *solution, int size) |
| Copy the current 1D solution into the caller-provided buffer. | |
| void | update_solution (int problem_id, double *solution, int size) |
| Push a solution vector into the 1D solver as the current state. | |
| void | run_simulation (int problem_id, double current_time, int save_incr, const std::string &coupling_type, double *params, double *solution, double &cpl_value, char last_flag, int &error_code) |
| Advance the 1D solver by one time step. | |
| void | extract_coupled_dof (int problem_id, int &coupled_dof, const std::string &coupling_type) |
| Retrieve the index within the solution vector that corresponds to the coupled boundary DOF. | |
Wrapper class for dynamically loading and calling the 1D solver shared library.
This class loads the svOneDSolver shared library and provides a C++ wrapper around its exported C interface.
The interface is used to couple 3D Navier-Stokes simulations in svMultiPhysics with reduced-order 1D blood flow models in svOneDSolver.
Supported coupling modes:
Each initialized 1D model is identified by a problem_id assigned by svOneDSolver and used in subsequent library calls.
Shared library functions:
| void OneDSolverInterface::extract_coupled_dof | ( | int | problem_id, |
| int & | coupled_dof, | ||
| const std::string & | coupling_type | ||
| ) |
Retrieve the index within the solution vector that corresponds to the coupled boundary DOF.
| void OneDSolverInterface::initialize | ( | const std::string & | input_file, |
| int & | problem_id, | ||
| int & | system_size, | ||
| const std::string & | coupling_type | ||
| ) |
Initialize the 1D solver from an input file.
| [in] | input_file | Path to the 1D solver .in file. |
| [out] | problem_id | Problem identifier assigned by the solver. |
| [out] | system_size | Total number of DOFs (nodes * 2: flow + area). |
| [in] | coupling_type | "NEU" or "DIR" coupling direction. |
| void OneDSolverInterface::load_library | ( | const std::string & | interface_lib | ) |
Load the 1D solver shared library from the given path.
| void OneDSolverInterface::return_solution | ( | int | problem_id, |
| double * | solution, | ||
| int | size | ||
| ) |
Copy the current 1D solution into the caller-provided buffer.
| void OneDSolverInterface::run_simulation | ( | int | problem_id, |
| double | current_time, | ||
| int | save_incr, | ||
| const std::string & | coupling_type, | ||
| double * | params, | ||
| double * | solution, | ||
| double & | cpl_value, | ||
| char | last_flag, | ||
| int & | error_code | ||
| ) |
Advance the 1D solver by one time step.
| [in] | problem_id | Problem identifier. |
| [in] | save_incr | VTK output interval (Increment_in_saving_VTK_files from solver.xml); the 1D library decides internally whether to write output. |
| [in] | coupling_type | "NEU" or "DIR". |
| [in] | params | Array [N, t1, t2, ..., val1, val2, ...] where N=2. |
| [in,out] | solution | Solution vector updated after the step. |
| [out] | cpl_value | The BC value returned by the 1D solver (pressure for NEU, flow for DIR). |
| [in] | last_flag | 'L' for the final (committed) iteration, 'D' for derivative / predictor steps. |
| [out] | error_code | Non-zero on failure. 0 indicates success. Any non-zero value is interpreted by this wrapper as a 1D solver failure. |
| void OneDSolverInterface::set_external_step_size | ( | int | problem_id, |
| double | dt | ||
| ) |
Synchronize the 1D solver's internal time step with the 3D solver.
| void OneDSolverInterface::update_solution | ( | int | problem_id, |
| double * | solution, | ||
| int | size | ||
| ) |
Push a solution vector into the 1D solver as the current state.