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

using fvc::interpolate without fvSchemes / manually prescribe interpolation schemes

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

Like Tree7Likes
  • 2 Post By kmooney
  • 1 Post By akidess
  • 4 Post By tomislav_maric

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2014, 12:31
Question using fvc::interpolate without fvSchemes / manually prescribe interpolation schemes
  #1
Senior Member
 
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16
linch is on a distinguished road
Hi foamers,

I want to use upwind and downwind interpolation schemes in my code.

A simple way could be e.g. using
Code:
AfUpstream = fvc::interpolate(A)
in the code and
Code:
interpolationSchemes
{
    interpolate(A)                upwind      fluxIndicator;
}
in the fvSchemes dictionary. But this is not an option, cause:
1) I want to apply both upwind and downwind on the same field A:
Code:
AfUpstream = fvc::interpolate(A)
AfDownstream = fvc::interpolate(A)
and this wouldn't work with fvSchemes dict, because only one interpolation method can be prescribed there for the field A.

2) I want to "protect" the interpolation scheme by making it unchangeable, so it shouldn't appear in the fvSchemes dict.

So I need something like that
Code:
AfUpstream = fvc::interpolate(A,"upwind",fluxIndicator)
or
Code:
AfUpstream = fvc::upwindInterpolate(A,fluxIndicator)
, but I can not find the wright syntax.
linch is offline   Reply With Quote

Old   March 29, 2014, 18:53
Default
  #2
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 17
kmooney is on a distinguished road
I know that for most of the other fvc and fvm operators you can name a particular operation like this:

fvm::div(phi,U,"velocityDivergenceUpwind")

and perhaps later in the code

fvm::div(phi,U,"velocityDivergenceDownwind")

Where the solver will force you to set each "velocityDivergence" scheme in fvSchemes even though they are both a div(phi,U) operation. I didn't check to see if this option is available for fvc::interpolation but its worth a shot!
ngj and linch like this.
kmooney is offline   Reply With Quote

Old   March 31, 2014, 11:42
Default
  #3
Senior Member
 
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 16
linch is on a distinguished road
Thanks a lot, it works.

Still, if there is a possibility to use it without fvSchemes, I would appreciate if someone share it
linch is offline   Reply With Quote

Old   April 3, 2014, 04:45
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
This snippet from interFoam might be useful for you:
Code:
fv::gaussConvectionScheme<scalar>
            (
                mesh,
                phi,
                upwind<scalar>(mesh, phi)
            ).fvmDiv(phi, alpha1)
Again it's a divergence scheme and not an interpolation scheme, but maybe it gives you a hint on how to get it done.
linch likes this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   April 4, 2014, 07:51
Default
  #5
Senior Member
 
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21
tomislav_maric is on a distinguished road
Hi everyone. Long time no see

This was an interesting question, so here's the working example:

Code:
#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:

int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    #include "createFields.H"

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    typedef fv::convectionScheme<vector> schemeType;  

    // Uncomment this line to see that the choice of the interpolation scheme 
    // is actually active.
    //IStringStream schemeData("Gauss something"); 
    
    IStringStream schemeData("Gauss upwind"); 

    tmp<schemeType> schemeTmp = schemeType::New(
        mesh, 
        phi, 
        schemeData // Constructor requires a ref to Istream.
    );

    const schemeType& scheme = schemeTmp(); 

    // Give us your name. 
    Info << "Chosen scheme type: " << scheme.type() << endl; 

    // Assemble the matrix. 
    fvVectorMatrix UEqn = scheme.fvmDiv(phi, U);  

    Info<< "\nEnd\n" << endl;
    return 0;
}
Explanation

Selecting anything at run-time will depend on the 'New' static factory function (selector, as it is confusingly named in OF). So all we need is to take a look at the arguments of the selector:


Code:
 
        //- Return a pointer to a new convectionScheme created on freestore
        static tmp<convectionScheme<Type> > New
        (
            const fvMesh& mesh,
            const surfaceScalarField& faceFlux,
            Istream& schemeData
        );
Here, 'Istream& schemeData' obviously defines the parameters used for the type selection. Therefore, in the example above, 'Istream' object (of concrete type IStringStream) is constructed as passed as a reference to the 'New' selector.

As for the direct call using the operators in "fvc" or "fvm", I would need to take a look at it.

In any case, @illya, if you are writing client code, that uses those classes, you can use the classes directly, without dispatching the call from a "fvc/m" operator.

Uncomment the "Gauss something" line to see that both parameters are taken and the interpolation scheme of the gaussConvectionScheme really does get selected from the second parameter.

T.
linch, hua1015, huyidao and 1 others like this.
tomislav_maric is offline   Reply With Quote

Old   March 20, 2018, 05:49
Question Back to original question
  #6
New Member
 
Join Date: Jan 2018
Posts: 12
Rep Power: 8
Pfiffikus is on a distinguished road
Hi Tomislav,

many thanks for your interesting code snippet, but imho it doesn't fully answer the initial question:
How to code the interpolation of a volScalarField X (defined on cell centres) to a surfaceScalarField Y (defined on cell faces) while controling the scheme _without_ any controldict entry for interpolationSchemes?

Or is it possible to implement something like
Code:
surfaceScalarField Y = scheme.fvmInterpolate(Y,fluxIndicator);
?
Pfiffikus 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
fvc::interpolate -> harmonic interpolation? gwierink OpenFOAM Running, Solving & CFD 8 October 1, 2012 13:31
Surface interpolation schemes and parallelization jutta OpenFOAM Running, Solving & CFD 0 February 25, 2010 14:32
Interpolation Schemes and Limiters mchurchf OpenFOAM Running, Solving & CFD 3 November 16, 2009 23:48
Question About solvers and interpolation schemes titio OpenFOAM Running, Solving & CFD 0 July 9, 2009 11:41
Momentum interpolation for explicit schemes Yogen Main CFD Forum 3 December 20, 2002 10:43


All times are GMT -4. The time now is 12:28.