XYZ.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef XYZ_H
6 #define XYZ_H
7 
8 #include <GeneralDefine.h>
9 #include <iostream>
10 #include "Math/Vector.h"
11 #include <vector>
12 #include <array>
13 #include "BaseCoordinates.h"
14 
15 #ifdef MERCURYDPM_OVERLAP
16 #include "overlap.hpp"
17 #endif
18 
19 class BaseParticle;
20 
21 class BaseInteraction;
22 
23 class DPMBase;
24 
40 namespace CGCoordinates
41 {
42 
58 class XYZ : public BaseCoordinates
59 {
60 public:
61 
65  static void writeNames(std::ostream& os);
66 
70  void write(std::ostream& os) const;
71 
72  #ifdef MERCURYDPM_OVERLAP
73  overlap::Hexahedron getMeshElement() const;
74  #endif
75 
80  static Mdouble getVolumeOfAveragedDimensions(const Vec3D& min, const Vec3D& max);
81 
86  Mdouble getDistanceSquared(const Vec3D& p) const;
87 
91  static Mdouble getLength(const Vec3D& p);
92 
97  void setXYZ(Vec3D p);
98 
102  void setHalfExtend(Vec3D halfExtend) { pointHalfExtend_ = halfExtend; }
103 
109  Mdouble getINormal(const BaseInteraction& c, const Vec3D& normal) const;
110 
116  Mdouble getPNormal(const BaseInteraction& c, const Vec3D& normal) const;
117 
123  Mdouble getCNormal(const BaseInteraction& c, const Vec3D& normal) const;
124 
130  Mdouble getTangentialSquared(const BaseInteraction& c, Mdouble pNormal) const;
131 
136  static Mdouble getGaussPrefactor(Mdouble width, Mdouble cutoff);
137 
142  static Mdouble getGaussIntegralPrefactor(Mdouble distance, Mdouble width, Mdouble cutoff);
143 
148  static void normalisePolynomialCoefficients(std::vector<Mdouble>& coefficients, Mdouble cutoff);
149 
153  static const unsigned countVariables();
154 
155  static bool isResolvedIn(unsigned i) {return true;}
156 
157  static std::string getName();
158 
159 protected:
160 
166 };
167 
181 template<typename T>
183 spaceEvenly(Vec3D min, Vec3D max, std::vector<std::size_t> n, std::vector<T>& points)
184 {
185  Vec3D delta = max - min;
186  delta.X /= n[0];
187  delta.Y /= n[1];
188  delta.Z /= n[2];
189  Vec3D halfExtend = delta/2.0;
190  Vec3D start = min + 0.5 * delta;
191  points.resize(n[0] * n[1] * n[2]);
192  for (std::size_t i = 0; i < n[0]; i++)
193  {
194  for (std::size_t j = 0; j < n[1]; j++)
195  {
196  for (std::size_t k = 0; k < n[2]; k++)
197  {
198  points[(i * n[1] + j) * n[2] + k].coordinates.
199  setXYZ({start.X + delta.X * i,
200  start.Y + delta.Y * j,
201  start.Z + delta.Z * k});
202  points[(i * n[1] + j) * n[2] + k].coordinates.
203  setHalfExtend(halfExtend);
204  }
205  }
206  }
207 }
208 
209 }
210 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
float * p
Definition: Tutorial_Map_using.cpp:9
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:39
Definition: BaseParticle.h:33
Contains common member functions of the X, Y, and Z classes.
Definition: BaseCoordinates.h:22
Defines the position of the CGPoint, in the non-averaged directions, i.e. all directions on which spa...
Definition: XYZ.h:59
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:117
Vec3D p_
Definition: XYZ.h:164
static void writeNames(std::ostream &os)
Writes the coordinate names in human-readable form to an ostream.
Definition: XYZ.cc:11
void setXYZ(Vec3D p)
Returns the position of the current CGPoint, in the non-averaged directions.
Definition: XYZ.cc:64
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:160
static std::string getName()
Definition: XYZ.cc:198
void setHalfExtend(Vec3D halfExtend)
Sets the extend of the current grid cell.
Definition: XYZ.h:102
static Mdouble getLength(const Vec3D &p)
Returns the length of the input vector in the non-averaged directions.
Definition: XYZ.cc:86
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:107
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:97
static const unsigned countVariables()
Definition: XYZ.cc:193
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:183
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:141
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:56
Vec3D pointHalfExtend_
Definition: XYZ.h:165
Mdouble getDistanceSquared(const Vec3D &p) const
Returns the square of the distance between the particle p and the current CGPoint,...
Definition: XYZ.cc:76
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:129
static bool isResolvedIn(unsigned i)
Definition: XYZ.h:155
void write(std::ostream &os) const
Writes the coordinates in human-readable form to an ostream.
Definition: XYZ.cc:19
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:56
Definition: Kernel/Math/Vector.h:30
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
char char char int int * k
Definition: level2_impl.h:374
The class in this namespace contain the position of a CGPoint, in the non-averaged directions,...
Definition: Base_X_Y_Z.h:21
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:81
squared absolute value
Definition: GlobalFunctions.h:87
int delta
Definition: MultiOpt.py:96
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
int c
Definition: calibrate.py:100
type
Definition: compute_granudrum_aor.py:141
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2