24#ifndef BLOCK_LATTICE_REFINEMENT_METRIC_F_3D_HH
25#define BLOCK_LATTICE_REFINEMENT_METRIC_F_3D_HH
34template<
typename T,
typename DESCRIPTOR>
42template<
typename T,
typename DESCRIPTOR>
51 const T uSqr = u[0]*u[0] + u[1]*u[1] + u[2]*u[2];
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() * this->_blockLattice.getNz();
84 T localOutput[1] = { };
85 int localInput[3] = { };
87 for (localInput[0] = 0; localInput[0] < this->_blockLattice.getNx(); ++localInput[0]) {
88 for (localInput[1] = 0; localInput[1] < this->_blockLattice.getNy(); ++localInput[1]) {
89 for (localInput[2]=0; localInput[2] < this->_blockLattice.getNz(); ++localInput[2]) {
92 blockSum += localOutput[0];
97 const T blockC = blockSum / cellCount;
99 output[0] = std::log2(blockC / _knudsen);
101 if ( output[0] <= 0. || blockC <= 0. ) {
108template<
typename T,
typename DESCRIPTOR>
110 T output[],
const int input[])
112 T measuredKnudsen[1] { };
115 output[0] = std::log2(measuredKnudsen[0] / _knudsen);
118 if ( output[0] <= 0. || measuredKnudsen[0] <= 0. ) {
127template<
typename T,
typename DESCRIPTOR>
132 this->
getName() =
"high_order_knudsen";
135template<
typename T,
typename DESCRIPTOR>
145 const T uSqr = u[0]*u[0] + u[1]*u[1] + u[2]*u[2];
149 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
153 sum +=
util::abs((cell[iPop] - fEq - fNeqFromPi) / (fEq + descriptors::t<T,DESCRIPTOR>(iPop)));
156 output[0] = sum / (DESCRIPTOR::q);
represents all functors that operate on a DESCRIPTOR in general, e.g. getVelocity(),...
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeHighOrderKnudsen3D(BlockLattice< T, DESCRIPTOR > &blockLattice)
BlockLatticeKnudsen3D(BlockLattice< T, DESCRIPTOR > &blockLattice)
bool operator()(T output[], const int input[]) override
has to be implemented for 'every' derived class
BlockLatticeRefinementMetricKnudsen3D(BlockLattice< T, DESCRIPTOR > &blockLattice, const UnitConverter< T, DESCRIPTOR > &converter)
bool operator()(T output[])
Platform-abstracted block lattice for external access and inter-block interaction.
Highest-level interface to read-only Cell data.
void computeAllMomenta(T &rho, T u[descriptors::d< DESCRIPTOR >()], T pi[util::TensorVal< DESCRIPTOR >::n]) const
Compute all momenta on the celll, up to second order.
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.
Collection of common computations for LBM.
Compute number of elements of a symmetric d-dimensional tensor.