Hi,
I am doing simulation for periodic boundaries on all sides of a 3D system. The flow is driven by a body force. I used lattice.collideAndStream(true) to signify periodic boundaries
In the interior of the system, using bounce-back, my code looks like
while(in)
{
for (int iZ=1; iZ< nz-1; ++iZ) {
for (int iY=1; iY< ny-1; ++iY) {
for (int iX=1; iX<nx-1; ++iX) {
in.get(ch);
if(ch == '0')
{
T u = converter.getLatticeU();
T vel[3] = { u, T(), T() };
T force[3] = { poiseuilleforce(converter), T(), T() };
lattice.get(iX,iY,iZ).defineExternalField(
DESCRIPTOR<T>::ExternalField::forceBeginsAt,
DESCRIPTOR<T>::ExternalField::sizeOfForce,
force
);
lattice.get(iX,iY,iZ).defineRhoU((T)1, vel);
lattice.get(iX,iY,iZ).iniEquilibrium((T)1, vel);
}
else if(ch == '1')
{
lattice.defineDynamics(iX,iX,iY,iY,iZ,iZ,
&instances::getBounceBack<T, DESCRIPTOR> () );
}
}
}
}
}
While the sides are defined as below
T u = converter.getLatticeU();
T vel[3] = { u, T(), T() };
T force[3] = { poiseuilleforce(converter), T(), T() };
for(int iZ=0; iZ<nz; ++iZ){
for(int iX=0; iX<nx; ++iX){
lattice.get(iX, 0, iZ).defineExternalField(
DESCRIPTOR<T>::ExternalField::forceBeginsAt,
DESCRIPTOR<T>::ExternalField::sizeOfForce,
force);
lattice.get(iX, 0, iZ).defineRhoU((T)1, vel);
lattice.get(iX, 0, iZ).iniEquilibrium((T)1, vel);
}
}
for(int iZ=0; iZ<nz; ++iZ){
for(int iX=0; iX<nx; ++iX){
lattice.get(iX, nz-1, iZ).defineExternalField(
DESCRIPTOR<T>::ExternalField::forceBeginsAt,
DESCRIPTOR<T>::ExternalField::sizeOfForce,
force);
lattice.get(iX, ny-1, iZ).defineRhoU((T)1, vel);
lattice.get(iX, ny-1, iZ).iniEquilibrium((T)1, vel);
}
}
for(int iY=0; iY<ny; ++iY){
for(int iX=0; iX<nx; ++iX){
lattice.get(iX, iY, 0).defineExternalField(
DESCRIPTOR<T>::ExternalField::forceBeginsAt,
DESCRIPTOR<T>::ExternalField::sizeOfForce,
force);
lattice.get(iX, iY, 0).defineRhoU((T)1, vel);
lattice.get(iX, iY, 0).iniEquilibrium((T)1, vel);
}
}
for(int iY=0; iY<ny; ++iY){
for(int iX=0; iX<nx; ++iX){
lattice.get(iX, iY, nz-1).defineExternalField(
DESCRIPTOR<T>::ExternalField::forceBeginsAt,
DESCRIPTOR<T>::ExternalField::sizeOfForce,
force);
lattice.get(iX, iY, nz-1).defineRhoU((T)1, vel);
lattice.get(iX, iY, nz-1).iniEquilibrium((T)1, vel);
}
}
for(int iZ=0; iZ<nz; ++iZ){
for(int iY=0; iY<ny; ++iY){
lattice.get(0, iY, iZ).defineExternalField(
DESCRIPTOR<T>::ExternalField::forceBeginsAt,
DESCRIPTOR<T>::ExternalField::sizeOfForce,
force);
lattice.get(0, iY, iZ).defineRhoU((T)1, vel);
lattice.get(0, iY, iZ).iniEquilibrium((T)1, vel);
}
}
for(int iZ=0; iZ<nz; ++iZ){
for(int iY=0; iY<ny; ++iY){
lattice.get(nx-1, iY, iZ).defineExternalField(
DESCRIPTOR<T>::ExternalField::forceBeginsAt,
DESCRIPTOR<T>::ExternalField::sizeOfForce,
force);
lattice.get(nx-1, iY, iZ).defineRhoU((T)1, vel);
lattice.get(nx-1, iY, iZ).iniEquilibrium((T)1, vel);
}
}
lattice.initialize();
}
Compilation of the code was successful. On running it, however, I got error messages.
I would appreciate if any mistake in the above definitions is pointed out to me.