SimVascular / svZeroDSolver

A C++ lumped-parameter solver for blood flow and pressure in hemodynamic networks
Other
6 stars 18 forks source link

Improve the usability of the interface code #52

Open ktbolt opened 11 months ago

ktbolt commented 11 months ago

The 0D solver svZeroDPlus/src/interface code is used to interface to the 0D solver from an external application by calling functions loaded from the libsvzero_interface shared library.

The LPNSolverInterface class located in svZeroDPlus/tests/test_interface/LPNSolverInterface is used to load the libsvzero_interface shared library and call functions loaded from it.

We need to make sure that the svZeroDPlus/src/interface and svZeroDPlus/tests/test_interface/LPNSolverInterface codes provide a consistent and correct access interface functions.

ktbolt commented 10 months ago

I've been looking at the svZeroDPlus/src/interface and svZeroDPlus/tests/test_interface/LPNSolverInterface code and think it would be good to merge LPNSolverInterface and interface functionality.

The idea would be to define a ZeroDSolverInterface class containing methods interfacing to the solver contained in the interface shared library.

The 3D solver using the interface would include the ZeroDSolverInterface.h header. It would then load the new_interface function used to create a ZeroDSolverInterface object like so

ZeroDSolverInterface* new_interface;

 *(void**)(new_interface) = dlsym(handle, "new_interface");

auto interface = new_interface();

Calls to the solver are then made using interface methods

interface->initialize(file_name, problem_id, pts_per_cycle, num_cycles, num_output_steps, block_names, variable_names);

interface->increment_time_(time, solution);

The user does not need to load interface functions, consistency of the names and signatures of the interface functions are maintained by the ZeroDSolverInterface.h header.

@menon-karthik What do you thinK?

ktbolt commented 6 months ago

@menon-karthik The idea about just loading an interface class is very complicated to implement so forget that.

I think what we can do is just move the svZeroDSolver/tests/test_interface/LPNSolverInterface class to svZeroDSolver/src/interface and have that code used by svZeroDSolver/tests/test_interface/test_0*. The svZeroDSolver/tests/test_interface/LPNSolverInterface code will then be installed with the svZeroDSolver executable and shared library.