svZeroDSolver
Loading...
Searching...
No Matches
interface.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the
2// University of California, and others. SPDX-License-Identifier: BSD-3-Clause
3/**
4 * @file interface.h
5 * @brief svZeroDSolver callable interface.
6 */
7
8#include <map>
9#include <nlohmann/json.hpp>
10#include <string>
11#include <vector>
12
13#include "Integrator.h"
14#include "Model.h"
15#include "SparseSystem.h"
16#include "State.h"
17#include "csv_writer.h"
18#include "debug.h"
19
20/**
21 * @brief Interface class for calling svZeroD from external programs
22 */
24 public:
25 /**
26 * @brief Construct a new interface object
27 * @param input_file_name The 0D JSON file which specifies the model
28 */
29 SolverInterface(const std::string& input_file_name);
30
31 /**
32 * @brief Destroy the interface object
33 */
35
36 /**
37 * @brief Counter for the number of interfaces
38 */
40 /**
41 * @brief List of interfaces
42 */
43 static std::map<int, SolverInterface*> interface_list_;
44
45 /**
46 * @brief ID of current interface
47 */
48 int problem_id_ = 0;
49
50 /**
51 * @brief 0D input (JSON) file
52 */
53 std::string input_file_name_;
54
55 /**
56 * @brief Time step size of the external program
57 *
58 * This is required for coupling with a 3D solver
59 */
60 double external_step_size_ = 0.1;
61
62 // These are read in from the input JSON solver configuration file.
63 /**
64 * @brief 0D time step size
65 */
66 double time_step_size_ = 0.0;
67
68 /**
69 * @brief Spectral radius of generalized alpha integrator
70 */
71 double rho_infty_ = 0.0;
72
73 /**
74 * @brief Number of 0D time steps
75 */
77 /**
78 * @brief Convergence tolerance for the 0D model
79 */
80 double absolute_tolerance_ = 0.0;
81 /**
82 * @brief Maximum number of non-linear iterations
83 */
84 int max_nliter_ = 0;
85 /**
86 * @brief Current time step
87 */
88 int time_step_ = 0.0;
89 /**
90 * @brief The size of the 0D system
91 */
92 int system_size_ = 0;
93 /**
94 * @brief The number of steps to output
95 */
97 /**
98 * @brief Number of time steps per cycle
99 */
101 /**
102 * @brief Output results from last cycle only?
103 */
105
106 /**
107 * @brief The current 0D model object
108 */
109 std::shared_ptr<Model> model_;
110 /**
111 * @brief The current 0D integrator object
112 */
114
115 /**
116 * @brief The current 0D state vector
117 */
119 /**
120 * @brief Vector to store solution times
121 */
122 std::vector<double> times_;
123 /**
124 * @brief Vector to store solution states
125 */
126 std::vector<State> states_;
127};
Integrator source file.
model::Model source file
SparseSystem source file.
State source file.
Generalized-alpha integrator.
Definition Integrator.h:26
~SolverInterface()
Destroy the interface object.
Definition interface.cpp:23
double external_step_size_
Time step size of the external program.
Definition interface.h:60
double rho_infty_
Spectral radius of generalized alpha integrator.
Definition interface.h:71
bool output_last_cycle_only_
Output results from last cycle only?
Definition interface.h:104
double time_step_size_
0D time step size
Definition interface.h:66
int num_time_steps_
Number of 0D time steps.
Definition interface.h:76
Integrator integrator_
The current 0D integrator object.
Definition interface.h:113
std::shared_ptr< Model > model_
The current 0D model object.
Definition interface.h:109
State state_
The current 0D state vector.
Definition interface.h:118
int max_nliter_
Maximum number of non-linear iterations.
Definition interface.h:84
int pts_per_cycle_
Number of time steps per cycle.
Definition interface.h:100
int num_output_steps_
The number of steps to output.
Definition interface.h:96
int time_step_
Current time step.
Definition interface.h:88
int problem_id_
ID of current interface.
Definition interface.h:48
double absolute_tolerance_
Convergence tolerance for the 0D model.
Definition interface.h:80
int system_size_
The size of the 0D system.
Definition interface.h:92
std::string input_file_name_
0D input (JSON) file
Definition interface.h:53
static std::map< int, SolverInterface * > interface_list_
List of interfaces.
Definition interface.h:43
std::vector< State > states_
Vector to store solution states.
Definition interface.h:126
std::vector< double > times_
Vector to store solution times.
Definition interface.h:122
static int problem_id_count_
Counter for the number of interfaces.
Definition interface.h:39
SolverInterface(const std::string &input_file_name)
Construct a new interface object.
Definition interface.cpp:17
State of the system.
Definition State.h:19
csv_writer source file
DEBUG_MSG source file.