R.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 R_H
6 #define R_H
7 
8 #include <GeneralDefine.h>
9 #include <iostream>
10 #include "Math/Vector.h"
11 #include "Base_X_Y_Z.h"
12 #include <vector>
13 #include <array>
14 #include "Math/ExtendedMath.h"
15 
16 class BaseParticle;
17 
18 class BaseInteraction;
19 
20 class DPMBase;
21 
22 namespace CGCoordinates
23 {
24 
31 class R : public Base_X_Y_Z
32 {
33 public:
34 
38  static void writeNames(std::ostream& os);
39 
43  void write(std::ostream& os) const;
44 
49  static Mdouble getVolumeOfAveragedDimensions(const Vec3D& min, const Vec3D& max);
50 
55  Mdouble getDistanceSquared(const Vec3D& p) const;
56 
60  static Mdouble getLength(const Vec3D& p);
61 
66  void setR(Mdouble r);
67 
68  const Mdouble getR() const
69  { return r_; }
70 
76  Mdouble getINormal(const BaseInteraction& c, const Vec3D& normal) const;
77 
83  Mdouble getPNormal(const BaseInteraction& c, const Vec3D& normal) const;
84 
90  Mdouble getCNormal(const BaseInteraction& c, const Vec3D& normal) const;
91 
96  static void normalisePolynomialCoefficients(std::vector<Mdouble>& coefficients, Mdouble cutoff);
97 
102  Mdouble getWeight() override;
103 
104  static Mdouble getDomainVolume(const Vec3D& min, const Vec3D& max);
105 
106  static bool isResolvedIn(unsigned i) {return i==0?true:false;}
107 
108  static std::string getName();
109 
110 protected:
111 
116 };
117 
122 template<typename T>
124 spaceEvenly(Vec3D min, Vec3D max, std::vector<std::size_t> nAll, std::vector<T>& points)
125 {
126  //note, the x-coordinate represents the r-coordinate here
127  std::size_t n = nAll[0];
128  Mdouble start = min.X;
129  Mdouble delta = (max.X - start) / n;
130 // Mdouble end = sqrt(mathsFunc::square(std::fmax(-min.X,max.X))+mathsFunc::square(std::fmax(-min.Y,max.Y)));
131 // Mdouble start = 0;
132 // Mdouble delta = (end - start) / n;
133  if (start < 0.0)
134  {
135  if (max.X > 0.0)
136  {
137  start = 0.0;
138  }
139  else
140  {
141  start = -max.X;
142  delta = (-min.X - start) / n;
143  }
144  logger(WARN, "r should be positive, but x-limits are not;"
145  "grid is set within % <r<%", start, start + delta * (n + 1));
146  }
147  start += 0.5 * delta;
148  points.resize(n);
149  for (std::size_t i = 0; i < n; i++)
150  {
151  points[i].coordinates.setR(start + delta * i);
152  }
153 }
154 
155 }
156 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
LL< Log::WARN > WARN
Warning log level.
Definition: Logger.cc:33
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: Base_X_Y_Z.h:29
Defines the non-averaged directions on which spatial coarse-graining is applied (the x-direction for ...
Definition: R.h:32
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: R.cc:46
Mdouble getDistanceSquared(const Vec3D &p) const
Returns the square of the distance between the particle p and the current CGPoint,...
Definition: R.cc:41
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: R.cc:21
Mdouble r_
Definition: R.h:115
const Mdouble getR() const
Definition: R.h:68
static std::string getName()
Definition: R.cc:108
static void writeNames(std::ostream &os)
Writes the coordinate names in human-readable form to an ostream.
Definition: R.cc:11
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: R.cc:87
Mdouble getWeight() override
Definition: R.cc:97
void setR(Mdouble r)
Returns the position of the current CGPoint, in the non-averaged directions.
Definition: R.cc:26
void write(std::ostream &os) const
Writes the coordinates in human-readable form to an ostream.
Definition: R.cc:16
static Mdouble getLength(const Vec3D &p)
Returns the length of the input vector in the non-averaged directions.
Definition: R.cc:36
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: R.cc:70
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: R.cc:58
static Mdouble getDomainVolume(const Vec3D &min, const Vec3D &max)
Definition: R.cc:102
static bool isResolvedIn(unsigned i)
Definition: R.h:106
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
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
r
Definition: UniformPSDSelfTest.py:20
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