OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::SmoothIndicatorCustom2D< T, S, PARTICLE > Class Template Reference

#include <smoothIndicatorF2D.h>

+ Inheritance diagram for olb::SmoothIndicatorCustom2D< T, S, PARTICLE >:
+ Collaboration diagram for olb::SmoothIndicatorCustom2D< T, S, PARTICLE >:

Public Member Functions

 SmoothIndicatorCustom2D (T latticeSpacing, std::shared_ptr< IndicatorF2D< T > > indPtr, Vector< T, 2 > pos, T epsilon, T theta=0.)
 
Vector< T, 2 > getLocalCenter ()
 
getArea () override
 
Vector< T, 2 > calcMofiAndMass (T rhoP) override
 calculates and returns mofi and mass of the particle (mofi is at index 0 and mass at index 1)
 
Vector< S, 2 > surfaceNormal (const Vector< S, 2 > &pos, const S meshSize) override
 
const S signedDistance (const Vector< S, 2 > input) override
 
bool regardCell (int input[2])
 
bool operator() (T output[], const S input[]) override
 

Detailed Description

template<typename T, typename S, bool PARTICLE = false>
class olb::SmoothIndicatorCustom2D< T, S, PARTICLE >

Definition at line 123 of file smoothIndicatorF2D.h.

Constructor & Destructor Documentation

◆ SmoothIndicatorCustom2D()

template<typename T , typename S , bool PARTICLE>
olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::SmoothIndicatorCustom2D ( T latticeSpacing,
std::shared_ptr< IndicatorF2D< T > > indPtr,
Vector< T, 2 > pos,
T epsilon,
T theta = 0. )

Definition at line 283 of file smoothIndicatorF2D.hh.

288 :_indPtr(indPtr),
289 _latticeSpacing(latticeSpacing)
290{
291 OstreamManager clout(std::cout,"createIndicatorCustom2D");
292 this->_name = "custom2D";
293 this->_epsilon = epsilon;
294 if constexpr(!PARTICLE) {
295 this->_pos = pos; // global position of the local center
296 this->_theta = util::degreeToRadian(theta);
297 this->init();
298 }
299
300 initData(*_indPtr);
301}
decltype(Vector< decltype(util::sqrt(T())), D >()) degreeToRadian(const Vector< T, D > &angle)

References olb::util::degreeToRadian().

+ Here is the call graph for this function:

Member Function Documentation

◆ calcMofiAndMass()

template<typename T , typename S , bool PARTICLE>
Vector< T, 2 > olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::calcMofiAndMass ( T rhoP)
override

calculates and returns mofi and mass of the particle (mofi is at index 0 and mass at index 1)

Definition at line 377 of file smoothIndicatorF2D.hh.

378{
379 // TODO - calculation
380 T mofi = 0.;
381 T mass;
382 unsigned nCells = 0;
383 int input[2];
384 for (input[0] = 0; input[0] < this->_blockData->getNx(); ++input[0]) {
385 const T dx = util::abs(input[0]*_latticeSpacing - this->_center[0]);
386 for (input[1] = 0; input[1] < this->_blockData->getNy(); ++input[1]) {
387 if (regardCell(input)) {
388 const T dy = util::abs(input[1]*_latticeSpacing - this->_center[1]);
389 mofi += (dx*dx+dy*dy);
390 ++nCells;
391 }
392 }
393 }
394 _area = nCells * util::pow(_latticeSpacing, 2);
395 mass = rhoP * _area;
396 mofi += util::pow(_latticeSpacing, 4)/ 6.0;
397 mofi *= mass/nCells;
398
399 return Vector<T,2>(mofi,mass);
400}
ADf< T, DIM > abs(const ADf< T, DIM > &a)
Definition aDiff.h:1019
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
Definition pack.h:112

References olb::util::abs(), and olb::util::pow().

+ Here is the call graph for this function:

◆ getArea()

template<typename T , typename S , bool PARTICLE>
S olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::getArea ( )
override

Definition at line 370 of file smoothIndicatorF2D.hh.

371{
372 return _area;
373}

◆ getLocalCenter()

template<typename T , typename S , bool PARTICLE>
Vector< T, 2 > olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::getLocalCenter ( )

Definition at line 438 of file smoothIndicatorF2D.hh.

439{
440 return this->_center;
441}

◆ operator()()

template<typename T , typename S , bool PARTICLE>
bool olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::operator() ( T output[],
const S input[] )
override

Definition at line 485 of file smoothIndicatorF2D.hh.

486{
487 PhysR<T,2> pos(input[0], input[1]);
488 if constexpr(!PARTICLE) {
489 pos = util::executeRotation<S,2,true>(pos, this->_rotMat, this->getPos());
490 }
491 if(norm(pos) < this->_circumRadius) {
492 return SmoothIndicatorF2D<T, S, PARTICLE>::operator()(output, input);
493 }
494 output[0] = T{0};
495 return false;
496}
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.

References olb::norm().

+ Here is the call graph for this function:

◆ regardCell()

template<typename T , typename S , bool PARTICLE>
bool olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::regardCell ( int input[2])

Definition at line 479 of file smoothIndicatorF2D.hh.

480{
481 return this->_blockData->get(input) < std::numeric_limits<T>::epsilon();
482}

◆ signedDistance()

template<typename T , typename S , bool PARTICLE>
const S olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::signedDistance ( const Vector< S, 2 > input)
override

Definition at line 450 of file smoothIndicatorF2D.hh.

451{
452 PhysR<T,2> position = input;
453 if constexpr (!PARTICLE) {
454 // translation, counter-clockwise rotation by _theta=-theta around (0/0) and movement from rotation center to local center
455 position = util::executeRotation<T,2,true>(input, this->_rotMat, this->getPos());
456 }
457 // The block data originates in (0,0,0) therefore we translate the input position which is relative to center of mass
458 const PhysR<T,2> positionInCache = this->_center + position;
459
460 T signedDistance(0.);
461 if(_interpolateCache->operator()(&signedDistance, positionInCache.data())) {
462 return signedDistance;
463 }
464
465 // If all points were outside return an estimation instead
466 LatticeR<2> latticePosition;
467 PhysR<T,2> extraDistance;
468 for(unsigned iDim=0; iDim<2; ++iDim) {
469 latticePosition[iDim] = util::round( positionInCache[iDim] / this->_latticeSpacing );
470 latticePosition[iDim] = util::max(0, latticePosition[iDim]);
471 latticePosition[iDim] = util::min(this->_blockData->getExtent()[iDim] - 1, latticePosition[iDim]);
472 // The extra distance is always positive because it must be outside the geometry
473 extraDistance[iDim] = util::abs(_latticeSpacing * latticePosition[iDim] - positionInCache[iDim]);
474 }
475 return this->_blockData->get(latticePosition.data()) + norm(extraDistance);
476}
const S signedDistance(const Vector< S, 2 > input) override
cpu::simd::Pack< T > min(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:124
ADf< T, DIM > round(const ADf< T, DIM > &a)
Definition aDiff.h:928
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Definition pack.h:130

References olb::util::abs(), olb::Vector< T, D >::data(), olb::util::max(), olb::util::min(), olb::norm(), and olb::util::round().

+ Here is the call graph for this function:

◆ surfaceNormal()

template<typename T , typename S , bool PARTICLE>
Vector< S, 2 > olb::SmoothIndicatorCustom2D< T, S, PARTICLE >::surfaceNormal ( const Vector< S, 2 > & pos,
const S meshSize )
override

Definition at line 444 of file smoothIndicatorF2D.hh.

445{
446 return _indPtr->surfaceNormal(pos, meshSize);
447}

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