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

Update boundary conditions calculated by an external program

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 13, 2010, 17:16
Question Update boundary conditions calculated by an external program
  #1
Member
 
Cedric Van Holsbeke
Join Date: Dec 2009
Location: Belgium
Posts: 81
Rep Power: 16
CedricVH is on a distinguished road
How can I update boundary conditions, calculated by an external program, in OpenFoam 1.6 while running a case?

The program was originally written for Fluent. It generates a file boundary.txt which contains pressure boundary conditions. Fluent reads these boundary conditions, iterates 30 times and outputs some variables in a file var.txt. This file is read in the external program and this program calculates new boundary conditions in the file boundary.txt which is read in Fluent, ... The process is stopped when the program generates a stop file.

The journal file for Fluent is rather straigthforward:

Code:
(do ((iter 1 (+ iter (rpgetvar 'stop-the-journal)))) ((> iter 1))
(ti-menu-load-string (format #f "file read-bc \"boundary.txt\" "))
  (ti-menu-load-string (format #f "solve iterate 30"))
  (ti-menu-load-string (format #f "report all sorts of variables \"var.txt\" "))
  ...
)
I want to use this external program with simpleFoam, but I don't really know how to do this efficiently. How I would do it:
  1. Make a good controlDict file ( startFrom latestTime; stopAt writeNow )
  2. Read the file boundary.txt, transform the contents with sed (or awk or perl) and put the contents in the 0/p file as fixedValue
  3. Let simpleFoam iterate 30 times, write the 30 folder, calculate the variables to a file var.txt and feed them to the external program
  4. Read the changed file boundary.txt, generated by the external program, transform the contents with sed and put the boundary conditions in the 30/p file as fixedValue
  5. Do this for 60, 90, ...
  6. Stop when the external program generates a stop file
The problem is that my method will be very slow. In step 4, the p file will be very big and the sed operations will take a lot of time.

Is there a better method, comparable to the Fluent script, to achieve this?

Last edited by CedricVH; January 13, 2010 at 17:44.
CedricVH is offline   Reply With Quote

Old   January 15, 2010, 06:26
Question
  #2
Member
 
Cedric Van Holsbeke
Join Date: Dec 2009
Location: Belgium
Posts: 81
Rep Power: 16
CedricVH is on a distinguished road
The text replacement is faster than foreseen and is not the bottleneck!

However, when running MPI cases, my method does not work anymore as the boundary conditions are spreaded across the several processor directories. Is there a way to change the boundary conditions in a generic way like the command "file read-bc" in Fluent?
CedricVH is offline   Reply With Quote

Old   January 15, 2010, 12:55
Default
  #3
Member
 
Cedric Van Holsbeke
Join Date: Dec 2009
Location: Belgium
Posts: 81
Rep Power: 16
CedricVH is on a distinguished road
It seems that this is not possible and that I have to use another boundary field than fixedValue.

I've looked at timeVaryingUniformFixedValue, but the values have to be known before the run starts and it interpolates the values. I'm searching for a boundary field that can read boundary conditions at runtime and does not interpolate.

I'm rather new to OpenFoam so I don't know how to modify an existing boundary field. Maybe somebody can help me?
CedricVH 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
Some Problems about the Boundary Conditions in OpenFoam lzgwhy OpenFOAM Running, Solving & CFD 47 October 10, 2017 09:33
Boundary Conditions Thomas P. Abraham Main CFD Forum 20 July 7, 2013 06:05
Boundary Conditions for External Flow raytracer OpenFOAM Running, Solving & CFD 4 July 14, 2008 13:18
UDS Boundary conditions Max Perrotta FLUENT 0 August 16, 2007 04:59
Outlet boundary conditions for unsteady flow Bjorn B Main CFD Forum 3 January 11, 2006 06:42


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