|
[Sponsors] |
Storing Boundary Condition Values for Later Use |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 19, 2011, 16:10 |
Storing Boundary Condition Values for Later Use
|
#1 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
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. |
|
October 19, 2011, 22:08 |
|
#2 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
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.
__________________
~~~ Follow me on twitter @DavidGaden |
|
October 19, 2011, 22:20 |
|
#3 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
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. |
|
October 20, 2011, 04:41 |
|
#4 | |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
Quote:
What is the overall algorithm that you need? I don't mean what you have implemented so far, but, your actual goal? Last edited by tomislav_maric; October 20, 2011 at 07:03. Reason: unclear qestion |
||
October 20, 2011, 11:02 |
|
#5 | |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
Dear All,
Thank you for your replies! I will reply to them in anti-chronological order.
Looking forward to your replies, Kind regards, Francois. |
||
October 20, 2011, 11:35 |
|
#6 |
Senior Member
Tomislav Maric
Join Date: Mar 2009
Location: Darmstadt, Germany
Posts: 284
Blog Entries: 5
Rep Power: 21 |
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 |
|
October 20, 2011, 17:21 |
|
#7 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
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.
__________________
~~~ Follow me on twitter @DavidGaden |
|
October 21, 2011, 09:15 |
|
#8 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
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. |
|
October 21, 2011, 10:47 |
|
#9 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
tmp<> will only work if another object is holding a reference to it outside of your boundary condition.
__________________
~~~ Follow me on twitter @DavidGaden |
|
December 9, 2011, 12:00 |
Store in Object registry
|
#10 |
Senior Member
Francois
Join Date: Jun 2010
Posts: 107
Rep Power: 21 |
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 ); if( !mesh.thisDb().foundObject< IOList< vector > >( "avgMean" ) ) { if( Pstream::master() ) { avgMeanReturned = readMeanFromFile(); } reduce( avgMeanReturned , sumOp< List< vector > >() ); mesh.thisDb().store ( new IOList< vector > ( IOobject ( "avgMean", mesh, IOobject::NO_READ, IOobject::NO_WRITE ), avgMeanReturned ) ); } else { const IOList< vector >& dbVecLst = mesh.thisDb().lookupObject< IOList< vector > >( "avgMean" ); avgMeanReturned = dbVecLst; } return avgMeanReturned; Code:
// using the new variable avgMeanUpdated const IOList< vector >& dbVecLst = mesh.thisDb().lookupObject< IOList< vector > >( "avgMean" ); const_cast< IOList< vector >& >( dbVecLst ) = avgMeanUpdated; Kind regards, Francois. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Boundary condition & reverse flows | zhenglun.wei | FLUENT | 4 | October 25, 2011 18:38 |
ATTENTION! Reliability problems in CFX 5.7 | Joseph | CFX | 14 | April 20, 2010 16:45 |
how to set up a wall boundary condition according to calculated wall shear stress? | gameoverli | OpenFOAM Pre-Processing | 1 | May 21, 2009 09:28 |
Convective Heat Transfer - Heat Exchanger | Mark | CFX | 6 | November 15, 2004 16:55 |
Pressure Boundary Condition | Matt Umbel | Main CFD Forum | 0 | January 11, 2002 11:06 |