|
[Sponsors] |
given a volScalarField object, how to read inputs from its dictionary |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 1, 2019, 16:54 |
given a volScalarField object, how to read inputs from its dictionary
|
#1 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
Hello,
If I have access to a volScalarField object, or volVectorField object. How can I access to its dictionary to read some inputs? For example, if I have access to the velocity field U object, how can I lookup for an input from the dictionary 0/U? Regards |
|
August 2, 2019, 06:08 |
|
#2 |
Member
Vivek
Join Date: Mar 2018
Location: India
Posts: 54
Rep Power: 8 |
Hi,
volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); I hope You are expecting the same like above lines. |
|
August 2, 2019, 08:31 |
|
#3 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
Sorry, that is not what I am asking. You just declared a volVectorField. I am not asking for that I am looking how to get a reference to the dictionary object given a volScalarField (or volVectorField).
|
|
August 7, 2019, 12:08 |
|
#4 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
Quote:
It doesn't work like that. You can start with a file that is more or less in dictionary format, and use that to create the fields. After this has happened, the dictionary input has no mean and also cannot be accessible. If, for example, you imagine creating a volScalarField from some other calculation, there simply is no dictionary correspondence. Depending on what you really need, you could go back to searching for the file on disk and read if from there. Can see why you'd want any of that though. If you have the volField, you have direct access to its contents and all of its boundary values. The only place where I might imagine wishing to have a dictionary would be if you are trying to stream off to some other external application. Could use a OListStream and then the writeEntries() methods on the boundary fields. /mark |
||
August 7, 2019, 13:12 |
|
#5 |
Senior Member
Join Date: Mar 2018
Posts: 115
Rep Power: 8 |
hello Mark,
Thank you for your reply. Actually, I need to access to some custom variables in the file 0/U but I have only a reference to the volVectorField U. |
|
August 7, 2019, 13:52 |
|
#6 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
Quote:
Just use an IOdictionary to read them in for name "U" and time 0 in that case, but make certain to have the IOobject unregistered to avoid any name collisions with your field. |
||
August 9, 2019, 02:07 |
|
#7 |
New Member
Ashwin
Join Date: Mar 2018
Location: Houston Texas
Posts: 10
Rep Power: 8 |
I created a custom list of scalar (powertime) and list of vector (powerVectime) in my thermophysicalProperties.air file and I could access the entries using the following command in my fvOptions.
List<scalar> my_myList = mesh().lookupObject<IOdictionary>("thermophysicalP roperties.air").lookup("powertime"); List<vector> my_vec = mesh().lookupObject<IOdictionary>("thermophysicalP roperties.air").lookup("powerVectime"); I have not tried accessing U fields , but may be we can try this way and see if it works. Hope this helps.. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[foam-extend.org] Error compiling OpenFOAM-1.6-ext | Canesin | OpenFOAM Installation | 137 | January 20, 2016 14:56 |
Read properties per component from an input file dictionary | Cyp | OpenFOAM Programming & Development | 29 | November 1, 2015 21:41 |
How to read a list from a dictionary? | ivan_cozza | OpenFOAM Programming & Development | 6 | November 7, 2014 08:31 |
Compilation error OF1.5-dev on Suse10.3 | darenyang | OpenFOAM Installation | 0 | April 29, 2009 04:55 |
Phase locked average in run time | panara | OpenFOAM | 2 | February 20, 2008 14:37 |