CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Mapping a boundary condition from file (

alberto February 23, 2007 16:16

I'm simulating a non-periodic
I'm simulating a non-periodic channel and I need to impose a velocity at the inlet BC which is read from a file at each time step. Each file contains the whole velocity field on the face from a previous simulation.

How can I do this in OF?


stefanke February 24, 2007 06:46

This is indeed a very interest
This is indeed a very interesting question!

Does anyone know how to do this in a "smart" way?

philippose February 24, 2007 07:21

Hi, Good day! There exis
Good day!

There exists a boundary condition in OpenFOAM called:


This basically reads the values of the patch for each time step from a given data file, complete with interpolation for timesteps not explicitly specified in the data file.

The limitation of this boundary condition is, that it reads in one "uniform fixed Value" and not a field, which is then applied to the entire patch.

For more information on this BC, run a search through the forum for "timeVaryingUniformFixedValue". There was quite a bit of discussion regarding the topic some time back.

You might also want to search for "parabolic inlet velocity profile" in the forum... this might give you pointers on how to modify the code for reading in complete fields from data-files rather than just a uniform fixed value.

Since openFOAM is so vast, it might also be possible that there already exists some form of boundary condition which lets you read in fields from files too :-)!



stefanke February 24, 2007 09:20

I think it is quite useful to
I think it is quite useful to have such a BC in OpenFOAM.

Is there anyone out there who has already implemented such a BC?

alberto February 24, 2007 11:19

Thanks you both. I know ab
Thanks you both.

I know about the timeVaryingUniformFixedValue BC. My main issue is how can I read and map the field extracted from a face in one case, onto my inlet patch.

In other words, how can I be sure the values in a cell of the "source face" are assigned to the right one on the inlet face?


hannes February 25, 2007 07:21

Hello, I have implemented a

I have implemented a boundary condition called "timeVaryingNonuniformFixedValue" which does what you want.
It reads the boundary fields at some time instants from files and interpolates the fields in time to the current time step.

You can get it here:

I think, I will put it into the wiki and describe it there in more detail.

Regards, Hannes

alberto February 25, 2007 13:19

Thanks Hannes! I'll try it
Thanks Hannes!

I'll try it immediately :-)


mattijs February 26, 2007 04:53

If you can afford to wait a li
If you can afford to wait a little bit longer: 1.4 will have a timeVaryingMappedFixedValue which does interpolation in time and space (by triangulating data points).

alberto February 26, 2007 06:23

Thanks Mattijs. I lost it read
Thanks Mattijs. I lost it reading the release notes :-)

Could you please give to me a rough estimate of the release date?


hannes February 26, 2007 11:14

Hello Alberto, I'm sorry fo
Hello Alberto,

I'm sorry for the lack of informative error messages, I haven't found the time for making the code comfortable (And it seems to get superfluous soon, as I read).

There was indeed a little bug in the code: it used a relative path. So the code only works if you start the solver from inside the case directory (I almost always start it that way, so I didn't notice the bug)

And the files with the instanteneous fields should start with the number of list entries that they contain (Just the file format, that the "List"-reader expects)

You can download an example-case here:

and a bug-fixed version of the BC:

Hope it works, Hannes

mattijs February 26, 2007 14:26

Hello Alberto, I hope we ca
Hello Alberto,

I hope we can release next month. Hannes, seems yours does not do any interpolation so could be more useful when replaying previous simulation data. The 1.4 version will do interpolation so is more suited for e.g. measurement data.

You might want to have the field in the path as well so you can have more than one field.

alberto February 26, 2007 16:23

Hello Hannes, thanks a lot fo
Hello Hannes,
thanks a lot for your help.

I've just tried your new code and it works perfectly :-)

With kind regards,

gameoverli December 29, 2007 05:59

Hello Mattijs Janssens: what
Hello Mattijs Janssens:
what I have now is OpenFoam-1.4.1 which contains the timeVaryingMappedFixedValue BC may do what I need. I have a profile file exported from FLUENT and I need use it as inlet boundary condition in OF. since I can generate a time series based on the FLUENT file, I do not need interpolation in time, but I do need interpolation in space. Does timeVaryingMappedFixedValue BC do this trick, and can you provide some kind of tutorials using this BC?

Thanks a lot

mattijs December 29, 2007 09:49

From a search for timeVaryingM
From a search for timeVaryingMappedFixedValue:

nishant_hull April 14, 2008 14:21

Hi Hannes I tried instal
Hi Hannes

I tried installing and recompiling your timeVaryingNonuniformFixedValue patch with my OF-1.4.1 installation. But unfortunately I found some error while recompiling it. Can you tell me, what's going wrong?

The error reported is:
lnInclude/fixedValueFvPatchField.C:41: note: Foam::fixedValueFvPatchField<type>::fixedValueFvPa tchField(const Foam::fvPatch&, const Foam::DimensionedField<type,>&) [with Type = double]
make: *** [Make/linuxGccDPOpt/timeVaryingNonuniformFixedValueFvPatchFields.o] Error 1


leonardo.morita May 25, 2009 11:09


My problem is slightly different: I'd like to use a profile obtained from a previous simulation as a boundary condition, which is constant in time. I simulate a jet in cross-flow, so I'll first develop my turbulent jet profile and then use it in the final system.

I searched here in the forum and I found two options already implemented: timeVaryingMappedFixedValue, discussed above, and directMapped. However, I don't know yet if they are appropriate to my case, the reasons are given bellow.

TimeVaryingMappedFixedValue interpolates given data, which is not necessary for me.

- doing so could bring numerical errors, couldn't it?
- assuming then that these errors are negligible: this BC is made for a transient BC case, but even so could I use it for my stationary BC problem?
- and one last question for this BC: since my results would be mapped using mapFields, a priori I wouldn't have position data. Could I use the sample utility to resolve this problem?

Concerning the other BC, directMapped: this one may be more suitable for me, but I still have some questions about it...

- does it work like the cyclic BC, imposing that the inlet (for example) profile is equal to that one at an arbitrary plane?
- in my case, how should I initializate it? Since the BCs in the previous simulation will be cyclic, is it possible to "trick" mapFields mapping all my boundary and internal fields and then changing their type for the final simulation?
- how does the averaging function work (I don't think I'll use it, but...)?

Anyway, I see that both BCs don't do exactly what I need, so I'd like to ask here if anybody know a more suitable way to map a BC. And it would be very nice too if you could give me hints to answer my questions =)

Thank you.


leonardo.morita May 26, 2009 03:59

After some more research, an update of my questions:

- in the tutorial case, I see that directMapped is used to develop a flow from a uniform internal field, i.e., no mapped solution is applied. In order to save computational time using this BC, is it possible to start with an already developped flow, as I've explained before?
- I've read in the User Guide that mapFields can map different boundary types, but how this works exactly? Should I only mention that the fields are inconsistent and list these patches in the patchMap subdictionary? (I know this question is not related to the subject of this thread, however it's quite simple and linked to my case, so I thought it might be more pratical to post it here anyway...)

Thank you!

All times are GMT -4. The time now is 03:05.