CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

swak4Foam and accessing flux on remote patches for setting B.C's

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree5Likes
  • 1 Post By mayank.dce2k7
  • 1 Post By gschaider
  • 1 Post By mayank.dce2k7
  • 1 Post By gschaider
  • 1 Post By mayank.dce2k7

Reply
 
LinkBack Thread Tools Display Modes
Old   August 10, 2013, 10:44
Default swak4Foam and accessing flux on remote patches for setting B.C's
  #1
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Hi Foamers,

I am trying to access flux at 'INLET' patch and set the B.C at 'OUTLET1' patch equal to 0.52 times the flux at inlet patch and B.C at 'OUTLET2' patch equal to 0.48 times the flux at inlet patch. Since I have specified parabolic velocity profile at inlet I don't know the exact value of flux at inlet so I need to access the flux at inlet somehow from within simulation. I am working to fix this bug for over a month but with no success.

I used below B.C's for setting flow rate B.C's at inlet and outlet:

INLET
{

type groovyBC;
variables "r2=(pow(pos().x,2)+pow(pos().z,2));R2=sum(are a())/pi;para=-((R2-r2)/R2)*normal();";
valueExpression "2*0.351*para"; //where 0.351 is the average velocity
value uniform (0 0 0);

}

WALL
{
type fixedValue;
value uniform (0 0 0);
}

OUTLET1
{

type flowRateInletVelocity;
flowRateExpression "0";
flowRate swak {
variables "phi1{INLET}=-0.52*sum(phi);";
expression "phi1"; // volume flow going out of domain from outlet 1 which 0.52 times that at inlet
valueType patch;
patchName OUTLET1;
};

value uniform ( 0 0 0 );
}

OUTLET2
{

type flowRateInletVelocity;
flowRateExpression "0";
flowRate swak {
variables "phi2{INLET}=-0.48*sum(phi);";
expression "phi2"; // volume flow going out of domain from outlet 1 which 0.52 times that at inlet
valueType patch;
patchName OUTLET2;
};

value uniform ( 0 0 0 );
}


Error message:

--> FOAM FATAL ERROR:
Continuity error cannot be removed by adjusting the outflow.
Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow.
Total flux : 0.000360325
Specified mass inflow : 0.000400984
Specified mass outflow : 0
Adjustable mass outflow : 0


From function adjustPhi(surfaceScalarField& phi, const volVectorField& U,const volScalarField& p
in file cfdTools/general/adjustPhi/adjustPhi.C at line 118.

FOAM exiting

The problem lies in using the expression "phi1{INLET}= -0.52*sum(phi)" here the value of "sum(phi)" is returned zero everytime and I am unable to understand why?
immortality likes this.
mayank.dce2k7 is offline   Reply With Quote

Old   August 10, 2013, 13:26
Default
  #2
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Hi
I'm curious about the cause .
are you sure you can use groovyBC dictionary mixed with ordinary BC types like flowRateInletVelocity? it seems it always read flowRateExpression "0"; not the Swak dictionary if not mistake. isn't there a BC like flowRateOutletVelocity for outlet?
it will be nice if you find an example related to this subject.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 10, 2013, 22:00
Default
  #3
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Hi Ehsan,

Thanks for your response.

No, even if I change the value of 'flowRateExpression' to '1' it doesn't make any difference for 'flowRateInletVelocity' with sawk4Foam data entry. I haven't found any examples of this sort in which an expression for setting volume flow rate is used . Infact, it doesn't make any difference if I remove 'flowRateExpression' field itself.

There is definitely some problem with expression " phi1{INLET}=-0.52*sum(phi)" or " phi1{INLET}=-0.48*sum(phi)" as value of "sum(phi)" returned is 'zero' everytime. Also, when I give some constant value in place of expression it is reflected in mass outflow as a non zero value in the output that means giving volume flow rate expression is a problem.

May be there is a scope of bug fix with swak4Foam in this case as everytime the value of "sum(phi)" at inlet is taken as zero....while it is not......it is around 0.0004 m3/s which is reflected in mass inflow in the output as below:

Continuity error cannot be removed by adjusting the outflow.
Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow.
Total flux : 0.000360325
Specified mass inflow : 0.000400984
Specified mass outflow : 0
Adjustable mass outflow : 0

FYI: I have also tried running 'potentialFoam' to initialize the flow and then run simpleFoam but it didn't help either.

Somebody can help, I am stuck for long time or tell an alternative?
mayank.dce2k7 is offline   Reply With Quote

Old   August 11, 2013, 03:04
Default
  #4
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
then where you have find flowRate swak{} dictionary?
I hope Bernhard see it and help.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 11, 2013, 03:23
Default
  #5
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Hi Ehsan,

If you have installed Swak4Foam then u will find the use of flowRateInletVelocity with swak4Foam data entry in the following example case included with swak4Foam:

/run/Swak4Foam_2.x_release_0.2.3/Examples/tests/swakDataEntry/flowRateAngledDuct

Is there a way I can tag people in my posts to attract their attention for some specific problems? for example in this case Bernhard

Regards,
Mayank
mayank.dce2k7 is offline   Reply With Quote

Old   August 11, 2013, 03:36
Default
  #6
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
inlet
{
type flowRateInletVelocity;
// type groovyFlowRateInletVelocity;
flowRateExpression "0.1";
flowRate swak {
expression "0.1";
valueType patch;
patchName inlet;
};
// flowRate constant 0.1;
value uniform (0 0 0);
}
here it is written for inlet I'm not sure if it be applicable for outlet in this form and expression is a constant maybe it has some issue with expressions.
Bernhard Gschaider reads threads carefully,don't worry.its in tests folder,its fine if you could find another example anywhere else I think.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 11, 2013, 07:43
Default
  #7
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Its applicable for the outlet too the only thing is that you have to put a negative sign for example "-0.1" and it is taken as outflow. I can't find any other example for the usage of "flowRateInletVelocity" with swak4Foam data entry in expression form.

May be it is a bug as this kind of stuff works fine on ANSYS i.e setting of mass flow/volume flow B.C's........
mayank.dce2k7 is offline   Reply With Quote

Old   August 11, 2013, 19:38
Default
  #8
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mayank.dce2k7 View Post
Hi Foamers,

I am trying to access flux at 'INLET' patch and set the B.C at 'OUTLET1' patch equal to 0.52 times the flux at inlet patch and B.C at 'OUTLET2' patch equal to 0.48 times the flux at inlet patch. Since I have specified parabolic velocity profile at inlet I don't know the exact value of flux at inlet so I need to access the flux at inlet somehow from within simulation. I am working to fix this bug for over a month but with no success.

I used below B.C's for setting flow rate B.C's at inlet and outlet:

INLET
{

type groovyBC;
variables "r2=(pow(pos().x,2)+pow(pos().z,2));R2=sum(are a())/pi;para=-((R2-r2)/R2)*normal();";
valueExpression "2*0.351*para"; //where 0.351 is the average velocity
value uniform (0 0 0);

}

WALL
{
type fixedValue;
value uniform (0 0 0);
}

OUTLET1
{

type flowRateInletVelocity;
flowRateExpression "0";
flowRate swak {
variables "phi1{INLET}=-0.52*sum(phi);";
expression "phi1"; // volume flow going out of domain from outlet 1 which 0.52 times that at inlet
valueType patch;
patchName OUTLET1;
};

value uniform ( 0 0 0 );
}

OUTLET2
{

type flowRateInletVelocity;
flowRateExpression "0";
flowRate swak {
variables "phi2{INLET}=-0.48*sum(phi);";
expression "phi2"; // volume flow going out of domain from outlet 1 which 0.52 times that at inlet
valueType patch;
patchName OUTLET2;
};

value uniform ( 0 0 0 );
}


Error message:

--> FOAM FATAL ERROR:
Continuity error cannot be removed by adjusting the outflow.
Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow.
Total flux : 0.000360325
Specified mass inflow : 0.000400984
Specified mass outflow : 0
Adjustable mass outflow : 0


From function adjustPhi(surfaceScalarField& phi, const volVectorField& U,const volScalarField& p
in file cfdTools/general/adjustPhi/adjustPhi.C at line 118.

FOAM exiting

The problem lies in using the expression "phi1{INLET}= -0.52*sum(phi)" here the value of "sum(phi)" is returned zero everytime and I am unable to understand why?
The error message is typical for cases where the velocity is fixed on all boundaries (which should be avoided).

I'm not totally sure, but I guess the problem here is that when U gets loaded there is no phi. Thus the value becomes 0. When phi gets calculated the first time it sees a U of 0 .... thus becomes 0 itself ... and the result you see in the error message.

Anyway: what I would recommend: avoid setting the velocity on all boundaries. Just set it on ONE of the outlets and leave the other one "free" (zeroGradient/inlet). The flow on the "free" outlet has to adjust to the "other" 48% anyway. You can even use that as a measure for the convergence/accuracy of your calculation.

PS: it also occured to me that you sum up phi in the expression (==total massflow) but don't divide it (which should give you too high an outflow anyway)
immortality likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 12, 2013, 02:09
Default
  #9
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Thanks Bernhard for your reply.

As I wrote I was researching on this problem for a long time. I got across this thread:

mass flow split BC

where you gave same advice. Accordingly, I set the boundary condition as follows:

1.) Steady state simulation with simpleFoam

Inlet: U parabolic profile with groovyBC, p- zerogradient
outlet1: U volume flow rate set to x% of inlet flux, p=zerogradient
outlet2: U zero gradient, p=0 (fixed value)

The simulation ran for long time but can't achieve converged solution? Any thoughts how can I improve convergence performance.

2.) Transient simulation with pimpleFoam:

Inlet: U parabolic profile with groovyBC varying with space and time , p- zerogradient
outlet1: U volume flow rate set to x% of inlet flux, p=zerogradient
outlet2: U pressureInletOutletVelocity, p=0 (fixed value)

Do these B.C's look ok as there is a chance of backflow from both the outlets? Also, above transient simulation crashes with icoFoam at around t=0.05 and takes unusually long with pimpleFoam

Regards,
Mayank
immortality likes this.
mayank.dce2k7 is offline   Reply With Quote

Old   August 12, 2013, 12:31
Default
  #10
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mayank.dce2k7 View Post
Thanks Bernhard for your reply.

As I wrote I was researching on this problem for a long time. I got across this thread:

mass flow split BC

where you gave same advice. Accordingly, I set the boundary condition as follows:

1.) Steady state simulation with simpleFoam

Inlet: U parabolic profile with groovyBC, p- zerogradient
outlet1: U volume flow rate set to x% of inlet flux, p=zerogradient
outlet2: U zero gradient, p=0 (fixed value)

The simulation ran for long time but can't achieve converged solution? Any thoughts how can I improve convergence performance.

2.) Transient simulation with pimpleFoam:

Inlet: U parabolic profile with groovyBC varying with space and time , p- zerogradient
outlet1: U volume flow rate set to x% of inlet flux, p=zerogradient
outlet2: U pressureInletOutletVelocity, p=0 (fixed value)

Do these B.C's look ok as there is a chance of backflow from both the outlets? Also, above transient simulation crashes with icoFoam at around t=0.05 and takes unusually long with pimpleFoam

Regards,
Mayank
Any BC that gives U some liberty (zeroGradient) has a CHANCE of getting backflow. Whether there is actual backflow is best judged by you by looking at the results in paraview.

One possibility to reduce backflow is making the outlet channel longer (if possible).

Apart from that it is hard to give you any hints without looking at your actual case (which I'm not prepared to do)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 13, 2013, 14:31
Default
  #11
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Hi Bernhard,

It looks like, I am making some progress. I got the steady state simulation running with discussed boundary conditions for simpleFoam in my previous post. I had to play around a little with divergence schemes and relaxation factors to get convergence.

I applied similar B.C's for transient simulation(except time varying parabolic velocity profile at inlet) and ran it with both icoFoam as well as pimpleFoam but they both blew up. My case(consisting of a tube with one inlet and two outlets) has a backflow from both outlets at some point of time as the same case was simulated on ANSYS-CFX. I have attached two images of ANSYS-CFX results to give you a better idea.

Can you advice me how to get similar results with backflow using icoFoam or pimpleFoam?
Attached Images
File Type: jpg normal.jpg (27.6 KB, 18 views)
File Type: jpg backflow.jpg (35.0 KB, 26 views)
mayank.dce2k7 is offline   Reply With Quote

Old   August 13, 2013, 19:00
Default
  #12
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mayank.dce2k7 View Post
Hi Bernhard,

It looks like, I am making some progress. I got the steady state simulation running with discussed boundary conditions for simpleFoam in my previous post. I had to play around a little with divergence schemes and relaxation factors to get convergence.

I applied similar B.C's for transient simulation(except time varying parabolic velocity profile at inlet) and ran it with both icoFoam as well as pimpleFoam but they both blew up. My case(consisting of a tube with one inlet and two outlets) has a backflow from both outlets at some point of time as the same case was simulated on ANSYS-CFX. I have attached two images of ANSYS-CFX results to give you a better idea.

Can you advice me how to get similar results with backflow using icoFoam or pimpleFoam?
Probably CFX does something to keep the "outflows" stable. But I have no idea what and frankly this is not a swak-problem (swak may allow you to implement it). One idea would be to make the inlet an outlet once the flow reverses there (same for the outlets)
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 19, 2013, 11:32
Default
  #13
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Thanks Bernhard, all the issues related to steady and transient simulations are now resolved.

Mayank.
mayank.dce2k7 is offline   Reply With Quote

Old   August 19, 2013, 13:58
Default
  #14
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mayank.dce2k7 View Post
Thanks Bernhard, all the issues related to steady and transient simulations are now resolved.

Mayank.
You might want to add a short description what you did (or a link if it was solved in another thread) so that people who have a similar problem and search for a solution on the board might be helped. Thanks
immortality likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   August 19, 2013, 15:49
Default
  #15
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Hi Mayank
how did you solve the problem? how it was related to steady and transient?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 21, 2013, 10:54
Default
  #16
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Refer:

Continuity error with volume flow split boundary condition

AND

For steady state I was facing trouble with achieving convergence. So I changed the divergence scheme for U from linear to upwind. There was no such trouble with transient but there was a backflow, which was desired, and as Bernhard said I imposed a zeroGradient B.C on outlets and obtained a stable solution with backflow.

Regards,
Mayank
mayank.dce2k7 is offline   Reply With Quote

Old   August 21, 2013, 16:59
Default
  #17
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
I didn't understand exactly,you mean you expect that flow be reversed completely,means outlets become inlet and inlet become outlet during transient study and it should be so?it has been in plan?
then you should change BC's when this essential change in flow occurs,how did you do it?
and in steady state doesn't occur this situation?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   August 21, 2013, 18:25
Default
  #18
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
Hi Ehsan,

Yaa, flow reversal was in plan. Velocity at inlet was function of time and space and sure it becomes negative at some point of time.

It was not required to reverse B.C's at the time of flow reversal. I have attached snapshots from simulation at t=1, t=5, t=10, t=15, t=20 to give you an idea of simulation results and what I wanted.

Regards,
Mayank.
Attached Images
File Type: jpg t1.jpg (22.3 KB, 6 views)
File Type: jpg t5.jpg (23.6 KB, 6 views)
File Type: jpg t10.jpg (21.5 KB, 3 views)
File Type: jpg t15.jpg (23.3 KB, 5 views)
File Type: jpg t20.jpg (23.3 KB, 3 views)
immortality likes this.
mayank.dce2k7 is offline   Reply With Quote

Old   August 21, 2013, 18:28
Default
  #19
Member
 
India
Join Date: Oct 2012
Posts: 84
Rep Power: 4
mayank.dce2k7 is on a distinguished road
I had one more question. I am also doing a particle simulation on the same bifurcating tube geometry using icoUcoupledKinematicParcelFoam and I want to count the number of particles coming out of each outlet separately. Can this be done using swak4Foam or any other method?

Mayank
mayank.dce2k7 is offline   Reply With Quote

Old   August 21, 2013, 19:01
Default
  #20
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by mayank.dce2k7 View Post
I had one more question. I am also doing a particle simulation on the same bifurcating tube geometry using icoUcoupledKinematicParcelFoam and I want to count the number of particles coming out of each outlet separately. Can this be done using swak4Foam or any other method?

Mayank
Swak can't do this. But there are CloudFunctionObjects and one of them is called PatchPostProcessing. But that is all I know
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 23:32.