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.
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 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
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
int delta
Definition: MultiOpt.py:96
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References MultiOpt::delta, i, j, k, max, min, n, and oomph::CumulativeTimings::start().

◆ 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.

82 {
83  points.resize(1);
84 }

◆ 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
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 }
double Mdouble
Definition: GeneralDefine.h:13
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

References MultiOpt::delta, i, logger, max, min, n, oomph::CumulativeTimings::start(), and WARN.

◆ 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.

117 {
118  std::size_t n0 = nAll[0];
119  std::size_t n1 = nAll[2];
120  Mdouble delta0 = (max.X - min.X) / n0;
121  Mdouble delta1 = (max.Z - min.Z) / n1;
122  Mdouble start0 = min.X + 0.5 * delta0;
123  Mdouble start1 = min.Z + 0.5 * delta1;
124  points.resize(n0 * n1);
125  for (std::size_t i = 0; i < n0; i++)
126  {
127  for (std::size_t j = 0; j < n1; j++)
128  {
129  points[i * n1 + j].coordinates.setRZ(start0 + delta0 * i, start1 + delta1 * j);
130  }
131  }
132 }

References i, j, max, and min.

◆ 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.

108 {
109  std::size_t n = nAll[0];
110  Mdouble delta = (max.X - min.X) / n;
111  Mdouble start = min.X + 0.5 * delta;
112  points.resize(n);
113  for (std::size_t i = 0; i < n; i++)
114  {
115  points[i].coordinates.setX(start + delta * i);
116  }
117 }

References MultiOpt::delta, i, max, min, n, and oomph::CumulativeTimings::start().

◆ 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.

117 {
118  std::size_t n0 = nAll[0];
119  std::size_t n1 = nAll[1];
120  Mdouble delta0 = (max.X - min.X) / n0;
121  Mdouble delta1 = (max.Y - min.Y) / n1;
122  Mdouble start0 = min.X + 0.5 * delta0;
123  Mdouble start1 = min.Y + 0.5 * delta1;
124  points.resize(n0 * n1);
125  for (std::size_t i = 0; i < n0; i++)
126  {
127  for (std::size_t j = 0; j < n1; j++)
128  {
129  points[i * n1 + j].coordinates.setXY(start0 + delta0 * i, start1 + delta1 * j);
130  }
131  }
132 }

References i, j, max, and min.

◆ 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.

117 {
118  std::size_t n0 = nAll[0];
119  std::size_t n1 = nAll[2];
120  Mdouble delta0 = (max.X - min.X) / n0;
121  Mdouble delta1 = (max.Z - min.Z) / n1;
122  Mdouble start0 = min.X + 0.5 * delta0;
123  Mdouble start1 = min.Z + 0.5 * delta1;
124  points.resize(n0 * n1);
125  for (std::size_t i = 0; i < n0; i++)
126  {
127  for (std::size_t j = 0; j < n1; j++)
128  {
129  points[i * n1 + j].coordinates.setXZ(start0 + delta0 * i, start1 + delta1 * j);
130  }
131  }
132 }

References i, j, max, and min.

◆ 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.

106 {
107  std::size_t n = nAll[1];
108  Mdouble delta = (max.Y - min.Y) / n;
109  Mdouble start = min.Y + 0.5 * delta;
110  points.resize(n);
111  for (std::size_t i = 0; i < n; i++)
112  {
113  points[i].coordinates.setY(start + delta * i);
114  }
115 }

References MultiOpt::delta, i, max, min, n, and oomph::CumulativeTimings::start().

◆ 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.

117 {
118  std::size_t n0 = nAll[1];
119  std::size_t n1 = nAll[2];
120  Mdouble delta0 = (max.Y - min.Y) / n0;
121  Mdouble delta1 = (max.Z - min.Z) / n1;
122  Mdouble start0 = min.Y + 0.5 * delta0;
123  Mdouble start1 = min.Z + 0.5 * delta1;
124  points.resize(n0 * n1);
125  for (std::size_t i = 0; i < n0; i++)
126  {
127  for (std::size_t j = 0; j < n1; j++)
128  {
129  points[i * n1 + j].coordinates.setYZ(start0 + delta0 * i, start1 + delta1 * j);
130  }
131  }
132 }

References i, j, max, and min.

◆ 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.

109 {
110  std::size_t n = nAll[2];
111  Mdouble delta = (max.Z - min.Z) / n;
112  Mdouble start = min.Z + 0.5 * delta;
113  points.resize(n);
114  for (std::size_t i = 0; i < n; i++)
115  {
116  points[i].coordinates.setZ(start + delta * i);
117  }
118 }

References MultiOpt::delta, i, max, min, n, and oomph::CumulativeTimings::start().