|
[Sponsors] |
How to divide a vectorfield by the magnitude if the vector can be zero |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 5, 2021, 18:24 |
How to divide a vectorfield by the magnitude if the vector can be zero
|
#1 |
Member
Torsten Schenkel
Join Date: Jan 2014
Posts: 69
Rep Power: 12 |
Hello,
I am trying to do some postprocessing with normalised vectors. The vector can be zero, so the simple form: Un = U/mag(U) will break with segfault. Un = U/(mag(U)+1e64) doesn't work, because the dimensions won't match (1e-64) has dimension [0 0 0 ... 0] Is there a trick to achieve that? U is not the velocity, so a specific normalised velocity function wouldn't help. Would need to take any dimensionedVolVectorField. |
|
October 6, 2021, 08:24 |
|
#2 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15 |
You should decide by a small dimensionized scalar. You can find an example here how to convert to dimensionless scalar in openfoam
|
|
October 6, 2021, 09:50 |
|
#3 | |
Member
Torsten Schenkel
Join Date: Jan 2014
Posts: 69
Rep Power: 12 |
Quote:
Thanks, that's very helpful. I was starting to play around with .value() and .dimensions(). Good to know that that is the right path. |
||
October 9, 2021, 06:09 |
|
#4 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,685
Rep Power: 40 |
Need to check if the normalised(..) function works on GeometricFields or only on primitive fields, but could start looking there. It haves a check for ROOTVSMALL to protect the division.
|
|
October 9, 2021, 10:16 |
|
#5 |
Member
Torsten Schenkel
Join Date: Jan 2014
Posts: 69
Rep Power: 12 |
||
October 9, 2021, 10:19 |
SOLVED: create a dimensionedScalar for the very small value epsilon
|
#6 |
Member
Torsten Schenkel
Join Date: Jan 2014
Posts: 69
Rep Power: 12 |
Code:
dimensionedScalar epsWSS = dimensionedScalar("epsWSS",WSS.dimensions(), 1e-64); creates a very small scalar with dimension of the vector field, which can then be used as: Code:
normalisedWSS = WSS / (mag(WSS)+epsWSS); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Velocity Magnitude not showing results | musa19 | Tecplot | 1 | November 18, 2020 23:49 |
HronTurekFsi3 foam-extend3.1 | Maimouna | OpenFOAM Running, Solving & CFD | 112 | April 20, 2019 21:11 |
Magnitude of a tensor | mmkr825 | OpenFOAM Programming & Development | 8 | December 12, 2018 13:49 |
'cell relative: velocity magnitude' vs 'velocity magnitude' | alpharays | Main CFD Forum | 2 | June 18, 2015 07:24 |
Stresseq vs stress magnitude | watashiwa | OpenFOAM | 1 | October 14, 2010 12:02 |