mbsim  4.0.0
MBSim Kernel
maxwell_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 _MAXWELL_CONTACT_H_
21 #define _MAXWELL_CONTACT_H_
22 
23 #include <mbsim/links/single_contact.h>
24 #include <mbsim/numerics/linear_complementarity_problem/linear_complementarity_problem.h>
25 #include <map>
26 
27 namespace MBSim {
28 
29  class ContactKinematics;
30  class GeneralizedForceLaw;
31  class GeneralizedImpactLaw;
32  class FrictionForceLaw;
33  class FrictionImpactLaw;
34  class InfluenceFunction;
35 
39  class MaxwellContact : public Link {
40  public:
45  MaxwellContact(const std::string &name = "");
46 
50  ~MaxwellContact() override;
51 
52  /* INHERITED INTERFACE OF LINKINTERFACE */
53  void updatewb() override;
54  void updateW(int i = 0) override;
55  void updateV(int i = 0) override;
56  void updateh(int i = 0) override;
57  void updateg() override;
58  void updategd() override;
59  void updateStopVector() override;
60  void updateJacobians(int j = 0) override;
61  /***************************************************/
62 
63  /* INHERITED INTERFACE OF LINK */
64  void updateWRef(fmatvec::Mat &ref, int j = 0) override;
65  void updateVRef(fmatvec::Mat &ref, int j = 0) override;
66  void updatehRef(fmatvec::Vec &hRef, int j = 0) override;
67  void updaterRef(fmatvec::Vec &hRef, int j = 0) override;
68  void updatewbRef(fmatvec::Vec &ref) override;
69  void updatelaRef(fmatvec::Vec& ref) override;
70  void updateLaRef(fmatvec::Vec& ref) override;
71  void updategRef(fmatvec::Vec& ref) override;
72  void updategdRef(fmatvec::Vec& ref) override;
73  void updateresRef(fmatvec::Vec& ref) override;
74  void updaterFactorRef(fmatvec::Vec &ref) override;
75  void updatesvRef(fmatvec::Vec &ref) override;
76  void updatejsvRef(fmatvec::VecInt &ref) override;
77  void updateLinkStatusRef(fmatvec::VecInt &LinkStatusParent) override;
78  void updateLinkStatusRegRef(fmatvec::VecInt &LinkStatusRegParent) override;
79  void calclaSize(int j) override;
80  void calcgSize(int j) override;
81  void calcgdSize(int j) override;
82  void calcrFactorSize(int j) override;
83  void calcsvSize() override;
84  void calcLinkStatusSize() override;
85  void calcLinkStatusRegSize() override;
86  void init(InitStage stage, const InitConfigSet &config) override;
87  bool isSetValued() const override;
88  bool isSingleValued() const override;
89  void updateLinkStatus() override;
90  void updateLinkStatusReg() override;
91  bool isActive() const override;
92  bool gActiveChanged() override;
93  bool detectImpact() override;
94  void solveImpactsFixpointSingle() override;
95  void solveConstraintsFixpointSingle() override;
96  void solveImpactsGaussSeidel() override;
97  void solveConstraintsGaussSeidel() override;
98  void solveImpactsRootFinding() override;
99  void solveConstraintsRootFinding() override;
100  void jacobianConstraints() override;
101  void jacobianImpacts() override;
102  void updaterFactors() override;
103  void checkConstraintsForTermination() override;
104  void checkImpactsForTermination() override;
105  void checkActive(int j) override;
106  void setGeneralizedForceTolerance(double tol) override;
107  void setGeneralizedImpulseTolerance(double tol) override;
108  void setGeneralizedRelativePositionTolerance(double tol) override;
109  void setGeneralizedRelativeVelocityTolerance(double tol) override;
110  void setGeneralizedRelativeAccelerationTolerance(double tol) override;
111  void setrMax(double rMax_) override;
112  void setLinkStatusInd(int LinkStatusInd_) override;
113  void setLinkStatusRegInd(int LinkStatusRegInd_) override;
114  void setsvInd(int svInd_) override;
115  void setlaInd(int laInd_) override;
116  void setgInd(int gInd_) override;
117  void setgdInd(int gdInd_) override;
118  void setrFactorInd(int rFactorInd_) override;
119  void LinearImpactEstimation(double t, fmatvec::Vec &gInActive_, fmatvec::Vec &gdInActive_, int *IndInActive_, fmatvec::Vec &gAct_, int *IndActive_) override;
120  void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override;
121  void updatecorrRef(fmatvec::Vec& ref) override;
122  void updatecorr(int j) override;
123  void calccorrSize(int j) override;
124  void setcorrInd(int corrInd_) override;
125  void checkRoot() override;
126  /***************************************************/
127 
128  /* INHERITED INTERFACE OF ELEMENT */
129  void plot() override;
130  void setDynamicSystemSolver(DynamicSystemSolver *sys) override;
131  /***************************************************/
132 
133  void resetUpToDate() override;
134 
135  /* GETTER / SETTER */
136 
137  void setNormalForceLaw(GeneralizedForceLaw *fcl_);
138  GeneralizedForceLaw * getNormalForceLaw() const { return fcl; }
139  void setNormalImpactLaw(GeneralizedImpactLaw *fnil_);
140  void setTangentialForceLaw(FrictionForceLaw *fdf_);
141  void setTangentialImpactLaw(FrictionImpactLaw *ftil_);
142  void setContactKinematics(ContactKinematics* ck, size_t index = 0) {
143  assert(index < contactKinematics.size());
144  contactKinematics[index] = ck;
145  }
146  ContactKinematics* getContactKinematics(size_t index = 0) const {
147  assert(index < contactKinematics.size());
148  return contactKinematics[index];
149  }
150 
151  ContactKinematics* findContactKinematics(const std::string& cKName) const {
152  int pos = find(ckNames.begin(), ckNames.end(), cKName) - ckNames.begin();
153  if (pos < static_cast<int>(ckNames.size())) {
154  return contactKinematics[pos];
155  }
156  throwError("Name of contact Kinematics is not valid");
157  return nullptr;
158  }
159 
160  const std::vector<std::vector<SingleContact>> & getSubcontacts() const {
161  return contacts;
162  }
163 
164  virtual void setPlotFeatureContactKinematics(std::string cKName, std::size_t pf, bool value);
165  /***************************************************/
166 
170  virtual int getFrictionDirections();
171 
179  void connect(Contour *contour1, Contour* contour2, ContactKinematics* contactKinematics = nullptr, const std::string & name = "");
180 
181  Contour* getContour(int i, int j=0) { return contour[i][j]; }
182 
183  SingleContact& getSingleContact(int i, int j=0) { return contacts[i][j]; }
184 
185  void initializeUsingXML(xercesc::DOMElement *element) override;
186 
187  void setSearchAllContactPoints(bool searchAllCP_) { searchAllCP = searchAllCP_; }
188  void setInitialGuess(const fmatvec::MatV &zeta0_) { zeta0 <<= zeta0_; }
189 
193  void setTolerance(double tol_) { tol = tol_; }
194 
195  virtual void initializeContourCouplings();
196 
205  void addContourCoupling(Contour *contour1, Contour *contour2, InfluenceFunction *fct);
206 
207  void setDampingCoefficient(double d) { dampingCoefficient = d; }
208 
209  void setGapLimit(double gLim_) { gLim = gLim_; }
210 
214  virtual void updatePossibleContactPoints();
215 
221  virtual void updateInfluenceMatrix();
222 
226  void updateRigidBodyGap();
227 
234  virtual double computeInfluenceCoefficient(const std::pair<int, int> & contactIndex);
235 
243  virtual double computeInfluenceCoefficient(const std::pair<int, int> & contactIndex, const std::pair<int, int> & couplingContactIndex);
244 
245  /*
246  * \brief computes the "material constant" to have a good guess for the lambda-vector
247  */
248  virtual void computeMaterialConstant();
249 
250  void updateGeneralizedPositions() override;
251  void updateGeneralizedForces() override;
252 
253  protected:
257  std::vector<std::vector<SingleContact>> contacts;
258 
262  std::vector<ContactKinematics*> contactKinematics;
263 
264  std::vector<std::vector<Contour*>> contour;
265 
271  std::vector<std::string> ckNames;
272 
278  std::map<std::pair<std::string, std::size_t>, bool> plotFeatureMap;
279 
284 
289 
294 
299 
300  bool searchAllCP;
301 
302  fmatvec::MatV zeta0;
303 
307  double tol;
308 
315  std::vector<std::pair<int, int>> possibleContactPoints;
316 
321 
326 
327  /*
328  * \brief vector of rigid body distances(gaps) for the active contacts
329  */
330  fmatvec::Vec rigidBodyGap;
331 
335  std::map<std::pair<Contour*, Contour*>, InfluenceFunction*> influenceFunctions;
336 
341 
346 
350  double gLim;
351 
355  double matConst;
356 
361 
362  private:
364  std::string name1;
365  std::string name2;
366  std::string contourPairingName;
367  };
368  std::vector<saved_references> saved_ref;
369  struct xmlInfo {
370  InfluenceFunction * function;
371  std::string name1;
372  std::string name2;
373  };
374  std::vector<xmlInfo> referenceXML;
375  };
376 
377 }
378 
379 #endif
void plot() override
plots time dependent data
Definition: maxwell_contact.cc:463
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:32
void updatehRef(fmatvec::Vec &hRef, int j=0) override
references to complete and link smooth force vector of dynamic system parent
Definition: maxwell_contact.cc:140
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: maxwell_contact.cc:708
std::vector< ContactKinematics * > contactKinematics
list of the single contact kinematics
Definition: maxwell_contact.h:262
std::vector< std::vector< SingleContact > > contacts
list of the single sub-contact(-points)
Definition: maxwell_contact.h:257
void updatesvRef(fmatvec::Vec &ref) override
references to stopvector of dynamic system parent (root function for event driven integration)
Definition: maxwell_contact.cc:211
class to solve a linear complementarity problem
Definition: linear_complementarity_problem.h:38
void updaterFactors() override
update relaxation factors for contact equations
Definition: maxwell_contact.cc:642
bool isSingleValued() const override
asks the link if it contains single valued force laws that contribute to the right-hand side vector h
Definition: maxwell_contact.cc:408
void updateVRef(fmatvec::Mat &ref, int j=0) override
references to condensed contact force direction matrix of dynamic system parent
Definition: maxwell_contact.cc:133
solver interface for modelling and simulation of dynamic systems
Definition: dynamic_system_solver.h:56
void connect(Contour *contour1, Contour *contour2, ContactKinematics *contactKinematics=nullptr, const std::string &name="")
Definition: maxwell_contact.cc:677
void checkImpactsForTermination() override
verify underlying force laws on velocity level concerning given tolerances
Definition: maxwell_contact.cc:656
void solveConstraintsFixpointSingle() override
Definition: maxwell_contact.cc:593
virtual void updatePossibleContactPoints()
saves all possible contacts in a vector
Definition: maxwell_contact.cc:959
void solveConstraintsRootFinding() override
Definition: maxwell_contact.cc:621
void calcrFactorSize(int j) override
calculates size of rfactors
Definition: maxwell_contact.cc:273
fmatvec::SymMat C
Influence matrix between contact points.
Definition: maxwell_contact.h:325
basic class for contour definition for rigid (which do not know about their shape) and flexible (they...
Definition: contour.h:40
void updaterRef(fmatvec::Vec &hRef, int j=0) override
references to nonsmooth force vector of dynamic system parent
Definition: maxwell_contact.cc:147
void updatewbRef(fmatvec::Vec &ref) override
references to TODO of dynamic system parent
Definition: maxwell_contact.cc:154
double dampingCoefficient
coefficient for possible contact damping
Definition: maxwell_contact.h:345
void solveImpactsFixpointSingle() override
Definition: maxwell_contact.cc:586
void updategRef(fmatvec::Vec &ref) override
references to contact relative distances of dynamic system parent
Definition: maxwell_contact.cc:178
std::vector< std::pair< int, int > > possibleContactPoints
saves the indices of all active contacts in pairs
Definition: maxwell_contact.h:315
void checkConstraintsForTermination() override
verify underlying force laws concerning given tolerances
Definition: maxwell_contact.cc:649
void calcsvSize() override
calculates size of stopvector (root function for event driven integration)
Definition: maxwell_contact.cc:283
void updateRigidBodyGap()
update the rigid body distances (gaps) for the single contacts
Definition: maxwell_contact.cc:993
void jacobianImpacts() override
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level
Definition: maxwell_contact.cc:635
void solveImpactsRootFinding() override
Definition: maxwell_contact.cc:614
void updatelaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: maxwell_contact.cc:162
void solveConstraintsGaussSeidel() override
Definition: maxwell_contact.cc:607
void addContourCoupling(Contour *contour1, Contour *contour2, InfluenceFunction *fct)
add a function that represents the coupling between two contours
Definition: maxwell_contact.cc:899
bool detectImpact() override
Definition: maxwell_contact.cc:453
void calcLinkStatusSize() override
calculates size of vector LinkStatus
Definition: maxwell_contact.cc:293
void updateLaRef(fmatvec::Vec &ref) override
references to contact force parameter of dynamic system parent
Definition: maxwell_contact.cc:170
double gLim
relative contact point distance limit under which damping is active
Definition: maxwell_contact.h:350
virtual double computeInfluenceCoefficient(const std::pair< int, int > &contactIndex)
computes the coupling factor for the influence matrix on one contact point (two contours)
Definition: maxwell_contact.cc:1004
fmatvec::Vec solution0
Solution of the last time, where contact has to be solved (can be used as starting guess for the next...
Definition: maxwell_contact.h:340
Definition: maxwell_contact.h:363
std::map< std::pair< std::string, std::size_t >, bool > plotFeatureMap
plotFeatures of sub-contacts
Definition: maxwell_contact.h:278
GeneralizedForceLaw * fcl
force laws in normal and tangential direction on acceleration and velocity level
Definition: maxwell_contact.h:283
std::vector< std::string > ckNames
names for the contact kinematics
Definition: maxwell_contact.h:271
FrictionForceLaw * fdf
force law defining relation between tangential velocities and tangential forces
Definition: maxwell_contact.h:288
std::map< std::pair< Contour *, Contour * >, InfluenceFunction * > influenceFunctions
saves the influence functions for a pair of contours. The key is the pair of contour names
Definition: maxwell_contact.h:335
void updateLinkStatusRegRef(fmatvec::VecInt &LinkStatusRegParent) override
reference to vector of link status (for single-valued links)
Definition: maxwell_contact.cc:235
~MaxwellContact() override
destructor
Definition: maxwell_contact.cc:50
Definition: maxwell_contact.h:369
basic friction force law on velocity level for constraint description
Definition: friction_impact_law.h:32
InitStage
The stages of the initialization.
Definition: element.h:62
bool isSetValued() const override
asks the link if it contains force laws that contribute to the lagrange multiplier and is therefore s...
Definition: maxwell_contact.cc:401
void updaterFactorRef(fmatvec::Vec &ref) override
references to rfactors of dynamic system parent
Definition: maxwell_contact.cc:203
basic friction force law on acceleration level for constraint description
Definition: friction_force_law.h:32
void updategdRef(fmatvec::Vec &ref) override
references to contact relative velocities of dynamic system parent
Definition: maxwell_contact.cc:187
basic force law on velocity level for constraint description
Definition: generalized_impact_law.h:32
void setDynamicSystemSolver(DynamicSystemSolver *sys) override
sets the used dynamics system solver to the element
Definition: maxwell_contact.cc:470
void calcLinkStatusRegSize() override
calculates size of vector LinkStatusReg
Definition: maxwell_contact.cc:304
std::string name
name of element
Definition: element.h:235
double tol
tolerance for root-finding
Definition: maxwell_contact.h:307
MaxwellContact(const std::string &name="")
constructor
Definition: maxwell_contact.cc:47
void checkActive(int j) override
check if set-valued contacts are active and set corresponding attributes
Definition: maxwell_contact.cc:663
bool isActive() const override
Definition: maxwell_contact.cc:434
bool matConstSetted
parameter to save if matConst has been computed already
Definition: maxwell_contact.h:360
function describing the influence between the deformations on a body
Definition: influence_function.h:45
void init(InitStage stage, const InitConfigSet &config) override
plots time series header
Definition: maxwell_contact.cc:315
class for maxwell contacts
Definition: maxwell_contact.h:39
void solveImpactsGaussSeidel() override
Definition: maxwell_contact.cc:600
GeneralizedImpactLaw * fnil
force law defining relation between penetration velocity and resulting normal impulses
Definition: maxwell_contact.h:293
void updatejsvRef(fmatvec::VecInt &ref) override
references to stopvector evaluation of dynamic system parent (root detection with corresponding bool ...
Definition: maxwell_contact.cc:219
bool gActiveChanged() override
Definition: maxwell_contact.cc:443
void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override
calculates the number of active and inactive unilateral constraints and increments sizeActive/sizeInA...
Definition: maxwell_contact.cc:715
LinearComplementarityProblem LCP
variable for the LCP
Definition: maxwell_contact.h:320
class for contacts
Definition: single_contact.h:46
FrictionImpactLaw * ftil
force law defining relation between tangential velocities and forces impulses
Definition: maxwell_contact.h:298
basic class for contact kinematical calculations
Definition: contact_kinematics.h:40
virtual int getFrictionDirections()
Definition: maxwell_contact.cc:670
virtual void updateInfluenceMatrix()
updates the influence matrix C
Definition: maxwell_contact.cc:970
void calcgSize(int j) override
calculates size of relative distances
Definition: maxwell_contact.cc:253
void updateLinkStatusRef(fmatvec::VecInt &LinkStatusParent) override
reference to vector of link status (for set valued links with piecewise link equations)
Definition: maxwell_contact.cc:227
void jacobianConstraints() override
computes JACOBIAN and mass action matrix of nonlinear contact equations
Definition: maxwell_contact.cc:628
void calcgdSize(int j) override
calculates size of gap velocities
Definition: maxwell_contact.cc:263
void setTolerance(double tol_)
set tolerance for root-finding
Definition: maxwell_contact.h:193
void updateWRef(fmatvec::Mat &ref, int j=0) override
references to contact force direction matrix of dynamic system parent
Definition: maxwell_contact.cc:126
void updateresRef(fmatvec::Vec &ref) override
references to residuum of nonlinear contact equations of dynamic system parent
Definition: maxwell_contact.cc:195
double matConst
parameter for guessing starting values of contact force (average eigenvalue of influence-matrix)
Definition: maxwell_contact.h:355
void calclaSize(int j) override
calculates size of contact force parameters
Definition: maxwell_contact.cc:243
namespace MBSim
Definition: eigenanalyzer.cc:47