CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   FixedGradient Boundary Condition (http://www.cfd-online.com/Forums/openfoam-solving/60209-fixedgradient-boundary-condition.html)

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:

Field<type>::operator=
(
this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
);

The function I'm referring to is this one:

// Evaluate the field on the patch
template<class>
void fixedGradientFvPatchField<type>::evaluate()
{
if (!this->updated())
{
this->updateCoeffs();
}

Field<type>::operator=
(
this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
);

fvPatchField<type>::evaluate();
}

Thanks in advance

hjasak May 17, 2006 09:25

Says: The current value on
 
Says:

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.

Better?

Hrv

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

a.operator=(b);

In the code above I would have to write

this->operator=(b)

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,

Hrv


All times are GMT -4. The time now is 15:20.