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

given a volScalarField object, how to read inputs from its dictionary

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 1, 2019, 16:54
Default given a volScalarField object, how to read inputs from its dictionary
  #1
Senior Member
 
Join Date: Mar 2018
Posts: 115
Rep Power: 8
anon_q is on a distinguished road
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
anon_q is offline   Reply With Quote

Old   August 2, 2019, 06:08
Smile
  #2
Member
 
Vivek
Join Date: Mar 2018
Location: India
Posts: 54
Rep Power: 8
vivek05 is on a distinguished road
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.
vivek05 is offline   Reply With Quote

Old   August 2, 2019, 08:31
Default
  #3
Senior Member
 
Join Date: Mar 2018
Posts: 115
Rep Power: 8
anon_q is on a distinguished road
Quote:
Originally Posted by vivek05 View Post
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.
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).
anon_q is offline   Reply With Quote

Old   August 7, 2019, 12:08
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Evren Linda View Post
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



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
olesen is offline   Reply With Quote

Old   August 7, 2019, 13:12
Default
  #5
Senior Member
 
Join Date: Mar 2018
Posts: 115
Rep Power: 8
anon_q is on a distinguished road
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.
anon_q is offline   Reply With Quote

Old   August 7, 2019, 13:52
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Evren Linda View Post
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.

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.
olesen is offline   Reply With Quote

Old   August 9, 2019, 02:07
Default
  #7
api
New Member
 
Ashwin
Join Date: Mar 2018
Location: Houston Texas
Posts: 10
Rep Power: 8
api is on a distinguished road
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..
api 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-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


All times are GMT -4. The time now is 04:11.