1 // =============================================================================
2 // PROJECT CHRONO - http://projectchrono.org
3 //
4 // Copyright (c) 2014 projectchrono.org
5 // All rights reserved.
6 //
7 // Use of this source code is governed by a BSD-style license that can be found
8 // in the LICENSE file at the top level of the distribution and at
9 // http://projectchrono.org/license-chrono.txt.
10 //
11 // =============================================================================
12 // Authors: Alessandro Tasora, Radu Serban
13 // =============================================================================
14
15 #include <algorithm>
16
17 #include "chrono/core/ChClassFactory.h"
18 #include "chrono/physics/ChMaterialSurfaceNSC.h"
19
20 namespace chrono {
21
22 // -----------------------------------------------------------------------------
23
24 // Register into the object factory, to enable run-time dynamic creation and persistence
CH_FACTORY_REGISTER(ChMaterialSurfaceNSC)25 CH_FACTORY_REGISTER(ChMaterialSurfaceNSC)
26
27 ChMaterialSurfaceNSC::ChMaterialSurfaceNSC()
28 : ChMaterialSurface(),
29 cohesion(0),
30 dampingf(0),
31 compliance(0),
32 complianceT(0),
33 complianceRoll(0),
34 complianceSpin(0) {}
35
ChMaterialSurfaceNSC(const ChMaterialSurfaceNSC & other)36 ChMaterialSurfaceNSC::ChMaterialSurfaceNSC(const ChMaterialSurfaceNSC& other) : ChMaterialSurface(other) {
37 cohesion = other.cohesion;
38 dampingf = other.dampingf;
39 compliance = other.compliance;
40 complianceT = other.complianceT;
41 complianceRoll = other.complianceRoll;
42 complianceSpin = other.complianceSpin;
43 }
44
ArchiveOUT(ChArchiveOut & marchive)45 void ChMaterialSurfaceNSC::ArchiveOUT(ChArchiveOut& marchive) {
46 // version number
47 marchive.VersionWrite<ChMaterialSurfaceNSC>();
48
49 // serialize parent class
50 ChMaterialSurface::ArchiveOUT(marchive);
51
52 // serialize all member data:
53 marchive << CHNVP(cohesion);
54 marchive << CHNVP(dampingf);
55 marchive << CHNVP(compliance);
56 marchive << CHNVP(complianceT);
57 marchive << CHNVP(complianceRoll);
58 marchive << CHNVP(complianceSpin);
59 }
60
ArchiveIN(ChArchiveIn & marchive)61 void ChMaterialSurfaceNSC::ArchiveIN(ChArchiveIn& marchive) {
62 // version number
63 /*int version =*/ marchive.VersionRead<ChMaterialSurfaceNSC>();
64
65 // deserialize parent class
66 ChMaterialSurface::ArchiveIN(marchive);
67
68 // stream in all member data:
69 marchive >> CHNVP(cohesion);
70 marchive >> CHNVP(dampingf);
71 marchive >> CHNVP(compliance);
72 marchive >> CHNVP(complianceT);
73 marchive >> CHNVP(complianceRoll);
74 marchive >> CHNVP(complianceSpin);
75 }
76
77 // -----------------------------------------------------------------------------
78
ChMaterialCompositeNSC()79 ChMaterialCompositeNSC::ChMaterialCompositeNSC()
80 : static_friction(0),
81 sliding_friction(0),
82 rolling_friction(0),
83 spinning_friction(0),
84 restitution(0),
85 cohesion(0),
86 dampingf(0),
87 compliance(0),
88 complianceT(0),
89 complianceRoll(0),
90 complianceSpin(0) {}
91
ChMaterialCompositeNSC(ChMaterialCompositionStrategy * strategy,std::shared_ptr<ChMaterialSurfaceNSC> mat1,std::shared_ptr<ChMaterialSurfaceNSC> mat2)92 ChMaterialCompositeNSC::ChMaterialCompositeNSC(ChMaterialCompositionStrategy* strategy,
93 std::shared_ptr<ChMaterialSurfaceNSC> mat1,
94 std::shared_ptr<ChMaterialSurfaceNSC> mat2) {
95 static_friction = strategy->CombineFriction(mat1->static_friction, mat2->static_friction);
96 sliding_friction = strategy->CombineFriction(mat1->sliding_friction, mat2->sliding_friction);
97 restitution = strategy->CombineRestitution(mat1->restitution, mat2->restitution);
98 cohesion = strategy->CombineCohesion(mat1->cohesion, mat2->cohesion);
99 dampingf = strategy->CombineDamping(mat1->dampingf, mat2->dampingf);
100 compliance = strategy->CombineCompliance(mat1->compliance, mat2->compliance);
101 complianceT = strategy->CombineCompliance(mat1->complianceT, mat2->complianceT);
102
103 rolling_friction = strategy->CombineFriction(mat1->rolling_friction, mat2->rolling_friction);
104 spinning_friction = strategy->CombineFriction(mat1->spinning_friction, mat2->spinning_friction);
105 complianceRoll = strategy->CombineCompliance(mat1->complianceRoll , mat2->complianceRoll);
106 complianceSpin = strategy->CombineCompliance(mat1->complianceSpin , mat2->complianceSpin);
107 }
108
109 } // end namespace chrono
110