mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Add normalDirections and normalTypes to extendedFeatureEdgeMesh
This commit is contained in:
@ -68,6 +68,19 @@ namespace Foam
|
|||||||
"multiple",
|
"multiple",
|
||||||
"none"
|
"none"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
const char* Foam::NamedEnum
|
||||||
|
<
|
||||||
|
Foam::extendedFeatureEdgeMesh::sideVolumeType,
|
||||||
|
4
|
||||||
|
>::names[] =
|
||||||
|
{
|
||||||
|
"inside",
|
||||||
|
"outside",
|
||||||
|
"both",
|
||||||
|
"neither"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::pointStatus, 4>
|
const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::pointStatus, 4>
|
||||||
@ -76,6 +89,9 @@ const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::pointStatus, 4>
|
|||||||
const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::edgeStatus, 6>
|
const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::edgeStatus, 6>
|
||||||
Foam::extendedFeatureEdgeMesh::edgeStatusNames_;
|
Foam::extendedFeatureEdgeMesh::edgeStatusNames_;
|
||||||
|
|
||||||
|
const Foam::NamedEnum<Foam::extendedFeatureEdgeMesh::sideVolumeType, 4>
|
||||||
|
Foam::extendedFeatureEdgeMesh::sideVolumeTypeNames_;
|
||||||
|
|
||||||
Foam::scalar Foam::extendedFeatureEdgeMesh::cosNormalAngleTol_ =
|
Foam::scalar Foam::extendedFeatureEdgeMesh::cosNormalAngleTol_ =
|
||||||
Foam::cos(degToRad(0.1));
|
Foam::cos(degToRad(0.1));
|
||||||
|
|
||||||
@ -106,7 +122,9 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
|
|||||||
openStart_(0),
|
openStart_(0),
|
||||||
multipleStart_(0),
|
multipleStart_(0),
|
||||||
normals_(0),
|
normals_(0),
|
||||||
|
normalVolumeTypes_(0),
|
||||||
edgeDirections_(0),
|
edgeDirections_(0),
|
||||||
|
normalDirections_(0),
|
||||||
edgeNormals_(0),
|
edgeNormals_(0),
|
||||||
featurePointNormals_(0),
|
featurePointNormals_(0),
|
||||||
featurePointEdges_(0),
|
featurePointEdges_(0),
|
||||||
@ -144,6 +162,8 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
|
|||||||
>> openStart_
|
>> openStart_
|
||||||
>> multipleStart_
|
>> multipleStart_
|
||||||
>> normals_
|
>> normals_
|
||||||
|
>> normalVolumeTypes_
|
||||||
|
>> normalDirections_
|
||||||
>> edgeNormals_
|
>> edgeNormals_
|
||||||
>> featurePointNormals_
|
>> featurePointNormals_
|
||||||
>> featurePointEdges_
|
>> featurePointEdges_
|
||||||
@ -196,7 +216,9 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
|
|||||||
openStart_(fem.openStart()),
|
openStart_(fem.openStart()),
|
||||||
multipleStart_(fem.multipleStart()),
|
multipleStart_(fem.multipleStart()),
|
||||||
normals_(fem.normals()),
|
normals_(fem.normals()),
|
||||||
|
normalVolumeTypes_(fem.normalVolumeTypes()),
|
||||||
edgeDirections_(fem.edgeDirections()),
|
edgeDirections_(fem.edgeDirections()),
|
||||||
|
normalDirections_(fem.normalDirections()),
|
||||||
edgeNormals_(fem.edgeNormals()),
|
edgeNormals_(fem.edgeNormals()),
|
||||||
featurePointNormals_(fem.featurePointNormals()),
|
featurePointNormals_(fem.featurePointNormals()),
|
||||||
featurePointEdges_(fem.featurePointEdges()),
|
featurePointEdges_(fem.featurePointEdges()),
|
||||||
@ -224,7 +246,9 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
|
|||||||
openStart_(0),
|
openStart_(0),
|
||||||
multipleStart_(0),
|
multipleStart_(0),
|
||||||
normals_(0),
|
normals_(0),
|
||||||
|
normalVolumeTypes_(0),
|
||||||
edgeDirections_(0),
|
edgeDirections_(0),
|
||||||
|
normalDirections_(0),
|
||||||
edgeNormals_(0),
|
edgeNormals_(0),
|
||||||
featurePointNormals_(0),
|
featurePointNormals_(0),
|
||||||
featurePointEdges_(0),
|
featurePointEdges_(0),
|
||||||
@ -263,7 +287,9 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
|
|||||||
openStart_(-1),
|
openStart_(-1),
|
||||||
multipleStart_(-1),
|
multipleStart_(-1),
|
||||||
normals_(0),
|
normals_(0),
|
||||||
|
normalVolumeTypes_(0),
|
||||||
edgeDirections_(0),
|
edgeDirections_(0),
|
||||||
|
normalDirections_(0),
|
||||||
edgeNormals_(0),
|
edgeNormals_(0),
|
||||||
featurePointNormals_(0),
|
featurePointNormals_(0),
|
||||||
featurePointEdges_(0),
|
featurePointEdges_(0),
|
||||||
@ -287,6 +313,41 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
|
|||||||
regionFeatureEdges,
|
regionFeatureEdges,
|
||||||
featurePoints
|
featurePoints
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const labelListList& edgeFaces = surf.edgeFaces();
|
||||||
|
|
||||||
|
normalVolumeTypes_.setSize(normals_.size());
|
||||||
|
|
||||||
|
// Noting when the normal of a face has been used so not to duplicate
|
||||||
|
labelList faceMap(surf.size(), -1);
|
||||||
|
|
||||||
|
label nAdded = 0;
|
||||||
|
|
||||||
|
forAll(featureEdges, i)
|
||||||
|
{
|
||||||
|
label sFEI = featureEdges[i];
|
||||||
|
|
||||||
|
// Pick up the faces adjacent to the feature edge
|
||||||
|
const labelList& eFaces = edgeFaces[sFEI];
|
||||||
|
|
||||||
|
forAll(eFaces, j)
|
||||||
|
{
|
||||||
|
label eFI = eFaces[j];
|
||||||
|
|
||||||
|
// Check to see if the points have been already used
|
||||||
|
if (faceMap[eFI] == -1)
|
||||||
|
{
|
||||||
|
normalVolumeTypes_[nAdded++] =
|
||||||
|
(
|
||||||
|
surfBaffleRegions[surf[eFI].region()]
|
||||||
|
? BOTH
|
||||||
|
: INSIDE
|
||||||
|
);
|
||||||
|
|
||||||
|
faceMap[eFI] = nAdded - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -309,7 +370,9 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
|
|||||||
openStart_(-1),
|
openStart_(-1),
|
||||||
multipleStart_(-1),
|
multipleStart_(-1),
|
||||||
normals_(0),
|
normals_(0),
|
||||||
|
normalVolumeTypes_(0),
|
||||||
edgeDirections_(0),
|
edgeDirections_(0),
|
||||||
|
normalDirections_(0),
|
||||||
edgeNormals_(0),
|
edgeNormals_(0),
|
||||||
featurePointNormals_(0),
|
featurePointNormals_(0),
|
||||||
featurePointEdges_(0),
|
featurePointEdges_(0),
|
||||||
@ -341,7 +404,9 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
|
|||||||
label openStart,
|
label openStart,
|
||||||
label multipleStart,
|
label multipleStart,
|
||||||
const vectorField& normals,
|
const vectorField& normals,
|
||||||
|
const PackedList<2>& normalVolumeTypes,
|
||||||
const vectorField& edgeDirections,
|
const vectorField& edgeDirections,
|
||||||
|
const labelListList& normalDirections,
|
||||||
const labelListList& edgeNormals,
|
const labelListList& edgeNormals,
|
||||||
const labelListList& featurePointNormals,
|
const labelListList& featurePointNormals,
|
||||||
const labelListList& featurePointEdges,
|
const labelListList& featurePointEdges,
|
||||||
@ -358,7 +423,9 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
|
|||||||
openStart_(openStart),
|
openStart_(openStart),
|
||||||
multipleStart_(multipleStart),
|
multipleStart_(multipleStart),
|
||||||
normals_(normals),
|
normals_(normals),
|
||||||
|
normalVolumeTypes_(normalVolumeTypes),
|
||||||
edgeDirections_(edgeDirections),
|
edgeDirections_(edgeDirections),
|
||||||
|
normalDirections_(normalDirections),
|
||||||
edgeNormals_(edgeNormals),
|
edgeNormals_(edgeNormals),
|
||||||
featurePointNormals_(featurePointNormals),
|
featurePointNormals_(featurePointNormals),
|
||||||
featurePointEdges_(featurePointEdges),
|
featurePointEdges_(featurePointEdges),
|
||||||
@ -1300,6 +1367,10 @@ bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
|
|||||||
<< multipleStart_ << nl
|
<< multipleStart_ << nl
|
||||||
<< "// normals" << nl
|
<< "// normals" << nl
|
||||||
<< normals_ << nl
|
<< normals_ << nl
|
||||||
|
<< "// normal volume types" << nl
|
||||||
|
<< normalVolumeTypes_ << nl
|
||||||
|
<< "// normalDirections" << nl
|
||||||
|
<< normalDirections_ << nl
|
||||||
<< "// edgeNormals" << nl
|
<< "// edgeNormals" << nl
|
||||||
<< edgeNormals_ << nl
|
<< edgeNormals_ << nl
|
||||||
<< "// featurePointNormals" << nl
|
<< "// featurePointNormals" << nl
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -61,6 +61,7 @@ SourceFiles
|
|||||||
#include "treeDataEdge.H"
|
#include "treeDataEdge.H"
|
||||||
#include "treeDataPoint.H"
|
#include "treeDataPoint.H"
|
||||||
#include "PrimitivePatch.H"
|
#include "PrimitivePatch.H"
|
||||||
|
#include "PackedList.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -108,6 +109,17 @@ public:
|
|||||||
|
|
||||||
static const Foam::NamedEnum<edgeStatus, 6> edgeStatusNames_;
|
static const Foam::NamedEnum<edgeStatus, 6> edgeStatusNames_;
|
||||||
|
|
||||||
|
//- Normals point to the outside
|
||||||
|
enum sideVolumeType
|
||||||
|
{
|
||||||
|
INSIDE = 0, // mesh inside
|
||||||
|
OUTSIDE = 1, // mesh outside
|
||||||
|
BOTH = 2, // e.g. a baffle
|
||||||
|
NEITHER = 3 // not sure when this may be used
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Foam::NamedEnum<sideVolumeType, 4> sideVolumeTypeNames_;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -150,9 +162,17 @@ private:
|
|||||||
// points and edges, unsorted
|
// points and edges, unsorted
|
||||||
vectorField normals_;
|
vectorField normals_;
|
||||||
|
|
||||||
|
//-
|
||||||
|
PackedList<2> normalVolumeTypes_;
|
||||||
|
|
||||||
//- Flat and open edges require the direction of the edge
|
//- Flat and open edges require the direction of the edge
|
||||||
vectorField edgeDirections_;
|
vectorField edgeDirections_;
|
||||||
|
|
||||||
|
//- Starting directions for the edges.
|
||||||
|
// This vector points to the half of the plane defined by the first
|
||||||
|
// edge normal.
|
||||||
|
labelListList normalDirections_;
|
||||||
|
|
||||||
//- Indices of the normals that are adjacent to the feature edges
|
//- Indices of the normals that are adjacent to the feature edges
|
||||||
labelListList edgeNormals_;
|
labelListList edgeNormals_;
|
||||||
|
|
||||||
@ -268,6 +288,7 @@ public:
|
|||||||
label multipleStart,
|
label multipleStart,
|
||||||
const vectorField& normals,
|
const vectorField& normals,
|
||||||
const vectorField& edgeDirections,
|
const vectorField& edgeDirections,
|
||||||
|
const labelListList& normalDirections,
|
||||||
const labelListList& edgeNormals,
|
const labelListList& edgeNormals,
|
||||||
const labelListList& featurePointNormals,
|
const labelListList& featurePointNormals,
|
||||||
const labelListList& featurePointEdges,
|
const labelListList& featurePointEdges,
|
||||||
@ -369,9 +390,15 @@ public:
|
|||||||
// and points
|
// and points
|
||||||
inline const vectorField& normals() const;
|
inline const vectorField& normals() const;
|
||||||
|
|
||||||
|
//- Return
|
||||||
|
inline const PackedList<2>& normalVolumeTypes() const;
|
||||||
|
|
||||||
//- Return the edgeDirection vectors
|
//- Return the edgeDirection vectors
|
||||||
inline const vectorField& edgeDirections() const;
|
inline const vectorField& edgeDirections() const;
|
||||||
|
|
||||||
|
//-
|
||||||
|
inline const labelListList& normalDirections() const;
|
||||||
|
|
||||||
//- Return the direction of edgeI, pointing away from ptI
|
//- Return the direction of edgeI, pointing away from ptI
|
||||||
inline vector edgeDirection(label edgeI, label ptI) const;
|
inline vector edgeDirection(label edgeI, label ptI) const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -90,12 +90,24 @@ inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::normals() const
|
|||||||
return normals_;
|
return normals_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const Foam::PackedList<2>&
|
||||||
|
Foam::extendedFeatureEdgeMesh::normalVolumeTypes() const
|
||||||
|
{
|
||||||
|
return normalVolumeTypes_;
|
||||||
|
}
|
||||||
|
|
||||||
inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::edgeDirections()
|
inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::edgeDirections()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
return edgeDirections_;
|
return edgeDirections_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline const Foam::labelListList&
|
||||||
|
Foam::extendedFeatureEdgeMesh::normalDirections() const
|
||||||
|
{
|
||||||
|
return normalDirections_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::vector Foam::extendedFeatureEdgeMesh::edgeDirection
|
inline Foam::vector Foam::extendedFeatureEdgeMesh::edgeDirection
|
||||||
(
|
(
|
||||||
|
|||||||
@ -27,6 +27,8 @@ License
|
|||||||
#include "ListListOps.H"
|
#include "ListListOps.H"
|
||||||
#include "unitConversion.H"
|
#include "unitConversion.H"
|
||||||
#include "PackedBoolList.H"
|
#include "PackedBoolList.H"
|
||||||
|
#include "PatchTools.H"
|
||||||
|
#include "searchableBox.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
|
|||||||
{
|
{
|
||||||
const pointField& sFeatLocalPts(surf.localPoints());
|
const pointField& sFeatLocalPts(surf.localPoints());
|
||||||
const edgeList& sFeatEds(surf.edges());
|
const edgeList& sFeatEds(surf.edges());
|
||||||
const labelListList& edgeFaces = surf.edgeFaces();
|
const labelListList edgeFaces = PatchTools::sortedEdgeFaces(surf);
|
||||||
const vectorField& faceNormals = surf.faceNormals();
|
const vectorField& faceNormals = surf.faceNormals();
|
||||||
const labelListList& pointEdges = surf.pointEdges();
|
const labelListList& pointEdges = surf.pointEdges();
|
||||||
|
|
||||||
@ -131,6 +133,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
|
|||||||
const labelList& eFaces = edgeFaces[sFEI];
|
const labelList& eFaces = edgeFaces[sFEI];
|
||||||
|
|
||||||
edgeNormals[i].setSize(eFaces.size());
|
edgeNormals[i].setSize(eFaces.size());
|
||||||
|
normalDirections[i].setSize(eFaces.size());
|
||||||
|
|
||||||
forAll(eFaces, j)
|
forAll(eFaces, j)
|
||||||
{
|
{
|
||||||
@ -145,6 +148,22 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
|
|||||||
}
|
}
|
||||||
|
|
||||||
edgeNormals[i][j] = faceMap[eFI];
|
edgeNormals[i][j] = faceMap[eFI];
|
||||||
|
|
||||||
|
const vector cross = (faceNormals[eFI] ^ edgeDirections[i]);
|
||||||
|
const vector fC0tofE0 =
|
||||||
|
surf[eFI].centre(surf.points())
|
||||||
|
- sFeatLocalPts[fE.start()];
|
||||||
|
|
||||||
|
normalDirections[i][j] =
|
||||||
|
(
|
||||||
|
(
|
||||||
|
(cross/(mag(cross) + VSMALL))
|
||||||
|
& (fC0tofE0/(mag(fC0tofE0)+ VSMALL))
|
||||||
|
)
|
||||||
|
> 0.0
|
||||||
|
? 1
|
||||||
|
: -1
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector fC0tofC1(vector::zero);
|
vector fC0tofC1(vector::zero);
|
||||||
@ -258,6 +277,7 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
|
|||||||
inplaceReorder(edMap, edStatus);
|
inplaceReorder(edMap, edStatus);
|
||||||
inplaceReorder(edMap, edgeDirections);
|
inplaceReorder(edMap, edgeDirections);
|
||||||
inplaceReorder(edMap, edgeNormals);
|
inplaceReorder(edMap, edgeNormals);
|
||||||
|
inplaceReorder(edMap, normalDirections);
|
||||||
inplaceRenumber(edMap, regionEdges);
|
inplaceRenumber(edMap, regionEdges);
|
||||||
|
|
||||||
forAll(featurePointFeatureEdges, pI)
|
forAll(featurePointFeatureEdges, pI)
|
||||||
@ -273,11 +293,13 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
|
|||||||
// Initialise sorted edge related data
|
// Initialise sorted edge related data
|
||||||
edgeDirections_ = edgeDirections/(mag(edgeDirections) + VSMALL);
|
edgeDirections_ = edgeDirections/(mag(edgeDirections) + VSMALL);
|
||||||
edgeNormals_ = edgeNormals;
|
edgeNormals_ = edgeNormals;
|
||||||
|
normalDirections_ = normalDirections;
|
||||||
regionEdges_ = regionEdges;
|
regionEdges_ = regionEdges;
|
||||||
|
|
||||||
// Normals are all now found and indirectly addressed, can also be stored
|
// Normals are all now found and indirectly addressed, can also be stored
|
||||||
normals_ = vectorField(norms);
|
normals_ = vectorField(norms);
|
||||||
|
|
||||||
|
|
||||||
// Reorder the feature points by classification
|
// Reorder the feature points by classification
|
||||||
|
|
||||||
List<DynamicList<label> > allPts(3);
|
List<DynamicList<label> > allPts(3);
|
||||||
@ -355,7 +377,6 @@ void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
|
|||||||
// renumbered edges
|
// renumbered edges
|
||||||
reset(xferMove(pts), xferMove(eds));
|
reset(xferMove(pts), xferMove(eds));
|
||||||
|
|
||||||
|
|
||||||
// Generate the featurePointNormals
|
// Generate the featurePointNormals
|
||||||
|
|
||||||
labelListList featurePointNormals(nonFeatureStart_);
|
labelListList featurePointNormals(nonFeatureStart_);
|
||||||
|
|||||||
Reference in New Issue
Block a user