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

patch constructor for non templated class

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 22, 2024, 15:04
Default patch constructor for non templated class
  #1
New Member
 
Duncan van der Heul
Join Date: Apr 2023
Posts: 5
Rep Power: 3
ArieKNarie is on a distinguished road
Dear All,
I am implementing a gradient scheme that will only be defined for scalar fields.

Now I have to define the patch constructor to add this new scheme to the hash tables.

All other gradient schemes are templates, for both scalars and vectors. Their patch constructor looks like this:

Code:
#define makeFvGradTypeScheme(SS, Type)                                         \
    defineNamedTemplateTypeNameAndDebug(Foam::fv::SS<Foam::Type>, 0);          \
                                                                               \
    namespace Foam                                                             \
    {                                                                          \
        namespace fv                                                           \
        {                                                                      \
            gradScheme<Type>::addIstreamConstructorToTable<SS<Type>>           \
                add##SS##Type##IstreamConstructorToTable_;                     \
        }                                                                      \
    }


#define makeFvGradScheme(SS)                                                   \
                                                                               \
makeFvGradTypeScheme(SS, scalar)                                               \
makeFvGradTypeScheme(SS, vector)


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
It is unclear to me how it would look for my nontemplated (scalar only) scheme. Clearly the line

Code:
makeFvGradTypeScheme(SS, vector)
will be absent, but what replaces
Code:
defineNamedTemplateTypeNameAndDebug
My final attempt was:
Code:
// Add the patch constructor functions to the hash tables

#define makeScalarGradTypeScheme(SS)                                           \
    defineTypeNameAndDebug(Foam::fv::SS, 0);                                   \
                                                                               \
    namespace Foam                                                             \
    {                                                                          \
        namespace fv                                                           \
        {                                                                      \
            gradScheme<scalar>::addIstreamConstructorToTable<SS>               \
                add##SS##IstreamConstructorToTable_;                           \
        }                                                                      \
    }


#define makeScalarGradScheme(SS)                                               \
    makeScalarGradTypeScheme(SS)
But this raises all kinds of errors in compilation

This part of the coding seems to be the most challenging :-)
Thanks in advance for your help.
ArieKNarie is offline   Reply With Quote

Old   June 22, 2024, 16:43
Smile
  #2
New Member
 
Duncan van der Heul
Join Date: Apr 2023
Posts: 5
Rep Power: 3
ArieKNarie is on a distinguished road
Ok I found it.

Code:
namespace Foam                                                             
{                                                                          
    namespace fv                                                           
    {                                                                      
        defineTypeNameAndDebug(myGaussGrad, 0);                                   

    }                                                                      
}
 

namespace Foam                                                             
{                                                                          
    namespace fv                                                           
    {                                                                      
        gradScheme<scalar>::addIstreamConstructorToTable<myGaussGrad>               
            addmyGaussGradIstreamConstructorToTable_;                           
    }                                                                      
}
works
ArieKNarie is offline   Reply With Quote

Old   June 24, 2024, 02:00
Default
  #3
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 802
Blog Entries: 1
Rep Power: 18
dlahaye is on a distinguished road
Thx for sharing!
dlahaye 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
PIMPLE Stability CallumG OpenFOAM Running, Solving & CFD 3 July 16, 2022 05:17
[Commercial meshers] Using starToFoam clo OpenFOAM Meshing & Mesh Conversion 33 September 26, 2012 05:04
Cyclic Boundary Condition Luiz Eduardo Bittencourt Sampaio (Sampaio) OpenFOAM Running, Solving & CFD 36 July 2, 2012 13:23
Problem with rhoSimpleFoam matteo_gautero OpenFOAM Running, Solving & CFD 0 February 28, 2008 07:51
[Gmsh] Import gmsh msh to Foam adorean OpenFOAM Meshing & Mesh Conversion 24 April 27, 2005 09:19


All times are GMT -4. The time now is 01:00.