24#ifndef BLOCK_LATTICE_REFINEMENT_METRIC_F_2D_HH
25#define BLOCK_LATTICE_REFINEMENT_METRIC_F_2D_HH
34template<
typename T,
typename DESCRIPTOR>
42template<
typename T,
typename DESCRIPTOR>
51 const T uSqr = u[0]*u[0] + u[1]*u[1];
55 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
58 sum +=
util::abs((cell[iPop] - fEq) / (fEq + descriptors::t<T,DESCRIPTOR>(iPop)));
61 output[0] = sum / (DESCRIPTOR::q);
67template<
typename T,
typename DESCRIPTOR>
72 _knudsen(converter.getKnudsenNumber())
74 this->
getName() =
"refinementMetricKnudsen";
77template<
typename T,
typename DESCRIPTOR>
80 const std::size_t cellCount = this->_blockLattice.getNx() * this->_blockLattice.getNy();
84 T localOutput[1] = { };
85 int localInput[2] = { };
87 for (localInput[0] = 0; localInput[0] < this->_blockLattice.getNx(); ++localInput[0]) {
88 for (localInput[1] = 0; localInput[1] < this->_blockLattice.getNy(); ++localInput[1]) {
91 blockSum += localOutput[0];
95 const T blockC = blockSum / cellCount;
97 output[0] = std::log2(blockC / _knudsen);
99 if ( output[0] <= 0. || blockC <= 0. ) {
106template<
typename T,
typename DESCRIPTOR>
108 T output[],
const int input[])
110 T measuredKnudsen[1] { };
113 output[0] = std::log2(measuredKnudsen[0] / _knudsen);
115 if ( output[0] <= 0. || measuredKnudsen[0] <= 0. ) {
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
BlockLatticeKnudsen2D(BlockLattice< T, DESCRIPTOR > &blockLattice)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
bool operator()(T output[])
BlockLatticeRefinementMetricKnudsen2D(BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &converter)
Platform-abstracted block lattice for external access and inter-block interaction.
Highest-level interface to read-only Cell data.
void computeRhoU(T &rho, T u[descriptors::d< DESCRIPTOR >()]) const
Compute fluid velocity and particle density on the cell.
std::string & getName()
read and write access to name
Conversion between physical and lattice units, as well as discretization.
ADf< T, DIM > abs(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
static V secondOrder(int iPop, const RHO &rho, const U &u, const USQR &uSqr) any_platform
Computation of equilibrium distribution, second order in u.