From b89b56b6b93d6b8df61954235c2ce6bd04bfd714 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 15 Jan 2019 12:05:50 +0100 Subject: Conclude refinement method implementation section --- code/computeRestrictedFneq.cpp | 23 +++++++++++++++++++++++ code/coupler2d.cpp | 2 +- code/fineCoupler2d.cpp | 4 ++-- code/fineCoupler2d_couple_extract.cpp | 18 ++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 code/computeRestrictedFneq.cpp create mode 100644 code/fineCoupler2d_couple_extract.cpp (limited to 'code') diff --git a/code/computeRestrictedFneq.cpp b/code/computeRestrictedFneq.cpp new file mode 100644 index 0000000..cf796b1 --- /dev/null +++ b/code/computeRestrictedFneq.cpp @@ -0,0 +1,23 @@ +template class DESCRIPTOR> +void computeRestrictedFneq(const SuperLattice2D& lattice, + Vector latticeR, + T restrictedFneq[DESCRIPTOR::q]) +{ + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + const auto neighbor = latticeR + + {0, DESCRIPTOR::c[iPop][0], DESCRIPTOR::c[iPop][1]}; + Cell cell; + lattice.get(neighbor, cell); + + T fNeq[DESCRIPTOR::q] {}; + lbHelpers::computeFneq(cell, fNeq); + + for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) { + restrictedFneq[jPop] += fNeq[jPop]; + } + } + + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + restrictedFneq[iPop] /= DESCRIPTOR::q; + } +} diff --git a/code/coupler2d.cpp b/code/coupler2d.cpp index 9752de8..b34ec80 100644 --- a/code/coupler2d.cpp +++ b/code/coupler2d.cpp @@ -13,7 +13,7 @@ protected: const Vector& getFineLatticeR(int y) const; const Vector& getCoarseLatticeR(int y) const; - T getScalingFactor() const; + T getScalingFactor() const; // Skalierungsfaktor $(\ref{eq:scaleFneq})$ der Nicht-Equilibriumsverteilung T getInvScalingFactor() const; private: diff --git a/code/fineCoupler2d.cpp b/code/fineCoupler2d.cpp index 4cde254..7da499a 100644 --- a/code/fineCoupler2d.cpp +++ b/code/fineCoupler2d.cpp @@ -1,8 +1,8 @@ template class DESCRIPTOR> class FineCoupler2D : public Coupler2D { private: - std::vector _c2f_rho; - std::vector> _c2f_u; + std::vector> _c2f_rho; + std::vector::d>> _c2f_u; std::vector::q>> _c2f_fneq; public: diff --git a/code/fineCoupler2d_couple_extract.cpp b/code/fineCoupler2d_couple_extract.cpp new file mode 100644 index 0000000..089ed02 --- /dev/null +++ b/code/fineCoupler2d_couple_extract.cpp @@ -0,0 +1,18 @@ +for (int y=1; y < this->_coarseSize-2; ++y) { + const auto rho = order4interpolation(_c2f_rho, y); // Siehe Listing $\ref{lst:ipol4ord}$ + const auto u = order4interpolation(_c2f_u, y); + const auto fneq = order4interpolation(_c2f_fneq, y); + + const T uSqr = u*u; + + const auto finePos = this->getFineLatticeR(1+2*y); + Cell fineCell; + fineLattice.get(finePos, fineCell); + + for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) { + fineCell[iPop] = lbHelpers::equilibrium(iPop, rho[0], u.data, uSqr) + + this->getScalingFactor() * fneq[iPop]; + } + + fineLattice.set(finePos, fineCell); +} -- cgit v1.2.3