24#ifndef LATTICE_STOKES_DRAG_FORCE_HH
25#define LATTICE_STOKES_DRAG_FORCE_HH
32template<
typename T,
typename DESCRIPTOR,
typename PARTICLETYPE,
bool serialize>
41 const std::unordered_set<int>& ignoredMaterials,
44 (DESCRIPTOR::d)*(particleSystem.size()-iP0)),
45 _blockGeometry(blockGeometry), _blockLattice(blockLattice),
46 _particleSystem(particleSystem),
47 _cellMin(cellMin), _cellMax(cellMax), _periodic(periodic),
48 _iP0(iP0), _ignoredMaterials(ignoredMaterials), _f(f)
50 this->getName() =
"physStokesDragForce";
52 _delTinv = 1./this->_converter.getPhysDeltaT();
59template<
typename T,
typename DESCRIPTOR,
typename PARTICLETYPE,
bool serialize>
63 constexpr unsigned D = DESCRIPTOR::d;
64 const int serialSize = D;
66 using namespace descriptors;
69 Vector<T,D> position = particle.template getField<GENERAL,POSITION>();
70 Vector<T,D> velocity = particle.template getField<MOBILITY,VELOCITY>();
71 T radius = particle.template getField<PHYSPROPERTIES,RADIUS>();
72 T mass = particle.template getField<PHYSPROPERTIES,MASS>();
73 T* positionArray = position.
data();
76 const auto& cuboid = _blockGeometry.getCuboid();
78 _blockLattice, this->_converter, cuboid);
81 T c = _C1 * radius * 1./mass;
84 T fluidVelArray[D] = {0.};
88 if constexpr ( !particles::access::providesParallelization<PARTICLETYPE>() ){
89 inside = cuboid.checkPoint(position);
94 blockInterpPhysVelF(fluidVelArray, positionArray);
97 if constexpr( PARTICLETYPE::template providesNested<MOBILITY,FLUIDVEL>() ){
98 particle.template setField<MOBILITY, FLUIDVEL>(fluidVelArray);
103 for (
int iDim = 0; iDim < PARTICLETYPE::d; ++iDim) {
104 tmpForce[iDim] = mass * _delTinv
105 * ((c * fluidVelArray[iDim] + velocity[iDim]) * C2 - velocity[iDim]);
112 if constexpr (serialize){
113 std::size_t iPeval = iP-_iP0;
114 for (
unsigned iDim=0; iDim<D; iDim++) {
115 output[iDim+iPeval*serialSize] += tmpForce[iDim];
119 particle.template setField<FORCING,FORCE>( tmpForce );
126template<
typename T,
typename DESCRIPTOR,
typename PARTICLETYPE,
bool serialize>
129 using namespace descriptors;
131 for (std::size_t iP=_iP0; iP!=_particleSystem.size(); iP++) {
132 auto particle = _particleSystem.get(iP);
134 evaluate(output, particle, iP);
Representation of a block geometry.
bool operator()(T output[], const int input[]) override
void evaluate(T output[], particles::Particle< T, PARTICLETYPE > &particle, int iP)
BlockLatticeStokesDragForce(BlockLattice< T, DESCRIPTOR > &blockLattice, const BlockGeometry< T, DESCRIPTOR::d > &blockGeometry, particles::ParticleSystem< T, PARTICLETYPE > &particleSystem, const UnitConverter< T, DESCRIPTOR > &converter, PhysR< T, DESCRIPTOR::d > cellMin=PhysR< T, DESCRIPTOR::d >(0.), PhysR< T, DESCRIPTOR::d > cellMax=PhysR< T, DESCRIPTOR::d >(0.), Vector< bool, DESCRIPTOR::d > periodic=Vector< bool, DESCRIPTOR::d >(false), std::size_t iP0=0, const std::unordered_set< int > &ignoredMaterials=std::unordered_set< int >{}, const F f=[](auto &, const auto &, const auto &, const auto &){})
Platform-abstracted block lattice for external access and inter-block interaction.
Conversion between physical and lattice units, as well as discretization.
constexpr T getPhysDensity() const
return density in physical units
constexpr T getPhysViscosity() const
return viscosity in physical units
constexpr T getConversionFactorTime() const
access (read-only) to private member variable
constexpr const T * data() const any_platform
bool isValid(Particle< T, PARTICLETYPE > particle)
Top level namespace for all of OpenLB.
std::conditional_t< DESCRIPTOR::d==2, BlockLatticeInterpPhysVelocity2D< T, DESCRIPTOR >, BlockLatticeInterpPhysVelocity3D< T, DESCRIPTOR > > BlockLatticeInterpPhysVelocity
std::conditional_t< DESCRIPTOR::d==2, BlockLatticePhysF2D< T, DESCRIPTOR >, BlockLatticePhysF3D< T, DESCRIPTOR > > BlockLatticePhysF
Converts dimensions by deriving from given cartesian dimension D.