Fluid Inlet Velocity Boundary
I need to define a "Velocity Inlet" boundary condition for fluid.
For instance, I need to define a specific fluid velocity at inlet of a pipe. I can create it by a moving piston, but I want to know if there are any other ways?
For instance, I need to define a specific fluid velocity at inlet of a pipe. I can create it by a moving piston, but I want to know if there are any other ways?
Comments
You can use the initial velocity or a tank model where the fluid flows out of the tank leading to your fluid domain.
In my observation the moving piston has a negative effect on the fluid density because of the compressible sph approach.
In the case of using tank, you have to increase the particle number to be able to create the velocity. It increases the cpu time and is not a good suggestion.
I think there should be another way.
Both methods require source code modifications !
sorry for answering on such an old posting, but mn61´s comment on " patch the velocity" sounds interesting. Is this already an available function or is it something, which one needs to implement?
Greetings
Chris
My solution although not elegant/very crude is this:
(find and change appropriate lines in code)
* JPeriodicGpu.h
void CheckPositionAll(bool boundchanged,float3* posg, float3* velg);
///
* JPeriodicGPU.cpp
void JPeriodicGpu::CheckPositionAll(bool boundchanged,float3* posg, float3* velg)
...
cuperi::CheckPositionAll(n,pini,posg,xrun,xmin,xmax,xperinc,yrun,ymin,ymax,yperinc,zrun,zmin,zmax,zperinc,velg);
///
* JSphGpuSingle.cpp
PeriZone->CheckPositionAll(BoundChanged,Posg,Velg);
///
*JPeriodPeriodicGpu_ker.h
void CheckPositionAll(unsigned n,unsigned pini,float3 *pos,bool xrun,float xmin,float xmax,tfloat3 xperinc,bool yrun,float ymin,float ymax,tfloat3 yperinc,bool zrun,float zmin,float zmax,tfloat3 zperinc,float3 *vel);
///
* JPeriodPeriodicGpu_ker.cu
template __global__ void KerCheckPositionAll(unsigned n,unsigned pini,float3 *pos,float xmin,float xmax,float3 xperinc,float ymin,float ymax,float3 yperinc,float zmin,float zmax,float3 zperinc, float3 *vel){
const unsigned p=blockIdx.y*gridDim.x*blockDim.x + blockIdx.x*blockDim.x + threadIdx.x; //-Number of particle.
if(p=xmax){ rpos=make_float3(rpos.x+xperinc.x,rpos.y+xperinc.y,rpos.z+xperinc.z); rvel=make_float3(0,0,0); modif=true; }
}
if(yrun){
if(rpos.y=ymax){ rpos=make_float3(rpos.x+yperinc.x,rpos.y+yperinc.y,rpos.z+yperinc.z); rvel=make_float3(0,0,0); modif=true; }
}
if(zrun){
if(rpos.z=zmax){ rpos=make_float3(rpos.x+zperinc.x,rpos.y+zperinc.y,rpos.z+zperinc.z); rvel=make_float3(0,0,0); modif=true; }
}
if(modif)pos[p2]=rpos;
if(modif)vel[p2]=rvel;
}}
///
void CheckPositionAll(unsigned n,unsigned pini,float3 *pos,bool xrun,float xmin,float xmax,tfloat3 xperinc,bool yrun,float ymin,float ymax,tfloat3 yperinc,bool zrun,float zmin,float zmax,tfloat3 zperinc,float3 *vel)
{
if(n){
dim3 sgrid=GetGridSize(n,PERIODICBSIZE);
if(xrun){ const bool runx=true;
if(yrun){ const bool runy=true;
if(zrun)KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
else KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
}
else{ const bool runy=false;
if(zrun)KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
else KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
}
}
else{ const bool runx=false;
if(yrun){ const bool runy=true;
if(zrun)KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
else KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
}
else{ const bool runy=false;
if(zrun)KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
else KerCheckPositionAll <<<sgrid,PERIODICBSIZE>>> (n,pini,pos,xmin,xmax,Float3(xperinc),ymin,ymax,Float3(yperinc),zmin,zmax,Float3(zperinc),vel);
} } }}
///
This to my understanding copies to device memory the velocity vector and might increase computational times, tough I'm not sure how much.
What I imagined was something to enhance the JSph class definition with:
*JSph.h
/// Structure with inlet information v = v0 + c.(|r0 - r|)^b
typedef struct {
bool InletResetOption; ///reset velocities yes/no
tfloat3 InletVelCenter; /// [r0] inlet velocity center
tfloat3 InletVelBase; /// [v0] base velocity at inlet center
float InletVelExp; /// [b] velocity exponent
float InletVelCoef; /// [c] 0 = Constant velocity; Negative = Maximum at the center; Positive = Minimum at the center
}Inlet;
and also:
void JSph::LoadCaseConfig(){
...
if(eparms.Exists("InletReset")&&eparms.GetValueInt("InletReset",true,0)==1)
{
InletReset.InletResetOption = true;
InletReset.InletVelBase = TFloat3(0);
if(eparms.Exists("InletVelBaseX"))
{ InletReset.InletVelBase.x = eparms.GetValueFloat("InletVelBaseX",true,0); }
if(eparms.Exists("InletVelBaseY"))
{ InletReset.InletVelBase.y = eparms.GetValueFloat("InletVelBaseY",true,0); }
if(eparms.Exists("InletVelBaseZ"))
{ InletReset.InletVelBase.z = eparms.GetValueFloat("InletVelBaseZ",true,0); }
if(eparms.Exists("InletVelCenterX"))
{ InletReset.InletVelCenter.x = eparms.GetValueFloat("InletVelCenterX",true,0); }
if(eparms.Exists("InletVelCenterY"))
{ InletReset.InletVelCenter.y = eparms.GetValueFloat("InletVelCenterY",true,0); }
if(eparms.Exists("InletVelCenterZ"))
{ InletReset.InletVelCenter.z = eparms.GetValueFloat("InletVelCenterZ",true,0); }
if(eparms.Exists("InletVelCoef"))
{ InletReset.InletVelCoef= eparms.GetValueFloat("InletVelCoef",true,0); }
if(eparms.Exists("InletVelExp"))
{ InletReset.InletVelExp= eparms.GetValueFloat("InletVelExp",true,1); } }
This way I could change the velocity of incoming particles according to a set o rules: inlet center + particle position and velocity equation.
I did not implemented this and do not know if it would work.