1 #ifndef SimTK_SIMBODY_CONTACT_SURFACE_H_ 2 #define SimTK_SIMBODY_CONTACT_SURFACE_H_ 38 class ContactGeometry;
137 Real staticFriction,
Real dynamicFriction,
138 Real viscousFriction = 0) {
139 setStiffness(stiffness);
140 setDissipation(dissipation);
141 setFriction(staticFriction, dynamicFriction, viscousFriction);
146 bool isValid()
const {
return m_stiffness > 0;}
150 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getStiffness()",
151 "This is an invalid ContactMaterial.");
152 return m_stiffness; }
155 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getStiffness23()",
156 "This is an invalid ContactMaterial.");
157 return m_stiffness23; }
160 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getDissipation()",
161 "This is an invalid ContactMaterial.");
162 return m_dissipation; }
165 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getStaticFriction()",
166 "This is an invalid ContactMaterial.");
167 return m_staticFriction; }
170 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getDynamicFriction()",
171 "This is an invalid ContactMaterial.");
172 return m_dynamicFriction; }
175 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getViscousFriction()",
176 "This is an invalid ContactMaterial.");
177 return m_viscousFriction; }
184 "Stiffness %g is illegal; must be >= 0.", stiffness);
185 m_stiffness = stiffness;
186 m_stiffness23 = std::pow(m_stiffness,
Real(2./3.));
195 "Dissipation %g (in 1/speed) is illegal; must be >= 0.", dissipation);
196 m_dissipation = dissipation;
202 Real dynamicFriction,
203 Real viscousFriction = 0)
206 "Illegal static friction coefficient %g.", staticFriction);
208 "ContactMaterial::setFriction()",
209 "Dynamic coefficient %g illegal; must be between 0 and static" 210 " coefficient %g.", dynamicFriction, staticFriction);
212 "Illegal viscous friction coefficient %g.", viscousFriction);
214 m_staticFriction = staticFriction;
215 m_dynamicFriction = dynamicFriction;
216 m_viscousFriction = viscousFriction;
233 -1 < poissonsRatio && poissonsRatio <= 0.5,
234 "ContactMaterial::calcStiffnessForSolid()",
235 "Illegal material properties E=%g, v=%g.",
236 youngsModulus, poissonsRatio);
238 return youngsModulus / (1-
square(poissonsRatio));
254 -1 < poissonsRatio && poissonsRatio < 0.5,
255 "ContactMaterial::calcStiffnessForSolid()",
256 "Illegal material properties E=%g, v=%g.",
257 youngsModulus, poissonsRatio);
259 return youngsModulus*(1-poissonsRatio)
260 / ((1+poissonsRatio)*(1-2*poissonsRatio));
274 static Real calcDissipationFromObservedRestitution
276 if (restitution==1)
return 0;
278 "ContactMaterial::calcDissipationFromRestitution()",
279 "Illegal coefficient of restitution or speed (%g,%g).",
281 return (1-restitution)/speed;
293 m_staticFriction=m_dynamicFriction=m_viscousFriction = 0;
308 Real m_staticFriction;
309 Real m_dynamicFriction;
310 Real m_viscousFriction;
350 : m_shape(shape), m_material(material), m_thickness(thickness),
351 m_indexOnBody(-1), m_userRef(nullptr) {
353 "Illegal thickness %g.", thickness);
358 { m_shape = shape;
return *
this; }
364 { m_material = material; setThickness(thickness);
return *
this; }
372 "Illegal thickness %g.", thickness);
373 m_thickness = thickness;
396 if (!clique.isValid())
return *
this;
400 for (p = m_cliques.
begin(); p != m_cliques.
end(); ++p) {
401 if (*p==clique)
return *
this;
402 if (*p>clique)
break;
405 m_cliques.
insert(p, clique);
412 if (!clique.isValid())
return;
415 std::find(m_cliques.begin(), m_cliques.end(), clique);
416 if (p != m_cliques.
end()) m_cliques.
erase(p);
423 {
if (getCliques().empty() || other.
getCliques().
empty())
return false;
424 return cliquesIntersect(getCliques(), other.
getCliques()); }
439 if (ap==a.
end() || bp==b.
end())
return false;
440 if (*ap > b.
back() || *bp > a.
back())
444 if (*ap==*bp)
return true;
446 if (*ap < *bp) {++ap;
if (ap==a.
end())
break;}
447 else {++bp;
if (bp==b.
end())
break;}
457 {
static std::atomic<int> nextAvailableContactClique(1);
458 return ContactCliqueId(nextAvailableContactClique++); }
517 #endif // SimTK_SIMBODY_CONTACT_SURFACE_H_ #define SimTK_ERRCHK2_ALWAYS(cond, whereChecked, fmt, a1, a2)
Definition: ExceptionMacros.h:289
bool empty() const
Return true if there are no elements currently stored in this array.
Definition: Array.h:2080
SimTK_DEFINE_UNIQUE_INDEX_TYPE(AssemblyConditionIndex)
#define SimTK_ERRCHK1_ALWAYS(cond, whereChecked, fmt, a1)
Definition: ExceptionMacros.h:285
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
const T * begin() const
The const version of begin() is the same as cbegin().
Definition: Array.h:2214
Every Simbody header and source file should include this header before any other Simbody header...
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:606
T * erase(T *first, const T *last1)
Erase elements in range [first,last1), packing in any later elements into the newly-available space a...
Definition: Array.h:2510
const Real NaN
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; ...
unsigned char square(unsigned char u)
Definition: Scalar.h:349
T * insert(T *p, size_type n, const T &value)
Insert n copies of a given value at a particular location within this array, moving all following ele...
Definition: Array.h:2632
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition: Array.h:53
#define SimTK_ERRCHK(cond, whereChecked, msg)
Definition: ExceptionMacros.h:324
const T * end() const
The const version of end() is the same as cend().
Definition: Array.h:2227
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
const T & back() const
Return a const reference to the last element in this array, which must not be empty.
Definition: Array.h:2337