Commit 0b54e1cc authored by mattijs's avatar mattijs
Browse files

ENH: surfaceIntersection: cleanup

parent aece1c1c
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -36,8 +36,24 @@ License
namespace Foam
{
defineTypeNameAndDebug(booleanSurface, 0);
template<>
const char* Foam::NamedEnum
<
Foam::booleanSurface::booleanOpType,
4
>::names[] =
{
"union",
"intersection",
"difference",
"all"
};
}
const Foam::NamedEnum<Foam::booleanSurface::booleanOpType, 4>
Foam::booleanSurface::booleanOpTypeNames;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -170,6 +170,11 @@ public:
// surface. (Produces multiply connected surface)
};
// Static data
static const NamedEnum<booleanOpType, 4> booleanOpTypeNames;
// Constructors
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -716,66 +716,35 @@ Foam::faceList Foam::intersectedSurface::resplitFace
edgeSurface& eSurf
)
{
{
// Dump face for debugging.
Pout<< "Writing face:" << faceI << " to face.obj" << endl;
OFstream str("face.obj");
writeOBJ(eSurf.points(), eSurf.edges(), eSurf.faceEdges()[faceI], str);
}
// Count the number of times point has been visited so we
// can compare number to facePointEdges.
Map<label> pointVisited(2*facePointEdges.size());
{
OFstream str0("visitedNone.obj");
OFstream str1("visitedOnce.obj");
OFstream str2("visitedTwice.obj");
forAll(eSurf.points(), pointI)
{
const point& pt = eSurf.points()[pointI];
str0 << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
str1 << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
str2 << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
forAllConstIter(Map<label>, visited, iter)
{
label edgeI = iter.key();
const edge& e = eSurf.edges()[edgeI];
label stat = iter();
if (stat == STARTTOEND || stat == ENDTOSTART)
{
incCount(pointVisited, e[0], 1);
incCount(pointVisited, e[1], 1);
str1 << "l " << e[0]+1 << ' ' << e[1]+1 << nl;
}
else if (stat == BOTH)
{
incCount(pointVisited, e[0], 2);
incCount(pointVisited, e[1], 2);
str2 << "l " << e[0]+1 << ' ' << e[1]+1 << nl;
}
else if (stat == UNVISITED)
{
incCount(pointVisited, e[0], 0);
incCount(pointVisited, e[1], 0);
str0 << "l " << e[0]+1 << ' ' << e[1]+1 << nl;
}
}
}
if (debug)
{
forAllConstIter(Map<label>, pointVisited, iter)
{
......@@ -838,8 +807,6 @@ Foam::faceList Foam::intersectedSurface::resplitFace
// Find second intersection.
label visitedVert1 = -1;
label unvisitedVert1 = -1;
{
scalar minDist = GREAT;
......@@ -876,8 +843,6 @@ Foam::faceList Foam::intersectedSurface::resplitFace
if (nearDist < minDist)
{
minDist = nearDist;
visitedVert1 = nearVertI;
unvisitedVert1 = pointI;
}
}
}
......@@ -885,32 +850,24 @@ Foam::faceList Foam::intersectedSurface::resplitFace
}
Pout<< "resplitFace : adding intersection from " << visitedVert0
<< " to " << unvisitedVert0 << endl
<< " and from " << visitedVert1
<< " to " << unvisitedVert1 << endl;
// // Add the new intersection edges to the edgeSurface
// edgeList additionalEdges(2);
// additionalEdges[0] = edge(visitedVert0, unvisitedVert0);
// additionalEdges[1] = edge(visitedVert1, unvisitedVert1);
// Add the new intersection edges to the edgeSurface
edgeList additionalEdges(1);
additionalEdges[0] = edge(visitedVert0, unvisitedVert0);
eSurf.addIntersectionEdges(faceI, additionalEdges);
fileName newFName("face_" + Foam::name(faceI) + "_newEdges.obj");
Pout<< "Dumping face:" << faceI << " to " << newFName << endl;
writeLocalOBJ
(
eSurf.points(),
eSurf.edges(),
eSurf.faceEdges()[faceI],
newFName
);
if (debug)
{
fileName newFName("face_" + Foam::name(faceI) + "_newEdges.obj");
Pout<< "Dumping face:" << faceI << " to " << newFName << endl;
writeLocalOBJ
(
eSurf.points(),
eSurf.edges(),
eSurf.faceEdges()[faceI],
newFName
);
}
// Retry splitFace. Use recursion since is rare situation.
return splitFace(surf, faceI, eSurf);
......@@ -1085,20 +1042,6 @@ Foam::faceList Foam::intersectedSurface::splitFace
}
else if (stat != BOTH)
{
//{
// Pout<< "Dumping faces so far to faces.obj" << nl
// << faces << endl;
//
// OFstream str("faces.obj");
//
// forAll(faces, i)
// {
// writeOBJ(points, faces[i], str);
// }
//}
Pout<< "** Resplitting **" << endl;
// Redo face after introducing extra edge. Edge introduced
// should be one nearest to any fully visited edge.
return resplitFace
......@@ -1220,34 +1163,6 @@ Foam::intersectedSurface::intersectedSurface
forAll(newFaces, newFaceI)
{
const face& newF = newFaces[newFaceI];
// {
// fileName fName
// (
// "face_"
// + Foam::name(faceI)
// + "_subFace_"
// + Foam::name(newFaceI)
// + ".obj"
// );
// Pout<< "Writing original face:" << faceI << " subFace:"
// << newFaceI << " to " << fName << endl;
//
// OFstream str(fName);
//
// forAll(newF, fp)
// {
// meshTools::writeOBJ(str, eSurf.points()[newF[fp]]);
// }
// str << 'l';
// forAll(newF, fp)
// {
// str << ' ' << fp+1;
// }
// str<< " 1" << nl;
// }
const vector& n = surf.faceNormals()[faceI];
const label region = surf[faceI].region();
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -54,7 +54,6 @@ void Foam::edgeIntersections::checkEdges(const triSurface& surf)
{
const pointField& localPoints = surf.localPoints();
const edgeList& edges = surf.edges();
const labelListList& edgeFaces = surf.edgeFaces();
treeBoundBox bb(localPoints);
......@@ -78,19 +77,6 @@ void Foam::edgeIntersections::checkEdges(const triSurface& surf)
<< "This might lead to problems in intersection"
<< endl;
}
if (edgeFaces[edgeI].size() == 1)
{
WarningIn
(
"Foam::edgeIntersections::checkEdges(const triSurface& surf)"
) << "Edge " << edgeI << " vertices " << e
<< " coords:" << localPoints[e[0]] << ' '
<< localPoints[e[1]] << " has only one face connected to it:"
<< edgeFaces[edgeI] << endl
<< "This might lead to problems in intersection"
<< endl;
}
}
}
......@@ -466,7 +452,6 @@ Foam::edgeIntersections::edgeIntersections()
{}
// Construct from surface and tolerance
Foam::edgeIntersections::edgeIntersections
(
const triSurface& surf1,
......@@ -478,16 +463,9 @@ Foam::edgeIntersections::edgeIntersections
classification_(surf1.nEdges())
{
checkEdges(surf1);
checkEdges(query2.surface());
// Current set of edges to test
labelList edgesToTest(surf1.nEdges());
// Start off with all edges
forAll(edgesToTest, i)
{
edgesToTest[i] = i;
}
labelList edgesToTest(identity(surf1.nEdges()));
// Determine intersections for edgesToTest
intersectEdges
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -242,9 +242,9 @@ void Foam::surfaceIntersection::storeIntersection
WarningIn
(
"Foam::surfaceIntersection::storeIntersection"
"(const bool isFirstSurf, const labelList& facesA,"
"const label faceB, DynamicList<edge>& allCutEdges,"
"DynamicList<point>& allCutPoints)"
"(const bool, const labelList&,"
"const label, DynamicList<edge>&,"
"DynamicList<point>&)"
) << "Encountered degenerate edge between face "
<< twoFaces[0] << " on first surface"
<< " and face " << twoFaces[1] << " on second surface"
......@@ -815,7 +815,7 @@ Foam::surfaceIntersection::surfaceIntersection
}
// Construct from full intersection Poutrmation
// Construct from full intersection information
Foam::surfaceIntersection::surfaceIntersection
(
const triSurface& surf1,
......
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [m s^-1];
internalField uniform (0 0 0);
boundaryField
{
//- Set patchGroups for constraint patches
#include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes"
minX
{
type uniformFixedValue;
uniformValue (1 0 0);
}
maxX
{
type zeroGradient;
}
wall
{
type uniformFixedValue;
uniformValue (0 0 0);
}
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [m^2/s^2];
internalField uniform 0;
boundaryField
{
//- Set patchGroups for constraint patches
#include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes"
minX
{
type zeroGradient;
}
maxX
{
type fixedValue;
value $internalField;
}
wall
{
type zeroGradient;
}
}
// ************************************************************************* //
#!/bin/sh
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
rm -f constant/polyMesh/boundary
cleanCase
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication topoSet
runApplication snappyHexMesh -overwrite
runApplication checkMesh
runApplication simpleFoam
# ----------------------------------------------------------------- end-of-file
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.001;
vertices
(
( 0 0 0)
(10 0 0)
(10 6 0)
( 0 6 0)
( 0 0 1)
(10 0 1)
(10 6 1)
( 0 6 1)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (20 12 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
maxY
{
type wall;
faces
(
(3 7 6 2)
);
}
minY
{
type wall;
faces
(
(1 5 4 0)
);
}
minX
{
type patch;
faces
(
(0 4 7 3)
);
}
maxX
{
type patch;
faces
(
(2 6 5 1)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(4 5 6 7)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1.5e-05;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |