26#ifndef MOMENTUM_EXCHANGE_FORCE_H
27#define MOMENTUM_EXCHANGE_FORCE_H
29#define M_PI 3.14159265358979323846
39template<
typename T,
unsigned D,
bool useLadd=false>
44 static constexpr T
calculate( T f1, T f2, T c, T pVel, T deltaR )
46 return (f1*(c-pVel) + f2*(c+pVel))*(1./deltaR) ;
51 static constexpr T
calculate( T f1, T f2, T c, T pVel, T deltaR )
53 return (f1*(c-pVel) + f2*(c+pVel));
59 static constexpr T
calculate( T f1, T f2, T c, T pVel, T deltaR )
61 return ((f1 + f2)*c)*(1./deltaR) ;
66 static constexpr T
calculate( T f1, T f2, T c, T pVel, T deltaR )
75template<
typename T,
typename DESCRIPTOR,
typename PARTICLETYPE>
84 const int bulkMaterial = 1
88 using namespace descriptors;
89 constexpr unsigned D = DESCRIPTOR::d;
93 const T deltaR = blockGeometry.
getDeltaR();
95 T physRinner[D] = { };
97 blockGeometry.
getPhysR(physRV, latticeRinner);
98 for (
unsigned iD = 0; iD < D; ++iD) {
99 physRinner[iD] = physRV[iD];
102 T porosityInner[1] = { };
105 if ( !
util::nearZero(porosityInner[0]) && blockGeometry.
get(latticeRinner)==bulkMaterial ) {
107 for (
int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
110 const LatticeR<D> latticeRouter = latticeRinner + c;
112 T physRouter[D] = {0.};
114 blockGeometry.
getPhysR(physRouterV, latticeRouter);
115 for (
unsigned iD = 0; iD < D; ++iD) {
116 physRouter[iD] = physRouterV[iD];
119 T porosityOuter[1] = {0.};
122 if ( !(porosityInner[0]==1 && porosityOuter[0]==1) ) {
124 const T f1 = blockLattice.get( latticeRouter )[iPop];
127 for (
unsigned iDim=0; iDim<D; ++iDim) {
135 auto contact = particle.template getField<NUMERICPROPERTIES,IS_IN_CONTACT>();
139 for (
unsigned iDim=0; iDim<D; ++iDim) {
141 vn = vn +
util::pow(momentumExchange[iDim],2);
146 auto cell = blockLattice.get(latticeRinner);
149 cell.computeU(localLatticeFluidVelocity.
data());
151 for(
unsigned iD=0; iD<D; ++iD) {
152 localPhysicalFluidVelocity[iD] = converter.
getPhysVelocity(localLatticeFluidVelocity[iD]);
156 for (
unsigned iDim=0; iDim<D; ++iDim) {
157 U = U +
util::pow(pVel[iDim]-localLatticeFluidVelocity[iDim],2.0);
175 for (
unsigned iDim=0; iDim<D; ++iDim) {
177 momentumExchange[iDim] *= mp;
Representation of a block geometry.
Vector< T, D > getPhysR(LatticeR< D > latticeR) const
T getDeltaR() const
Read only access to the voxel size given in SI units (meter)
std::enable_if_t< sizeof...(L)==D, int > get(L... latticeR) const
Read-only access to a material number.
Conversion between physical and lattice units, as well as discretization.
constexpr T getPhysDensity() const
return density in physical units
constexpr T getLatticeDensity(T physDensity) const
conversion from physical to lattice density
constexpr size_t getLatticeTime(T physTime) const
conversion from physical to lattice time
constexpr T getPhysVelocity(T latticeVelocity) const
conversion from lattice to physical velocity
constexpr T getLatticeVelocity(T physVelocity) const
conversion from physical to lattice velocity
constexpr T getPhysDeltaT() const
returns time spacing (timestep length) in s
constexpr T getPhysForce(T latticeForce) const
conversion from lattice to physical force
constexpr const T * data() const any_platform
constexpr int c(unsigned iPop, unsigned iDim) any_platform
constexpr int opposite(unsigned iPop) any_platform
constexpr bool providesIsInContact()
Vector< T, PARTICLETYPE::d > getPosition(Particle< T, PARTICLETYPE > particle)
constexpr Vector< T, PARTICLETYPE::d > calculateLocalVelocity(Particle< T, PARTICLETYPE > &particle, const PhysR< T, PARTICLETYPE::d > &input)
bool momentumExchangeAtSurfaceLocation(T momentumExchange[], PhysR< T, DESCRIPTOR::d > &lever, const LatticeR< DESCRIPTOR::d > &latticeRinner, const BlockGeometry< T, DESCRIPTOR::d > &blockGeometry, BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &converter, Particle< T, PARTICLETYPE > &particle, const int bulkMaterial=1)
bool evalSolidVolumeFraction(T output[], const S input[], Particle< T, PARTICLETYPE > &particle)
Expr pow(Expr base, Expr exp)
bool nearZero(T a) any_platform
return true if a is close to zero
Top level namespace for all of OpenLB.
Vector< T, D > PhysR
Type for spatial (physical) coordinates.
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)
static constexpr T calculate(T f1, T f2, T c, T pVel, T deltaR)