diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/boundary_conditions.cc | 17 | ||||
-rw-r--r-- | src/boundary_conditions.h | 2 | ||||
-rw-r--r-- | src/vector.h | 5 |
3 files changed, 24 insertions, 0 deletions
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<int>, Vector<int>> neighbors(Vector<int> v) { if ( v[0] == 0 ) { return { @@ -27,6 +29,21 @@ void computeWallCell(DataCellBuffer& pop, Vector<std::size_t> cell, Vector<int> pop.curr(cell).get(neighborB) = pop.curr(cell).get(-neighborB); } +void computeMovingWallCell(DataCellBuffer& pop, Vector<std::size_t> cell, Vector<int> normal, Vector<double> 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<std::size_t> cell, Vector<int> 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<std::size_t> cell, Vector<int> normal); +void computeMovingWallCell(DataCellBuffer& pop, Vector<std::size_t> cell, Vector<int> normal, Vector<double> u); + void computeZouHeVelocityWallCell(DataCellBuffer& pop, Vector<std::size_t> cell, Vector<int> 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 @@ -53,6 +53,11 @@ Vector<T> operator*(T scalar, const Vector<T>& v) { } template <typename T, typename W> +decltype(T{}*W{}) operator*(const Vector<T>& a, const Vector<W>& b) { + return a[0]*b[0] + a[1]*b[1]; +} + +template <typename T, typename W> Vector<T> operator-(const Vector<T>& a, const Vector<W>& b) { return Vector<T>{ a[0] - b[0], |