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

cyclic boundary violates mass conservation

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 7, 2015, 21:47
Default cyclic boundary violates mass conservation
  #1
New Member
 
Maik Wissing
Join Date: Jan 2015
Posts: 5
Rep Power: 2
Maik is on a distinguished road
Dear everyone,
the title might be a little provocative and it might be more likely that I made a mistake in the boundary settings (that's why I choose this forum and not the bug section).

My setup is a fish passage in which one segment should be made "endless" by a cyclic boundary condition. This segment has a slope, so inlet and outlet are not on the same altitude, which I assumed would automatically generate a continuous flow as soon as inlet and outlet are connected by a cyclic boundary (because given by the slope the water level is higher at the outlet).

The problem is that after about 40s the water is almost gone!

I checked if the simulation is also loosing water when setting cyclic to a wall, but that looks fine.

I would be very thankful if an expert could have a short look at it and tell me what I did wrong to manipulate physics in such a undesired way.


Here are my boundaries:
(A link with the full project is at the end of the post.)

alpha.water before setFields

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      alpha.water;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions      [0 0 0 0 0 0 0];

internalField   uniform 0;

boundaryField
{
    wall
    {
        type            zeroGradient;
    }

    atmosphere
    {
        type            inletOutlet;
        inletValue      uniform 0;
        value           uniform 0;
    }
    
    cyc_half0
    {
        type            cyclic;
        neighbourPatch  cyc_half1;
    }
    
    cyc_half1
    {
        type            cyclic;
        neighbourPatch  cyc_half0;
    }
}
U

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    location    "0";
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions      [0 1 -1 0 0 0 0];

internalField   uniform (0 0 0);

boundaryField
{
    wall
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    atmosphere
    {
        type            pressureInletOutletVelocity;
        value           uniform (0 0 0);
    }
    
    cyc_half0
    {
        type            cyclic;
        neighbourPatch  cyc_half1;
    }
    
    cyc_half1
    {
        type            cyclic;
        neighbourPatch  cyc_half0;
    }
}
p_rgh

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

internalField   uniform 0;

boundaryField
{
    wall
    {
        type            fixedFluxPressure;
        value           uniform 0;
    }

    atmosphere
    {
        type            totalPressure;
        p0              uniform 0;
        U               U;
        phi             phi;
        rho             rho;
        psi             none;
        gamma           1;
        value           uniform 0;
    }
    
    cyc_half0
    {
        type            cyclic;
        neighbourPatch  cyc_half1;
    }
    
    cyc_half1
    {
        type            cyclic;
        neighbourPatch  cyc_half0;
    }  

}
Here is the full project (<1MB):
http://sun.usf.uos.de/~maik/fish_passage.zip

just execute with:
sh Allrun.sh

p.s. I know that the mesh resolution especially at inlet, outlet and walls is too low to produce realistic values, but that shouldn't create mass defects.(?)

Best regards,
Maik
Attached Images
File Type: jpg after6s.jpg (46.5 KB, 20 views)
File Type: jpg after40s.jpg (41.3 KB, 16 views)
Maik is offline   Reply With Quote

Old   January 8, 2015, 11:16
Default
  #2
Senior Member
 
RodriguezFatz's Avatar
 
Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,097
Rep Power: 16
RodriguezFatz will become famous soon enough
Hi Maik,

something with the cyclic is going wrong. Take one timestep in paraview, such as t=4. Select mesh part "internalMesh" and volume field "alpha.water" to plot.
If you have a close look at the "upper" cyclic part, then turn it around to look at the lower cyclic part you will see that alpha differs, where it should be the same.
I will try to find the reason for that.

Philipp.
__________________
The skeleton ran out of shampoo in the shower.
RodriguezFatz is offline   Reply With Quote

Old   January 8, 2015, 11:23
Default
  #3
Senior Member
 
RodriguezFatz's Avatar
 
Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,097
Rep Power: 16
RodriguezFatz will become famous soon enough
Ok sorry, I was wrong... these were just interpolated values from cell center. Using the wall and patches to plot it looks ok.
__________________
The skeleton ran out of shampoo in the shower.
RodriguezFatz is offline   Reply With Quote

Old   January 8, 2015, 12:46
Default look at source vector
  #4
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 108
Rep Power: 5
danny123 is on a distinguished road
Hello Maik,

I just filled a bug report (1477). Maybe your issue is related. In my case the source vector of the matrix equation of the pressure equation (already at pcorr level) has a wrong value in a single cell. If you resolve such an equation (provided your matrix solver succeeds to do it), all the flux calculations gets corrupted. If the flux is not correct, alpha will change too. In interFoam you do not have that problem, I did test this on the dam case in the tutorial.

You may be able to see this in your case too, if you recompile PCG to plot out the source vector, you may be able to reproduce the same error.

If you know how to manipulate the matrix solver implementation or somebody who knows, I would be grateful.

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   January 9, 2015, 02:51
Default
  #5
Senior Member
 
RodriguezFatz's Avatar
 
Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,097
Rep Power: 16
RodriguezFatz will become famous soon enough
Maik,

At least it's not the cyclic b.c.
If you set the two cyclics to wall you also lose water...
But why? I can't see any difference to the dam break tutorial, except the mesh... But that is pretty coarse in both cases.
__________________
The skeleton ran out of shampoo in the shower.
RodriguezFatz is offline   Reply With Quote

Old   January 9, 2015, 18:15
Default
  #6
New Member
 
Maik Wissing
Join Date: Jan 2015
Posts: 5
Rep Power: 2
Maik is on a distinguished road
Hi Philipp, Hi Daniel,
Thank you for your replies!

I used the same settings as in the damBreak tutorial, and if you also saw water disappearing in the a "just wall" scenario (actually I didn't notice that up to 40s, and the defect increases with the cyclic boundary condition) I should concentrate on the mesh.
I generated it with salome and I will have a look if I will my mesh settings are known to be incompatible with openfoam - or what will happen when I change the mesh.

Thank you and I will report my results!
Best wishes,
Maik
Maik is offline   Reply With Quote

Old   January 13, 2015, 13:41
Default
  #7
New Member
 
Maik Wissing
Join Date: Jan 2015
Posts: 5
Rep Power: 2
Maik is on a distinguished road
Hi!
Current status is that both setups, the cyclic boundary and the "just wall" scenario loose water. The cyclic boundary scenario does it very fast.
-There seems to be no velocity pointing outward of the volume (except for cyclic boundaries).
-checkMesh says the mesh is alright
-a run with better Courant number (0.1 instead of 1) gives the same result

Honestly, I don't know what's going on here. Did anyone experienced a similar loss of water/mass?
Maik is offline   Reply With Quote

Old   January 14, 2015, 02:56
Default
  #8
Senior Member
 
RodriguezFatz's Avatar
 
Philipp
Join Date: Jun 2011
Location: Germany
Posts: 1,097
Rep Power: 16
RodriguezFatz will become famous soon enough
1) Create a new mesh from scratch and try it.
2) If it doesn't work try a different meshing software.

What do you think?
__________________
The skeleton ran out of shampoo in the shower.
RodriguezFatz is offline   Reply With Quote

Old   January 14, 2015, 06:59
Default mass losses
  #9
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 108
Rep Power: 5
danny123 is on a distinguished road
Hi Maik,

The dam break case is set up such, that the initial condition (0 folder) is not mass conservative. The error corrects itself while integrating over time. This has nothing to do with the mesh. This is why the case looses mass much more at the begining than later. The mesh is very simple and therefore cannot be the problem.

The other possible problem, that I have sent a bug report recently for, is that pcorr is correted in a single cell within the BC by a very strange method, which leads to a very starnge initilialization. This applies only if you have set a reference pressure in fvsolutions. If you leave that out, then this problem goes away.

Henry Weller has stated that AMI has an inherent mass loss problem. I will have to investigate myself where this problem stems from. The regular interFoam has no such mass loss problem if it is properly initilalized. Maybe it is if the two AMI do not cover well. But you may check this in various threads he is refering to.

Probably opening the domain is the easiest thing to do, as he suggested.

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   January 16, 2015, 09:19
Default
  #10
New Member
 
Maik Wissing
Join Date: Jan 2015
Posts: 5
Rep Power: 2
Maik is on a distinguished road
Hi!
I reconstructed my geomatry from scratch, replacing the sharp edge that divided my two water bassins by a simple wall. However, the mass loss persists. So it looks like geometry and mesh are not the reason for the loss of mass.

Daniel, can you give more details which part of the initial conditions in the damBreak scenario is not mass conservative -- and maybe even better, how to make it mass conservative?
I didn't modify fvSolution, no pressure is that here.
And I didn't use cyclicAMI, just the normal cyclic boundaries.

Best regards and that you for your help!
Maik
Maik is offline   Reply With Quote

Old   January 16, 2015, 10:38
Default
  #11
Senior Member
 
Daniel Witte
Join Date: Nov 2011
Posts: 108
Rep Power: 5
danny123 is on a distinguished road
Maik,

Dam break works with interFoam, not interDymFoam. The line "p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell));" in pEqn.H is not mass conservative. correctPhi.H is also not mass conservative, but this does not matter if you problem converges well. The error may disappear over time, but you should be avare that it takes a number of p_rgh iterations to cancel out the error.

interDymFopam has a similar error, just I do not know if there are other errors. I am currently testing it. For sure, you need to state "correctPhi no" in fvsolutions.

Regards,

Daniel
danny123 is offline   Reply With Quote

Old   January 19, 2015, 09:31
Default
  #12
New Member
 
Maik Wissing
Join Date: Jan 2015
Posts: 5
Rep Power: 2
Maik is on a distinguished road
Hi Daniel,
I didn't solve my problem.

So in principle interFoam should be mass conservative, as long as the initial/boundary conditions are correct, right?

But I dind't get what you meant with non mass conservative initial conditions. I am still using the setup from the first post and I don't see what could be wrong in the initialization.
(I am using interFoam, not interDynFoam, maybe that got mixed up.)
And what about this file: pEqn.H? Is it part of the solver?

In principle the setup is very simple: damBreak scenario as starting point, enhanced to 3D and with changed geometry: one tilted and surrounding wall, cyclic inlet and outlet on different heights and an atmosphere on top.
Does anyone know how to run it without loosing mass (water)?
Maik is offline   Reply With Quote

Reply

Tags
cyclic boundary, loss of mass, mass conservation

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Overflow Error in Multiphase Modelling with Two Continuous Fluids ashtonJ CFX 6 August 11, 2014 14:32
GETVAR Error in Multiband Monte Carlo Radiation Simulation with Directional Source silvan CFX 3 June 16, 2014 09:49
why my momentum and mass not convergence wwwuxing CFX 3 May 18, 2012 07:49
CFX does not continue Shafiul CFX 10 February 17, 2011 08:57
Mass conservation in COMSOL Diego Main CFD Forum 1 December 27, 2010 06:14


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