MercuryDPM  Beta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Helpers.h
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 #ifndef HELPERS_H
27 #define HELPERS_H
28 
29 #include "ExtendedMath.h"
30 #include <iostream> //std::istream and std::stringstream
31 #include <fstream> //std::fstream
32 
33 namespace helpers
34 {
35 
39  class KAndDisp
40  {
41  public:
44  };
45 
52 
60 
67 
73 
80 
87 
94 
101 
108 
114 
121 
127 
134 
136 
141  {
142  public:
147  };
148 
154 
159  Mdouble getMaximumVelocity(Mdouble k, Mdouble disp, Mdouble radius, Mdouble mass);
160 
164  unsigned int getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep(unsigned int numberOfSaves, Mdouble timeMax, Mdouble timestep);
165 
169  void getLineFromStringStream(std::istream& in, std::stringstream& out);
170 
174  bool writeToFile(std::string filename, std::string filecontent);
175 
179  bool fileExists(std::string strFilename);
180 
184  bool openFile(std::fstream& file, std::string filename, std::fstream::openmode mode);
185 
189  Mdouble getEffectiveMass(Mdouble mass0, Mdouble mass1);
190 
191 }
192 
193 #endif
MERCURY_DEPRECATED KAndDispAndKtAndDispt computeDisptFromCollisionTimeAndRestitutionCoefficientAndTangentialRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble beta, Mdouble mass)
Set disp, k, dispt and kt such that is matches a given collision time tc and a normal andtangential r...
Definition: Helpers.cc:302
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: Helpers.cc:411
Mdouble getEffectiveMass(Mdouble mass0, Mdouble mass1)
Calculates the effective mass of a particle pair, i.e. half the harmonic mean of two particle masses...
Definition: Helpers.cc:482
return type specifically for fuctions returning k and disp at once
Definition: Helpers.h:39
MERCURY_DEPRECATED Mdouble computeRestitutionCoefficientFromKAndDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass)
Calculates the restitution coefficient time for a given stiffness, dissipation, and effective mass...
Definition: Helpers.cc:66
MERCURY_DEPRECATED Mdouble computeRestitutionCoefficientFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass)
Calculates the restitution coefficient for a given stiffness, collision time, and effective mass...
Definition: Helpers.cc:156
double Mdouble
return type specifically for fuctions returning k, disp, kt, dispt at once
Definition: Helpers.h:140
MERCURY_DEPRECATED Mdouble computeKFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass)
Calculates the stiffness for a given collision time, dissipation, and effective mass.
Definition: Helpers.cc:221
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:35
MERCURY_DEPRECATED KAndDisp computeKAndDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass)
Set disp and k such that is matches a given collision time tc and restitution coefficient r for a col...
Definition: Helpers.cc:33
MERCURY_DEPRECATED Mdouble computeCollisionTimeFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass)
Calculates the collision time for a given stiffness, restitution coefficient, and effective mass...
Definition: Helpers.cc:111
MERCURY_DEPRECATED Mdouble computeDispFromKAndRestitutionCoefficientAndEffectiveMass(Mdouble k, Mdouble r, Mdouble mass)
Calculates the dissipation for a given stiffness, restitution coefficient, and effective mass...
Definition: Helpers.cc:91
Mdouble disp
Definition: Helpers.h:43
void getLineFromStringStream(std::istream &in, std::stringstream &out)
Reads a line from one stringstream into another, and prepares the latter for reading in...
Definition: Helpers.cc:389
MERCURY_DEPRECATED Mdouble computeCollisionTimeFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass)
Calculates the collision time for a given dissipation, restitution coefficient, and effective mass...
Definition: Helpers.cc:281
MERCURY_DEPRECATED Mdouble computeRestitutionCoefficientFromCollisionTimeAndDispAndEffectiveMass(Mdouble tc, Mdouble disp, Mdouble mass)
Calculates the resitution coefficient for a given collision time, dissipation, and effective mass...
Definition: Helpers.cc:241
MERCURY_DEPRECATED Mdouble computeKFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass)
Calculates the stiffness for a given collision time, restitution coefficient, and effective mass...
Definition: Helpers.cc:201
MERCURY_DEPRECATED Mdouble computeDispFromCollisionTimeAndRestitutionCoefficientAndEffectiveMass(Mdouble tc, Mdouble r, Mdouble mass)
Calculates the dissipation for a given collision time, restitution coefficient, and effective mass...
Definition: Helpers.cc:181
bool fileExists(std::string strFilename)
Function to check if a file exists, is used to check if a run has already need done.
Definition: Helpers.cc:429
MERCURY_DEPRECATED Mdouble getMaximumVelocity(Mdouble k, Mdouble disp, Mdouble radius, Mdouble mass)
Calculates the maximum relative velocity allowed for a normal collision of two particles of radius r ...
Definition: Helpers.cc:315
MERCURY_DEPRECATED Mdouble computeCollisionTimeFromKAndDispAndEffectiveMass(Mdouble k, Mdouble disp, Mdouble mass)
Calculates the collision time for a given stiffness, dissipation, and effective mass.
Definition: Helpers.cc:41
bool openFile(std::fstream &file, std::string filename, std::fstream::openmode mode)
Provides a simple interface for opening a file.
Definition: Helpers.cc:466
MERCURY_DEPRECATED Mdouble computeKFromDispAndRestitutionCoefficientAndEffectiveMass(Mdouble disp, Mdouble r, Mdouble mass)
Calculates the stiffness for a given dissipation, restitution coefficient, and effective mass...
Definition: Helpers.cc:261
MERCURY_DEPRECATED Mdouble computeDispFromKAndCollisionTimeAndEffectiveMass(Mdouble k, Mdouble tc, Mdouble mass)
Calculates the dissipation for a given stiffness, collision time, and effective mass.
Definition: Helpers.cc:131
unsigned int getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep(unsigned int numberOfSaves, Mdouble timeMax, Mdouble timestep)
Returns the correct saveCount if the total number of saves, the final time and the time step is known...
Definition: Helpers.cc:343