CGCoordinates Namespace Reference

The class in this namespace contain the position of a CGPoint, in the non-averaged directions, and functions that only depend on which non-averaged directions are used. More...

Classes

class  Base_X_Y_Z
 Contains common member functions of the X, Y, and Z classes. More...
 
class  Base_XY_XZ_YZ
 Contains common member functions of the XY, XZ, and YZ classes. More...
 
class  BaseCoordinates
 Contains common member functions of the X, Y, and Z classes. More...
 
class  O
 Defines the non-averaged directions on which spatial coarse-graining is applied (none for O); all other directions (all for O) are averaged
over homogeneously. More...
 
class  R
 Defines the non-averaged directions on which spatial coarse-graining is applied (the x-direction for R); all other directions are averaged
over homogeneously. More...
 
class  RZ
 Defines the non-averaged directions on which spatial coarse-graining is applied (the x- and z-direction for RZ); all other directions are averaged
over homogeneously. More...
 
class  X
 Defines the non-averaged directions on which spatial coarse-graining is applied (the x-direction for X); all other directions are averaged
over homogeneously. More...
 
class  XY
 Defines the non-averaged directions on which spatial coarse-graining is applied (the x- and y-direction for XY); all other directions are averaged
over homogeneously. More...
 
class  XYZ
 Defines the position of the CGPoint, in the non-averaged directions, i.e. all directions on which spatial coarse-graining is applied (all directions for XYZ); all other directions are averaged over homogeneously. More...
 
class  XZ
 Defines the non-averaged directions on which spatial coarse-graining is applied (the x- and z-direction for XZ); all other directions are averaged
over homogeneously. More...
 
class  Y
 Defines the non-averaged directions on which spatial coarse-graining is applied (the y- direction for Y); all other directions are averaged
over homogeneously. More...
 
class  YZ
 Defines the non-averaged directions on which spatial coarse-graining is applied (the y- and z-direction for YZ); all other directions are averaged
over homogeneously. More...
 
class  Z
 Defines the non-averaged directions on which spatial coarse-graining is applied (the z-direction for Z); all other directions are averaged over homogeneously. More...
 

Functions

template<typename T >
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)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::R, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::RZ, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::X, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::XY, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::XYZ, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > n, std::vector< T > &points)
 Creates a spatial mesh of CGPoints, i.e. the spatial positions at which the cg-variables are evaluated. More...
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::XZ, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::Y, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::YZ, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 
template<typename T >
std::enable_if< std::is_base_of< CGCoordinates::Z, typename T::CoordinatesType >::value, void >::type spaceEvenly (Vec3D min, Vec3D max, std::vector< std::size_t > nAll, std::vector< T > &points)
 

Detailed Description

The class in this namespace contain the position of a CGPoint, in the non-averaged directions, and functions that only depend on which non-averaged directions are used.

Contains base classes of CGFunctions, which in turn contains the base classes of CGPoint; CGPoint's and CGFunctions are always templated with one of these classes. The classes currently are: O, X, Y, Z, YZ, XZ, XY, XYZ.

As the 1D classes X, Y, Z have some common functionality, they are derived from a common base class Base_X_Y_Z. Similarly, XY, XZ, YZ are derived from Base_XY_XZ_YZ.

See member CGCoordinates::XYZ for more details.

Function Documentation

◆ spaceEvenly() [1/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::XYZ, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  n,
std::vector< T > &  points 
)

Creates a spatial mesh of CGPoints, i.e. the spatial positions at which the cg-variables are evaluated.

The mesh is created over the domain [min.X,max.X].[min.Y,max.Y].[min.Z,max.Z]. The mesh is defined by splitting the domain into nx.ny.nz smaller cubical subdomains; the centers of these cubes are the mesh points. This is done to keep the results comparable to a binning method.

Parameters
[in]minthe lower limit coordinate values of the meshed domain.
[in]maxthe upper limit coordinate values of the meshed domain.
[in]nthe number of points in each spatial direction.
[out]pointsthe vector of CGPoint's, which are now on a spatial mesh over the given domain.
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 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
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
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References constants::i, n, Vec3D::X, Vec3D::Y, and Vec3D::Z.

◆ spaceEvenly() [2/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::O, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

102 {
103  points.resize(1);
104 }

◆ spaceEvenly() [3/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::R, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

Todo:
limit to r>0
145 {
146  //note, the x-coordinate represents the r-coordinate here
147  std::size_t n = nAll[0];
148  Mdouble start = min.X;
149  Mdouble delta = (max.X - start) / n;
150 // Mdouble end = sqrt(mathsFunc::square(std::fmax(-min.X,max.X))+mathsFunc::square(std::fmax(-min.Y,max.Y)));
151 // Mdouble start = 0;
152 // Mdouble delta = (end - start) / n;
153  if (start < 0.0)
154  {
155  if (max.X > 0.0)
156  {
157  start = 0.0;
158  }
159  else
160  {
161  start = -max.X;
162  delta = (-min.X - start) / n;
163  }
164  logger(WARN, "r should be positive, but x-limits are not;"
165  "grid is set within % <r<%", start, start + delta * (n + 1));
166  }
167  start += 0.5 * delta;
168  points.resize(n);
169  for (std::size_t i = 0; i < n; i++)
170  {
171  points[i].coordinates.setR(start + delta * i);
172  }
173 }
double Mdouble
Definition: GeneralDefine.h:34
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:54

References constants::i, logger, n, WARN, and Vec3D::X.

◆ spaceEvenly() [4/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::RZ, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

137 {
138  std::size_t n0 = nAll[0];
139  std::size_t n1 = nAll[2];
140  Mdouble delta0 = (max.X - min.X) / n0;
141  Mdouble delta1 = (max.Z - min.Z) / n1;
142  Mdouble start0 = min.X + 0.5 * delta0;
143  Mdouble start1 = min.Z + 0.5 * delta1;
144  points.resize(n0 * n1);
145  for (std::size_t i = 0; i < n0; i++)
146  {
147  for (std::size_t j = 0; j < n1; j++)
148  {
149  points[i * n1 + j].coordinates.setRZ(start0 + delta0 * i, start1 + delta1 * j);
150  }
151  }
152 }

References constants::i, Vec3D::X, and Vec3D::Z.

◆ spaceEvenly() [5/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::X, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

128 {
129  std::size_t n = nAll[0];
130  Mdouble delta = (max.X - min.X) / n;
131  Mdouble start = min.X + 0.5 * delta;
132  points.resize(n);
133  for (std::size_t i = 0; i < n; i++)
134  {
135  points[i].coordinates.setX(start + delta * i);
136  }
137 }

References constants::i, n, and Vec3D::X.

◆ spaceEvenly() [6/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::XY, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

137 {
138  std::size_t n0 = nAll[0];
139  std::size_t n1 = nAll[1];
140  Mdouble delta0 = (max.X - min.X) / n0;
141  Mdouble delta1 = (max.Y - min.Y) / n1;
142  Mdouble start0 = min.X + 0.5 * delta0;
143  Mdouble start1 = min.Y + 0.5 * delta1;
144  points.resize(n0 * n1);
145  for (std::size_t i = 0; i < n0; i++)
146  {
147  for (std::size_t j = 0; j < n1; j++)
148  {
149  points[i * n1 + j].coordinates.setXY(start0 + delta0 * i, start1 + delta1 * j);
150  }
151  }
152 }

References constants::i, Vec3D::X, and Vec3D::Y.

◆ spaceEvenly() [7/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::XZ, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

137 {
138  std::size_t n0 = nAll[0];
139  std::size_t n1 = nAll[2];
140  Mdouble delta0 = (max.X - min.X) / n0;
141  Mdouble delta1 = (max.Z - min.Z) / n1;
142  Mdouble start0 = min.X + 0.5 * delta0;
143  Mdouble start1 = min.Z + 0.5 * delta1;
144  points.resize(n0 * n1);
145  for (std::size_t i = 0; i < n0; i++)
146  {
147  for (std::size_t j = 0; j < n1; j++)
148  {
149  points[i * n1 + j].coordinates.setXZ(start0 + delta0 * i, start1 + delta1 * j);
150  }
151  }
152 }

References constants::i, Vec3D::X, and Vec3D::Z.

◆ spaceEvenly() [8/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::Y, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

126 {
127  std::size_t n = nAll[1];
128  Mdouble delta = (max.Y - min.Y) / n;
129  Mdouble start = min.Y + 0.5 * delta;
130  points.resize(n);
131  for (std::size_t i = 0; i < n; i++)
132  {
133  points[i].coordinates.setY(start + delta * i);
134  }
135 }

References constants::i, n, and Vec3D::Y.

◆ spaceEvenly() [9/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::YZ, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

137 {
138  std::size_t n0 = nAll[1];
139  std::size_t n1 = nAll[2];
140  Mdouble delta0 = (max.Y - min.Y) / n0;
141  Mdouble delta1 = (max.Z - min.Z) / n1;
142  Mdouble start0 = min.Y + 0.5 * delta0;
143  Mdouble start1 = min.Z + 0.5 * delta1;
144  points.resize(n0 * n1);
145  for (std::size_t i = 0; i < n0; i++)
146  {
147  for (std::size_t j = 0; j < n1; j++)
148  {
149  points[i * n1 + j].coordinates.setYZ(start0 + delta0 * i, start1 + delta1 * j);
150  }
151  }
152 }

References constants::i, Vec3D::Y, and Vec3D::Z.

◆ spaceEvenly() [10/10]

template<typename T >
std::enable_if<std::is_base_of<CGCoordinates::Z, typename T::CoordinatesType>::value, void>::type CGCoordinates::spaceEvenly ( Vec3D  min,
Vec3D  max,
std::vector< std::size_t >  nAll,
std::vector< T > &  points 
)

See spaceEvenly for details.

129 {
130  std::size_t n = nAll[2];
131  Mdouble delta = (max.Z - min.Z) / n;
132  Mdouble start = min.Z + 0.5 * delta;
133  points.resize(n);
134  for (std::size_t i = 0; i < n; i++)
135  {
136  points[i].coordinates.setZ(start + delta * i);
137  }
138 }

References constants::i, n, and Vec3D::Z.