Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Community
integration-cfmesh
Commits
aa8f5626
Commit
aa8f5626
authored
Mar 14, 2015
by
Franjo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial version of surface checks
parent
7035d077
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
140 additions
and
99 deletions
+140
-99
meshLibrary/utilities/triSurfaceTools/triSurfaceChecks/triSurfaceChecks.C
...ities/triSurfaceTools/triSurfaceChecks/triSurfaceChecks.C
+44
-26
meshLibrary/utilities/triSurfaceTools/triSurfaceChecks/triSurfaceChecks.H
...ities/triSurfaceTools/triSurfaceChecks/triSurfaceChecks.H
+1
-1
utilities/checkSurfaceMesh/checkSurfaceMesh.C
utilities/checkSurfaceMesh/checkSurfaceMesh.C
+95
-72
No files found.
meshLibrary/utilities/triSurfaceTools/triSurfaceChecks/triSurfaceChecks.C
View file @
aa8f5626
...
...
@@ -281,13 +281,13 @@ label checkForHoles(const triSurf& surf, labelLongList& badTriangles)
return
badTriangles
.
size
();
}
label
checkForHoles
(
triSurf
&
surf
,
const
word
subset
Prefix
)
label
checkForHoles
(
triSurf
&
surf
,
const
word
subset
Name
)
{
labelLongList
trianglesNearHoles
;
if
(
checkForHoles
(
surf
,
trianglesNearHoles
)
)
{
const
label
setId
=
surf
.
addFacetSubset
(
subset
Prefix
);
const
label
setId
=
surf
.
addFacetSubset
(
subset
Name
);
forAll
(
trianglesNearHoles
,
i
)
surf
.
addFacetToSubset
(
setId
,
trianglesNearHoles
[
i
]);
...
...
@@ -623,6 +623,13 @@ label checkSelfIntersections
{
const
labelledTri
&
tri
=
surf
[
tI
];
const
triangle
<
point
,
point
>
currTri
(
pts
[
tri
[
0
]],
pts
[
tri
[
1
]],
pts
[
tri
[
2
]]
);
boundBox
bb
(
pts
[
tri
[
0
]],
pts
[
tri
[
0
]]);
for
(
label
i
=
1
;
i
<
3
;
++
i
)
{
...
...
@@ -649,21 +656,23 @@ label checkSelfIntersections
if
(
tI
>=
triJ
)
continue
;
point
int0
,
int1
;
const
triangle
<
point
,
point
>
neiTri
(
pts
[
nt
[
0
]],
pts
[
nt
[
1
]],
pts
[
nt
[
2
]]
);
FixedList
<
point
,
2
>
intersectionEdge
;
const
bool
intersect
=
triangleFuncs
::
i
ntersect
help
::
doTrianglesI
ntersect
(
pts
[
tri
[
0
]],
pts
[
tri
[
1
]],
pts
[
tri
[
2
]],
pts
[
nt
[
0
]],
pts
[
nt
[
1
]],
pts
[
nt
[
2
]],
int0
,
int1
currTri
,
neiTri
,
intersectionEdge
,
tol
,
Foam
::
cos
(
5
.
0
*
M_PI
/
180
.
0
)
);
if
(
intersect
)
...
...
@@ -728,6 +737,13 @@ label checkOverlaps
{
const
labelledTri
&
tri
=
surf
[
tI
];
const
triangle
<
point
,
point
>
currTri
(
pts
[
tri
[
0
]],
pts
[
tri
[
1
]],
pts
[
tri
[
2
]]
);
boundBox
bb
(
pts
[
tri
[
0
]],
pts
[
tri
[
0
]]);
for
(
label
i
=
1
;
i
<
3
;
++
i
)
{
...
...
@@ -754,21 +770,23 @@ label checkOverlaps
if
(
tI
>=
triJ
)
continue
;
point
int0
,
int1
;
const
triangle
<
point
,
point
>
neiTri
(
pts
[
nt
[
0
]],
pts
[
nt
[
1
]],
pts
[
nt
[
2
]]
);
DynList
<
point
>
intersectionPolygon
;
const
bool
intersect
=
triangleFuncs
::
intersect
help
::
doTrianglesOverlap
(
pts
[
tri
[
0
]],
pts
[
tri
[
1
]],
pts
[
tri
[
2
]],
pts
[
nt
[
0
]],
pts
[
nt
[
1
]],
pts
[
nt
[
2
]],
int0
,
int1
currTri
,
neiTri
,
intersectionPolygon
,
tol
,
Foam
::
cos
(
angleTol
*
M_PI
/
180
.
0
)
);
if
(
intersect
)
...
...
meshLibrary/utilities/triSurfaceTools/triSurfaceChecks/triSurfaceChecks.H
View file @
aa8f5626
...
...
@@ -74,7 +74,7 @@ label checkSurfaceManifolds(triSurf&, const word subsetPrefix="manifold_");
//- check for existence of holes in the surface mesh
label
checkForHoles
(
const
triSurf
&
,
labelLongList
&
);
label
checkForHoles
(
triSurf
&
,
const
word
subset
Prefix
=
"hole
_
"
);
label
checkForHoles
(
triSurf
&
,
const
word
subset
Name
=
"hole
s
"
);
//- check for existence of non-manifold edges
label
checkForNonManifoldEdges
(
const
triSurf
&
,
labelLongList
&
);
...
...
utilities/checkSurfaceMesh/checkSurfaceMesh.C
View file @
aa8f5626
...
...
@@ -30,12 +30,8 @@ Description
#include "IFstream.H"
#include "fileName.H"
#include "triSurf.H"
#include "triSurfModifier.H"
#include "helperFunctions.H"
#include "demandDrivenData.H"
#include "coordinateModifier.H"
#include "checkMeshDict.H"
#include "surfaceMeshGeometryModification.H"
#include "triSurfaceChecks.H"
#include "boundBox.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
...
...
@@ -43,79 +39,106 @@ using namespace Foam;
int
main
(
int
argc
,
char
*
argv
[])
{
# include "setRootCase.H"
# include "createTime.H"
IOdictionary
meshDict
(
IOobject
(
"meshDict"
,
runTime
.
system
(),
runTime
,
IOobject
::
MUST_READ
,
IOobject
::
NO_WRITE
)
);
checkMeshDict
cmd
(
meshDict
);
fileName
surfaceFile
=
meshDict
.
lookup
(
"surfaceFile"
);
if
(
Pstream
::
parRun
()
)
surfaceFile
=
".."
/
surfaceFile
;
triSurf
surface
(
runTime
.
path
()
/
surfaceFile
);
surfaceMeshGeometryModification
gMod
(
surface
,
meshDict
);
//- modify points
const
triSurf
*
modSurfPtr
=
gMod
.
modifyGeometry
();
Info
<<
"Writting modified surface"
<<
endl
;
modSurfPtr
->
writeSurface
(
"modifiedSurf.stl"
);
# ifdef DEBUGScaling
//- apply backward modification
Info
<<
"Here"
<<
endl
;
coordinateModifier
cMod
(
meshDict
.
subDict
(
"anisotropicSources"
));
Info
<<
"Starting modifications"
<<
endl
;
forAll
(
surface
.
points
(),
i
)
argList
::
noParallel
();
argList
::
validArgs
.
clear
();
argList
::
validArgs
.
append
(
"input surface file"
);
argList
args
(
argc
,
argv
);
fileName
inFileName
(
args
.
args
()[
1
]);
triSurf
surf
(
inFileName
);
label
nFailed
(
0
);
boundBox
bb
;
triSurfaceChecks
::
calculateBoundingBox
(
surf
,
bb
);
Info
<<
"Surface bounding box is "
<<
bb
<<
endl
;
//- calculate manifolds
const
label
nManifolds
=
triSurfaceChecks
::
checkSurfaceManifolds
(
surf
);
if
(
nManifolds
>
1
)
{
++
nFailed
;
Info
<<
"Surface mesh consists of "
<<
nManifolds
<<
" manifolds."
<<
endl
;
Warning
<<
"You cannot mesh geometries consisting of more than"
<<
" one domain, and it must not contain baffles."
<<
endl
;
}
else
{
Info
<<
"
\n
Orig point "
<<
i
<<
" coordinates "
<<
surface
.
points
()[
i
]
<<
" modified point "
<<
modSurfPtr
->
points
()[
i
]
<<
endl
;
const
point
p
=
cMod
.
backwardModifiedPoint
(
modSurfPtr
->
points
()[
i
]);
if
(
mag
(
p
-
surface
.
points
()[
i
])
>
1e-14
)
{
Warning
<<
"Point "
<<
i
<<
" is different "
<<
p
<<
" from original "
<<
surface
.
points
()[
i
]
<<
" modified point "
<<
cMod
.
modifiedPoint
(
surface
.
points
()[
i
])
<<
endl
;
::
exit
(
0
);
}
Info
<<
"Surface mesh consists of a single manifold."
<<
endl
;
}
Info
<<
"Backscaling Ok"
<<
endl
;
::
exit
(
0
);
# endif
//- find open boundary edges
if
(
triSurfaceChecks
::
checkForHoles
(
surf
)
)
{
++
nFailed
;
surfaceMeshGeometryModification
bgMod
(
*
modSurfPtr
,
meshDict
);
const
triSurf
*
backModSurfPtr
=
bgMod
.
revertGeometryModification
();
Info
<<
"Surface mesh has open boundaries!!"
<<
endl
;
Warning
<<
"This indicates that there may be some holes in the surface"
<<
" mesh. Holes in the mesh must be smaller than the specified"
<<
" cell size at this location. In addition, please avoid"
<<
" using automatic refinement (minCellSize)."
<<
endl
;
}
else
{
Info
<<
"No holes found in the surface mesh."
<<
endl
;
}
Info
<<
"Writting backward transformed surface"
<<
endl
;
backModSurfPtr
->
writeSurface
(
"backwardModifiedSurf.stl"
);
//- find non-manifold edges
if
(
triSurfaceChecks
::
checkForNonManifoldEdges
(
surf
)
)
{
++
nFailed
;
# ifdef DEBUGScaling
forAll
(
backModSurfPtr
->
points
(),
pI
)
if
(
mag
(
backModSurfPtr
->
points
()[
pI
]
-
surface
.
points
()[
pI
])
>
1e-14
)
Warning
<<
"Point "
<<
pI
<<
" is different "
<<
backModSurfPtr
->
points
()[
pI
]
<<
" from original "
<<
surface
.
points
()[
pI
]
<<
endl
;
# endif
Info
<<
"Surface mesh has non-manifold edges!!"
<<
endl
;
Warning
<<
"This indicates that the surface mesh consists of multiple"
<<
" domains and/or baffles. Please make sure that they are not"
<<
" in the domain which shall be meshed."
<<
endl
;
}
else
{
Info
<<
"Surface does not have any non-manifold edges."
<<
endl
;
}
deleteDemandDrivenData
(
modSurfPtr
);
deleteDemandDrivenData
(
backModSurfPtr
);
//- check the number of disconnected parts
if
(
triSurfaceChecks
::
checkDisconnectedParts
(
surf
)
>
1
)
{
++
nFailed
;
Info
<<
"Surface mesh consists of disconnected parts."
<<
endl
;
Warning
<<
"This is not a problem if there exists a region surrounding"
<<
" the other ones! In other case, the mesher will generate"
<<
" the mesh in the domains with most cells."
<<
endl
;
}
else
{
Info
<<
"Surface mesh consists of a single region."
<<
endl
;
}
//- find triangles with small angles
if
(
triSurfaceChecks
::
checkAngles
(
surf
,
"smallAngles"
,
1
.
0
)
)
{
++
nFailed
;
Info
<<
"Surface mesh has some bad-quality triangles."
<<
endl
;
Warning
<<
"This may cause problems to the automatic refinement"
<<
" procedure (minCellSize). "
<<
endl
;
}
else
{
Info
<<
"No sliver triangles found."
<<
endl
;
}
if
(
nFailed
)
{
Warning
<<
"Found "
<<
nFailed
<<
" checks indicating potential problems."
<<
endl
;
Warning
<<
"This does not mean that you cannot generate"
<<
" a valid mesh. "
<<
endl
;
surf
.
writeSurface
(
inFileName
);
}
Info
<<
"End
\n
"
<<
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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