CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

how to get the unit volScalar, surfaceScalar and volVector

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 25, 2021, 13:20
Default how to get the unit volScalar, surfaceScalar and volVector
  #1
New Member
 
behnamCheraghi
Join Date: Feb 2021
Posts: 14
Rep Power: 5
behnamEll is on a distinguished road
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?
behnamEll is offline   Reply With Quote

Old   July 25, 2021, 17:26
Default
  #2
Member
 
MNM
Join Date: Aug 2017
Posts: 67
Rep Power: 8
SHUBHAM9595 is on a distinguished road
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
SHUBHAM9595 is offline   Reply With Quote

Old   July 26, 2021, 00:50
Default
  #3
New Member
 
behnamCheraghi
Join Date: Feb 2021
Posts: 14
Rep Power: 5
behnamEll is on a distinguished road
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.

Last edited by behnamEll; July 26, 2021 at 00:52. Reason: mathematical refinments
behnamEll is offline   Reply With Quote

Old   July 26, 2021, 07:55
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by behnamEll View Post
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)
behnamEll likes this.
olesen is offline   Reply With Quote

Reply

Tags
unit phi, unit surfacescalar, unit volscalar, unit volvector

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 19:28.