1 #ifndef SimTK_SIMBODY_CONTACT_SURFACE_H_
2 #define SimTK_SIMBODY_CONTACT_SURFACE_H_
37 class ContactGeometry;
136 Real staticFriction,
Real dynamicFriction,
137 Real viscousFriction = 0) {
138 setStiffness(stiffness);
139 setDissipation(dissipation);
140 setFriction(staticFriction, dynamicFriction, viscousFriction);
145 bool isValid()
const {
return m_stiffness > 0;}
149 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getStiffness()",
150 "This is an invalid ContactMaterial.");
151 return m_stiffness; }
154 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getStiffness23()",
155 "This is an invalid ContactMaterial.");
156 return m_stiffness23; }
159 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getDissipation()",
160 "This is an invalid ContactMaterial.");
161 return m_dissipation; }
164 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getStaticFriction()",
165 "This is an invalid ContactMaterial.");
166 return m_staticFriction; }
169 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getDynamicFriction()",
170 "This is an invalid ContactMaterial.");
171 return m_dynamicFriction; }
174 {
SimTK_ERRCHK(isValid(),
"ContactMaterial::getViscousFriction()",
175 "This is an invalid ContactMaterial.");
176 return m_viscousFriction; }
183 "Stiffness %g is illegal; must be >= 0.", stiffness);
184 m_stiffness = stiffness;
185 m_stiffness23 = std::pow(m_stiffness,
Real(2./3.));
194 "Dissipation %g (in 1/speed) is illegal; must be >= 0.", dissipation);
195 m_dissipation = dissipation;
201 Real dynamicFriction,
202 Real viscousFriction = 0)
205 "Illegal static friction coefficient %g.", staticFriction);
207 "ContactMaterial::setFriction()",
208 "Dynamic coefficient %g illegal; must be between 0 and static"
209 " coefficient %g.", dynamicFriction, staticFriction);
211 "Illegal viscous friction coefficient %g.", viscousFriction);
213 m_staticFriction = staticFriction;
214 m_dynamicFriction = dynamicFriction;
215 m_viscousFriction = viscousFriction;
232 -1 < poissonsRatio && poissonsRatio <= 0.5,
233 "ContactMaterial::calcStiffnessForSolid()",
234 "Illegal material properties E=%g, v=%g.",
235 youngsModulus, poissonsRatio);
237 return youngsModulus / (1-
square(poissonsRatio));
253 -1 < poissonsRatio && poissonsRatio < 0.5,
254 "ContactMaterial::calcStiffnessForSolid()",
255 "Illegal material properties E=%g, v=%g.",
256 youngsModulus, poissonsRatio);
258 return youngsModulus*(1-poissonsRatio)
259 / ((1+poissonsRatio)*(1-2*poissonsRatio));
273 static Real calcDissipationFromObservedRestitution
275 if (restitution==1)
return 0;
277 "ContactMaterial::calcDissipationFromRestitution()",
278 "Illegal coefficient of restitution or speed (%g,%g).",
280 return (1-restitution)/speed;
292 m_staticFriction=m_dynamicFriction=m_viscousFriction = 0;
307 Real m_staticFriction;
308 Real m_dynamicFriction;
309 Real m_viscousFriction;
340 : m_shape(shape), m_material(material), m_thickness(thickness) {
342 "Illegal thickness %g.", thickness);
347 { m_shape = shape;
return *
this; }
353 { m_material = material; setThickness(thickness);
return *
this; }
361 "Illegal thickness %g.", thickness);
362 m_thickness = thickness;
385 if (!clique.isValid())
return *
this;
389 for (p = m_cliques.
begin(); p != m_cliques.
end(); ++p) {
390 if (*p==clique)
return *
this;
391 if (*p>clique)
break;
394 m_cliques.
insert(p, clique);
401 if (!clique.isValid())
return;
404 std::find(m_cliques.begin(), m_cliques.end(), clique);
405 if (p != m_cliques.
end()) m_cliques.
erase(p);
412 {
if (getCliques().empty() || other.
getCliques().
empty())
return false;
413 return cliquesIntersect(getCliques(), other.
getCliques()); }
428 if (ap==a.
end() || bp==b.
end())
return false;
429 if (*ap > b.
back() || *bp > a.
back())
433 if (*ap==*bp)
return true;
435 if (*ap < *bp) {++ap;
if (ap==a.
end())
break;}
436 else {++bp;
if (bp==b.
end())
break;}
447 return ContactCliqueId(nextAvailableContactClique++); }
462 #endif // SimTK_SIMBODY_CONTACT_SURFACE_H_
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:2556
#define SimTK_ERRCHK2_ALWAYS(cond, whereChecked, fmt, a1, a2)
Definition: ExceptionMacros.h:289
SimTK_DEFINE_UNIQUE_INDEX_TYPE(AssemblyConditionIndex)
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:2434
#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
Every Simbody header and source file should include this header before any other Simbody header...
The SimTK::Array_ container class is a plug-compatible replacement for the C++ standard template l...
Definition: Array.h:50
const T & back() const
Return a const reference to the last element in this array, which must not be empty.
Definition: Array.h:2297
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:577
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:351
This class functions exactly like an int, except that the following operators are atomic: ++...
Definition: AtomicInteger.h:44
const T * end() const
The const version of end() is the same as cend().
Definition: Array.h:2187
#define SimTK_ERRCHK(cond, whereChecked, msg)
Definition: ExceptionMacros.h:324
const T * begin() const
The const version of begin() is the same as cbegin().
Definition: Array.h:2174
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:72
bool empty() const
Return true if there are no elements currently stored in this array.
Definition: Array.h:2042