svMultiPhysics
Loading...
Searching...
No Matches
LPNSolverInterface.h
1/* Copyright (c) Stanford University, The Regents of the University of California, and others.
2 *
3 * All Rights Reserved.
4 *
5 * See Copyright-SimVascular.txt for additional details.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject
13 * to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <dlfcn.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <string>
35#include <vector>
36
37#ifndef LPNSolverInterface_h
38#define LPNSolverInterface_h
39
40//--------------------
41// LPNSolverInterface
42//--------------------
43//
45{
46 public:
49
50 void load_library(const std::string& interface_lib);
51 void initialize(std::string file_name);
52 void increment_time(const double time, std::vector<double>& solution);
53 void run_simulation(const double time, std::vector<double>& output_times,
54 std::vector<double>& output_solutions, int& error_code);
55 void update_block_params(std::string block_name, std::vector<double>& new_params);
56 void read_block_params(std::string block_name, std::vector<double>& block_params);
57 void get_block_node_IDs(std::string block_name, std::vector<int>& IDs);
58 void update_state(std::vector<double> state_y, std::vector<double> state_ydot);
59 void return_y(std::vector<double>& y);
60 void return_ydot(std::vector<double>& ydot);
61 void set_external_step_size(double step_size);
62
63 // Interface functions.
64 std::string lpn_initialize_name_;
65 void (*lpn_initialize_)(std::string, int&, int&, int&, int&, std::vector<std::string>&,
66 std::vector<std::string>&);
67
68 std::string lpn_increment_time_name_;
69 void (*lpn_increment_time_)(const int, const double, std::vector<double>& solution);
70
71 std::string lpn_run_simulation_name_;
72 void (*lpn_run_simulation_)(const int, const double, std::vector<double>& output_times,
73 std::vector<double>& output_solutions, int& error_code);
74
75 std::string lpn_update_block_params_name_;
76 void (*lpn_update_block_params_)(const int, std::string, std::vector<double>& new_params);
77
78 std::string lpn_read_block_params_name_;
79 void (*lpn_read_block_params_)(const int, std::string, std::vector<double>& block_params);
80
81 std::string lpn_get_block_node_IDs_name_;
82 void (*lpn_get_block_node_IDs_)(const int, std::string, std::vector<int>& block_params);
83
84 std::string lpn_update_state_name_;
85 void (*lpn_update_state_)(const int, std::vector<double>, std::vector<double>);
86
87 std::string lpn_return_y_name_;
88 void (*lpn_return_y_)(const int, std::vector<double>&);
89
90 std::string lpn_return_ydot_name_;
91 void (*lpn_return_ydot_)(const int, std::vector<double>&);
92
93 std::string lpn_set_external_step_size_name_;
94 void (*lpn_set_external_step_size_)(const int, double);
95
96 void* library_handle_ = nullptr;
97 int problem_id_ = 0;
98 int system_size_ = 0;
99 int num_cycles_ = 0;
100 int pts_per_cycle_ = 0;
101 int num_output_steps_ = 0;
102 std::vector<std::string> block_names_;
103 std::vector<std::string> variable_names_;
104};
105
106#endif
107
Definition LPNSolverInterface.h:45