Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __PLUGGABLESIMULATOR_HPP__
00042 #define __PLUGGABLESIMULATOR_HPP__
00043
00044
00045 #include <string>
00046
00047 #include <openfluid/dllexport.hpp>
00048 #include <openfluid/ware/SimulatorSignature.hpp>
00049 #include <openfluid/core/TypeDefs.hpp>
00050 #include <openfluid/base/SchedulingRequest.hpp>
00051 #include <openfluid/base/LoopMacros.hpp>
00052 #include <openfluid/core/DateTime.hpp>
00053 #include <openfluid/core/Unit.hpp>
00054 #include <openfluid/core/CoreRepository.hpp>
00055 #include <openfluid/core/Event.hpp>
00056 #include <openfluid/core/EventsColl.hpp>
00057 #include <openfluid/ware/SimulationContributorWare.hpp>
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 #define DECLARE_SIMULATOR_PLUGIN \
00068 extern "C" \
00069 { \
00070 DLLEXPORT std::string WAREABIVERSION_PROC_DECL(); \
00071 DLLEXPORT openfluid::ware::PluggableSimulator* WAREBODY_PROC_DECL(); \
00072 DLLEXPORT openfluid::ware::SimulatorSignature* WARESIGNATURE_PROC_DECL(); \
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #define DEFINE_SIMULATOR_CLASS(pluginclassname) \
00085 std::string WAREABIVERSION_PROC_DECL() \
00086 { \
00087 return std::string(openfluid::config::FULL_VERSION); \
00088 } \
00089 \
00090 openfluid::ware::PluggableSimulator* WAREBODY_PROC_DECL() \
00091 { \
00092 return new pluginclassname(); \
00093 }
00094
00095
00096
00097
00098
00099
00100
00101 namespace openfluid { namespace ware {
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113 class DLLEXPORT PluggableSimulator : public SimulationContributorWare
00114 {
00115
00116 private:
00117
00118
00119
00120
00121
00122
00123
00124
00125 unsigned int m_MaxThreads;
00126
00127
00128 protected:
00129
00130
00131
00132
00133
00134
00135
00136 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00137 const openfluid::ware::WareParamKey_t& ParamName,
00138 openfluid::core::StringValue& Val) const;
00139
00140
00141
00142
00143
00144
00145
00146 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00147 const openfluid::ware::WareParamKey_t& ParamName,
00148 openfluid::core::DoubleValue& Val) const;
00149
00150
00151
00152
00153
00154
00155
00156 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00157 const openfluid::ware::WareParamKey_t& ParamName,
00158 openfluid::core::VectorValue& Val) const;
00159
00160
00161
00162
00163
00164
00165
00166 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00167 const openfluid::ware::WareParamKey_t& ParamName,
00168 openfluid::core::MatrixValue& Val) const;
00169
00170
00171
00172
00173
00174
00175
00176 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00177 const openfluid::ware::WareParamKey_t& ParamName,
00178 double& Val) const;
00179
00180
00181
00182
00183
00184
00185
00186 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00187 const openfluid::ware::WareParamKey_t& ParamName,
00188 long& Val) const;
00189
00190
00191
00192
00193
00194
00195
00196 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00197 const openfluid::ware::WareParamKey_t& ParamName,
00198 float& Val) const;
00199
00200
00201
00202
00203
00204
00205
00206 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00207 const openfluid::ware::WareParamKey_t& ParamName,
00208 int& Val) const;
00209
00210
00211
00212
00213
00214
00215
00216 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00217 const openfluid::ware::WareParamKey_t& ParamName,
00218 std::string& Val) const;
00219
00220
00221
00222
00223
00224
00225
00226 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00227 const openfluid::ware::WareParamKey_t& ParamName,
00228 std::vector<std::string>& Vals) const;
00229
00230
00231
00232
00233
00234
00235
00236 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00237 const openfluid::ware::WareParamKey_t& ParamName,
00238 std::vector<double>& Vals) const;
00239
00240
00241
00242
00243
00244
00245
00246 bool OPENFLUID_GetSimulatorParameter(const openfluid::ware::WareParams_t& Params,
00247 const openfluid::ware::WareParamKey_t& ParamName,
00248 std::vector<long>& Vals) const;
00249
00250
00251
00252
00253
00254 inline unsigned int OPENFLUID_GetSimulatorMaxThreads() const { return m_MaxThreads; };
00255
00256
00257
00258
00259
00260 void OPENFLUID_SetSimulatorMaxThreads(const unsigned int& MaxNumThreads);
00261
00262
00263 inline openfluid::base::SchedulingRequest AtTheEnd() const
00264 { return openfluid::base::SchedulingRequest(openfluid::base::SchedulingRequest::ATTHEEND); };
00265
00266 inline openfluid::base::SchedulingRequest Never() const
00267 { return openfluid::base::SchedulingRequest(openfluid::base::SchedulingRequest::NEVER); };
00268
00269 inline openfluid::base::SchedulingRequest DefaultDeltaT() const
00270 { return openfluid::base::SchedulingRequest(OPENFLUID_GetDefaultDeltaT()); };
00271
00272 inline openfluid::base::SchedulingRequest MultipliedDefaultDeltaT(const double& Mult) const
00273 { return openfluid::base::SchedulingRequest(Mult * OPENFLUID_GetDefaultDeltaT()); };
00274
00275 inline openfluid::base::SchedulingRequest Duration(const openfluid::core::Duration_t& D) const
00276 { return openfluid::base::SchedulingRequest(D); };
00277
00278
00279 public:
00280
00281
00282
00283 PluggableSimulator();
00284
00285
00286
00287
00288 virtual ~PluggableSimulator();
00289
00290
00291
00292
00293 void initializeWare(const WareID_t& SimID,const unsigned int& MaxThreads);
00294
00295
00296
00297
00298 virtual void initParams(const openfluid::ware::WareParams_t& Params)=0;
00299
00300
00301
00302
00303 virtual void prepareData()=0;
00304
00305
00306
00307
00308 virtual void checkConsistency()=0;
00309
00310
00311
00312
00313 virtual openfluid::base::SchedulingRequest initializeRun()=0;
00314
00315
00316
00317
00318 virtual openfluid::base::SchedulingRequest runStep()=0;
00319
00320
00321
00322
00323 virtual void finalizeRun()=0;
00324
00325 };
00326
00327 typedef PluggableSimulator* (*GetPluggableSimulatorBodyProc)();
00328
00329 typedef SimulatorSignature* (*GetPluggableSimulatorSignatureProc)();
00330
00331 } }
00332
00333
00334 #endif