-
Notifications
You must be signed in to change notification settings - Fork 297
/
Modelica.h
240 lines (224 loc) · 6.87 KB
/
Modelica.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#pragma once
/** @addtogroup core
*
* @{
*/
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <numeric>
#include <functional>
#define BOOST_UBLAS_SHALLOW_ARRAY_ADAPTOR
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/matrix_proxy.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include <boost/numeric/ublas/storage.hpp>
#include <boost/container/vector.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
/*Namespaces*/
using std::abs;
using std::ios;
using std::endl;
using std::cout;
using std::cerr;
using std::ostream_iterator;
using std::map;
using std::pair;
using std::make_pair;
using std::max;
using std::min;
using std::string;
using std::ostream;
using std::ostringstream;
using std::stringstream;
using std::vector;
using std::deque;
using std::copy;
using std::exception;
using std::runtime_error;
// uBLAS library
namespace ublas = boost::numeric::ublas;
#if !defined(USE_CPP_03) && !defined(__vxworks)
#include <array>
#include <tuple>
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
using namespace std::chrono;
#define USE_CHRONO
#if defined(USE_THREAD)
#include <thread>
#include <atomic>
#include <mutex>
#include <condition_variable>
using std::thread;
using std::atomic;
using std::mutex;
using std::memory_order_release;
using std::memory_order_relaxed;
using std::condition_variable;
using std::unique_lock;
#endif //USE_THREAD
// builtin range based for loop
#define FOREACH(element, range) for(element : range)
// builtin list initializers
#define LIST_OF {
#define LIST_SEP ,
#define LIST_END }
#define MAP_LIST_OF {{
#define MAP_LIST_SEP },{
#define MAP_LIST_END }}
#define TUPLE_LIST_OF {std::make_tuple(
#define TUPLE_LIST_SEP ),std::make_tuple(
#define TUPLE_LIST_END )}
/** namespace for generated code to avoid name clashes */
namespace omcpp {
using std::ref;
using std::trunc;
using std::to_string;
}
using std::bind;
using std::function;
using std::make_tuple;
using std::array;
using std::isfinite;
using std::minmax_element;
using std::get;
using std::tuple;
using std::unordered_map;
using std::unordered_set;
using std::shared_ptr;
using std::weak_ptr;
using std::dynamic_pointer_cast;
using std::to_string;
#else
#if defined(_MSC_VER)
#include <tuple>
using std::get;
using std::tuple;
using std::make_tuple;
using std::minmax_element;
#else
#include <boost/tuple/tuple.hpp>
#include <boost/algorithm/minmax_element.hpp>
using boost::get;
using boost::tuple;
using boost::make_tuple;
using boost::minmax_element;
#endif
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/array.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/trunc.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
#include <boost/ref.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#if defined(USE_THREAD)
#include <boost/thread.hpp>
#include <boost/atomic.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/bind.hpp>
using boost::bind;
using boost::function;
using boost::thread;
using boost::atomic;
using boost::mutex;
using boost::memory_order_release;
using boost::memory_order_relaxed;
using boost::condition_variable;
using boost::unique_lock;
#endif //USE_THREAD
// boost range based for loop
#define FOREACH BOOST_FOREACH
// boost list initializers
#define LIST_OF boost::assign::list_of(
#define LIST_SEP )(
#define LIST_END )
#define MAP_LIST_OF boost::assign::map_list_of(
#define MAP_LIST_SEP )(
#define MAP_LIST_END )
#define TUPLE_LIST_OF boost::assign::tuple_list_of(
#define TUPLE_LIST_SEP )(
#define TUPLE_LIST_END )
/** namespace for generated code to avoid name clashes */
namespace omcpp {
using boost::ref;
using boost::math::trunc;
template <typename T>
std::string to_string(T val) {
return boost::lexical_cast<std::string>(val);
}
}
using boost::array;
using boost::math::isfinite;
using boost::unordered_map;
using boost::unordered_set;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
using omcpp::to_string;
using namespace boost::lambda;
#endif //!USE_CPP_03
#if defined(USE_THREAD)
#include <Core/Utils/extension/barriers.hpp>
#endif //USE_THREAD
typedef ublas::shallow_array_adaptor<double> adaptor_t;
typedef ublas::vector<double, adaptor_t> shared_vector_t;
typedef ublas::matrix<double, ublas::column_major,adaptor_t> shared_matrix_t;
//typedef boost::function<bool (unsigned int)> getCondition_type;
//typedef boost::function<void (unordered_map<string,unsigned int>&,unordered_map<string,unsigned int>&)> init_prevars_type;
typedef ublas::compressed_matrix<double, ublas::column_major, 0, ublas::unbounded_array<int>, ublas::unbounded_array<double> > sparsematrix_t;
typedef ublas::matrix<double, ublas::column_major> matrix_t;
#include <Core/SimulationSettings/IGlobalSettings.h>
#include <Core/Solver/ISolverSettings.h>
#include <Core/SimulationSettings/ISettingsFactory.h>
#include <SimCoreFactory/Policies/FactoryConfig.h>
#include <Core/Utils/Modelica/ModelicaSimulationError.h>
#include <ModelicaUtilities.h>
#include <Core/Math/Array.h>
#include <Core/System/IStateSelection.h>
#include <Core/System/ISystemProperties.h>
#include <Core/System/ISystemInitialization.h>
#include <Core/System/IWriteOutput.h>
#include <Core/System/IContinuous.h>
#include <Core/System/ITime.h>
#include <Core/System/IEvent.h>
#include <Core/System/IStepEvent.h>
#include <Core/Solver/INonLinSolverSettings.h>
#include <Core/Solver/ILinSolverSettings.h>
#include <Core/DataExchange/IHistory.h>
#include <Core/System/IMixedSystem.h>
#include <Core/System/ILinearAlgLoop.h>
#include <Core/System/INonLinearAlgLoop.h>
#include <Core/System/ISystemTypes.h>
#include <Core/Solver/ISolver.h>
#include <Core/Solver/ILinearAlgLoopSolver.h>
#include <Core/Solver/INonLinearAlgLoopSolver.h>
#include <Core/System/IAlgLoopSolverFactory.h>
#include <Core/System/ISimVars.h>
#include <Core/DataExchange/ISimVar.h>
#include <Core/SimController/ISimData.h>
#include <Core/SimController/ISimObjects.h>
#include <Core/SimulationSettings/ISimControllerSettings.h>
#include <Core/Math/Functions.h>
#include <Core/Math/ArrayOperations.h>
#include <Core/Math/ArraySlice.h>
#include <Core/Math/Utility.h>
#include <Core/DataExchange/IPropertyReader.h>
#include <Core/DataExchange/SimDouble.h>
#ifdef USE_REDUCE_DAE
#include <Core/ReduceDAE/IReduceDAE.h>
#include <Core/ReduceDAE/ReduceDAESettings.h>
#endif
/** @} */ // end of group1