MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
friction.cc File Reference
#include "mbconfig.h"
#include <cmath>
#include "mbpar.h"
#include "datamanforward.h"
#include "friction.h"
#include "submat.h"
Include dependency graph for friction.cc:

Go to the source code of this file.

Functions

int sign (const doublereal x)
 
BasicFriction *const ParseFriction (MBDynParser &HP, DataManager *pDM)
 
BasicShapeCoefficient *const ParseShapeCoefficient (MBDynParser &HP)
 

Function Documentation

BasicFriction* const ParseFriction ( MBDynParser HP,
DataManager pDM 
)

Definition at line 608 of file friction.cc.

References IncludeParser::GetLineData(), HighParser::GetReal(), HighParser::IsKeyWord(), LASTKEYWORD, MBDYN_EXCEPT_ARGS, and ParseScalarFunction().

610 {
611  const char* sKeyWords[] = {
612  "modlugre",
613  "discrete" "coulomb",
614  NULL
615  };
616  enum KeyWords {
617  MODLUGRE = 0,
618  DISCRETECOULOMB,
620  };
621  /* token corrente */
622  KeyWords FuncType;
623 
624  KeyTable K(HP, sKeyWords);
625 
626  FuncType = KeyWords(HP.IsKeyWord());
627  switch (FuncType) {
628  case MODLUGRE: {
629  doublereal sigma0 = HP.GetReal();
630  doublereal sigma1 = HP.GetReal();
631  doublereal sigma2 = HP.GetReal();
632  doublereal kappa = HP.GetReal();
633  const BasicScalarFunction*const sf =
634  ParseScalarFunction(HP, pDM);
635  return new ModLugreFriction(sigma0, sigma1, sigma2, kappa, sf);
636  break;
637  }
638  case DISCRETECOULOMB: {
639  const BasicScalarFunction*const sf =
640  ParseScalarFunction(HP, pDM);
641  doublereal sigma2 = 0.;
642  doublereal vel_ratio = 0.8;
643  if (HP.IsKeyWord("sigma2")) {
644  sigma2 = HP.GetReal();
645  }
646  if (HP.IsKeyWord("velocity" "ratio")) {
647  vel_ratio = HP.GetReal();
648  }
649  return new DiscreteCoulombFriction(sf,sigma2, vel_ratio);
650  break;
651  }
652  default: {
653  silent_cerr("ParseFriction(): unrecognized friction type "
654  "at line " << HP.GetLineData() << std::endl);
656  break;
657  }
658  }
659  return 0;
660 };
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
KeyWords
Definition: dataman4.cc:94
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
const BasicScalarFunction *const ParseScalarFunction(MBDynParser &HP, DataManager *const pDM)
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function:

BasicShapeCoefficient* const ParseShapeCoefficient ( MBDynParser HP)

Definition at line 662 of file friction.cc.

References IncludeParser::GetLineData(), HighParser::GetReal(), HighParser::IsKeyWord(), LASTKEYWORD, and MBDYN_EXCEPT_ARGS.

662  {
663  const char* sKeyWords[] = {
664  "simple",
665  "simple" "plane" "hinge",
666  "screw" "joint",
667  NULL
668  };
669  enum KeyWords {
670  SIMPLE = 0,
671  SIMPLEPLANEHINGE,
672  SCREWJOINT,
674  };
675  /* token corrente */
676  KeyWords FuncType;
677 
678  KeyTable K(HP, sKeyWords);
679 
680  FuncType = KeyWords(HP.IsKeyWord());
681  switch (FuncType) {
682  case SIMPLE: {
683  return new SimpleShapeCoefficient();
684  break;
685  }
686  case SIMPLEPLANEHINGE: {
687  return new SimplePlaneHingeJointSh_c();
688  break;
689  }
690  case SCREWJOINT: {
691  doublereal radius(0.), hta(0.);
692  if (HP.IsKeyWord("radius")) {
693  radius = HP.GetReal();
694  } else {
695  pedantic_cerr("ScrewJointShapeCoefficient: missing keyword \"radius\" at line "
696  << HP.GetLineData());
697  }
698  if (HP.IsKeyWord("half" "thread" "angle")) {
699  hta = HP.GetReal();
700  } else {
701  pedantic_cerr("ScrewJointShapeCoefficient: missing keyword \"half thread angle\" at line "
702  << HP.GetLineData());
703  }
704  return new ScrewJointSh_c(radius, hta);
705  break;
706  }
707  default: {
708  silent_cerr("ParseShapeCoefficient(): "
709  "unrecognized shape coefficient type "
710  "at line " << HP.GetLineData() << std::endl);
712  break;
713  }
714  }
715  return 0;
716 };
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
KeyWords
Definition: dataman4.cc:94
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
virtual doublereal GetReal(const doublereal &dDefval=0.0)
Definition: parser.cc:1056

Here is the call graph for this function:

int sign ( const doublereal  x)

Definition at line 42 of file friction.cc.

Referenced by ModLugreFriction::alpha(), ModLugreFriction::alphad_v(), ModLugreFriction::alphad_z(), DiscreteCoulombFriction::AssJac(), DiscreteCoulombFriction::AssRes(), ModLugreFriction::fs(), and ModLugreFriction::fsd().

42  {
43  if (x >= 0.) {
44  return 1;
45  } else if (x < 0.) {
46  return -1;
47  }
48  return 0;
49 };