CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Where are Field<Type> operators defined (https://www.cfd-online.com/Forums/openfoam-programming-development/65568-where-field-type-operators-defined.html)

agodfrey June 18, 2009 16:01

Where are Field<Type> operators defined
 
Where can I find the code for operator+, operator-, operator*, operator/ for, say, a volScalarField for example? Surely, these are called when building the transport equations.

Programmer's Guide v1.5 (9 July 2008) says "Algebraic operations can be performed between Fields subject to obvious restrictions such as the fields having the same number of elements" (P-29)

I could re-compile Debug and step through, but can someone spare me the trouble? Thanks

ngj June 19, 2009 07:36

Here you go. Doxygen will become your friend after a while.

http://foam.sourceforge.net/doc/Doxy...b6d65dfbddd227

Have a nice weekend,

Niels

agodfrey June 19, 2009 09:55

Thanks for the reply, Niels.

Please let me see if I follow the code correctly by using operator/ as an example

1) Field.C includes "FieldFunctions.C"

2) FieldFunctions.C contains the line
BINARY_OPERATOR(Type, Type, scalar, /, divide)

3) BINARY_OPERATOR is defined in FieldFunctionsM.C as
#define BINARY_OPERATOR(ReturnType, Type1, Type2, Op, OpFunc)

part of which compiles as

template<class Type>
tmp<Field<Type> > operator /
(
const UList<Type>& f1,
const UList<scalar>& f2
)
{
tmp<Field<Type> > tRes(new Field<Type>(f1.size()));
divide(tRes(), f1, f2);
return tRes;
}

4) If that's the case, then where is divide(tRes(), f1, f2); defined? I see a version is ops.H, but I'm not sure if I follow the syntax there.

Thanks


All times are GMT -4. The time now is 09:34.