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
26 namespace 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;
144 void setDynamicSystemSolver(DynamicSystemSolver *sys) 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
210 ContactKinematics* contactKinematics{nullptr};
211
212 std::vector<Contour*> contour{2};
213
219 std::map<std::pair<std::string, std::size_t>, bool> plotFeatureMap;
220
224 GeneralizedForceLaw *fcl{nullptr};
225
229 FrictionForceLaw *fdf{nullptr};
230
234 GeneralizedImpactLaw *fnil{nullptr};
235
239 FrictionImpactLaw *ftil{nullptr};
240
241 bool gS{false};
242 bool iGS{false};
243
244 fmatvec::MatV zeta0;
245
249 double tol{1e-10};
250
254 int maxNumContacts{-1};
255
256 private:
257 std::string saved_ref1, saved_ref2;
258 };
259
260 }
261
262 #endif /* _CONTACT_H_ */
MBSim::GeneralizedForceLaw
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:34
MBSim::Contact::solveConstraintsFixpointSingle
void solveConstraintsFixpointSingle() override
Definition: contact.cc:503
MBSim::Contact::isSetValued
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
MBSim::Contact::updaterFactors
void updaterFactors() override
update relaxation factors for contact equations
Definition: contact.cc:538
MBSim::Contact::calcsvSize
void calcsvSize() override
calculates size of stopvector (root function for event driven integration)
Definition: contact.cc:229
MBSim::Contact
class for contacts
Definition: contact.h:48
MBSim::Link
general link to one or more objects
Definition: link.h:48
MBSim::Contact::detectImpact
bool detectImpact() override
Definition: contact.cc:393
MBSim::Contact::updatelaRef
void updatelaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: contact.cc:122
MBSim::DynamicSystemSolver
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:61
MBSim::Contact::updateWRef
void updateWRef(fmatvec::Mat &ref, int j=0) override
references to contact force direction matrix of dynamic system parent
Definition: contact.cc:96
MBSim::Contact::setMaximumNumberOfContacts
void setMaximumNumberOfContacts(int maxNumContacts_)
set maximum number of contacts
Definition: contact.h:194
MBSim::Contact::calcrFactorSize
void calcrFactorSize(int j) override
calculates size of rfactors
Definition: contact.cc:221
MBSim::Contact::SizeLinearImpactEstimation
void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override
calculates the number of active and inactive unilateral constraints and increments sizeActive/sizeInA...
Definition: contact.cc:575
MBSim::Contact::solveImpactsFixpointSingle
void solveImpactsFixpointSingle() override
Definition: contact.cc:498
MBSim::Contact::solveConstraintsRootFinding
void solveConstraintsRootFinding() override
Definition: contact.cc:523
MBSim::Contact::contacts
std::vector< SingleContact > contacts
list of the single sub-contact(-points)
Definition: contact.h:205
MBSim::Contact::updateLinkStatusRegRef
void updateLinkStatusRegRef(fmatvec::VecInt &LinkStatusRegParent) override
reference to vector of link status (for single-valued links)
Definition: contact.cc:182
MBSim::Contact::updateresRef
void updateresRef(fmatvec::Vec &ref) override
references to residuum of nonlinear contact equations of dynamic system parent
Definition: contact.cc:152
MBSim::Contact::solveImpactsRootFinding
void solveImpactsRootFinding() override
Definition: contact.cc:518
MBSim::Contact::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: contact.cc:570
MBSim::Contact::updateLinkStatusRef
void updateLinkStatusRef(fmatvec::VecInt &LinkStatusParent) override
reference to vector of link status (for set valued links with piecewise link equations)
Definition: contact.cc:176
MBSim::Contact::fdf
FrictionForceLaw * fdf
force law defining relation between tangential velocities and tangential forces
Definition: contact.h:229
MBSim::Element::getPlotGroup
H5::GroupBase * getPlotGroup()
Definition: element.h:139
H5::GroupBase
MBSim::Contact::maxNumContacts
int maxNumContacts
maximum number of contacts
Definition: contact.h:254
MBSim::Contact::setTolerance
void setTolerance(double tol_)
set tolerance for root-finding
Definition: contact.h:189
MBSim::Contact::updaterFactorRef
void updaterFactorRef(fmatvec::Vec &ref) override
references to rfactors of dynamic system parent
Definition: contact.cc:158
MBSim::Contact::updatewbRef
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: contact.cc:116
MBSim::Contact::solveImpactsGaussSeidel
void solveImpactsGaussSeidel() override
Definition: contact.cc:508
MBSim::Contact::jacobianConstraints
void jacobianConstraints() override
computes JACOBIAN and mass action matrix of nonlinear contact equations
Definition: contact.cc:528
MBSim::Contact::updateVRef
void updateVRef(fmatvec::Mat &ref, int j=0) override
references to condensed contact force direction matrix of dynamic system parent
Definition: contact.cc:101
MBSim::Contact::updaterRef
void updaterRef(fmatvec::Vec &hRef, int j=0) override
references to nonsmooth force vector of dynamic system parent
Definition: contact.cc:111
MBSim::Contact::setDynamicSystemSolver
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: contact.cc:407
MBSim::Contact::connect
void connect(Contour *contour1, Contour *contour2)
Definition: contact.cc:565
MBSim::FrictionImpactLaw
basic friction force law on velocity level for constraint description
Definition: friction_impact_law.h:32
MBSim::Contact::updategRef
void updategRef(fmatvec::Vec &ref) override
references to contact relative distances of dynamic system parent
Definition: contact.cc:140
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::GeneralizedImpactLaw
basic force law on velocity level for constraint description
Definition: generalized_impact_law.h:32
MBSim::Contact::plot
void plot() override
plots time dependent data
Definition: contact.cc:402
MBSim::Contact::isActive
bool isActive() const override
Definition: contact.cc:376
MBSim::Contact::updatesvRef
void updatesvRef(fmatvec::Vec &ref) override
references to stopvector of dynamic system parent (root function for event driven integration)
Definition: contact.cc:164
MBSim::Contact::fnil
GeneralizedImpactLaw * fnil
force law defining relation between penetration velocity and resulting normal impulses
Definition: contact.h:234
MBSim::Contact::~Contact
~Contact() override
destructor
Definition: contact.cc:39
MBSim::Contact::gActiveChanged
bool gActiveChanged() override
Definition: contact.cc:384
MBSim::Element::name
std::string name
name of element
Definition: element.h:260
MBSim::Contact::init
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: contact.cc:255
MBSim::Contact::calcgdSize
void calcgdSize(int j) override
calculates size of gap velocities
Definition: contact.cc:213
MBSim::Contact::updateLaRef
void updateLaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: contact.cc:128
MBSim::Contact::plotFeatureMap
std::map< std::pair< std::string, std::size_t >, bool > plotFeatureMap
plotFeatures of sub-contacts
Definition: contact.h:219
MBSim::Contact::calcLinkStatusRegSize
void calcLinkStatusRegSize() override
calculates size of vector LinkStatusReg
Definition: contact.cc:246
MBSim::Contact::tol
double tol
tolerance for root-finding
Definition: contact.h:249
MBSim::Contact::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: contact.cc:362
MBSim::Contact::jacobianImpacts
void jacobianImpacts() override
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level
Definition: contact.cc:533
MBSim::Contact::updateInternalStateRef
void updateInternalStateRef(fmatvec::Vec &cur, fmatvec::Vec &next) override
references to internal state of dynamic system parent
Definition: contact.cc:134
MBSim::Contact::updatehRef
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
MBSim::Contact::solveConstraintsGaussSeidel
void solveConstraintsGaussSeidel() override
Definition: contact.cc:513
MBSim::Contact::contactKinematics
ContactKinematics * contactKinematics
contact kinematics
Definition: contact.h:210
MBSim::Contact::calcgSize
void calcgSize(int j) override
calculates size of relative distances
Definition: contact.cc:205
MBSim::Contact::checkConstraintsForTermination
void checkConstraintsForTermination() override
verify underlying force laws concerning given tolerances
Definition: contact.cc:543
MBSim::Contact::checkImpactsForTermination
void checkImpactsForTermination() override
verify underlying force laws on velocity level concerning given tolerances
Definition: contact.cc:548
MBSim::ContactKinematics
basic class for contact kinematical calculations
Definition: contact_kinematics.h:41
MBSim::Contact::calclaSize
void calclaSize(int j) override
calculates size of contact force parameters
Definition: contact.cc:188
MBSim::Contact::calcLinkStatusSize
void calcLinkStatusSize() override
calculates size of vector LinkStatus
Definition: contact.cc:237
MBSim::Contact::updatejsvRef
void updatejsvRef(fmatvec::VecInt &ref) override
references to stopvector evaluation of dynamic system parent (root detection with corresponding bool ...
Definition: contact.cc:170
MBSim::Contact::ftil
FrictionImpactLaw * ftil
force law defining relation between tangential velocities and forces impulses
Definition: contact.h:239
MBSim::Contact::checkActive
void checkActive(int j) override
check if set-valued contacts are active and set corresponding attributes
Definition: contact.cc:553
MBSim::Contact::updategdRef
void updategdRef(fmatvec::Vec &ref) override
references to contact relative velocities of dynamic system parent
Definition: contact.cc:146
MBSim::Contact::fcl
GeneralizedForceLaw * fcl
force laws in normal and tangential direction on acceleration and velocity level
Definition: contact.h:224
MBSim::Contact::getFrictionDirections
virtual int getFrictionDirections()
Definition: contact.cc:558
MBSim::Contact::Contact
Contact(const std::string &name="")
constructor
Definition: contact.h:54
MBSim
namespace MBSim
Definition: bilateral_constraint.cc:30