mbsim  4.0.0
MBSim Kernel
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
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 setGlobalSearch(bool gS_) { gS = gS_; }
188  void setInitialGlobalSearch(bool iGS_) { iGS = iGS_; }
189  void setInitialGuess(const fmatvec::MatV &zeta0_) { zeta0 <<= zeta0_; }
190 
194  void setTolerance(double tol_) { tol = tol_; }
195 
196  virtual void initializeContourCouplings();
197 
206  void addContourCoupling(Contour *contour1, Contour *contour2, InfluenceFunction *fct);
207 
208  void setDampingCoefficient(double d) { dampingCoefficient = d; }
209 
210  void setGapLimit(double gLim_) { gLim = gLim_; }
211 
215  virtual void updatePossibleContactPoints();
216 
222  virtual void updateInfluenceMatrix();
223 
227  void updateRigidBodyGap();
228 
235  virtual double computeInfluenceCoefficient(const std::pair<int, int> & contactIndex);
236 
244  virtual double computeInfluenceCoefficient(const std::pair<int, int> & contactIndex, const std::pair<int, int> & couplingContactIndex);
245 
246  /*
247  * \brief computes the "material constant" to have a good guess for the lambda-vector
248  */
249  virtual void computeMaterialConstant();
250 
251  void updateGeneralizedPositions() override;
252  void updateGeneralizedForces() override;
253 
254  std::shared_ptr<OpenMBV::Group> getLinksOpenMBVGrp() override { return getOpenMBVGrp(); }
255  H5::GroupBase *getLinksPlotGroup() override { return getPlotGroup(); }
256 
257  protected:
261  std::vector<std::vector<SingleContact>> contacts;
262 
266  std::vector<ContactKinematics*> contactKinematics;
267 
268  std::vector<std::vector<Contour*>> contour;
269 
275  std::vector<std::string> ckNames;
276 
282  std::map<std::pair<std::string, std::size_t>, bool> plotFeatureMap;
283 
288 
293 
298 
303 
304  bool gS;
305  bool iGS;
306 
307  fmatvec::MatV zeta0;
308 
312  double tol;
313 
320  std::vector<std::pair<int, int>> possibleContactPoints;
321 
326 
330  fmatvec::SymMat C;
331 
332  /*
333  * \brief vector of rigid body distances(gaps) for the active contacts
334  */
335  fmatvec::Vec rigidBodyGap;
336 
340  std::map<std::pair<Contour*, Contour*>, InfluenceFunction*> influenceFunctions;
341 
345  fmatvec::Vec solution0;
346 
351 
355  double gLim;
356 
360  double matConst;
361 
366 
367  private:
369  std::string name1;
370  std::string name2;
371  std::string contourPairingName;
372  };
373  std::vector<saved_references> saved_ref;
374  struct xmlInfo {
375  InfluenceFunction * function;
376  std::string name1;
377  std::string name2;
378  };
379  std::vector<xmlInfo> referenceXML;
380  };
381 
382 }
383 
384 #endif
void plot() override
plots time dependent data
Definition: maxwell_contact.cc:464
basic force law on acceleration level for constraint description
Definition: generalized_force_law.h:34
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:709
std::vector< ContactKinematics * > contactKinematics
list of the single contact kinematics
Definition: maxwell_contact.h:266
std::vector< std::vector< SingleContact > > contacts
list of the single sub-contact(-points)
Definition: maxwell_contact.h:261
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:643
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:409
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:61
void connect(Contour *contour1, Contour *contour2, ContactKinematics *contactKinematics=nullptr, const std::string &name="")
Definition: maxwell_contact.cc:678
void checkImpactsForTermination() override
verify underlying force laws on velocity level concerning given tolerances
Definition: maxwell_contact.cc:657
void solveConstraintsFixpointSingle() override
Definition: maxwell_contact.cc:594
virtual void updatePossibleContactPoints()
saves all possible contacts in a vector
Definition: maxwell_contact.cc:963
void solveConstraintsRootFinding() override
Definition: maxwell_contact.cc:622
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:330
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:350
void solveImpactsFixpointSingle() override
Definition: maxwell_contact.cc:587
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:320
void checkConstraintsForTermination() override
verify underlying force laws concerning given tolerances
Definition: maxwell_contact.cc:650
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:997
void jacobianImpacts() override
computes JACOBIAN and mass action matrix of nonlinear contact equations on velocity level ...
Definition: maxwell_contact.cc:636
void solveImpactsRootFinding() override
Definition: maxwell_contact.cc:615
H5::GroupBase * getPlotGroup()
Definition: element.h:139
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:608
void addContourCoupling(Contour *contour1, Contour *contour2, InfluenceFunction *fct)
add a function that represents the coupling between two contours
Definition: maxwell_contact.cc:903
bool detectImpact() override
Definition: maxwell_contact.cc:454
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:355
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:1008
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:345
Definition: maxwell_contact.h:368
std::map< std::pair< std::string, std::size_t >, bool > plotFeatureMap
plotFeatures of sub-contacts
Definition: maxwell_contact.h:282
GeneralizedForceLaw * fcl
force laws in normal and tangential direction on acceleration and velocity level
Definition: maxwell_contact.h:287
std::vector< std::string > ckNames
names for the contact kinematics
Definition: maxwell_contact.h:275
FrictionForceLaw * fdf
force law defining relation between tangential velocities and tangential forces
Definition: maxwell_contact.h:292
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:340
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:374
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:402
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:34
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:471
void calcLinkStatusRegSize() override
calculates size of vector LinkStatusReg
Definition: maxwell_contact.cc:304
std::string name
name of element
Definition: element.h:260
double tol
tolerance for root-finding
Definition: maxwell_contact.h:312
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:664
bool isActive() const override
Definition: maxwell_contact.cc:435
bool matConstSetted
parameter to save if matConst has been computed already
Definition: maxwell_contact.h:365
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:601
GeneralizedImpactLaw * fnil
force law defining relation between penetration velocity and resulting normal impulses ...
Definition: maxwell_contact.h:297
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:444
void SizeLinearImpactEstimation(int *sizeInActive_, int *sizeActive_) override
calculates the number of active and inactive unilateral constraints and increments sizeActive/sizeInA...
Definition: maxwell_contact.cc:716
LinearComplementarityProblem LCP
variable for the LCP
Definition: maxwell_contact.h:325
class for contacts
Definition: single_contact.h:46
FrictionImpactLaw * ftil
force law defining relation between tangential velocities and forces impulses
Definition: maxwell_contact.h:302
basic class for contact kinematical calculations
Definition: contact_kinematics.h:41
virtual int getFrictionDirections()
Definition: maxwell_contact.cc:671
virtual void updateInfluenceMatrix()
updates the influence matrix C
Definition: maxwell_contact.cc:974
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:629
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:194
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:360
void calclaSize(int j) override
calculates size of contact force parameters
Definition: maxwell_contact.cc:243