mbsim  4.0.0
MBSim Kernel
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 _CONTACT_H_
21#define _CONTACT_H_
22
23#include <mbsim/links/single_contact.h>
24#include <map>
25
26namespace MBSim {
27
28 class ContactKinematics;
29 class GeneralizedForceLaw;
30 class GeneralizedImpactLaw;
31 class FrictionForceLaw;
32 class FrictionImpactLaw;
33
48 class Contact : public Link {
49 public:
54 Contact(const std::string &name = "") : Link(name) { }
55
59 ~Contact() override;
60
61 /* INHERITED INTERFACE OF LINKINTERFACE */
62 void updatewb() override;
63 void updateW(int i = 0) override;
64 void updateV(int i = 0) override;
65 void updateh(int i = 0) override;
66 void updateg() override;
67 void updategd() override;
68 void updateStopVector() override;
69 void updateStopVectorParameters() override;
70 void updateJacobians(int j = 0) override;
71 /***************************************************/
72
73 /* INHERITED INTERFACE OF LINK */
74 void updateWRef(fmatvec::Mat &ref, int j = 0) override;
75 void updateVRef(fmatvec::Mat &ref, int j = 0) override;
76 void updatehRef(fmatvec::Vec &hRef, int j = 0) override;
77 void updaterRef(fmatvec::Vec &hRef, int j = 0) override;
78 void updatewbRef(fmatvec::Vec &ref) override;
79 void updatelaRef(fmatvec::Vec& ref) override;
80 void updateLaRef(fmatvec::Vec& ref) override;
81 void updateInternalStateRef(fmatvec::Vec& cur, fmatvec::Vec& next) override;
82 void updategRef(fmatvec::Vec& ref) override;
83 void updategdRef(fmatvec::Vec& ref) override;
84 void updateresRef(fmatvec::Vec& ref) override;
85 void updaterFactorRef(fmatvec::Vec &ref) override;
86 void updatesvRef(fmatvec::Vec &ref) override;
87 void updatejsvRef(fmatvec::VecInt &ref) override;
88 void updateLinkStatusRef(fmatvec::VecInt &LinkStatusParent) override;
89 void updateLinkStatusRegRef(fmatvec::VecInt &LinkStatusRegParent) override;
90 void calclaSize(int j) override;
91 void calcisSize() override;
92 void calcgSize(int j) override;
93 void calcgdSize(int j) override;
94 void calcrFactorSize(int j) override;
95 void calcsvSize() override;
96 void calcLinkStatusSize() override;
97 void calcLinkStatusRegSize() override;
98 void init(InitStage stage, const InitConfigSet &config) override;
99 bool isSetValued() const override;
100 bool isSingleValued() const override;
101 void updateLinkStatus() override;
102 void updateLinkStatusReg() override;
103 bool isActive() const override;
104 bool gActiveChanged() override;
105 bool detectImpact() override;
106 void solveImpactsFixpointSingle() override;
107 void solveConstraintsFixpointSingle() override;
108 void solveImpactsGaussSeidel() override;
109 void solveConstraintsGaussSeidel() override;
110 void solveImpactsRootFinding() override;
111 void solveConstraintsRootFinding() override;
112 void jacobianConstraints() override;
113 void jacobianImpacts() override;
114 void updaterFactors() override;
115 void checkConstraintsForTermination() override;
116 void checkImpactsForTermination() override;
117 void checkActive(int j) override;
118 void setGeneralizedForceTolerance(double tol) override;
119 void setGeneralizedImpulseTolerance(double tol) override;
120 void setGeneralizedRelativePositionTolerance(double tol) override;
121 void setGeneralizedRelativeVelocityTolerance(double tol) override;
122 void setGeneralizedRelativeAccelerationTolerance(double tol) override;
123 void setGeneralizedRelativePositionCorrectionValue(double corr) override;
124 void setGeneralizedRelativeVelocityCorrectionValue(double corr) override;
125 void setrMax(double rMax_) override;
126 void setLinkStatusInd(int LinkStatusInd_) override;
127 void setLinkStatusRegInd(int LinkStatusRegInd_) override;
128 void setsvInd(int svInd_) override;
129 void setlaInd(int laInd_) override;
130 void setgInd(int gInd_) override;
131 void setgdInd(int gdInd_) override;
132 void setrFactorInd(int rFactorInd_) override;
133 void LinearImpactEstimation(double t, fmatvec::Vec &gInActive_, fmatvec::Vec &gdInActive_, int *IndInActive_, fmatvec::Vec &gAct_, int *IndActive_) override;
134 void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override;
135 void updatecorrRef(fmatvec::Vec& ref) override;
136 void updatecorr(int j) override;
137 void calccorrSize(int j) override;
138 void setcorrInd(int corrInd_) override;
139 void checkRoot() override;
140 /***************************************************/
141
142 /* INHERITED INTERFACE OF ELEMENT */
143 void plot() override;
145 /***************************************************/
146
147 void resetUpToDate() override;
148
149 /* GETTER / SETTER */
150
151 void setNormalForceLaw(GeneralizedForceLaw *fcl_);
152 GeneralizedForceLaw * getNormalForceLaw() const { return fcl; }
153 void setNormalImpactLaw(GeneralizedImpactLaw *fnil_);
154 void setTangentialForceLaw(FrictionForceLaw *fdf_);
155 void setTangentialImpactLaw(FrictionImpactLaw *ftil_);
156 void setContactKinematics(ContactKinematics* ck) { contactKinematics = ck; }
157 ContactKinematics* getContactKinematics() const { return contactKinematics; }
158
159 const std::vector<SingleContact>& getSubcontacts() const { return contacts; }
160 /***************************************************/
161
165 virtual int getFrictionDirections();
166
174 void connect(Contour *contour1, Contour* contour2);
175
176 Contour* getContour(int i) { return contour[i]; }
177
178 SingleContact& getSingleContact(int i) { return contacts[i]; }
179
180 void initializeUsingXML(xercesc::DOMElement *element) override;
181
182 void setGlobalSearch(bool gS_) { gS = gS_; }
183 void setInitialGlobalSearch(bool iGS_) { iGS = iGS_; }
184 void setInitialGuess(const fmatvec::MatV &zeta0_) { zeta0 <<= zeta0_; }
185
189 void setTolerance(double tol_) { tol = tol_; }
190
194 void setMaximumNumberOfContacts(int maxNumContacts_) { maxNumContacts = maxNumContacts_; }
195
196 void updateGeneralizedPositions() override;
197
198 std::shared_ptr<OpenMBV::Group> getLinksOpenMBVGrp() override { return getOpenMBVGrp(); }
199 H5::GroupBase *getLinksPlotGroup() override { return getPlotGroup(); }
200
201 protected:
205 std::vector<SingleContact> contacts;
206
211
212 std::vector<Contour*> contour{2};
213
219 std::map<std::pair<std::string, std::size_t>, bool> plotFeatureMap;
220
225
230
235
240
241 bool gS{false};
242 bool iGS{false};
243
244 fmatvec::MatV zeta0;
245
249 double tol{1e-10};
250
255
256 private:
257 std::string saved_ref1, saved_ref2;
258 };
259
260}
261
262#endif /* _CONTACT_H_ */
basic class for contact kinematical calculations
Definition: contact_kinematics.h:41
class for contacts
Definition: contact.h:48
void updateWRef(fmatvec::Mat &ref, int j=0) override
references to contact force direction matrix of dynamic system parent
Definition: contact.cc:96
void solveImpactsGaussSeidel() override
Definition: contact.cc:508
void checkConstraintsForTermination() override
verify underlying force laws concerning given tolerances
Definition: contact.cc:543
void calcLinkStatusSize() override
calculates size of vector LinkStatus
Definition: contact.cc:237
void updategdRef(fmatvec::Vec &ref) override
references to contact relative velocities of dynamic system parent
Definition: contact.cc:146
void calclaSize(int j) override
calculates size of contact force parameters
Definition: contact.cc:188
void updatesvRef(fmatvec::Vec &ref) override
references to stopvector of dynamic system parent (root function for event driven integration)
Definition: contact.cc:164
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: contact.cc:116
void updaterFactorRef(fmatvec::Vec &ref) override
references to rfactors of dynamic system parent
Definition: contact.cc:158
void calcsvSize() override
calculates size of stopvector (root function for event driven integration)
Definition: contact.cc:229
void updategRef(fmatvec::Vec &ref) override
references to contact relative distances of dynamic system parent
Definition: contact.cc:140
bool detectImpact() override
Definition: contact.cc:393
void solveConstraintsFixpointSingle() override
Definition: contact.cc:503
std::vector< SingleContact > contacts
list of the single sub-contact(-points)
Definition: contact.h:205
void updateresRef(fmatvec::Vec &ref) override
references to residuum of nonlinear contact equations of dynamic system parent
Definition: contact.cc:152
void solveConstraintsRootFinding() override
Definition: contact.cc:523
void updatehRef(fmatvec::Vec &hRef, int j=0) override
references to complete and link smooth force vector of dynamic system parent
Definition: contact.cc:106
FrictionImpactLaw * ftil
force law defining relation between tangential velocities and forces impulses
Definition: contact.h:239
virtual int getFrictionDirections()
Definition: contact.cc:558
void updatelaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: contact.cc:122
void plot() override
plots time dependent data
Definition: contact.cc:402
~Contact() override
destructor
Definition: contact.cc:39
GeneralizedForceLaw * fcl
force laws in normal and tangential direction on acceleration and velocity level
Definition: contact.h:224
double tol
tolerance for root-finding
Definition: contact.h:249
void solveImpactsFixpointSingle() override
Definition: contact.cc:498
void solveConstraintsGaussSeidel() override
Definition: contact.cc:513
void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override
calculates the number of active and inactive unilateral constraints and increments sizeActive/sizeInA...
Definition: contact.cc:575
void updateLinkStatusRegRef(fmatvec::VecInt &LinkStatusRegParent) override
reference to vector of link status (for single-valued links)
Definition: contact.cc:182
void solveImpactsRootFinding() override
Definition: contact.cc:518
void setTolerance(double tol_)
set tolerance for root-finding
Definition: contact.h:189
void calcgdSize(int j) override
calculates size of gap velocities
Definition: contact.cc:213
void checkImpactsForTermination() override
verify underlying force laws on velocity level concerning given tolerances
Definition: contact.cc:548
GeneralizedImpactLaw * fnil
force law defining relation between penetration velocity and resulting normal impulses
Definition: contact.h:234
void updaterFactors() override
update relaxation factors for contact equations
Definition: contact.cc:538
ContactKinematics * contactKinematics
contact kinematics
Definition: contact.h:210
void jacobianConstraints() override
computes JACOBIAN and mass action matrix of nonlinear contact equations
Definition: contact.cc:528
int maxNumContacts
maximum number of contacts
Definition: contact.h:254
void jacobianImpacts() override
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level
Definition: contact.cc:533
void calcgSize(int j) override
calculates size of relative distances
Definition: contact.cc:205
void updateInternalStateRef(fmatvec::Vec &cur, fmatvec::Vec &next) override
references to internal state of dynamic system parent
Definition: contact.cc:134
bool isSetValued() const override
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: contact.cc:358
void calcLinkStatusRegSize() override
calculates size of vector LinkStatusReg
Definition: contact.cc:246
bool isActive() const override
Definition: contact.cc:376
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: contact.cc:407
Contact(const std::string &name="")
constructor
Definition: contact.h:54
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: contact.cc:255
FrictionForceLaw * fdf
force law defining relation between tangential velocities and tangential forces
Definition: contact.h:229
void setMaximumNumberOfContacts(int maxNumContacts_)
set maximum number of contacts
Definition: contact.h:194
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: contact.cc:570
void updateLinkStatusRef(fmatvec::VecInt &LinkStatusParent) override
reference to vector of link status (for set valued links with piecewise link equations)
Definition: contact.cc:176
void calcrFactorSize(int j) override
calculates size of rfactors
Definition: contact.cc:221
void updaterRef(fmatvec::Vec &hRef, int j=0) override
references to nonsmooth force vector of dynamic system parent
Definition: contact.cc:111
void updatejsvRef(fmatvec::VecInt &ref) override
references to stopvector evaluation of dynamic system parent (root detection with corresponding bool ...
Definition: contact.cc:170
void connect(Contour *contour1, Contour *contour2)
Definition: contact.cc:565
std::map< std::pair< std::string, std::size_t >, bool > plotFeatureMap
plotFeatures of sub-contacts
Definition: contact.h:219
bool isSingleValued() const override
asks the link if it contains single valued force laws that contribute to the right-hand side vector h
Definition: contact.cc:362
bool gActiveChanged() override
Definition: contact.cc:384
void updateVRef(fmatvec::Mat &ref, int j=0) override
references to condensed contact force direction matrix of dynamic system parent
Definition: contact.cc:101
void checkActive(int j) override
check if set-valued contacts are active and set corresponding attributes
Definition: contact.cc:553
void updateLaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: contact.cc:128
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
InitStage
The stages of the initialization.
Definition: element.h:62
H5::GroupBase * getPlotGroup()
Definition: element.h:139
std::string name
name of element
Definition: element.h:260
basic friction force law on acceleration level for constraint description
Definition: friction_force_law.h:34
basic friction force law on velocity level for constraint description
Definition: friction_impact_law.h:32
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:34
basic force law on velocity level for constraint description
Definition: generalized_impact_law.h:32
namespace MBSim
Definition: bilateral_constraint.cc:30