coupling OpenFOAM with other programs
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.
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:
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.
@finding cell numbers:
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
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.
But it should however not read from disk, I want to specify the field values during run-time. Could you enlighten this?
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!
|All times are GMT -4. The time now is 03:31.|