AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
464  Physics::MaterialPtr& getEntity();
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:
483  friend class agxSDK::MaterialManager;
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 
503  class AGXPHYSICS_EXPORT ContactMaterial : public Referenced, public virtual agxStream::Serializable
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 
898  {
899  return m_entity.roughness();
900  }
901 
903  {
904  return m_entity.adhesion();
905  }
906 
908  {
909  return m_entity.adhesiveOverlap();
910  }
911 
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 
947  {
948  return m_entity.dampingStretch();
949  }
950 
952  {
953  return m_entity.youngsModulusBend();
954  }
955 
957  {
958  return m_entity.dampingBend();
959  }
960 
962  {
963  setDirty( true );
964  m_entity.youngsModulusStretch() = youngsStretch;
965  }
966 
968  {
969  setDirty( true );
970  m_entity.dampingStretch() = dampingStretch;
971  }
972 
974  {
975  setDirty( true );
976  m_entity.youngsModulusBend() = youngsBend;
977  }
978 
980  {
981  setDirty( true );
982  m_entity.dampingBend() = dampingBend;
983  }
984 
985  // BulkMaterial AGX_FORCE_INLINE implementation
987  {
988  return m_entity.viscosity();
989  }
990 
992  {
993  return m_entity.poissonsRatio();
994  }
995 
997  {
998  return m_entity.damping();
999  }
1000 
1002  {
1003  return m_entity.youngsModulus();
1004  }
1005 
1007  {
1008  return m_entity.density();
1009  }
1010 
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
1024  AGX_FORCE_INLINE SurfaceMaterial* Material::getSurfaceMaterial()
1025  {
1026  return m_surfaceMaterial;
1027  }
1028 
1030  {
1031  return m_surfaceMaterial;
1032  }
1033 
1035  {
1036  return m_bulkMaterial;
1037  }
1038 
1040  {
1041  return m_bulkMaterial;
1042  }
1043 
1045  {
1046  return m_wireMaterial;
1047  }
1048 
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
1076  {
1077  return m_entity.restitution()[ (int)RestitutionCoefficient::NORMAL ];
1078  }
1079 
1081  {
1082  return m_entity.friction()[ agx::clamp< int >( direction, 0, 1 ) ];
1083  }
1084 
1086  {
1087  return m_entity.viscosity()[ agx::clamp< int >( direction, 0, 1 ) ];
1088  }
1089 
1091  {
1092  return m_entity.adhesion();
1093  }
1094 
1096  {
1097  return m_entity.adhesiveOverlap();
1098  }
1099 
1101  {
1102  return m_entity.surfaceFrictionEnabled();
1103  }
1104 
1106  {
1107  return m_entity.youngsModulus();
1108  }
1109 
1111  {
1112  return m_entity.damping();
1113  }
1114 
1116  {
1117  return m_frictionModel;
1118  }
1119 
1121  {
1122  return m_frictionModel;
1123  }
1124 
1126  {
1127  return m_entity.isExplicit();
1128  }
1129 
1131  {
1132  return m_material1;
1133  }
1134 
1136  {
1137  return m_material2;
1138  }
1139 
1141  {
1142  return (ContactReductionMode)m_entity.contactReductionMode();
1143  }
1144 
1146  {
1147  return m_entity.contactReductionBinResolution();
1148  }
1149 
1151 
1152  AGX_FORCE_INLINE Physics::BulkMaterialPtr& BulkMaterial::getEntity()
1153  {
1154  return m_entity;
1155  }
1156  AGX_FORCE_INLINE const Physics::BulkMaterialPtr& BulkMaterial::getEntity() const
1157  {
1158  return m_entity;
1159  }
1160 
1161  AGX_FORCE_INLINE Physics::SurfaceMaterialPtr& SurfaceMaterial::getEntity()
1162  {
1163  return m_entity;
1164  }
1165 
1166  AGX_FORCE_INLINE const Physics::SurfaceMaterialPtr& SurfaceMaterial::getEntity() const
1167  {
1168  return m_entity;
1169  }
1170 
1171 
1172  AGX_FORCE_INLINE Physics::WireMaterialPtr& WireMaterial::getEntity()
1173  {
1174  return m_entity;
1175  }
1176 
1177  AGX_FORCE_INLINE const Physics::WireMaterialPtr& WireMaterial::getEntity() const
1178  {
1179  return m_entity;
1180  }
1181 
1182 
1183  AGX_FORCE_INLINE Physics::MaterialPtr& Material::getEntity()
1184  {
1185  return m_entity;
1186  }
1187 
1188  AGX_FORCE_INLINE const Physics::MaterialPtr& Material::getEntity() const
1189  {
1190  return m_entity;
1191  }
1192 
1193 
1194  AGX_FORCE_INLINE Physics::ContactMaterialPtr& ContactMaterial::getEntity()
1195  {
1196  return m_entity;
1197  }
1198 
1199  AGX_FORCE_INLINE const Physics::ContactMaterialPtr& ContactMaterial::getEntity() const
1200  {
1201  return m_entity;
1202  }
1204 
1205  AGX_FORCE_INLINE agx::Real ContactMaterial::getRollingResistanceCoefficient() const
1206  {
1207  return m_entity.rollingResistanceCoefficient();
1208  }
1209 
1211  {
1212  return m_entity.rollingResistanceCompliance();
1213  }
1214 
1216  {
1217  return m_entity.twistingResistanceCompliance();
1218  }
1219 
1221  {
1222  return m_entity.impactCompliance();
1223  }
1224 
1226  {
1227  return m_entity.useContactAreaApproach();
1228  }
1229 
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
Real getRoughness() const
Definition: Material.h:897
void AGXPHYSICS_EXPORT init()
Initialize agx.
bool isDirty() const
Definition: Material.h:1011
Physical properties for the bulk of geometries made up by a Material.
Definition: Material.h:65
void setDampingBend(Real dampingBend)
Assign damping in wire bend constraints.
Definition: Material.h:979
bool getSurfaceFrictionEnabled() const
Definition: Material.h:1100
Real getAdhesiveOverlap() const
Definition: Material.h:907
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
void setYoungsModulusBend(Real youngsBend)
Set the Young&#39;s modulus controlling the bend resistance of a wire.
Definition: Material.h:973
Real getDensity() const
Get the density of a material.
Definition: Material.h:1006
Real getDampingStretch() const
Definition: Material.h:946
Real getAdhesiveOverlap() const
Definition: Material.h:1095
Real getYoungsModulus() const
Definition: Material.h:1001
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
Real getAdhesion() const
Definition: Material.h:902
#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:62
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
Real getDamping() const
This is the damping factor that is used by the contact constraint.
Definition: Material.h:996
Pointer to a entity instance of type Physics.WireMaterial.
Real getYoungsModulusBend() const
Definition: Material.h:951
SurfaceMaterial * getSurfaceMaterial()
Definition: Material.h:1024
void setDampingStretch(Real dampingStretch)
Set the damping in wire stretch constraints.
Definition: Material.h:967
agx::UInt8 getContactReductionBinResolution() const
Definition: Material.h:1145
Pointer to a entity instance of type Physics.BulkMaterial.
Real getFrictionCoefficient(FrictionDirection direction=PRIMARY_DIRECTION) const
Definition: Material.h:1080
Real getRestitution() const
Definition: Material.h:1075
Physical properties for the surface of a Material.
Definition: Material.h:203
Real getAdhesion() const
Definition: Material.h:1090
agx::Real getRollingResistanceCompliance() const
Definition: Material.h:1210
WireMaterial * getWireMaterial()
Definition: Material.h:1044
FrictionModel * getFrictionModel()
Definition: Material.h:1115
agx::Real getTwistingResistanceCompliance() const
Definition: Material.h:1215
Real getViscosity() const
Definition: Material.h:986
bool isExplicit() const
Definition: Material.h:1125
Real getDampingBend() const
Definition: Material.h:956
Main material class which acts as a holder of a Surface Material and a Bulk material.
Definition: Material.h:384
const Material * getMaterial2() const
Definition: Material.h:1135
Real getWireFrictionCoefficient(FrictionDirection direction=PRIMARY_DIRECTION) const
Definition: Material.h:1230
ContactReductionMode
Specifies the mode for contact reduction.
Definition: Material.h:514
Real getDamping() const
The value is the time the contact constraint has to fulfill its violation.
Definition: Material.h:1110
FrictionDirection
Specifies the direction of friction.
Definition: Material.h:507
AGXFMI_EXPORT InputVariable_Real * setDamping(agx::Constraint *constraint)
Real getSurfaceViscosity(FrictionDirection direction=PRIMARY_DIRECTION) const
Definition: Material.h:1085
#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
Real getYoungsModulus() const
Definition: Material.h:1105
const Material * getMaterial1() const
Definition: Material.h:1130
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
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
Real getViscosity() const
Definition: Material.h:912
double Real
Definition: Real.h:42
agx::Real getImpactCompliance() const
Definition: Material.h:1220
Real getPoissonsRatio() const
Definition: Material.h:991
#define AGX_DEPRECATED(since)
Definition: Object.h:93
void setYoungsModulusStretch(Real youngsStretch)
Set the Young&#39;s modulus controlling the stretchiness of a wire.
Definition: Material.h:961
Pointer to a entity instance of type Physics.SurfaceMaterial.
BulkMaterial * getBulkMaterial()
Definition: Material.h:1034
ContactReductionMode getContactReductionMode() const
Returns whether contact reduction is enabled for this surface material.
Definition: Material.h:1140
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: Object.h:101
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: Object.h:100
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.
bool isDirty() const