CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Continuity error with volume flow split boundary condition (http://www.cfd-online.com/Forums/openfoam-solving/121077-continuity-error-volume-flow-split-boundary-condition.html)

mayank.dce2k7 July 21, 2013 05:06

Continuity error with volume flow split boundary condition
 
Hi,

I am trying to simulate a case in which a tube with one inlet bifurcates in two outlets. I ran the case with simpleFoam solver by fixing volume flow rate at all outlets(because that is the condition to be satisfied) and got following errors:

--> 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.000719163
Specified mass inflow : 0.000400984
Specified mass outflow : 0.000400984
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


I ran potentialFoam and used the generated velocity field to run simulation and again encountered same error.

I don't understand when inflow rate is equal to outflow rate then why OpenFoam is giving continuity errors. Any suggestions on solving this problem?

Thanks,
Mayank

wyldckat July 21, 2013 10:59

Greetings Mayank,

What is the boundary condition on the inlet you are using?

I can't remember correctly what the total flux value should be, but clearly the values do not add up.
The total is not equal to the inlet+outlets, therefore you're not allowing enough fluid into the domain or you are extracting too much fluid.

Best regards,
Bruno

mayank.dce2k7 July 21, 2013 15:13

Hi Bruno,

Thanks for the quick response.

The flow at the inlet is parabolic.

Basically, I want to divide the inlet flow into 0.52 times at one outlet and 0.48 times at the other outlet. Below are my 0/p and 0/U files:

0/U

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //



dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    INLET
    {

      type            groovyBC;
      variables "r2=(pow(pos().x,2)+pow(pos().z,2));R2=sum(area())/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;
flowRate    -0.000208512;        // Volumetric/mass flow rate
value      uniform (0 0 0);
    }

    OUTLET2
    {

      type        flowRateInletVelocity;
flowRate    -0.000192472;        // Volumetric/mass flow rate
value      uniform (0 0 0);
    }
}

0/p

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    INLET
    {
        type            zeroGradient;
    }

    OUTLET1
    {
        type            zeroGradient;
    }
 
    OUTLET2
    {
        type            zeroGradient;
    } 

    WALL
    {
        type            zeroGradient;
    }

   
}

// ************************************************************************* //

Thanks,
Mayank

wyldckat July 21, 2013 15:25

Hi Mayank,

What values do you get if you do not constrain the outlets to a fixed value?

And did you know that simply by defining a parabolic shaped inlet, it does not strictly mean that the mass-flow you were calculating for, is properly respected? Because the parabolic profile values will be placed inside discrete cells, for which the total mass-flow sum might not be exactly the same as the parabolic profile... here's an similar example of what I mean: http://ars.els-cdn.com/content/image...003428-gr1.gif

And then there's the really annoying part... OpenFOAM can be veeeery picky with errors of up to 1e-6 or something like that... so, even if it shows that the the values are virtually identical, they are probably not computationally identical :(


I vaguely remember seeing on this forum some discussions about splitting flow between patches... but I can't remember what it talked about in specific :(

Best regards,
Bruno

mayank.dce2k7 July 21, 2013 23:35

Ok, so this means I have to somehow access total volume flow rate field (say phi_inlet) at the inlet patch from within the simulation and define volume flow rate at outlet1=0.52*phi_inlet and outlet2=0.48*phi_inlet .....that can be done using swak4Foam.....I did that but it didn't work either.....it still gave errors.....

Below is 0/U file for what I have said:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //



dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    INLET
    {

      type            groovyBC;
      variables "r2=(pow(pos().x,2)+pow(pos().z,2));R2=sum(area())/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}=sum(phi);";
            expression "-0.52*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}=sum(phi);";
            expression "-0.48*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 );
    }


   

 
}

0/p

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.1.1                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 2 -2 0 0 0 0];

internalField  uniform 0;

boundaryField
{
    INLET
    {
        type            zeroGradient;
    }

    OUTLET1
    {
      type            zeroGradient;
    }
 
    OUTLET2
    {
      type            zeroGradient;
    } 

    WALL
    {
        type            zeroGradient;
    }

   
}

// ************************************************************************* //

I got the following error:

Create time

Create mesh for time = 0

Reading field p

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting RAS turbulence model laminar
No field sources present


SIMPLE: convergence criteria
field p tolerance 1e-05
field U tolerance 1e-05
field nuTilda tolerance 1e-05


Starting time loop

Time = 0.005

swak4Foam: Allocating new repository for sampledGlobalVariables
smoothSolver: Solving for Ux, Initial residual = 1, Final residual = 0.0952526, No Iterations 2
smoothSolver: Solving for Uy, Initial residual = 1, Final residual = 0.0542153, No Iterations 3
smoothSolver: Solving for Uz, Initial residual = 1, Final residual = 0.060015, No Iterations 3


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

When I ran potentialFoam and then used the velocity field for new simulation. I got the same error but with different values:

--> 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.0147875
Specified mass inflow : 0.000801967
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.

mayank.dce2k7 July 26, 2013 18:47

Is there any way I can reduce the tolerance for continuity errors in OpenFOAM?

Regards,
Mayank

wyldckat August 18, 2013 16:45

Hi Mayank,

I see that you continued working on this and that the latest thread related to this topic is this one: http://www.cfd-online.com/Forums/ope...ting-b-cs.html

Unfortunately I don't have the time to look further into this, specially since it looks like it'll require some heavy duty work.

Nonetheless, regarding the last question you made: I haven't found where the setting for the mass flow balance is configurable. :(

Good luck! Best regards,
Bruno

mayank.dce2k7 August 18, 2013 23:30

Thanks Bruno for your concern but the problem is now solved. Thanks to the forum.

Regards,
Mayank.

hrushi.397 August 19, 2013 01:07

Hi Mayank,

How did you solve it?

Thanks,

Hrushi

mayank.dce2k7 August 19, 2013 11:41

I didn't set velocity boundary conditions at all patches. One usually runs into trouble with stupid "continuity errors". The tolerance for continuity error is 10e-8 (refer source code for adjustPhi.C). You should define pressure boundary condition on atleast one patch then everything goes fine.

Do not use the expression "sum(phi)" for setting massflow/volumeflow boundary conditions conditions with swak4FOAM or any other place because at t=0 there is no field as "phi" ,although velocity and pressure fields exist, hence OpenFOAM returns a zero value and continuity errors start showing up.

Regards,
Mayank.

musahossein November 16, 2014 05:16

Continuity error in sloshingtank2d
 
Quote:

Originally Posted by wyldckat (Post 441087)
Hi Mayank,

What values do you get if you do not constrain the outlets to a fixed value?

And did you know that simply by defining a parabolic shaped inlet, it does not strictly mean that the mass-flow you were calculating for, is properly respected? Because the parabolic profile values will be placed inside discrete cells, for which the total mass-flow sum might not be exactly the same as the parabolic profile... here's an similar example of what I mean: http://ars.els-cdn.com/content/image...003428-gr1.gif

And then there's the really annoying part... OpenFOAM can be veeeery picky with errors of up to 1e-6 or something like that... so, even if it shows that the the values are virtually identical, they are probably not computationally identical :(


I vaguely remember seeing on this forum some discussions about splitting flow between patches... but I can't remember what it talked about in specific :(

Best regards,
Bruno

Hi Bruno:
I get continuity errors in sloshingtank2D -- no inlets or outlets, which is strange.The error message is as follows:
[0] --> FOAM FATAL ERROR:
[0] 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 : 5.50768e-18
Specified mass inflow : 1.0222e-17
Specified mass outflow : 4.16554e-17
Adjustable mass outflow : 0
[0]
[0]
[0] From function adjustPhi(surfaceScalarField& phi, const volVectorField& U,const volScalarField& p
[0] in file cfdTools/general/adjustPhi/adjustPhi.C at line 118.
[0]
FOAM parallel run exiting
[0]


I ckecked the adjustPhi.C code and noted the small threshold that triggers this message and causes analysis to stop. Would you have any suggestions as to what might be causing this? I have a small 2D tank -- width 1 m, height 1 m. Water depth is 0.4 m. I am applying discrete oscillations in the range of 0.0002 to 0.006 m. However, the displacements are not in the form of a list, but rather computed by another program and then sent to OpenFoam for computing pressures on the tank walls. So for example, a time time t=0, the displacements are 0; then at time =0.02, the displacement may be 0.003, so OpenFoam will be asked to return the pressure values for the following range:
time displacement
0 0
0.02 0.003

and so on. At each call to OpenFoam, a pair of start/stop time and associated displacement will be sent to OpenFoam. So OpenFoam will be starting and stopping as the program that generates these displacements runs. I realize that the coupling is not an issue, but just thought it may be helpful to give a brief background on the circumstance under which OpenFoam is being run. Thankyou. I look forward to your reply -- or that of anyone in the Forum who might come across this post.

musahossein November 18, 2014 22:03

Sorry for the false alarm. I was generating displacement in the x axis which in the case of the 2D tank, does not have any dimension. In the 2D case there can only be movement in the Y and Z direction, and I was trying to push the tank in the +-X direction.


All times are GMT -4. The time now is 06:58.