24#ifndef HYPERPLANE_LATTICE_2D_HH
25#define HYPERPLANE_LATTICE_2D_HH
33int HyperplaneLattice2D<T>::computeMaxLatticeDistance()
const
35 const Cuboid2D<T>& cuboid = _geometry.getMotherCuboid();
36 const Vector<T,2> origin = cuboid.getOrigin();
37 const Vector<int,2> extend = cuboid.getExtent();
38 const T deltaR = cuboid.getDeltaR();
40 T maxPhysDistance = T();
45 for (
int iDim=0; iDim<2; ++iDim) {
46 tmpO[iDim] = origin[iDim] - _origin[iDim];
47 tmpE[iDim] = origin[iDim] + extend[iDim]*deltaR - _origin[iDim];
49 tmp =
util::sqrt(tmpO[0]*tmpO[0] + tmpO[1]*tmpO[1]);
50 if (maxPhysDistance < tmp) {
51 maxPhysDistance = tmp;
53 tmp =
util::sqrt((tmpE[0]*tmpE[0] + tmpO[1]*tmpO[1]));
54 if (maxPhysDistance < tmp) {
55 maxPhysDistance = tmp;
57 tmp =
util::sqrt(tmpO[0]*tmpO[0] + tmpE[1]*tmpE[1]);
58 if (maxPhysDistance < tmp) {
59 maxPhysDistance = tmp;
61 tmp =
util::sqrt(tmpE[0]*tmpE[0] + tmpE[1]*tmpE[1]);
62 if (maxPhysDistance < tmp) {
63 maxPhysDistance = tmp;
66 return int(maxPhysDistance/_h) + 1;
70void HyperplaneLattice2D<T>::constructCuboid(
int maxLatticeDistance)
73 int min = -maxLatticeDistance;
74 int max = maxLatticeDistance;
76 for (
int i = -maxLatticeDistance; i < maxLatticeDistance; ++i ) {
77 if ( _geometry.getC(getPhysR(i), iC) ) {
82 for (
int i = maxLatticeDistance; i > -maxLatticeDistance; --i ) {
83 if ( _geometry.getC(getPhysR(i), iC) ) {
90 _origin = _origin + T(min)*_u;
94void HyperplaneLattice2D<T>::setToResolution(
int resolution)
96 T newH = _n*_h/(T) resolution;
105 : _geometry(geometry),
106 _hyperplane(hyperplane),
107 _origin(hyperplane.origin),
109 _h(geometry.getMinDeltaR())
113 const int maxLatticeDistance = computeMaxLatticeDistance();
115 constructCuboid(maxLatticeDistance);
121 : _geometry(geometry),
122 _hyperplane(hyperplane),
123 _origin(hyperplane.origin),
125 _h(geometry.getMinDeltaR())
129 const int maxLatticeDistance = computeMaxLatticeDistance();
131 constructCuboid(maxLatticeDistance);
133 if ( resolution > 0 ) {
134 setToResolution(resolution);
141 : _geometry(geometry),
142 _hyperplane(hyperplane),
143 _origin(hyperplane.origin),
148 _h = _geometry.getMinDeltaR();
153 const int maxLatticeDistance = computeMaxLatticeDistance();
155 constructCuboid(maxLatticeDistance);
168 _origin[0] + T(n)*_u[0],
169 _origin[1] + T(n)*_u[1]
A cuboid structure represents the grid of a considered domain.
HyperplaneLattice2D(CuboidGeometry2D< T > &geometry, Hyperplane2D< T > hyperplane)
Constructor for automatic discretization.
Vector< T, 2 > getPhysR(const int &n) const
Transform 1d lattice coordinates to their physical 2d location.
T _h
Distance between discrete lattice points.
const Hyperplane2D< T > & getHyperplane() const
Vector< T, 2 > getPhysOrigin() const
Vector< T, 2 > getVectorU() const
Vector< T, 2 > _u
Direction vector of the lattice, normalized to grid width _h.
Pack< T > min(Pack< T > rhs, Pack< T > lhs)
Pack< T > max(Pack< T > rhs, Pack< T > lhs)
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
bool nearZero(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
constexpr Vector< T, D > normalize(const ScalarVector< T, D, IMPL > &a, T scale=T{1})
Definition of a analytical line embedded in 2D space.