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

LimitedScheme source code understanding

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2014, 11:42
Question LimitedScheme source code understanding
  #1
Member
 
Lianhua Zhu
Join Date: Aug 2011
Location: Wuhan, China
Posts: 35
Rep Power: 14
zhulianhua is on a distinguished road
Hi! all,

I'm reading the source code of the van Leer limiter based surface interpolation scheme. I think I need your help to understand some of the code below:

Code:
template<class LimiterFunc>
class vanLeerLimiter
:
    public LimiterFunc
{

public:

    vanLeerLimiter(Istream&)
    {}
    scalar limiter
    (
        const scalar,
        const scalar faceFlux,
        const typename LimiterFunc::phiType& phiP,
        const typename LimiterFunc::phiType& phiN,
        const typename LimiterFunc::gradPhiType& gradcP,
        const typename LimiterFunc::gradPhiType& gradcN,
        const vector& d
    ) const
    {
        scalar r = LimiterFunc::r
        (
            faceFlux, phiP, phiN, gradcP, gradcN, d
        );

        return (r + mag(r))/(1 + mag(r));
    }
};
Where can I find the source code for the definition of function r() and the phiType/gradPhiType?

Thanks,

Lianhua

Last edited by zhulianhua; August 1, 2014 at 11:43. Reason: typo
zhulianhua is offline   Reply With Quote

Old   August 1, 2014, 11:45
Default The link to the code above
  #2
Member
 
Lianhua Zhu
Join Date: Aug 2011
Location: Wuhan, China
Posts: 35
Rep Power: 14
zhulianhua is on a distinguished road
The code in the post is from here:

https://github.com/OpenFOAM/OpenFOAM...Leer/vanLeer.H

Quote:
Originally Posted by zhulianhua View Post
Hi! all,

I'm reading the source code of the van Leer limiter based surface interpolation scheme. I think I need your help to understand some of the code below:

Code:
template<class LimiterFunc>
class vanLeerLimiter
:
    public LimiterFunc
{

public:

    vanLeerLimiter(Istream&)
    {}
    scalar limiter
    (
        const scalar,
        const scalar faceFlux,
        const typename LimiterFunc::phiType& phiP,
        const typename LimiterFunc::phiType& phiN,
        const typename LimiterFunc::gradPhiType& gradcP,
        const typename LimiterFunc::gradPhiType& gradcN,
        const vector& d
    ) const
    {
        scalar r = LimiterFunc::r
        (
            faceFlux, phiP, phiN, gradcP, gradcN, d
        );

        return (r + mag(r))/(1 + mag(r));
    }
};
Where can I find the source code for the definition of function r() and the phiType/gradPhiType?

Thanks,

Lianhua
zhulianhua is offline   Reply With Quote

Old   August 2, 2014, 08:03
Default
  #3
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hallo Lianhua,

Note that the file you have shown is a templated class in the type name "LimiterFunc", why you cannot directly find that class. I believe that this is a template in e.g. the NVDTVD and NVDTVDV definitions, which you will find here:

https://github.com/OpenFOAM/OpenFOAM...eme/NVDVTVDV.H

and

https://github.com/OpenFOAM/OpenFOAM...cheme/NVDTVD.H

These are then invoked through the macros in e.g. vanLeer.C. I am not 100% sure that this is the correct understanding of the source code, as it borders my current understanding of the C++ language. I hope, nonetheless, that this will help you on your way.

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   August 2, 2014, 09:42
Default
  #4
Member
 
Lianhua Zhu
Join Date: Aug 2011
Location: Wuhan, China
Posts: 35
Rep Power: 14
zhulianhua is on a distinguished road
Hello, Neils

Thanks for your reply. It really helps me. Yes, I have never seen such C++ usage on textbooks and web -- The base class is a template! I even don't know how to google this kind of usage.

Best,

Lianhua
zhulianhua is offline   Reply With Quote

Old   August 2, 2014, 10:48
Default
  #5
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Yes, I know. It is pretty advanced stuff

Kind regards,

Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Old   August 4, 2014, 12:43
Default
  #6
New Member
 
Vahid E.
Join Date: Jul 2014
Posts: 6
Rep Power: 11
yourvahid is on a distinguished road
I wanted to add a new limiter scheme such as "stacs" in openFOAM. I've already written the codes, however, I dont know how shall i compile and add it to openFOAM.
please note that I'm new in openFOAM environment and the interface is unfamiliar for me.
thanks a million.
yourvahid is offline   Reply With Quote

Old   August 5, 2014, 09:01
Default
  #7
Member
 
Jibran
Join Date: Oct 2012
Location: UK
Posts: 61
Blog Entries: 1
Rep Power: 14
Jibran is on a distinguished road
Quote:
Originally Posted by yourvahid View Post
I wanted to add a new limiter scheme such as "stacs" in openFOAM. I've already written the codes, however, I dont know how shall i compile and add it to openFOAM.
please note that I'm new in openFOAM environment and the interface is unfamiliar for me.
thanks a million.
Hi,

I suppose you have already added the .C and .H files in the relevant folder (for ex. \src\finiteVolume\interpolation\surfaceInterpolati on....). Then edit the 'files' and 'options' files in the 'Make' folder in \src\finiteVolume. Then compile it with 'wclean libso && wmake libso'. Finally make sure that your solver picks up the newly compiled library.

For more information please read the chapter 3.2 of the OF User Manual

Jibran
Jibran is offline   Reply With Quote

Reply


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
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 16:02
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 09:17
Help for the small implementation in turbulence model shipman OpenFOAM Programming & Development 25 March 19, 2014 10:08
centOS 5.6 : paraFoam not working yossi OpenFOAM Installation 2 October 9, 2013 01:41
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 17:18


All times are GMT -4. The time now is 15:39.