Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 34 / 0 / 34
Functions: 100.0% 6 / 1 / 7
Branches: -% 0 / 0 / 0

OMCompiler/SimulationRuntime/cpp/Core/DataExchange/IHistory.h
Line Branch Exec Source
1 /*
2 * This file belongs to the OpenModelica Run-Time System
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings
5 * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights
6 * reserved.
7 *
8 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
9 * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY
10 * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
11 * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL
12 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
13 *
14 * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License
15 * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs:
16 * http://www.openmodelica.org or https://github.com/OpenModelica/ or
17 * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU
18 * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW
19 * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause.
20 *
21 * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY
23 * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF
24 * OSMC-PL.
25 *
26 */
27
28 #pragma once
29
30 /** @defgroup dataexchange Core.DataExchange
31 * Data storage module for simulation variables
32 * @{
33 */
34
35 /*****************************************************************************/
36 /**
37
38 Abstract dataexchange interface for dae system
39
40 \date June, 1st, 2011
41 \author
42
43 */
44
45
46 /** typedef for variable, parameter names*/
47 typedef std::vector<string> var_names_t;
48 /** typedef for the output values kind list, this is a boolean container which indicates if the output variable is a negate alias variable*/
49 typedef std::vector<bool> negate_values_t;
50 /**
51 * Class the holds all information to print output variables in a output file (matlab,textfile,buffer, ...)
52 * Holds a container of pointers for all output variable and parameter stored in the simvars array
53 */
54 template<typename T>
55 struct SimulationOutput
56 {
57 /** typedef for the output values list, this is a container which holds pointer for all output variables stored in the simvar array*/
58 typedef std::vector<const T*> values_t;
59
60 /** Container for all output parameter names*/
61 var_names_t parameterNames;
62 /** Container for all output parameter description*/
63 var_names_t parameterDescription;
64 /** Container for all output variable names*/
65 var_names_t outputVarNames;
66 /** Container for all output variable descriptions*/
67 var_names_t outputVarDescription;
68 /** Container for all output variables*/
69 values_t outputVars;
70 /** Container for all output parameter*/
71 values_t outputParams;
72 /** Container for all output variable kinds*/
73 negate_values_t negateOutputVars;
74
75 /**
76 * \brief adds a parameter to output list
77 *
78 * \param [in] name name of parameter
79 * \param [in] description description of parameter
80 * \param [in] var pointer to parameter in simvars array
81 */
82 802 void addParameter(string& name,string& description,const T* var)
83 {
84 802 parameterNames.push_back(name);
85 802 parameterDescription.push_back(description);
86 802 outputParams.push_back(var);
87 802 }
88 /**
89 * \brief adds a variable to output list
90 * \param [in] name name of variable
91 * \param [in] description description of variable
92 * \param [in] var pointer to variable in simvars array
93 */
94 2039 void addOutputVar(string& name,string& description,const T* var,bool negate)
95 {
96 2039 outputVarNames.push_back(name);
97 2039 outputVarDescription.push_back(description);
98 2039 outputVars.push_back(var);
99 2039 negateOutputVars.push_back(negate);
100 2039 }
101 };
102 /** typedef for all integer outputs */
103 typedef SimulationOutput<int> output_int_vars_t;
104 /** typedef for all boolean outputs */
105 typedef SimulationOutput<bool> output_bool_vars_t;
106 /** typedef for all real outputs */
107 typedef SimulationOutput<double> output_real_vars_t;
108 /** typedef for all derivatives output */
109 typedef SimulationOutput<double> output_der_vars_t;
110 /** typedef for all residues output */
111 typedef SimulationOutput<double> output_res_vars_t;
112
113 /** typedef for the integer output values list*/
114 typedef output_int_vars_t::values_t int_vars_t;
115 /** typedef for the boolean output values list*/
116 typedef output_bool_vars_t::values_t bool_vars_t;
117 /** typedef for the real output values list*/
118 typedef output_real_vars_t::values_t real_vars_t;
119 /** typedef for the derivatives output values list*/
120 typedef output_der_vars_t::values_t der_vars_t;
121 /** typedef for the residues output values list*/
122 typedef output_res_vars_t::values_t res_vars_t;
123 /**typedef for all output variables at one time step, all real vars, integer vars, boolean vars, simulation time*/
124 typedef tuple<real_vars_t,int_vars_t,bool_vars_t,double,der_vars_t,res_vars_t> all_vars_time_t;
125 /**typedef for all output variables at one time step except simulation time*/
126 typedef tuple<real_vars_t,int_vars_t,bool_vars_t,der_vars_t,res_vars_t> all_vars_t;
127 /**typedef for all output variables kinds at one time step*/
128 typedef tuple<negate_values_t,negate_values_t,negate_values_t,negate_values_t,negate_values_t> neg_all_vars_t;
129 /**typedef for all output data at one time step*/
130 typedef tuple<all_vars_time_t,neg_all_vars_t> write_data_t;
131 /**typedef for all variable names*/
132 typedef tuple<var_names_t,var_names_t,var_names_t,var_names_t,var_names_t> all_names_t;
133 /**typedef for all variable description*/
134 typedef tuple<var_names_t,var_names_t,var_names_t,var_names_t,var_names_t> all_description_t;
135
136
137
138
139 40 class IHistory
140 {
141 public:
142 /**
143 Returns simvalues for a time entry
144 */
145 virtual void getSimResults(const double time,ublas::vector<double>& v,ublas::vector<double>& dv) =0;
146 /**
147 Returns all simulation results for all Variables (R matrix) and rhs(dR)
148 */
149 virtual void getSimResults(ublas::matrix<double>& R,ublas::matrix<double>& dR) =0;
150 /**
151 Returns all simulation results for all Variables (R matrix), rhs(dR) and residues (Re)
152 */
153 virtual void getSimResults(ublas::matrix<double>& R,ublas::matrix<double>& dR,ublas::matrix<double>& Re) =0;
154
155 virtual void getOutputNames(vector<string >& output_names) = 0;
156
157 /**
158 Returns all output variables results
159 */
160 virtual void getOutputResults(ublas::matrix<double>& OR)=0;
161 /**
162 Retunrs all time entries
163 */
164 virtual vector<double> getTimeEntries() =0;
165 /**
166 Returns numer of all time entries
167 */
168 virtual unsigned long getSize()=0;
169 /**
170 Returns number of variabels (state-,algebraic variables)
171 */
172 virtual unsigned long getDimR()=0;
173 /**
174 Retunrs number of state variables
175 */
176 virtual unsigned long getDimdR()=0;
177 /**
178 Returns number of residues
179 */
180 virtual int getDimRe()=0;
181 /**
182 Clears simulation buffer
183 */
184 virtual void clear()=0;
185 virtual ~IHistory() {};
186 virtual void init() = 0;
187 virtual void write(const all_vars_t& v_list, double start_time, double end_time) = 0;
188 virtual void write(const all_names_t& s_list,const all_description_t& s_desc_list, const all_names_t& s_parameter_list,const all_description_t& s_desc_parameter_list) = 0;
189 virtual void write(const all_vars_time_t& v_list,const neg_all_vars_t& neg_v_list) = 0;
190 virtual void addContainerToWriteQueue(const write_data_t& container) = 0;
191 virtual write_data_t& getFreeContainer() =0;
192 };
193 /** @} */ // end of dataexchange
194