|
[Sponsors] |
September 27, 2021, 14:35 |
Error: Request from objectRegistry failed
|
#1 |
New Member
Christoph
Join Date: Jan 2021
Location: Vienna
Posts: 10
Rep Power: 5 |
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. 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(); 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 |
|
September 27, 2021, 15:34 |
|
#2 | |
Senior Member
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28 |
Quote:
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() ) ); |
||
September 27, 2021, 17:04 |
|
#3 |
New Member
Christoph
Join Date: Jan 2021
Location: Vienna
Posts: 10
Rep Power: 5 |
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. |
|
September 28, 2021, 10:58 |
|
#4 |
Senior Member
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28 |
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 } |
|
|
|
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 04:35 |
Initial conditions for uniform flow | andreas | OpenFOAM | 5 | November 16, 2012 16:00 |
[OpenFOAM] ParaView/Parafoam error when making animation | Disco_Caine | ParaView | 6 | September 28, 2010 10:54 |
user subroutine error | CFDUSER | CFX | 2 | December 9, 2006 07:31 |
user defined function | cfduser | CFX | 0 | April 29, 2006 11:58 |