CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   Boundary Condition and U-field (

dl6tud August 23, 2012 08:37

Boundary Condition and U-field
From a boundary condition I would like to access for example the velocity field. I try like that:


fvPatchField<vector>& U = this->patch().lookupPatchField<volVectorField, vector>("U");
That gives me the error

heatFlowFvPatchField.C:232:71: Fehler: expected primary-expression before , token
heatFlowFvPatchField.C:232:79: Fehler: expected primary-expression before > token
And I do not know why. The code comes from an older version of OF. I thought some include file may be missing, but I found nothing. Can anyone help me?

jhoepken August 23, 2012 09:29

I usually use

const fvPatchField<vector>& foo = patch().lookupPatchField<volVectorField, vector>("U");
So the difference is only in the constness of foo, but your compiler error does not complain about the constness but about some incorrect expressions. Have you copied the code from somewhere (internet,...)? Maybe the encoding is screwed up a little bit.


dl6tud August 23, 2012 09:42

Thanks for your answer! I use a modified 'fixedValue' BC added to a solver. I tried 100 different versions for accessing U, but nothing worked. It's always the same error -> no idea why :-(

A good explanation how to access fixed dict entries:

jhoepken August 24, 2012 02:20

What exactly do you mean by "added to a solver"? Did you compile the boundary condition into the executable of a solver?

dl6tud August 24, 2012 02:28

Yes, that's what I did! Linking a BC directly to a solver is possible by compiling BC and Solver together (Make/files):



EXE = $(FOAM_USER_APPBIN)/buoyantBoussinesqQFoam
First, I based my new BC on fixedValueFvPatchField, that did newer work. It worked with wallHeatTransferFvPatchScalarField, I have no idea why.

jhoepken August 24, 2012 02:57

I know how this should work in principle, but I would very much like to avoid it. Since one might want to use the BC with a different solver as well. But I guess that this is a matter of choice ;).

It doesn't compile at the moment, right? Have you checked your line for incorrect chars (resulting from copying code from somewhere else, e.g. the internet)?

dl6tud August 26, 2012 17:37

Yes, I checked for incorrect characters. And I tried different ways of access (db.lookup; this->patch.lookup; etc.).

First, I thought using fixedValue as basis because I know very well how it works. But as I want to use the BC only for Temperature I thought later that it might be better to use some scalar BC (fixedValue can be scalar or vector). So I took wallHeatTransfer and modified that. I had to investigate again to understand how it works, but here I did no face any problems.

--> The problem it not solved, but I found a working solution. Thank you!!! :)

jhoepken August 27, 2012 03:55

I see. Do you mind sharing your workaround? Maybe others run into the same issue as well.

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