AGXDynamics  2.31.1.0
Material.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_MATERIAL_H
18 #define AGX_MATERIAL_H
19 
20 
21 #include <agx/agxPhysics_export.h>
22 #include <agxStream/Serializable.h>
23 #include <agx/FrictionModel.h>
29 #include <agx/macros.h>
30 
31 
32 #ifdef _MSC_VER
33 # pragma warning(push)
34 # pragma warning(disable: 4251) // warning C4251: class X needs to have dll-interface to be used by clients of class Y
35 #endif
36 
37 namespace agxSDK
38 {
39  class MaterialManager;
40 }
41 namespace agxIO
42 {
43  class SceneExporter;
44 }
45 namespace agxCollide
46 {
47  class GeometryContact;
48 }
49 namespace agxData
50 {
51  class EntityStorage;
52 }
53 
54 namespace agx
55 {
61 
66  {
67  public:
68 
70  BulkMaterial();
71 
79  void setDensity(Real density);
80 
85  Real getDensity() const;
86 
90  void setYoungsModulus(Real value);
91 
95  Real getYoungsModulus() const;
96 
100  AGX_DEPRECATED(2.27.0.0)
101  void setPoissonsRatio(Real value);
102 
106  AGX_DEPRECATED(2.27.0.0)
107  Real getPoissonsRatio() const;
108 
113  Real getDamping() const;
114 
120  void setDamping( Real damping );
121 
135  bool setMinMaxElasticRestLength(Real minElasticRestLength, Real maxElasticRestLength);
136 
143  Real getMinElasticRestLength() const;
144 
151  Real getMaxElasticRestLength() const;
152 
154  void copy( const BulkMaterial* source );
155 
160  void setViscosity( Real viscosity );
161 
165  Real getViscosity() const;
166 
170  bool isDirty() const;
171 
173 
174 
176 
179 
181  const Physics::BulkMaterialPtr& getEntity() const;
182 
183  protected:
184 
185  friend class Material;
186 
187  AGX_FORCE_INLINE void setDirty( bool flag ) const;
189 
190 
191  virtual ~BulkMaterial();
192 
193 
194 
195  private:
196  mutable Physics::BulkMaterialRef m_entity;
197  };
198 
199 
204  {
205  public:
206 
208  SurfaceMaterial();
209 
214  void setRoughness( Real roughness );
215 
220  Real getRoughness() const;
221 
231  void setAdhesion( Real adhesion, Real adhesiveOverlap );
232 
236  Real getAdhesion() const;
237 
241  Real getAdhesiveOverlap() const;
242 
248  void setViscosity( Real viscosity );
249 
253  Real getViscosity() const;
254 
259  bool getFrictionEnabled() const;
260 
266  void setFrictionEnabled( bool flag );
267 
269  bool isDirty() const;
270 
272 
274 
275 
279  void copy( const SurfaceMaterial* source );
280 
282 
283  const Physics::SurfaceMaterialPtr& getEntity() const;
284 
285  protected:
286 
287  friend class Material;
288  void setDirty( bool flag ) const;
289 
291 
292 
293  virtual ~SurfaceMaterial();
294 
295  private:
296  mutable Physics::SurfaceMaterialRef m_entity;
297  };
298 
299 
304  {
305  public:
306 
308  WireMaterial();
309 
313  Real getYoungsModulusStretch() const;
314 
318  Real getDampingStretch() const;
319 
323  Real getYoungsModulusBend() const;
324 
328  Real getDampingBend() const;
329 
334  void setYoungsModulusStretch( Real youngsStretch );
335 
340  void setDampingStretch( Real dampingStretch );
341 
346  void setYoungsModulusBend( Real youngsBend );
347 
352  void setDampingBend( Real dampingBend );
353 
355 
356 
358 
359  bool isDirty() const;
360  void setDirty(bool flag) const;
361 
363  void copy( const WireMaterial* source );
364 
366 
367  const Physics::WireMaterialPtr& getEntity() const;
368 
369  protected:
370 
371  friend class Material;
373 
374 
375  virtual ~WireMaterial();
376 
377  private:
378  mutable Physics::WireMaterialRef m_entity;
379  };
380 
381 
382 
385  {
386  public:
387 
393  Material( const agx::Name& name, const Material* parent = nullptr );
394 
402  Material( const agx::Name& name, Real restitution, Real friction );
403 
407  Material( const Material& material );
408 
412  SurfaceMaterial* getSurfaceMaterial();
413 
417  const SurfaceMaterial* getSurfaceMaterial() const;
418 
422  BulkMaterial* getBulkMaterial();
423 
427  const BulkMaterial* getBulkMaterial() const;
428 
432  WireMaterial* getWireMaterial();
433 
437  const WireMaterial* getWireMaterial() const;
438 
442  const agx::Name& getName() const;
443 
447  void setName( const agx::Name& name ) {
448  m_entity.name() = name;
449  }
450 
452  static Material* getDefaultMaterial();
453 
455 
456 
459  bool isDirty() const;
460 
462 
463 
465 
466  const Physics::MaterialPtr& getEntity() const;
467 
469  void copy(const Material* other);
470 
472 
473 
474  protected:
475 
477  Material();
478 
480  virtual ~Material();
481 
482  private:
484  void setDirty( bool flag ) const;
485 
487  void init(const Name& name);
488 
489  private:
490  BulkMaterialRef m_bulkMaterial;
491  SurfaceMaterialRef m_surfaceMaterial;
492  WireMaterialRef m_wireMaterial;
493 
494  mutable Physics::MaterialRef m_entity;
495  };
496 
497 
504  {
505  public:
510  BOTH_PRIMARY_AND_SECONDARY
511  };
512 
517  REDUCE_ALL
518  };
519 
520  public:
521 
528  ContactMaterial( const Material* m1, const Material* m2, bool implicit=false );
529 
535  ContactMaterial( const ContactMaterial* other, bool implicit );
536 
542  void setRestitution( Real restitution );
543 
551  void setTangentialRestitution( Real restitution, FrictionDirection direction = BOTH_PRIMARY_AND_SECONDARY );
552 
559  void setFrictionCoefficient( Real friction, FrictionDirection direction = BOTH_PRIMARY_AND_SECONDARY );
560 
567  void setSurfaceViscosity( Real viscosity, FrictionDirection direction = BOTH_PRIMARY_AND_SECONDARY );
568 
578  void setAdhesion( Real adhesion, Real adhesiveOverlap );
579 
583  Real getAdhesion() const;
584 
588  Real getAdhesiveOverlap() const;
589 
593  Real getRestitution() const;
594 
598  Real getTangentialRestitution( FrictionDirection direction = PRIMARY_DIRECTION ) const;
599 
603  Real getFrictionCoefficient( FrictionDirection direction = PRIMARY_DIRECTION ) const;
604 
608  Real getSurfaceViscosity( FrictionDirection direction = PRIMARY_DIRECTION ) const;
609 
613  bool getSurfaceFrictionEnabled() const;
614 
618  void setEnableSurfaceFriction( bool flag );
619 
621  void setYoungsModulus( Real youngsModulus );
622 
624  Real getYoungsModulus() const ;
625 
631  void setDamping( Real damping );
632 
646  bool setMinMaxElasticRestLength(Real minElasticRestLength, Real maxElasticRestLength);
647 
654  Real getMinElasticRestLength() const;
655 
662  Real getMaxElasticRestLength() const;
663 
668  Real getDamping() const ;
669 
673  FrictionModel* getFrictionModel();
674 
678  const FrictionModel* getFrictionModel() const;
679 
683  void setFrictionModel( FrictionModel* frictionModel );
684 
688  const Material* getMaterial1() const;
689 
693  const Material* getMaterial2() const;
694 
698  bool isExplicit() const;
699 
704  void setContactReductionMode( ContactReductionMode mode );
705 
710  ContactReductionMode getContactReductionMode( ) const;
711 
719  void setContactReductionBinResolution( agx::UInt8 binResolution );
720 
724  agx::UInt8 getContactReductionBinResolution() const;
725 
731  void setUseContactAreaApproach( bool useContactAreaApproach );
732 
738  bool getUseContactAreaApproach() const;
739 
746  void setRollingResistanceCoefficient(agx::Real rollingCoefficient);
747 
754  void setTwistingResistanceCoefficient(agx::Real twistingCoefficient);
755 
759  agx::Real getRollingResistanceCoefficient() const;
760 
764  agx::Real getTwistingResistanceCoefficient() const;
765 
772  void setRollingResistanceCompliance(agx::Real compliance);
773 
780  void setTwistingResistanceCompliance(agx::Real compliance);
781 
785  agx::Real getRollingResistanceCompliance() const;
786 
790  agx::Real getTwistingResistanceCompliance() const;
791 
797  void setImpactCompliance(agx::Real impactCompliance);
798 
802  agx::Real getImpactCompliance() const;
803 
812  void setWireFrictionCoefficient( Real friction, FrictionDirection direction = BOTH_PRIMARY_AND_SECONDARY );
813 
817  Real getWireFrictionCoefficient( FrictionDirection direction = PRIMARY_DIRECTION ) const;
818 
820 
821 
830  agx::ContactMaterial* clone( const agx::Material* material1, const agx::Material* material2 ) const;
831 
832 
836  void copyInto( ContactMaterial& target ) const;
837 
838  void transfer( agxData::EntityStorage* storage );
839 
840 
842 
843  Physics::ContactMaterialPtr& getEntity();
844 
845  const Physics::ContactMaterialPtr& getEntity() const;
846 
852  enum class RestitutionCoefficient
853  {
854  NORMAL,
855  TANGENTIAL_PRIMARY,
856  TANGENTIAL_SECONDARY
857  };
858 
860 
861  protected:
862  ContactMaterial();
863  virtual ~ContactMaterial();
864 
865  private:
866 
867  ContactMaterial( const ContactMaterial& m );
868 
869  ContactMaterial& operator = ( const ContactMaterial& );
870 
871  void setDefaultParameters();
872 
873  friend class agxSDK::MaterialManager;
874  friend class agxCollide::GeometryContact;
875  friend class agxIO::SceneExporter;
876  void setIsExplicit( bool is_explicit );
877 
878 
879  private:
880  ref_ptr<const Material> m_material1;
881  ref_ptr<const Material> m_material2;
882  FrictionModelRef m_frictionModel;
883 
884  mutable Physics::ContactMaterialRef m_entity;
885  };
886 
887 
888  /* Implementation */
889 
890 
891  // SurfaceMaterial AGX_FORCE_INLINE implementation
892  AGX_FORCE_INLINE bool SurfaceMaterial::getFrictionEnabled() const
893  {
894  return m_entity.frictionEnabled();
895  }
896 
897  AGX_FORCE_INLINE Real SurfaceMaterial::getRoughness() const
898  {
899  return m_entity.roughness();
900  }
901 
902  AGX_FORCE_INLINE Real SurfaceMaterial::getAdhesion() const
903  {
904  return m_entity.adhesion();
905  }
906 
907  AGX_FORCE_INLINE Real SurfaceMaterial::getAdhesiveOverlap() const
908  {
909  return m_entity.adhesiveOverlap();
910  }
911 
912  AGX_FORCE_INLINE Real SurfaceMaterial::getViscosity() const
913  {
914  return m_entity.viscosity();
915  }
916 
918  AGX_FORCE_INLINE bool SurfaceMaterial::isDirty() const
919  {
920  return m_entity.dirty();
921  }
922 
923  AGX_FORCE_INLINE void SurfaceMaterial::setDirty( bool flag ) const
924  {
925  m_entity.dirty() = flag;
926  }
928 
930  AGX_FORCE_INLINE bool WireMaterial::isDirty() const
931  {
932  return m_entity.dirty();
933  }
934 
935  AGX_FORCE_INLINE void WireMaterial::setDirty( bool flag ) const
936  {
937  m_entity.dirty() = flag;
938  }
940 
941  AGX_FORCE_INLINE Real WireMaterial::getYoungsModulusStretch() const
942  {
943  return m_entity.youngsModulusStretch();
944  }
945 
946  AGX_FORCE_INLINE Real WireMaterial::getDampingStretch() const
947  {
948  return m_entity.dampingStretch();
949  }
950 
951  AGX_FORCE_INLINE Real WireMaterial::getYoungsModulusBend() const
952  {
953  return m_entity.youngsModulusBend();
954  }
955 
956  AGX_FORCE_INLINE Real WireMaterial::getDampingBend() const
957  {
958  return m_entity.dampingBend();
959  }
960 
961  AGX_FORCE_INLINE void WireMaterial::setYoungsModulusStretch( Real youngsStretch )
962  {
963  setDirty( true );
964  m_entity.youngsModulusStretch() = youngsStretch;
965  }
966 
967  AGX_FORCE_INLINE void WireMaterial::setDampingStretch( Real dampingStretch )
968  {
969  setDirty( true );
970  m_entity.dampingStretch() = dampingStretch;
971  }
972 
973  AGX_FORCE_INLINE void WireMaterial::setYoungsModulusBend( Real youngsBend )
974  {
975  setDirty( true );
976  m_entity.youngsModulusBend() = youngsBend;
977  }
978 
979  AGX_FORCE_INLINE void WireMaterial::setDampingBend( Real dampingBend )
980  {
981  setDirty( true );
982  m_entity.dampingBend() = dampingBend;
983  }
984 
985  // BulkMaterial AGX_FORCE_INLINE implementation
986  AGX_FORCE_INLINE Real BulkMaterial::getViscosity() const
987  {
988  return m_entity.viscosity();
989  }
990 
991  AGX_FORCE_INLINE Real BulkMaterial::getPoissonsRatio() const
992  {
993  return m_entity.poissonsRatio();
994  }
995 
996  AGX_FORCE_INLINE Real BulkMaterial::getDamping() const
997  {
998  return m_entity.damping();
999  }
1000 
1001  AGX_FORCE_INLINE Real BulkMaterial::getYoungsModulus() const
1002  {
1003  return m_entity.youngsModulus();
1004  }
1005 
1006  AGX_FORCE_INLINE Real BulkMaterial::getDensity() const
1007  {
1008  return m_entity.density();
1009  }
1010 
1011  AGX_FORCE_INLINE bool BulkMaterial::isDirty() const
1012  {
1013  return m_entity.dirty();
1014  }
1015 
1017  AGX_FORCE_INLINE void BulkMaterial::setDirty( bool flag ) const
1018  {
1019  m_entity.dirty() = flag;
1020  }
1022 
1023  // Material AGX_FORCE_INLINE implementation
1025  {
1026  return m_surfaceMaterial;
1027  }
1028 
1029  AGX_FORCE_INLINE const SurfaceMaterial* Material::getSurfaceMaterial() const
1030  {
1031  return m_surfaceMaterial;
1032  }
1033 
1034  AGX_FORCE_INLINE BulkMaterial* Material::getBulkMaterial()
1035  {
1036  return m_bulkMaterial;
1037  }
1038 
1039  AGX_FORCE_INLINE const BulkMaterial* Material::getBulkMaterial() const
1040  {
1041  return m_bulkMaterial;
1042  }
1043 
1044  AGX_FORCE_INLINE WireMaterial* Material::getWireMaterial()
1045  {
1046  return m_wireMaterial;
1047  }
1048 
1049  AGX_FORCE_INLINE const WireMaterial* Material::getWireMaterial() const
1050  {
1051  return m_wireMaterial;
1052  }
1053 
1055  AGX_FORCE_INLINE bool Material::isDirty() const
1056  {
1057  return m_surfaceMaterial->isDirty() || m_bulkMaterial->isDirty() || m_wireMaterial->isDirty();
1058  }
1059 
1060  AGX_FORCE_INLINE void Material::setDirty( bool flag ) const
1061  {
1062  m_surfaceMaterial->setDirty(flag);
1063  m_bulkMaterial->setDirty(flag);
1064  m_wireMaterial->setDirty(flag);
1065  }
1067 
1068 
1069  AGX_FORCE_INLINE const agx::Name& Material::getName() const
1070  {
1071  return m_entity.name();
1072  }
1073 
1074  // ContactMaterial AGX_FORCE_INLINE implementation
1075  AGX_FORCE_INLINE Real ContactMaterial::getRestitution() const
1076  {
1077  return m_entity.restitution()[ (int)RestitutionCoefficient::NORMAL ];
1078  }
1079 
1080  AGX_FORCE_INLINE Real ContactMaterial::getFrictionCoefficient(FrictionDirection direction) const
1081  {
1082  return m_entity.friction()[ agx::clamp< int >( direction, 0, 1 ) ];
1083  }
1084 
1085  AGX_FORCE_INLINE Real ContactMaterial::getSurfaceViscosity( FrictionDirection direction /* = PRIMARY_DIRECTION */ ) const
1086  {
1087  return m_entity.viscosity()[ agx::clamp< int >( direction, 0, 1 ) ];
1088  }
1089 
1090  AGX_FORCE_INLINE Real ContactMaterial::getAdhesion() const
1091  {
1092  return m_entity.adhesion();
1093  }
1094 
1095  AGX_FORCE_INLINE Real ContactMaterial::getAdhesiveOverlap() const
1096  {
1097  return m_entity.adhesiveOverlap();
1098  }
1099 
1100  AGX_FORCE_INLINE bool ContactMaterial::getSurfaceFrictionEnabled() const
1101  {
1102  return m_entity.surfaceFrictionEnabled();
1103  }
1104 
1105  AGX_FORCE_INLINE Real ContactMaterial::getYoungsModulus() const
1106  {
1107  return m_entity.youngsModulus();
1108  }
1109 
1110  AGX_FORCE_INLINE Real ContactMaterial::getDamping() const
1111  {
1112  return m_entity.damping();
1113  }
1114 
1115  AGX_FORCE_INLINE FrictionModel* ContactMaterial::getFrictionModel()
1116  {
1117  return m_frictionModel;
1118  }
1119 
1120  AGX_FORCE_INLINE const FrictionModel* ContactMaterial::getFrictionModel() const
1121  {
1122  return m_frictionModel;
1123  }
1124 
1125  AGX_FORCE_INLINE bool ContactMaterial::isExplicit() const
1126  {
1127  return m_entity.isExplicit();
1128  }
1129 
1130  AGX_FORCE_INLINE const Material* ContactMaterial::getMaterial1() const
1131  {
1132  return m_material1;
1133  }
1134 
1135  AGX_FORCE_INLINE const Material* ContactMaterial::getMaterial2() const
1136  {
1137  return m_material2;
1138  }
1139 
1140  AGX_FORCE_INLINE ContactMaterial::ContactReductionMode ContactMaterial::getContactReductionMode( ) const
1141  {
1142  return (ContactReductionMode)m_entity.contactReductionMode();
1143  }
1144 
1145  AGX_FORCE_INLINE agx::UInt8 ContactMaterial::getContactReductionBinResolution() const
1146  {
1147  return m_entity.contactReductionBinResolution();
1148  }
1149 
1151 
1153  {
1154  return m_entity;
1155  }
1157  {
1158  return m_entity;
1159  }
1160 
1162  {
1163  return m_entity;
1164  }
1165 
1167  {
1168  return m_entity;
1169  }
1170 
1171 
1173  {
1174  return m_entity;
1175  }
1176 
1178  {
1179  return m_entity;
1180  }
1181 
1182 
1184  {
1185  return m_entity;
1186  }
1187 
1189  {
1190  return m_entity;
1191  }
1192 
1193 
1195  {
1196  return m_entity;
1197  }
1198 
1200  {
1201  return m_entity;
1202  }
1204 
1205  AGX_FORCE_INLINE agx::Real ContactMaterial::getRollingResistanceCoefficient() const
1206  {
1207  return m_entity.rollingResistanceCoefficient();
1208  }
1209 
1210  AGX_FORCE_INLINE agx::Real ContactMaterial::getRollingResistanceCompliance() const
1211  {
1212  return m_entity.rollingResistanceCompliance();
1213  }
1214 
1215  AGX_FORCE_INLINE agx::Real ContactMaterial::getTwistingResistanceCompliance() const
1216  {
1217  return m_entity.twistingResistanceCompliance();
1218  }
1219 
1221  {
1222  return m_entity.impactCompliance();
1223  }
1224 
1226  {
1227  return m_entity.useContactAreaApproach();
1228  }
1229 
1230  AGX_FORCE_INLINE Real ContactMaterial::getWireFrictionCoefficient(FrictionDirection direction) const
1231  {
1232  return m_entity.wireFriction()[ agx::clamp< int >( direction, 0, 1 ) ];
1233  }
1234 } // namespace agx
1235 
1236 #ifdef _MSC_VER
1237 # pragma warning(pop)
1238 #endif
1239 
1240 
1241 #endif
This class store the combine material properties between two agx::Material&#39;s.
Definition: Material.h:503
void AGXPHYSICS_EXPORT init()
Initialize agx.
Physical properties for the bulk of geometries made up by a Material.
Definition: Material.h:65
The agxIO namespace contains classes for reading, writing and finding files.
Definition: Material.h:41
No contact reduction enabled.
Definition: Material.h:515
Base class for all friction models with interface and some utility/necessary methods implemented...
Definition: FrictionModel.h:45
agxCollide namespace consists of a set of classes for handling geometric intersection tests including...
Pointer to a entity instance of type Physics.Material.
uint8_t UInt8
Definition: Integer.h:38
void setName(const agx::Name &name)
Set the name of the material.
Definition: Material.h:447
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:63
Physical properties for the contact between a Geometry and an agx::Wire.
Definition: Material.h:303
Base class providing referencing counted objects.
Definition: Referenced.h:113
Pointer to a entity instance of type Physics.WireMaterial.
Pointer to a entity instance of type Physics.BulkMaterial.
Namespace agx contains the dynamics/math part of the AGX Dynamics API.
Physical properties for the surface of a Material.
Definition: Material.h:203
Contains classes for low level data storage for AGX.
Definition: Container.h:23
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:384
agx::Real getImpactCompliance() const
Definition: Material.h:1220
ContactReductionMode
Specifies the mode for contact reduction.
Definition: Material.h:514
FrictionDirection
Specifies the direction of friction.
Definition: Material.h:507
AGXFMI_EXPORT InputVariable_Real * setDamping(agx::Constraint *constraint)
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:206
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
Simulation unique manager that handles logics around and parameters in contact materials given two ag...
bool getUseContactAreaApproach() const
Should contacts using this contact material use the new approach for computing contact area...
Definition: Material.h:1225
Default: Reduce contacts between geometries.
Definition: Material.h:516
double Real
Definition: Real.h:42
#define AGX_DEPRECATED(since)
Definition: Object.h:94
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition: Constraint.h:30
Pointer to a entity instance of type Physics.SurfaceMaterial.
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:102
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:101
Pointer to a entity instance of type Physics.ContactMaterial.
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.