CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Use LES filter operation

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

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 25, 2014, 08:33
Question Use LES filter operation
  #1
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Dear all,

Similar to the filtering operation in dynamic Smagorinsky model for the incompressible flows:

Code:
homogeneousDynSmagorinsky.H
I am trying to use the same filtering operations in one of the applications, like rhoPimepleFoam. In order to see how the filtering is applied, I first read the code of homogeneousDynSmagorinsky, but I have two questions:

1, How the class LESfilter is initialized? In homogeneousDynSmagorinsky.H, it appears as the priviate data:

Code:
LESfilter& filter_
I think filter is initialized when homogeneousDynSmagorinsky is initilized but I did not find where the latter is initialzied.

2, In homogeneousDynSmagorinsky.C, the filter operation is applied as filter_(x), I do not why here filter_(*) is used like a function, it is an object!

Thank you so much if anyone can provide some guidance.
openfoammaofnepo is offline   Reply With Quote

Old   March 1, 2014, 06:15
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi OFFO (the acronym OF is a lot easier to write ),

If the questions were about hard-core LES mathematics, I wouldn't be able to answer, but since it's C++ related questions, here we go:
Quote:
Originally Posted by openfoammaofnepo View Post
1, How the class LESfilter is initialized? In homogeneousDynSmagorinsky.H, it appears as the priviate data:

Code:
LESfilter& filter_
I think filter is initialized when homogeneousDynSmagorinsky is initilized but I did not find where the latter is initialzied.
This is a two sided issue:
Let's look at the C file: https://github.com/OpenFOAM/OpenFOAM...nSmagorinsky.C
  1. Looking at the constructor:
    Code:
    homogeneousDynSmagorinsky::homogeneousDynSmagorinsky
    (
        const volVectorField& U,
        const surfaceScalarField& phi,
        transportModel& transport,
        const word& turbulenceModelName,
        const word& modelName
    )
  2. You'll see this:
    Code:
    filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
    filter_(filterPtr_())
    The first line initializes "filterPtr_" with a new "LESfilter". The second line will assign to the reference variable "filter_" the memory address pointed to by "filterPtr_", because "filterPtr_()" is using an operator. For more on this, have a look into this article: http://openfoamwiki.net/index.php/OpenFOAM_guide/tmp
Note: "autoPtr" is a much more simple class than "tmp", but they are conceptually similar.

Quote:
Originally Posted by openfoammaofnepo View Post
2, In homogeneousDynSmagorinsky.C, the filter operation is applied as filter_(x), I do not why here filter_(*) is used like a function, it is an object!
Already hinted in the previous answer, because in C++ we can override operators, as explained here: http://www.cplusplus.com/doc/tutorial/operators/
If you look into the header file respective to LESfilter: https://github.com/OpenFOAM/OpenFOAM...er/LESfilter.H - you'll see that there are four "operator()", each one receiving a different type of field. These are abstract virtual methods, as explained here: http://www.cplusplus.com/doc/tutorial/polymorphism/ - which means that you will have to look at the specific filter implementation to see what the respective operator does.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   March 1, 2014, 06:30
Default
  #3
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Dear Bruno,

Thank you first for your so detailed help. I will dig into it later today. Now I am implementing a dynamic constants in my mixing model, where the test filtering is used. Thank you again.

OFFO.
openfoammaofnepo is offline   Reply With Quote

Old   March 5, 2014, 11:16
Default
  #4
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Dear Bruno,

About the following lines:

Code:
filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
filter_(filterPtr_())
You have already given me the explanations. Thank you. So actually filterPtr_ is the pointer toward the object of LESfilter and the latter is initilized by LESfilter::New(U.mesh(), coeffDict()). The correpsonding constructor is as follows:
Code:
        //- Return a reference to the selected LES filter
        static autoPtr<LESfilter> New
        (
            const fvMesh&,
            const dictionary&
        );
The operation filterPtr_() gives me the object that filterPtr_ points to.

Besides, filter_ is the reference of the object "filterPtr_()". Are the above what I saying correct?

In the dynamic LES models , the expressions filter_ extensively appears, like filter_(U()) and filter_(D). what is the relation between the filter_(U()) and filter_(filterPtr_())? A little confused.

Thank you so much.

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   March 5, 2014, 15:38
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi OFFO,

I know, C++ can get seriously confusing I suggest that you give a good study at this tutorial: http://www.cplusplus.com/doc/tutorial/

So, the notion to keep in mind is that this:
Code:
filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
filter_(filterPtr_())
was declared in the initialization section of the constructor. This means that it follows the paradigm that the constructor will also initialize any dependant constructors of its child variables or inherited classes. Which is why the parenthesis are used.
In practice, for example, doing this:
Code:
MyOwnClass::MyOwnClass() :
  filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
  filter_(filterPtr_())
{
}
Is almost the same thing as doing this:
Code:
MyOwnClass::MyOwnClass()
{
  filterPtr_ = LESfilter::New(U.mesh(), coeffDict());
  filter_ = filterPtr_();
}
The difference is usually a matter of performance, where the first one is more efficient and faster to do when the solver is running.
  • Side note - This:
    Code:
    filterPtr_ = LESfilter::New(U.mesh(), coeffDict());
    Is basically this:
    Code:
    filterPtr_ = new LESfilter(U.mesh(), coeffDict());
    But the difference is that we have to use the "New" method, because of some special operations that are needed when creating an instance of "LESfilter".


As for:
Code:
filter_(U);
is the same as doing this:
Code:
filter_.operator()(U);
where the method "operator()" is a special method, which is automatically called if you simply do the first form:
Code:
filter_(U);
And it's only possible to do so, because it was defined that way.
For example, doing:
Code:
filter_(2.0+1);
won't work, because the method "operator()(scalar value)" was not defined.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   March 6, 2014, 05:08
Default
  #6
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Dear Bruno,

Thank you for your help. Much clearer now!

have a nice day!

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   April 8, 2014, 04:24
Default filter_
  #7
Member
 
ehk
Join Date: Sep 2012
Posts: 30
Rep Power: 13
ehsankf is on a distinguished road
Hi Bruno,

I there a way to use filter_ operator in a solver like channelFoam, as in can be used in models.
ehsankf is offline   Reply With Quote

Old   April 13, 2014, 14:28
Default
  #8
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by ehsankf View Post
I there a way to use filter_ operator in a solver like channelFoam, as in can be used in models.
Quick answer:
From what I can see, my guess is that you'll have to create a new local instance of LESfilter, indicated in point #2, at post #2, namely this one:
Quote:
Originally Posted by wyldckat View Post
2. You'll see this:
Code:
filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
filter_(filterPtr_())
wyldckat is offline   Reply With Quote

Old   April 13, 2014, 14:36
Default
  #9
Senior Member
 
Join Date: Jan 2013
Posts: 372
Rep Power: 14
openfoammaofnepo is on a distinguished road
Yes, Bruno is right.

In order to use coeffDict(), you need to define the following in createFields.H

Code:
    autoPtr<compressible::LESModel> les
    (
        compressible::LESModel::New
        (
            rho,
            U,
            phi,
            thermo
        )
    );
Then the lines mentioned in Bruno's thread is:

Code:
    autoPtr<LESfilter> filterPtr(LESfilter::New(U.mesh(), les->coeffDict()));
    LESfilter& filter(filterPtr());
Quote:
Originally Posted by wyldckat View Post
Quick answer:
From what I can see, my guess is that you'll have to create a new local instance of LESfilter, indicated in point #2, at post #2, namely this one:
openfoammaofnepo is offline   Reply With Quote

Old   August 21, 2015, 09:10
Default filter_
  #10
Senior Member
 
Ehsan
Join Date: Mar 2009
Posts: 112
Rep Power: 17
ehsan is on a distinguished road
Hello

Could any one help me to know where the function "filter_" is defined in OF?

https://github.com/OpenFOAM/OpenFOAM...dynOneEqEddy.C

this function, filter_, used many times here and in other dynamic based SGS models but I could not find its definition.

Regards

Last edited by ehsan; August 21, 2015 at 10:20.
ehsan is offline   Reply With Quote

Old   August 21, 2015, 10:47
Default
  #11
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by ehsan View Post
Could any one help me to know where the function "filter_" is defined in OF?
Quick answer:
  • Moved your post from another thread: http://www.cfd-online.com/Forums/ope...filtering.html - to here, since this thread is more related to what you're looking for.
  • Did you check the file "dynOneEqEddy.H"?
  • More details are in the posts above, which is also why I moved your post to here.
wyldckat is offline   Reply With Quote

Old   August 21, 2015, 14:01
Default
  #12
Senior Member
 
Ehsan
Join Date: Mar 2009
Posts: 112
Rep Power: 17
ehsan is on a distinguished road
Thank you, the problem is solved in this thread:

autoPtr<LESfilter> filterPtr_;
LESfilter& filter_;

Since it is an autoPtr its special Type is defined during runtime.

Meanwhile, I would like now to apply a new filter, which is called "scale-dependent dynamics viscosity" from this paper:

A scale-dependent dynamic model for large-eddy simulation: application to a neutral atmospheric boundary layer, by Porte-Agel et al.

A scale-dependent Lagrangian dynamic model for large eddy simulation of complex turbulent flows

, which needs a third filter as well, could any one gives a help?

Thanks a lot
ehsan is offline   Reply With Quote

Old   August 21, 2015, 18:21
Default
  #13
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick answers:
ehsan likes this.
wyldckat is offline   Reply With Quote

Old   August 24, 2015, 02:08
Default
  #14
Senior Member
 
Ehsan
Join Date: Mar 2009
Posts: 112
Rep Power: 17
ehsan is on a distinguished road
On the meanwhile, may I ask you why in dynamicSmagorinsky, the used filter width is not two times larger than the cell size, it calls filter_, without doubling the filter width.
Regards
ehsan is offline   Reply With Quote

Old   August 24, 2015, 11:54
Default
  #15
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

Sorry, I have no idea. I'm not familiar with LES modelling itself. Perhaps openfoammaofnepo (the forum member who started this thread ) can answer about that?

Nonetheless, I believe there are a lot of threads about dynamicSmagorinsky itself, including a modified model provided here: https://bitbucket.org/albertop/dynamicsmagorinsky

Good luck! Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 27, 2016, 13:49
Default implement simplefilter inside solver
  #16
New Member
 
sina
Join Date: Jul 2013
Posts: 21
Rep Power: 12
aghsin is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Yes, Bruno is right.

In order to use coeffDict(), you need to define the following in createFields.H

Code:
    autoPtr<compressible::LESModel> les
    (
        compressible::LESModel::New
        (
            rho,
            U,
            phi,
            thermo
        )
    );
Then the lines mentioned in Bruno's thread is:

Code:
    autoPtr<LESfilter> filterPtr(LESfilter::New(U.mesh(), les->coeffDict()));
    LESfilter& filter(filterPtr());
hello friend
I want to implement sompleFilter on one of the term in my solver. would you please let me know how I can add the filter inside a solver
regards
aghsin is offline   Reply With Quote

Old   June 22, 2017, 03:33
Default
  #17
Member
 
Mahdi
Join Date: Jul 2012
Posts: 53
Rep Power: 13
Mahdi2010 is on a distinguished road
Did you manage to solve your problem with applying a filter within the solver?
Mahdi2010 is offline   Reply With Quote

Old   June 22, 2017, 10:31
Default
  #18
New Member
 
sina
Join Date: Jul 2013
Posts: 21
Rep Power: 12
aghsin is on a distinguished road
Quote:
Originally Posted by Mahdi2010 View Post
Did you manage to solve your problem with applying a filter within the solver?
yep I applied simpleFilter from LESFilter Class
aghsin is offline   Reply With Quote

Old   June 22, 2017, 10:54
Default
  #19
Member
 
Mahdi
Join Date: Jul 2012
Posts: 53
Rep Power: 13
Mahdi2010 is on a distinguished road
Quote:
Originally Posted by aghsin View Post
yep I applied simpleFilter from LESFilter Class
Good. I have done as well. But what about the width of simple filter? This is something unclear to me.
As in other threads we discuss if the simple filter of OpenFOAM uses neighboring cells?
Mahdi2010 is offline   Reply With Quote

Old   July 11, 2022, 19:50
Default
  #20
Senior Member
 
CFD_Lovers
Join Date: Mar 2015
Posts: 168
Rep Power: 11
sinatahmooresi is on a distinguished road
Quote:
Originally Posted by openfoammaofnepo View Post
Yes, Bruno is right.

In order to use coeffDict(), you need to define the following in createFields.H

Code:
    autoPtr<compressible::LESModel> les
    (
        compressible::LESModel::New
        (
            rho,
            U,
            phi,
            thermo
        )
    );
Then the lines mentioned in Bruno's thread is:

Code:
    autoPtr<LESfilter> filterPtr(LESfilter::New(U.mesh(), les->coeffDict()));
    LESfilter& filter(filterPtr());

Hello Dear Foamer, and thanks for this useful thread. I have the same intention to use filter operation in pimpleFoam. Thus, I tired to do the initialization using "autoPtr...". However I get the following error:



no suitable user-defined conversion from "Foam::volVectorField" to "const Foam::geometricOneField" exists
incompressible::LESModel::New(U, phi, laminarTransport)

The same error is repeated for "phi" and "laminarTransport" based on their types (the error is basically the same as "no suitable user-defined conversion..."



Here is what I wrote in creatFields.H:


autoPtr<incompressible::LESModel> sgsModel
(
incompressible::LESModel::New(U, phi, laminarTransport)
);

autoPtr<LESfilter> filterPtr(LESfilter::New(U.mesh(), sgsModel->coeffDict()));
LESfilter& filter(filterPtr());


Any idea on what goes wrong here?
sinatahmooresi is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can use the LES filter? (laplace filter and anistropic filter) ethan oh OpenFOAM Running, Solving & CFD 11 December 26, 2018 02:37
Bugs in LES filter codes yekaniyasari OpenFOAM Bugs 4 February 19, 2018 06:51
LES Filter in Smagorinsky model on inhomogenous grids Ivan Main CFD Forum 1 October 25, 2012 11:30
calculation of test filter quantites for desired parameters(equations) in les mrn FLUENT 0 July 15, 2010 05:04
LES with different filter Rick Main CFD Forum 1 August 22, 2008 18:10


All times are GMT -4. The time now is 20:47.