From 2bcbae122b141147e472bdbbad219c3571f71d0b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 16 Oct 2018 12:44:24 +0200 Subject: Implement moving wall / velocity Dirichlet boundary condition Usable as both the inflow condition of the channel example and the top wall of a lid driven cavity. --- src/boundary_conditions.cc | 17 +++++++++++++++++ src/boundary_conditions.h | 2 ++ src/vector.h | 5 +++++ 3 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/boundary_conditions.cc b/src/boundary_conditions.cc index 3488463..08b157c 100644 --- a/src/boundary_conditions.cc +++ b/src/boundary_conditions.cc @@ -1,5 +1,7 @@ #include "boundary_conditions.h" +#include "lbm.h" + std::pair, Vector> neighbors(Vector v) { if ( v[0] == 0 ) { return { @@ -27,6 +29,21 @@ void computeWallCell(DataCellBuffer& pop, Vector cell, Vector pop.curr(cell).get(neighborB) = pop.curr(cell).get(-neighborB); } +void computeMovingWallCell(DataCellBuffer& pop, Vector cell, Vector normal, Vector u) { + const auto [neighborA, neighborB] = neighbors(normal); + + const double rho = pop.curr(cell).get(-1,0) + pop.curr(cell).get(0,0) + pop.curr(cell).get(1,0) + + 2.*( + pop.curr(cell).get(-neighborA) + + pop.curr(cell).get(-normal ) + + pop.curr(cell).get(-neighborB) + ); + + pop.curr(cell).get(neighborA) = pop.curr(cell).get(-neighborA) - (6. * weight.get(-neighborA) * rho * (-neighborA * u)); + pop.curr(cell).get(normal ) = pop.curr(cell).get(-normal ) - (6. * weight.get(-normal) * rho * (-normal * u)); + pop.curr(cell).get(neighborB) = pop.curr(cell).get(-neighborB) - (6. * weight.get(-neighborB) * rho * (-neighborB * u)); +} + void computeZouHeVelocityWallCell(DataCellBuffer& pop, Vector cell, Vector normal, double vX) { const auto [neighborA, neighborB] = neighbors(normal); diff --git a/src/boundary_conditions.h b/src/boundary_conditions.h index 6b7de19..5f528e1 100644 --- a/src/boundary_conditions.h +++ b/src/boundary_conditions.h @@ -5,4 +5,6 @@ void computeWallCell(DataCellBuffer& pop, Vector cell, Vector normal); +void computeMovingWallCell(DataCellBuffer& pop, Vector cell, Vector normal, Vector u); + void computeZouHeVelocityWallCell(DataCellBuffer& pop, Vector cell, Vector normal, double vX); diff --git a/src/vector.h b/src/vector.h index 5e105c4..839707f 100644 --- a/src/vector.h +++ b/src/vector.h @@ -52,6 +52,11 @@ Vector operator*(T scalar, const Vector& v) { }; } +template +decltype(T{}*W{}) operator*(const Vector& a, const Vector& b) { + return a[0]*b[0] + a[1]*b[1]; +} + template Vector operator-(const Vector& a, const Vector& b) { return Vector{ -- cgit v1.2.3