MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FrictionSpecies.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #include "FrictionSpecies.h"
27 #include<cmath>
28 #include "Species/BaseSpecies.h"
29 
30 class BaseParticle;
31 class BaseInteractable;
32 
35 {
44 #ifdef DEBUG_CONSTRUCTOR
45  std::cout<<"FrictionSpecies::FrictionSpecies() finished"<<std::endl;
46 #endif
47 }
48 
54 {
63 #ifdef DEBUG_CONSTRUCTOR
64  std::cout<<"FrictionSpecies::FrictionSpecies(const FrictionSpecies &p) finished"<<std::endl;
65 #endif
66 }
67 
69 {
70 #ifdef DEBUG_DESTRUCTOR
71  std::cout<<"FrictionSpecies::~FrictionSpecies() finished"<<std::endl;
72 #endif
73 }
74 
78 void FrictionSpecies::write(std::ostream& os) const
79 {
81  os << " rollingStiffness " << rollingStiffness_;
82  os << " rollingDissipation " << rollingDissipation_;
83  os << " rollingFrictionCoefficient " << rollingFrictionCoefficient_;
84  os << " rollingFrictionCoefficientStatic " << rollingFrictionCoefficientStatic_;
85  os << " torsionStiffness " << torsionStiffness_;
86  os << " torsionDissipation " << torsionDissipation_;
87  os << " torsionFrictionCoefficient " << torsionFrictionCoefficient_;
88  os << " torsionFrictionCoefficientStatic " << torsionFrictionCoefficientStatic_;
89 }
90 
94 void FrictionSpecies::read(std::istream& is)
95 {
97  std::string dummy;
98  is >> dummy >> rollingStiffness_;
99  is >> dummy >> rollingDissipation_;
100  is >> dummy >> rollingFrictionCoefficient_;
101  is >> dummy >> rollingFrictionCoefficientStatic_;
102  is >> dummy >> torsionStiffness_;
103  is >> dummy >> torsionDissipation_;
104  is >> dummy >> torsionFrictionCoefficient_;
105  is >> dummy >> torsionFrictionCoefficientStatic_;
106 }
107 
111 std::string FrictionSpecies::getBaseName() const
112 {
113  return "Friction";
114 }
115 
123 {
124  return true;
125 }
126 
133 {
142 }
143 
146 {
147  if (new_kt >= 0)
148  {
149  rollingStiffness_ = new_kt;
150  }
151  else
152  {
153  std::cerr << "Error in setRollingStiffness" << std::endl;
154  exit(-1);
155  }
156 }
157 
160 {
161  return rollingStiffness_;
162 }
163 
166 {
167  if (new_dispt >= 0)
168  rollingDissipation_ = new_dispt;
169  else
170  {
171  std::cerr << "Error in setRollingDissipation" << std::endl;
172  exit(-1);
173  }
174 }
177 {
178  return rollingDissipation_;
179 }
180 
182 //mu has to be set to allow tangential forces (sets dispt=disp as default)
184 {
185  if (new_mu >= 0)
186  {
189  }
190  else
191  {
192  std::cerr << "Error in setSlidingFrictionCoefficient" << std::endl;
193  exit(-1);
194  }
195 }
196 
199 {
201 }
202 
205 {
206  if (new_mu >= 0)
207  {
209  }
210  else
211  {
212  std::cerr << "Error in setSlidingFrictionCoefficientStatic" << std::endl;
213  exit(-1);
214  }
215 }
216 
219 {
221 }
222 
223 
226 {
227  if (new_kt >= 0)
228  {
229  torsionStiffness_ = new_kt;
230  }
231  else
232  {
233  std::cerr << "Error in setTorsionStiffness" << std::endl;
234  exit(-1);
235  }
236 }
237 
240 {
241  return torsionStiffness_;
242 }
243 
246 {
247  if (new_dispt >= 0)
248  torsionDissipation_ = new_dispt;
249  else
250  {
251  std::cerr << "Error in setTorsionDissipation" << std::endl;
252  exit(-1);
253  }
254 }
257 {
258  return torsionDissipation_;
259 }
260 
262 //mu has to be set to allow tangential forces (sets dispt=disp as default)
264 {
265  if (new_mu >= 0)
266  {
269  }
270  else
271  {
272  std::cerr << "Error in setSlidingFrictionCoefficient" << std::endl;
273  exit(-1);
274  }
275 }
276 
279 {
281 }
282 
285 {
286  if (new_mu >= 0)
287  {
289  }
290  else
291  {
292  std::cerr << "Error in setSlidingFrictionCoefficientStatic" << std::endl;
293  exit(-1);
294  }
295 }
296 
299 {
301 }
void read(std::istream &is)
Reads the species properties from an input stream.
Mdouble getRollingFrictionCoefficient() const
Allows the (dynamic) Coulomb friction coefficient to be accessed.
void setRollingFrictionCoefficientStatic(Mdouble new_mu)
Allows the static Coulomb rolling friction coefficient to be changed.
void setTorsionFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb torsion friction coefficient to be changed; also sets mu_s by default...
Mdouble getTorsionFrictionCoefficient() const
Allows the (dynamic) Coulomb torsion friction coefficient to be accessed.
void setTorsionStiffness(Mdouble new_kt)
Allows the torsion stiffness to be changed.
FrictionSpecies contains the parameters used to describe sliding, rolling and torsional friction...
Mdouble rollingStiffness_
rolling stiffness.
Mdouble rollingDissipation_
rolling dissipation coefficient.
void setRollingStiffness(Mdouble new_kt)
Allows the spring constant to be changed.
Mdouble rollingFrictionCoefficientStatic_
static Coulomb rolling friction coefficient (by default set equal to the dynamic one).
void write(std::ostream &os) const
Writes the species properties to an output stream.
double Mdouble
FrictionSpecies()
The default constructor.
Mdouble getTorsionStiffness() const
Allows the torsion stiffness to be accessed.
Mdouble getRollingDissipation() const
Allows the tangential viscosity to be accessed.
Mdouble getRollingFrictionCoefficientStatic() const
Allows the static Coulomb rolling friction coefficient to be accessed.
Mdouble getRollingStiffness() const
Allows the spring constant to be accessed.
void setTorsionFrictionCoefficientStatic(Mdouble new_mu)
Allows the static Coulomb torsion friction coefficient to be accessed.
Mdouble torsionDissipation_
rolling dissipation coefficient.
void setTorsionDissipation(Mdouble new_dispt)
Allows the torsion viscosity to be changed.
void read(std::istream &is)
Reads the species properties from an input stream.
void setRollingFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb friction coefficient to be changed; also sets mu_s by default...
std::string getBaseName() const
Used in Species::getName to obtain a unique name for each Species.
Mdouble torsionFrictionCoefficient_
(dynamic) Coulomb torsion friction coefficient.
void mix(FrictionSpecies *const S, FrictionSpecies *const T)
creates default values for mixed species
Mdouble average(Mdouble a, Mdouble b)
defines the average of two variables by the harmonic mean.
Definition: BaseSpecies.cc:85
Mdouble rollingFrictionCoefficient_
(dynamic) Coulomb rolling friction coefficient.
SlidingFrictionSpecies contains the parameters used to describe sliding friction. ...
void write(std::ostream &os) const
Writes the species properties to an output stream.
virtual ~FrictionSpecies()
The default destructor.
void setRollingDissipation(Mdouble new_dispt)
Allows the tangential viscosity to be changed.
Defines the basic properties that a interactable object can have.
Mdouble torsionFrictionCoefficientStatic_
static Coulomb torsion friction coefficient (by default set equal to the dynamic one).
Mdouble torsionStiffness_
rolling stiffness.
bool getUseAngularDOFs() const
Returns true if torques have to be calculated.
Mdouble getTorsionDissipation() const
Allows the torsion viscosity to be accessed.
Mdouble getTorsionFrictionCoefficientStatic() const
Allows the static Coulomb torsion friction coefficient to be accessed.