26#ifndef REDUCTION_F_3D_HH
27#define REDUCTION_F_3D_HH
30#define M_PI 3.14159265358979323846
39template<
typename T,
typename DESCRIPTOR>
46 this->
getName() =
"fromAnalyticalF(" +
_f->getName() +
")";
51 for (
int iC = 0; iC < load.
size(); ++iC) {
61template<
typename T,
typename DESCRIPTOR>
63 T output[],
const int input[])
66 this->_sLattice.getCuboidGeometry().getPhysR(physR,input);
67 return _f(output,physR);
71template<
typename T,
typename DESCRIPTOR>
80 this->
getName() =
"blockFfromAnalyticalF(" +
_f.getName() +
")";
83template<
typename T,
typename DESCRIPTOR>
85 T output[],
const int input[])
88 _cuboid.getPhysR(physR,input);
89 return _f(output,physR);
95template<
typename T,
typename DESCRIPTOR>
98 :
BlockDataF3D<T, T>((int)((f.getMax()[0] - f.getMin()[0]) / h + ( util::round(eps*0.5)*2+2 )),
99 (int)((f.getMax()[1] - f.getMin()[1]) / h + ( util::round(eps*0.5)*2+2 )),
100 (int)((f.getMax()[2] - f.getMin()[2]) / h + ( util::round(eps*0.5)*2+2 ))),
103 _eps(util::round(eps*0.5)*2),
107 this->
getName() =
"SmoothBlockIndicator3D";
109 T weights[this->
_wa][this->
_wa][this->
_wa];
115 for (
int x = -iStart; x < iEnd; ++x) {
116 for (
int y = -iStart; y < iEnd; ++y) {
117 for (
int z = -iStart; z < iEnd; ++z) {
120 sum += weights[x+iStart][y+iStart][z+iStart];
124 const T invSum = 1./sum;
143 for (
int x = -iStart; x < iEnd; ++x) {
144 for (
int y = -iStart; y < iEnd; ++y) {
145 for (
int z = -iStart; z < iEnd; ++z) {
159 value += output[0] * weights[x+iStart][y+iStart][z+iStart];
189template<
typename T,
typename DESCRIPTOR>
195 this->
getName() =
"Interp3DegreeVelocity";
196 int maxC = this->
_sLattice.getLoadBalancer().size();
198 for (
int iC = 0; iC < maxC; iC++) {
206 _bLattices.push_back(foo);
210template<
typename T,
typename DESCRIPTOR>
212 T output[],
const T input[],
const int iC)
214 _bLattices[this->_sLattice.getLoadBalancer().loc(iC)]->operator()(output,
218template<
typename T,
typename DESCRIPTOR>
228 this->
getName() =
"BlockLatticeInterpVelocity3Degree3D";
231template<
typename T,
typename DESCRIPTOR>
237 _cuboid(rhs._cuboid),
242template<
typename T,
typename DESCRIPTOR>
244 T output[3],
const T input[3])
247 int latIntPos[3] = {0};
248 T latPhysPos[3] = {T()};
249 _cuboid->getFloorLatticeR(latIntPos, &input[0]);
250 _cuboid->getPhysR(latPhysPos, latIntPos);
253 for (
int i = -_range; i <= _range+1; ++i) {
254 for (
int j = -_range; j <= _range+1; ++j) {
255 for (
int k = -_range; k <= _range+1; ++k) {
257 this->_blockLattice.get(latIntPos[0]+i, latIntPos[1]+j,
258 latIntPos[2]+k).computeRhoU(rho, u);
259 for (
int l = -_range; l <= _range+1; ++l) {
261 volume *= (input[0] - (latPhysPos[0]+ l *_cuboid->getDeltaR()))
262 / (latPhysPos[0] + i *_cuboid->getDeltaR()
263 - (latPhysPos[0] + l *_cuboid->getDeltaR()));
266 for (
int m = -_range;
m <= _range+1; ++
m) {
269 - (latPhysPos[1] +
m *_cuboid->getDeltaR()))
270 / (latPhysPos[1] + j * _cuboid->getDeltaR()
271 - (latPhysPos[1] +
m * _cuboid->getDeltaR()));
274 for (
int n = -_range; n <= _range+1; ++n) {
277 - (latPhysPos[2] + n * _cuboid->getDeltaR()))
278 / (latPhysPos[2] + k * _cuboid->getDeltaR()
279 - (latPhysPos[2] + n * _cuboid->getDeltaR()));
282 output[0] += u[0] * volume;
283 output[1] += u[1] * volume;
284 output[2] += u[2] * volume;
290 output[0] = _conv.getPhysVelocity(output[0]);
291 output[1] = _conv.getPhysVelocity(output[1]);
292 output[2] = _conv.getPhysVelocity(output[2]);
296template<
typename T,
typename DESCRIPTOR>
302 this->
getName() =
"Interp3DegreeDensity";
303 int maxC = this->
_sLattice.getLoadBalancer().size();
305 for (
int lociC = 0; lociC < maxC; lociC++) {
306 int globiC = this->
_sLattice.getLoadBalancer().glob(lociC);
315 _bLattices.push_back(foo);
318 std::cout <<
"lattice overlap has to be larger than (range + 1)"
323template<
typename T,
typename DESCRIPTOR>
327 for (
auto it : _bLattices) {
334template<
typename T,
typename DESCRIPTOR>
336 const T input[],
const int globiC)
339 _bLattices[this->_sLattice.getLoadBalancer().loc(globiC)]->operator()(output,
344template<
typename T,
typename DESCRIPTOR>
349 BlockLatticeF3D<T, DESCRIPTOR>(blockLattice, 3), _blockGeometry(blockGeometry),
350 _conv(conv), _cuboid(c), _range(range)
352 this->
getName() =
"BlockLatticeInterpDensity3Degree3D";
355template<
typename T,
typename DESCRIPTOR>
359 _blockGeometry(rhs._blockGeometry),_conv(rhs._conv), _cuboid(
360 rhs._cuboid), _range(rhs._range)
364template<
typename T,
typename DESCRIPTOR>
366 T output[DESCRIPTOR::q],
const T input[3])
373 int latIntPos[3] = { 0 };
375 T latPhysPos[3] = { T() };
377 _cuboid->getFloorLatticeR(latIntPos, input);
379 _cuboid->getPhysR(latPhysPos, latIntPos);
381 for (
unsigned iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
383 for (
int i = -_range; i <= _range + 1; ++i) {
384 for (
int j = -_range; j <= _range + 1; ++j) {
385 for (
int k = -_range; k <= _range + 1; ++k) {
388 if (_blockGeometry.getMaterial({latIntPos[0] + i, latIntPos[1] + j,
389 latIntPos[2] + k}) != 0) {
392 f_iPop = this->_blockLattice.get(latIntPos[0] + i, latIntPos[1] + j,
393 latIntPos[2] + k)[iPop];
395 for (
int l = -_range; l <= _range + 1; ++l) {
397 volume *= (input[0] - (latPhysPos[0] + l * _cuboid->getDeltaR()))
398 / (latPhysPos[0] + i * _cuboid->getDeltaR()
399 - (latPhysPos[0] + l * _cuboid->getDeltaR()));
402 for (
int m = -_range; m <= _range + 1; ++m) {
404 volume *= (input[1] - (latPhysPos[1] + m * _cuboid->getDeltaR()))
405 / (latPhysPos[1] + j * _cuboid->getDeltaR()
406 - (latPhysPos[1] + m * _cuboid->getDeltaR()));
409 for (
int n = -_range; n <= _range + 1; ++n) {
411 volume *= (input[2] - (latPhysPos[2] + n * _cuboid->getDeltaR()))
412 / (latPhysPos[2] + k * _cuboid->getDeltaR()
413 - (latPhysPos[2] + n * _cuboid->getDeltaR()));
416 output[iPop] += f_iPop * volume;
424template<
typename T,
typename DESCRIPTOR>
430 this->
getName() =
"SuperLatticeSmoothDiracDelta3D";
431 int maxC = this->
_sLattice.getLoadBalancer().size();
433 for (
int lociC = 0; lociC < maxC; lociC++) {
434 int globiC = this->
_sLattice.getLoadBalancer().glob(lociC);
441 _bLattices.push_back(foo);
445template<
typename T,
typename DESCRIPTOR>
448 for (
auto it : _bLattices) {
454template<
typename T,
typename DESCRIPTOR>
456 const T physPos[3],
const int globiC)
459 _bLattices[this->_sLattice.getLoadBalancer().loc(globiC)]->operator()(delta,
464template<
typename T,
typename DESCRIPTOR>
467 :
BlockLatticeF3D<T, DESCRIPTOR>(blockLattice, 3), _conv(conv), _cuboid(cuboid)
469 this->
getName() =
"BlockLatticeSmoothDiracDelta3D";
472template<
typename T,
typename DESCRIPTOR>
476 BlockLatticeF3D<T, DESCRIPTOR>(rhs._blockLattice, 3), _conv(rhs._conv), _cuboid(rhs._cuboid)
480template<
typename T,
typename DESCRIPTOR>
482 T delta[4][4][4],
const T physPos[])
486 int latticeRoundedPosP[3] = { 0 };
487 T physRoundedPosP[3] = { T() };
488 T physLatticeL = _conv.getConversionFactorLength();
492 _cuboid->getLatticeR(latticeRoundedPosP, physPos);
493 _cuboid->getPhysR(physRoundedPosP, latticeRoundedPosP);
495 for (
int i = -range; i <= range + 1; ++i) {
496 for (
int j = -range; j <= range + 1; ++j) {
497 for (
int k = -range; k <= range + 1; ++k) {
498 delta[i+range][j+range][k+range] = T(1);
500 a = (physRoundedPosP[0] + i * physLatticeL - physPos[0])
502 b = (physRoundedPosP[1] + j * physLatticeL - physPos[1])
504 c = (physRoundedPosP[2] + k * physLatticeL - physPos[2])
508 delta[i+range][j+range][k+range] *= 1. / 4 * (1 +
util::cos(
M_PI * a / 2.));
509 delta[i+range][j+range][k+range] *= 1. / 4 * (1 +
util::cos(
M_PI * b / 2.));
510 delta[i+range][j+range][k+range] *= 1. / 4 * (1 +
util::cos(
M_PI * c / 2.));
512 counter += delta[i+range][j+range][k+range];
AnalyticalF are applications from DD to XD, where X is set by the constructor.
BlockDataF3D can store data of any BlockFunctor3D.
BlockData< 3, T, T > & getBlockData()
returns _blockData
U & get(std::size_t iCell, int iD=0)
Representation of a block geometry.
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
Block level functor for conversion of analytical to lattice functors.
AnalyticalF3D< T, T > & _f
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeFfromAnalyticalF3D(AnalyticalF3D< T, T > &f, BlockLattice< T, DESCRIPTOR > &lattice, Cuboid3D< T > &cuboid)
BlockLatticeInterpDensity3Degree3D(BlockLattice< T, DESCRIPTOR > &blockLattice, BlockGeometry< T, 3 > &blockGeometry, UnitConverter< T, DESCRIPTOR > &conv, Cuboid3D< T > *c, int range)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeInterpPhysVelocity3Degree3D(BlockLattice< T, DESCRIPTOR > &blockLattice, UnitConverter< T, DESCRIPTOR > &conv, Cuboid3D< T > *c, int range)
BlockLatticeSmoothDiracDelta3D(BlockLattice< T, DESCRIPTOR > &blockLattice, UnitConverter< T, DESCRIPTOR > &conv, Cuboid3D< T > *c)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
Platform-abstracted block lattice for external access and inter-block interaction.
int getNy() const
Read only access to block height.
int getNx() const
Read only access to block width.
int getNz() const
Read only access to block height.
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
A cuboid geometry represents a voxel mesh.
Cuboid3D< T > & get(int iC)
Read and write access to a single cuboid.
Smart pointer for managing the various ways of passing functors around.
std::string & getName()
read and write access to name
IndicatorF3D is an application from .
virtual Vector< S, 3 > & getMin()
Base class for all LoadBalancer.
const int _wa
size of the matrix of weight coefficients (from 3D Gaussian Function) _wa x _wa x _wa
SmoothBlockIndicator3D(IndicatorF3D< T > &f, T h, T eps, T sigma)
const T _h
Lattice spacing of the particle grid.
IndicatorF3D< T > & _f
_f holds the geometry
const T _sigma
Important parameter for the Gaussian point spread Function (standard deviations)
std::vector< std::unique_ptr< BlockF3D< T > > > _blockF
Super functors may consist of several BlockF3D<W> derived functors.
Representation of a statistic for a parallel 2D geometry.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
represents all functors that operate on a SuperLattice in general, e.g. getVelocity(),...
SuperLattice< T, DESCRIPTOR > & _sLattice
bool operator()(T output[], const int input[]) override
FunctorPtr< AnalyticalF3D< T, T > > _f
SuperLatticeFfromAnalyticalF3D(FunctorPtr< AnalyticalF3D< T, T > > &&f, SuperLattice< T, DESCRIPTOR > &sLattice)
SuperLatticeInterpDensity3Degree3D(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 3 > &sGeometry, UnitConverter< T, DESCRIPTOR > &conv, int range=1)
bool operator()(T output[], const int input[]) override
~SuperLatticeInterpDensity3Degree3D() override
bool operator()(T output[], const int input[]) override
SuperLatticeInterpPhysVelocity3Degree3D(SuperLattice< T, DESCRIPTOR > &sLattice, UnitConverter< T, DESCRIPTOR > &conv, int range=1)
SuperLatticeSmoothDiracDelta3D(SuperLattice< T, DESCRIPTOR > &sLattice, UnitConverter< T, DESCRIPTOR > &conv, SuperGeometry< T, 3 > &superGeometry)
bool operator()(T output[], const int input[]) override
~SuperLatticeSmoothDiracDelta3D() override
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.
int getOverlap()
Read and write access to the overlap.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Conversion between physical and lattice units, as well as discretization.
int getRank() const
Returns the process ID.
platform_constant int c[Q][D]
constexpr T m(unsigned iPop, unsigned jPop, tag::MRT)
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
ADf< T, DIM > ceil(const ADf< T, DIM > &a)
ADf< T, DIM > floor(const ADf< T, DIM > &a)
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
ADf< T, DIM > exp(const ADf< T, DIM > &a)
ADf< T, DIM > cos(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.