XYZ.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 XYZ_H
26 #define XYZ_H
27 
28 #include <GeneralDefine.h>
29 #include <iostream>
30 #include "Math/Vector.h"
31 #include <vector>
32 #include <array>
33 #include "BaseCoordinates.h"
34 
35 class BaseParticle;
36 
37 class BaseInteraction;
38 
39 class DPMBase;
40 
56 namespace CGCoordinates
57 {
58 
74 class XYZ : public BaseCoordinates
75 {
76 public:
77 
81  static void writeNames(std::ostream& os);
82 
86  void write(std::ostream& os) const;
87 
92  static Mdouble getVolumeOfAveragedDimensions(const Vec3D& min, const Vec3D& max);
93 
98  Mdouble getDistanceSquared(const Vec3D& p) const;
99 
103  static Mdouble getLength(const Vec3D& p);
104 
109  void setXYZ(Vec3D p);
110 
116  Mdouble getINormal(const BaseInteraction& c, const Vec3D& normal) const;
117 
123  Mdouble getPNormal(const BaseInteraction& c, const Vec3D& normal) const;
124 
130  Mdouble getCNormal(const BaseInteraction& c, const Vec3D& normal) const;
131 
137  Mdouble getTangentialSquared(const BaseInteraction& c, Mdouble pNormal) const;
138 
143  static Mdouble getGaussPrefactor(Mdouble width, Mdouble cutoff);
144 
149  static Mdouble getGaussIntegralPrefactor(Mdouble distance, Mdouble width, Mdouble cutoff);
150 
155  static void normalisePolynomialCoefficients(std::vector<Mdouble>& coefficients, Mdouble cutoff);
156 
160  static const unsigned countVariables();
161 
162  static bool isResolvedIn(unsigned i) {return true;}
163 
164  static std::string getName();
165 
166 protected:
167 
172 };
173 
187 template<typename T>
188 typename std::enable_if<std::is_base_of<CGCoordinates::XYZ, typename T::CoordinatesType>::value, void>::type
189 spaceEvenly(Vec3D min, Vec3D max, std::vector<std::size_t> n, std::vector<T>& points)
190 {
191  Vec3D delta = max - min;
192  delta.X /= n[0];
193  delta.Y /= n[1];
194  delta.Z /= n[2];
195  Vec3D start = min + 0.5 * delta;
196  points.resize(n[0] * n[1] * n[2]);
197  for (std::size_t i = 0; i < n[0]; i++)
198  {
199  for (std::size_t j = 0; j < n[1]; j++)
200  {
201  for (std::size_t k = 0; k < n[2]; k++)
202  {
203  points[(i * n[1] + j) * n[2] + k].coordinates.
204  setXYZ({start.X + delta.X * i,
205  start.Y + delta.Y * j,
206  start.Z + delta.Z * k});
207  }
208  }
209  }
210 }
211 
212 }
213 #endif
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:60
Definition: BaseParticle.h:54
Contains common member functions of the X, Y, and Z classes.
Definition: BaseCoordinates.h:39
Defines the position of the CGPoint, in the non-averaged directions, i.e. all directions on which spa...
Definition: XYZ.h:75
Mdouble getCNormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: XYZ.cc:114
Vec3D p_
Definition: XYZ.h:171
static void writeNames(std::ostream &os)
Writes the coordinate names in human-readable form to an ostream.
Definition: XYZ.cc:32
void setXYZ(Vec3D p)
Returns the position of the current CGPoint, in the non-averaged directions.
Definition: XYZ.cc:61
static Mdouble getGaussIntegralPrefactor(Mdouble distance, Mdouble width, Mdouble cutoff)
Computes the prefactor of the Gauss line integral, which is dependent on the number of non-averaged d...
Definition: XYZ.cc:157
static std::string getName()
Definition: XYZ.cc:195
static Mdouble getLength(const Vec3D &p)
Returns the length of the input vector in the non-averaged directions.
Definition: XYZ.cc:83
Mdouble getPNormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: XYZ.cc:104
Mdouble getINormal(const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between th...
Definition: XYZ.cc:94
static const unsigned countVariables()
Definition: XYZ.cc:190
static void normalisePolynomialCoefficients(std::vector< Mdouble > &coefficients, Mdouble cutoff)
Normalises the coefficients of Polynomial CGFunction such that the integral over all non-averaged dim...
Definition: XYZ.cc:180
static Mdouble getGaussPrefactor(Mdouble width, Mdouble cutoff)
Computes the prefactor of the Gauss CGFunction, which is dependent on the number of non-averaged dime...
Definition: XYZ.cc:138
static Mdouble getVolumeOfAveragedDimensions(const Vec3D &min, const Vec3D &max)
returns the factor the CGFunction has to be divided by, due to integrating the variables over the ave...
Definition: XYZ.cc:53
Mdouble getDistanceSquared(const Vec3D &p) const
Returns the square of the distance between the particle p and the current CGPoint,...
Definition: XYZ.cc:73
Mdouble getTangentialSquared(const BaseInteraction &c, Mdouble pNormal) const
For the Interaction between particles/walls P and I, this function returns the square of the minimum ...
Definition: XYZ.cc:126
static bool isResolvedIn(unsigned i)
Definition: XYZ.h:162
void write(std::ostream &os) const
Writes the coordinates in human-readable form to an ostream.
Definition: XYZ.cc:40
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:77
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
The class in this namespace contain the position of a CGPoint, in the non-averaged directions,...
Definition: Base_X_Y_Z.h:41
std::enable_if< std::is_base_of< CGCoordinates::O, typename T::CoordinatesType >::value, void >::type spaceEvenly(Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
Definition: O.h:101
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51