示例#1
0
void setBoundaryValues(LBconverter<T> const* converter,
                       BlockStructure2D<T,DESCRIPTOR>& lattice, int iT){

  if(iT==0){

    const int nx = lattice.getNx();
    const int ny = lattice.getNy();

    // set initial values: v = [0,0]
    for (int iX=0; iX<nx; ++iX) {
      for (int iY=0; iY<ny; ++iY) {
        T vel[] = { T(), T()};
        lattice.get(iX,iY).defineRhoU((T)1, vel);
        lattice.get(iX,iY).iniEquilibrium((T)1, vel);
      }
    }

    // set non-zero velocity for upper boundary cells
    for (int iX=1; iX<nx-1; ++iX) {
      T u = converter->getLatticeU();
      T vel[] = { u, T() };
      lattice.get(iX,ny-1).defineRhoU((T)1, vel);
      lattice.get(iX,ny-1).iniEquilibrium((T)1, vel);
    }

    // Make the lattice ready for simulation
    lattice.initialize();
  }
}
示例#2
0
void setBoundaryValues(LBconverter<T> const&converter,
                       BlockStructure2D<T,DESCRIPTOR>& lattice, int iT){

  int nx = lattice.getNx();
  int ny = lattice.getNy();

  if(iT==0){
    for (int iX=0; iX<nx; ++iX) {
      for (int iY=0; iY<ny; ++iY) {
        T force[2] = { poiseuilleForce(converter), T() };
        lattice.get(iX,iY).defineExternalField (
          DESCRIPTOR<T>::ExternalField::forceBeginsAt,
          DESCRIPTOR<T>::ExternalField::sizeOfForce,
          force
        );
      }
    }
    /// Make the lattice ready for simulation
    lattice.initialize();
  }
}
示例#3
0
void iniGeometry( BlockStructure2D<T, DESCRIPTOR>& lattice,
                  LBunits<T> const& converter,
                  Dynamics<T, DESCRIPTOR>& bulkDynamics,
                  OnLatticeBoundaryCondition2D<T,DESCRIPTOR>& boundaryCondition,
                  BoundaryType boundaryType )
{
    int nx = converter.getNx();
    int ny = converter.getNy();
    T   omega = converter.getOmega();
    lattice.defineDynamics(0,nx-1, 0,ny-1, &bulkDynamics);

    boundaryCondition.addVelocityBoundary1P(1,nx-2,ny-1,ny-1, omega);
    boundaryCondition.addVelocityBoundary1N(1,nx-2,   0,   0, omega);

    if (boundaryType==velocity) {
        boundaryCondition.addVelocityBoundary0N(0,0, 1, ny-2, omega);
        boundaryCondition.addVelocityBoundary0P(nx-1,nx-1, 1, ny-2, omega);
    }
    else {
        boundaryCondition.addPressureBoundary0N(0,0, 1, ny-2, omega);
        boundaryCondition.addPressureBoundary0P(nx-1,nx-1, 1, ny-2, omega);
    }

    boundaryCondition.addExternalVelocityCornerNN(0,0, omega);
    boundaryCondition.addExternalVelocityCornerNP(0,ny-1, omega);
    boundaryCondition.addExternalVelocityCornerPN(nx-1,0, omega);
    boundaryCondition.addExternalVelocityCornerPP(nx-1,ny-1, omega);

    for (int iX=0; iX<nx; ++iX) {
        for (int iY=0; iY<ny; ++iY) {
            T u[2] = {poiseuilleVelocity(iY, converter),0.};
            T rho = (T)1 + poiseuillePressure(iX, converter) * DESCRIPTOR<T>::invCs2;
            lattice.get(iX,iY).defineRhoU(rho, u);
            lattice.get(iX,iY).iniEquilibrium(rho, u);
        }
    }

    lattice.initialize();
}
示例#4
0
void iniGeometry( BlockStructure2D<T, DESCRIPTOR>& latticeOne,
                  BlockStructure2D<T, DESCRIPTOR>& latticeTwo,
                  Dynamics<T, DESCRIPTOR>& bulkDynamics1,
                  Dynamics<T, DESCRIPTOR>& bulkDynamics2,
                  Dynamics<T, DESCRIPTOR>& bounceBackRho0,
                  Dynamics<T, DESCRIPTOR>& bounceBackRho1,
                  T force
                )
{
    // The setup is: periodicity along horizontal direction, bounce-back on top
    // and bottom. The upper half is initially filled with fluid 1 + random noise,
    // and the lower half with fluid 2. Only fluid 1 experiences a forces,
    // directed downwards.
    T noise      = 1.e-2;
    
    int nx = latticeOne.getNx();
    int ny = latticeOne.getNy();
    
    latticeOne.defineDynamics(0,nx-1, 0,ny-1, &bulkDynamics1);
    latticeTwo.defineDynamics(0,nx-1, 0,ny-1, &bulkDynamics2);

    latticeOne.defineDynamics(0,nx-1, 0,0, &bounceBackRho0);
    latticeTwo.defineDynamics(0,nx-1, 0,0, &bounceBackRho1);
    latticeOne.defineDynamics(0,nx-1, ny-1,ny-1, &bounceBackRho1);
    latticeTwo.defineDynamics(0,nx-1, ny-1,ny-1, &bounceBackRho0);
   
    for (int iX=0; iX<nx; ++iX) {
        for (int iY=0; iY<ny; ++iY) {
            T f[2] = {0.,-force};
            T zeroVelocity[2] = {0.,0.};
            T noForce[2] = {0.,0.};
            T rho1 = (T)1;
            T rho2 = (T)1;
            if (iY>ny/2) {
                rho2 = 0.;
                rho1 += (double)random()/(double)RAND_MAX * noise;
                rho1 += force*DESCRIPTOR<T>::invCs2* ((T)ny - (T)iY - (T)ny/(T)2);
            }
            else {
                rho1 = 0.;
            }

            Cell<T,DESCRIPTOR>& cell1 = latticeOne.get(iX,iY);
            cell1.defineRhoU(rho1, zeroVelocity);
            cell1.iniEquilibrium(rho1, zeroVelocity);
            cell1.defineExternalField (
                    DESCRIPTOR<T>::ExternalField::forceBeginsAt,
                    DESCRIPTOR<T>::ExternalField::sizeOfForce, f );
        
            Cell<T,DESCRIPTOR>& cell2 = latticeTwo.get(iX,iY);
            cell2.defineRhoU(rho2, zeroVelocity);
            cell2.iniEquilibrium(rho2, zeroVelocity);
            cell2.defineExternalField (
                    DESCRIPTOR<T>::ExternalField::forceBeginsAt,
                    DESCRIPTOR<T>::ExternalField::sizeOfForce, noForce );
        }
    }
    
    latticeOne.initialize();
    latticeTwo.initialize();
}