Storing Boundary Condition Values for Later Use
Dear Foamers,
I would like to be able to store time-averaged patch values I extract from a boundary condition I'm programming. More specifically I'm trying to store a vectorField. The problem is that at every (sub)-iteration step the boundary condition I'm working on is instantiated and destroyed again, making it impossible to store it in the boundary condition itself. I thought of a few things:
Would anybody know how to solve this? Maybe by finding a way workaround allowing me to modify the IOList? Looking forward to your suggestions Francois. |
Can you access it during a sub iteration, when it is still alive, and store a copy at the top level? Then you could use your registry hack to retrieve a const copy from within the boundary condition the next time to create a fresh copy.
I can't think of much else - the algorithm you describe is difficult to guess at. |
So you want a vectorField stored for each time-step? Are you looking to store this list of vectorFields to a file eventually (i.e., when the run is completed presumably)?
You can always resize a field using the setSize() member function, so it is possible to modify it after construction. |
Quote:
What is the overall algorithm that you need? I don't mean what you have implemented so far, but, your actual goal? |
Dear All,
Thank you for your replies! I will reply to them in anti-chronological order.
Looking forward to your replies, Kind regards, Francois. |
Well, if the IOobject is dying when going out of scope, why not wrap it into a tmp<IOobject>? This way, it won't die after going out of scope... either this or autoPtr..
I think I get what you mean to do now (hopefully), thanks for clarifying! :) Tomislav |
Yes, you could try using tmp. See here: http://openfoamwiki.net/index.php/OpenFOAM_guide/tmp
Here's what I mean. In createFields.H: - Create a vectorField with a size of 0. - Initialize your IOList<vector> hack as well, size = 0. In your custom boundary condition: - lookup your IOList -- if size = 0, initialize your temporary vectorField with all vectors at your initial guess (zero?). -- if size != 0, initialize your temporary vectorField by copying the vectors from IOList. In you solver body, sub-iteration loop, when the custom boundary condition exists: - Access the boundary field in question. - setSize your IOList, and copy the field values into it. |
Dear Tomislav, dear David,
Although I was aware of the existence of tmp<> objects I thought they were only used to return large objects from functions. I will re-dive in the wiki and try to implement my vectorFields following your guidelines. I'll keep you updated on my progress! Thank you for your help, Kind regards, Francois. |
tmp<> will only work if another object is holding a reference to it outside of your boundary condition.
|
Store in Object registry
Anyways, just in case somebody might be interested in how I solve this problem, here is my workaround:
Code:
List<vector> avgMeanReturned( my_var_size, vector::zero ); Code:
// using the new variable avgMeanUpdated Kind regards, Francois. |
All times are GMT -4. The time now is 04:22. |