MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
beam2.h File Reference
#include "myassert.h"
#include "except.h"
#include "strnode.h"
#include "elem.h"
#include "gravity.h"
#include "constltp.h"
Include dependency graph for beam2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Beam2
 
class  Beam2::ErrGeneric
 
class  ViscoElasticBeam2
 

Functions

ElemReadBeam2 (DataManager *pDM, MBDynParser &HP, unsigned int uLabel)
 

Function Documentation

Elem* ReadBeam2 ( DataManager pDM,
MBDynParser HP,
unsigned int  uLabel 
)

Definition at line 1329 of file beam2.cc.

References AbsRefFrame, Node::ABSTRACT, Elem::BEAM, Elem::bInverseDynamics(), DataManager::bIsInverseDynamics(), DEBUGCOUTFNAME, DEBUGLCOUT, ConstLawType::ELASTIC, Beam::ELASTIC, InverseDynamics::ERGONOMY, Eye3, DataManager::fReadOutput(), MBDynParser::GetConstLaw6D(), ConstitutiveLaw< T, Tder >::GetConstLawType(), ConstitutiveLaw< T, Tder >::GetFDE(), HighParser::GetInt(), WithLabel::GetLabel(), IncludeParser::GetLineData(), DataManager::GetLogFile(), MBDynParser::GetMat6xN(), MBDynParser::GetPosRel(), StructNode::GetRCurr(), MBDynParser::GetRotAbs(), MBDynParser::GetRotRel(), StructDispNode::GetXCurr(), HighParser::GetYesNoOrBool(), ConstitutiveLaw< T, Tder >::iGetNumDof(), HighParser::IsArg(), HighParser::IsKeyWord(), CGR_Rot::MatR, MBDYN_EXCEPT_ARGS, Mat3x3::MulTM(), MYDEBUG_INPUT, NO_OP, Beam::OUTPUT_NONE, CGR_Rot::Param, R, DataManager::ReadNode(), ReadOptionalBeamCustomOutput(), Mat3xN::Resize(), InverseDynamics::RIGHT_HAND_SIDE, SAFENEWARR, SAFENEWWITHCONSTRUCTOR, Elem::SetInverseDynamicsFlags(), Node::STRUCTURAL, ConstLawType::UNKNOWN, UNKNOWN_ORIENTATION_DESCRIPTION, and Beam::VISCOELASTIC.

Referenced by DataManager::ReadOneElem().

1330 {
1331  DEBUGCOUTFNAME("ReadBeam2");
1332 
1333  /* Nodo 1 */
1334  const StructNode* pNode1 = pDM->ReadNode<const StructNode, Node::STRUCTURAL>(HP);
1335 
1336  Mat3x3 R1(pNode1->GetRCurr());
1337  if (HP.IsKeyWord("position")) {
1338  /* just eat it! */
1339  NO_OP;
1340  }
1341  Vec3 f1(HP.GetPosRel(ReferenceFrame(pNode1)));
1342  Mat3x3 Rn1(Eye3);
1343  if (HP.IsKeyWord("orientation") || HP.IsKeyWord("rot")) {
1344  Rn1 = HP.GetRotRel(ReferenceFrame(pNode1));
1345  }
1346 
1347  DEBUGLCOUT(MYDEBUG_INPUT, "node 1 offset (node reference frame): "
1348  << f1 << std::endl << "(global frame): "
1349  << pNode1->GetXCurr() + pNode1->GetRCurr()*f1 << std::endl);
1350 
1351  /* Nodo 2 */
1352  const StructNode* pNode2 = pDM->ReadNode<const StructNode, Node::STRUCTURAL>(HP);
1353 
1354  Mat3x3 R2(pNode2->GetRCurr());
1355  if (HP.IsKeyWord("position")) {
1356  /* just eat it! */
1357  NO_OP;
1358  }
1359  Vec3 f2(HP.GetPosRel(ReferenceFrame(pNode2)));
1360  Mat3x3 Rn2(Eye3);
1361  if (HP.IsKeyWord("orientation") || HP.IsKeyWord("rot")) {
1362  Rn2 = HP.GetRotRel(ReferenceFrame(pNode2));
1363  }
1364 
1365  DEBUGLCOUT(MYDEBUG_INPUT, "node 2 offset (node reference frame): "
1366  << f2 << std::endl << "(global frame): "
1367  << pNode2->GetXCurr() + pNode2->GetRCurr()*f2 << std::endl);
1368 
1369  /* Matrice R */
1370  Mat3x3 R;
1371  flag f(0);
1372  if (HP.IsKeyWord("from" "nodes") || HP.IsKeyWord("node")) {
1373  f = flag(1);
1374  } else {
1375  R = HP.GetRotAbs(::AbsRefFrame);
1376  }
1377 
1378  /* Legame costitutivo */
1380  ConstitutiveLaw6D* pD = HP.GetConstLaw6D(CLType);
1381 
1382  if (pD->iGetNumDof() != 0) {
1383  silent_cerr("line " << HP.GetLineData()
1384  << ": Beam2(" << uLabel << ") does not support "
1385  "dynamic constitutive laws yet"
1386  << std::endl);
1388  }
1389 
1390  Beam::Type Type;
1391  if (CLType == ConstLawType::ELASTIC) {
1392  Type = Beam::ELASTIC;
1393  } else {
1394  Type = Beam::VISCOELASTIC;
1395  }
1396 
1397 #ifdef DEBUG
1398  Mat6x6 MTmp(pD->GetFDE());
1399  Mat3x3 D11(MTmp.GetMat11());
1400  Mat3x3 D12(MTmp.GetMat12());
1401  Mat3x3 D21(MTmp.GetMat21());
1402  Mat3x3 D22(MTmp.GetMat22());
1403 
1405  "First point matrix D11: " << std::endl << D11 << std::endl
1406  << "First point matrix D12: " << std::endl << D12 << std::endl
1407  << "First point matrix D21: " << std::endl << D21 << std::endl
1408  << "First point matrix D22: " << std::endl << D22 << std::endl);
1409 #endif /* DEBUG */
1410 
1411  flag fPiezo(0);
1412  Mat3xN PiezoMat[2];
1413  integer iNumElec = 0;
1414  const ScalarDifferentialNode** pvElecDofs = 0;
1415  if (HP.IsKeyWord("piezoelectric" "actuator")) {
1416  fPiezo = flag(1);
1418  "Piezoelectric actuator beam is expected"
1419  << std::endl);
1420 
1421  iNumElec = HP.GetInt();
1423  "piezo actuator " << uLabel
1424  << " has " << iNumElec
1425  << " electrodes" << std::endl);
1426  if (iNumElec <= 0) {
1427  silent_cerr("Beam2(" << uLabel << "): "
1428  "illegal number of electric nodes "
1429  << iNumElec
1430  << " at line " << HP.GetLineData()
1431  << std::endl);
1433  }
1434 
1435  SAFENEWARR(pvElecDofs, const ScalarDifferentialNode *, iNumElec);
1436 
1437  for (integer i = 0; i < iNumElec; i++) {
1438  pvElecDofs[i] = pDM->ReadNode<const ScalarDifferentialNode, Node::ABSTRACT>(HP);
1439  }
1440 
1441  PiezoMat[0].Resize(iNumElec);
1442  PiezoMat[1].Resize(iNumElec);
1443 
1444  /* leggere le matrici (6xN sez. 1, 6xN sez. 2) */
1445  HP.GetMat6xN(PiezoMat[0], PiezoMat[1], iNumElec);
1446 
1447 #if 0
1448  DEBUGLCOUT(MYDEBUG_INPUT, "Piezo matrix I:" << std::endl
1449  << PiezoMat[0][0] << PiezoMat[1][0]);
1450 #endif /* 0 */
1451  }
1452 
1454  unsigned uFlags = Beam::OUTPUT_NONE;
1455  ReadOptionalBeamCustomOutput(pDM, HP, uLabel, Type, uFlags, od);
1456 
1457  flag fOut = pDM->fReadOutput(HP, Elem::BEAM);
1458  if (fOut) {
1459  fOut |= uFlags;
1460  }
1461 
1462  /* Se necessario, interpola i parametri di rotazione delle sezioni */
1463  if (f) {
1464  Mat3x3 RR2 = R2*Rn2;
1465  Vec3 g(Vec3(CGR_Rot::Param, RR2.MulTM(R1*Rn1))/2);
1466  R = RR2*Mat3x3(CGR_Rot::MatR, g);
1467  }
1468 
1469  std::ostream& out = pDM->GetLogFile();
1470  out << "beam2: " << uLabel
1471  << " " << pNode1->GetLabel()
1472  << " ", f1.Write(out, " ")
1473  << " " << pNode2->GetLabel()
1474  << " ", f2.Write(out, " ")
1475  << std::endl;
1476 
1477  Elem* pEl = NULL;
1478 
1479  if (CLType == ConstLawType::ELASTIC) {
1480  if (fPiezo == 0) {
1482  Beam2,
1483  Beam2(uLabel,
1484  pNode1, pNode2,
1485  f1, f2,
1486  Rn1, Rn2,
1487  R,
1488  pD,
1489  od,
1490  fOut));
1491  } else {
1494  PiezoActuatorBeam2(uLabel,
1495  pNode1, pNode2,
1496  f1, f2,
1497  Rn1, Rn2,
1498  R,
1499  pD,
1500  iNumElec,
1501  pvElecDofs,
1502  PiezoMat[0], PiezoMat[1],
1503  od,
1504  fOut));
1505  }
1506 
1507  } else /* At least one is VISCOUS or VISCOELASTIC */ {
1508  if (fPiezo == 0) {
1511  ViscoElasticBeam2(uLabel,
1512  pNode1, pNode2,
1513  f1, f2,
1514  Rn1, Rn2,
1515  R,
1516  pD,
1517  od,
1518  fOut));
1519  } else {
1522  PiezoActuatorVEBeam2(uLabel,
1523  pNode1, pNode2,
1524  f1, f2,
1525  Rn1, Rn2,
1526  R,
1527  pD,
1528  iNumElec,
1529  pvElecDofs,
1530  PiezoMat[0], PiezoMat[1],
1531  od,
1532  fOut));
1533  }
1534  }
1535 
1536  // add here inverse dynamics
1537  bool bIsErgonomy(false);
1538  bool bIsRightHandSide(true);
1539 
1540  if (HP.IsKeyWord("inverse" "dynamics")) {
1541  if (HP.IsKeyWord("torque")) {
1542  silent_cerr("Beam2(" << uLabel << "): \"torque\" meaningless in this context "
1543  "at line " << HP.GetLineData() << std::endl);
1545  }
1546 
1547  if (HP.IsKeyWord("prescribed" "motion")) {
1548  silent_cerr("Beam2(" << uLabel << "): \"prescribed motion\" meaningless in this context "
1549  "at line " << HP.GetLineData() << std::endl);
1551  }
1552 
1553  if (HP.IsKeyWord("right" "hand" "side")) {
1554  bIsRightHandSide = HP.GetYesNoOrBool(bIsRightHandSide);
1555  }
1556 
1557  if (HP.IsKeyWord("ergonomy")) {
1558  bIsErgonomy = HP.GetYesNoOrBool(bIsErgonomy);
1559  if (bIsErgonomy) {
1560  ConstLawType::Type type = pD->GetConstLawType();
1561  if (type != ConstLawType::ELASTIC) {
1562  silent_cerr("Beam2(" << uLabel << "): invalid constitutive law type (must be ELASTIC)" << std::endl);
1564  }
1565 
1566  if (bIsRightHandSide) {
1567  silent_cerr("warning, Beam2(" << uLabel << ") is both \"ergonomy\" and \"right hand side\"" << std::endl);
1568  }
1569  }
1570  }
1571  }
1572 
1573  // set flags for inverse dynamics
1574  if (pDM->bIsInverseDynamics() && pEl->bInverseDynamics()) {
1575  unsigned flags = 0;
1576  if (bIsRightHandSide) {
1578  }
1579  if (bIsErgonomy) {
1580  flags |= InverseDynamics::ERGONOMY;
1581  }
1582  pEl->SetInverseDynamicsFlags(flags);
1583  }
1584 
1585  /* Se non c'e' il punto e virgola finale */
1586  if (HP.IsArg()) {
1587  silent_cerr("semicolon expected at line "
1588  << HP.GetLineData() << std::endl);
1590  }
1591 
1592  return pEl;
1593 } /* End of ReadBeam2() */
flag fReadOutput(MBDynParser &HP, const T &t) const
Definition: dataman.h:1064
virtual bool bInverseDynamics(void) const
Definition: elem.cc:65
Mat3x3 GetRotRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1795
const Param_Manip Param
Definition: matvec3.cc:644
long int flag
Definition: mbdyn.h:43
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
#define DEBUGCOUTFNAME(fname)
Definition: myassert.h:256
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
Mat3x3 GetRotAbs(const ReferenceFrame &rf)
Definition: mbpar.cc:1857
Definition: beam2.h:50
virtual void GetMat6xN(Mat3xN &m1, Mat3xN &m2, integer iNumCols)
Definition: mbpar.cc:2743
virtual const Tder & GetFDE(void) const
Definition: constltp.h:129
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
OrientationDescription
Definition: matvec3.h:1597
#define NO_OP
Definition: myassert.h:74
void SetInverseDynamicsFlags(unsigned uIDF)
Definition: elem.cc:71
virtual bool GetYesNoOrBool(bool bDefval=false)
Definition: parser.cc:1038
const ReferenceFrame AbsRefFrame(0, Vec3(0., 0., 0), Mat3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), Vec3(0., 0., 0), Vec3(0., 0., 0), EULER_123)
Vec3 GetPosRel(const ReferenceFrame &rf)
Definition: mbpar.cc:1331
virtual ConstLawType::Type GetConstLawType(void) const =0
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
Type
Definition: beam.h:64
const MatR_Manip MatR
Definition: matvec3.cc:645
ConstitutiveLaw6D * GetConstLaw6D(ConstLawType::Type &clt)
Definition: mbpar.cc:1995
Mat3x3 MulTM(const Mat3x3 &m) const
Definition: matvec3.cc:500
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
void Resize(integer ns)
Definition: matvec3n.cc:318
void ReadOptionalBeamCustomOutput(DataManager *pDM, MBDynParser &HP, unsigned int uLabel, Beam::Type BT, unsigned &uFlags, OrientationDescription &od)
Definition: beam.cc:1863
virtual unsigned int iGetNumDof(void) const
Definition: constltp.h:138
virtual bool IsArg(void)
Definition: parser.cc:807
Definition: elem.h:75
std::ostream & GetLogFile(void) const
Definition: dataman.h:326
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
long int integer
Definition: colamd.c:51
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
unsigned int GetLabel(void) const
Definition: withlab.cc:62
Node * ReadNode(MBDynParser &HP, Node::Type type) const
Definition: dataman3.cc:2309
#define DEBUGLCOUT(level, msg)
Definition: myassert.h:244
Mat3x3 R
bool bIsInverseDynamics(void) const
Definition: dataman.h:493

Here is the call graph for this function: