OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | List of all members
olb::VortexMethodPreProcessor Struct Reference

#include <vortexMethod.h>

+ Collaboration diagram for olb::VortexMethodPreProcessor:

Public Types

using parameters
 

Public Member Functions

int getPriority () const
 
template<typename CELL , typename PARAMETERS , typename V = typename CELL::value_t>
Vector< V, 3 > computeVelocityGradient (CELL &cell, PARAMETERS &parameters) any_platform
 
template<typename CELL , typename PARAMETERS >
void apply (CELL &cell, PARAMETERS &parameters) any_platform
 

Static Public Attributes

static constexpr OperatorScope scope = OperatorScope::PerCellWithParameters
 

Detailed Description

Definition at line 296 of file vortexMethod.h.

Member Typedef Documentation

◆ parameters

Initial value:
meta::list<
SEEDS_COUNT,
SEEDS,
SEEDS_VORTICITY,
CONVERSION_FACTOR_LENGTH,
CONVERSION_FACTOR_VELOCITY,
AXIS_DIRECTION,
SIGMA
>

Definition at line 297 of file vortexMethod.h.

Member Function Documentation

◆ apply()

template<typename CELL , typename PARAMETERS >
void olb::VortexMethodPreProcessor::apply ( CELL & cell,
PARAMETERS & parameters )
inline

Definition at line 336 of file vortexMethod.h.

336 {
337 using V = typename CELL::value_t;
338 using DESCRIPTOR = typename CELL::descriptor_t;
339
340 const auto seeds = parameters.template get<SEEDS>();
341 const auto seedsVorticity = parameters.template get<SEEDS_VORTICITY>();
342 const auto axisDirection = parameters.template get<AXIS_DIRECTION>();
343 const auto sigma = parameters.template get<SIGMA>();
344
345 Vector<V,DESCRIPTOR::d> x = cell.template getField<descriptors::LOCATION>();
346 Vector<V,DESCRIPTOR::d> output = cell.template getField<U_PROFILE>();
347 const V conversionFactorVelocity = parameters.template get<CONVERSION_FACTOR_VELOCITY>();
348 output /= conversionFactorVelocity;
349
350 // calculation of velocities from the placed vortexes
351 Vector<V,3> uVortex {0, 0, 0};
352 for (std::size_t j=0; j < parameters.template get<SEEDS_COUNT>(); ++j) {
353 Vector<V,DESCRIPTOR::d> diffX = {0,0,0};
354 for (int iD = 0; iD < DESCRIPTOR::d; ++iD) {
355 diffX[iD] = seeds[iD][j] - x[iD];
356 }
357 Vector<V,3> crossP = crossProduct3D(diffX, axisDirection);
358 V norm2 = diffX[0]*diffX[0] + diffX[1]*diffX[1] + diffX[2]*diffX[2];
359 V expTerm = util::exp(V{-0.5}*norm2/(sigma*sigma));
360 uVortex += (V{0.5}/M_PI * seedsVorticity[j] * crossP / norm2 * (V{1} - expTerm)*expTerm) / conversionFactorVelocity;
361 }
362
363 // calculation of the fluctuation streamwise with Langevin equation
364 auto grad = computeVelocityGradient(cell, parameters);
365 V normGrad = olb::norm(grad);
366 if (normGrad == V{0}) {
367 normGrad = 1;
368 }
369 V streamFluct = -(uVortex*grad);
370 streamFluct /= normGrad;
371
372 output += uVortex + streamFluct * axisDirection;
373
374 cell.defineU(output.data());
375 }
#define M_PI
T norm2(const std::vector< T > &a)
l2 norm to the power of 2 of a vector of arbitrary length
ADf< T, DIM > exp(const ADf< T, DIM > &a)
Definition aDiff.h:455
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.
constexpr Vector< T, 3 > crossProduct3D(const ScalarVector< T, 3, IMPL > &a, const ScalarVector< T, 3, IMPL_ > &b) any_platform
Definition vector.h:224
Vector< V, 3 > computeVelocityGradient(CELL &cell, PARAMETERS &parameters) any_platform
meta::list< SEEDS_COUNT, SEEDS, SEEDS_VORTICITY, CONVERSION_FACTOR_LENGTH, CONVERSION_FACTOR_VELOCITY, AXIS_DIRECTION, SIGMA > parameters

References computeVelocityGradient(), olb::crossProduct3D(), olb::Vector< T, D >::data(), olb::util::exp(), M_PI, and olb::norm().

+ Here is the call graph for this function:

◆ computeVelocityGradient()

template<typename CELL , typename PARAMETERS , typename V = typename CELL::value_t>
Vector< V, 3 > olb::VortexMethodPreProcessor::computeVelocityGradient ( CELL & cell,
PARAMETERS & parameters )
inline

Definition at line 314 of file vortexMethod.h.

315 {
316 const V dx = parameters.template get<CONVERSION_FACTOR_LENGTH>();
317 Vector<V,3> actVel = cell.template getField<VELOCITY_OLD>();
318 V aXPlus = util::max(actVel[0], 0); V aXMinus = util::min(actVel[0], 0);
319 V aYPlus = util::max(actVel[1], 0); V aYMinus = util::min(actVel[1], 0);
320 V aZPlus = util::max(actVel[2], 0); V aZMinus = util::min(actVel[2], 0);
321 Vector<V,3> uXPlus = cell.neighbor({ 1, 0, 0}).template getField<VELOCITY_OLD>();
322 Vector<V,3> uXMinus = cell.neighbor({-1, 0, 0}).template getField<VELOCITY_OLD>();
323 Vector<V,3> uYPlus = cell.neighbor({ 0, 1, 0}).template getField<VELOCITY_OLD>();
324 Vector<V,3> uYMinus = cell.neighbor({ 0, -1, 0}).template getField<VELOCITY_OLD>();
325 Vector<V,3> uZPlus = cell.neighbor({ 0, 0, 1}).template getField<VELOCITY_OLD>();
326 Vector<V,3> uZMinus = cell.neighbor({ 0, 0, -1}).template getField<VELOCITY_OLD>();
327 Vector<V,3> grad;
328 const V actVelNorm = olb::norm(actVel);
329 grad[0] = -aXPlus*(actVelNorm - olb::norm(uXMinus))/dx - aXMinus*(olb::norm(uXPlus) - actVelNorm)/dx;
330 grad[1] = -aYPlus*(actVelNorm - olb::norm(uYMinus))/dx - aYMinus*(olb::norm(uYPlus) - actVelNorm)/dx;
331 grad[2] = -aZPlus*(actVelNorm - olb::norm(uZMinus))/dx - aZMinus*(olb::norm(uZPlus) - actVelNorm)/dx;
332 return grad;
333 }
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130

References olb::util::max(), olb::util::min(), and olb::norm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPriority()

int olb::VortexMethodPreProcessor::getPriority ( ) const
inline

Definition at line 309 of file vortexMethod.h.

309 {
310 return 0;
311 }

Member Data Documentation

◆ scope

constexpr OperatorScope olb::VortexMethodPreProcessor::scope = OperatorScope::PerCellWithParameters
staticconstexpr

Definition at line 307 of file vortexMethod.h.


The documentation for this struct was generated from the following file: