Velocity boundary conditions
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Velocity boundary conditions
- This topic has 8 replies, 2 voices, and was last updated 3 years, 6 months ago by Gloriousface.
-
AuthorPosts
-
May 17, 2021 at 4:31 am #5671GloriousfaceParticipant
Hello,everyone
I’m trying to simulate the two-component flow problem, but the examples are all the velocity boundary problems of one component. Can I use velocity boundary for two components?
Best,
GloriousfaceMay 17, 2021 at 1:15 pm #5672mathiasKeymasterYou can do, yes.
May 17, 2021 at 3:15 pm #5673GloriousfaceParticipantThank you very much for your reply. Sorry to disturb you again. I’m simulating the flow of oil drops in water. According to the example of cylinder2d, I set the velocity boundary at the entrance of two lattices and the pressure boundary at the exit, but the program can’t work normally. I hope you can help me solve this problem, I will be very grateful.
The main parts of the procedure are as follows:
void prepareGeometry(SuperGeometry2D<T>& superGeometry )
{
Vector<T,2> origin1( 0, 0 );
Vector<T,2> extend1( nx,ny );
IndicatorCuboid2D<T> channel( extend1, origin1 );
superGeometry.rename( 0,2 );
superGeometry.rename( 2,1,1,1 );
Vector<T,2> origin2( 0, 0);
Vector<T,2> extend2( 0, ny );
IndicatorCuboid2D<T> inflow( extend2, origin2 );
superGeometry.rename( 2,3,1,inflow );
Vector<T,2> origin3( nx-1, 0);
Vector<T,2> extend3( 1, ny );
IndicatorCuboid2D<T> outflow( extend3, origin3 );
superGeometry.rename( 2,4,1,outflow );
Vector<T,2> center( nx/2, 35);
IndicatorCircle2D<T> circle( center, 30 );
superGeometry.rename( 1,5,circle );
}void prepareLattice( SuperLattice2D<T, DESCRIPTOR>& sLatticeOne,
SuperLattice2D<T, DESCRIPTOR>& sLatticeTwo,
Dynamics<T, DESCRIPTOR>& bulkDynamics1,
Dynamics<T, DESCRIPTOR>& bulkDynamics2,
Dynamics<T, DESCRIPTOR>& bounceBackRho0,
Dynamics<T, DESCRIPTOR>& bounceBackRho1,
SuperGeometry2D<T>& superGeometry )
{
const T omega = 1;
sLatticeOne.defineDynamics( superGeometry, 0, &instances::getNoDynamics<T, DESCRIPTOR>() );
sLatticeTwo.defineDynamics( superGeometry, 0, &instances::getNoDynamics<T, DESCRIPTOR>() );
sLatticeOne.defineDynamics( superGeometry, 1, &bulkDynamics1 );
sLatticeOne.defineDynamics( superGeometry, 2, &bulkDynamics1 );
sLatticeOne.defineDynamics( superGeometry, 3, &bulkDynamics1 );
sLatticeOne.defineDynamics( superGeometry, 4, &bulkDynamics1 );
sLatticeOne.defineDynamics( superGeometry, 5, &bulkDynamics1 );
sLatticeTwo.defineDynamics( superGeometry, 1, &bulkDynamics2 );
sLatticeTwo.defineDynamics( superGeometry, 2, &bulkDynamics2 );
sLatticeTwo.defineDynamics( superGeometry, 3, &bulkDynamics2 );
sLatticeTwo.defineDynamics( superGeometry, 4, &bulkDynamics2 );
sLatticeTwo.defineDynamics( superGeometry, 5, &bulkDynamics2 );setLocalVelocityBoundary<T,DESCRIPTOR>(sLatticeOne, omega, superGeometry, 3);
setLocalPressureBoundary<T,DESCRIPTOR>(sLatticeOne, omega, superGeometry, 4);
setLocalVelocityBoundary<T,DESCRIPTOR>(sLatticeTwo, omega, superGeometry, 3);
setLocalPressureBoundary<T,DESCRIPTOR>(sLatticeTwo, omega, superGeometry, 4);sLatticeOne.defineDynamics( superGeometry, 2, &bounceBackRho0 );
sLatticeTwo.defineDynamics( superGeometry, 2, &bounceBackRho1 );
}void setBoundaryValues( SuperLattice2D<T, DESCRIPTOR>& sLatticeOne,
SuperLattice2D<T, DESCRIPTOR>& sLatticeTwo,
T force, int iT, SuperGeometry2D<T>& superGeometry )
{
if ( iT==0 ) {
AnalyticalConst2D<T,T> noise( 4.e-2 );
std::vector<T> v( 2,T() );
AnalyticalConst2D<T,T> zeroV( v );
AnalyticalConst2D<T,T> zero( 1.e-6 );
AnalyticalLinear2D<T,T> one( 0.,-force*invCs2<T,DESCRIPTOR>(),0.98+force*ny*invCs2<T,DESCRIPTOR>() );
AnalyticalConst2D<T,T> onePlus( 0.98+force*ny/2.*invCs2<T,DESCRIPTOR>() );
AnalyticalRandom2D<T,T> random;
AnalyticalIdentity2D<T,T> randomOne( random*noise+one );
AnalyticalIdentity2D<T,T> randomPlus( random*noise+onePlus );
std::vector<T> F( 2,T() );
F[1] = -force;
AnalyticalConst2D<T,T> f( F );sLatticeOne.defineRhoU( superGeometry, 5, zero, zeroV );
sLatticeOne.iniEquilibrium( superGeometry, 5, zero, zeroV );
sLatticeOne.defineField<descriptors::EXTERNAL_FORCE>( superGeometry, 5, f );
sLatticeTwo.defineRhoU( superGeometry, 5, randomPlus, zeroV );
sLatticeTwo.iniEquilibrium( superGeometry, 5, randomPlus, zeroV );sLatticeOne.defineRhoU( superGeometry, 1, randomOne, zeroV );
sLatticeOne.iniEquilibrium( superGeometry, 1, randomOne, zeroV );
sLatticeOne.defineField<descriptors::EXTERNAL_FORCE>( superGeometry, 1, f );
sLatticeTwo.defineRhoU( superGeometry, 1, zero, zeroV );
sLatticeTwo.iniEquilibrium( superGeometry, 1, zero, zeroV );sLatticeOne.defineRhoU(superGeometry, 3, randomOne, zeroV);
sLatticeOne.iniEquilibrium(superGeometry, 3, randomOne, zeroV);
sLatticeOne.defineField<descriptors::EXTERNAL_FORCE>(superGeometry, 3, f);
sLatticeTwo.defineRhoU(superGeometry, 3, randomOne, zeroV);
sLatticeTwo.iniEquilibrium(superGeometry, 3, randomOne, zeroV);sLatticeOne.defineRhoU(superGeometry, 4, randomPlus, zeroV);
sLatticeOne.iniEquilibrium(superGeometry, 4, randomPlus, zeroV);
sLatticeOne.defineField<descriptors::EXTERNAL_FORCE>(superGeometry, 4, f);
sLatticeTwo.defineRhoU(superGeometry, 4, randomPlus, zeroV);
sLatticeTwo.iniEquilibrium(superGeometry, 4, randomPlus, zeroV);sLatticeOne.defineRhoU(superGeometry, 2, zero, zeroV);
sLatticeOne.iniEquilibrium(superGeometry, 2, zero, zeroV);
sLatticeOne.defineField<descriptors::EXTERNAL_FORCE>(superGeometry, 2, f);
sLatticeTwo.defineRhoU(superGeometry, 2, zero, zeroV);
sLatticeTwo.iniEquilibrium(superGeometry, 2, zero, zeroV);PolynomialStartScale<T,T> StartScale( maxIter, T( 1 ) );
T iTvec[1] = {T( iT )};
T frac[1] = {};
StartScale( frac,iTvec );
T maxVelocity = 0.02*3./2.*frac[0];
T distance2Wall = 0.1;
Poiseuille2D<T> poiseuilleU( superGeometry, 3, maxVelocity, distance2Wall );
sLatticeOne.defineU( superGeometry, 3, poiseuilleU );
sLatticeTwo.defineU( superGeometry, 3, poiseuilleU );sLatticeOne.initialize();
sLatticeTwo.initialize();
}
}May 17, 2021 at 3:56 pm #5674mathiasKeymasterUsing a pressure boundary means fixing the density which is not a good idea if you are interested in the density evolutions. You should set a convetion boundary condition instead, which is a Neuman condition for density and velocity!
May 18, 2021 at 4:40 am #5675GloriousfaceParticipantThank you very much for your reply. In fact, the oil-water two-phase density I simulated should be fixed. I have some questions about the speed setting,
T distance2Wall = 0.1;
What is the function of distance2Wall?
May 18, 2021 at 11:37 am #5676mathiasKeymasterit is basically there ot distigish betwwen bounce back boundaries (0.5) and other (1.0).
May 18, 2021 at 3:56 pm #5677GloriousfaceParticipantThank you for answering my question in your busy schedule. In the parameter initialization of velocity and pressure boundary in bstep2d, set the density to 1.
setLocalVelocityBoundary<T,DESCRIPTOR>(sLattice, converter.getLatticeRelaxationFrequency(), superGeometry, 3);
setLocalPressureBoundary<T,DESCRIPTOR>(sLattice, converter.getLatticeRelaxationFrequency(), superGeometry, 4);
AnalyticalConst2D<T,T> rho( 1. );
sLattice.defineRhoU( bulkIndicator, rho, u );
sLattice.iniEquilibrium( bulkIndicator, rho, u );How to assign the density in the initial condition of velocity and pressure boundary in multicomponent flow?
May 18, 2021 at 8:20 pm #5678mathiasKeymasterYou can see that in our multi-component examples. Best Mathias
May 20, 2021 at 6:00 am #5680GloriousfaceParticipantThank you very much for your reply.
-
AuthorPosts
- You must be logged in to reply to this topic.