Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
openfoam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
openfoam
Commits
a88e67f2
Commit
a88e67f2
authored
5 years ago
by
Mark OLESEN
Browse files
Options
Downloads
Patches
Plain Diff
BUG: potential divide-by-zero in x3d surface output (
#1212
)
- eg, for a uniform field and auto range.
parent
b4229841
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/surfMesh/writers/x3d/x3dSurfaceWriter.C
+32
-8
32 additions, 8 deletions
src/surfMesh/writers/x3d/x3dSurfaceWriter.C
with
32 additions
and
8 deletions
src/surfMesh/writers/x3d/x3dSurfaceWriter.C
+
32
−
8
View file @
a88e67f2
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\ / A nd | www.openfoam.com
\\/ M anipulation |
\\/ M anipulation |
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019
-2020
OpenCFD Ltd.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
License
License
This file is part of OpenFOAM.
This file is part of OpenFOAM.
...
@@ -50,13 +50,30 @@ namespace surfaceWriters
...
@@ -50,13 +50,30 @@ namespace surfaceWriters
namespace
Foam
namespace
Foam
{
{
//- A (0-1) range for colouring
inline
scalar
srange01
(
const
scalarMinMax
&
range
,
scalar
x
)
{
if
(
x
>=
range
.
max
())
{
return
1
;
}
x
-=
range
.
min
();
if
(
x
<
VSMALL
)
{
return
0
;
}
return
x
/
(
range
.
max
()
-
range
.
min
());
}
//- A (0-1) range for colouring
//- A (0-1) range for colouring
template
<
class
Type
>
template
<
class
Type
>
static
inline
scalar
rangex
(
const
scalarMinMax
&
range
,
const
Type
&
val
)
static
inline
scalar
rangex
(
const
scalarMinMax
&
range
,
const
Type
&
val
)
{
{
scalar
x
=
Foam
::
mag
(
val
);
return
srange01
(
range
,
Foam
::
mag
(
val
));
return
(
x
-
range
.
min
())
/
(
range
.
max
()
-
range
.
min
());
}
}
...
@@ -64,8 +81,7 @@ static inline scalar rangex(const scalarMinMax& range, const Type& val)
...
@@ -64,8 +81,7 @@ static inline scalar rangex(const scalarMinMax& range, const Type& val)
template
<>
template
<>
inline
scalar
rangex
(
const
scalarMinMax
&
range
,
const
scalar
&
val
)
inline
scalar
rangex
(
const
scalarMinMax
&
range
,
const
scalar
&
val
)
{
{
scalar
x
=
val
;
return
srange01
(
range
,
val
);
return
(
x
-
range
.
min
())
/
(
range
.
max
()
-
range
.
min
());
}
}
...
@@ -73,8 +89,7 @@ inline scalar rangex(const scalarMinMax& range, const scalar& val)
...
@@ -73,8 +89,7 @@ inline scalar rangex(const scalarMinMax& range, const scalar& val)
template
<>
template
<>
inline
scalar
rangex
(
const
scalarMinMax
&
range
,
const
label
&
val
)
inline
scalar
rangex
(
const
scalarMinMax
&
range
,
const
label
&
val
)
{
{
scalar
x
=
val
;
return
srange01
(
range
,
val
);
return
(
x
-
range
.
min
())
/
(
range
.
max
()
-
range
.
min
());
}
}
...
@@ -266,8 +281,17 @@ Foam::fileName Foam::surfaceWriters::x3dWriter::writeTemplate
...
@@ -266,8 +281,17 @@ Foam::fileName Foam::surfaceWriters::x3dWriter::writeTemplate
if
(
!
range
.
valid
())
if
(
!
range
.
valid
())
{
{
range
=
minMaxMag
(
values
);
range
=
minMaxMag
(
values
);
if
(
equal
(
range
.
mag
(),
0
))
{
range
.
add
(
range
.
centre
());
}
}
}
// Slight rounding
range
.
min
()
-=
VSMALL
;
range
.
max
()
+=
VSMALL
;
if
(
!
isDir
(
outputFile
.
path
()))
if
(
!
isDir
(
outputFile
.
path
()))
{
{
mkDir
(
outputFile
.
path
());
mkDir
(
outputFile
.
path
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment