|
[Sponsors] |
May 26, 2009, 12:30 |
coupling OpenFOAM with other programs
|
#1 |
New Member
Martin Tek
Join Date: May 2009
Posts: 7
Rep Power: 17 |
Hi,
I am Martin and new to OpenFOAM. I want to solve the Laplace-Equation grad(k(x)*grad u(x))=0 with OpenFOAM and interconnect k(x) with data coming from outside. Is there any possibility to read in and write out dynamically on run-time the k(x) values into a VolScalarField (I'd guess) ? And to access maybe the nearest node for a given coordinate? Or at least to iterate over all nodes, get the coordinates and get/set k(x)? Any help is appreciated. Martin |
|
May 28, 2009, 22:02 |
|
#2 |
Senior Member
Henrik Rusche
Join Date: Mar 2009
Location: Wernigerode, Sachsen-Anhalt, Germany
Posts: 281
Rep Power: 18 |
Dear Martin,
the bottom line is that you can do anything because you have the source code. If you have the source code for the other code, then merging the two codes into a single executable is easier & faster than file IO while avoiding syncronisation problems. However, this is major surgery and you need to know what you are doing. Concerning your questions: @reading I would simply create a (temporary) field from an IOobject. Look at any createField.H and place the code inside of the time loop. However, field.read() should work, too. @writing: field.write(); @finding cell numbers: Code:
vector pos; label cellI = mesh.findCell(pos); Info << field[cellI] << endl; Code:
forAll(mesh.C(), cellI) { vector pos; if ( mag(mesh.C()[cellI] - pos) < SMALL) { field[cellI] = newValue; } } Henrik |
|
June 2, 2009, 06:26 |
|
#3 |
New Member
Martin Tek
Join Date: May 2009
Posts: 7
Rep Power: 17 |
Dear Henrik,
thank you very much for you help, this is exactly what I was looking for. I followed your suggestion and created and temporary field during the runtime-loop; unfortunately, OF claims that it cannot read my temporary field volScalarField epsilon ( IOobject ( "epsilon", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE ), mesh ); cannot open file file: /home/dw9203/projects/ofoprj/cavity/0.005/epsilon at line 0. From function regIOobject::readStream(const word&) in file db/regIOobject/regIOobjectRead.C at line 66. FOAM exiting But it should however not read from disk, I want to specify the field values during run-time. Could you enlighten this? |
|
June 3, 2009, 19:13 |
|
#4 |
New Member
Martin Tek
Join Date: May 2009
Posts: 7
Rep Power: 17 |
Thanks, now it works setting values on run-time. A different constructor for volscalarfield made it and I can set now values during run-time. Great!
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Superlinear speedup in OpenFOAM 13 | msrinath80 | OpenFOAM Running, Solving & CFD | 18 | March 3, 2015 06:36 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 19:07 |
Adventure of fisrst openfoam installation on Ubuntu 710 | jussi | OpenFOAM Installation | 0 | April 24, 2008 15:25 |
OpenFOAM Debian packaging current status problems and TODOs | oseen | OpenFOAM Installation | 9 | August 26, 2007 14:50 |
OpenFOAM Training and Workshop Zagreb 2628Jan2006 | hjasak | OpenFOAM | 1 | February 2, 2006 22:07 |