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

#include <shape_impl.h>

Inheritance diagram for PiecewiseLinearShape1D:
Collaboration diagram for PiecewiseLinearShape1D:

Public Member Functions

 PiecewiseLinearShape1D (int n, doublereal *x, doublereal *v)
 
 ~PiecewiseLinearShape1D (void)
 
doublereal dGet (doublereal d, doublereal=0.) const
 
std::ostream & Restart (std::ostream &out) const
 
- Public Member Functions inherited from Shape1D
virtual ~Shape1D (void)
 
- Public Member Functions inherited from Shape
virtual ~Shape (void)
 

Protected Attributes

int nPoints
 
doublerealpdX
 
doublerealpdV
 

Detailed Description

Definition at line 76 of file shape_impl.h.

Constructor & Destructor Documentation

PiecewiseLinearShape1D::PiecewiseLinearShape1D ( int  n,
doublereal x,
doublereal v 
)

Definition at line 171 of file shape.cc.

References ASSERT, nPoints, pdV, and pdX.

173 : nPoints(n), pdX(x), pdV(v)
174 {
175  ASSERT(nPoints > 0);
176  ASSERT(pdX != NULL);
177  ASSERT(pdV != NULL);
178 }
doublereal * pdV
Definition: shape_impl.h:80
#define ASSERT(expression)
Definition: colamd.c:977
doublereal * pdX
Definition: shape_impl.h:79
PiecewiseLinearShape1D::~PiecewiseLinearShape1D ( void  )

Definition at line 180 of file shape.cc.

References pdV, pdX, and SAFEDELETEARR.

181 {
184 }
doublereal * pdV
Definition: shape_impl.h:80
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdX
Definition: shape_impl.h:79

Member Function Documentation

doublereal PiecewiseLinearShape1D::dGet ( doublereal  d,
doublereal  = 0. 
) const
virtual

Implements Shape.

Definition at line 187 of file shape.cc.

References nPoints, pdV, and pdX.

188 {
189  if (d <= pdX[0]) {
190  return pdV[0];
191  }
192 
193  for (int i = 1; i < nPoints; i++) {
194  if (d <= pdX[i]) {
195  doublereal dl = pdX[i] - pdX[i-1];
196  doublereal dw1 = pdX[i] - d;
197  doublereal dw2 = d - pdX[i - 1];
198  return (pdV[i]*dw2 + pdV[i - 1]*dw1)/dl;
199  }
200  }
201 
202  return pdV[nPoints - 1];
203 }
doublereal * pdV
Definition: shape_impl.h:80
double doublereal
Definition: colamd.c:52
doublereal * pdX
Definition: shape_impl.h:79
std::ostream & PiecewiseLinearShape1D::Restart ( std::ostream &  out) const
virtual

Implements Shape.

Definition at line 206 of file shape.cc.

References nPoints, pdV, and pdX.

207 {
208  out << "piecewise linear, " << nPoints;
209 
210  for (int i = 0; i < nPoints; i++) {
211  out << ", " << pdX[i] << ", " << pdV[i];
212  }
213 
214  return out;
215 }
doublereal * pdV
Definition: shape_impl.h:80
doublereal * pdX
Definition: shape_impl.h:79

Member Data Documentation

int PiecewiseLinearShape1D::nPoints
protected

Definition at line 78 of file shape_impl.h.

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

doublereal* PiecewiseLinearShape1D::pdV
protected

Definition at line 80 of file shape_impl.h.

Referenced by dGet(), PiecewiseLinearShape1D(), Restart(), and ~PiecewiseLinearShape1D().

doublereal* PiecewiseLinearShape1D::pdX
protected

Definition at line 79 of file shape_impl.h.

Referenced by dGet(), PiecewiseLinearShape1D(), Restart(), and ~PiecewiseLinearShape1D().


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