CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   FixedGradient Boundary Condition (

shrina May 17, 2006 09:21

Hi all, I'm trying to under
Hi all,

I'm trying to understand how evaluate function is implemented in fixedGradientFvPatchField.C, but the following lines are obscure to me:

this->patchInternalField() + gradient_/this->patch().deltaCoeffs()

The function I'm referring to is this one:

// Evaluate the field on the patch
void fixedGradientFvPatchField<type>::evaluate()
if (!this->updated())

this->patchInternalField() + gradient_/this->patch().deltaCoeffs()


Thanks in advance

hjasak May 17, 2006 09:25

Says: The current value on

The current value on the boundary = the value in the cells next to the boundary + (boundary-normal gradient)*(distance form the cell centre to the boundary face).

The this->patch().deltaCoeffs() bit means 1/distance, which is why you have a division instead of multiplication.



shrina May 17, 2006 11:00

Thanks for your ready answer,
Thanks for your ready answer, but what was not clear to me was how the assignment was done, where was the receiver of the operation, since there is not anything on the left of operator "=", apart from Field<type>::, which is the scope resolution operator used to specify which class the operator "=" refers to.
I'have just read the effective implementation of this operator in the file "List.C" and I've seen that there is any type returned, the "returned type" is void, consequently no object has to be put on the left of "=", the operator "=" can be called as a usual function that "returns a void".
Have I understood correctly? I'm a beginner in C++.
Thanks again

hjasak May 17, 2006 11:21

This is pure C++. I can call
This is pure C++. I can call operator= in 2 ways:

class HrvsClass
void operator=(const HrvsClass&);

and then

HrvsClass a;
HrvsClass b;

a = b;

which is the same as


In the code above I would have to write


Additionally, I wish to call operator= from the base class rather than the current class. So, the long (and ugly) notation would say:

Field<type>& f = *this;
f = this->patchInternalField() + gradient_/this->patch().deltaCoeffs();

which is pretty ugly.

Hope this helps,


All times are GMT -4. The time now is 06:47.