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

[PyFoam] Using pyFoam to extract BCs from text file and automate my own solver

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By gschaider

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 3, 2014, 07:03
Post Using pyFoam to extract BCs from text file and automate my own solver
  #1
New Member
 
Edward Shorthouse
Join Date: Dec 2014
Posts: 2
Rep Power: 0
e.shorthouse is on a distinguished road
Hello all,

I have a text file with 40 sets of boundary conditions (4 parameters in each BC set).

I'm trying to use pyFoam to extract one BC set at a time and feed into my case, and to run my own solver on that case (a variant of buoyantBoussinesqSimpleFoam). Q: Do I need a separate text file for each boundary condition, or can pyFoam extract the values for each of the 40 BC parameters from a single text file?

Once each case has converged I want to take the BCs from the last time step of that case and use as the first time step for the next case.

Can all the above be done using one pyFoam utility? If so, which one is most appropriate.

Thanks!



Last edited by e.shorthouse; December 3, 2014 at 07:04. Reason: format of table looked wrong
e.shorthouse is offline   Reply With Quote

Old   December 3, 2014, 08:44
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by e.shorthouse View Post
Hello all,

I have a text file with 40 sets of boundary conditions (4 parameters in each BC set).

I'm trying to use pyFoam to extract one BC set at a time and feed into my case, and to run my own solver on that case (a variant of buoyantBoussinesqSimpleFoam). Q: Do I need a separate text file for each boundary condition, or can pyFoam extract the values for each of the 40 BC parameters from a single text file?

Once each case has converged I want to take the BCs from the last time step of that case and use as the first time step for the next case.

Can all the above be done using one pyFoam utility? If so, which one is most appropriate.

Thanks!


I'm not quite clear what you mean with "extract one BC set at a time". Is this "set by the user" or "set as the result of a solver run". Also: please stay with the OF-nomenclature "BC set" means what? A patch? Or a boundary field on a patch? I think it would be best if you explained in a step by step fashion what you're currently doing. Then I can give you a concrete answer. Currently I can think of at least 4 different ones depending on what you mean
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   December 3, 2014, 09:47
Default
  #3
New Member
 
Edward Shorthouse
Join Date: Dec 2014
Posts: 2
Rep Power: 0
e.shorthouse is on a distinguished road
Thanks Bernhard, by BC I mean boundary conditions for my 0 time directory. All the boundary conditions are set by me (the user) which are in a separate text file.

The 4 user variables (in addition to the standard ones 'k', 'epsilon' etc which are kept the same for each case) used in the boundary conditions are: wall surface temp, floor surface temp, relative humidity and air speed. I have 40 sets of values for these variables which I want to run on my case. I've attached the text file with the user variables.

I am running my solver on the same mesh using the 40 different user set boundary conditions (so I have 40 cases because the boundary conditions are different every time). This is what I want to automate with pyFoam.

Running 40 cases in series will take a long time, so to speed up convergence for each case, I want to use the latestTime directory from the previous converged case to start off my run for the next case.

Hope that makes sense,

Thanks
Attached Files
File Type: xls Training Data for OpenFoam Building Model - 251114.xls (13.0 KB, 9 views)
e.shorthouse is offline   Reply With Quote

Old   December 3, 2014, 10:22
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by e.shorthouse View Post
Thanks Bernhard, by BC I mean boundary conditions for my 0 time directory. All the boundary conditions are set by me (the user) which are in a separate text file.

The 4 user variables (in addition to the standard ones 'k', 'epsilon' etc which are kept the same for each case) used in the boundary conditions are: wall surface temp, floor surface temp, relative humidity and air speed. I have 40 sets of values for these variables which I want to run on my case. I've attached the text file with the user variables.

I am running my solver on the same mesh using the 40 different user set boundary conditions (so I have 40 cases because the boundary conditions are different every time). This is what I want to automate with pyFoam.

Running 40 cases in series will take a long time, so to speed up convergence for each case, I want to use the latestTime directory from the previous converged case to start off my run for the next case.

Hope that makes sense,

Thanks
You want to do a "parameter variation". Since the release last week there is a utility pyFoamRunParameterVariation.py which builds on the template engine described here http://openfoamwiki.net/staticPages/....slides.html#/

Two problems with that:
- apart from the online-help there is no documentation on this
- it varies the 4 parameters independently and judging from that you have 40 sets this is not applicable for your case

Apart from that I think you'll have to write a script yourself. Something like http://openfoamwiki.net/index.php/Co...eter_Variation
The main "challenge" would be getting the values into the script but the DictReader from https://docs.python.org/2/library/csv.html might be your friend here
davibarreira and e.shorthouse like this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Reply

Tags
pyfoam


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
Using fluent loop to automate write to the file Eman. FLUENT 1 November 17, 2017 03:02
Hybrid discretisation - blend factor gcoopermax CFX 5 September 23, 2016 08:05
Flow 3D Cast Exporting Output as Text File shantanu1 FLOW-3D 0 October 30, 2015 11:51
Journal file to automate a time step change Damien_CFD FLUENT 0 August 2, 2011 07:05


All times are GMT -4. The time now is 17:36.