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

[OF 5.0] - declaring single variables

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 24, 2018, 10:33
Default [OF 5.0] - declaring single variables
  #1
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Howdy folks:

I am wondering if there is a way to create individual variables at the beginning of solving, and let the solver change it through out.

In my solver, there are a number of solution domain independent variables (think g, but changes in value through time) and I would like to be able to update their values at the start of each iteration while allowing the solver variables (U, p, T, etc) to access them in the inner iteration. Since the value will be identifical to all cells, so I don't want to create an extra scalar to save space and computational effort. How could this be done?

Thanks in advance, GK.
Gerry Kan is offline   Reply With Quote

Old   May 28, 2018, 17:07
Default Turns out it wasn't so bad afterall
  #2
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
So it was more straightforward than I thought. As I am still at the prototyping stage, I don't want to be too fancy with my code, but it looks like I can declare variables (scalars, bool, what not) at the solver level and have them accessible later. So for now my problem is solved.

But again, once my solver works, I should think about packaging these variables nicely (in a class, for instance).

Gerry.
Gerry Kan is offline   Reply With Quote

Old   May 29, 2018, 09:46
Default
  #3
New Member
 
Marius Bünker
Join Date: Oct 2017
Posts: 13
Rep Power: 8
Blumenkind is on a distinguished road
Declare them as Fields (for example VolScalarField)
OpenFoam recognizes that they are uniform for your domain and converts them to uniformField, which is saved as one Value and your BC.
Blumenkind is offline   Reply With Quote

Old   May 29, 2018, 10:39
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
Quote:
Originally Posted by Blumenkind View Post
Declare them as Fields (for example VolScalarField)
OpenFoam recognizes that they are uniform for your domain and converts them to uniformField, which is saved as one Value and your BC.
Why on earth would you run all the machinery to create a uniform field with boundaries, when all you need is a scalar?
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   May 30, 2018, 01:43
Red face
  #5
New Member
 
Marius Bünker
Join Date: Oct 2017
Posts: 13
Rep Power: 8
Blumenkind is on a distinguished road
You are right. I somehow thought, he wanted to save them and then he would have needed IOObjects.
Blumenkind is offline   Reply With Quote

Old   May 30, 2018, 16:52
Default
  #6
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
Gerry Kan is on a distinguished road
Quote:
Originally Posted by Blumenkind View Post
Declare them as Fields (for example VolScalarField)
OpenFoam recognizes that they are uniform for your domain and converts them to uniformField, which is saved as one Value and your BC.
Hallo Blumenkind: That's the situation I want to avoid. But for now I am declaring them as "globals" and for now I am happy with it. The solver should have access to them in the inner / outer loops, should I need them.

VG, Gerry.
Gerry Kan 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
[swak4Foam] How to define boundary condition variables by using previosly defined variables? pawlo OpenFOAM Community Contributions 8 September 13, 2020 11:37
Single v.s. double precision Confused CFX 15 November 10, 2016 04:42
How to export single variable of a single surface? zeitistgeld CFX 6 September 26, 2009 06:37
PHI file structure Eugene Phoenics 9 November 2, 2001 22:00
P4 1.5 or Dual P3 800EB on Gibabyte board Danial FLUENT 4 September 12, 2001 11:44


All times are GMT -4. The time now is 12:35.