MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
PiecewiseLinearDriveCaller Class Reference

#include <drive_.h>

Inheritance diagram for PiecewiseLinearDriveCaller:
Collaboration diagram for PiecewiseLinearDriveCaller:

Public Member Functions

 PiecewiseLinearDriveCaller (const DriveHandler *pDH, unsigned int i, doublereal *p)
 
virtual ~PiecewiseLinearDriveCaller (void)
 
virtual DriveCallerpCopy (void) const
 
virtual std::ostream & Restart (std::ostream &out) const
 
doublereal dGet (const doublereal &dVar) const
 
virtual bool bIsDifferentiable (void) const
 
virtual doublereal dGetP (const doublereal &dVar) const
 
- Public Member Functions inherited from DriveCaller
 DriveCaller (const DriveHandler *pDH)
 
virtual ~DriveCaller (void)
 
virtual doublereal dGet (void) const
 
virtual doublereal dGetP (void) const
 
virtual void SetDrvHdl (const DriveHandler *pDH)
 
virtual const DriveHandlerpGetDrvHdl (void) const
 
virtual void Output (OutputHandler &OH) const
 
virtual void Trace (OutputHandler &OH) const
 
- Public Member Functions inherited from WithLabel
 WithLabel (unsigned int uL=0, const std::string &sN="")
 
virtual ~WithLabel (void)
 
void PutLabel (unsigned int uL)
 
void PutName (const std::string &sN)
 
unsigned int GetLabel (void) const
 
const std::string & GetName (void) const
 
- Public Member Functions inherited from ToBeOutput
 ToBeOutput (flag fOut=fDefaultOut)
 
virtual ~ToBeOutput (void)
 
virtual void OutputPrepare (OutputHandler &OH)
 
virtual void Output (OutputHandler &OH, const VectorHandler &X, const VectorHandler &XP) const
 
virtual flag fToBeOutput (void) const
 
virtual bool bToBeOutput (void) const
 
virtual void SetOutputFlag (flag f=flag(1))
 
- Public Member Functions inherited from Traceable
 Traceable (flag fTrace=0)
 
virtual ~Traceable (void)
 
virtual flag fToBeTraced (void) const
 
virtual void SetTraceFlag (flag f=TRACE)
 

Private Attributes

unsigned int iNumPoints
 
doublerealpPoints
 
doublerealpVals
 

Additional Inherited Members

- Public Types inherited from DriveCaller
enum  OutputFlags { OUTPUT_VALUE = OUTPUT_PRIVATE << 0, OUTPUT_DERIVATIVE = OUTPUT_PRIVATE << 1 }
 
enum  TraceFlags { TRACE_VALUE = TRACE_PRIVATE << 0, TRACE_DERIVATIVE = TRACE_PRIVATE << 1 }
 
- Public Types inherited from ToBeOutput
enum  { OUTPUT = 0x1U, OUTPUT_MASK = 0xFU, OUTPUT_PRIVATE = 0x10U, OUTPUT_PRIVATE_MASK = ~OUTPUT_MASK }
 
- Public Types inherited from Traceable
enum  { TRACE = 0x01U, TRACE_PUBLIC_MASK = 0x0FU, TRACE_PRIVATE = 0x10U, TRACE_PRIVATE_MASK = ~TRACE_PUBLIC_MASK }
 
- Protected Attributes inherited from DriveCaller
DriveHandlerpDrvHdl
 
- Protected Attributes inherited from WithLabel
unsigned int uLabel
 
std::string sName
 
- Protected Attributes inherited from ToBeOutput
flag fOutput
 

Detailed Description

Definition at line 1396 of file drive_.h.

Constructor & Destructor Documentation

PiecewiseLinearDriveCaller::PiecewiseLinearDriveCaller ( const DriveHandler pDH,
unsigned int  i,
doublereal p 
)

Definition at line 1063 of file drive_.cc.

References ASSERT.

Referenced by pCopy().

1065 : DriveCaller(pDH), iNumPoints(i), pPoints(p), pVals(p + i)
1066 {
1067  ASSERT(i >= 2);
1068  ASSERT(p != 0);
1069 }
unsigned int iNumPoints
Definition: drive_.h:1398
DriveCaller(const DriveHandler *pDH)
Definition: drive.cc:475
doublereal * pPoints
Definition: drive_.h:1399
#define ASSERT(expression)
Definition: colamd.c:977
PiecewiseLinearDriveCaller::~PiecewiseLinearDriveCaller ( void  )
virtual

Definition at line 1071 of file drive_.cc.

References pPoints, and SAFEDELETEARR.

1072 {
1073  if (pPoints != 0) {
1075  }
1076 }
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pPoints
Definition: drive_.h:1399

Member Function Documentation

bool PiecewiseLinearDriveCaller::bIsDifferentiable ( void  ) const
inlinevirtual

Reimplemented from DriveCaller.

Definition at line 1449 of file drive_.h.

1450 {
1451  return true;
1452 }
doublereal PiecewiseLinearDriveCaller::dGet ( const doublereal dVar) const
inlinevirtual

Implements DriveCaller.

Definition at line 1424 of file drive_.h.

References iNumPoints, MBDYN_EXCEPT_ARGS, pPoints, and pVals.

1425 {
1426  if (dVar <= pPoints[0]) {
1427  return pVals[0];
1428  }
1429 
1430  if (dVar >= pPoints[iNumPoints - 1]) {
1431  return pVals[iNumPoints - 1];
1432  }
1433 
1434  for (unsigned int i = 1; i < iNumPoints; i++) {
1435  if (dVar == pPoints[i]) {
1436  return pVals[i];
1437  }
1438  if (dVar < pPoints[i]) {
1439  doublereal dx = pPoints[i] - pPoints[i - 1];
1440  return ((dVar - pPoints[i - 1])*pVals[i]
1441  + (pPoints[i] - dVar)*pVals[i - 1])/dx;
1442  }
1443  }
1444 
1446 }
unsigned int iNumPoints
Definition: drive_.h:1398
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal * pPoints
Definition: drive_.h:1399
double doublereal
Definition: colamd.c:52
doublereal PiecewiseLinearDriveCaller::dGetP ( const doublereal dVar) const
inlinevirtual

Reimplemented from DriveCaller.

Definition at line 1455 of file drive_.h.

References iNumPoints, MBDYN_EXCEPT_ARGS, pPoints, and pVals.

1456 {
1457  if (dVar < pPoints[0] || dVar > pPoints[iNumPoints - 1]) {
1458  return 0.;
1459  }
1460 
1461  if (dVar == pPoints[0]) {
1462  return (pVals[1] - pVals[0])/(pPoints[1] - pPoints[0])/2.;
1463  }
1464 
1465  if (dVar == pPoints[iNumPoints - 1]) {
1466  return (pVals[iNumPoints - 1] - pVals[iNumPoints - 2])/(pPoints[iNumPoints - 1] - pPoints[iNumPoints - 2])/2.;
1467  }
1468 
1469  for (unsigned int i = 1; i < iNumPoints; i++) {
1470  if (dVar == pPoints[i]) {
1471  doublereal dS1 = (pVals[i] - pVals[i - 1])/(pPoints[i] - pPoints[i - 1]);
1472  doublereal dS2 = (pVals[i + 1] - pVals[i])/(pPoints[i + 1] - pPoints[i]);
1473 
1474  return (dS1 + dS2)/2.;
1475  }
1476 
1477  if (dVar < pPoints[i]) {
1478  return (pVals[i] - pVals[i - 1])/(pPoints[i] - pPoints[i - 1]);
1479  }
1480  }
1481 
1483 }
unsigned int iNumPoints
Definition: drive_.h:1398
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
doublereal * pPoints
Definition: drive_.h:1399
double doublereal
Definition: colamd.c:52
DriveCaller * PiecewiseLinearDriveCaller::pCopy ( void  ) const
virtual

Implements DriveCaller.

Definition at line 1080 of file drive_.cc.

References iNumPoints, DriveCaller::pDrvHdl, PiecewiseLinearDriveCaller(), pPoints, SAFENEWARR, and SAFENEWWITHCONSTRUCTOR.

1081 {
1082  doublereal *p = 0;
1084  for (unsigned int i = 0; i < 2*iNumPoints; i++) {
1085  p[i] = pPoints[i];
1086  }
1087 
1088  DriveCaller* pDC = 0;
1091  PiecewiseLinearDriveCaller(pDrvHdl, iNumPoints, p));
1092 
1093  return pDC;
1094 }
unsigned int iNumPoints
Definition: drive_.h:1398
doublereal * pPoints
Definition: drive_.h:1399
DriveHandler * pDrvHdl
Definition: drive.h:444
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
PiecewiseLinearDriveCaller(const DriveHandler *pDH, unsigned int i, doublereal *p)
Definition: drive_.cc:1063
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

std::ostream & PiecewiseLinearDriveCaller::Restart ( std::ostream &  out) const
virtual

Implements DriveCaller.

Definition at line 1098 of file drive_.cc.

References iNumPoints, pPoints, and pVals.

1099 {
1100  out << "piecewise linear, " << iNumPoints;
1101 
1102  for (unsigned int i = 0; i < iNumPoints; i++) {
1103  out << ", " << pPoints[i] << ", " << pVals[i];
1104  }
1105 
1106  return out;
1107 }
unsigned int iNumPoints
Definition: drive_.h:1398
doublereal * pPoints
Definition: drive_.h:1399

Member Data Documentation

unsigned int PiecewiseLinearDriveCaller::iNumPoints
private

Definition at line 1398 of file drive_.h.

Referenced by dGet(), dGetP(), pCopy(), and Restart().

doublereal* PiecewiseLinearDriveCaller::pPoints
private

Definition at line 1399 of file drive_.h.

Referenced by dGet(), dGetP(), pCopy(), Restart(), and ~PiecewiseLinearDriveCaller().

doublereal* PiecewiseLinearDriveCaller::pVals
private

Definition at line 1400 of file drive_.h.

Referenced by dGet(), dGetP(), and Restart().


The documentation for this class was generated from the following files: