mbsim 4.0.0 MBSim Kernel

single_contact.h
1 /* Copyright (C) 2004-2014 MBSim Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 *
17 * Contact: martin.o.foerg@googlemail.com
18 */
19
20 #ifndef _SINGLE_CONTACT_H_
21 #define _SINGLE_CONTACT_H_
22
23 #include <mbsim/links/contour_link.h>
24
25 namespace MBSim {
26
27 class GeneralizedForceLaw;
28 class GeneralizedImpactLaw;
29 class FrictionForceLaw;
30 class FrictionImpactLaw;
31
46 class SingleContact: public ContourLink {
47
48 friend class Contact;
49 friend class MaxwellContact;
50
51 public:
56 SingleContact(const std::string &name="") : ContourLink(name) { }
57
58 void resetUpToDate() override;
59
60 bool isSticking() const;
61
62 const double& evalGeneralizedNormalForce() { if(updlaN) updateGeneralizedNormalForce(); return lambdaN; }
63 const fmatvec::VecV& evalGeneralizedTangentialForce() { if(updlaT) updateGeneralizedTangentialForce(); return lambdaT; }
64
65 double& getGeneralizedNormalForce(bool check=true) { assert((not check) or (not updlaN)); return lambdaN; }
66
67 const double& evallaN();
68 const fmatvec::Vec& evallaT();
69
70 const double& evalLaN();
71 const fmatvec::Vec& evalLaT();
72
73 const double& evalgdnN();
74 const fmatvec::Vec& evalgdnT();
75
76 const double& evalgddN();
77 const fmatvec::Vec& evalgddT();
78
79 /* INHERITED INTERFACE OF LINKINTERFACE */
80 void updateGeneralizedNormalForce() { (this->*updateGeneralizedNormalForce_)(); updlaN = false; }
81 void updateGeneralizedTangentialForce() { (this->*updateGeneralizedTangentialForce_)(); updlaT = false; }
82 void updateGeneralizedNormalForceS();
83 void updateGeneralizedNormalForceM();
84 void updateGeneralizedNormalForceP();
85 void updateGeneralizedTangentialForceS();
86 void updateGeneralizedTangentialForceM();
87 void updateGeneralizedTangentialForce0() { }
88 void (SingleContact::*updateGeneralizedNormalForce_)();
89 void (SingleContact::*updateGeneralizedTangentialForce_)();
90 void updateGeneralizedForces() override;
91 void updateGeneralizedPositions() override;
92 void updateGeneralizedVelocities() override;
93 void updatePositions(Frame *frame) override;
94 void updateg() override;
95 void updategd() override;
96 void updateh(int i=0) override;
97 void updateW(int i=0) override;
98 void updateV(int i=0) override;
99 void updatewb() override;
100 void updateStopVector() override;
101 void updateStopVectorParameters() override;
102 /***************************************************/
103
104 /* INHERITED INTERFACE OF LINK */
105 void updatelaRef(fmatvec::Vec& ref) override;
106 void updateLaRef(fmatvec::Vec& ref) override;
107 void updategdRef(fmatvec::Vec& ref) override;
108 void calcSize() override;
109 void calclaSize(int j) override;
110 void calcgSize(int j) override;
111 void calcgdSize(int j) override;
112 void calcrFactorSize(int j) override;
113 void calcsvSize() override;
114 void calcLinkStatusSize() override;
115 void calcLinkStatusRegSize() override;
116 void init(InitStage stage, const InitConfigSet &config) override;
117 bool isSetValued() const override;
118 bool isSingleValued() const override;
119 void updateLinkStatus() override;
120 void updateLinkStatusReg() override;
121 bool isActive() const override;
122 bool gActiveChanged() override;
123 bool detectImpact() override;
124 void solveImpactsFixpointSingle() override;
125 void solveConstraintsFixpointSingle() override;
126 void solveImpactsGaussSeidel() override;
127 void solveConstraintsGaussSeidel() override;
128 void solveImpactsRootFinding() override;
129 void solveConstraintsRootFinding() override;
130 void jacobianConstraints() override;
131 void jacobianImpacts() override;
132 void updaterFactors() override;
133 void checkConstraintsForTermination() override;
134 void checkImpactsForTermination() override;
135 void checkActive(int j) override;
136 void LinearImpactEstimation(double t, fmatvec::Vec &gInActive_,fmatvec::Vec &gdInActive_,int *IndInActive_,fmatvec::Vec &gAct_,int *IndActive_) override;
137 void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override;
138
139 /***************************************************/
140
141 /* INHERITED INTERFACE OF ELEMENT */
142 /***************************************************/
143
144 /* GETTER / SETTER */
145 void setNormalForceLaw(GeneralizedForceLaw *fcl_) { fcl = fcl_; }
146 GeneralizedForceLaw * getNormalForceLaw() const { return fcl; }
147 void setNormalImpactLaw(GeneralizedImpactLaw *fnil_) { fnil = fnil_; }
148 void setTangentialForceLaw(FrictionForceLaw *fdf_) { fdf = fdf_; }
149 FrictionForceLaw * getTangentialForceLaw() const { return fdf; }
150 void setTangentialImpactLaw(FrictionImpactLaw *ftil_) { ftil = ftil_; }
151 /***************************************************/
152
156 virtual int getFrictionDirections() const;
157
158 void calccorrSize(int j) override;
159 void updatecorr(int j) override;
160
161 void checkRoot() override;
162
163 bool isNormalForceLawSetValued() const;
164 bool isTangentialForceLawSetValued() const;
165 bool isNormalForceLawSetValuedAndActive() const { return isNormalForceLawSetValued() and gdActive[normal]; }
166 bool isTangentialForceLawSetValuedAndActive() const { return isTangentialForceLawSetValued() and gdActive[tangential]; }
167
168 protected:
172 GeneralizedForceLaw *fcl{nullptr};
173
177 FrictionForceLaw *fdf{nullptr};
178
182 GeneralizedImpactLaw *fnil{nullptr};
183
187 FrictionImpactLaw *ftil{nullptr};
188
194 fmatvec::Vec laN, LaN;
195
201 fmatvec::Vec laT, LaT;
202
207 fmatvec::Vec gdN;
208
214 fmatvec::Vec gdT;
215
219 unsigned int gActive{0}, gActive0{0};
220
221 enum Direction {
222 normal,
223 tangential,
224 DirectionDIM
225 };
226
232 std::array<unsigned int, DirectionDIM> gdActive;
233
239 std::array<unsigned int, DirectionDIM> gddActive;
240
244 fmatvec::Vec gdnN, gdnT;
245
249 fmatvec::Vec gddN, gddT;
250
251 double lambdaN;
252 fmatvec::VecV lambdaT;
253
254 bool updlaN{true}, updlaT{true};
255
256 fmatvec::Vec gdTDir;
257
265 int rootID{0};
266 };
267
268 }
269
270 #endif /* _SINGLE_CONTACT_H_ */
MBSim::SingleContact::fnil
GeneralizedImpactLaw * fnil
force law defining relation between penetration velocity and resulting normal impulses
Definition: single_contact.h:182
MBSim::GeneralizedForceLaw
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:34
MBSim::SingleContact::solveImpactsFixpointSingle
void solveImpactsFixpointSingle() override
Definition: single_contact.cc:508
MBSim::SingleContact::calcgSize
void calcgSize(int j) override
calculates size of relative distances
Definition: single_contact.cc:307
MBSim::SingleContact::solveImpactsRootFinding
void solveImpactsRootFinding() override
Definition: single_contact.cc:630
MBSim::SingleContact::SizeLinearImpactEstimation
void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override
calculates the number of active and inactive unilateral constraints and increments sizeActive/sizeInA...
Definition: single_contact.cc:1161
MBSim::SingleContact::gddN
fmatvec::Vec gddN
gap acceleration for event driven scheme on acceleration level
Definition: single_contact.h:249
MBSim::SingleContact::fdf
FrictionForceLaw * fdf
force law defining relation between tangential velocities and tangential forces
Definition: single_contact.h:177
MBSim::Contact
class for contacts
Definition: contact.h:48
MBSim::SingleContact::gddActive
std::array< unsigned int, DirectionDIM > gddActive
boolean flag symbolising activity of contact on acceleration level
Definition: single_contact.h:239
MBSim::SingleContact::detectImpact
bool detectImpact() override
Definition: single_contact.cc:504
MBSim::SingleContact::calcsvSize
void calcsvSize() override
calculates size of stopvector (root function for event driven integration)
Definition: single_contact.cc:395
MBSim::SingleContact::updatelaRef
void updatelaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: single_contact.cc:213
MBSim::SingleContact::calcrFactorSize
void calcrFactorSize(int j) override
calculates size of rfactors
Definition: single_contact.cc:368
MBSim::SingleContact::gdnN
fmatvec::Vec gdnN
new gap velocity after an impact for event driven scheme
Definition: single_contact.h:244
MBSim::SingleContact::gdN
fmatvec::Vec gdN
relative velocity in normal direction
Definition: single_contact.h:207
MBSim::SingleContact::getFrictionDirections
virtual int getFrictionDirections() const
Definition: single_contact.cc:1055
MBSim::SingleContact::rootID
int rootID
type of detected root
Definition: single_contact.h:265
MBSim::SingleContact::calcgdSize
void calcgdSize(int j) override
calculates size of gap velocities
Definition: single_contact.cc:319
MBSim::SingleContact::updateLaRef
void updateLaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: single_contact.cc:223
MBSim::SingleContact::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: single_contact.cc:418
MBSim::SingleContact::fcl
GeneralizedForceLaw * fcl
force laws in normal and tangential direction on acceleration and velocity level
Definition: single_contact.h:172
MBSim::SingleContact::calcLinkStatusRegSize
void calcLinkStatusRegSize() override
calculates size of vector LinkStatusReg
Definition: single_contact.cc:412
MBSim::SingleContact::gdT
fmatvec::Vec gdT
relative velocity in tangential direction
Definition: single_contact.h:214
MBSim::SingleContact::checkActive
void checkActive(int j) override
check if set-valued contacts are active and set corresponding attributes
Definition: single_contact.cc:926
MBSim::SingleContact::updaterFactors
void updaterFactors() override
update relaxation factors for contact equations
Definition: single_contact.cc:795
MBSim::SingleContact::jacobianConstraints
void jacobianConstraints() override
computes JACOBIAN and mass action matrix of nonlinear contact equations
Definition: single_contact.cc:690
MBSim::SingleContact::isSingleValued
bool isSingleValued() const override
asks the link if it contains single valued force laws that contribute to the right-hand side vector h
Definition: single_contact.cc:469
MBSim::SingleContact::isSetValued
bool isSetValued() const override
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: single_contact.cc:465
MBSim::SingleContact::solveImpactsGaussSeidel
void solveImpactsGaussSeidel() override
Definition: single_contact.cc:565
MBSim::SingleContact::checkConstraintsForTermination
void checkConstraintsForTermination() override
verify underlying force laws concerning given tolerances
Definition: single_contact.cc:856
MBSim::SingleContact::solveConstraintsFixpointSingle
void solveConstraintsFixpointSingle() override
Definition: single_contact.cc:536
MBSim::SingleContact::calclaSize
void calclaSize(int j) override
calculates size of contact force parameters
Definition: single_contact.cc:250
MBSim::FrictionImpactLaw
basic friction force law on velocity level for constraint description
Definition: friction_impact_law.h:32
MBSim::Element::InitStage
InitStage
The stages of the initialization.
Definition: element.h:62
MBSim::FrictionForceLaw
basic friction force law on acceleration level for constraint description
Definition: friction_force_law.h:34
MBSim::SingleContact::laN
fmatvec::Vec laN
force in normal direction
Definition: single_contact.h:194
MBSim::SingleContact::jacobianImpacts
void jacobianImpacts() override
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level
Definition: single_contact.cc:743
MBSim::SingleContact::gActiveChanged
bool gActiveChanged() override
Definition: single_contact.cc:498
MBSim::ContourLink
contour link
Definition: contour_link.h:34
MBSim::GeneralizedImpactLaw
basic force law on velocity level for constraint description
Definition: generalized_impact_law.h:32
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::SingleContact::laT
fmatvec::Vec laT
force in tangential direction
Definition: single_contact.h:201
MBSim::SingleContact::calcLinkStatusSize
void calcLinkStatusSize() override
calculates size of vector LinkStatus
Definition: single_contact.cc:406
MBSim::MaxwellContact
class for maxwell contacts
Definition: maxwell_contact.h:39
MBSim::SingleContact::solveConstraintsGaussSeidel
void solveConstraintsGaussSeidel() override
Definition: single_contact.cc:597
MBSim::SingleContact
class for contacts
Definition: single_contact.h:46
MBSim::SingleContact::isActive
bool isActive() const override
Definition: single_contact.cc:494
MBSim::SingleContact::checkImpactsForTermination
void checkImpactsForTermination() override
verify underlying force laws on velocity level concerning given tolerances
Definition: single_contact.cc:893
MBSim::SingleContact::gdActive
std::array< unsigned int, DirectionDIM > gdActive
boolean flag symbolising activity of contact on velocity level
Definition: single_contact.h:232
MBSim::SingleContact::ftil
FrictionImpactLaw * ftil
force law defining relation between tangential velocities and forces impulses
Definition: single_contact.h:187
MBSim::SingleContact::gActive
unsigned int gActive
boolean flag symbolising activity of contact on position level with possibility to save previous time...
Definition: single_contact.h:219
MBSim::SingleContact::LinearImpactEstimation
void LinearImpactEstimation(double t, fmatvec::Vec &gInActive_, fmatvec::Vec &gdInActive_, int *IndInActive_, fmatvec::Vec &gAct_, int *IndActive_) override
get gap distance and calculate gap velocity of unilateral links to estimate impacts within the next s...
Definition: single_contact.cc:1145
MBSim::SingleContact::solveConstraintsRootFinding
void solveConstraintsRootFinding() override
Definition: single_contact.cc:660
MBSim::SingleContact::SingleContact
SingleContact(const std::string &name="")
constructor
Definition: single_contact.h:56
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30
MBSim::SingleContact::updategdRef
void updategdRef(fmatvec::Vec &ref) override
references to contact relative velocities of dynamic system parent
Definition: single_contact.cc:233