OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE > Class Template Referencefinal

Functor that returns forces acting on a particle surface, returns data in output for every particle in a row(described are return values for the first particle). More...

#include <latticeMomentumExchangeForce.h>

+ Inheritance diagram for olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE >:
+ Collaboration diagram for olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE >:

Public Member Functions

 BlockLatticeMomentumExchangeForce (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 &){})
 
void evaluate (T output[], particles::Particle< T, PARTICLETYPE > &particle, int iP)
 
bool operator() (T output[], const int input[]) override
 

Static Public Attributes

static constexpr bool serializeForce = true
 

Detailed Description

template<typename T, typename DESCRIPTOR, typename PARTICLETYPE>
class olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE >

Functor that returns forces acting on a particle surface, returns data in output for every particle in a row(described are return values for the first particle).

Returns
output[0]-output[2] translational force - physical units
output[3]-output[5] torque - physical units
output[7] number of voxels

Definition at line 49 of file latticeMomentumExchangeForce.h.

Constructor & Destructor Documentation

◆ BlockLatticeMomentumExchangeForce()

template<typename T , typename DESCRIPTOR , typename PARTICLETYPE >
olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE >::BlockLatticeMomentumExchangeForce ( 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&){} )

Definition at line 86 of file latticeMomentumExchangeForce.hh.

94 : BlockLatticePhysF<T,DESCRIPTOR>(blockLattice, converter,
95 (DESCRIPTOR::d+utilities::dimensions::convert<DESCRIPTOR::d>::rotation+1)*(particleSystem.size()-iP0)),
96 _blockGeometry(blockGeometry), _blockLattice(blockLattice),
97 _particleSystem(particleSystem),
98 _cellMin(cellMin), _cellMax(cellMax), _periodic(periodic),
99 _iP0(iP0), _ignoredMaterials(ignoredMaterials), _f(f)
100{
101 this->getName() = "physMomentumExchangeForce";
102}

Member Function Documentation

◆ evaluate()

template<typename T , typename DESCRIPTOR , typename PARTICLETYPE >
void olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE >::evaluate ( T output[],
particles::Particle< T, PARTICLETYPE > & particle,
int iP )

Definition at line 105 of file latticeMomentumExchangeForce.hh.

106{
107 constexpr unsigned D = DESCRIPTOR::d;
108 constexpr unsigned Drot = utilities::dimensions::convert<D>::rotation; //TODO: prevent rotation calculatiion, when no angle
109 constexpr int serialSize = D+Drot+1;
110
111 using namespace descriptors;
112 const PhysR<T, D> position = particles::access::getPosition(particle);
113 const T circumRadius = particles::access::getRadius(particle);
114
115 //For all cells in block particle intersection
116 int numVoxels = 0;
117 constexpr int padding = 0;
118 const std::size_t iPeval = iP - _iP0; //Shifted output index, if iP!=0
120 _blockLattice, padding, position, circumRadius,
121 [&](const LatticeR<D>& latticeRinner) {
122
123 if (_ignoredMaterials.find(_blockGeometry.getMaterial(latticeRinner)) == _ignoredMaterials.end()) {
124 Vector<T,D>tmpForce(0.);
125 PhysR<T,D> lever(0.);
126 if ( particles::resolved::momentumExchangeAtSurfaceLocation(tmpForce.data(),
127 lever, latticeRinner, this->_blockGeometry,
128 this->_blockLattice, this->_converter, particle) ){
129
130 // count cells of considered object
131 ++numVoxels;
132
133 //Shift centre of mass (for oblique rotation) if offset provided
134 if constexpr ( PARTICLETYPE::template providesNested<SURFACE,COR_OFFSET>() ){
135 lever -= Vector<T,D> ( particle.template getField<SURFACE,COR_OFFSET>() );
136 }
137
138 //Calculate torque
139 const Vector<T,Drot> torque = particles::dynamics::torque_from_force<D,T>::calculate( tmpForce, lever );
140
141 T physR[D] = {0.};
142 this->_blockGeometry.getPhysR(physR, latticeRinner);
143 _f(particle, physR, tmpForce, torque);
144
145 //Add force and torque to output
146 for (unsigned iDim=0; iDim<D; ++iDim) {
147 output[iDim+iPeval*serialSize] += tmpForce[iDim];
148 }
149 for (unsigned iRot=0; iRot<Drot; ++iRot) {
150 output[(iRot+D)+iPeval*serialSize] += torque[iRot];
151 }
152 }
153 }
154 });
155
156 output[D+Drot+iPeval*serialSize] += numVoxels;
157}
int getMaterial(LatticeR< D > latticeR) const
returns the (iX,iY) entry in the 2D scalar field
T getRadius(Particle< T, PARTICLETYPE > &particle)
Vector< T, PARTICLETYPE::d > getPosition(Particle< T, PARTICLETYPE > particle)
void forSpatialLocationsInBlockParticleIntersection(const BlockGeometry< T, DESCRIPTOR::d > &blockGeometry, BlockLattice< T, DESCRIPTOR > &blockLattice, Vector< T, DESCRIPTOR::d > position, T circumRadius, F f)

References olb::particles::forSpatialLocationsInBlockParticleIntersection(), olb::particles::access::getPosition(), and olb::particles::access::getRadius().

+ Here is the call graph for this function:

◆ operator()()

template<typename T , typename DESCRIPTOR , typename PARTICLETYPE >
bool olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE >::operator() ( T output[],
const int input[] )
override

Definition at line 160 of file latticeMomentumExchangeForce.hh.

161{
162 constexpr unsigned D = DESCRIPTOR::d;
163
164 using namespace descriptors;
165
166 //Evaluate periodicity
167 bool anyPeriodic = false;
168 for (unsigned iDim=0; iDim<D; ++iDim) {
169 anyPeriodic = anyPeriodic || _periodic[iDim];
170 }
171
172 // iterate over all particles in _particleSystem
173 for (std::size_t iP=_iP0; iP!=_particleSystem.size(); ++iP) {
174 auto particle = _particleSystem.get(iP);
175 if (particles::access::isValid(particle)){
176 // If any direction requires periodic treatment
177 if (anyPeriodic) {
178 const T circumRadius = particles::access::getRadius(particle);
179 const PhysR<T,D> position = particles::access::getPosition(particle);
180
181 bool surfaceOutOfGeometry = false;
182 PhysR<T,D> ghostPos;
183 particles::checkSmoothIndicatorOutOfGeometry(surfaceOutOfGeometry, ghostPos,
184 _cellMin, _cellMax, position, circumRadius, _periodic);
185
186 if (!surfaceOutOfGeometry) {
187 evaluate(output, particle, iP);
188 }
189 else {
190 // Calculate force for the ghost particle
191 particle.template setField<GENERAL,POSITION>(ghostPos);
192 evaluate(output, particle, iP);
193 // Calculate force of actual particle
194 particle.template setField<GENERAL,POSITION>(position);
195 evaluate(output, particle, iP);
196 }
197 }
198 else {
199 evaluate(output, particle, iP);
200 }
201 }
202 }
203 return true;
204}
void evaluate(T output[], particles::Particle< T, PARTICLETYPE > &particle, int iP)
bool isValid(Particle< T, PARTICLETYPE > particle)
void checkSmoothIndicatorOutOfGeometry(bool &outOfGeometry, Vector< T, D > &ghostPos, const PhysR< T, D > &cellMin, const PhysR< T, D > &cellMax, const Vector< T, D > &position, T circumRadius, const Vector< bool, D > &periodic)

Member Data Documentation

◆ serializeForce

template<typename T , typename DESCRIPTOR , typename PARTICLETYPE >
constexpr bool olb::BlockLatticeMomentumExchangeForce< T, DESCRIPTOR, PARTICLETYPE >::serializeForce = true
staticconstexpr

Definition at line 76 of file latticeMomentumExchangeForce.h.


The documentation for this class was generated from the following files: