/* This file is part of the OpenLB library
*
* Copyright (C) 2012 Lukas Baron, Mathias J. Krause, Albert Mink
* E-mail contact: info@openlb.net
* The most recent release of OpenLB can be downloaded at
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef BLOCK_LATTICE_LOCAL_F_3D_H
#define BLOCK_LATTICE_LOCAL_F_3D_H
#include "blockBaseF3D.h"
#include "geometry/blockGeometry3D.h"
#include "functors/analytical/indicator/indicatorBaseF3D.h"
#include "indicator/blockIndicatorBaseF3D.h"
#include "dynamics/smagorinskyBGKdynamics.h"
#include "dynamics/porousBGKdynamics.h"
/** Note: Throughout the whole source code directory genericFunctions, the
* template parameters for i/o dimensions are:
* F: S^m -> T^n (S=source, T=target)
*/
namespace olb {
template class blockLatticeStructure3D;
template class ParticleIndicatorF3D;
////////////////////////////////////////////////////////////////////////////////
//// if globIC is not on the local processor, the returned vector is empty//////
////////////////////////////////////////////////////////////////////////////////
/// functor returns pointwise f population on local lattices
template
class BlockLatticeFpop3D final : public BlockLatticeF3D {
public:
BlockLatticeFpop3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise dissipation density on local lattices
template
class BlockLatticeDissipation3D final : public BlockLatticeF3D {
protected:
const UnitConverter& _converter;
public:
BlockLatticeDissipation3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise dissipation density on local lattices
template
class BlockLatticePhysDissipation3D final : public BlockLatticeF3D {
protected:
const int _overlap;
const UnitConverter& _converter;
public:
BlockLatticePhysDissipation3D(BlockLatticeStructure3D& blockLattice,
int overlap,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise turbulent dissipation density on local lattices
template
class BlockLatticeEffevtiveDissipation3D final : public BlockLatticeF3D {
protected:
const UnitConverter& _converter;
T _smagoConst;
LESDynamics& _LESdynamics;
public:
BlockLatticeEffevtiveDissipation3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter, T smagoConst,
LESDynamics& LESdynamics);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise turbulent dissipation density on local lattices
template
class BlockLatticePhysEffevtiveDissipation3D final : public BlockLatticeF3D {
protected:
const UnitConverter& _converter;
T _smagoConst;
LESDynamics& _LESdynamics;
public:
BlockLatticePhysEffevtiveDissipation3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter, T smagoConst,
LESDynamics& LESdynamics);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise density rho on local lattices
template
class BlockLatticeDensity3D final : public BlockLatticeF3D {
public:
BlockLatticeDensity3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise velocity on local lattice
template
class BlockLatticeVelocity3D final : public BlockLatticeF3D {
public:
BlockLatticeVelocity3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise external velocity (external field) on local lattice
template
class BlockLatticeExternalVelocity3D final : public BlockLatticeF3D {
public:
BlockLatticeExternalVelocity3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]);
};
/// functor returns pointwise the material no. presenting the geometry on local lattice
template
class BlockLatticeGeometry3D final : public BlockLatticeF3D {
BlockGeometryStructure3D& _blockGeometry;
int _material;
public:
BlockLatticeGeometry3D(BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry, int material = -1);
bool operator() (T output[], const int input[]) override;
};
/// functor to get pointwise the rank no. + 1 on local lattice
template
class BlockLatticeRank3D final : public BlockLatticeF3D {
public:
BlockLatticeRank3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]) override;
};
/// functor to get pointwise the cuboid no. + 1 on local lattice
template
class BlockLatticeCuboid3D final : public BlockLatticeF3D {
private:
// holds cuboid nmb of current block
int _iC;
public:
BlockLatticeCuboid3D(BlockLatticeStructure3D& blockLattice, int iC);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise phys pressure from rho on local lattices
template
class BlockLatticePhysPressure3D final : public BlockLatticePhysF3D {
private:
const int _overlap;
public:
BlockLatticePhysPressure3D(BlockLatticeStructure3D& blockLattice,
int overlap,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise phys velocity on local lattice
template
class BlockLatticePhysVelocity3D final : public BlockLatticePhysF3D {
private:
const int _overlap;
const bool _print;
public:
BlockLatticePhysVelocity3D(BlockLatticeStructure3D& blockLattice,
int overlap,
const UnitConverter& converter,
bool print=false);
bool operator() (T output[], const int input[]) override;
};
template
class BlockLatticePhysExternalVelocity3D final : public BlockLatticePhysF3D {
public:
BlockLatticePhysExternalVelocity3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};
template
class BlockLatticePhysExternalPorosity3D final : public BlockLatticePhysF3D {
private:
const int _overlap;
public:
BlockLatticePhysExternalPorosity3D(BlockLatticeStructure3D& blockLattice,
int overlap,
const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};
template
class BlockLatticePhysExternalParticleVelocity3D final : public BlockLatticePhysF3D {
public:
BlockLatticePhysExternalParticleVelocity3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};
template
class BlockLatticePhysExternal3D final : public BlockLatticeF3D {
public:
BlockLatticePhysExternal3D(BlockLatticeStructure3D& blockLattice,
T convFactorToPhysUnits, int offset, int size);
bool operator() (T output[], const int input[]) override;
private:
T _convFactorToPhysUnits;
int _offset, _size;
};
/// functor returns pointwise lattice flux on local lattice
template
class BlockLatticeFlux3D final : public BlockLatticeF3D {
private:
public:
BlockLatticeFlux3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[3], const int input[3]) override;
};
/// functor returns pointwise strain rate on local lattice, s_ij = 1/2*(du_idr_j + du_jdr_i)
template
class BlockLatticeStrainRate3D final : public BlockLatticePhysF3D {
public:
BlockLatticeStrainRate3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise phys strain rate on local lattice, s_ij = 1/2*(du_idr_j + du_jdr_i)
template
class BlockLatticePhysStrainRate3D final : public BlockLatticePhysF3D {
private:
const int _overlap;
public:
BlockLatticePhysStrainRate3D(BlockLatticeStructure3D& blockLattice,
int overlap,
const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};
/// functor returns pointwise phys force acting on a boundary with a given material on local lattice
template
class BlockLatticePhysBoundaryForce3D final : public BlockLatticePhysF3D {
private:
BlockIndicatorF3D& _indicatorF;
BlockGeometryStructure3D& _blockGeometry;
public:
BlockLatticePhysBoundaryForce3D(BlockLatticeStructure3D& blockLattice,
BlockIndicatorF3D& indicatorF,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise phys force for PSM dynamics
template
class BlockLatticePSMPhysForce3D final : public BlockLatticePhysF3D {
public:
BlockLatticePSMPhysForce3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter, int mode_);
bool operator() (T output[], const int input[]) override;
private:
Mode mode;
};
/// functor returns pointwise phys wall shear stress acting on a boundary with a given material on local lattice
template
class BlockLatticePhysWallShearStress3D final : public BlockLatticePhysF3D {
private:
BlockGeometryStructure3D& _blockGeometry;
const int _overlap;
const int _material;
std::vector>>> _discreteNormal;
std::vector>>> _normal;
T _physFactor;
public:
BlockLatticePhysWallShearStress3D(BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry,
int overlap,
int material,
const UnitConverter& converter,
IndicatorF3D& indicator);
bool operator() (T output[], const int input[]) override;
};
/**
* functor returns pointwise phys force acting on a indicated boundary on local lattice
* see: Caiazzo, Junk: Boundary Forces in lattice Boltzmann: Analysis of MEA
*/
template
class BlockLatticePhysCorrBoundaryForce3D final : public BlockLatticePhysF3D {
private:
BlockIndicatorF3D& _indicatorF;
BlockGeometryStructure3D& _blockGeometry;
public:
BlockLatticePhysCorrBoundaryForce3D(BlockLatticeStructure3D& blockLattice,
BlockIndicatorF3D& indicatorF,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// functor to get pointwise, lattice-dependent external field
template
class BlockLatticeField3D final : public BlockLatticeF3D {
public:
BlockLatticeField3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]) override;
};
/**
* functor returns pointwise, lattice-dependent porosity values in [0,1]
* in combination with (Extended)PorousBGKdynamics: 0->solid, 1->fluid
*/
template
class BlockLatticePorosity3D final : public BlockLatticeF3D {
public:
BlockLatticePorosity3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]);
};
/**
* functor returns pointwise an approximation for the volume fraction
*/
template
class BlockLatticeVolumeFractionApproximation3D final : public BlockLatticeF3D {
private:
BlockGeometryStructure3D& _blockGeometry;
IndicatorF3D& _indicator;
int _refinementLevel;
const UnitConverter& _converter;
bool _insideOut;
T _physSubGridMinPhysRshift;
T _physSubGridDeltaX;
T _latticeSubGridVolume;
public:
BlockLatticeVolumeFractionApproximation3D(BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry,
IndicatorF3D& indicator,
int refinementLevel,
const UnitConverter& converter, bool insideOut);
bool operator() (T output[], const int input[]);
};
/**
* functor to get pointwise mesh-independent permeability values in (0,inf)
* in combination with (Extended)PorousBGKdynamics
* note: result is cropped to 999999
*/
template
class BlockLatticePhysPermeability3D final : public BlockLatticePhysF3D {
public:
BlockLatticePhysPermeability3D(BlockLatticeStructure3D& blockLattice, const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};
/**
* functor to get pointwise mesh-independent permeability values in (0,inf)
* in combination with (Extended)PorousBGKdynamics
* note: result is cropped to 1
*/
template
class BlockLatticePhysCroppedPermeability3D final : public BlockLatticePhysF3D {
public:
BlockLatticePhysCroppedPermeability3D(BlockLatticeStructure3D& blockLattice, const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};
//TODO: consistency with 2D (181219)
/*
template
class BlockLatticePhysPermeability3D final : public BlockLatticePhysF3D {
private:
BlockGeometry3D& _blockGeometry;
int _material;
public:
BlockLatticePhysPermeability3D(BlockLatticeStructure3D& blockLattice,
BlockGeometry3D& blockGeometry,
int material, const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};*/
/// functor returns pointwise -nu/K*u on the lattice, can be used with BlockSum3D as objective
template
class BlockLatticePhysDarcyForce3D final : public BlockLatticePhysF3D {
private:
BlockGeometry3D& _blockGeometry;
int _material;
public:
BlockLatticePhysDarcyForce3D(BlockLatticeStructure3D& blockLattice,
BlockGeometry3D& blockGeometry,
int material, const UnitConverter& converter);
bool operator() (T output[], const int input[]);
};
/// functor returns pointwise the l2-norm, e.g. of a velocity
template
class BlockEuklidNorm3D final : public BlockF3D {
protected:
BlockF3D& _f;
public:
BlockEuklidNorm3D(BlockF3D& f);
bool operator() (T output[], const int input[]) override;
};
template
class BlockLatticeInterpPhysVelocity3D final : public BlockLatticePhysF3D {
protected:
Cuboid3D* _cuboid;
int _overlap;
public:
BlockLatticeInterpPhysVelocity3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& conv, Cuboid3D* c, int overlap);
BlockLatticeInterpPhysVelocity3D(const BlockLatticeInterpPhysVelocity3D& rhs);
bool operator() (T output[3], const int input[3]) override
{
return false;
}
void operator() (T output[3], const T input[3]);
};
/** 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).
* \return output[0]-output[2] translational force - physical units
* \return output[3]-output[5] torque - physical units
* \return output[7] number of voxels
*/
template
class BlockLatticePorousMomentumLossForce3D final : public BlockLatticePhysF3D {
private:
BlockGeometryStructure3D& _blockGeometry;
std::vector* >& _vectorOfIndicator;
public:
BlockLatticePorousMomentumLossForce3D(BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry,
std::vector* >& indicator,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
template
class BlockLatticePhysTemperature3D final : public BlockLatticeThermalPhysF3D {
public:
BlockLatticePhysTemperature3D(BlockLatticeStructure3D& blockLattice,
ThermalUnitConverter const& converter);
bool operator() (T output[], const int input[]);
};
/// BlockLatticePhysHeatFlux3D returns pointwise phys heat flux on local lattice.
template
class BlockLatticePhysHeatFlux3D final : public BlockLatticeThermalPhysF3D {
public:
BlockLatticePhysHeatFlux3D(BlockLatticeStructure3D& blockLattice,
const ThermalUnitConverter& converter);
bool operator() (T output[], const int input[]) override;
private:
T _temp; // contains latticeSpecificHeatCapacity * (tau - 0.5) / tau
};
/// functor returns pointwise minimum distance to boundary given by indicators
template
class BlockLatticePhysBoundaryDistance3D final : public BlockLatticeF3D {
private:
BlockGeometryStructure3D& _blockGeometry;
std::shared_ptr> _tmpIndicator = nullptr;
std::vector>> _indicatorList;
public:
BlockLatticePhysBoundaryDistance3D(BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry,
XMLreader const& xmlReader);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise pore radius for packings of spheres given by indicators
/// returns NAN for non-pore voxels
template
class BlockLatticePhysPoreSizeDistribution3D final : public BlockLatticeF3D {
private:
BlockGeometryStructure3D& _blockGeometry;
int _material;
std::shared_ptr> _tmpIndicator = nullptr;
std::vector>> _indicatorList;
BlockLatticePhysBoundaryDistance3D _distanceFunctor;
BlockData3D _distanceCache;
public:
BlockLatticePhysPoreSizeDistribution3D(BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry, int material,
XMLreader const& xmlReader);
bool operator() (T output[], const int input[]) override;
};
/// functor returns pointwise pore radius for packings of spheres given by indicators
/// returns NAN for non-pore voxels
template
class BlockLatticePhysTauFromBoundaryDistance3D final : public BlockLatticeThermalPhysF3D {
private:
BlockGeometryStructure3D& _blockGeometry;
BlockLatticePhysBoundaryDistance3D _distanceFunctor;
const T _tmp1, _tmp2;
public:
BlockLatticePhysTauFromBoundaryDistance3D(BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry,
XMLreader const& xmlReader,
ThermalUnitConverter const& converter,
const T p, const T T_avg, const T c_p, const T beta, const T lambda_0, const T sigma, const T p_0, const T n_0);
bool operator() (T output[], const int input[]) override;
};
/// functor that returns 1 if SmoothIndicatorF A intersects IndicatorF B; otherwise, 0
template
class BlockLatticeIndicatorSmoothIndicatorIntersection3D final : public BlockLatticeF3D {
private:
BlockGeometryStructure3D& _blockGeometry;
IndicatorF3D& _normalInd;
SmoothIndicatorF3D& _smoothInd;
public:
BlockLatticeIndicatorSmoothIndicatorIntersection3D(
BlockLatticeStructure3D& blockLattice,
BlockGeometryStructure3D& blockGeometry,
IndicatorF3D& normalInd,
SmoothIndicatorF3D& smoothInd );
bool operator() (T output[], const int input[]) override;
};
/// Returns pointwise porosity on local lattices for Guo & Zhao (2002)'s model.
template
class BlockLatticeGuoZhaoEpsilon3D final : public BlockLatticeF3D {
public:
BlockLatticeGuoZhaoEpsilon3D(BlockLatticeStructure3D& blockLattice);
bool operator() (T output[], const int input[]) override;
};
/// Returns pointwise porous conductivity on local lattices for Guo & Zhao (2002)'s model.
template
class BlockLatticeGuoZhaoPhysK3D final : public BlockLatticePhysF3D {
public:
BlockLatticeGuoZhaoPhysK3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// Returns pointwise body force on local lattices for Guo & Zhao (2002)'s model.
template
class BlockLatticeGuoZhaoPhysBodyForce3D final : public BlockLatticePhysF3D {
public:
BlockLatticeGuoZhaoPhysBodyForce3D(BlockLatticeStructure3D& blockLattice,
const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
/// functor to scale particle distributions to a time step
template
class BlockLatticeTimeStepScale3D final : public BlockLatticeF3D {
private:
T _tau_old;
const UnitConverter& _converter;
public:
BlockLatticeTimeStepScale3D(BlockLatticeStructure3D& blockLattice,
T oldTau, const UnitConverter& converter);
bool operator() (T output[], const int input[]) override;
};
} // end namespace olb
#endif