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
2be17edc
Commit
2be17edc
authored
Aug 17, 2017
by
Andrew Heather
Browse files
ENH: AMIInterpolation - added base for caching of triangulation
parent
80ffdfb1
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.C
View file @
2be17edc
...
...
@@ -57,7 +57,7 @@ void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::calcAddressing
boolList
mapFlag
(
nFacesRemaining
,
true
);
// reset starting seed
label
startSeed
I
=
0
;
label
startSeed
i
=
0
;
DynamicList
<
label
>
nonOverlapFaces
;
do
...
...
@@ -91,7 +91,7 @@ void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::calcAddressing
{
setNextFaces
(
startSeed
I
,
startSeed
i
,
srcFacei
,
tgtFacei
,
mapFlag
,
...
...
@@ -179,7 +179,7 @@ bool Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::processSourceFace
template
<
class
SourcePatch
,
class
TargetPatch
>
void
Foam
::
faceAreaWeightAMI
<
SourcePatch
,
TargetPatch
>::
setNextFaces
(
label
&
startSeed
I
,
label
&
startSeed
i
,
label
&
srcFacei
,
label
&
tgtFacei
,
const
boolList
&
mapFlag
,
...
...
@@ -195,15 +195,12 @@ void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::setNextFaces
// set possible seeds for later use
bool
valuesSet
=
false
;
for
All
(
srcNbrFaces
,
i
)
for
(
label
faceS
:
srcNbrFaces
)
{
label
faceS
=
srcNbrFaces
[
i
];
if
(
mapFlag
[
faceS
]
&&
seedFaces
[
faceS
]
==
-
1
)
{
for
All
(
visitedFaces
,
j
)
for
(
label
faceT
:
visitedFaces
)
{
label
faceT
=
visitedFaces
[
j
];
scalar
area
=
interArea
(
faceS
,
faceT
);
scalar
areaTotal
=
this
->
srcMagSf_
[
srcFacei
];
...
...
@@ -234,13 +231,13 @@ void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::setNextFaces
{
// try to use existing seed
bool
foundNextSeed
=
false
;
for
(
label
facei
=
startSeed
I
;
facei
<
mapFlag
.
size
();
facei
++
)
for
(
label
facei
=
startSeed
i
;
facei
<
mapFlag
.
size
();
facei
++
)
{
if
(
mapFlag
[
facei
])
{
if
(
!
foundNextSeed
)
{
startSeed
I
=
facei
;
startSeed
i
=
facei
;
foundNextSeed
=
true
;
}
...
...
@@ -262,13 +259,13 @@ void Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::setNextFaces
}
foundNextSeed
=
false
;
for
(
label
facei
=
startSeed
I
;
facei
<
mapFlag
.
size
();
facei
++
)
for
(
label
facei
=
startSeed
i
;
facei
<
mapFlag
.
size
();
facei
++
)
{
if
(
mapFlag
[
facei
])
{
if
(
!
foundNextSeed
)
{
startSeed
I
=
facei
+
1
;
startSeed
i
=
facei
+
1
;
foundNextSeed
=
true
;
}
...
...
@@ -316,7 +313,8 @@ Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea
}
// create intersection object
faceAreaIntersect
inter
(
srcPoints
,
tgtPoints
,
this
->
reverseTarget_
);
bool
cache
=
true
;
faceAreaIntersect
inter
(
srcPoints
,
tgtPoints
,
this
->
reverseTarget_
,
cache
);
// crude resultant norm
vector
n
(
-
this
->
srcPatch_
.
faceNormals
()[
srcFacei
]);
...
...
@@ -333,6 +331,8 @@ Foam::scalar Foam::faceAreaWeightAMI<SourcePatch, TargetPatch>::interArea
if
(
magN
>
ROOTVSMALL
)
{
area
=
inter
.
calc
(
src
,
tgt
,
n
/
magN
,
this
->
triMode_
);
DebugVar
(
inter
.
triangles
());
DebugVar
(
inter
.
triangles
().
size
());
}
else
{
...
...
src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/faceAreaWeightAMI/faceAreaWeightAMI.H
View file @
2be17edc
...
...
@@ -107,7 +107,7 @@ protected:
//- Set the source and target seed faces
virtual
void
setNextFaces
(
label
&
startSeed
I
,
label
&
startSeed
i
,
label
&
srcFacei
,
label
&
tgtFacei
,
const
boolList
&
mapFlag
,
...
...
src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/partialFaceAreaWeightAMI/partialFaceAreaWeightAMI.C
View file @
2be17edc
...
...
@@ -30,7 +30,7 @@ License
template
<
class
SourcePatch
,
class
TargetPatch
>
void
Foam
::
partialFaceAreaWeightAMI
<
SourcePatch
,
TargetPatch
>::
setNextFaces
(
label
&
startSeed
I
,
label
&
startSeed
i
,
label
&
srcFacei
,
label
&
tgtFacei
,
const
boolList
&
mapFlag
,
...
...
@@ -41,7 +41,7 @@ void Foam::partialFaceAreaWeightAMI<SourcePatch, TargetPatch>::setNextFaces
{
faceAreaWeightAMI
<
SourcePatch
,
TargetPatch
>::
setNextFaces
(
startSeed
I
,
startSeed
i
,
srcFacei
,
tgtFacei
,
mapFlag
,
...
...
src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/partialFaceAreaWeightAMI/partialFaceAreaWeightAMI.H
View file @
2be17edc
...
...
@@ -67,7 +67,7 @@ private:
//- Set the source and target seed faces
virtual
void
setNextFaces
(
label
&
startSeed
I
,
label
&
startSeed
i
,
label
&
srcFacei
,
label
&
tgtFacei
,
const
boolList
&
mapFlag
,
...
...
src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.C
View file @
2be17edc
...
...
@@ -231,14 +231,14 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
FixedList
<
triPoints
,
10
>
workTris2
;
label
nWorkTris2
=
0
;
//
c
ut source triangle with all inward
s
pointing faces of target triangle
//
C
ut source triangle with all inward pointing faces of target triangle
// - triangles in workTris1 are inside target triangle
scalar
t
=
sqrt
(
triArea
(
src
));
const
scalar
t
=
sqrt
(
triArea
(
src
));
//
e
dge 0
//
E
dge 0
{
//
c
ut triangle src with plane and put resulting sub-triangles in
//
C
ut triangle src with plane and put resulting sub-triangles in
// workTris1 list
scalar
s
=
mag
(
tgt
[
1
]
-
tgt
[
0
]);
...
...
@@ -251,9 +251,9 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
return
0
.
0
;
}
//
e
dge1
//
E
dge
1
{
//
c
ut workTris1 with plane and put resulting sub-triangles in
//
C
ut workTris1 with plane and put resulting sub-triangles in
// workTris2 list (re-use tris storage)
scalar
s
=
mag
(
tgt
[
2
]
-
tgt
[
1
]);
...
...
@@ -272,9 +272,9 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
}
}
//
e
dge2
//
E
dge
2
{
//
c
ut workTris2 with plane and put resulting sub-triangles in
//
C
ut workTris2 with plane and put resulting sub-triangles in
// workTris1 list (re-use workTris1 storage)
scalar
s
=
mag
(
tgt
[
2
]
-
tgt
[
0
]);
...
...
@@ -293,11 +293,16 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
}
else
{
//
c
alculate area of sub-triangles
//
C
alculate area of sub-triangles
scalar
area
=
0
.
0
;
for
(
label
i
=
0
;
i
<
nWorkTris1
;
i
++
)
{
area
+=
triArea
(
workTris1
[
i
]);
if
(
cacheTriangulation_
)
{
triangles_
.
append
(
workTris1
[
i
]);
}
}
return
area
;
...
...
@@ -312,12 +317,15 @@ Foam::faceAreaIntersect::faceAreaIntersect
(
const
pointField
&
pointsA
,
const
pointField
&
pointsB
,
const
bool
reverseB
const
bool
reverseB
,
const
bool
cacheTriangulation
)
:
pointsA_
(
pointsA
),
pointsB_
(
pointsB
),
reverseB_
(
reverseB
)
reverseB_
(
reverseB
),
cacheTriangulation_
(
cacheTriangulation
),
triangles_
(
cacheTriangulation
?
10
:
0
)
{}
...
...
@@ -337,7 +345,7 @@ void Foam::faceAreaIntersect::triangulate
{
case
tmFan
:
{
for
(
label
i
=
0
;
i
<
f
.
nTriangles
();
++
i
)
for
(
label
i
=
0
;
i
<
f
.
nTriangles
();
++
i
)
{
faceTris
[
i
]
=
face
(
3
);
faceTris
[
i
][
0
]
=
f
[
0
];
...
...
@@ -379,8 +387,10 @@ Foam::scalar Foam::faceAreaIntersect::calc
triangulate
(
faceA
,
pointsA_
,
triMode
,
trisA
);
triangulate
(
faceB
,
pointsB_
,
triMode
,
trisB
);
//
i
ntersect triangles
//
I
ntersect triangles
scalar
totalArea
=
0
.
0
;
triangles_
.
clear
();
forAll
(
trisA
,
tA
)
{
triPoints
tpA
=
getTriPoints
(
pointsA_
,
trisA
[
tA
],
false
);
...
...
src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersect.H
View file @
2be17edc
...
...
@@ -79,6 +79,12 @@ private:
//- Flag to reverse B faces
const
bool
reverseB_
;
//- Flag to cache the final triangulation
bool
cacheTriangulation_
;
//- Final triangulation
DynamicList
<
triPoints
>
triangles_
;
// Static data members
...
...
@@ -146,7 +152,8 @@ public:
(
const
pointField
&
pointsA
,
const
pointField
&
pointsB
,
const
bool
reverseB
=
false
const
bool
reverseB
=
false
,
const
bool
cacheTriangulation
=
false
);
...
...
@@ -164,6 +171,15 @@ public:
faceList
&
faceTris
);
//- Const access to the cacheTriangulation flag
inline
bool
cacheTriangulation
()
const
;
//- Const access to the triangulation
inline
const
DynamicList
<
triPoints
>
triangles
()
const
;
//- Non-const access to the triangulation
inline
DynamicList
<
triPoints
>&
triangles
();
//- Return area of intersection of faceA with faceB
scalar
calc
(
...
...
src/meshTools/AMIInterpolation/faceAreaIntersect/faceAreaIntersectI.H
View file @
2be17edc
...
...
@@ -75,7 +75,9 @@ inline Foam::point Foam::faceAreaIntersect::planeIntersection
const
label
posI
)
const
{
return
(
d
[
posI
]
*
t
[
negI
]
-
d
[
negI
]
*
t
[
posI
])
/
(
-
d
[
negI
]
+
d
[
posI
]);
scalar
dp
=
d
[
posI
];
scalar
dn
=
d
[
negI
];
return
(
dp
*
t
[
negI
]
-
dn
*
t
[
posI
])
/
(
-
dn
+
dp
);
}
...
...
@@ -93,4 +95,22 @@ Foam::scalar& Foam::faceAreaIntersect::tolerance()
}
bool
Foam
::
faceAreaIntersect
::
cacheTriangulation
()
const
{
return
cacheTriangulation_
;
}
const
Foam
::
DynamicList
<
Foam
::
triPoints
>
Foam
::
faceAreaIntersect
::
triangles
()
const
{
return
triangles_
;
}
Foam
::
DynamicList
<
Foam
::
triPoints
>&
Foam
::
faceAreaIntersect
::
triangles
()
{
return
triangles_
;
}
// ************************************************************************* //
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