CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Update boundary conditions calculated by an external program (http://www.cfd-online.com/Forums/openfoam/71751-update-boundary-conditions-calculated-external-program.html)

CedricVH January 13, 2010 17:16

Update boundary conditions calculated by an external program
 
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?

CedricVH January 15, 2010 06:26

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 January 15, 2010 12:55

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?


All times are GMT -4. The time now is 11:57.