View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000618 | OpenFOAM | Bug | public | 2012-08-07 13:12 | 2012-08-07 13:53 |
Reporter | Assigned To | henry | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Summary | 0000618: sign function gives incorrect sign of zero | ||||
Description | mathematically, the sign (also called sgn) function should give +1 for values of S greater than zero -1 for values of S less than zero 0 for values equal to zero OpenFOAM sign gives +1 for values of S greater than or equal to zero -1 for values of S less than zero Solutions: 1) correct the sign function for scalars and make sure all references to sign give expected result. 2) or create new function called signum (latin for sign) that will give the expected result | ||||
Steps To Reproduce | using sign(volScalarField) | ||||
Additional Information | A function to return the correct sign of scalar s, might have the structure return (s > -SMALL)-(s < SMALL); this might be faster than the branched version of return s < 0 ? -1 : s > 0 ? 1 : 0; **the reason for such a formulation of sign, could be for level-set methods, where you need to preserve the zero level-set. For classical level-set you solve dG/dt = sign(G)(1-mag(grad(G)) and if sign(G) returns a +1 for zero, then the solution process will alter the zero level-set and "lose" the interface. Alternatively, a smoothed sign function could be defined with the pseudo-code smoothsignum(s) = s / sqrt(pow(s,2)+pow(eps,2)) where transition is sharper for eps approaching 0. | ||||
Tags | No tags attached. | ||||