|
[Sponsors] |
Accessing transportProperties from coded functionObject |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 19, 2021, 12:35 |
Accessing transportProperties from coded functionObject
|
#1 |
Member
Join Date: Feb 2020
Posts: 90
Rep Power: 6 |
Hello to all,
I would like to create a custom functionObject to use in laplacianFoam. For this purpose, I need the parameter DT in the dictionary transportProperties. I have: Code:
functions { myCodedFunction { type coded; libs (utilityFunctionObjects); writeControl runTime; writeInterval $writeInterval; // Name of on-the-fly generated functionObject name test; codeWrite #{ // Lookup for T const volScalarField& T = mesh().lookupObject<volScalarField>("T"); // Gets the DT coefficient from const dictionary& transportProperties = mesh().lookupObject<IOdictionary> ( "transportProperties" ); const scalar alpha (transportProperties.getScalar("DT")); Info << "Alpha is: " << alpha << endl; #}; } } Code:
request for dictionary transportProperties from objectRegistry region0 failed available objects of type dictionary are 4(fvSchemes fvOptions fvSolution data) It the transportProperties not created yet? Am I looking for it in a wrong manner? |
|
April 19, 2021, 16:26 |
|
#2 |
Senior Member
Join Date: Aug 2015
Posts: 494
Rep Power: 15 |
A quick look at the laplacianFoam code suggests that the transportProperties dictionary is only created (inside an if statement) if DT doesn't exist (otherwise it's read). So to guess at a fix you could create a custom version of laplacianFoam in which you force the creation of the dictionary without the if statement, or create a dummy/copy of it inside your function object like :
Code:
IOdictionary dummyTransportProperties //ensure the original isn't duplicated ( IOobject ( "transportProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); //then read from dict const scalar alpha (transportProperties.getScalar("DT")); Caelan
__________________
Public git repository : https://github.com/clapointe2011/public |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
accessing 0 time directory in coded functionObject | JM27 | OpenFOAM Programming & Development | 3 | May 26, 2023 17:50 |
Cannot find functionObject file residuals | vava10 | OpenFOAM Pre-Processing | 2 | November 14, 2020 13:21 |
accessing 0 time directory in coded functionObject | JM27 | OpenFOAM Post-Processing | 0 | November 21, 2018 09:41 |
Coded FunctionObject to calculate distance to axis? Nothing written | be_inspired | OpenFOAM Programming & Development | 0 | February 22, 2018 19:23 |
codeInclude in coded function in controlDict, and yPlus | LuisAlberto | OpenFOAM Programming & Development | 4 | August 18, 2015 13:48 |