Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
5d2ad922
Commit
5d2ad922
authored
Jun 20, 2018
by
Mark OLESEN
Browse files
STYLE: separate areaNormal/unitNormal method for primitives (issue
#885
)
parent
a410f52e
Changes
16
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/meshShapes/face/face.C
View file @
5d2ad922
...
...
@@ -81,7 +81,7 @@ Foam::label Foam::face::mostConcaveAngle
scalar
&
maxAngle
)
const
{
vector
n
(
n
ormal
(
points
));
vector
n
(
areaN
ormal
(
points
));
label
index
=
0
;
maxAngle
=
-
GREAT
;
...
...
@@ -542,17 +542,16 @@ Foam::point Foam::face::centre(const UList<point>& points) const
}
Foam
::
vector
Foam
::
face
::
n
ormal
(
const
UList
<
point
>&
p
)
const
Foam
::
vector
Foam
::
face
::
areaN
ormal
(
const
UList
<
point
>&
p
)
const
{
const
label
nPoints
=
size
();
// Calculate the normal by summing the face triangle normals.
// Calculate the
area
normal by summing the face triangle
area
normals.
// Changed to deal with small concavity by using a central decomposition
//
// If the face is a triangle, do a direct calculation to avoid round-off
// error-related problems
//
if
(
nPoints
==
3
)
{
return
triPointRef
...
...
@@ -560,7 +559,7 @@ Foam::vector Foam::face::normal(const UList<point>& p) const
p
[
operator
[](
0
)],
p
[
operator
[](
1
)],
p
[
operator
[](
2
)]
).
n
ormal
();
).
areaN
ormal
();
}
label
pI
;
...
...
@@ -594,7 +593,7 @@ Foam::vector Foam::face::normal(const UList<point>& p) const
p
[
operator
[](
pI
)],
nextPoint
,
centrePoint
).
n
ormal
();
).
areaN
ormal
();
}
return
n
;
...
...
src/OpenFOAM/meshes/meshShapes/face/face.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -39,7 +39,6 @@ SourceFiles
faceTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef face_H
#define face_H
...
...
@@ -194,12 +193,22 @@ public:
const
Field
<
Type
>&
fld
)
const
;
//- The area normal - with magnitude equal to area of face
vector
areaNormal
(
const
UList
<
point
>&
p
)
const
;
//- The unit normal
inline
vector
unitNormal
(
const
UList
<
point
>&
p
)
const
;
//- Legacy name for areaNormal.
// \deprecated Deprecated for new use (JUN-2018)
inline
vector
normal
(
const
UList
<
point
>&
p
)
const
{
return
areaNormal
(
p
);
// Legacy definition
}
//- Magnitude of face area
inline
scalar
mag
(
const
UList
<
point
>&
p
)
const
;
//- Vector normal; magnitude is equal to area of face
vector
normal
(
const
UList
<
point
>&
p
)
const
;
//- Return face with reverse direction
// The starting points of the original and reverse face are identical.
face
reverseFace
()
const
;
...
...
src/OpenFOAM/meshes/meshShapes/face/faceContactSphere.C
View file @
5d2ad922
...
...
@@ -37,10 +37,8 @@ Foam::scalar Foam::face::contactSphereDiameter
const
UList
<
point
>&
meshPoints
)
const
{
scalar
magN
=
Foam
::
mag
(
n
);
vector
n1
=
n
/
(
magN
+
SMALL
);
vector
n2
=
normal
(
meshPoints
);
vector
n1
=
n
/
(
Foam
::
mag
(
n
)
+
SMALL
);
vector
n2
=
areaNormal
(
meshPoints
);
n2
/=
Foam
::
mag
(
n2
)
+
SMALL
;
...
...
src/OpenFOAM/meshes/meshShapes/face/faceI.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -105,9 +105,17 @@ inline Foam::pointField Foam::face::points
}
inline
Foam
::
vector
Foam
::
face
::
unitNormal
(
const
UList
<
point
>&
p
)
const
{
const
vector
n
(
areaNormal
(
p
));
const
scalar
s
(
Foam
::
mag
(
n
));
return
s
<
ROOTVSMALL
?
Zero
:
n
/
s
;
}
inline
Foam
::
scalar
Foam
::
face
::
mag
(
const
UList
<
point
>&
p
)
const
{
return
::
Foam
::
mag
(
n
ormal
(
p
));
return
::
Foam
::
mag
(
areaN
ormal
(
p
));
}
...
...
src/OpenFOAM/meshes/meshShapes/triFace/triFace.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -124,12 +124,22 @@ public:
template
<
class
Type
>
Type
average
(
const
UList
<
point
>&
unused
,
const
Field
<
Type
>&
fld
)
const
;
//- The area normal - with magnitude equal to area of face
inline
vector
areaNormal
(
const
UList
<
point
>&
points
)
const
;
//- The unit normal
inline
vector
unitNormal
(
const
UList
<
point
>&
points
)
const
;
//- Legacy name for areaNormal.
// \deprecated Deprecated for new use (JUN-2018)
inline
vector
normal
(
const
UList
<
point
>&
points
)
const
{
return
areaNormal
(
points
);
// Legacy definition
}
//- Magnitude of face area
inline
scalar
mag
(
const
UList
<
point
>&
points
)
const
;
//- Vector normal; magnitude is equal to area of face
inline
vector
normal
(
const
UList
<
point
>&
points
)
const
;
//- Number of triangles after splitting
inline
label
nTriangles
()
const
;
...
...
src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017
-2018
OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -171,15 +171,9 @@ inline Foam::point Foam::triFace::centre(const UList<point>& points) const
}
inline
Foam
::
scalar
Foam
::
triFace
::
mag
(
const
UList
<
point
>&
points
)
const
{
return
::
Foam
::
mag
(
normal
(
points
));
}
// could also delegate to triPointRef(...).normal()
inline
Foam
::
vector
Foam
::
triFace
::
normal
(
const
UList
<
point
>&
points
)
const
inline
Foam
::
vector
Foam
::
triFace
::
areaNormal
(
const
UList
<
point
>&
points
)
const
{
// As per triPointRef(...).areaNormal()
return
0
.
5
*
(
(
points
[
operator
[](
1
)]
-
points
[
operator
[](
0
)])
...
...
@@ -188,6 +182,20 @@ inline Foam::vector Foam::triFace::normal(const UList<point>& points) const
}
inline
Foam
::
vector
Foam
::
triFace
::
unitNormal
(
const
UList
<
point
>&
points
)
const
{
const
vector
n
(
areaNormal
(
points
));
const
scalar
s
(
Foam
::
mag
(
n
));
return
s
<
ROOTVSMALL
?
Zero
:
n
/
s
;
}
inline
Foam
::
scalar
Foam
::
triFace
::
mag
(
const
UList
<
point
>&
points
)
const
{
return
::
Foam
::
mag
(
areaNormal
(
points
));
}
inline
Foam
::
label
Foam
::
triFace
::
nTriangles
()
const
{
return
1
;
...
...
src/OpenFOAM/meshes/primitiveShapes/cut/cut.H
View file @
5d2ad922
...
...
@@ -172,7 +172,7 @@ public:
//- Operate on a triangle
result
operator
()(
const
FixedList
<
point
,
3
>&
p
)
const
{
return
result
(
triPointRef
(
p
[
0
],
p
[
1
],
p
[
2
]).
n
ormal
());
return
result
(
triPointRef
(
p
[
0
],
p
[
1
],
p
[
2
]).
areaN
ormal
());
}
};
...
...
src/OpenFOAM/meshes/primitiveShapes/cut/cutTemplates.C
View file @
5d2ad922
...
...
@@ -106,8 +106,9 @@ typename Foam::cut::opAddResult<AboveOp, BelowOp>::type Foam::triCut
{
// Set the level set to the signed distance from the plane
FixedList
<
scalar
,
3
>
level
;
for
(
label
i
=
0
;
i
<
3
;
++
i
)
for
(
label
i
=
0
;
i
<
3
;
++
i
)
{
// uses unit-normal
level
[
i
]
=
(
tri
[
i
]
-
p
.
refPoint
())
&
p
.
normal
();
}
...
...
@@ -251,8 +252,9 @@ typename Foam::cut::opAddResult<AboveOp, BelowOp>::type Foam::tetCut
{
// Set the level set to the signed distance from the plane
FixedList
<
scalar
,
4
>
level
;
for
(
label
i
=
0
;
i
<
4
;
++
i
)
for
(
label
i
=
0
;
i
<
4
;
++
i
)
{
// uses unit-normal
level
[
i
]
=
(
tet
[
i
]
-
p
.
refPoint
())
&
p
.
normal
();
}
...
...
src/OpenFOAM/meshes/primitiveShapes/plane/plane.H
View file @
5d2ad922
...
...
@@ -195,7 +195,7 @@ public:
// Member Functions
//- Return plane normal
//- Return
the
plane
unit
normal
const
vector
&
normal
()
const
;
//- Return plane base point
...
...
src/OpenFOAM/meshes/primitiveShapes/pyramid/pyramidI.H
View file @
5d2ad922
...
...
@@ -89,7 +89,7 @@ inline Foam::scalar Foam::pyramid<Point, PointRef, polygonRef>::mag
const
UList
<
point
>&
points
)
const
{
return
(
1.0
/
3.0
)
*
(
base_
.
n
ormal
(
points
)
&
(
height
(
points
)));
return
(
1.0
/
3.0
)
*
(
base_
.
areaN
ormal
(
points
)
&
(
height
(
points
)));
}
...
...
src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -54,13 +54,12 @@ SourceFiles
namespace
Foam
{
// Forward declarations
class
Istream
;
class
Ostream
;
class
tetPoints
;
class
plane
;
// Forward declaration of friend functions and operators
template
<
class
Point
,
class
PointRef
>
class
tetrahedron
;
template
<
class
Point
,
class
PointRef
>
...
...
@@ -210,13 +209,16 @@ public:
// Properties
//-
Return face normal
//-
Face area normal for side a
inline
vector
Sa
()
const
;
//- Face area normal for side b
inline
vector
Sb
()
const
;
//- Face area normal for side c
inline
vector
Sc
()
const
;
//- Face area normal for side d
inline
vector
Sd
()
const
;
//- Return centre (centroid)
...
...
src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -133,28 +133,28 @@ inline Foam::triPointRef Foam::tetrahedron<Point, PointRef>::tri
template
<
class
Point
,
class
PointRef
>
inline
Foam
::
vector
Foam
::
tetrahedron
<
Point
,
PointRef
>::
Sa
()
const
{
return
triangle
<
Point
,
PointRef
>
(
b_
,
c_
,
d_
).
n
ormal
();
return
triangle
<
Point
,
PointRef
>
(
b_
,
c_
,
d_
).
areaN
ormal
();
}
template
<
class
Point
,
class
PointRef
>
inline
Foam
::
vector
Foam
::
tetrahedron
<
Point
,
PointRef
>::
Sb
()
const
{
return
triangle
<
Point
,
PointRef
>
(
a_
,
d_
,
c_
).
n
ormal
();
return
triangle
<
Point
,
PointRef
>
(
a_
,
d_
,
c_
).
areaN
ormal
();
}
template
<
class
Point
,
class
PointRef
>
inline
Foam
::
vector
Foam
::
tetrahedron
<
Point
,
PointRef
>::
Sc
()
const
{
return
triangle
<
Point
,
PointRef
>
(
a_
,
b_
,
d_
).
n
ormal
();
return
triangle
<
Point
,
PointRef
>
(
a_
,
b_
,
d_
).
areaN
ormal
();
}
template
<
class
Point
,
class
PointRef
>
inline
Foam
::
vector
Foam
::
tetrahedron
<
Point
,
PointRef
>::
Sd
()
const
{
return
triangle
<
Point
,
PointRef
>
(
a_
,
c_
,
b_
).
n
ormal
();
return
triangle
<
Point
,
PointRef
>
(
a_
,
c_
,
b_
).
areaN
ormal
();
}
...
...
@@ -415,7 +415,7 @@ bool Foam::tetrahedron<Point, PointRef>::inside(const point& pt) const
// "definitively" shown otherwise by obtaining a positive dot
// product greater than a tolerance of SMALL.
// The tet is defined: tet(Cc, tetBasePt, pA, pB) where the normal
// The tet is defined: tet(Cc, tetBasePt, pA, pB) where the
area
normal
// vectors and base points for the half-space planes are:
// area[0] = Sa();
// area[1] = Sb();
...
...
@@ -575,10 +575,11 @@ inline void Foam::tetrahedron<Point, PointRef>::tetSliceWithPlane
label
nPos
=
0
;
forAll
(
tet
,
i
)
{
// with plane unit-normal
d
[
i
]
=
((
tet
[
i
]
-
pl
.
refPoint
())
&
pl
.
normal
());
if
(
d
[
i
]
>
0
)
{
nPos
++
;
++
nPos
;
}
}
...
...
src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -206,12 +206,22 @@ public:
//- Return centre (centroid)
inline
Point
centre
()
const
;
//- The area normal - with magnitude equal to area of triangle
inline
vector
areaNormal
()
const
;
//- Return unit normal
inline
vector
unitNormal
()
const
;
//- Legacy name for areaNormal.
// \deprecated Deprecated for new use (JUN-2018)
inline
vector
normal
()
const
{
return
areaNormal
();
}
//- Return scalar magnitude
inline
scalar
mag
()
const
;
//- Return vector normal
inline
vector
normal
()
const
;
//- Return circum-centre
inline
Point
circumCentre
()
const
;
...
...
src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H
View file @
5d2ad922
...
...
@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation |
Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
...
...
@@ -106,16 +106,25 @@ inline Point Foam::triangle<Point, PointRef>::centre() const
template
<
class
Point
,
class
PointRef
>
inline
Foam
::
scala
r
Foam
::
triangle
<
Point
,
PointRef
>::
ma
g
()
const
inline
Foam
::
vecto
r
Foam
::
triangle
<
Point
,
PointRef
>::
areaNor
ma
l
()
const
{
return
Foam
::
mag
(
normal
(
));
return
0.5
*
((
b_
-
a_
)
^
(
c_
-
a_
));
}
template
<
class
Point
,
class
PointRef
>
inline
Foam
::
vector
Foam
::
triangle
<
Point
,
PointRef
>::
n
ormal
()
const
inline
Foam
::
vector
Foam
::
triangle
<
Point
,
PointRef
>::
unitN
ormal
()
const
{
return
0.5
*
((
b_
-
a_
)
^
(
c_
-
a_
));
const
vector
n
(
areaNormal
());
const
scalar
s
(
Foam
::
mag
(
n
));
return
s
<
ROOTVSMALL
?
Zero
:
n
/
s
;
}
template
<
class
Point
,
class
PointRef
>
inline
Foam
::
scalar
Foam
::
triangle
<
Point
,
PointRef
>::
mag
()
const
{
return
::
Foam
::
mag
(
areaNormal
());
}
...
...
@@ -392,7 +401,7 @@ inline Foam::pointHit Foam::triangle<Point, PointRef>::ray
||
(
alg
==
intersection
::
HALF_RAY
&&
dist
>
-
planarPointTol
)
||
(
alg
==
intersection
::
VISIBLE
&&
((
q1
&
n
ormal
())
<
-
VSMALL
)
&&
((
q1
&
areaN
ormal
())
<
-
VSMALL
)
);
if
(
hit
&&
eligible
)
...
...
src/lagrangian/basic/particle/particle.H
View file @
5d2ad922
...
...
@@ -526,11 +526,6 @@ public:
// current tet.
inline
vector
normal
()
const
;
//- Return the normal of the tri on tetFacei_ for the
// current tet at the start of the timestep, i.e. based
// on oldPoints
inline
vector
oldNormal
()
const
;
//- Is the particle on a face?
inline
bool
onFace
()
const
;
...
...
src/lagrangian/basic/particle/particleI.H
View file @
5d2ad922
...
...
@@ -280,12 +280,6 @@ inline Foam::vector Foam::particle::normal() const
}
inline
Foam
::
vector
Foam
::
particle
::
oldNormal
()
const
{
return
currentTetIndices
().
oldFaceTri
(
mesh_
).
normal
();
}
inline
bool
Foam
::
particle
::
onFace
()
const
{
return
facei_
>=
0
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment