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

#include <drive_.h>

Inheritance diagram for FourierSeriesDriveCaller:
Collaboration diagram for FourierSeriesDriveCaller:

Public Member Functions

 FourierSeriesDriveCaller (const DriveHandler *pDH, doublereal dStartTime, doublereal dOmega, std::vector< doublereal > &a, integer iNumCyc, doublereal dInitialValue)
 
 ~FourierSeriesDriveCaller (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

doublereal dStartTime
 
doublereal dOmega
 
std::vector< doublerealamplitudes
 
integer iNumCycles
 
doublereal dInitialValue
 
doublereal dEndTime
 
bool bNeverEnd
 

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 964 of file drive_.h.

Constructor & Destructor Documentation

FourierSeriesDriveCaller::FourierSeriesDriveCaller ( const DriveHandler pDH,
doublereal  dStartTime,
doublereal  dOmega,
std::vector< doublereal > &  a,
integer  iNumCyc,
doublereal  dInitialValue 
)

Definition at line 611 of file drive_.cc.

References amplitudes, ASSERT, bNeverEnd, dEndTime, iNumCycles, and M_PI.

Referenced by pCopy().

617 : DriveCaller(pDH),
619 dOmega(dOmega),
620 iNumCycles(iNumCyc),
622 bNeverEnd(false)
623 {
624  ASSERT(iNumCycles >= 0);
625 
626  if (iNumCycles > 0) {
629 
630  /* Onde di coseno che continuano all'infinito */
631  } else if (iNumCycles == 0) {
632  dEndTime = 0.;
633  bNeverEnd = true;
634  }
635 
636  amplitudes.resize(a.size());
637  for (unsigned i = 0; i < a.size(); i++) {
638  amplitudes[i] = a[i];
639  }
640 }
std::vector< doublereal > amplitudes
Definition: drive_.h:968
#define M_PI
Definition: gradienttest.cc:67
doublereal dInitialValue
Definition: drive_.h:970
doublereal dStartTime
Definition: drive_.h:966
DriveCaller(const DriveHandler *pDH)
Definition: drive.cc:475
doublereal dEndTime
Definition: drive_.h:971
#define ASSERT(expression)
Definition: colamd.c:977
static const doublereal a
Definition: hfluid_.h:289
double doublereal
Definition: colamd.c:52
FourierSeriesDriveCaller::~FourierSeriesDriveCaller ( void  )

Definition at line 642 of file drive_.cc.

References NO_OP.

643 {
644  NO_OP;
645 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

bool FourierSeriesDriveCaller::bIsDifferentiable ( void  ) const
inlinevirtual

Reimplemented from DriveCaller.

Definition at line 1023 of file drive_.h.

1024 {
1025  return true;
1026 }
doublereal FourierSeriesDriveCaller::dGet ( const doublereal dVar) const
inlinevirtual

Implements DriveCaller.

Definition at line 1003 of file drive_.h.

References amplitudes, bNeverEnd, grad::cos(), dEndTime, dInitialValue, dOmega, dStartTime, and grad::sin().

1004 {
1006 
1007  if (dVar >= dStartTime && (bNeverEnd || dVar < dEndTime)) {
1008  doublereal t = dVar - dStartTime;
1009 
1010  d += amplitudes[0];
1011 
1012  for (unsigned i = 2; i < amplitudes.size(); i += 2 ) {
1013  doublereal theta = (i/2)*dOmega*t;
1014 
1015  d += amplitudes[i - 1]*cos(theta) + amplitudes[i]*sin(theta);
1016  }
1017  }
1018 
1019  return d;
1020 }
std::vector< doublereal > amplitudes
Definition: drive_.h:968
doublereal dInitialValue
Definition: drive_.h:970
GradientExpression< UnaryExpr< FuncSin, Expr > > sin(const GradientExpression< Expr > &u)
Definition: gradient.h:2977
doublereal dStartTime
Definition: drive_.h:966
doublereal dEndTime
Definition: drive_.h:971
GradientExpression< UnaryExpr< FuncCos, Expr > > cos(const GradientExpression< Expr > &u)
Definition: gradient.h:2978
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

doublereal FourierSeriesDriveCaller::dGetP ( const doublereal dVar) const
inlinevirtual

Reimplemented from DriveCaller.

Definition at line 1029 of file drive_.h.

References amplitudes, bNeverEnd, grad::cos(), dEndTime, dOmega, dStartTime, MBDYN_EXCEPT_ARGS, and grad::sin().

1030 {
1031  if (dVar < dStartTime) {
1032  return 0.;
1033  }
1034 
1035  if (!bNeverEnd && dVar > dEndTime) {
1036  return 0.;
1037  }
1038 
1039  doublereal t = dVar - dStartTime;
1040  doublereal dVal = 0.;
1041  bool bSingular = (amplitudes[0] != 0);
1042  for (unsigned i = 2; i < amplitudes.size(); i += 2 ) {
1043  doublereal omega = (i/2)*dOmega;
1044  doublereal theta = omega*t;
1045 
1046  dVal += omega*(-amplitudes[i - 1]*sin(theta) + amplitudes[i]*cos(theta));
1047 
1048  if (amplitudes[i - 1] != 0) {
1049  bSingular = true;
1050  }
1051  }
1052 
1053  if (dVar == dStartTime || (!bNeverEnd && dVar == dEndTime)) {
1054  if (bSingular) {
1055  silent_cerr("singularity in fourier series drive derivative at " << dVar << std::endl);
1057  }
1058  dVal /= 2.;
1059  }
1060 
1061  return dVal;
1062 }
std::vector< doublereal > amplitudes
Definition: drive_.h:968
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
GradientExpression< UnaryExpr< FuncSin, Expr > > sin(const GradientExpression< Expr > &u)
Definition: gradient.h:2977
doublereal dStartTime
Definition: drive_.h:966
doublereal dEndTime
Definition: drive_.h:971
GradientExpression< UnaryExpr< FuncCos, Expr > > cos(const GradientExpression< Expr > &u)
Definition: gradient.h:2978
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

DriveCaller * FourierSeriesDriveCaller::pCopy ( void  ) const
virtual

Implements DriveCaller.

Definition at line 649 of file drive_.cc.

References amplitudes, dInitialValue, dOmega, dStartTime, FourierSeriesDriveCaller(), iNumCycles, DriveCaller::pDrvHdl, and SAFENEWWITHCONSTRUCTOR.

650 {
651  DriveCaller* pDC = 0;
652 
656  dStartTime,
657  dOmega,
658  amplitudes,
659  iNumCycles,
660  dInitialValue));
661  return pDC;
662 }
std::vector< doublereal > amplitudes
Definition: drive_.h:968
doublereal dInitialValue
Definition: drive_.h:970
doublereal dStartTime
Definition: drive_.h:966
DriveHandler * pDrvHdl
Definition: drive.h:444
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
FourierSeriesDriveCaller(const DriveHandler *pDH, doublereal dStartTime, doublereal dOmega, std::vector< doublereal > &a, integer iNumCyc, doublereal dInitialValue)
Definition: drive_.cc:611

Here is the call graph for this function:

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

Implements DriveCaller.

Definition at line 667 of file drive_.cc.

References amplitudes, dInitialValue, dOmega, dStartTime, and iNumCycles.

668 {
669  out
670  << " fourier series, "
671  << dStartTime << ", "
672  << dOmega << ", "
673  << amplitudes.size()/2 << ", "
674  << 2.*amplitudes[0] << ", ";
675 
676  for (unsigned i = 1; i < amplitudes.size(); i++) {
677  out << amplitudes[i] << ", ";
678  }
679 
680  out
681  << iNumCycles << ", "
682  << dInitialValue;
683 
684  return out;
685 }
std::vector< doublereal > amplitudes
Definition: drive_.h:968
doublereal dInitialValue
Definition: drive_.h:970
doublereal dStartTime
Definition: drive_.h:966

Member Data Documentation

std::vector<doublereal> FourierSeriesDriveCaller::amplitudes
mutableprivate

Definition at line 968 of file drive_.h.

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

bool FourierSeriesDriveCaller::bNeverEnd
private

Definition at line 972 of file drive_.h.

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

doublereal FourierSeriesDriveCaller::dEndTime
private

Definition at line 971 of file drive_.h.

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

doublereal FourierSeriesDriveCaller::dInitialValue
private

Definition at line 970 of file drive_.h.

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

doublereal FourierSeriesDriveCaller::dOmega
private

Definition at line 967 of file drive_.h.

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

doublereal FourierSeriesDriveCaller::dStartTime
private

Definition at line 966 of file drive_.h.

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

integer FourierSeriesDriveCaller::iNumCycles
private

Definition at line 969 of file drive_.h.

Referenced by FourierSeriesDriveCaller(), pCopy(), and Restart().


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