Polynomial.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, 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 
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 
124 
128  void setCutoff(Mdouble cutoff);
129 
134 
139 
143  Mdouble evaluateCGFunction(const Vec3D& position, const Coordinates& r);
144 
148  Mdouble
150 
155  Mdouble
157 
158  std::vector<Mdouble> getCoefficients();
159 
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
IntegralType
Specifies the two points between which a line integral is computed.
Definition: IntegralType.h:34
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
Definition: BaseParticle.h:54
Defines the position of the CGPoint (e.g. x, y, z) and the parameters of a polynomial coarse-graining...
Definition: Polynomial.h:81
Mdouble evaluateCGFunction(const Vec3D &position, const Coordinates &r)
Evaluates the coarse-graining function.
void setCutoff(Mdouble cutoff)
unsigned currentInteraction_
Definition: Polynomial.h:201
void setStandardDeviation(Mdouble std)
Set the standard deviation.
Mdouble getWidth() const
PolynomialType polynomialType_
Definition: Polynomial.h:195
~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)
Mdouble eps_
Definition: Polynomial.h:212
void setWidth(Mdouble width)
Set the cutoff radius.
std::vector< Mdouble > getCoefficients()
Mdouble getEps() const
Returns the finite difference step size used to evaluate derivatives of the CG function.
void setPolynomialType(PolynomialType polynomialType)
Polynomial()
Default constructor, sets all parameters to zero.
Mdouble normalLength_
Definition: Polynomial.h:197
Vec3D normal_
Definition: Polynomial.h:199
Polynomial(const Polynomial &p)=default
Copy constructor. It copies all objects the class contains.
Vec3D evaluateCGFunctionDerivatives(const Vec3D &position, const Coordinates &r)
void setEps(Mdouble eps)
Sets the finite difference step size used to evaluate derivatives of the CG function.
void write(std::ostream &os) const
Writes class content into an output stream, usually a stat file.
Mdouble cutoff_
Definition: Polynomial.h:207
Coordinates CoordinatesType
Definition: Polynomial.h:84
std::vector< Mdouble > coefficients_
Definition: Polynomial.h:188
Mdouble evaluateCGIntegral(const BaseInteraction &i, const Coordinates &r, IntegralType type=IntegralType::I_TO_P)
Evaluates the line integral needed for the calculation of stresses.
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.
Template argument; use a member class of CGCoordinates to instantiate.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:77
Definition: Vector.h:51
Contains base classes of CGPoint; CGPoint is always templated with one of these classes; these classe...
Definition: Gauss.h:48
PolynomialType
PolynomialType is used to define how files are opened random fixed-particle bottom.
Definition: Polynomial.h:49
std::istream & operator>>(std::istream &is, PolynomialType &type)
std::ostream & operator<<(std::ostream &os, PolynomialType type)
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51