aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-10-16 12:44:24 +0200
committerAdrian Kummerlaender2018-10-16 12:44:24 +0200
commit2bcbae122b141147e472bdbbad219c3571f71d0b (patch)
treee4e0f67dbe052708a8259da4247fa025d182efcf /src
parentd1d96371a0d857bf874d6370c17595ffa0bfeaec (diff)
downloadboltzbub-2bcbae122b141147e472bdbbad219c3571f71d0b.tar
boltzbub-2bcbae122b141147e472bdbbad219c3571f71d0b.tar.gz
boltzbub-2bcbae122b141147e472bdbbad219c3571f71d0b.tar.bz2
boltzbub-2bcbae122b141147e472bdbbad219c3571f71d0b.tar.lz
boltzbub-2bcbae122b141147e472bdbbad219c3571f71d0b.tar.xz
boltzbub-2bcbae122b141147e472bdbbad219c3571f71d0b.tar.zst
boltzbub-2bcbae122b141147e472bdbbad219c3571f71d0b.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/boundary_conditions.cc17
-rw-r--r--src/boundary_conditions.h2
-rw-r--r--src/vector.h5
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],