MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Polynomial.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 #ifndef Polynomial_H
26 #define Polynomial_H
27 
28 #include <GeneralDefine.h>
29 #include "IntegralType.h"
30 #include <iostream>
31 #include <vector>
32 
33 class BaseParticle;
34 
35 class BaseInteraction;
36 
37 class DPMBase;
38 
39 class Coordinates;
40 
41 namespace CGFunctions
42 {
43 
48 enum class PolynomialType : unsigned char
49 {
50  HEAVISIDE = 0,
51  LINEAR = 1,
52  LUCY = 2
53 };
54 
55 std::ostream& operator<<(std::ostream& os, PolynomialType type);
56 
57 std::istream& operator>>(std::istream& is, PolynomialType& type);
58 
79 template<class Coordinates>
81 {
82 public:
83 
85 
89  Polynomial();
90 
95  Polynomial(const Polynomial& p) = default;
96 
100  ~Polynomial() = default;
101 
106  void write(std::ostream& os) const;
107 
111  void setPolynomialType(PolynomialType polynomialType);
112 
116  void setWidth(Mdouble width);
117 
118  Mdouble getWidth() const;
119 
123  void setStandardDeviation(Mdouble std);
124 
128  void setCutoff(Mdouble cutoff);
129 
133  Mdouble getCutoff() const;
134 
138  void computeCoefficients();
139 
143  Mdouble evaluateCGFunction(const Vec3D& position, const Coordinates& r);
144 
148  Mdouble
150 
155  Mdouble
157 
158  std::vector<Mdouble> getCoefficients();
159 
160  Vec3D evaluateCGFunctionDerivatives(const Vec3D& position, const Coordinates& r);
161 
162  Mdouble evaluateCGFunctionDerivativeWithFD(const Vec3D& position, const Coordinates& r, const int i);
163 
168  Mdouble getEps() const;
169 
174  void setEps(Mdouble eps);
175 
176 protected:
177 
188  std::vector<Mdouble> coefficients_;
189 
196 
198 
200 
202 
208 
213 
214 };
215 
216 } //namespace CGFunctions
217 #include "Polynomial.hcc"
218 
219 #endif
Mdouble evaluateCGIntegral1D(const BaseInteraction &i, const Coordinates &r, IntegralType type=IntegralType::I_TO_P)
Evaluates the line integral needed for the calculation of stresses for 1D CGCoordinates.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:72
void setEps(Mdouble eps)
Sets the finite difference step size used to evaluate derivatives of the CG function.
double Mdouble
Definition: GeneralDefine.h:34
std::vector< Mdouble > getCoefficients()
void setPolynomialType(PolynomialType polynomialType)
void setStandardDeviation(Mdouble std)
Set the standard deviation.
void setCutoff(Mdouble cutoff)
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
Mdouble getEps() const
Returns the finite difference step size used to evaluate derivatives of the CG function.
std::vector< Mdouble > coefficients_
Definition: Polynomial.h:188
PolynomialType polynomialType_
Definition: Polynomial.h:195
Coordinates CoordinatesType
Definition: Polynomial.h:84
void write(std::ostream &os) const
Writes class content into an output stream, usually a stat file.
Stores information about interactions between two interactable objects; often particles but could be ...
unsigned currentInteraction_
Definition: Polynomial.h:201
Polynomial()
Default constructor, sets all parameters to zero.
IntegralType
Specifies the two points between which a line integral is computed.
Definition: IntegralType.h:33
Defines the position of the CGPoint (e.g. x, y, z) and the parameters of a polynomial coarse-graining...
Definition: Polynomial.h:80
~Polynomial()=default
Destructor, it simply destructs the PolynomialCoordinates and all the objects it contains.
Mdouble getCutoff() const
Mdouble evaluateCGFunctionDerivativeWithFD(const Vec3D &position, const Coordinates &r, const int i)
std::ostream & operator<<(std::ostream &os, PolynomialType type)
Mdouble evaluateCGFunction(const Vec3D &position, const Coordinates &r)
Evaluates the coarse-graining function.
Definition: Vector.h:49
void setWidth(Mdouble width)
Set the cutoff radius.
std::istream & operator>>(std::istream &is, PolynomialType &type)
Mdouble getWidth() const
PolynomialType
PolynomialType is used to define how files are opened random fixed-particle bottom.
Definition: Polynomial.h:48
Template argument; use a member class of CGCoordinates to instantiate.
Mdouble evaluateCGIntegral(const BaseInteraction &i, const Coordinates &r, IntegralType type=IntegralType::I_TO_P)
Evaluates the line integral needed for the calculation of stresses.
Vec3D evaluateCGFunctionDerivatives(const Vec3D &position, const Coordinates &r)