Hi All,
I’m writing my very first codes in palabos and I’m dealing with the advection diffusion problem. I wrote a simple code which aims to solve the pure diffusion in a box imposing two different temperature on the top and bottom wall. As first attempt, i’m pretty satisfiedbut still I dont get why the top wall value doesn’t preserve during the simulation. I think I’m messing with the boudary conditions, but I’m really new to the topic and some concepts are not so clear yet… Hope that somebody of you can help me and can corrects the code if there are mistakes.
[code=“cpp”]
#include
#include “palabos2D.h”
#include “palabos2D.hh”
using namespace std;
using namespace plb;
typedef double T;
#define DES descriptors::AdvectionDiffusionD2Q5Descriptor
int main(int argc, char *argv[])
{
// Init simulation
plbInit(&argc, &argv);
const T omega = 1.;
Array <T,2> u0(0.0,0.0);
// Istantiate lattice
MultiBlockLattice2D <T, DES> lattice(100,100, new AdvectionDiffusionBGKdynamics<T, DES>(omega));
// Init lattice and assign boundary conditions
plint nx = lattice.getNx();
plint ny = lattice.getNy();
Box2D topwall(0, nx-1, ny-1, ny-1);
Box2D bottomwall(0, nx-1, 0, 0);
// Create boundary conditions
OnLatticeAdvectionDiffusionBoundaryCondition2D <T, DES> *BC = createLocalAdvectionDiffusionBoundaryCondition2D<T, DES>();
//Impose the boundary conditions
BC->addTemperatureBoundary0N(topwall, lattice);
BC->addTemperatureBoundary0N(bottomwall, lattice);
// Try to impose a different temperature
setBoundaryDensity(lattice, topwall, 1.0);
setBoundaryDensity(lattice, bottomwall, 2.0);
// Init lattice
initializeAtEquilibrium(lattice, lattice.getBoundingBox(), 0.0,u0);
// Command to init the lattice
lattice.periodicity().toggleAll(true);
lattice.initialize();
ImageWriter <T> imagewrite("leeloo");
imagewrite.writeScaledGif(createFileName("temp", 1, 1), *computeDensity(lattice), 100,100);
//* Main cicle for LbM
for(plint iT=0; iT < 100000; ++iT) {
if (iT % 1000 == 0) {
pcout << "Writing GIF... \n";
imagewrite.writeScaledGif(createFileName("temp", iT, 6), *computeDensity(lattice), 100,100);
}
lattice.collideAndStream();
}
return 0;
}