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

Error: Request from objectRegistry failed

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By GerhardHolzinger
  • 1 Post By GerhardHolzinger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 27, 2021, 13:35
Default Error: Request from objectRegistry failed
  #1
New Member
 
Christoph
Join Date: Jan 2021
Location: Vienna
Posts: 10
Rep Power: 5
woodie is on a distinguished road
Good day everybody,

I have a question concerning an error about requesting objects from the objectRegistry.
I get the following error when using decomposePar:

Code:
--> FOAM FATAL ERROR:

    request for incompressibleTurbulenceModel turbulenceProperties from objectRegistry region0 failed
    available objects of type incompressibleTurbulenceModel are
0()

    From function const Type& Foam::objectRegistry::lookupObject(const Foam::word&, bool) const [with Type = Foam::incompressibleTurbulenceModel]
    in file /home/cholzinger/OpenFOAM/OpenFOAM-v1912/src/OpenFOAM/lnInclude/objectRegistryTemplates.C at line 463.
I know it has something to do with the BC i have programmed for omega. It works perfectly fine with a standard BC, but with my custom BC, the error occurs (It occurs as well using other functions like renumberMesh, but i was able to work around that). So my understanding is, that when OpenFoam reads 0/omega, it tries to look up a turbulence model which ist not selected yet.

In the custom BC the Reynolds Stress Tensor is retrieved by something like that (in the .C-File):

Code:
	
// - Retrieve Reynolds Stress Tensor from Turbulence Model
const incompressibleTurbulenceModel& turbModel = db().lookupObject<incompressibleTurbulenceModel>
const tmp<volSymmTensorField> Re1 = turbModel.devReff();
In general, the custom BC is used with a custom turbulence model (slightly modified SSTLM) to model surface roughness and i use v1912.

Does anyone know a better way to program this, or a workaround so i can use functions which only read the 0-directory like decomposePar and renumberMesh?

Best regards
Christoph
woodie is offline   Reply With Quote

Old   September 27, 2021, 14:34
Default
  #2
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 341
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Quote:
Originally Posted by woodie View Post
Code:
    
// - Retrieve Reynolds Stress Tensor from Turbulence Model
const incompressibleTurbulenceModel& turbModel = db().lookupObject<incompressibleTurbulenceModel>
const tmp<volSymmTensorField> Re1 = turbModel.devReff();
Christoph

I see a difference between your code and OpenFOAM-v1912 in the way the turbulence model is fetched from the object registry:


Code:
    const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
    (
        IOobject::groupName
        (
            turbulenceModel::propertiesName,
            internalField().group()
        )
    );
This may or may not be the cause of the error, however the standard omegaWallFunction BC does it this way.
s7020588 likes this.
GerhardHolzinger is offline   Reply With Quote

Old   September 27, 2021, 16:04
Default
  #3
New Member
 
Christoph
Join Date: Jan 2021
Location: Vienna
Posts: 10
Rep Power: 5
woodie is on a distinguished road
Thanks for your quick response.

The reason for that difference is that i need to access defReff to compute the wall shear stress. And i only managed to do that through the incompressibleTurbulenceModel class.
woodie is offline   Reply With Quote

Old   September 28, 2021, 09:58
Default
  #4
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 341
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
Two problems:

1. Assuming that looking-up the turbulenceModel is always possible.
This causes the error when running decomposePar. Pre-processing utilities generally do not create a turbulence model. Hence, when the BC is constructed, there is no turbulenceModel for the BC to look-up.

Code:
    // check if there is a turbulence model in the object registry
    //  this is the case when the solver runs the case
    //  this is not the case when we do pre-processing
    if
    (
        db().found
        (
            IOobject::groupName
            (
                turbulenceModel::propertiesName,
                internalField().group()
            )
        )
    )
    {
        // get the turbulence model from the object registry
        //  this returns the base class
        const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>
        (
            IOobject::groupName
            (
                turbulenceModel::propertiesName,
                internalField().group()
            )
        );

        // do what you intend to do here

    }

2. Using/relying on methods that are provided by some classes further down the family tree.
This was the reases why you looked up incompressibleTurbulenceModel instead of turbulenceModel. While this is technically not wrong, it would be safer and better form () to look up the base class, i.e. the root of the family tree (of class inheritance); and then check whether the looked-up turbulence model is acutally an incompressible one. If this is the case, you can do a type-cast, which then provides you all the methods you intend to use.

Code:
        // check whether the turbulence model is an incompressible one
        if (isA<incompressibleTurbulenceModel>(turbModel))
        {
            // get a reference to the incompressible turbulence model by doing a refCast
            //  now we have access to methods that the base class does not provide, e.g. devReff()
            const incompressibleTurbulenceModel& incompTurbModel = refCast<const incompressibleTurbulenceModel>(turbModel);
	        
	        // - Deviatoric Reynolds Stress Tensor at boundary patch
	        const tmp<volSymmTensorField> Re1 = incompTurbModel.devReff();
	        
	        // do what you intend to do here
	    }
woodie likes this.
GerhardHolzinger 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
Foam::error::printStack(Foam::Ostream&) with simpleFoam -parallel U.Golling OpenFOAM Running, Solving & CFD 52 September 23, 2023 03:35
Initial conditions for uniform flow andreas OpenFOAM 5 November 16, 2012 15:00
[OpenFOAM] ParaView/Parafoam error when making animation Disco_Caine ParaView 6 September 28, 2010 09:54
user subroutine error CFDUSER CFX 2 December 9, 2006 06:31
user defined function cfduser CFX 0 April 29, 2006 10:58


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