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

Updating solver from older version to OF8

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 19, 2023, 08:48
Default Updating solver from older version to OF8
  #1
New Member
 
Sarah
Join Date: Jan 2023
Posts: 12
Rep Power: 3
Sarah13 is on a distinguished road
I am trying to update a solver (artificially thickened flame) from OF2.2.2 to OF8. There is a class named efficiencyFunction that uses delta as variable, whose input arguments are in the form (for OF2.2.2):
delta_(LESdelta::New("delta", U.mesh(), *this))


But the LESdelta's "New" function in OF8 take input arguments in the form:
Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
(
const word& name,
const momentumTransportModel& turbulence,
const dictionary& dict
)


which was in older version OF2.2.2 is of the form:
Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)


so when I am trying to compile it, it is giving me an error as:
no matching function for call to ‘Foam::LESdelta::New(const char [6], const Mesh&, Foam::efficiencyFunction&)’


If anyone can get my query (if it is clear enough) and respond to it as to what changes should I make, I would be really grateful.


Sarah13 is offline   Reply With Quote

Old   February 1, 2023, 07:11
Default
  #2
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
Hey Sarah,

as you can see and already pointed out, the constructors are different:

NEW
Code:
Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
(
const word& name,
const momentumTransportModel& turbulence,
const dictionary& dict
)
OLD
Code:
Foam::autoPtr<Foam::LESdelta> Foam::LESdelta::New
(
const word& name,
const fvMesh& mesh,
const dictionary& dict
)
Hence you are not allowed to put the mesh object for creating the new LESdelta. Simply check out newer solvers how it is implemented there.

Example given, the LESdelta::New function needs e.g., the following argument: https://github.com/OpenFOAM/OpenFOAM...teFields.H#L42
Meaning that you call needs to be something like that:

Code:
auto myNewObject = LESdelta::New("whatEver", turbulence, dict);
Therefore, you need to get access to that object in your file you need.
E.g.
  • In your solver, you need to send the "turbulence" object to your class you need it (probably by implementing some functions)
  • After you stored a reference/pointer in the class, you can access it
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   June 12, 2023, 03:07
Default
  #3
New Member
 
Sarah
Join Date: Jan 2023
Posts: 12
Rep Power: 3
Sarah13 is on a distinguished road
Hi Thanks for your reply, I am still not able to solve the problem.
However I wish to access LESDelta in my solver code, can anyone please help me how to can I use the LES delta, as I can't find any solver which uses LES delta in their formula to which I can refer to?
Sarah13 is offline   Reply With Quote

Old   August 2, 2023, 06:30
Default
  #4
New Member
 
serg
Join Date: Dec 2015
Posts: 28
Rep Power: 10
kont87 is on a distinguished road
Quote:
Originally Posted by Sarah13 View Post
Hi Thanks for your reply, I am still not able to solve the problem.
However I wish to access LESDelta in my solver code, can anyone please help me how to can I use the LES delta, as I can't find any solver which uses LES delta in their formula to which I can refer to?
Hi,

Did you make any progress on accessing the delta? My solver uses it for calculating scalar variances of mixture fraction variance. I’d be glad if anyone could help.
Thanks
kont87 is offline   Reply With Quote

Old   August 22, 2023, 06:28
Default
  #5
New Member
 
Sarah
Join Date: Jan 2023
Posts: 12
Rep Power: 3
Sarah13 is on a distinguished road
Hi Serg
I calculated delta in my code itself using the mesh information. For 3-D it would be pow(mesh.V(),1.0/3.0). Note that it is only valid for cubeRootVol type of delta. For other type of delta you can maybe refer to their source code to find out how they are calculated.
Also to implement it properly you can refer to the source file of cubeRootVol delta.
Sarah13 is offline   Reply With Quote

Old   December 12, 2023, 07:46
Default
  #6
New Member
 
serg
Join Date: Dec 2015
Posts: 28
Rep Power: 10
kont87 is on a distinguished road
I was using this code snippet to reach delta, but it seems its an old version, so It does not return anything.

PHP Code:
    if (mesh.objectRegistry::foundObject<volScalarField>("delta"))
    {       

      const 
volScalarFielddelta mesh_.objectRegistry::lookupObject<volScalarField>("delta");
      
LESdelta_ delta;
    } 
Anybody have any idea to solve the problem, for OF version 7 or higher?
kont87 is offline   Reply With Quote

Old   December 15, 2023, 09:20
Default
  #7
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
This may not work, but is a shortcut that is worth trying - essentially it's the "banana" trick. Try modifying your code snippet to:

Code:
//if (mesh.objectRegistry::foundObject<volScalarField>("delta"))
//{       
      const volScalarField& delta = mesh_.objectRegistry::lookupObject<volScalarField>("delta");
//      LESdelta_ = delta;
//    }
recompile and run ... ie force the solver to do the registry assignment; the solver should then crash out saying that it can't find "delta" in the registry. But here's the useful bit - it should also list all the objects it does have in the registry, and so if it is stored with a different name then you'll be able to spot it and use the name. Otherwise, you'll need to get at it a different way, through the turbulence class structure.
Tobermory is offline   Reply With Quote

Old   December 16, 2023, 09:32
Smile
  #8
New Member
 
serg
Join Date: Dec 2015
Posts: 28
Rep Power: 10
kont87 is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
This may not work, but is a shortcut that is worth trying - essentially it's the "banana" trick. Try modifying your code snippet to:

Code:
//if (mesh.objectRegistry::foundObject<volScalarField>("delta"))
//{       
      const volScalarField& delta = mesh_.objectRegistry::lookupObject<volScalarField>("delta");
//      LESdelta_ = delta;
//    }
recompile and run ... ie force the solver to do the registry assignment; the solver should then crash out saying that it can't find "delta" in the registry. But here's the useful bit - it should also list all the objects it does have in the registry, and so if it is stored with a different name then you'll be able to spot it and use the name. Otherwise, you'll need to get at it a different way, through the turbulence class structure.
Thank you Tobermary, I guess I need to access it in a different way. I changed "delta" in the code I provided to "bananas", however, It does not include "delta", since the implementation is changed and delta can not be accessed through turbulence pointer. Do you have any other suggestions?

Best regards
kont87 is offline   Reply With Quote

Old   December 16, 2023, 13:34
Default
  #9
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
Strange. I added the following into a clone of pisoFoam, in OF8, and it worked fine:

Code:
    Info << "-------------------------------------" << endl;

    volScalarField LESdelta
    (
        IOobject
        (
            "LESdelta",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh,
        dimensionedScalar("LESdelta", dimLength, SMALL)
    );

    if (mesh.objectRegistry::foundObject<volScalarField>("delta"))
    {
        Info << "Found it!" << endl;
        const volScalarField& delta =
            mesh.objectRegistry::lookupObject<volScalarField>("delta");
        LESdelta = delta;
    }
    else
    {
        Info << "No joy I am afraid" << endl;
    }
    Info << LESdelta << endl;

    Info << "-------------------------------------" << endl;
... i.e. it printed out the contents of the delta field.
Tobermory is offline   Reply With Quote

Old   December 16, 2023, 13:38
Default
  #10
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 668
Rep Power: 14
Tobermory will become famous soon enough
PS, check your syntax:

Code:
    if (mesh.objectRegistry::foundObject<volScalarField>("delta"))
    {
      const volScalarField& delta = mesh_.objectRegistry::lookupObject<volScalarField>("delta");
      LESdelta_ = delta;
    }
in line 3, you probably mean mesh rather than mesh_, right?
Tobermory is offline   Reply With Quote

Old   December 17, 2023, 01:23
Default
  #11
New Member
 
serg
Join Date: Dec 2015
Posts: 28
Rep Power: 10
kont87 is on a distinguished road
Quote:
Originally Posted by Tobermory View Post
Strange. I added the following into a clone of pisoFoam, in OF8, and it worked fine:

Code:
    Info << "-------------------------------------" << endl;

    volScalarField LESdelta
    (
        IOobject
        (
            "LESdelta",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh,
        dimensionedScalar("LESdelta", dimLength, SMALL)
    );

    if (mesh.objectRegistry::foundObject<volScalarField>("delta"))
    {
        Info << "Found it!" << endl;
        const volScalarField& delta =
            mesh.objectRegistry::lookupObject<volScalarField>("delta");
        LESdelta = delta;
    }
    else
    {
        Info << "No joy I am afraid" << endl;
    }
    Info << LESdelta << endl;

    Info << "-------------------------------------" << endl;
... i.e. it printed out the contents of the delta field.
Interesting, it is maybe because I was trying to reach it in turbulenceModel constructor, that must be why.

Regards
kont87 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
Error: WorkBench Error: Could not handle event: SolutionStatusUpdate Kieyo Fluent Multiphase 0 November 9, 2022 23:58
viscosity udf don't use correct temperature and strain rate rezvani Fluent UDF and Scheme Programming 8 May 27, 2021 05:40
Updating solver version saj216 OpenFOAM Programming & Development 0 April 29, 2020 09:25
Problem in compiling a solver made for a different version (v2.0 ->v4.1) JLS OpenFOAM Programming & Development 2 July 9, 2019 14:03
Converting custom solver from old version to openFoam4.1 Nigel Bruce Khan OpenFOAM Running, Solving & CFD 2 August 11, 2017 10:45


All times are GMT -4. The time now is 05:32.