CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   dimensionedScalar + volScalarField is evaluated elementwisely ? (https://www.cfd-online.com/Forums/openfoam-programming-development/99253-dimensionedscalar-volscalarfield-evaluated-elementwisely.html)

 tianyikillua March 29, 2012 13:53

dimensionedScalar + volScalarField is evaluated elementwisely ?

Hello everyone,

I'd like to know if a dimensionedScalar (ex. T1) + volScalarField (ex. T) is still a volScalarField and the result is obtained elementwisely, that is : result(i)=T1+T(i).

I need also to use a scalar function (ex. pos) determing the positivity of a scalar. If I apply this function to a volScalarField (ex. T), can I still obtain a volScalarField and result(i)=pos(T(i)) ?

I wrote this because I'm now implementing a non-constant diffusivity in the laplacianFoam solver.

In mylaplacianFoam.C, I have
Code:

`DT=(a1+b1*T)*pos(T1-T)+(a2+b2*T)*neg(T1-T)*pos(T2-T)+(a3+b3*T)*neg(T2-T);`
before solving the laplacian equation.

In creatFields.H, I have
Code:

```    volScalarField DT     (         IOobject         (             "DT",             runTime.timeName(),             mesh,             IOobject::NO_READ,             IOobject::AUTO_WRITE         ),         (a1+b1*T)*pos(T1-T)+(a2+b2*T)*neg(T1-T)*pos(T2-T)+(a3+b3*T)*neg(T2-T)     );```
where ai, bi, T1 and T2 are scalars and DT is piecewise affine in [0,T1], [T1,T2] and [T2,+Inf].

Thank you very much for your help !!

 akidess March 30, 2012 03:12

Yes, pos(T - X), where T is a volScalarField and X is a dimensionedScalar will return a volScalarField.

 All times are GMT -4. The time now is 22:01.