CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Non stationary simulation of a 2D cylinder (http://www.cfd-online.com/Forums/openfoam/98911-non-stationary-simulation-2d-cylinder.html)

lovecraft22 March 21, 2012 18:35

Non stationary simulation of a 2D cylinder
 
Hi all;
I'm trying to run a non stationary simulation of a 2D circular cylinder and I have some questions:

1. If I use icoFoam (can I use it in my case?) I have a floating point exception due to the courant number. I can avoid that but I need to lower my time step below 0.000001.

2. If I use pisoFoam it complies about the empty patches…

3. [Warning - stupid question!] what's the different between using simpleFoam and saving the result at different time steps and using a non stationary solver? Even with simpleFoam I can get the vortex shedding…

Thank you!

kmooney March 23, 2012 12:36

If you tar up the case I wouldn't mind taking a look at it.

lovecraft22 March 23, 2012 13:39

1 Attachment(s)
Thank you kmooney.
Had to do a .zip file instead of a .tar because of the size allowance by the forum…I hope that's fine…

kmooney April 3, 2012 10:05

2 Attachment(s)
The high Co numbers appear to be a result of some bad cells generated by snappyHexMesh. I added a little code to CoNumber.H to write out the local Courant numbers:

Code:

//Compute and write Co field
        scalar CoNum = 0.0;
        scalar meanCoNum = 0.0;

        volScalarField CoField
        (
        IOobject
        (
            "CoField",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        fvc::surfaceSum(mag(phi))()
        );

        if (mesh.nInternalFaces())
        {
            scalarField sumPhi
            (
            fvc::surfaceSum(mag(phi))().internalField()
            );

            CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue();

                    CoField.internalField() = 0.5*(CoField/mesh.V().field())*runTime.deltaTValue();

            meanCoNum =
            0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue();

        }
        Info<< "Courant Number mean: " << meanCoNum
            << " max: " << CoNum << endl;
//END Co Number

Those bad cells cause a 3 order of magnitude variation of Co throughout the domain. (Images attached!) It may just be easier to use something else to mesh it or work with your snappyHexMesh settings to avoid the bad cells. I hope that helps!

lovecraft22 April 3, 2012 10:21

1 Attachment(s)
Thank you Kyle, I really appreciate you help.

I had noticed indeed that my extruded mesh was bad on the cylinder surface so I played a little bit with the snappyHexMesh parameters and eventually I got a really good looking surface mesh but, again, no look with the convergence…

Could you please have a look at this case as well and see if the problem may be the same? The runScript is included. I got rid of the feature edges as it makes no differences for a 2D case like mine.

Those lines you posted, is that just something you need to add at the bottom of your controlDict?

Also, could you please explain the difference between running simpleFoam and looking at the flow at different time steps and doing the same thing with icoFoam? I know simpleFoam is a steady state solver but yet I can get the vortex shedding… is that just some numerical stuff?

Thank you again for your help!

Anne Severt May 4, 2012 05:01

Hey Kyle,

I´m new to CFD and OpenFoam, but I´m very much interested in your CoField implementation. Could you explain to me how you created the pictures? I edited the CourantNo.H file as you described, but I can´t create the images of CoField.

Thank you!

I was able to get a pic, but they don´t change in time. Aren´t they supposed to change?

vkrastev May 4, 2012 08:19

Quote:

Originally Posted by lovecraft22 (Post 352927)
Also, could you please explain the difference between running simpleFoam and looking at the flow at different time steps and doing the same thing with icoFoam? I know simpleFoam is a steady state solver but yet I can get the vortex shedding… is that just some numerical stuff?

In one word, yes. The "transient" solution you got from simpleFoam is just a numerical transitory till the algorithm goes convergent and generally speaking it does not have any physical meaning (although it could qualitatively seem so).

Regards

V.

kmooney May 7, 2012 14:18

Quote:

Originally Posted by Anne Severt (Post 359250)
Hey Kyle,

I´m new to CFD and OpenFoam, but I´m very much interested in your CoField implementation. Could you explain to me how you created the pictures? I edited the CourantNo.H file as you described, but I can´t create the images of CoField.

Thank you!

I was able to get a pic, but they don´t change in time. Aren´t they supposed to change?

Hi Anne,

As far as I can tell the Co field should be changing as long as U or deltaT is changing. The values are only valid on the internal field however so the patch values aren't accurate. It's always possible there is a bug but I haven't spent much time at all on it.

Anne Severt May 8, 2012 02:06

Hey Kyle,

thanks for your answer. Is there a way to plot accurate patch values? How can I access the volScalarField to keep track of the values while time is running?

Could you explain, why the patch values aren´t accurate? Thus, why is ().internalField() used?

Thanks!

adrieno August 2, 2016 05:04

Hi all,

I'm facing some problem of cfl and I would like to see the courant number on my mesh to know were comes my problem... I've seen that the code made by mister Mooney was able to do that, but I have two questions about how to implement it.

FIRST: do we just have to copy this code on a file called CourantNo.H ?

SECOND : were exactly do we have to put #include "CourantNo.H" in the XiFoam.C file ?
Let see on the code below, HERE n°1 or n°2 or n°3 ? or non of them ?

Code:


/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
XiFoam
Description
Compressible premixed/partially-premixed combustion solver with turbulence
modelling.
Combusting RANS code using the b-Xi two-equation model.
Xi may be obtained by either the solution of the Xi transport
equation or from an algebraic exression. Both approaches are
based on Gulder's flame speed correlation which has been shown
to be appropriate by comparison with the results from the
spectral model.
Strain effects are encorporated directly into the Xi equation
but not in the algebraic approximation. Further work need to be
done on this issue, particularly regarding the enhanced removal rate
caused by flame compression. Analysis using results of the spectral
model will be required.
For cases involving very lean Propane flames or other flames which are
very strain-sensitive, a transport equation for the laminar flame
speed is present. This equation is derived using heuristic arguments
involving the strain time scale and the strain-rate at extinction.
the transport velocity is the same as that for the Xi equation.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "hhuCombustionThermo.H"
#include "compressible/RASModel/RASModel.H"
#include "laminarFlameSpeed.H"
#include "ignition.H"
#include "Switch.H"
HERE n°1
 
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
# include "readCombustionProperties.H"
# include "readEnvironmentalProperties.H"
# include "createFields.H"
# include "readPISOControls.H"
# include "initContinuityErrs.H"
# include "readTimeControls.H"
# include "compressibleCourantNo.H"
# include "setInitialDeltaT.H"
HERE n°2
 
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.run())
{
# include "readTimeControls.H"
# include "readPISOControls.H"
# include "compressibleCourantNo.H"
# include "setDeltaT.H"
HERE n°3
 
runTime++;
Info<< "Time = " << runTime.timeName() << nl << endl;
# include "rhoEqn.H"
# include "UEqn.H"
// --- PISO loop
for (int corr=1; corr<=nCorr; corr++)
{
# include "ftEqn.H"
# include "bEqn.H"
# include "huEqn.H"
# include "hEqn.H"
if (!ign.ignited())
{
hu == h;
}
# include "pEqn.H"
}
turbulence->correct();
rho = thermo->rho();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "End\n" << endl;
return(0);
}
 
// ************************************************************************* //

Thank you and have a nice day,
Adrien ORSINI


All times are GMT -4. The time now is 16:10.