CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] and accessing flux on remote patches for setting B.C's (https://www.cfd-online.com/Forums/openfoam-community-contributions/122022-accessing-flux-remote-patches-setting-b-cs.html)

mayank.dce2k7 August 10, 2013 11:44

and accessing flux on remote patches for setting B.C's
 
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 August 10, 2013 14:26

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.

mayank.dce2k7 August 10, 2013 23:00

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?

immortality August 11, 2013 04:04

then where you have find flowRate swak{} dictionary?
I hope Bernhard see it and help.

mayank.dce2k7 August 11, 2013 04:23

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

immortality August 11, 2013 04:36

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.

mayank.dce2k7 August 11, 2013 08:43

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........

gschaider August 11, 2013 20:38

Quote:

Originally Posted by mayank.dce2k7 (Post 444859)
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)

mayank.dce2k7 August 12, 2013 03:09

Thanks Bernhard for your reply.

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

http://www.cfd-online.com/Forums/ope...-split-bc.html

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

gschaider August 12, 2013 13:31

Quote:

Originally Posted by mayank.dce2k7 (Post 445071)
Thanks Bernhard for your reply.

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

http://www.cfd-online.com/Forums/ope...-split-bc.html

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)

mayank.dce2k7 August 13, 2013 15:31

2 Attachment(s)
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?

gschaider August 13, 2013 20:00

Quote:

Originally Posted by mayank.dce2k7 (Post 445514)
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)

mayank.dce2k7 August 19, 2013 12:32

Thanks Bernhard, all the issues related to steady and transient simulations are now resolved.

Mayank.

gschaider August 19, 2013 14:58

Quote:

Originally Posted by mayank.dce2k7 (Post 446676)
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 August 19, 2013 16:49

Hi Mayank
how did you solve the problem? how it was related to steady and transient? :)

mayank.dce2k7 August 21, 2013 11:54

Refer:

http://www.cfd-online.com/Forums/ope...tml#post446682

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

immortality August 21, 2013 17:59

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?

mayank.dce2k7 August 21, 2013 19:25

5 Attachment(s)
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.

mayank.dce2k7 August 21, 2013 19:28

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

gschaider August 21, 2013 20:01

Quote:

Originally Posted by mayank.dce2k7 (Post 447288)
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


All times are GMT -4. The time now is 11:21.