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

Create runTime selectable class with subModels

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 1, 2022, 14:32
Default Create runTime selectable class with subModels
  #1
New Member
 
Join Date: Dec 2021
Posts: 23
Rep Power: 4
MamboJambo is on a distinguished road
Hello to all,


I would like to create a class representing a model. Since there will be different models, it needs to be runTime selectable. Each model, will need a subModel defined for the system of equations which should also be runTime selectable.


The main idea is illustrated in the image bellow:





I was thinking of doing this based on the structure of the viscosity model.


Code:
Foam::autoPtr<Foam::viscosityModel> Foam::viscosityModel::New
(
    const word& name,
    const dictionary& dict,
    const volVectorField& U,
    const surfaceScalarField& phi
)
{
    const word modelType(dict.get<word>("transportModel"));

    Info<< "Selecting incompressible transport model " << modelType << endl;

    auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);

    if (!cstrIter.found())
    {
        FatalIOErrorInLookup
        (
            dict,
            "viscosityModel",
            modelType,
            *dictionaryConstructorTablePtr_
        ) << exit(FatalIOError);
    }

    return autoPtr<viscosityModel>(cstrIter()(name, dict, U, phi));
}
So inside my createFields, I would have a autoPtr<BaseClass> and inside the base class a member of type autoPtr<subModelBaseClass>.

Is this a suitable strategy? Do you know of a better approach? Does the use of autoPtr [unique_ptr] have any influence in parallel processing?

Thanks
MamboJambo 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
RunTime Selection and the Templates mess ELwardi OpenFOAM Programming & Development 0 September 4, 2020 09:24
Meshing a Sphere Ajay FLUENT 10 September 3, 2016 14:18
Where's the singularity/mesh flaw? audrich FLUENT 3 August 4, 2009 01:07
A problem about class OFstream jennyrui2008 OpenFOAM Running, Solving & CFD 0 December 5, 2008 03:55
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 11:55


All times are GMT -4. The time now is 10:52.