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 updategRef(fmatvec::Vec& ref) override;
82  void updategdRef(fmatvec::Vec& ref) override;
83  void updateresRef(fmatvec::Vec& ref) override;
84  void updaterFactorRef(fmatvec::Vec &ref) override;
85  void updatesvRef(fmatvec::Vec &ref) override;
86  void updatejsvRef(fmatvec::VecInt &ref) override;
87  void updateLinkStatusRef(fmatvec::VecInt &LinkStatusParent) override;
88  void updateLinkStatusRegRef(fmatvec::VecInt &LinkStatusRegParent) override;
89  void calclaSize(int j) override;
90  void calcgSize(int j) override;
91  void calcgdSize(int j) override;
92  void calcrFactorSize(int j) override;
93  void calcsvSize() override;
94  void calcLinkStatusSize() override;
95  void calcLinkStatusRegSize() override;
96  void init(InitStage stage, const InitConfigSet &config) override;
97  bool isSetValued() const override;
98  bool isSingleValued() const override;
99  void updateLinkStatus() override;
100  void updateLinkStatusReg() override;
101  bool isActive() const override;
102  bool gActiveChanged() override;
103  bool detectImpact() override;
104  void solveImpactsFixpointSingle() override;
105  void solveConstraintsFixpointSingle() override;
106  void solveImpactsGaussSeidel() override;
107  void solveConstraintsGaussSeidel() override;
108  void solveImpactsRootFinding() override;
109  void solveConstraintsRootFinding() override;
110  void jacobianConstraints() override;
111  void jacobianImpacts() override;
112  void updaterFactors() override;
113  void checkConstraintsForTermination() override;
114  void checkImpactsForTermination() override;
115  void checkActive(int j) override;
116  void setGeneralizedForceTolerance(double tol) override;
117  void setGeneralizedImpulseTolerance(double tol) override;
118  void setGeneralizedRelativePositionTolerance(double tol) override;
119  void setGeneralizedRelativeVelocityTolerance(double tol) override;
120  void setGeneralizedRelativeAccelerationTolerance(double tol) override;
121  void setGeneralizedRelativePositionCorrectionValue(double corr) override;
122  void setGeneralizedRelativeVelocityCorrectionValue(double corr) override;
123  void setrMax(double rMax_) override;
124  void setLinkStatusInd(int LinkStatusInd_) override;
125  void setLinkStatusRegInd(int LinkStatusRegInd_) override;
126  void setsvInd(int svInd_) override;
127  void setlaInd(int laInd_) override;
128  void setgInd(int gInd_) override;
129  void setgdInd(int gdInd_) override;
130  void setrFactorInd(int rFactorInd_) override;
131  void LinearImpactEstimation(double t, fmatvec::Vec &gInActive_, fmatvec::Vec &gdInActive_, int *IndInActive_, fmatvec::Vec &gAct_, int *IndActive_) override;
132  void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override;
133  void updatecorrRef(fmatvec::Vec& ref) override;
134  void updatecorr(int j) override;
135  void calccorrSize(int j) override;
136  void setcorrInd(int corrInd_) override;
137  void checkRoot() override;
138  /***************************************************/
139 
140  /* INHERITED INTERFACE OF ELEMENT */
141  void plot() override;
142  void setDynamicSystemSolver(DynamicSystemSolver *sys) override;
143  /***************************************************/
144 
145  void resetUpToDate() override;
146 
147  /* GETTER / SETTER */
148 
149  void setNormalForceLaw(GeneralizedForceLaw *fcl_);
150  GeneralizedForceLaw * getNormalForceLaw() const { return fcl; }
151  void setNormalImpactLaw(GeneralizedImpactLaw *fnil_);
152  void setTangentialForceLaw(FrictionForceLaw *fdf_);
153  void setTangentialImpactLaw(FrictionImpactLaw *ftil_);
154  void setContactKinematics(ContactKinematics* ck) { contactKinematics = ck; }
155  ContactKinematics* getContactKinematics() const { return contactKinematics; }
156 
157  const std::vector<SingleContact>& getSubcontacts() const { return contacts; }
158  /***************************************************/
159 
163  virtual int getFrictionDirections();
164 
172  void connect(Contour *contour1, Contour* contour2);
173 
174  Contour* getContour(int i) { return contour[i]; }
175 
176  SingleContact& getSingleContact(int i) { return contacts[i]; }
177 
178  void initializeUsingXML(xercesc::DOMElement *element) override;
179 
180  void setSearchAllContactPoints(bool searchAllCP_) { searchAllCP = searchAllCP_; }
181  void setInitialGuess(const fmatvec::MatV &zeta0_) { zeta0 <<= zeta0_; }
182 
186  void setTolerance(double tol_) { tol = tol_; }
187 
191  void setMaximumNumberOfContacts(int maxNumContacts_) { maxNumContacts = maxNumContacts_; }
192 
193  void updateGeneralizedPositions() override;
194 
195  protected:
199  std::vector<SingleContact> contacts;
200 
205 
206  std::vector<Contour*> contour{2};
207 
213  std::map<std::pair<std::string, std::size_t>, bool> plotFeatureMap;
214 
219 
224 
229 
234 
235  bool searchAllCP{false};
236 
237  fmatvec::MatV zeta0;
238 
242  double tol{1e-10};
243 
247  int maxNumContacts{-1};
248 
249  private:
250  std::string saved_ref1, saved_ref2;
251  };
252 
253 }
254 
255 #endif /* _CONTACT_H_ */
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:32
void solveConstraintsFixpointSingle() override
Definition: contact.cc:471
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:326
void updaterFactors() override
update relaxation factors for contact equations
Definition: contact.cc:506
void calcsvSize() override
calculates size of stopvector (root function for event driven integration)
Definition: contact.cc:214
class for contacts
Definition: contact.h:48
bool detectImpact() override
Definition: contact.cc:361
void updatelaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: contact.cc:122
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:56
void updateWRef(fmatvec::Mat &ref, int j=0) override
references to contact force direction matrix of dynamic system parent
Definition: contact.cc:96
void setMaximumNumberOfContacts(int maxNumContacts_)
set maximum number of contacts
Definition: contact.h:191
void calcrFactorSize(int j) override
calculates size of rfactors
Definition: contact.cc:206
void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override
calculates the number of active and inactive unilateral constraints and increments sizeActive/sizeInA...
Definition: contact.cc:543
void solveImpactsFixpointSingle() override
Definition: contact.cc:466
void solveConstraintsRootFinding() override
Definition: contact.cc:491
std::vector< SingleContact > contacts
list of the single sub-contact(-points)
Definition: contact.h:199
void updateLinkStatusRegRef(fmatvec::VecInt &LinkStatusRegParent) override
reference to vector of link status (for single-valued links)
Definition: contact.cc:176
void updateresRef(fmatvec::Vec &ref) override
references to residuum of nonlinear contact equations of dynamic system parent
Definition: contact.cc:146
void solveImpactsRootFinding() override
Definition: contact.cc:486
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:538
void updateLinkStatusRef(fmatvec::VecInt &LinkStatusParent) override
reference to vector of link status (for set valued links with piecewise link equations)
Definition: contact.cc:170
FrictionForceLaw * fdf
force law defining relation between tangential velocities and tangential forces
Definition: contact.h:223
int maxNumContacts
maximum number of contacts
Definition: contact.h:247
void setTolerance(double tol_)
set tolerance for root-finding
Definition: contact.h:186
void updaterFactorRef(fmatvec::Vec &ref) override
references to rfactors of dynamic system parent
Definition: contact.cc:152
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: contact.cc:116
void solveImpactsGaussSeidel() override
Definition: contact.cc:476
void jacobianConstraints() override
computes JACOBIAN and mass action matrix of nonlinear contact equations
Definition: contact.cc:496
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 updaterRef(fmatvec::Vec &hRef, int j=0) override
references to nonsmooth force vector of dynamic system parent
Definition: contact.cc:111
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: contact.cc:375
void connect(Contour *contour1, Contour *contour2)
Definition: contact.cc:533
basic friction force law on velocity level for constraint description
Definition: friction_impact_law.h:32
void updategRef(fmatvec::Vec &ref) override
references to contact relative distances of dynamic system parent
Definition: contact.cc:134
InitStage
The stages of the initialization.
Definition: element.h:62
basic friction force law on acceleration level for constraint description
Definition: friction_force_law.h:32
basic force law on velocity level for constraint description
Definition: generalized_impact_law.h:32
void plot() override
plots time dependent data
Definition: contact.cc:370
bool isActive() const override
Definition: contact.cc:344
void updatesvRef(fmatvec::Vec &ref) override
references to stopvector of dynamic system parent (root function for event driven integration)
Definition: contact.cc:158
GeneralizedImpactLaw * fnil
force law defining relation between penetration velocity and resulting normal impulses
Definition: contact.h:228
~Contact() override
destructor
Definition: contact.cc:39
bool gActiveChanged() override
Definition: contact.cc:352
std::string name
name of element
Definition: element.h:235
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: contact.cc:240
void calcgdSize(int j) override
calculates size of gap velocities
Definition: contact.cc:198
void updateLaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: contact.cc:128
std::map< std::pair< std::string, std::size_t >, bool > plotFeatureMap
plotFeatures of sub-contacts
Definition: contact.h:213
void calcLinkStatusRegSize() override
calculates size of vector LinkStatusReg
Definition: contact.cc:231
double tol
tolerance for root-finding
Definition: contact.h:242
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:330
void jacobianImpacts() override
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level
Definition: contact.cc:501
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
void solveConstraintsGaussSeidel() override
Definition: contact.cc:481
ContactKinematics * contactKinematics
contact kinematics
Definition: contact.h:204
void calcgSize(int j) override
calculates size of relative distances
Definition: contact.cc:190
void checkConstraintsForTermination() override
verify underlying force laws concerning given tolerances
Definition: contact.cc:511
void checkImpactsForTermination() override
verify underlying force laws on velocity level concerning given tolerances
Definition: contact.cc:516
basic class for contact kinematical calculations
Definition: contact_kinematics.h:40
void calclaSize(int j) override
calculates size of contact force parameters
Definition: contact.cc:182
void calcLinkStatusSize() override
calculates size of vector LinkStatus
Definition: contact.cc:222
void updatejsvRef(fmatvec::VecInt &ref) override
references to stopvector evaluation of dynamic system parent (root detection with corresponding bool ...
Definition: contact.cc:164
FrictionImpactLaw * ftil
force law defining relation between tangential velocities and forces impulses
Definition: contact.h:233
void checkActive(int j) override
check if set-valued contacts are active and set corresponding attributes
Definition: contact.cc:521
void updategdRef(fmatvec::Vec &ref) override
references to contact relative velocities of dynamic system parent
Definition: contact.cc:140
GeneralizedForceLaw * fcl
force laws in normal and tangential direction on acceleration and velocity level
Definition: contact.h:218
virtual int getFrictionDirections()
Definition: contact.cc:526
Contact(const std::string &name="")
constructor
Definition: contact.h:54
namespace MBSim
Definition: eigenanalyzer.cc:47