70 JournalBearing(
unsigned uLabel,
const DofOwner *pDO,
72 virtual ~JournalBearing(
void);
73 virtual unsigned int iGetNumDof(
void)
const;
76 virtual std::ostream& DescribeDof(std::ostream& out,
const char *prefix,
bool bInitial)
const;
77 virtual std::ostream& DescribeEq(std::ostream& out,
const char *prefix,
bool bInitial)
const;
78 virtual unsigned int iGetNumPrivData(
void)
const;
79 virtual unsigned int iGetPrivDataIdx(
const char *s)
const;
80 virtual doublereal dGetPrivData(
unsigned int i)
const;
82 virtual void WorkSpaceDim(
integer* piNumRows,
integer* piNumCols)
const;
100 int iGetNumConnectedNodes(
void)
const;
101 void GetConnectedNodes(std::vector<const Node *>& connectedNodes)
const;
104 std::ostream& Restart(std::ostream& out)
const;
105 virtual unsigned int iGetInitialNumDof(
void)
const;
107 InitialWorkSpaceDim(
integer* piNumRows,
integer* piNumCols)
const;
113 template <
typename T>
121 template <grad::index_type N>
124 template <grad::index_type N>
141 static const index_type iInitialWorkSpace = 28;
144 JournalBearing::JournalBearing(
145 unsigned uLabel,
const DofOwner *pDO,
173 " This element implements a journal bearing with lugre friction\n"
175 " journal bearing,\n"
176 " node1, (label) <node1>,\n"
177 " [ offset, (Vec3) <offset>, ]\n"
178 " [ hinge, (Mat3x3) <orientation>, ]\n"
179 " node2, (label) <node2>,\n"
180 " [ offset, (Vec3) <offset>, ]\n"
182 " diameter, (real) <d>, \n"
183 " coulomb friction coefficient, (real) <muc>,\n"
184 " [static friction coefficient, (real) <mus>,]\n"
185 " micro stick stiffness, (real) <sigma0>\n"
186 " [,micro stick damping, (real) <sigma1>]\n"
187 " [,sliding velocity coefficient, (real) <vs>]\n"
188 " [,sliding velocity exponent, (real) <a>]\n"
189 " [,viscous friction coefficient, (real) <kv>]\n"
202 silent_cerr(
"journal bearing(" << GetLabel() <<
"): keyword \"node1\" expected at line " << HP.
GetLineData() << std::endl);
209 silent_cerr(
"journal bearing(" << GetLabel() <<
"): structural node expected at line " << HP.
GetLineData() << std::endl);
224 silent_cerr(
"journal bearing(" << GetLabel() <<
"): keyword \"node2\" expected at line " << HP.
GetLineData() << std::endl);
231 silent_cerr(
"journal bearing(" << GetLabel() <<
"): structural node expected at line " << HP.
GetLineData() << std::endl);
243 silent_cerr(
"journal bearing(" << GetLabel()
244 <<
"): keyword \"diameter\" expected at line "
252 silent_cerr(
"journal bearing(" << GetLabel()
253 <<
"): \"diameter\" must be greater than zero at line "
258 if (!HP.
IsKeyWord(
"coulomb" "friction" "coefficient")) {
259 silent_cerr(
"journal bearing(" << GetLabel()
260 <<
"): keyword \"coulomb friction coefficient\" expected at line "
268 silent_cerr(
"\"coulomb friction coefficient\" "
269 "must be greater than zero at line "
274 if (HP.
IsKeyWord(
"static" "friction" "coefficient")) {
281 silent_cerr(
"journal bearing(" << GetLabel()
282 <<
"): \"static friction coefficient\" must be greater "
283 "than or equal to \"coulomb friction coefficient\" "
288 if (!HP.
IsKeyWord(
"micro" "stick" "stiffness")) {
289 silent_cerr(
"journal bearing(" << GetLabel()
290 <<
"): keyword \"micro stick stiffness\" expected at line "
298 silent_cerr(
"journal bearing(" << GetLabel()
299 <<
"): \"micro stick stiffness\" must be greater than zero at line "
304 if (HP.
IsKeyWord(
"micro" "stick" "damping")) {
309 silent_cerr(
"journal bearing(" << GetLabel()
310 <<
"): \"micro stick damping\" must be greater than or equal to zero at line "
315 if (HP.
IsKeyWord(
"sliding" "velocity" "coefficient")) {
320 silent_cerr(
"journal bearing(" << GetLabel()
321 <<
"): \"sliding velocity coefficient "
322 "must be greater than zero at line "
327 if (HP.
IsKeyWord(
"sliding" "velocity" "exponent")) {
331 if (HP.
IsKeyWord(
"viscous" "friction" "coefficient")) {
336 silent_cerr(
"journal bearing(" << GetLabel()
337 <<
"): \"viscous friction coefficient\" "
338 "must be greater than or equal to zero at line "
344 using namespace grad;
345 const Mat3x3& R1 = pNode1->GetRCurr();
346 const Vec3& omega1 = pNode1->GetWCurr();
347 const Vec3& omega2 = pNode2->GetWCurr();
349 const double domega_proj =
Dot(e.GetCol(1), domega);
350 const double v = (0.5 * d) * domega_proj;
353 const double g = muc + (mus - muc) *
exp(-
pow(
fabs(v / vs),
a));
354 z = v * g / (sigma0 *
fabs(v));
363 out <<
"journal bearing: " << GetLabel() <<
" "
364 << pNode1->GetLabel() <<
" "
367 << pNode2->GetLabel() <<
" " << o2 <<
" "
371 JournalBearing::~JournalBearing(
void)
376 unsigned int JournalBearing::iGetNumDof(
void)
const
378 return 2u + (muc > 0 ? 1u : 0u);
413 std::ostream& JournalBearing::DescribeDof(std::ostream& out,
const char *prefix,
bool bInitial)
const
415 const integer iFirstIndex = iGetFirstIndex();
417 out << prefix << iFirstIndex + 1 <<
"->" << iFirstIndex + 2 <<
": reaction forces [lambda1, lambda2]" << std::endl;
420 out << prefix << iFirstIndex + 3 <<
"->" << iFirstIndex + 4 <<
": reaction force derivatives [lambdaP1, lambdaP2]" << std::endl;
421 }
else if (muc > 0) {
422 out << prefix << iFirstIndex + 3 <<
"->" << iFirstIndex + 3 <<
": sticktion state [z]" << std::endl;
428 std::ostream& JournalBearing::DescribeEq(std::ostream& out,
const char *prefix,
bool bInitial)
const
430 const integer iFirstIndex = iGetFirstIndex();
432 out << prefix << iFirstIndex + 1 <<
"->" << iFirstIndex + 2 <<
": position constraints [c1, c2]" << std::endl;
435 out << prefix << iFirstIndex + 3 <<
"->" << iFirstIndex + 4 <<
": velocity constraints [cP1, cP2]" << std::endl;
436 }
else if (muc > 0) {
437 out << prefix << iFirstIndex + 3 <<
"->" << iFirstIndex + 3 <<
": sticktion state equation [f(z, zP)]" << std::endl;
443 unsigned int JournalBearing::iGetNumPrivData(
void)
const
448 unsigned int JournalBearing::iGetPrivDataIdx(
const char *s)
const
450 static const struct {
463 const int N = iGetNumPrivData();
465 ASSERT(N <=
sizeof(data) /
sizeof(data[0]));
467 for (
int i = 0; i < N; ++i) {
468 if (0 == strcmp(data[i].name, s)) {
469 return data[i].index;
476 doublereal JournalBearing::dGetPrivData(
unsigned int i)
const
499 silent_cerr(
"journal bearing(" << GetLabel() <<
"): invalid private data index " << i << std::endl);
513 os << std::setw(8) << GetLabel();
515 for (
int i = 1; i <= lambda.iGetNumRows(); ++i)
517 os <<
" " << lambda(i);
522 os <<
" " << z <<
" " << zP <<
" " << omega <<
" " << mf <<
" " << -omega * mf;
531 JournalBearing::WorkSpaceDim(
integer* piNumRows,
integer* piNumCols)
const
533 *piNumRows = *piNumCols = iWorkSpace;
570 template <
typename T>
581 const integer iFirstIndex = iGetFirstIndex();
582 const integer iFirstMomentumIndexNode1 = pNode1->iGetFirstMomentumIndex();
583 const integer iFirstMomentumIndexNode2 = pNode2->iGetFirstMomentumIndex();
588 pNode1->GetXCurr(X1, dCoef, func, &
dof);
589 pNode1->GetRCurr(R1, dCoef, func, &
dof);
590 pNode2->GetXCurr(X2, dCoef, func, &
dof);
591 pNode2->GetRCurr(R2, dCoef, func, &
dof);
595 XCurr.GetVec(iFirstIndex + 1, lambda, 1., &
dof);
599 const Vec3 R2o2 = R2 * o2;
600 const Vec3 l1 = X2 + R2o2 - X1;
602 const Vec3 F1 = R1 * Vec3(e.GetCol(2) * lambda(1) + e.GetCol(3) * lambda(2));
603 Vec3 M1 =
Cross(l1, F1);
605 Vec3 M2 =
Cross(R2o2, F2);
607 if (muc > 0 || kv > 0)
611 pNode1->GetWCurr(omega1, dCoef, func, &
dof);
612 pNode2->GetWCurr(omega2, dCoef, func, &
dof);
614 const T domega =
Dot(e.GetCol(1),
Transpose(R1) * Vec3(omega2 - omega1));
621 XCurr.dGetCoef(iFirstIndex + 3, z, dCoef, &
dof);
622 XPrimeCurr.dGetCoef(iFirstIndex + 3, zP, 1., &
dof);
626 const T v = (0.5 * d) * domega;
629 g = muc + (mus - muc) *
exp(-
pow(
fabs(v / vs),
a));
634 const T f = v - sigma0 *
fabs(v) / g * z - zP;
635 const T mu = sigma0 * z + sigma1 * zP;
637 if (lambda(1) != 0. || lambda(2) != 0) {
638 mf += (0.5 * d) * mu *
sqrt(lambda(1) * lambda(1) + lambda(2) * lambda(2));
641 WorkVec.AddItem(iFirstIndex + 3, f);
644 SaveFriction(domega, mf);
646 const Vec3 Mf = (R1 * e.
GetCol(1)) * mf;
652 WorkVec.AddItem(iFirstMomentumIndexNode1 + 1, F1);
653 WorkVec.AddItem(iFirstMomentumIndexNode1 + 4, M1);
654 WorkVec.AddItem(iFirstMomentumIndexNode2 + 1, F2);
655 WorkVec.AddItem(iFirstMomentumIndexNode2 + 4, M2);
659 for (
integer i = 1; i <= 2; ++i) {
660 WorkVec.AddItem(iFirstIndex + i,
Dot(e.GetCol(i + 1), a1) / dCoef);
666 this->lambda = lambda;
676 JournalBearing::iGetNumConnectedNodes(
void)
const
682 JournalBearing::GetConnectedNodes(std::vector<const Node *>& connectedNodes)
const
684 connectedNodes.resize(iGetNumConnectedNodes());
685 connectedNodes[0] = pNode1;
686 connectedNodes[1] = pNode2;
694 const integer iFirstIndex = iGetFirstIndex();
698 for (i = 1; i <= 2; ++i) {
699 X.
PutCoef(iFirstIndex + i, lambda(i));
704 XP.
PutCoef(iFirstIndex + i, zP);
709 JournalBearing::Restart(std::ostream& out)
const
715 JournalBearing::iGetInitialNumDof(
void)
const
721 JournalBearing::InitialWorkSpaceDim(
725 *piNumRows = *piNumCols = iInitialWorkSpace;
729 JournalBearing::InitialAssJac(
744 JournalBearing::InitialAssRes(
756 template <
typename T>
766 Vec3 X1, XP1, X2, XP2, omega1, omega2;
769 pNode1->GetXCurr(X1, 1., func, &
dof);
770 pNode1->GetRCurr(R1, 1., func, &
dof);
771 pNode1->GetVCurr(XP1, 1., func, &
dof);
772 pNode1->GetWCurr(omega1, 1., func, &
dof);
774 pNode2->GetXCurr(X2, 1., func, &
dof);
775 pNode2->GetRCurr(R2, 1., func, &
dof);
776 pNode2->GetVCurr(XP2, 1., func, &
dof);
777 pNode2->GetWCurr(omega2, 1., func, &
dof);
779 const integer iFirstIndexNode1 = pNode1->iGetFirstIndex();
780 const integer iFirstIndexNode2 = pNode2->iGetFirstIndex();
781 const integer iFirstIndex = iGetFirstIndex();
783 Vec2 lambda, lambdaP;
785 for (
integer i = 1; i <= 2; ++i) {
786 XCurr.dGetCoef(iFirstIndex + i, lambda(i), 1., &
dof);
787 XCurr.dGetCoef(iFirstIndex + i + 2, lambdaP(i), 1., &
dof);
792 const Vec3 R2o2 = R2 * o2;
793 const Vec3 l1 = X2 + R2o2 - X1;
795 const Vec3 F1 = R1 * Vec3(e.GetCol(2) * lambda(1) + e.GetCol(3) * lambda(2));
796 const Vec3 M1 =
Cross(l1, F1);
797 const Vec3 FP1 =
Cross(omega1, R1 * Vec3(e.GetCol(2) * lambda(1) + e.GetCol(3) * lambda(2)))
798 + R1 * Vec3(e.GetCol(2) * lambdaP(1) + e.GetCol(3) * lambdaP(2));
799 const Vec3 MP1 = -
Cross(F1, XP2 +
Cross(omega2, R2o2) - XP1) +
Cross(l1, FP1);
801 const Vec3 M2 =
Cross(R2o2, F2);
802 const Vec3 FP2 = -FP1;
808 WorkVec.AddItem(iFirstIndexNode1 + 1, F1);
809 WorkVec.AddItem(iFirstIndexNode1 + 4, M1);
810 WorkVec.AddItem(iFirstIndexNode1 + 7, FP1);
811 WorkVec.AddItem(iFirstIndexNode1 + 10, MP1);
813 WorkVec.AddItem(iFirstIndexNode2 + 1, F2);
814 WorkVec.AddItem(iFirstIndexNode2 + 4, M2);
815 WorkVec.AddItem(iFirstIndexNode2 + 7, FP2);
816 WorkVec.AddItem(iFirstIndexNode2 + 10, MP2);
818 for (
int i = 1; i <= 2; ++i) {
819 WorkVec.AddItem(iFirstIndex + i,
Dot(e.GetCol(i + 1),
a));
820 WorkVec.AddItem(iFirstIndex + i + 2,
Dot(e.GetCol(i + 1), aP));
830 if (!
SetUDE(
"journal" "bearing", rf))
842 #ifndef STATIC_MODULES
851 silent_cerr(
"journal_bearing: "
852 "module_init(" << module_name <<
") "
853 "failed" << std::endl);
863 #endif // ! STATIC_MODULE
flag fReadOutput(MBDynParser &HP, const T &t) const
GradientExpression< UnaryExpr< FuncExp, Expr > > exp(const GradientExpression< Expr > &u)
Mat3x3 GetRotRel(const ReferenceFrame &rf)
const Vec3 Zero3(0., 0., 0.)
MatrixExpression< TransposedMatrix< MatrixDirectExpr< Matrix< T, N_rows, N_cols > > >, N_cols, N_rows > Transpose(const Matrix< T, N_rows, N_cols > &A)
GradientExpression< BinaryExpr< FuncPow, LhsExpr, RhsExpr > > pow(const GradientExpression< LhsExpr > &u, const GradientExpression< RhsExpr > &v)
#define MBDYN_EXCEPT_ARGS
const Mat3x3 Eye3(1., 0., 0., 0., 1., 0., 0., 0., 1.)
Vec3 GetCol(unsigned short int i) const
int module_init(const char *module_name, void *pdm, void *php)
This function registers our user defined element for the math parser.
std::vector< Hint * > Hints
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
virtual bool GetYesNoOrBool(bool bDefval=false)
void func(const T &u, const T &v, const T &w, doublereal e, T &f)
Vec3 GetPosRel(const ReferenceFrame &rf)
static const char * dof[]
virtual bool IsKeyWord(const char *sKeyWord)
std::ostream & Loadable(void) const
bool journal_bearing_set(void)
DotTraits< VectorExprLhs, VectorExprRhs, N_rows, N_rows >::ExpressionType Dot(const VectorExpression< VectorExprLhs, N_rows > &u, const VectorExpression< VectorExprRhs, N_rows > &v)
#define ASSERT(expression)
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
virtual void PutCoef(integer iRow, const doublereal &dCoef)=0
VectorExpression< VectorCrossExpr< VectorLhsExpr, VectorRhsExpr >, 3 > Cross(const VectorExpression< VectorLhsExpr, 3 > &u, const VectorExpression< VectorRhsExpr, 3 > &v)
std::ostream & GetLogFile(void) const
bool SetUDE(const std::string &s, UserDefinedElemRead *rude)
static const doublereal a
SparseSubMatrixHandler & SetSparse(void)
virtual HighParser::ErrOut GetLineData(void) const
Node * ReadNode(MBDynParser &HP, Node::Type type) const
bool UseText(int out) const
virtual doublereal GetReal(const doublereal &dDefval=0.0)