CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Improved implementation of dynamic Smagorinsky (https://www.cfd-online.com/Forums/openfoam-solving/82780-improved-implementation-dynamic-smagorinsky.html)

alberto December 5, 2010 17:59

Improved implementation of dynamic Smagorinsky
 
Hello,

if you need a dynamic Smagorinsky code with a truly dynamic coefficient (not domain-averaged as in the current implementation), you might find this useful.

You can find an implementation the dynamic model with local average of the coefficient here:

http://www.openfoam.com/mantisbt/view.php?id=99

I proposed it for inclusion in OpenFOAM. If this is not going to happen (very probable, read the answer), the code is available from my GitHub repository

git://github.com/AlbertoPa/dynLocalAverageSmagorinsky.git

Best,

Ingenierias2003 December 6, 2010 12:37

LES - VOF Method
 
Dear Alberto,

I would like to know if this new dynamic smagorinsky model is useful too two-phase flow models. I don't know is could be possible to you explain me better how con set my /constant/LESmodel to use this new approach.

Thanks in advance

My deep regards

Respectfully
Javier Basurco

alberto December 6, 2010 12:58

Quote:

Originally Posted by Ingenierias2003 (Post 286237)
Dear Alberto,

I would like to know if this new dynamic smagorinsky model is useful too two-phase flow models. I don't know is could be possible to you explain me better how con set my /constant/LESmodel to use this new approach.

Strictly speaking, no. None if the implemented LES models has been derived with multiphase flows in mind.

The additional model I posted can be simply compiled with "wmake libso", and then include

Code:

libs ( "libOpenFOAM.so" "libdynLocalAverageSmagorinskyModel.so" ) ;
in controlDict, and:

Code:

LESModel        dynLocalAverageSmagorinsky;
delta              cubeRootVol;

Code:

dynLocalAverageSmagorinskyCoeffs
{
  filter    simple;
  ce            1.048;
}

Best,

flavio_galeazzo December 7, 2010 10:14

Thanky you for the generous contribution, Alberto. I will give it a try as soon as I get some resources free.

alberto December 7, 2010 12:46

Hi Flavio, there is nothing new in the model. It is basically the dynamic model proposed by Lilly, with face averaging to limit the risk of numerical instabilities.

Best,

grandgo December 7, 2010 19:33

Quote:

Originally Posted by alberto (Post 286239)
Strictly speaking, no. None if the implemented LES models has been derived with multiphase flows in mind.

The additional model I posted can be simply compiled with "wmake libso", and then include

Code:

libs ( "libOpenFOAM.so" "libdynLocalAverageSmagorinskyModel.so" ) ;
in controlDict, and:

Code:

LESModel        dynLocalAverageSmagorinsky;
delta              cubeRootVol;

Code:

dynLocalAverageSmagorinskyCoeffs
{
  filter    simple;
  ce            1.048;
}

Best,

hi alberto!

i don't understand, why to include a library in controlDict.... :confused:

best regards
grandgo

alberto December 7, 2010 19:58

Quote:

Originally Posted by grandgo (Post 286434)
hi alberto!

i don't understand, why to include a library in controlDict.... :confused:

best regards
grandgo

When you execute wmake libso, you generate a dynamic library, not linked to the executable. Adding that line to controlDict tells the solver to load the library.

Best,

alberto December 8, 2010 12:28

Since the proper name of the model is "dynamic Smagorinsky", I updated code, description (added reference) and repository.

The new URL is here:

git clone git://github.com/AlbertoPa/dynamicSmagorinsky.git

The README also contains the instructions to use the it.

Notice that the limitation observed by the current implementation of dynamic Smagorinsky in OpenFOAM affects all the dynamic models, not only the dynSmagorinsky. All the SGS models relying on the dynamic procedure in OpenFOAM average the dynamic coefficient over the whole domain.

Best,

panda60 December 14, 2010 09:18

Dear alberto ,
What's the meaning of "face averaging "? It is not "not domain averaging"?
If not average at all, but give a cutoff for nuSGS (for example, nu+nuSGS>0), it is better or not ?

Could you make your model easier to be modified by others who wants to use this.
Thank you very much.

alberto December 14, 2010 11:32

Quote:

Originally Posted by panda60 (Post 287397)
Dear alberto ,
What's the meaning of "face averaging "? It is not "not domain averaging"?

Let's start from the beginning :D

Lilly's formulation of the dynamic model, which is the one implemented, relies on a formulation of L and M, so that both the numerator and the denominator should vanish if one tends to zero. Based on this consideration, formally, the model should not present problems. However, the coefficient can change significantly, and some averaging might be required.

The less intrusive form of averaging I could think to is the "face-averaging". Face averaging means that the numerator and the denominator in the definition of the dynamic coefficient are the face-average value for that cell. This helps in limiting steep variations of the coefficient which would cause numerical problems.

It is very different from the "domain average" used in the standard implementation in OpenFOAM 1.7.x. In the domain average you end up having one single value of the coefficient over the whole domain, which removes the advantages of the dynamic procedure.

Quote:

If not average at all, but give a cutoff for nuSGS (for example, nu+nuSGS>0), it is better or not ?
That is done too in the code, and represents a physical constraint. The effective viscosity is bounded to zero in the code. Averaging addresses the problem of strong variability of the coefficient (check Lilly (1992) paper).

Quote:

Could you make your model easier to be modified by others who wants to use this.
What do you mean with "make it easier"? The code can be freely downloaded and it follows the structure of OpenFOAM LES models.

Best,

alberto December 14, 2010 12:46

I added a modified version of channel395 to the git repository, where the model is enabled. I hope this makes things a bit more clear.

Best,

panda60 December 22, 2010 22:11

Dear alberto ,
Thank you very much. And I also have question. Originally in dynamic model, it seems that k is not needed. But in OpenFOAM's dynamic model, the SGS kinetic energy k is needed. Could you explain this for us ? and how we can give this boundary condition ? in one equation model, Eugene said at inflow boundary, the resolved kinetic energy is OK, and it will quickly decrease. In this dynamic model, also like this ? thanks.

And I am sorry, your git repository is not allowed to acess for me. I just download the "Attached files", but can't download the channel395 example.

alberto December 23, 2010 00:57

Quote:

Originally Posted by panda60 (Post 288216)
Dear alberto ,
Thank you very much. And I also have question. Originally in dynamic model, it seems that k is not needed. But in OpenFOAM's dynamic model, the SGS kinetic energy k is needed.

It is not explicitly needed by the Smagorinsky model itself. A field named "k" has to be present because of how the LES models have been implemented.

Quote:

Could you explain this for us ? and how we can give this boundary condition ? in one equation model, Eugene said at inflow boundary, the resolved kinetic energy is OK, and it will quickly decrease. In this dynamic model, also like this ? thanks.
These questions would find an answer by simply taking a quick look to the code, which is always the best reference anyway. However:
  • k is not the resolved kinetic energy, but the residual part (SGS) in the LES models. A quick check to the code will confirm this to you.
  • In OpenFOAM the SGS turbulent kinetic energy is included explicitly in the SGS stresses.
  • The dynamic modes has exactly the same requirements for its setup as the standard Smagorinsky (some differences in the dictionaries), so yes, you will need a file for k.
  • About the BC's, set k to zero at walls, and to an appropriate value at inlets (you can estimate it with some theoretical consideration).
Quote:

And I am sorry, your git repository is not allowed to acess for me. I just download the "Attached files", but can't download the channel395 example.
My git repository is on github, so you have both git and https access to the content. You should be able to easily access to it.
Either:
Code:

git clone https://github.com/AlbertoPa/dynamicSmagorinsky.git
or
Code:

git clone git://github.com/AlbertoPa/dynamicSmagorinsky.git
should work. Additionally, if you go to this page https://github.com/AlbertoPa/dynamicSmagorinsky , you can push the Downloads button and github will create a .tar.gz or a .zip file for you. The tutorial is inside the testCases/channel directory.

Best,

panda60 December 26, 2010 03:05

1 Attachment(s)
Dear alberto,

at the inlet position, I have the kinetic energy profile measured from experiment, and I just use this as SGS k. But my professor doesn't agree with me, and said that "turbulent kinetic energy is more large than SGS k, you shouldn't use like this". He let me to fine other papers, see how does other people give inlet condition for SGS k. But I think that inlet condition for SGS k is not important, do you agree with me ? the following is my simulation. at the inlet position, I use experiment profile ,and the SGS k is very large, but as flow proceeded downstream, the k quickly decrease.

alberto December 26, 2010 08:50

Hi,
Quote:

Originally Posted by panda60 (Post 288471)
Dear alberto,

at the inlet position, I have the kinetic energy profile measured from experiment, and I just use this as SGS k. But my professor doesn't agree with me, and said that "turbulent kinetic energy is more large than SGS k, you shouldn't use like this".

Your professor is correct. :D
The turbulent kinetic energy you measure from experiments is the trace of the Reynolds stress tensor, while the SGS turbulent kinetic energy is the kinetic energy of the residual (unresolved) scales. Clearly they can be very different.

Quote:

He let me to fine other papers, see how does other people give inlet condition for SGS k. But I think that inlet condition for SGS k is not important, do you agree with me ? the following is my simulation. at the inlet position, I use experiment profile ,and the SGS k is very large, but as flow proceeded downstream, the k quickly decrease.
You are using a Smagorinsky-like model, as a consequence k_sgs is only used in computing the stress tensor. In other words, the value specified at the inlet should not be used at all in the simulation.

Do a simple check: set k = 0 at the inlet. Run your case. Compare with what you obtain from the case with k=k_sgs. Does it show any difference?

Of course, if you use a model involving the transport equation for k, things are different, and you must specify an appropriate BC for k_sgs.

Best,

panda60 December 27, 2010 01:36

Dear alberto .
Thank you very much. You means in dynamic Smagorinsky model, the k_Sgs is not used, so will not influence the result. If it is like this, now I will do simulation using this dynamic model, and compare with my experiement. I have two case , one is empty domain, another is flow around a cubic building. I think the first case can be finished in 10 days.

alberto December 27, 2010 02:01

Quote:

Originally Posted by panda60 (Post 288536)
Dear alberto .
Thank you very much. You means in dynamic Smagorinsky model, the k_Sgs is not used, so will not influence the result.

Exactly. k_SGS is an output of the model, and it is defined explicitly (check the code to see how).

Best,

StSchiff January 12, 2011 14:38

plannar averaging
 
Quote:

Originally Posted by alberto (Post 287421)

The less intrusive form of averaging I could think to is the "face-averaging". Face averaging means that the numerator and the denominator in the definition of the dynamic coefficient are the face-average value for that cell. This helps in limiting steep variations of the coefficient which would cause numerical problems.

It is very different from the "domain average" used in the standard implementation in OpenFOAM 1.7.x. In the domain average you end up having one single value of the coefficient over the whole domain, which removes the advantages of the dynamic procedure.

Hello Alberto,

thanks for sharing your corrected dynamicSmagorinsky with us! I tried it and it works fine. I wonder if the model can be changed in a way that it uses a planar averaging technique as was proposed by Germano (1990)? Of course that would only work for channel flow. That way the constant would only change with the height of the channel. Do you know of any plannar averaging methods in OpenFoam?

Are you getting fairly low results for C for the channel testcase as well? I'm getting values around 0.01, but I was expecting values at around 0.1 or 0.2. Also I'm getting negative values for C.

Best
Stefanie

alberto January 12, 2011 15:53

Quote:

Originally Posted by StSchiff (Post 290182)
Hello Alberto,

thanks for sharing your corrected dynamicSmagorinsky with us! I tried it and it works fine. I wonder if the model can be changed in a way that it uses a planar averaging technique as was proposed by Germano (1990)? Of course that would only work for channel flow. That way the constant would only change with the height of the channel. Do you know of any plannar averaging methods in OpenFoam?

No, I do not know any pre-defined plane-averaging method.

Additionally, keep in mind that Germano's formulation for Cs is different from Lilly's formulation. Lilly's formulation in theory is always defined (numerically you still have issues due to large values). Check the corresponding references.

Quote:

Are you getting fairly low results for C for the channel testcase as well? I'm getting values around 0.01, but I was expecting values at around 0.1 or 0.2. Also I'm getting negative values for C.
The value will depend on the actual local conditions. Yes, you will obtain negative values of Cs and of SGS viscosity. The implementation only ensures that nuEff >= 0. Negative values of Cs are typically identified with back-scatter phenomena.

Best,

StSchiff January 13, 2011 07:14

thanks, I think I'll keep working with Lilly's locally defined Cs then.
Is there a reason why the function cD is missing the factor 1/2 in the implementation? Or is that considered somewhere else?

Best
Stefanie

yashar.afarin January 23, 2011 04:42

Warning
 
Hi Alberto,

thanks for sharing your corrected dynamicSmagorinsky. I have complied it without any problem. but when I want to decompose my mesh, the below warning wolud be appear( I am using OF-1.6.x and Fedora-12):
--> FOAM Warning :
From function dlLibraryTable::open(const fileName& functionLibName)
in file db/dlLibraryTable/dlLibraryTable.C at line 79
could not load /home/Yashar/OpenFOAM/OpenFOAM-1.6.x/lib/linux64GccDPOpt/libdynamicSmagorinskyModel.so: undefined symbol: _ZNK4Foam14incompressible9LESModels


I would appreciate if you could help me to solve it.

alberto January 23, 2011 13:11

Hi Yashfar,

nothing to worry about. You can safely ignore the warning. It happens sometime when using libraries through controlDict.

Best,

yashar.afarin January 29, 2011 12:11

Quote:

Originally Posted by alberto (Post 291786)
Hi Yashfar,

nothing to worry about. You can safely ignore the warning. It happens sometime when using libraries through controlDict.

Best,

Hi Alberto,

thanks for your reply and your sharing.

sincerely yours.

yashar.afarin February 9, 2011 04:17

Hi Alberto,

I would appreciate if you could answer me that " how could this model be used in compressible solver?"

Best regard,

alberto February 9, 2011 04:22

Hi Yashar,

it cannot. The implementation I released works for incompressible solvers. For the compressible version you need to implement a compressible dynamic Smagorinsky model (see for example Piomelli's papers to have an idea).

Best,

BernhardGrieser February 17, 2011 08:16

non-root compilation of dynamicSmagorinsky
 
Alberto,

thank you very much for your efforts on implementing a truly dynamic Smagorinsky model! I realized the flaw of the old implementation a few weeks ago and I am more than happy that someone already took care of the issue.

I'm running my simulations as a non-root user on my university's HP XC3000, where OpenFOAM 1.7 is pre-installed.
Logically it produces an error when compiling with wmake libso:

Code:

...
/usr/bin/ld: cannot open output file /software/all/OpenFOAM/OpenFOAM-1.7.0/lib/linux64GccDPOpt/libdynamicSmagorinskyModel.so: Permission denied
collect2: ld returned 1 exit status
make: *** [/software/all/OpenFOAM/OpenFOAM-1.7.0/lib/linux64GccDPOpt/libdynamicSmagorinskyModel.so] Error 1

Do you know a work-around, so I can compile it as non-root?

Best regards,
Bernhard

BernhardGrieser February 17, 2011 08:37

non-root compilation of dynamicSmagorinsky
 
ok, problem solved. One only has to change the content of ./Make/files:
I replaced FOAM_LIBBIN with FOAM_USER_LIBBIN

alberto February 17, 2011 14:51

Good the code is useful to someone :-)

JamesJCFD April 1, 2011 00:47

Thanks!
 
Dear Alberto,

Many thanks for your contribution! This is just what I have been looking for...

kind regards,

James

alberto April 1, 2011 02:41

Happy to share! :)

PerryLJohnson June 11, 2011 22:06

Alberto,

Just trying to understand your code (and OpenFOAM coding in general), not being picky.

If I have understood your code correctly, by changing the average(LLMM/MMMM) to fvc::average(LLMM/MMMM), you have averaged over the faces belonging to the cells, which are interpolated from their respective cells.

So essentially, you have applied the box filter (or simple filter as OpenFOAM calls it) and could accomplish the same thing using filter_(LLMM/MMMM) assuming the user chooses the simple filter. This would also allow use of the other filters to perform this averaging at the choice of the user. Please correct me if I have misunderstood anything.

FYI, the fluent manual states that it averages locally using the test filter, which appears to be what you have done as well (fluent also uses box filter).

Regards,
Perry

alberto June 11, 2011 22:32

Quote:

Originally Posted by PerryLJohnson (Post 311625)
Alberto,

Just trying to understand your code (and OpenFOAM coding in general), not being picky.

If I have understood your code correctly, by changing the average(LLMM/MMMM) to fvc::average(LLMM/MMMM), you have averaged over the faces belonging to the cells, which are interpolated from their respective cells.

So essentially, you have applied the box filter (or simple filter as OpenFOAM calls it) and could accomplish the same thing using filter_(LLMM/MMMM) assuming the user chooses the simple filter. This would also allow use of the other filters to perform this averaging at the choice of the user. Please correct me if I have misunderstood anything.

Yes, correct.

Quote:

FYI, the fluent manual states that it averages locally using the test filter, which appears to be what you have done as well (fluent also uses box filter).
Yes. Notice however that FLUENT forces nu_sgs > 0, which is not the case, and I do not do.

Best,

PerryLJohnson June 11, 2011 22:41

Quote:

Originally Posted by alberto (Post 311626)
Yes, correct.



Yes. Notice however that FLUENT forces nu_sgs > 0, which is not the case, and I do not do.

Best,

I did notice that. I know you want to allow for back-scattering, but is there a numerical danger in letting nuEff get *close* to zero? I guess not since the numerical diffusion would take over at this point (provided you were using a dissipative scheme). They also clip nuSgs at 0.23 which seems kinda arbitrary.

Perry

alberto June 11, 2011 23:07

Quote:

Originally Posted by PerryLJohnson (Post 311627)
I did notice that. I know you want to allow for back-scattering, but is there a numerical danger in letting nuEff get *close* to zero? I guess not since the numerical diffusion would take over at this point (provided you were using a dissipative scheme).

Numerically I do not see any problem. It would just be like solving for an inviscid flow. Physically it could not be meaningful however.

Quote:

They also clip nuSgs at 0.23 which seems kinda arbitrary.
Yes, I agree.

Best,

kpsl July 5, 2011 09:57

Hi,

I am having some trouble compiling this on OpenFOAM 2.0.x.

I get the following error:

Code:

dynLocalAverageSmagorinsky.C:40:  instantiated from here
/home/kris/OpenFOAM/OpenFOAM-2.0.x/src/turbulenceModels/incompressible/LES/lnInclude/LESModel.H:115: error: no matching function for call to ‘Foam::incompressible::LESModels::dynLocalAverageSmagorinsky::dynLocalAverageSmagorinsky(const Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&, const Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>&, Foam::transportModel&, const Foam::word&)’
dynLocalAverageSmagorinsky.H:130: note: candidates are: Foam::incompressible::LESModels::dynLocalAverageSmagorinsky::dynLocalAverageSmagorinsky(const Foam::volVectorField&, const Foam::surfaceScalarField&, Foam::transportModel&)
dynLocalAverageSmagorinsky.H:118: note:                Foam::incompressible::LESModels::dynLocalAverageSmagorinsky::dynLocalAverageSmagorinsky(const Foam::incompressible::LESModels::dynLocalAverageSmagorinsky&)
make: *** [Make/linux64GccDPOpt/dynLocalAverageSmagorinsky.o] Error 1

Is there an updated version for 2.0? Any help would be much appreciated :)

Kris

Bernhard July 5, 2011 10:04

This was released by Alberto this morning:
https://github.com/AlbertoPa/dynamicSmagorinsky

grandgo July 5, 2011 11:48

hi alberto,

i'm using dynamicSmagorinsky for a LES in parallel processing.
i have this message. the calculation is running but i'm concerned because of this warning.

Code:

FOAM Warning :
    From function dlLibraryTable::open(const fileName& functionLibName)
    in file db/dlLibraryTable/dlLibraryTable.C at line 78
    could not load /home/stss8/OpenFOAM/stss8-1.7.x/lib/linux64GccDPOpt/libdynamicSmagorinskyModel.so: undefined symbol: _ZNK4Foam14incompressible9LESModels11GenEddyVisc1BEv

do you know anything about this?

best regards
grandgo

PerryLJohnson July 5, 2011 12:04

grandgo,

I think your question is posed and answered in posts 21 and 22 respectively.

Perry

grandgo July 5, 2011 12:34

Quote:

Originally Posted by PerryLJohnson (Post 314810)
grandgo,

I think your question is posed and answered in posts 21 and 22 respectively.

Perry

right. sorry.

(couldn't find the keywords via search function ...)

alberto July 5, 2011 14:22

Quote:

Originally Posted by kpsl (Post 314789)

Is there an updated version for 2.0? Any help would be much appreciated :)

I released it this morning. Note that the version for OpenFOAM 2.0.x *breaks* the compatibility with 1.7.x.
If you need both, take a look at the README. However I am not going to update the version for 1.7.x in case bugs are found.

P.S. Notice that OF 2.0.x comes with the dynLagrangian model, which uses Lagrangian averaging to find the dynamic coefficient. It is a more refined model than the traditional dynamic Smagorinsky, so it might be worth considering it too (the reference is in the header file).

Best,


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