CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Can't get data from OpenFoam to external solver using externalCoupled (https://www.cfd-online.com/Forums/openfoam-solving/133966-cant-get-data-openfoam-external-solver-using-externalcoupled.html)

perry April 23, 2014 05:06

Can't get data from OpenFoam to external solver using externalCoupled
 
Hi guys,

and thanks for reading this :-).

I need to couple OpenFoam with an external solver and I am currently trying to do this by means of the "externalCoupledMixedFvPatchField"-boundary as described here:

http://foam.sourceforge.net/docs/cpp/a00682.html

The data is communicated via files, where the external solver should write e.g. the file "data.in" containing <value>, <gradient> and <valueFraction> for each cell face to be read by OpenFoam.
OpenFoam reads in the data, performs a simulation step and writes the file "data.out" containing <magSf>, <value> and <snGrad>.

I've also had a look at the source code here:

https://github.com/OpenFOAM/OpenFOAM...FvPatchField.C

As far as I understand the procedure roughly works as follows (from OpenFoam point of view):

1. write data.out
2. remove lock file, signaling the external solver to take over
3. wait until lock file is re-created by external solver
4. read data.in
5. repeat

I have succeeded in transferring data from the external solver to OpenFoam. Specifically I've tested this with OpenFoam version 2.2.2 and scalarTransportFoam where I set the temperature at an inlet from the external solver.

What I'm still having problems with is getting data from OpenFoam back to the external solver, e.g. temperature at an outlet patch.

I know there are several ways to accomplish this but I would like to use the above mentioned externalCoupled boundary because then I can avoid having to compile any code and have a nice, consistent and flexible interface to all kinds of OpenFoam-models.

For data transfer from the external solver to OpenFoam I'm writing the file data.in to contain e.g. <value> 0 1, which means that it is set to fixedValue (because valueFraction == 1).

For data transfer from OpenFoam to the external solver I write the file data.in to contain e.g. 0 0 0, meaning zero gradient. The problem is that the returned file data.out always contains a value 0 for the outlet-patch. I tried all kinds of combinations and it seems to me that data.out always contains the value that I supply via data.in when in fact I would like to not specify any value in data.in because I'm actually waiting for OpenFoam to give me its value.

I hope this makes sense and sorry for the long story :-)...

Right now, I can't think of anything more to try so if no one knows what I'm doing wrong, I'll try something like using the writeRegisteredObject-function-object instead. Using the externalCoupled-boundary for input and output would be more consistent, though...

Anyway, help will be greatly appreciated, thank you!

Regards,
Perry

jherb April 23, 2014 11:47

I guess you know this
https://github.com/OpenFOAM/OpenFOAM...lCoupledCavity
and it didn't help?

perry April 24, 2014 03:12

Hello jherb,

thanks for your reply.

Yes, I know the externalCoupledCavity-tutorial. It helped me in the beginning to see how to set the value at the boundary from an external source.

What it doesn't show (as far as I understand) is how to get the value at a boundary as calculated by OpenFoam without setting it from an external source first (like an output-signal).

jherb May 20, 2014 08:00

Hello Perry,

did you solve your problem. I looked at the source code and also did not understand, how it should work.

perry May 26, 2014 08:09

Hello jherb,

no I didn't solve the problem, yet. I'm currently implementing the part from external-solver to OpenFoam.

I'll probably try out the writeRegisteredObject-function-object and extracting the data I need from the time directories.

Thanks for having a look at the code.


All times are GMT -4. The time now is 09:46.