svMultiPhysics
Loading...
Searching...
No Matches
LPNSolverInterface.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include <dlfcn.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <string>
8#include <vector>
9
10#ifndef LPNSolverInterface_h
11#define LPNSolverInterface_h
12
13//--------------------
14// LPNSolverInterface
15//--------------------
16//
18{
19 public:
22
23 void load_library(const std::string& interface_lib);
24 void initialize(std::string file_name);
25 void increment_time(const double time, std::vector<double>& solution);
26 void run_simulation(const double time, std::vector<double>& output_times,
27 std::vector<double>& output_solutions, int& error_code);
28 void update_block_params(std::string block_name, std::vector<double>& new_params);
29 void read_block_params(std::string block_name, std::vector<double>& block_params);
30 void get_block_node_IDs(std::string block_name, std::vector<int>& IDs);
31 void update_state(std::vector<double> state_y, std::vector<double> state_ydot);
32 void return_y(std::vector<double>& y);
33 void return_ydot(std::vector<double>& ydot);
34 void set_external_step_size(double step_size);
35
36 // Interface functions.
37 std::string lpn_initialize_name_;
38 void (*lpn_initialize_)(std::string, int&, int&, int&, int&, std::vector<std::string>&,
39 std::vector<std::string>&);
40
41 std::string lpn_increment_time_name_;
42 void (*lpn_increment_time_)(const int, const double, std::vector<double>& solution);
43
44 std::string lpn_run_simulation_name_;
45 void (*lpn_run_simulation_)(const int, const double, std::vector<double>& output_times,
46 std::vector<double>& output_solutions, int& error_code);
47
48 std::string lpn_update_block_params_name_;
49 void (*lpn_update_block_params_)(const int, std::string, std::vector<double>& new_params);
50
51 std::string lpn_read_block_params_name_;
52 void (*lpn_read_block_params_)(const int, std::string, std::vector<double>& block_params);
53
54 std::string lpn_get_block_node_IDs_name_;
55 void (*lpn_get_block_node_IDs_)(const int, std::string, std::vector<int>& block_params);
56
57 std::string lpn_update_state_name_;
58 void (*lpn_update_state_)(const int, std::vector<double>, std::vector<double>);
59
60 std::string lpn_return_y_name_;
61 void (*lpn_return_y_)(const int, std::vector<double>&);
62
63 std::string lpn_return_ydot_name_;
64 void (*lpn_return_ydot_)(const int, std::vector<double>&);
65
66 std::string lpn_set_external_step_size_name_;
67 void (*lpn_set_external_step_size_)(const int, double);
68
69 void* library_handle_ = nullptr;
70 int problem_id_ = 0;
71 int system_size_ = 0;
72 int num_cycles_ = 0;
73 int pts_per_cycle_ = 0;
74 int num_output_steps_ = 0;
75 std::vector<std::string> block_names_;
76 std::vector<std::string> variable_names_;
77};
78
79#endif
80
Definition LPNSolverInterface.h:18