CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

Accessing the value of a field variable

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 23, 2018, 11:01
Default Accessing the value of a field variable
  #1
Member
 
Join Date: Feb 2018
Posts: 87
Rep Power: 4
charles4allme is on a distinguished road
Hello,

I have looked at the forums and have found solutions but I want to be sure that I am correct. I am trying to access the value of velocity during each time step to calculate losses in a ventilation duct. Here is the form that I have written it in:

Code:
const volVectorField& Uduct = U.db().lookupObject<volVectorField>("U");
Uduct is what I would input into my equation for calculating the duct losses. Is that the right way of setting it up. I appreciate any input.

Thanks
charles4allme is offline   Reply With Quote

Old   June 23, 2018, 16:15
Default
  #2
Member
 
Norbert Weber
Join Date: May 2012
Location: Dresden, Germany
Posts: 34
Rep Power: 10
dl6tud is on a distinguished road
Your questions is difficult to understand. From where do you need to access the velocity? In a boundary condition? In the solver itself? In a post-processing tool?
dl6tud is offline   Reply With Quote

Old   June 25, 2018, 08:15
Default
  #3
Member
 
Join Date: Feb 2018
Posts: 87
Rep Power: 4
charles4allme is on a distinguished road
HI thanks,


From the solver itself. So what ever value of U in the time step, it looks it up and gets the value. Is that possible?
charles4allme is offline   Reply With Quote

Old   June 25, 2018, 08:26
Default
  #4
Member
 
Norbert Weber
Join Date: May 2012
Location: Dresden, Germany
Posts: 34
Rep Power: 10
dl6tud is on a distinguished road
U


only "U"


Info << U << endl;
dl6tud is offline   Reply With Quote

Old   June 25, 2018, 15:06
Default
  #5
Member
 
Join Date: Feb 2018
Posts: 87
Rep Power: 4
charles4allme is on a distinguished road
Alright thanks.


Is it possible to use the values at each time step to update the values for the reynolds number. I need the value for the reynolds number to calculate the flow loss. I assumed my earlier code would do that but at the moment all I think it does is take the initial velocity value.


Thanks.
charles4allme is offline   Reply With Quote

Old   June 25, 2018, 17:07
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 928
Rep Power: 26
olesen will become famous soon enougholesen will become famous soon enough
Quote:
Originally Posted by charles4allme View Post
Hello,

I have looked at the forums and have found solutions but I want to be sure that I am correct. I am trying to access the value of velocity during each time step to calculate losses in a ventilation duct. Here is the form that I have written it in:

Code:
const volVectorField& Uduct = U.db().lookupObject<volVectorField>("U");
Uduct is what I would input into my equation for calculating the duct losses. Is that the right way of setting it up. I appreciate any input.

Thanks
Actually your code snippet makes very little sense (or it suffered from transcription problems).

If we really start with this:
Code:
const volVectorField& Uduct = U.db().lookupObject<volVectorField>("U");
The "U" part is presumably already the velocity field. The "db()" part gets you the objectRegistry used by "U", which means your mesh. From this the "lookupObject" finds the named object of the specified type. Which seems like you've gone once around to come up with a reference to your starting point??

If you want to calculate a Reynolds number or something, having the entire velocity field throughout the volume probably won't help much. It might be more useful to use a sampling plane or a sampling patch combined with an area average to obtain a representative value.
Can't say offhand where you want to proceed from there (how to get a length scale, which rho, mu, etc) - it's not really obvious from your post what data or geometry you have.

/mark
olesen is offline   Reply With Quote

Old   June 26, 2018, 06:45
Default
  #7
Member
 
Join Date: Feb 2018
Posts: 87
Rep Power: 4
charles4allme is on a distinguished road
Quote:
Originally Posted by olesen View Post
Actually your code snippet makes very little sense (or it suffered from transcription problems).

If you want to calculate a Reynolds number or something, having the entire velocity field throughout the volume probably won't help much. It might be more useful to use a sampling plane or a sampling patch combined with an area average to obtain a representative value.
Can't say offhand where you want to proceed from there (how to get a length scale, which rho, mu, etc) - it's not really obvious from your post what data or geometry you have.

/mark
I would go with your suggestion to calculate the Reynolds number. I have all other variables except the length scale on this occassion . I have attached the geometry. Its a simple case of flow through a ventilation duct with an initial velocity of 10m/s. The dimension of the duct is 0.4m x 0.4m x 3m.

Thanks.
Attached Images
File Type: png Screenshot from 2018-06-26 11-43-30.png (5.3 KB, 7 views)
charles4allme is offline   Reply With Quote

Old   June 17, 2020, 16:36
Default
  #8
Member
 
René Thibault
Join Date: Dec 2019
Posts: 47
Rep Power: 2
Tibo99 is on a distinguished road
What would be the code line to access to the variable field 'k', let say at every cells center of the domain, but from the file fvOptions?

I try to find an example of how to achieve that and I find nothing.

Thank!

Best Regards,
Tibo99 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[Other] dynamicTopoFVMesh and pointDisplacement RandomUser OpenFOAM Meshing & Mesh Conversion 6 April 26, 2018 07:30
Compare field variable in two cells upuli OpenFOAM Programming & Development 0 July 24, 2017 01:06
Help solving "c dot inv(A)" after solving the field variable (Ax=b) Logan Page OpenFOAM Programming & Development 0 September 11, 2014 07:57
field function to point variable temperature Trofrensis STAR-CCM+ 1 November 25, 2009 00:46
field variable macro of the mean-x-velocity? zt xie FLUENT 2 November 15, 2005 05:48


All times are GMT -4. The time now is 19:58.