73 #ifdef USE_MULTITHREAD
74 pthread_mutexattr_t ma;
75 pthread_mutexattr_init(&ma);
76 pthread_mutexattr_settype(&ma, PTHREAD_MUTEX_RECURSIVE);
77 int rc = pthread_mutex_init(&parser_mutex, &ma);
78 pthread_mutexattr_destroy(&ma);
80 silent_cerr(
"DriveHandler::DriveHandler(): mutex init failed"
94 silent_cerr(
"DriveHandler::DriveHandler(): "
95 "error while inserting symbol 'Time'"
102 silent_cerr(
"Symbol 'Time' must be a variable"
115 silent_cerr(
"DriveHandler::DriveHandler(): "
116 "error while inserting symbol 'TimeStep'"
123 silent_cerr(
"Symbol 'TimeStep' must be a variable"
136 silent_cerr(
"DriveHandler::DriveHandler(): "
137 "error while inserting symbol 'Step'"
144 silent_cerr(
"Symbol 'Step' must be a variable"
157 silent_cerr(
"DriveHandler::DriveHandler(): "
158 "error while insterting symbol 'Var'"
165 silent_cerr(
"Symbol 'Var' must be a variable"
178 #ifdef USE_MULTITHREAD
179 pthread_mutex_destroy(&parser_mutex);
182 for (std::vector<MyMeter *>::iterator i =
Meter.begin();
183 i !=
Meter.end(); ++i)
188 for (std::vector<MyRand *>::iterator i =
Rand.begin();
189 i !=
Rand.end(); ++i)
194 for (std::vector<MyClosestNext*>::iterator i =
ClosestNext.begin();
200 for (std::vector<MySH *>::iterator i =
SH.begin();
231 for (std::vector<MyMeter *>::iterator i =
Meter.begin();
232 i !=
Meter.end(); ++i)
237 for (std::vector<MyRand *>::iterator i =
Rand.begin();
238 i !=
Rand.end(); ++i)
243 for (std::vector<MyClosestNext*>::iterator i =
ClosestNext.begin();
249 for (std::vector<MySH *>::iterator i =
SH.begin();
274 MyRand((
unsigned int)iNumber, iSteps, rand()));
287 MyMeter((
unsigned int)iNumber, iSteps));
288 Meter.push_back(pmm);
302 pIncrement, dStartTime));
317 MySH((
unsigned int)iNumber, pFunc, pTrigger, dVal0));
326 return SH[iNumber]->pGetFunc();
332 return SH[iNumber]->pGetTrigger();
338 return SH[iNumber]->dGetVal0();
362 #ifdef USE_MULTITHREAD
364 pthread_mutex_lock(&parser_mutex);
371 silent_cerr(
"StringDrive: " << e.
what() << std::endl);
373 #ifdef USE_MULTITHREAD
374 pthread_mutex_unlock(&parser_mutex);
381 silent_cerr(
"StringDrive: " << e.
what() << std::endl);
386 silent_cerr(
"StringDrive generic error" << std::endl);
388 #ifdef USE_MULTITHREAD
389 pthread_mutex_unlock(&parser_mutex);
395 #ifdef USE_MULTITHREAD
396 pthread_mutex_unlock(&parser_mutex);
404 :
MyMeter(uLabel, iS), iRand(iR)
415 :
WithLabel(uLabel), iSteps(iS), iCurr(0)
429 :
WithLabel(uLabel), pDH(pDH), Increment(pIncrement), bMustSetNext(
false), dNext(dStartTime)
443 :
WithLabel(uLabel), dVal0(dVal0), dVal(dVal0), Func(pFunc), Trigger(pTrigger)
456 return Func.pGetDriveCaller();
462 return Trigger.pGetDriveCaller();
510 if (fOut &
flag(1)) {
523 os <<
' ' <<
dGetP();
537 std::ostream& os = OH.
Traces();
548 os <<
' ' <<
dGetP();
586 return out <<
"null";
634 : pDriveCaller(drive.pDriveCaller ? drive.pDriveCaller->pCopy() : 0)
651 DEBUGCOUT(
"warning: the original pointer to a drive caller is not null!" << std::endl);
MySH(unsigned int uLabel, const DriveCaller *pFunc, const DriveCaller *pTrigger, const doublereal dVal0)
DriveHandler(MathParser &mp)
static doublereal dReturnValue
virtual DriveCaller * pCopy(void) const
#define MBDYN_EXCEPT_ARGS
Var * Put(const std::string &name, const TypedValue &v)
const DriveCaller * pGetSHTrigger(integer iNumber) const
integer iSHInit(const DriveCaller *pFunc, const DriveCaller *pTrigger, const doublereal dVal0)
virtual const DriveHandler * pGetDrvHdl(void) const
const char * what(void) const
doublereal dGet(void) const
virtual ~DriveCaller(void)
virtual void Trace(OutputHandler &OH) const
DriveCaller * pDriveCaller
const DriveCaller * pGetFunc(void) const
MyClosestNext(unsigned int uLabel, const DriveHandler *pDH, const DriveCaller *pIncrementDC, doublereal dStartTime)
void SetVar(const doublereal &dVar)
bool bIsDifferentiable(void) const
std::vector< MyMeter * > Meter
virtual std::ostream & Restart(std::ostream &out) const
virtual doublereal dGetP(const doublereal &dVar) const
const doublereal dGetVal0(void) const
void PutSymbolTable(Table &T)
doublereal dGetP(void) const
std::vector< MyClosestNext * > ClosestNext
DriveCaller(const DriveHandler *pDH)
std::ostream & Traces(void) const
virtual void SetDrvHdl(const DriveHandler *pDH)
Drive(unsigned int uL, const DriveHandler *pDH)
integer iMeterInit(integer iSteps)
virtual std::ostream & Restart(std::ostream &out) const
virtual bool bIsDifferentiable(void) const
const DriveCaller * pGetSHFunc(integer iNumber) const
#define SAFENEW(pnt, item)
static doublereal dDriveHandlerReturnValue
std::vector< MyRand * > Rand
virtual ~DriveOwner(void)
virtual ~MyClosestNext(void)
#define ASSERT(expression)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
DriveCaller * pGetDriveCaller(void) const
virtual DriveCaller * pCopy(void) const
virtual flag fToBeTraced(void) const
virtual doublereal dGet(void) const
VectorHandler * pXPrimeCurr
integer iRandInit(integer iSteps)
virtual doublereal dGet(const doublereal &dVar) const =0
std::ostream & DriveCallers(void) const
void LinkToSolution(const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
virtual doublereal dGetP(void) const
NamedValue * Get(const std::string &name) const
Real GetLastStmt(Real d=0., Token t=ARGSEP)
virtual flag fToBeOutput(void) const
void Set(const DriveCaller *pDC)
virtual ~NullDriveCaller(void)
void SetTime(const doublereal &dt, const doublereal &dts, const integer &s)
void PutSymbolTable(Table &T)
integer iClosestNextInit(const DriveCaller *pIncrement, doublereal dStartTime)
MyMeter(unsigned int uLabel, integer iS=1)
void SetVal(const bool &b)
Table & GetSymbolTable(void) const
const doublereal dGetSHVal0(integer iNumber) const
unsigned int GetLabel(void) const
doublereal dGet(InputStream &InStr) const
static int drive(const MathParser::MathArgs &args)
virtual void Output(OutputHandler &OH) const
virtual bool IsVar(void) const
const DriveCaller * pGetTrigger(void) const
DriveOwner(const DriveCaller *pDC=0)
bool UseText(int out) const
MyRand(unsigned int uLabel, integer iS=1, integer iR=0)
virtual ~OneDriveCaller(void)