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/)
-   -   how to get the unit volScalar, surfaceScalar and volVector (https://www.cfd-online.com/Forums/openfoam-programming-development/237582-how-get-unit-volscalar-surfacescalar-volvector.html)

behnamEll July 25, 2021 13:20

how to get the unit volScalar, surfaceScalar and volVector
 
Hello every one,
I need to make a "unit phi" to get the div(phi,U)/mag(phi).
but in this case, the 1/mag(phi) may lead to a core dumped (floating point exception) error.

in fact, i try to make a surfaceScalar/volScalar/volVector such that:
-------------------------------------------------------

if ( mag(surfaceScalar) == 0 )
surfaceScalar = 0;
else
surfaceScalar/mag(surfaceScalar);
-------------------------------------------------------



can anyone help me?

SHUBHAM9595 July 25, 2021 17:26

I'm not sure what you want to achieve with "unit phi".

But to avoid FPE you can just simply add the machine epsilon in the denominator. Something like
Code:

surfaceScalarField your_Desired_var = 1/(mag(phi) + VSMALL);
where VSMALL is float having magnitude \cong 1.93e-34

behnamEll July 26, 2021 00:50

in fact i am looking for a property on the cell face using *upwind* schemes, but without the phi magnitude.

for example \nabla.(mdot U) without the mdot magnitude.

by adding an small values, again, there is a possibility that the values ​​will be zero. because there are negative and positive values ​​of it.

olesen July 26, 2021 07:55

Quote:

Originally Posted by behnamEll (Post 808919)
Hello every one,
I need to make a "unit phi" to get the div(phi,U)/mag(phi).
but in this case, the 1/mag(phi) may lead to a core dumped (floating point exception) error.

in fact, i try to make a surfaceScalar/volScalar/volVector such that:
-------------------------------------------------------

if ( mag(surfaceScalar) == 0 )
surfaceScalar = 0;
else
surfaceScalar/mag(surfaceScalar);
-------------------------------------------------------

can anyone help me?


stabilise() ? Eg, x / stabilise(y, SMALL)


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