svZeroDSolver
Loading...
Searching...
No Matches
interface.h
Go to the documentation of this file.
1// Copyright (c) Stanford University, The Regents of the University of
2// California, and others.
3//
4// All Rights Reserved.
5//
6// See Copyright-SimVascular.txt for additional details.
7//
8// Permission is hereby granted, free of charge, to any person obtaining
9// a copy of this software and associated documentation files (the
10// "Software"), to deal in the Software without restriction, including
11// without limitation the rights to use, copy, modify, merge, publish,
12// distribute, sublicense, and/or sell copies of the Software, and to
13// permit persons to whom the Software is furnished to do so, subject
14// to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included
17// in all copies or substantial portions of the Software.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30/**
31 * @file interface.h
32 * @brief svZeroDSolver callable interface.
33 */
34
35#include <map>
36#include <nlohmann/json.hpp>
37#include <string>
38#include <vector>
39
40#include "Integrator.h"
41#include "Model.h"
42#include "SparseSystem.h"
43#include "State.h"
44#include "csv_writer.h"
45#include "debug.h"
46
47/**
48 * @brief Interface class for calling svZeroD from external programs
49 */
51 public:
52 /**
53 * @brief Construct a new interface object
54 * @param input_file_name The 0D JSON file which specifies the model
55 */
56 SolverInterface(const std::string& input_file_name);
57
58 /**
59 * @brief Destroy the interface object
60 */
62
63 /**
64 * @brief Counter for the number of interfaces
65 */
67 /**
68 * @brief List of interfaces
69 */
70 static std::map<int, SolverInterface*> interface_list_;
71
72 /**
73 * @brief ID of current interface
74 */
75 int problem_id_ = 0;
76
77 /**
78 * @brief 0D input (JSON) file
79 */
80 std::string input_file_name_;
81
82 /**
83 * @brief Time step size of the external program
84 *
85 * This is required for coupling with a 3D solver
86 */
87 double external_step_size_ = 0.1;
88
89 // These are read in from the input JSON solver configuration file.
90 /**
91 * @brief 0D time step size
92 */
93 double time_step_size_ = 0.0;
94
95 /**
96 * @brief Spectral radius of generalized alpha integrator
97 */
98 double rho_infty_ = 0.0;
99
100 /**
101 * @brief Number of 0D time steps
102 */
104 /**
105 * @brief Convergence tolerance for the 0D model
106 */
108 /**
109 * @brief Maximum number of non-linear iterations
110 */
111 int max_nliter_ = 0;
112 /**
113 * @brief Current time step
114 */
115 int time_step_ = 0.0;
116 /**
117 * @brief The size of the 0D system
118 */
120 /**
121 * @brief The number of steps to output
122 */
124 /**
125 * @brief Number of time steps per cycle
126 */
128 /**
129 * @brief Output results from last cycle only?
130 */
132
133 /**
134 * @brief The current 0D model object
135 */
136 std::shared_ptr<Model> model_;
137 /**
138 * @brief The current 0D integrator object
139 */
141
142 /**
143 * @brief The current 0D state vector
144 */
146 /**
147 * @brief Vector to store solution times
148 */
149 std::vector<double> times_;
150 /**
151 * @brief Vector to store solution states
152 */
153 std::vector<State> states_;
154};
Integrator source file.
model::Model source file
SparseSystem source file.
State source file.
Generalized-alpha integrator.
Definition Integrator.h:53
Interface class for calling svZeroD from external programs.
Definition interface.h:50
~SolverInterface()
Destroy the interface object.
Definition interface.cpp:50
double external_step_size_
Time step size of the external program.
Definition interface.h:87
double rho_infty_
Spectral radius of generalized alpha integrator.
Definition interface.h:98
bool output_last_cycle_only_
Output results from last cycle only?
Definition interface.h:131
double time_step_size_
0D time step size
Definition interface.h:93
int num_time_steps_
Number of 0D time steps.
Definition interface.h:103
Integrator integrator_
The current 0D integrator object.
Definition interface.h:140
std::shared_ptr< Model > model_
The current 0D model object.
Definition interface.h:136
State state_
The current 0D state vector.
Definition interface.h:145
int max_nliter_
Maximum number of non-linear iterations.
Definition interface.h:111
int pts_per_cycle_
Number of time steps per cycle.
Definition interface.h:127
int num_output_steps_
The number of steps to output.
Definition interface.h:123
int time_step_
Current time step.
Definition interface.h:115
int problem_id_
ID of current interface.
Definition interface.h:75
double absolute_tolerance_
Convergence tolerance for the 0D model.
Definition interface.h:107
int system_size_
The size of the 0D system.
Definition interface.h:119
std::string input_file_name_
0D input (JSON) file
Definition interface.h:80
static std::map< int, SolverInterface * > interface_list_
List of interfaces.
Definition interface.h:70
std::vector< State > states_
Vector to store solution states.
Definition interface.h:153
std::vector< double > times_
Vector to store solution times.
Definition interface.h:149
static int problem_id_count_
Counter for the number of interfaces.
Definition interface.h:66
SolverInterface(const std::string &input_file_name)
Construct a new interface object.
Definition interface.cpp:44
State of the system.
Definition State.h:46
csv_writer source file
DEBUG_MSG source file.