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

Global variables or How to get a vector into an objectRegistry

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By maddhi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 19, 2008, 08:08
Default Hello everyone! What is the
  #1
maddhi
Guest
 
Posts: n/a
Hello everyone!

What is the recommended approach to handle "global" variables? For example a vector U0 which is calculated in a solvers main() function, but which is also required (and maybe modified) when boundary conditions are evaluated in a class myFvPatchField?

In order to avoid global variables I would assume that passing U0 through an objectRegistry, known to both main() and myFvPatchField, could be a common solution. If not, what else would you suggest?

Assuming myFvPatchField has a member variable mesh _ containing this objectRegistry, I can get retrieve U0 inside myFvPatchField with

vector U0=mesh_.lookupObject<vector>("U0"));.

But how do I get U0 *into* the objectRegistry mesh at the main() side? It must be something like

vector mainU0;
...
mesh.checkIn(regIOobject("U0",...mainU0...));.

But I can't get sorted out how to use the regIOobject, IOobject, objectRegistry and IOdictionary in the correct way, because their interrelationship isn't clear to me.

Any hints how the ...checkIn... line has to look like? Or about other solutions to pass U0 between main() and fvPatchFields without looping over all patches from within main() and assigning U0 to each of the fvPatchFields through an additional setter function?

With kind regards
Maddhi
mitu_94 likes this.
  Reply With Quote

Old   January 8, 2016, 02:56
Default
  #2
New Member
 
anand sudhi
Join Date: Sep 2015
Posts: 16
Rep Power: 11
anandsudhi is on a distinguished road
Hi maddhi,

I am also trying to figure out how to add the vector into the object registry. Please share if you recall the solution.
anandsudhi 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
MSHArequest for surfaceScalarField phi from objectRegistry msha OpenFOAM Running, Solving & CFD 11 March 21, 2014 04:35
Global variables harly OpenFOAM Running, Solving & CFD 0 December 5, 2008 21:41
Register pointer to class in mesh objectRegistry kar OpenFOAM 1 June 3, 2008 05:57
Global and local variables Astrid CFX 8 April 16, 2002 01:52
Global variables storage in CFX. Fabio Kasper CFX 1 October 6, 2000 09:21


All times are GMT -4. The time now is 08:27.