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/)
-   -   Import data fields for boundary conditions during run time (https://www.cfd-online.com/Forums/openfoam-solving/133114-import-data-fields-boundary-conditions-during-run-time.html)

aylalisa April 10, 2014 08:49

Import data fields for boundary conditions during run time
 
Dear Foamers,

Is it possible to import data during run time and map it on the inlet patch?
The data could be the result of another case, from measurements or artificially created and saved in text files.

I would like to periodically read in the prepared data fields during run time.

I did not find a possible approach in swak4foam (funkySetFields, groovyBC), please correct me if I am wrong.

Each answer is appreciated!

Aylalisa

chrisb2244 April 10, 2014 20:44

You could code a library function to do that. You'd need to pass the field you wanted to change, probably, so that you didn't change the internal field (you want that to remain as it is, right?)

Then you can set boundary values using something like
Code:

field.boundaryField()[patchNumberForInlet] == setOfNewValues
The difficult bit is I guess formatting the new values in a way that OF likes?
What setup do you have for your text files?
Do you have a list of values, one per patch face? If so, should be pretty doable.
If you have a different number of values, I suppose you'll need to reconstruct a new patch face - maybe the mapFields utility could help you here, but I have no idea how it works and haven't used it.

Best,
Christian

aylalisa April 11, 2014 17:37

Dear Christian,

thanks a lot for your reply!

I have minimal programming skills, so please apologize my questions.

Quote:

You'd need to pass the field you wanted to change, probably, so that you didn't change the internal field (you want that to remain as it is, right?)
Do you mean the field in my OF case, e.g. velocity field U at the inlet (of a channel or pipe geometry) that will get the new values (caculated by a function or measurements) ?

I would prefer to do all the data formatting before transfering it to the library function, maybe with Python because it seems to me to be easier to handle it there.
In Python I could probably produce each kind of format. But in which format does OpenFOAM accept the values? My first idea is a *.xy file with one column (according to the cell ordering of the area I want to provide with the data?

Do you think I destroy to much of the field information if I do some kind of interpolation with the field data to finally match the number of patch faces???

mapFields works good to map Fields from a source case to a target case before simulation starts. I need a mapFields function that runs periodically through the source case volume field (with the mapped measurement data) maybe during the run.

At the moment this is still an idea. Yet I am busy with existing utilites (that don't cooperate:o).

Best regards,
Aylalisa

jherb April 12, 2014 10:24

Have a look at the coupling boundary condition, e.g. https://github.com/OpenFOAM/OpenFOAM...lCoupledCavity


All times are GMT -4. The time now is 02:44.