Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
Andrew Heather
2017-06-01 17:28:21 +01:00
2387 changed files with 119977 additions and 41187 deletions

View File

@ -492,7 +492,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const AABBTree<Type>& tree)
<< tree.addressing_;
}
os.check("Ostream& operator<<(Ostream&, const AABBTree<Type>&)");
os.check(FUNCTION_NAME);
return os;
}
@ -519,7 +519,7 @@ Foam::Istream& Foam::operator>>(Istream& is, AABBTree<Type>& tree)
>> tree.addressing_;
}
is.check("Istream& operator>>(Istream&, AABBTree<Type>&)");
is.check(FUNCTION_NAME);
return is;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -1017,7 +1017,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
mapDistributeBase::distribute
(
Pstream::nonBlocking,
Pstream::commsTypes::nonBlocking,
List<labelPair>(),
tgtPatch.size(),
map.constructMap(),
@ -1032,7 +1032,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
mapDistributeBase::distribute
(
Pstream::nonBlocking,
Pstream::commsTypes::nonBlocking,
List<labelPair>(),
tgtPatch.size(),
map.constructMap(),

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -126,7 +126,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::distributePatches
List<labelList>& faceIDs
) const
{
PstreamBuffers pBufs(Pstream::nonBlocking);
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
for (label domain = 0; domain < Pstream::nProcs(); domain++)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -211,7 +211,8 @@ public:
//- Evaluate the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType=Pstream::blocking
const Pstream::commsTypes commsType =
Pstream::commsTypes::blocking
)
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -211,7 +211,8 @@ public:
//- Evaluate the patch field
virtual void evaluate
(
const Pstream::commsTypes commsType=Pstream::blocking
const Pstream::commsTypes commsType =
Pstream::commsTypes::blocking
)
{}

View File

@ -1,3 +1,50 @@
em = edgeMesh
$(em)/edgeMesh.C
$(em)/edgeMeshIO.C
$(em)/edgeMeshNew.C
edgeMeshFormats = $(em)/edgeMeshFormats
$(edgeMeshFormats)/edgeMeshFormatsCore.C
$(edgeMeshFormats)/edgeMesh/edgeMeshFormat.C
$(edgeMeshFormats)/edgeMesh/edgeMeshFormatRunTime.C
$(edgeMeshFormats)/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshFormat.C
$(edgeMeshFormats)/extendedFeatureEdgeMesh/extendedFeatureEdgeMeshFormatRunTime.C
$(edgeMeshFormats)/nas/NASedgeFormat.C
$(edgeMeshFormats)/nas/NASedgeFormatRunTime.C
$(edgeMeshFormats)/obj/OBJedgeFormat.C
$(edgeMeshFormats)/obj/OBJedgeFormatRunTime.C
$(edgeMeshFormats)/starcd/STARCDedgeFormat.C
$(edgeMeshFormats)/starcd/STARCDedgeFormatRunTime.C
$(edgeMeshFormats)/vtk/VTKedgeFormat.C
$(edgeMeshFormats)/vtk/VTKedgeFormatRunTime.C
edgeMeshTools = $(em)/edgeMeshTools
$(edgeMeshTools)/edgeMeshTools.C
$(edgeMeshTools)/edgeMeshFeatureProximity.C
$(em)/featureEdgeMesh/featureEdgeMesh.C
eem = $(em)/extendedEdgeMesh
$(eem)/extendedEdgeMesh.C
$(eem)/extendedEdgeMeshNew.C
$(eem)/extendedEdgeMeshFormats/extendedEdgeMeshFormat/extendedEdgeMeshFormat.C
$(eem)/extendedEdgeMeshFormats/extendedEdgeMeshFormat/extendedEdgeMeshFormatRunTime.C
efm = $(eem)/extendedFeatureEdgeMesh
$(efm)/extendedFeatureEdgeMesh.C
cellClassification/cellClassification.C
cellClassification/cellInfo.C
@ -22,8 +69,6 @@ $(csys)/coordinateRotation/EulerCoordinateRotation.C
$(csys)/coordinateRotation/STARCDCoordinateRotation.C
$(csys)/coordinateRotation/cylindrical.C
edgeFaceCirculator/edgeFaceCirculator.C
polyMeshZipUpCells/polyMeshZipUpCells.C
primitiveMeshGeometry/primitiveMeshGeometry.C
@ -63,23 +108,24 @@ indexedOctree/treeDataPoint.C
indexedOctree/treeDataPrimitivePatchName.C
indexedOctree/treeDataTriSurface.C
searchableSurface = searchableSurface
$(searchableSurface)/searchableBox.C
$(searchableSurface)/searchableRotatedBox.C
$(searchableSurface)/searchableCylinder.C
$(searchableSurface)/searchableCone.C
$(searchableSurface)/searchableDisk.C
$(searchableSurface)/searchablePlane.C
$(searchableSurface)/searchablePlate.C
$(searchableSurface)/searchableSphere.C
$(searchableSurface)/searchableSurface.C
$(searchableSurface)/searchableSurfaceCollection.C
$(searchableSurface)/searchableSurfaces.C
$(searchableSurface)/searchableSurfacesQueries.C
$(searchableSurface)/searchableSurfaceWithGaps.C
$(searchableSurface)/triSurfaceMesh.C
$(searchableSurface)/closedTriSurfaceMesh.C
$(searchableSurface)/subTriSurfaceMesh.C
searchableSurfaces/closedTriSurfaceMesh/closedTriSurfaceMesh.C
searchableSurfaces/searchableBox/searchableBox.C
searchableSurfaces/searchableCone/searchableCone.C
searchableSurfaces/searchableCylinder/searchableCylinder.C
searchableSurfaces/searchableDisk/searchableDisk.C
searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C
searchableSurfaces/searchablePlane/searchablePlane.C
searchableSurfaces/searchablePlate/searchablePlate.C
searchableSurfaces/searchableRotatedBox/searchableRotatedBox.C
searchableSurfaces/searchableSphere/searchableSphere.C
searchableSurfaces/searchableSurface/searchableSurface.C
searchableSurfaces/searchableSurfaceCollection/searchableSurfaceCollection.C
searchableSurfaces/searchableSurfaces/searchableSurfaces.C
searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C
searchableSurfaces/searchableSurfaceWithGaps/searchableSurfaceWithGaps.C
searchableSurfaces/subTriSurfaceMesh/subTriSurfaceMesh.C
searchableSurfaces/triSurfaceMesh/triSurfaceMesh.C
topoSets = sets/topoSets
$(topoSets)/cellSet.C
@ -175,6 +221,8 @@ triSurface/triangleFuncs/triangleFuncs.C
triSurface/surfaceFeatures/surfaceFeatures.C
triSurface/triSurfaceLoader/triSurfaceLoader.C
triSurface/triSurfaceTools/triSurfaceTools.C
triSurface/triSurfaceTools/triSurfaceCloseness.C
triSurface/triSurfaceTools/triSurfaceCurvature.C
triSurface/triSurfaceTools/geompack/geompack.C
triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C

View File

@ -1,8 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude
LIB_LIBS = \
-ltriSurface \
-lsurfMesh

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -514,7 +514,7 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
// Send all
PstreamBuffers pBufs(Pstream::nonBlocking);
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
forAll(procPatches, i)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -311,7 +311,7 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
{
// 1. Send all point info on processor patches.
PstreamBuffers pBufs(Pstream::nonBlocking);
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
DynamicList<Type> patchInfo;
DynamicList<label> thisPoints;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -155,9 +155,7 @@ public:
//- Update the rotation for a list of cells
virtual void updateCells(const polyMesh&, const labelList&)
{
// do nothing
}
{}
//- Return local-to-global transformation tensor
virtual const tensor& R() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -147,9 +147,7 @@ public:
//- Update the rotation for a list of cells
virtual void updateCells(const polyMesh&, const labelList&)
{
// do nothing
}
{}
//- Return local-to-global transformation tensor
virtual const tensor& R() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -141,9 +141,7 @@ public:
//- Update the rotation for a list of cells
virtual void updateCells(const polyMesh&, const labelList&)
{
// Do nothing
}
{}
//- Return local-to-global transformation tensor
virtual const tensor& R() const

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,10 +49,8 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
if (!cstrIter.found())
{
FatalIOErrorInFunction
(
dict
) << "Unknown coordinateRotation type "
FatalIOErrorInFunction(dict)
<< "Unknown coordinateRotation type "
<< rotType << nl << nl
<< "Valid coordinateRotation types are :" << nl
<< "[default: axes ]"
@ -83,13 +81,10 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
if (!cstrIter.found())
{
FatalIOErrorInFunction
(
dict
) << "Unknown coordinateRotation type "
FatalIOErrorInFunction(dict)
<< "Unknown coordinateRotation type "
<< rotType << nl << nl
<< "Valid coordinateRotation types are :" << nl
<< "[default: axes ]"
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalIOError);
}
@ -97,4 +92,5 @@ Foam::autoPtr<Foam::coordinateRotation> Foam::coordinateRotation::New
return autoPtr<coordinateRotation>(cstrIter()(dict));
}
// ************************************************************************* //

View File

@ -378,7 +378,7 @@ bool Foam::operator!=(const coordinateSystem& a, const coordinateSystem& b)
Foam::Ostream& Foam::operator<<(Ostream& os, const coordinateSystem& cs)
{
cs.write(os);
os.check("Ostream& operator<<(Ostream&, const coordinateSystem&");
os.check(FUNCTION_NAME);
return os;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -86,16 +86,10 @@ class primitiveMesh;
class edgeFaceCirculator
{
// Static data members
// Private Member Data
//- End iterator
static const edgeFaceCirculator endConstIter;
// Private data
//- Mesh
const primitiveMesh& mesh_;
//- The underlying mesh pointer
const primitiveMesh* meshPtr_;
//- Current face
label faceLabel_;
@ -116,16 +110,21 @@ class edgeFaceCirculator
// Private Member Functions
//- The underlying mesh
inline const primitiveMesh& mesh() const;
//- Set to end() iterator
inline void setEnd();
//- Check and set faceLabel_ and ownerSide_
inline void setFace(const label facei, const label celli);
//- Set faceLabel_ to be the other face on the cell that uses the
// edge.
//- Set faceLabel_ to be the other face on the cell that uses the edge.
inline void otherFace(const label celli);
//- Construct null - this is also an end iterator
inline edgeFaceCirculator();
public:
@ -142,7 +141,7 @@ public:
);
//- Construct as copy
inline edgeFaceCirculator(const edgeFaceCirculator&);
inline edgeFaceCirculator(const edgeFaceCirculator& circ);
// Member Functions
@ -156,8 +155,12 @@ public:
const label v1
);
//- Return the face label, -1 for end iterator
inline label faceLabel() const;
//- Return true if the face label corresponds to an internal face
inline bool isInternalFace() const;
inline bool ownerSide() const;
inline label index() const;
@ -194,8 +197,8 @@ public:
inline edgeFaceCirculator cbegin() const;
//- Iterator set to beyond the end of the walk.
inline const edgeFaceCirculator& end() const;
inline const edgeFaceCirculator& cend() const;
inline const edgeFaceCirculator end() const;
inline const edgeFaceCirculator cend() const;
};

View File

@ -27,6 +27,12 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline const Foam::primitiveMesh& Foam::edgeFaceCirculator::mesh() const
{
return *meshPtr_;
}
void Foam::edgeFaceCirculator::setEnd()
{
faceLabel_ = -1;
@ -42,7 +48,7 @@ void Foam::edgeFaceCirculator::setFace
{
faceLabel_ = facei;
if (!isBoundaryEdge_ && !mesh_.isInternalFace(facei))
if (!isBoundaryEdge_ && !mesh().isInternalFace(facei))
{
FatalErrorInFunction
<< "Edge is not defined as boundary edge but still walked to"
@ -54,11 +60,11 @@ void Foam::edgeFaceCirculator::setFace
void Foam::edgeFaceCirculator::otherFace(const label celli)
{
const face& f = mesh_.faces()[faceLabel_];
const face& f = mesh().faces()[faceLabel_];
label v0 = f[index_];
label v1 = f.nextLabel(index_);
const cell& cFaces = mesh_.cells()[celli];
const cell& cFaces = mesh().cells()[celli];
forAll(cFaces, i)
{
@ -66,7 +72,7 @@ void Foam::edgeFaceCirculator::otherFace(const label celli)
if (faceB != faceLabel_)
{
label fp = getMinIndex(mesh_.faces()[faceB], v0, v1);
label fp = getMinIndex(mesh().faces()[faceB], v0, v1);
if (fp >= 0)
{
@ -81,14 +87,24 @@ void Foam::edgeFaceCirculator::otherFace(const label celli)
<< "Could not find next face stepping"
<< " through cell along edge." << endl
<< "face:" << faceLabel_ << " index in face:" << index_
<< " edge:" << mesh_.points()[v0] << mesh_.points()[v1]
<< " edge:" << mesh().points()[v0] << mesh().points()[v1]
<< abort(FatalError);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from components
Foam::edgeFaceCirculator::edgeFaceCirculator()
:
meshPtr_(nullptr),
faceLabel_(-1),
ownerSide_(false),
index_(-1),
isBoundaryEdge_(false),
startFaceLabel_(0)
{}
Foam::edgeFaceCirculator::edgeFaceCirculator
(
const primitiveMesh& mesh,
@ -98,7 +114,7 @@ Foam::edgeFaceCirculator::edgeFaceCirculator
const bool isBoundaryEdge
)
:
mesh_(mesh),
meshPtr_(&mesh),
faceLabel_(faceLabel),
ownerSide_(ownerSide),
index_(index),
@ -107,10 +123,9 @@ Foam::edgeFaceCirculator::edgeFaceCirculator
{}
//- Construct copy
Foam::edgeFaceCirculator::edgeFaceCirculator(const edgeFaceCirculator& circ)
:
mesh_(circ.mesh_),
meshPtr_(circ.meshPtr_),
faceLabel_(circ.faceLabel_),
ownerSide_(circ.ownerSide_),
index_(circ.index_),
@ -158,6 +173,17 @@ Foam::label Foam::edgeFaceCirculator::faceLabel() const
}
bool Foam::edgeFaceCirculator::isInternalFace() const
{
return
(
faceLabel_ >= 0
&& meshPtr_
&& meshPtr_->isInternalFace(faceLabel_)
);
}
bool Foam::edgeFaceCirculator::ownerSide() const
{
return ownerSide_;
@ -174,11 +200,11 @@ Foam::label Foam::edgeFaceCirculator::cellLabel() const
{
if (ownerSide_)
{
return mesh_.faceOwner()[faceLabel_];
return mesh().faceOwner()[faceLabel_];
}
else if (mesh_.isInternalFace(faceLabel_))
else if (mesh().isInternalFace(faceLabel_))
{
return mesh_.faceNeighbour()[faceLabel_];
return mesh().faceNeighbour()[faceLabel_];
}
else
{
@ -189,7 +215,7 @@ Foam::label Foam::edgeFaceCirculator::cellLabel() const
bool Foam::edgeFaceCirculator::sameOrder(const label v0, const label v1) const
{
const face& f = mesh_.faces()[faceLabel_];
const face& f = mesh().faces()[faceLabel_];
label fp = getMinIndex(f, v0, v1);
@ -216,21 +242,21 @@ void Foam::edgeFaceCirculator::setCanonical()
while (true)
{
if (mesh_.isInternalFace(faceLabel_))
if (mesh().isInternalFace(faceLabel_))
{
if (ownerSide_)
{
label celli = mesh_.faceNeighbour()[faceLabel_];
label celli = mesh().faceNeighbour()[faceLabel_];
otherFace(celli);
// Maintain reverse direction of walking
ownerSide_ = (mesh_.faceOwner()[faceLabel_] == celli);
ownerSide_ = (mesh().faceOwner()[faceLabel_] == celli);
}
else
{
label celli = mesh_.faceOwner()[faceLabel_];
label celli = mesh().faceOwner()[faceLabel_];
otherFace(celli);
// Maintain reverse direction of walking
ownerSide_ = (mesh_.faceOwner()[faceLabel_] == celli);
ownerSide_ = (mesh().faceOwner()[faceLabel_] == celli);
}
}
else if (ownerSide_)
@ -239,22 +265,22 @@ void Foam::edgeFaceCirculator::setCanonical()
}
else
{
label celli = mesh_.faceOwner()[faceLabel_];
label celli = mesh().faceOwner()[faceLabel_];
otherFace(celli);
// Maintain reverse direction of walking
ownerSide_ = (mesh_.faceOwner()[faceLabel_] == celli);
ownerSide_ = (mesh().faceOwner()[faceLabel_] == celli);
}
i++;
if (i >= 1000)
{
const face& f = mesh_.faces()[faceLabel_];
const face& f = mesh().faces()[faceLabel_];
FatalErrorInFunction
<< "Walked " << i << " cells around edge "
<< mesh_.points()[f[index_]]
<< mesh_.points()[f.nextLabel(index_)]
<< mesh().points()[f[index_]]
<< mesh().points()[f.nextLabel(index_)]
<< " without reaching a boundary face."
<< " Are you sure this is a boundary edge?"
<< abort(FatalError);
@ -281,15 +307,15 @@ void Foam::edgeFaceCirculator::setCanonical()
break;
}
if (!mesh_.isInternalFace(faceLabel_))
if (!mesh().isInternalFace(faceLabel_))
{
const face& f = mesh_.faces()[faceLabel_];
const face& f = mesh().faces()[faceLabel_];
FatalErrorInFunction
<< "Reached boundary face " << faceLabel_
<< " when walking around internal edge "
<< mesh_.points()[f[index_]]
<< mesh_.points()[f.nextLabel(index_)]
<< mesh().points()[f[index_]]
<< mesh().points()[f.nextLabel(index_)]
<< "." << endl
<< "Are you sure this is an internal edge?"
<< abort(FatalError);
@ -360,10 +386,10 @@ Foam::edgeFaceCirculator::operator++()
else if (ownerSide_)
{
// Step to owner
label celli = mesh_.faceOwner()[faceLabel_];
label celli = mesh().faceOwner()[faceLabel_];
otherFace(celli);
// Maintain direction of walking
ownerSide_ = (mesh_.faceOwner()[faceLabel_] != celli);
ownerSide_ = (mesh().faceOwner()[faceLabel_] != celli);
// Check for internal edge : ends on starting face.
if (!isBoundaryEdge_ && faceLabel_ == startFaceLabel_)
@ -371,13 +397,13 @@ Foam::edgeFaceCirculator::operator++()
setEnd();
}
}
else if (mesh_.isInternalFace(faceLabel_))
else if (mesh().isInternalFace(faceLabel_))
{
// Step to neighbour
label celli = mesh_.faceNeighbour()[faceLabel_];
label celli = mesh().faceNeighbour()[faceLabel_];
otherFace(celli);
// Maintain direction of walking
ownerSide_ = (mesh_.faceOwner()[faceLabel_] != celli);
ownerSide_ = (mesh().faceOwner()[faceLabel_] != celli);
// Check for internal edge : ends on starting face.
if (!isBoundaryEdge_ && faceLabel_ == startFaceLabel_)
@ -399,7 +425,7 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::begin() const
{
edgeFaceCirculator iter
(
mesh_,
*meshPtr_,
faceLabel_,
ownerSide_,
index_,
@ -418,7 +444,7 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cbegin() const
{
edgeFaceCirculator iter
(
mesh_,
*meshPtr_,
faceLabel_,
ownerSide_,
index_,
@ -433,14 +459,14 @@ Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cbegin() const
}
const Foam::edgeFaceCirculator& Foam::edgeFaceCirculator::end() const
const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::end() const
{
return endConstIter;
return edgeFaceCirculator();
}
const Foam::edgeFaceCirculator& Foam::edgeFaceCirculator::cend() const
const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::cend() const
{
return endConstIter;
return edgeFaceCirculator();
}

View File

@ -0,0 +1,411 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMesh.H"
#include "mergePoints.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
#include "ListOps.H"
#include "EdgeMap.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(edgeMesh, 0);
defineRunTimeSelectionTable(edgeMesh, fileExtension);
defineMemberFunctionSelectionTable(edgeMesh,write,fileExtension);
}
Foam::wordHashSet Foam::edgeMesh::readTypes()
{
return wordHashSet(*fileExtensionConstructorTablePtr_);
}
Foam::wordHashSet Foam::edgeMesh::writeTypes()
{
return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
bool Foam::edgeMesh::canReadType
(
const word& ext,
const bool verbose
)
{
return checkSupport
(
readTypes(),
ext,
verbose,
"reading"
);
}
bool Foam::edgeMesh::canWriteType
(
const word& ext,
const bool verbose
)
{
return checkSupport
(
writeTypes(),
ext,
verbose,
"writing"
);
}
bool Foam::edgeMesh::canRead
(
const fileName& name,
const bool verbose
)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return canReadType(ext, verbose);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::edgeMesh::calcPointEdges() const
{
if (pointEdgesPtr_.valid())
{
FatalErrorInFunction
<< "pointEdges already calculated." << abort(FatalError);
}
pointEdgesPtr_.reset(new labelListList(points_.size()));
labelListList& pointEdges = pointEdgesPtr_();
invertManyToMany(pointEdges.size(), edges_, pointEdges);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::edgeMesh::edgeMesh()
:
fileFormats::edgeMeshFormatsCore(),
points_(0),
edges_(0),
pointEdgesPtr_(nullptr)
{}
Foam::edgeMesh::edgeMesh
(
const pointField& points,
const edgeList& edges
)
:
fileFormats::edgeMeshFormatsCore(),
points_(points),
edges_(edges),
pointEdgesPtr_(nullptr)
{}
Foam::edgeMesh::edgeMesh
(
const Xfer<pointField>& pointLst,
const Xfer<edgeList>& edgeLst
)
:
fileFormats::edgeMeshFormatsCore(),
points_(0),
edges_(0),
pointEdgesPtr_(nullptr)
{
points_.transfer(pointLst());
edges_.transfer(edgeLst());
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::edgeMesh::~edgeMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::edgeMesh::clear()
{
points_.clear();
edges_.clear();
pointEdgesPtr_.clear();
}
void Foam::edgeMesh::reset
(
const Xfer<pointField>& pointLst,
const Xfer<edgeList>& edgeLst
)
{
// Take over new primitive data.
// Optimized to avoid overwriting data at all
if (notNull(pointLst))
{
points_.transfer(pointLst());
}
if (notNull(edgeLst))
{
edges_.transfer(edgeLst());
// connectivity likely changed
pointEdgesPtr_.clear();
}
}
void Foam::edgeMesh::transfer(edgeMesh& mesh)
{
points_.transfer(mesh.points_);
edges_.transfer(mesh.edges_);
pointEdgesPtr_ = mesh.pointEdgesPtr_;
}
Foam::Xfer<Foam::edgeMesh> Foam::edgeMesh::xfer()
{
return xferMove(*this);
}
Foam::label Foam::edgeMesh::regions(labelList& edgeRegion) const
{
edgeRegion.setSize(edges_.size());
edgeRegion = -1;
label startEdgeI = 0;
label currentRegion = 0;
while (true)
{
while (startEdgeI < edges_.size() && edgeRegion[startEdgeI] != -1)
{
startEdgeI++;
}
if (startEdgeI == edges_.size())
{
break;
}
// Found edge that has not yet been assigned a region.
// Mark connected region with currentRegion starting at startEdgeI.
edgeRegion[startEdgeI] = currentRegion;
labelList edgesToVisit(1, startEdgeI);
while (edgesToVisit.size())
{
// neighbours of current edgesToVisit
DynamicList<label> newEdgesToVisit(edgesToVisit.size());
// Mark all point connected edges with current region.
forAll(edgesToVisit, i)
{
label edgeI = edgesToVisit[i];
// Mark connected edges
const edge& e = edges_[edgeI];
forAll(e, fp)
{
const labelList& pEdges = pointEdges()[e[fp]];
forAll(pEdges, pEdgeI)
{
label nbrEdgeI = pEdges[pEdgeI];
if (edgeRegion[nbrEdgeI] == -1)
{
edgeRegion[nbrEdgeI] = currentRegion;
newEdgesToVisit.append(nbrEdgeI);
}
}
}
}
edgesToVisit.transfer(newEdgesToVisit);
}
currentRegion++;
}
return currentRegion;
}
void Foam::edgeMesh::scalePoints(const scalar scaleFactor)
{
// avoid bad scaling
if (scaleFactor > 0 && scaleFactor != 1.0)
{
points_ *= scaleFactor;
}
}
void Foam::edgeMesh::mergePoints(const scalar mergeDist)
{
pointField newPoints;
labelList pointMap;
const bool hasMerged = Foam::mergePoints
(
points_,
mergeDist,
false,
pointMap,
newPoints,
vector::zero
);
if (hasMerged)
{
pointEdgesPtr_.clear(); // connectivity change
points_.transfer(newPoints);
forAll(edges_, edgeI)
{
edge& e = edges_[edgeI];
e[0] = pointMap[e[0]];
e[1] = pointMap[e[1]];
}
}
this->mergeEdges();
}
void Foam::edgeMesh::mergeEdges()
{
HashSet<edge, Hash<edge>> uniqEdges(2*edges_.size());
PackedBoolList pointIsUsed(points_.size());
label nUniqEdges = 0;
label nUniqPoints = 0;
forAll(edges_, edgeI)
{
const edge& e = edges_[edgeI];
// Remove degenerate and repeated edges
// - reordering (e[0] < e[1]) is not really necessary
if (e[0] != e[1] && uniqEdges.insert(e))
{
if (nUniqEdges != edgeI)
{
edges_[nUniqEdges] = e;
}
edges_[nUniqEdges].sort();
++nUniqEdges;
if (pointIsUsed.set(e[0], 1))
{
++nUniqPoints;
}
if (pointIsUsed.set(e[1], 1))
{
++nUniqPoints;
}
}
}
if (debug)
{
Info<< "Merging duplicate edges: "
<< (edges_.size() - nUniqEdges)
<< " edges will be deleted, "
<< (points_.size() - nUniqPoints)
<< " unused points will be removed." << endl;
}
if (nUniqEdges < edges_.size())
{
pointEdgesPtr_.clear(); // connectivity change
edges_.setSize(nUniqEdges); // truncate
}
if (nUniqPoints < points_.size())
{
pointEdgesPtr_.clear(); // connectivity change
// build a oldToNew point-map and rewrite the points.
// We can do this simultaneously since the point order is unchanged
// and we are only effectively eliminating some entries.
labelList pointMap(points_.size(), -1);
label newId = 0;
forAll(pointMap, pointi)
{
if (pointIsUsed[pointi])
{
pointMap[pointi] = newId;
if (newId < pointi)
{
// copy down
points_[newId] = points_[pointi];
}
++newId;
}
}
points_.setSize(newId);
// Renumber edges - already sorted (above)
forAll(edges_, edgeI)
{
edge& e = edges_[edgeI];
e[0] = pointMap[e[0]];
e[1] = pointMap[e[1]];
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,291 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::edgeMesh
Description
Points connected by edges.
Can be read from fileName based on extension. Uses ::New factory method
to select the reader and transfer the result.
SourceFiles
edgeMeshI.H
edgeMesh.C
edgeMeshIO.C
edgeMeshNew.C
\*---------------------------------------------------------------------------*/
#ifndef edgeMesh_H
#define edgeMesh_H
#include "pointField.H"
#include "edgeList.H"
#include "edgeMeshFormatsCore.H"
#include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class Istream;
class Ostream;
// Forward declaration of friend functions and operators
class edgeMesh;
Istream& operator>>(Istream& is, edgeMesh& em);
Ostream& operator<<(Ostream& os, const edgeMesh& em);
/*---------------------------------------------------------------------------*\
Class edgeMesh Declaration
\*---------------------------------------------------------------------------*/
class edgeMesh
:
public fileFormats::edgeMeshFormatsCore
{
// Private data
//- Vertices of the edges
pointField points_;
//- The edges defining the boundary
edgeList edges_;
//- From point to edges
mutable autoPtr<labelListList> pointEdgesPtr_;
// Private Member Functions
//- Calculate point-edge addressing (inverse of edges)
void calcPointEdges() const;
protected:
// Protected Member Functions
//- Non-const access to global points
inline pointField& storedPoints();
//- Non-const access to the edges
inline edgeList& storedEdges();
public:
//- Runtime type information
TypeName("edgeMesh");
// Static
//- Can we read this file format?
static bool canRead(const fileName& name, const bool verbose=false);
//- Can we read this file format?
static bool canReadType(const word& ext, const bool verbose=false);
//- Can we write this file format type?
static bool canWriteType(const word& ext, const bool verbose=false);
static wordHashSet readTypes();
static wordHashSet writeTypes();
// Constructors
//- Construct null
edgeMesh();
//- Construct from components
edgeMesh(const pointField& points, const edgeList& edges);
//- Construct by transferring components (points, edges).
edgeMesh
(
const Xfer<pointField>& pointLst,
const Xfer<edgeList>& edgeLst
);
//- Construct as copy
edgeMesh(const edgeMesh& em);
//- Construct from file name (uses extension to determine type)
edgeMesh(const fileName& name);
//- Construct from file name (uses extension to determine type)
edgeMesh(const fileName& name, const word& ext);
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
edgeMesh,
fileExtension,
(
const fileName& name
),
(name)
);
// Selectors
//- Select constructed from filename (explicit extension)
static autoPtr<edgeMesh> New
(
const fileName& name,
const word& ext
);
//- Select constructed from filename (implicit extension)
static autoPtr<edgeMesh> New(const fileName& name);
//- Destructor
virtual ~edgeMesh();
// Member Function Selectors
declareMemberFunctionSelectionTable
(
void,
edgeMesh,
write,
fileExtension,
(
const fileName& name,
const edgeMesh& mesh
),
(name, mesh)
);
//- Write to file
static void write(const fileName& name, const edgeMesh& mesh);
// Member Functions
//- Transfer the contents of the argument and annul the argument
void transfer(edgeMesh&);
//- Transfer contents to the Xfer container
Xfer<edgeMesh> xfer();
// Read
//- Read from file. Chooses reader based on explicit extension
bool read(const fileName& name, const word& ext);
//- Read from file. Chooses reader based on detected extension
virtual bool read(const fileName& name);
// Access
//- Return points
inline const pointField& points() const;
//- Return edges
inline const edgeList& edges() const;
//- Return edges
inline const labelListList& pointEdges() const;
//- Find connected regions. Set region number per edge.
// Returns number of regions.
label regions(labelList& edgeRegion) const;
// Edit
//- Clear all storage
virtual void clear();
//- Reset primitive data (points, edges)
// Note, optimized to avoid overwriting data (with Xfer::null)
virtual void reset
(
const Xfer<pointField>& points,
const Xfer<edgeList>& edges
);
//- Scale points. A non-positive factor is ignored
virtual void scalePoints(const scalar scaleFactor);
//- Geometric merge points (points within mergeDist) prior to
// automatically calling mergeEdges().
virtual void mergePoints(const scalar mergeDist);
//- Merge duplicate edges and eliminate unused points.
virtual void mergeEdges();
// Write
virtual void writeStats(Ostream&) const;
//- Generic write routine. Chooses writer based on extension.
virtual void write(const fileName& name) const
{
write(name, *this);
}
// Member Operators
inline void operator=(const edgeMesh& rhs);
// Ostream Operator
friend Ostream& operator<<(Ostream& os, const edgeMesh& em);
friend Istream& operator>>(Istream& is, edgeMesh& em);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "edgeMeshI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,209 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMeshFormat.H"
#include "IOobject.H"
#include "IFstream.H"
#include "clock.H"
#include "Time.H"
#include "featureEdgeMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::edgeMeshFormat::edgeMeshFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::edgeMeshFormat::read
(
const fileName& filename
)
{
clear();
fileName dir = filename.path();
fileName caseName = dir.name();
fileName rootPath = dir.path();
// Construct dummy time to use as an objectRegistry
Time dummyTime
(
".", //rootPath,
".", //caseName,
"system", //systemName,
"constant", //constantName,
false //enableFunctionObjects
);
// Construct IOobject to re-use the headerOk & readHeader
// (so we can read ascii and binary)
IOobject io
(
filename,
dummyTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (!io.typeHeaderOk<featureEdgeMesh>(false))
{
FatalErrorInFunction
<< "Cannot read file " << filename
<< exit(FatalError);
}
const fileName fName(typeFilePath<featureEdgeMesh>(io));
autoPtr<IFstream> isPtr(new IFstream(fName));
bool ok = false;
if (isPtr().good())
{
Istream& is = isPtr();
ok = io.readHeader(is);
if (ok)
{
ok = read(is, this->storedPoints(), this->storedEdges());
}
}
return ok;
}
bool Foam::fileFormats::edgeMeshFormat::read
(
Istream& is,
pointField& pointLst,
edgeList& edgeLst
)
{
if (!is.good())
{
FatalErrorInFunction
<< "read error "
<< exit(FatalError);
}
// read points:
is >> pointLst;
// read edges:
is >> edgeLst;
return true;
}
Foam::Ostream& Foam::fileFormats::edgeMeshFormat::write
(
Ostream& os,
const pointField& pointLst,
const edgeList& edgeLst
)
{
if (!os.good())
{
FatalErrorInFunction
<< "bad output stream " << os.name()
<< exit(FatalError);
}
os << "\n// points:" << nl << pointLst << nl
<< "\n// edges:" << nl << edgeLst << nl;
IOobject::writeDivider(os);
os.check(FUNCTION_NAME);
return os;
}
void Foam::fileFormats::edgeMeshFormat::write
(
const fileName& filename,
const edgeMesh& mesh
)
{
// Construct dummy time to use as an objectRegistry
Time dummyTime
(
".", //rootPath,
".", //caseName,
"system", //systemName,
"constant", //constantName,
false //enableFunctionObjects
);
// Construct IOobject to re-use the writeHeader
IOobject io
(
filename,
dummyTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
io.note() = "written " + clock::dateTime();
// Note: always write ascii
autoPtr<OFstream> osPtr(new OFstream(filename));
if (!osPtr().good())
{
FatalIOErrorInFunction
(
osPtr()
) << "Cannot open file for writing " << filename
<< exit(FatalIOError);
}
OFstream& os = osPtr();
bool ok = io.writeHeader(os, featureEdgeMesh::typeName);
if (!ok)
{
FatalIOErrorInFunction
(
os
) << "Cannot write header"
<< exit(FatalIOError);
}
write(os, mesh.points(), mesh.edges());
os.check(FUNCTION_NAME);
}
// ************************************************************************* //

View File

@ -0,0 +1,148 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::edgeMeshFormat
Description
Provide a means of reading/writing the single-file OpenFOAM edge format.
Note
This class provides more methods than the regular edge format interface.
SourceFiles
edgeMeshFormat.C
\*---------------------------------------------------------------------------*/
#ifndef edgeMeshFormat_H
#define edgeMeshFormat_H
#include "edgeMesh.H"
#include "Ostream.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class edgeMeshFormat Declaration
\*---------------------------------------------------------------------------*/
class edgeMeshFormat
:
public edgeMesh
{
// Private Member Functions
//- Disallow default bitwise copy construct
edgeMeshFormat(const edgeMeshFormat&);
//- Disallow default bitwise assignment
void operator=(const edgeMeshFormat&);
protected:
// Protected Member Functions
//- Write header information
static void writeHeader
(
Ostream&,
const pointField&,
const edgeList&
);
public:
// Constructors
//- Construct from file name
edgeMeshFormat(const fileName&);
// Selectors
//- Read file and return edgeMesh
static autoPtr<edgeMesh> New(const fileName& name)
{
return autoPtr<edgeMesh>
(
new edgeMeshFormat(name)
);
}
//- Destructor
virtual ~edgeMeshFormat()
{}
// Member Functions
//- Read edgeMesh components from stream
static bool read
(
Istream&,
pointField&,
edgeList&
);
//- Write edgeMesh components to stream
static Ostream& write
(
Ostream&,
const pointField&,
const edgeList&
);
//- Write edgeMesh with a mimicked IOobject header
static void write(const fileName&, const edgeMesh&);
//- Read from file
virtual bool read(const fileName&);
//- Write object
virtual void write(const fileName& name) const
{
write(name, *this);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,23 +23,38 @@ License
\*---------------------------------------------------------------------------*/
#include "edgeFaceCirculator.H"
#include "primitiveMesh.H"
#include "nullObject.H"
#include "edgeMeshFormat.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::edgeFaceCirculator Foam::edgeFaceCirculator::endConstIter
namespace Foam
{
namespace fileFormats
{
// read edgeMesh
addNamedToRunTimeSelectionTable
(
*reinterpret_cast<const primitiveMesh*>
(
NullObject::nullObject.pointer() // nullptr dummy
),
-1, // faceLabel
false, // ownerSide
-1, // index
false // isBoundaryEdge
edgeMesh,
edgeMeshFormat,
fileExtension,
eMesh
);
// write edgeMesh
addNamedToMemberFunctionSelectionTable
(
edgeMesh,
edgeMeshFormat,
write,
fileExtension,
eMesh
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMeshFormatsCore.H"
#include "Time.H"
#include "IFstream.H"
#include "OFstream.H"
#include "edgeMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::word Foam::fileFormats::edgeMeshFormatsCore::nativeExt("eMesh");
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::string Foam::fileFormats::edgeMeshFormatsCore::getLineNoComment
(
IFstream& is
)
{
string line;
do
{
is.getLine(line);
}
while ((line.empty() || line[0] == '#') && is.good());
return line;
}
#if 0
Foam::fileName Foam::fileFormats::edgeMeshFormatsCore::localMeshFileName
(
const word& meshName
)
{
const word name(meshName.size() ? meshName : surfaceRegistry::defaultName);
return fileName
(
surfaceRegistry::prefix/name/surfMesh::meshSubDir
/ name + "." + nativeExt
);
}
Foam::fileName Foam::fileFormats::edgeMeshFormatsCore::findMeshInstance
(
const Time& t,
const word& meshName
)
{
fileName localName = localMeshFileName(meshName);
// Search back through the time directories list to find the time
// closest to and lower than current time
instantList ts = t.times();
label instanceI;
for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
{
if (ts[instanceI].value() <= t.timeOutputValue())
{
break;
}
}
// Noting that the current directory has already been searched
// for mesh data, start searching from the previously stored time directory
if (instanceI >= 0)
{
for (label i = instanceI; i >= 0; --i)
{
if (isFile(t.path()/ts[i].name()/localName))
{
return ts[i].name();
}
}
}
return t.constant();
}
Foam::fileName Foam::fileFormats::edgeMeshFormatsCore::findMeshFile
(
const Time& t,
const word& meshName
)
{
fileName localName = localMeshFileName(meshName);
// Search back through the time directories list to find the time
// closest to and lower than current time
instantList ts = t.times();
label instanceI;
for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
{
if (ts[instanceI].value() <= t.timeOutputValue())
{
break;
}
}
// Noting that the current directory has already been searched
// for mesh data, start searching from the previously stored time directory
if (instanceI >= 0)
{
for (label i = instanceI; i >= 0; --i)
{
fileName testName(t.path()/ts[i].name()/localName);
if (isFile(testName))
{
return testName;
}
}
}
// fallback to "constant"
return t.path()/t.constant()/localName;
}
#endif
bool Foam::fileFormats::edgeMeshFormatsCore::checkSupport
(
const wordHashSet& available,
const word& ext,
const bool verbose,
const word& functionName
)
{
if (available.found(ext))
{
return true;
}
else if (verbose)
{
wordList known = available.sortedToc();
Info<<"Unknown file extension for " << functionName
<< " : " << ext << nl
<<"Valid types: (";
// compact output:
forAll(known, i)
{
Info<<" " << known[i];
}
Info<<" )" << endl;
}
return false;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::edgeMeshFormatsCore::edgeMeshFormatsCore()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fileFormats::edgeMeshFormatsCore::~edgeMeshFormatsCore()
{}
// ************************************************************************* //

View File

@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::edgeMeshFormatsCore
Description
A collection of helper functions for reading/writing edge formats.
SourceFiles
edgeMeshFormatsCore.C
\*---------------------------------------------------------------------------*/
#ifndef edgeMeshFormatsCore_H
#define edgeMeshFormatsCore_H
#include "Map.H"
#include "HashSet.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class IFstream;
class Time;
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class edgeMeshFormatsCore Declaration
\*---------------------------------------------------------------------------*/
class edgeMeshFormatsCore
{
protected:
// Protected Member Functions
//- Read non-comment line
static string getLineNoComment(IFstream&);
public:
// Static Data
//- The file extension corresponding to 'native' edge format
// Normally "eMesh" (edge-mesh)
static word nativeExt;
// Static Member Functions
static bool checkSupport
(
const wordHashSet& available,
const word& ext,
const bool verbose,
const word& functionName
);
// //- Return the local file name (within time directory)
// // NEEDS FIXING
// static fileName localMeshFileName(const word& edgeName="");
// //- Find instance with edgeName
// // NEEDS FIXING
// static fileName findMeshInstance
// (
// const Time&,
// const word& edgeName=""
// );
// //- Find mesh file with edgeName
// // NEEDS FIXING
// static fileName findMeshFile(const Time&, const word& edgeName="");
// Constructors
//- Construct null
edgeMeshFormatsCore();
//- Destructor
virtual ~edgeMeshFormatsCore();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,67 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedFeatureEdgeMeshFormat.H"
#include "edgeMeshFormat.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::extendedFeatureEdgeMeshFormat::extendedFeatureEdgeMeshFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::extendedFeatureEdgeMeshFormat::read
(
const fileName& filename
)
{
clear();
IFstream is(filename);
if (!is.good())
{
FatalErrorInFunction
<< "Cannot read file " << filename
<< exit(FatalError);
}
return fileFormats::edgeMeshFormat::read
(
is,
this->storedPoints(),
this->storedEdges()
);
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::extendedFeatureEdgeMeshFormat
Description
Provide a means of reading extendedFeatureEdgeMesh as featureEdgeMesh
SourceFiles
extendedFeatureEdgeMeshFormat.C
\*---------------------------------------------------------------------------*/
#ifndef extendedFeatureEdgeMeshFormat_H
#define extendedFeatureEdgeMeshFormat_H
#include "edgeMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class extendedFeatureEdgeMeshFormat Declaration
\*---------------------------------------------------------------------------*/
class extendedFeatureEdgeMeshFormat
:
public edgeMesh
{
// Private Member Functions
//- Disallow default bitwise copy construct
extendedFeatureEdgeMeshFormat(const extendedFeatureEdgeMeshFormat&);
//- Disallow default bitwise assignment
void operator=(const extendedFeatureEdgeMeshFormat&);
public:
// Constructors
//- Construct from file name
extendedFeatureEdgeMeshFormat(const fileName&);
// Selectors
//- Read file and return surface
static autoPtr<edgeMesh> New(const fileName& name)
{
return autoPtr<edgeMesh>
(
new extendedFeatureEdgeMeshFormat(name)
);
}
//- Destructor
virtual ~extendedFeatureEdgeMeshFormat()
{}
// Member Functions
//- Read from file
virtual bool read(const fileName&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedFeatureEdgeMeshFormat.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
// read extendedEdgeMesh
addNamedToRunTimeSelectionTable
(
edgeMesh,
extendedFeatureEdgeMeshFormat,
fileExtension,
featureEdgeMesh
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,236 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "NASedgeFormat.H"
#include "IFstream.H"
#include "IStringStream.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::NASedgeFormat::NASedgeFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::NASedgeFormat::read
(
const fileName& filename
)
{
clear();
IFstream is(filename);
if (!is.good())
{
FatalErrorInFunction
<< "Cannot read file " << filename
<< exit(FatalError);
}
DynamicList<point> dynPoints;
DynamicList<edge> dynEdges;
DynamicList<label> pointId; // Nastran index of points
while (is.good())
{
string line;
is.getLine(line);
// Skip empty or comment
if (line.empty() || line[0] == '$')
{
continue;
}
// Check if character 72 is continuation
if (line.size() > 72 && line[72] == '+')
{
line = line.substr(0, 72);
while (true)
{
string buf;
is.getLine(buf);
if (buf.size() > 72 && buf[72] == '+')
{
line += buf.substr(8, 64);
}
else
{
line += buf.substr(8, buf.size()-8);
break;
}
}
}
// Read first word
IStringStream lineStream(line);
word cmd;
lineStream >> cmd;
if (cmd == "CBEAM" || cmd == "CROD")
{
edge e;
// label groupId = readLabel(IStringStream(line.substr(16,8))());
e[0] = readLabel(IStringStream(line.substr(24,8))());
e[1] = readLabel(IStringStream(line.substr(32,8))());
// discard groupID
dynEdges.append(e);
}
else if (cmd == "PLOTEL")
{
edge e;
// label groupId = readLabel(IStringStream(line.substr(16,8))());
e[0] = readLabel(IStringStream(line.substr(16,8))());
e[1] = readLabel(IStringStream(line.substr(24,8))());
// discard groupID
dynEdges.append(e);
}
else if (cmd == "GRID")
{
label index = readLabel(IStringStream(line.substr(8,8))());
scalar x = parseNASCoord(line.substr(24, 8));
scalar y = parseNASCoord(line.substr(32, 8));
scalar z = parseNASCoord(line.substr(40, 8));
pointId.append(index);
dynPoints.append(point(x, y, z));
}
else if (cmd == "GRID*")
{
// Long format is on two lines with '*' continuation symbol
// on start of second line.
// Typical line (spaces compacted)
// GRID* 126 0 -5.55999875E+02 -5.68730474E+02
// * 2.14897901E+02
label index = readLabel(IStringStream(line.substr(8,16))());
scalar x = parseNASCoord(line.substr(40, 16));
scalar y = parseNASCoord(line.substr(56, 16));
is.getLine(line);
if (line[0] != '*')
{
FatalErrorInFunction
<< "Expected continuation symbol '*' when reading GRID*"
<< " (double precision coordinate) format" << nl
<< "Read:" << line << nl
<< "File:" << is.name() << " line:" << is.lineNumber()
<< exit(FatalError);
}
scalar z = parseNASCoord(line.substr(8, 16));
pointId.append(index);
dynPoints.append(point(x, y, z));
}
}
// transfer to normal lists
storedPoints().transfer(dynPoints);
pointId.shrink();
dynEdges.shrink();
// Build inverse mapping (NASTRAN pointId -> index)
Map<label> mapPointId(2*pointId.size());
forAll(pointId, i)
{
mapPointId.insert(pointId[i], i);
}
// note which points were really used and which can be culled
PackedBoolList usedPoints(points().size());
// Pass1: relabel edges
// ~~~~~~~~~~~~~~~~~~~~
forAll(dynEdges, i)
{
edge& e = dynEdges[i];
e[0] = mapPointId[e[0]];
e[1] = mapPointId[e[1]];
usedPoints.set(e[0]);
usedPoints.set(e[1]);
}
pointId.clearStorage();
mapPointId.clear();
// not all the points were used, cull them accordingly
if (unsigned(points().size()) != usedPoints.count())
{
label nUsed = 0;
pointField& pts = storedPoints();
forAll(pts, pointi)
{
if (usedPoints.get(pointi))
{
if (nUsed != pointi)
{
pts[nUsed] = pts[pointi];
}
// map prev -> new id
mapPointId[pointi] = nUsed;
++nUsed;
}
}
pts.setSize(nUsed);
// renumber edge vertices
forAll(dynEdges, edgeI)
{
edge& e = dynEdges[edgeI];
e[0] = mapPointId[e[0]];
e[1] = mapPointId[e[1]];
}
}
// transfer to normal lists
storedEdges().transfer(dynEdges);
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::NASedgeFormat
Description
Nastran edge reader.
SourceFiles
NASedgeFormat.C
\*---------------------------------------------------------------------------*/
#ifndef NASedgeFormat_H
#define NASedgeFormat_H
#include "edgeMesh.H"
#include "NASCore.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class NASedgeFormat Declaration
\*---------------------------------------------------------------------------*/
class NASedgeFormat
:
public edgeMesh,
public NASCore
{
// Private Member Functions
//- Disallow default bitwise copy construct
NASedgeFormat(const NASedgeFormat&);
//- Disallow default bitwise assignment
void operator=(const NASedgeFormat&);
public:
// Constructors
//- Construct from file name
NASedgeFormat(const fileName&);
// Selectors
//- Read file and return edge mesh
static autoPtr<edgeMesh> New(const fileName& name)
{
return autoPtr<edgeMesh>
(
new NASedgeFormat(name)
);
}
//- Destructor
virtual ~NASedgeFormat()
{}
// Member Functions
//- Read from a file
virtual bool read(const fileName&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "NASedgeFormat.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
// read edgeMesh - .bdf (Bulk Data Format)
addNamedToRunTimeSelectionTable
(
edgeMesh,
NASedgeFormat,
fileExtension,
bdf
);
// read edgeMesh - .nas (Nastran Data Format)
addNamedToRunTimeSelectionTable
(
edgeMesh,
NASedgeFormat,
fileExtension,
nas
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,279 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "OBJedgeFormat.H"
#include "clock.H"
#include "IFstream.H"
#include "IStringStream.H"
#include "Ostream.H"
#include "OFstream.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::OBJedgeFormat::OBJedgeFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fileFormats::OBJedgeFormat::readVertices
(
const string& line,
string::size_type& endNum,
DynamicList<label>& dynVertices
)
{
dynVertices.clear();
while (true)
{
string::size_type startNum =
line.find_first_not_of(' ', endNum);
if (startNum == string::npos)
{
break;
}
endNum = line.find(' ', startNum);
string vertexSpec;
if (endNum != string::npos)
{
vertexSpec = line.substr(startNum, endNum-startNum);
}
else
{
vertexSpec = line.substr(startNum, line.size() - startNum);
}
string::size_type slashPos = vertexSpec.find('/');
label vertI = 0;
if (slashPos != string::npos)
{
IStringStream intStream(vertexSpec.substr(0, slashPos));
intStream >> vertI;
}
else
{
IStringStream intStream(vertexSpec);
intStream >> vertI;
}
dynVertices.append(vertI - 1);
}
}
bool Foam::fileFormats::OBJedgeFormat::read(const fileName& filename)
{
clear();
IFstream is(filename);
if (!is.good())
{
FatalErrorInFunction
<< "Cannot read file " << filename
<< exit(FatalError);
}
DynamicList<point> dynPoints;
DynamicList<edge> dynEdges;
DynamicList<label> dynUsedPoints;
DynamicList<label> dynVertices;
while (is.good())
{
string line = this->getLineNoComment(is);
// handle continuations
if (line[line.size()-1] == '\\')
{
line.substr(0, line.size()-1);
line += this->getLineNoComment(is);
}
// Read first word
IStringStream lineStream(line);
word cmd;
lineStream >> cmd;
if (cmd == "v")
{
scalar x, y, z;
lineStream >> x >> y >> z;
dynPoints.append(point(x, y, z));
dynUsedPoints.append(-1);
}
else if (cmd == "l")
{
// Assume 'l' is followed by space.
string::size_type endNum = 1;
readVertices
(
line,
endNum,
dynVertices
);
for (label i = 1; i < dynVertices.size(); i++)
{
edge edgeRead(dynVertices[i-1], dynVertices[i]);
dynUsedPoints[edgeRead[0]] = edgeRead[0];
dynUsedPoints[edgeRead[1]] = edgeRead[1];
dynEdges.append(edgeRead);
}
}
else if (cmd == "f")
{
// Support for faces with 2 vertices
// Assume 'f' is followed by space.
string::size_type endNum = 1;
readVertices
(
line,
endNum,
dynVertices
);
if (dynVertices.size() == 2)
{
for (label i = 1; i < dynVertices.size(); i++)
{
edge edgeRead(dynVertices[i-1], dynVertices[i]);
dynUsedPoints[edgeRead[0]] = edgeRead[0];
dynUsedPoints[edgeRead[1]] = edgeRead[1];
dynEdges.append(edgeRead);
}
}
}
}
// cull unused points
label nUsed = 0;
forAll(dynPoints, pointi)
{
if (dynUsedPoints[pointi] >= 0)
{
if (nUsed != pointi)
{
dynPoints[nUsed] = dynPoints[pointi];
dynUsedPoints[pointi] = nUsed; // new position
}
++nUsed;
}
}
dynPoints.setSize(nUsed);
// transfer to normal lists
storedPoints().transfer(dynPoints);
// renumber edge vertices
if (nUsed != dynUsedPoints.size())
{
forAll(dynEdges, edgeI)
{
edge& e = dynEdges[edgeI];
e[0] = dynUsedPoints[e[0]];
e[1] = dynUsedPoints[e[1]];
}
}
storedEdges().transfer(dynEdges);
return true;
}
void Foam::fileFormats::OBJedgeFormat::write
(
const fileName& filename,
const edgeMesh& mesh
)
{
const pointField& pointLst = mesh.points();
const edgeList& edgeLst = mesh.edges();
OFstream os(filename);
if (!os.good())
{
FatalErrorInFunction
<< "Cannot open file for writing " << filename
<< exit(FatalError);
}
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
<< "o " << os.name().nameLessExt() << nl
<< nl
<< "# points : " << pointLst.size() << nl
<< "# lines : " << edgeLst.size() << nl;
os << nl
<< "# <points count=\"" << pointLst.size() << "\">" << nl;
// Write vertex coords
forAll(pointLst, ptI)
{
const point& p = pointLst[ptI];
os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl;
}
os << "# </points>" << nl
<< nl
<< "# <edges count=\"" << edgeLst.size() << "\">" << endl;
// Write line connectivity
forAll(edgeLst, edgeI)
{
const edge& e = edgeLst[edgeI];
os << "l " << (e[0] + 1) << " " << (e[1] + 1) << nl;
}
os << "# </edges>" << endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,126 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::OBJedgeFormat
Description
Provide a means of reading/writing Alias/Wavefront OBJ format.
Does not handle negative vertex indices.
SourceFiles
OBJedgeFormat.C
\*---------------------------------------------------------------------------*/
#ifndef OBJedgeFormat_H
#define OBJedgeFormat_H
#include "edgeMesh.H"
#include "IFstream.H"
#include "Ostream.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class OBJedgeFormat Declaration
\*---------------------------------------------------------------------------*/
class OBJedgeFormat
:
public edgeMesh
{
// Private Member Functions
void readVertices
(
const string& line,
string::size_type& endNum,
DynamicList<label>& dynVertices
);
//- Disallow default bitwise copy construct
OBJedgeFormat(const OBJedgeFormat&);
//- Disallow default bitwise assignment
void operator=(const OBJedgeFormat&);
public:
// Constructors
//- Construct from file name
OBJedgeFormat(const fileName&);
// Selectors
//- Read file and return surface
static autoPtr<edgeMesh> New(const fileName& name)
{
return autoPtr<edgeMesh>
(
new OBJedgeFormat(name)
);
}
//- Destructor
virtual ~OBJedgeFormat()
{}
// Member Functions
//- Write surface mesh components by proxy
static void write(const fileName&, const edgeMesh&);
//- Read from file
virtual bool read(const fileName&);
//- Write object file
virtual void write(const fileName& name) const
{
write(name, *this);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "OBJedgeFormat.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
// read edgeMesh
addNamedToRunTimeSelectionTable
(
edgeMesh,
OBJedgeFormat,
fileExtension,
obj
);
// write edgeMesh
addNamedToMemberFunctionSelectionTable
(
edgeMesh,
OBJedgeFormat,
write,
fileExtension,
obj
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,263 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "STARCDedgeFormat.H"
#include "ListOps.H"
#include "clock.H"
#include "PackedBoolList.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline void Foam::fileFormats::STARCDedgeFormat::writeLines
(
Ostream& os,
const edgeList& edges
)
{
writeHeader(os, STARCDCore::HEADER_CEL);
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
const label cellId = edgeI + 1;
os << cellId // includes 1 offset
<< ' ' << starcdLine // 2(line) shape
<< ' ' << e.size()
<< ' ' << 401 // arbitrary value
<< ' ' << starcdLineType; // 5(line)
os << nl << " " << cellId << " "
<< (e[0]+1) << " " << (e[1]+1) << nl;
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fileFormats::STARCDedgeFormat::writeCase
(
Ostream& os,
const pointField& pointLst,
const label nEdges
)
{
const word caseName = os.name().nameLessExt();
os << "! STAR-CD file written " << clock::dateTime().c_str() << nl
<< "! " << pointLst.size() << " points, " << nEdges << " lines" << nl
<< "! case " << caseName << nl
<< "! ------------------------------" << nl;
// forAll(zoneLst, zoneI)
// {
// os << "ctable " << zoneI + 1 << " line" << nl
// << "ctname " << zoneI + 1 << " "
// << zoneLst[zoneI].name() << nl;
// }
os << "! ------------------------------" << nl
<< "*set icvo mxv - 1" << nl
<< "vread " << caseName << ".vrt icvo,,,coded" << nl
<< "cread " << caseName << ".cel icvo,,,add,coded" << nl
<< "*set icvo" << nl
<< "! end" << nl;
os.flush();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::STARCDedgeFormat::STARCDedgeFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::STARCDedgeFormat::read
(
const fileName& filename
)
{
clear();
fileName baseName = filename.lessExt();
// STAR-CD index of points
List<label> pointId;
// read points from .vrt file
readPoints
(
IFstream(starFileName(baseName, STARCDCore::VRT_FILE))(),
storedPoints(),
pointId
);
// Build inverse mapping (STAR-CD pointId -> index)
Map<label> mapPointId(2*pointId.size());
forAll(pointId, i)
{
mapPointId.insert(pointId[i], i);
}
pointId.clear();
// note which points were really used and which can be culled
PackedBoolList usedPoints(points().size());
//
// read .cel file
// ~~~~~~~~~~~~~~
IFstream is(starFileName(baseName, STARCDCore::CEL_FILE));
if (!is.good())
{
FatalErrorInFunction
<< "Cannot read file " << is.name()
<< exit(FatalError);
}
readHeader(is, STARCDCore::HEADER_CEL);
DynamicList<edge> dynEdges;
label lineLabel, shapeId, nLabels, cellTableId, typeId;
DynamicList<label> vertexLabels(64);
while ((is >> lineLabel).good())
{
is >> shapeId >> nLabels >> cellTableId >> typeId;
vertexLabels.clear();
vertexLabels.reserve(nLabels);
// read indices - max 8 per line
for (label i = 0; i < nLabels; ++i)
{
label vrtId;
if ((i % 8) == 0)
{
is >> lineLabel;
}
is >> vrtId;
// convert original vertex id to point label
vertexLabels.append(mapPointId[vrtId]);
}
if (typeId == starcdLineType)
{
if (vertexLabels.size() >= 2)
{
dynEdges.append(edge(vertexLabels[0], vertexLabels[1]));
usedPoints.set(vertexLabels[0]);
usedPoints.set(vertexLabels[1]);
}
}
}
mapPointId.clear();
// not all the points were used, cull them accordingly
if (unsigned(points().size()) != usedPoints.count())
{
label nUsed = 0;
pointField& pts = storedPoints();
forAll(pts, pointi)
{
if (usedPoints.get(pointi))
{
if (nUsed != pointi)
{
pts[nUsed] = pts[pointi];
}
// map prev -> new id
mapPointId.set(pointi, nUsed);
++nUsed;
}
}
pts.setSize(nUsed);
// renumber edge vertices
forAll(dynEdges, edgeI)
{
edge& e = dynEdges[edgeI];
e[0] = mapPointId[e[0]];
e[1] = mapPointId[e[1]];
}
}
storedEdges().transfer(dynEdges);
return true;
}
void Foam::fileFormats::STARCDedgeFormat::write
(
const fileName& filename,
const edgeMesh& mesh
)
{
const pointField& pointLst = mesh.points();
const edgeList& edgeLst = mesh.edges();
fileName baseName = filename.lessExt();
writePoints
(
OFstream(starFileName(baseName, STARCDCore::VRT_FILE))(),
pointLst
);
writeLines
(
OFstream(starFileName(baseName, STARCDCore::CEL_FILE))(),
edgeLst
);
// write a simple .inp file
writeCase
(
OFstream(starFileName(baseName, STARCDCore::INP_FILE))(),
pointLst,
edgeLst.size()
);
}
// ************************************************************************* //

View File

@ -0,0 +1,142 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::STARCDedgeFormat
Description
Read/write the lines from pro-STAR vrt/cel files.
Note
Uses the extension \a .inp (input) to denote the format.
See also
Foam::meshReaders::STARCD
SourceFiles
STARCDedgeFormat.C
\*---------------------------------------------------------------------------*/
#ifndef STARCDedgeFormat_H
#define STARCDedgeFormat_H
#include "edgeMesh.H"
#include "STARCDCore.H"
#include "IFstream.H"
#include "Ostream.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class STARCDedgeFormat Declaration
\*---------------------------------------------------------------------------*/
class STARCDedgeFormat
:
public edgeMesh,
protected STARCDCore
{
// Private Member Functions
static inline void writeLines(Ostream&, const edgeList&);
//- Disallow default bitwise copy construct
STARCDedgeFormat(const STARCDedgeFormat&) = delete;
//- Disallow default bitwise assignment
void operator=(const STARCDedgeFormat&) = delete;
protected:
// Protected Member Functions
static void writeCase
(
Ostream&,
const pointField&,
const label nEdges
);
public:
// Constructors
//- Construct from file name
STARCDedgeFormat(const fileName&);
// Selectors
//- Read file and return edgeMesh
static autoPtr<edgeMesh> New(const fileName& name)
{
return autoPtr<edgeMesh>
(
new STARCDedgeFormat(name)
);
}
//- Destructor
virtual ~STARCDedgeFormat()
{}
// Member Functions
//- Write edge mesh
static void write(const fileName&, const edgeMesh&);
//- Read from file
virtual bool read(const fileName&);
//- Write object
virtual void write(const fileName& name) const
{
write(name, *this);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "STARCDedgeFormat.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
// read edgeMesh
addNamedToRunTimeSelectionTable
(
edgeMesh,
STARCDedgeFormat,
fileExtension,
inp
);
// write edgeMesh
addNamedToMemberFunctionSelectionTable
(
edgeMesh,
STARCDedgeFormat,
write,
fileExtension,
inp
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,173 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VTKedgeFormat.H"
#include "OFstream.H"
#include "clock.H"
#include "IFstream.H"
#include "vtkUnstructuredReader.H"
#include "Time.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fileFormats::VTKedgeFormat::writeHeader
(
Ostream& os,
const pointField& pointLst
)
{
// Write header
os << "# vtk DataFile Version 2.0" << nl
<< "featureEdgeMesh written " << clock::dateTime().c_str() << nl
<< "ASCII" << nl
<< nl
<< "DATASET POLYDATA" << nl;
// Write vertex coords
os << "POINTS " << pointLst.size() << " float" << nl;
forAll(pointLst, ptI)
{
const point& pt = pointLst[ptI];
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
}
void Foam::fileFormats::VTKedgeFormat::writeEdges
(
Ostream& os,
const UList<edge>& edgeLst
)
{
os << "LINES " << edgeLst.size() << ' ' << 3*edgeLst.size() << nl;
forAll(edgeLst, edgeI)
{
const edge& e = edgeLst[edgeI];
os << "2 " << e[0] << ' ' << e[1] << nl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::VTKedgeFormat::VTKedgeFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::VTKedgeFormat::read
(
const fileName& filename
)
{
IFstream is(filename);
if (!is.good())
{
FatalErrorInFunction
<< "Cannot read file " << filename
<< exit(FatalError);
}
// Construct dummy time so we have something to create an objectRegistry
// from
Time dummyTime
(
"dummyRoot",
"dummyCase",
"system",
"constant",
false // enableFunctionObjects
);
// Make dummy object registry
objectRegistry obr
(
IOobject
(
"dummy",
dummyTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
);
// Construct reader to read file
vtkUnstructuredReader reader(obr, is);
// Extract lines
storedPoints().transfer(reader.points());
label nEdges = 0;
forAll(reader.lines(), lineI)
{
nEdges += reader.lines()[lineI].size()-1;
}
storedEdges().setSize(nEdges);
nEdges = 0;
forAll(reader.lines(), lineI)
{
const labelList& verts = reader.lines()[lineI];
for (label i = 1; i < verts.size(); i++)
{
storedEdges()[nEdges++] = edge(verts[i-1], verts[i]);
}
}
return true;
}
void Foam::fileFormats::VTKedgeFormat::write
(
const fileName& filename,
const edgeMesh& eMesh
)
{
OFstream os(filename);
if (!os.good())
{
FatalErrorInFunction
<< "Cannot open file for writing " << filename
<< exit(FatalError);
}
writeHeader(os, eMesh.points());
writeEdges(os, eMesh.edges());
}
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::VTKedgeFormat
Description
Provide a means of writing VTK legacy format.
SourceFiles
VTKedgeFormat.C
\*---------------------------------------------------------------------------*/
#ifndef VTKedgeFormat_H
#define VTKedgeFormat_H
#include "edgeMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class VTKedgeFormat Declaration
\*---------------------------------------------------------------------------*/
class VTKedgeFormat
:
public edgeMesh
{
// Private Member Functions
//- Disallow default bitwise copy construct
VTKedgeFormat(const VTKedgeFormat&);
//- Disallow default bitwise assignment
void operator=(const VTKedgeFormat&);
protected:
// Protected Member Functions
//- Write header information with points
static void writeHeader
(
Ostream&,
const pointField&
);
//- Write edges
static void writeEdges(Ostream&, const UList<edge>&);
public:
// Constructors
//- Construct from file name
VTKedgeFormat(const fileName&);
// Selectors
//- Read file and return surface
static autoPtr<edgeMesh> New(const fileName& name)
{
return autoPtr<edgeMesh>
(
new VTKedgeFormat(name)
);
}
//- Destructor
virtual ~VTKedgeFormat()
{}
// Member Functions
//- Write surface mesh components by proxy
static void write(const fileName&, const edgeMesh&);
//- Read from file
virtual bool read(const fileName&);
//- Write object file
virtual void write(const fileName& name) const
{
write(name, *this);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "VTKedgeFormat.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
// read edgeMesh
addNamedToRunTimeSelectionTable
(
edgeMesh,
VTKedgeFormat,
fileExtension,
vtk
);
// write edgeMesh
addNamedToMemberFunctionSelectionTable
(
edgeMesh,
VTKedgeFormat,
write,
fileExtension,
vtk
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
inline Foam::pointField& Foam::edgeMesh::storedPoints()
{
return points_;
}
inline Foam::edgeList& Foam::edgeMesh::storedEdges()
{
return edges_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::edgeMesh::edgeMesh(const edgeMesh& em)
:
fileFormats::edgeMeshFormatsCore(),
points_(em.points_),
edges_(em.edges_),
pointEdgesPtr_(nullptr)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::pointField& Foam::edgeMesh::points() const
{
return points_;
}
inline const Foam::edgeList& Foam::edgeMesh::edges() const
{
return edges_;
}
inline const Foam::labelListList& Foam::edgeMesh::pointEdges() const
{
if (pointEdgesPtr_.empty())
{
calcPointEdges();
}
return pointEdgesPtr_();
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::edgeMesh::operator=(const edgeMesh& rhs)
{
points_ = rhs.points_;
edges_ = rhs.edges_;
pointEdgesPtr_.clear();
}
// ************************************************************************* //

View File

@ -0,0 +1,147 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMesh.H"
#include "boundBox.H"
#include "edgeMeshFormat.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::edgeMesh::edgeMesh
(
const fileName& name,
const word& ext
)
:
points_(0),
edges_(0),
pointEdgesPtr_(nullptr)
{
read(name, ext);
}
Foam::edgeMesh::edgeMesh(const fileName& name)
:
points_(0),
edges_(0),
pointEdgesPtr_(nullptr)
{
read(name);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::edgeMesh::read(const fileName& name)
{
word ext = name.ext();
if (ext == "gz")
{
fileName unzipName = name.lessExt();
return read(unzipName, unzipName.ext());
}
else
{
return read(name, ext);
}
}
// Read from file in given format
bool Foam::edgeMesh::read
(
const fileName& name,
const word& ext
)
{
// read via selector mechanism
transfer(New(name, ext)());
return true;
}
void Foam::edgeMesh::write
(
const fileName& name,
const edgeMesh& mesh
)
{
if (debug)
{
InfoInFunction << "Writing to " << name << endl;
}
const word ext = name.ext();
writefileExtensionMemberFunctionTable::iterator mfIter =
writefileExtensionMemberFunctionTablePtr_->find(ext);
if (!mfIter.found())
{
FatalErrorInFunction
<< "Unknown file extension " << ext << nl << nl
<< "Valid types are :" << endl
<< writefileExtensionMemberFunctionTablePtr_->sortedToc()
<< exit(FatalError);
}
else
{
mfIter()(name, mesh);
}
}
void Foam::edgeMesh::writeStats(Ostream& os) const
{
os << indent << "points : " << points().size() << nl;
os << indent << "edges : " << edges().size() << nl;
os << indent << "boundingBox : " << boundBox(this->points()) << endl;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const edgeMesh& em)
{
fileFormats::edgeMeshFormat::write(os, em.points_, em.edges_);
os.check(FUNCTION_NAME);
return os;
}
Foam::Istream& Foam::operator>>(Istream& is, edgeMesh& em)
{
fileFormats::edgeMeshFormat::read(is, em.points_, em.edges_);
em.pointEdgesPtr_.clear();
is.check(FUNCTION_NAME);
return is;
}
// ************************************************************************* //

View File

@ -0,0 +1,64 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMesh.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::edgeMesh> Foam::edgeMesh::New
(
const fileName& name,
const word& ext
)
{
fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(ext);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown file extension " << ext
<< " for file " << name << nl << nl
<< "Valid extensions are :" << nl
<< fileExtensionConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<edgeMesh>(cstrIter()(name));
}
Foam::autoPtr<Foam::edgeMesh> Foam::edgeMesh::New(const fileName& name)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return New(name, ext);
}
// ************************************************************************* //

View File

@ -0,0 +1,228 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMeshTools.H"
#include "extendedEdgeMesh.H"
#include "triSurface.H"
#include "triSurfaceFields.H"
#include "pointIndexHit.H"
#include "MeshedSurface.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
static scalar calcProximityOfFeaturePoints
(
const List<pointIndexHit>& hitList,
const scalar defaultCellSize
)
{
scalar minDist = defaultCellSize;
for
(
label hI1 = 0;
hI1 < hitList.size() - 1;
++hI1
)
{
const pointIndexHit& pHit1 = hitList[hI1];
if (pHit1.hit())
{
for
(
label hI2 = hI1 + 1;
hI2 < hitList.size();
++hI2
)
{
const pointIndexHit& pHit2 = hitList[hI2];
if (pHit2.hit())
{
scalar curDist = mag(pHit1.hitPoint() - pHit2.hitPoint());
minDist = min(curDist, minDist);
}
}
}
}
return minDist;
}
scalar calcProximityOfFeatureEdges
(
const edgeMesh& emesh,
const List<pointIndexHit>& hitList,
const scalar defaultCellSize
)
{
scalar minDist = defaultCellSize;
for
(
label hI1 = 0;
hI1 < hitList.size() - 1;
++hI1
)
{
const pointIndexHit& pHit1 = hitList[hI1];
if (pHit1.hit())
{
const edge& e1 = emesh.edges()[pHit1.index()];
for
(
label hI2 = hI1 + 1;
hI2 < hitList.size();
++hI2
)
{
const pointIndexHit& pHit2 = hitList[hI2];
if (pHit2.hit())
{
const edge& e2 = emesh.edges()[pHit2.index()];
// Don't refine if the edges are connected to each other
if (!e1.connects(e2))
{
scalar curDist =
mag(pHit1.hitPoint() - pHit2.hitPoint());
minDist = min(curDist, minDist);
}
}
}
}
}
return minDist;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::edgeMeshTools::featureProximity
(
const extendedEdgeMesh& emesh,
const triSurface& surf,
const scalar searchDistance
)
{
tmp<scalarField> tfld(new scalarField(surf.size(), searchDistance));
scalarField& featureProximity = tfld.ref();
Info<< "Extracting proximity of close feature points and "
<< "edges to the surface" << endl;
forAll(surf, fI)
{
const triPointRef& tri = surf[fI].tri(surf.points());
const point& triCentre = tri.circumCentre();
const scalar radiusSqr = min
(
sqr(4*tri.circumRadius()),
sqr(searchDistance)
);
List<pointIndexHit> hitList;
emesh.allNearestFeatureEdges(triCentre, radiusSqr, hitList);
featureProximity[fI] =
calcProximityOfFeatureEdges
(
emesh,
hitList,
featureProximity[fI]
);
emesh.allNearestFeaturePoints(triCentre, radiusSqr, hitList);
featureProximity[fI] =
calcProximityOfFeaturePoints
(
hitList,
featureProximity[fI]
);
}
return tfld;
}
Foam::tmp<Foam::scalarField> Foam::edgeMeshTools::writeFeatureProximity
(
const Time& runTime,
const word& basename,
const extendedEdgeMesh& emesh,
const triSurface& surf,
const scalar searchDistance
)
{
Info<< nl << "Extracting curvature of surface at the points."
<< endl;
tmp<scalarField> tfld =
edgeMeshTools::featureProximity(emesh, surf, searchDistance);
scalarField& featureProximity = tfld.ref();
triSurfaceScalarField outputField
(
IOobject
(
basename + ".featureProximity",
runTime.constant(),
"triSurface",
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE
),
surf,
dimLength,
scalarField()
);
outputField.swap(featureProximity);
outputField.write();
outputField.swap(featureProximity);
return tfld;
}
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMeshTools.H"
#include "extendedFeatureEdgeMesh.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::edgeMeshTools::writeStats
(
Ostream& os,
const extendedFeatureEdgeMesh& emesh
)
{
os << "Feature set:" << nl
<< " points : " << emesh.points().size() << nl
<< " of which" << nl
<< " convex : "
<< emesh.concaveStart() << nl
<< " concave : "
<< (emesh.mixedStart()-emesh.concaveStart()) << nl
<< " mixed : "
<< (emesh.nonFeatureStart()-emesh.mixedStart()) << nl
<< " non-feature : "
<< (emesh.points().size()-emesh.nonFeatureStart()) << nl
<< " edges : " << emesh.edges().size() << nl
<< " of which" << nl
<< " external edges : "
<< emesh.internalStart() << nl
<< " internal edges : "
<< (emesh.flatStart()- emesh.internalStart()) << nl
<< " flat edges : "
<< (emesh.openStart()- emesh.flatStart()) << nl
<< " open edges : "
<< (emesh.multipleStart()- emesh.openStart()) << nl
<< " multiply connected : "
<< (emesh.edges().size()- emesh.multipleStart()) << endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace
Foam::edgeMeshTools
Description
Collection of static functions related to edgeMesh features.
SourceFiles
edgeMeshTools.C
edgeMeshFeatureProximity.C
\*---------------------------------------------------------------------------*/
#ifndef edgeMeshTools_H
#define edgeMeshTools_H
#include "tmp.H"
#include "scalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class edgeMesh;
class extendedEdgeMesh;
class extendedFeatureEdgeMesh;
class triSurface;
class Time;
class Ostream;
/*---------------------------------------------------------------------------*\
Namespace edgeMeshTools Declaration
\*---------------------------------------------------------------------------*/
namespace edgeMeshTools
{
//- Write some information
void writeStats
(
Ostream& os,
const extendedFeatureEdgeMesh& emesh
);
//- Calculate proximity of the features to the surface
tmp<scalarField> featureProximity
(
const extendedEdgeMesh& emesh,
const triSurface& surf,
const scalar searchDistance
);
//- Calculate proximity of the features to the surface and write the field
tmp<scalarField> writeFeatureProximity
(
const Time& runTime,
const word& basename,
const extendedEdgeMesh& emesh,
const triSurface& surf,
const scalar searchDistance
);
} // End namespace edgeMeshTools
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,643 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::extendedEdgeMesh
Description
Description of feature edges and points.
Feature points are a sorted subset at the start of the overall points list:
0 .. concaveStart_-1 : convex points (w.r.t normals)
concaveStart_ .. mixedStart_-1 : concave points
mixedStart_ .. nonFeatureStart_-1 : mixed internal/external points
nonFeatureStart_ .. size-1 : non-feature points
Feature edges are the edgeList of the edgeMesh and are sorted:
0 .. internalStart_-1 : external edges (convex w.r.t normals)
internalStart_ .. flatStart_-1 : internal edges (concave)
flatStart_ .. openStart_-1 : flat edges (neither concave or convex)
can arise from region interfaces on
flat surfaces
openStart_ .. multipleStart_-1 : open edges (e.g. from baffle surfaces)
multipleStart_ .. size-1 : multiply connected edges
The edge direction and feature edge and feature point adjacent normals
are stored.
SourceFiles
extendedEdgeMeshI.H
extendedEdgeMesh.C
extendedEdgeMeshNew.C
\*---------------------------------------------------------------------------*/
#ifndef extendedEdgeMesh_H
#define extendedEdgeMesh_H
#include "edgeMesh.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "treeDataPoint.H"
#include "PrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class surfaceFeatures;
class searchableSurface;
// Forward declaration of friend functions and operators
class extendedEdgeMesh;
Istream& operator>>(Istream&, extendedEdgeMesh&);
Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
/*---------------------------------------------------------------------------*\
Class extendedEdgeMesh Declaration
\*---------------------------------------------------------------------------*/
class extendedEdgeMesh
:
public edgeMesh
{
public:
//- Runtime type information
TypeName("extendedEdgeMesh");
enum pointStatus
{
CONVEX, //!< Fully convex point (w.r.t normals)
CONCAVE, //!< Fully concave point
MIXED, //!< A point surrounded by both convex and concave edges
NONFEATURE //!< Not a feature point
};
static const Foam::NamedEnum<pointStatus, 4> pointStatusNames_;
enum edgeStatus
{
EXTERNAL, //!< "Convex" edge
INTERNAL, //!< "Concave" edge
FLAT, //!< Neither concave or convex, on a flat surface
OPEN, //!< Only connected to a single face
MULTIPLE, //!< Multiply connected (connected to more than two faces)
NONE //!< Unclassified (consistency with surfaceFeatures)
};
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_;
//- Angular closeness tolerance for treating normals as the same
static scalar cosNormalAngleTol_;
protected:
// Static data
//- Index of the start of the convex feature points - static as 0
static label convexStart_;
//- Index of the start of the external feature edges - static as 0
static label externalStart_;
// Protected data
//- Index of the start of the concave feature points
label concaveStart_;
//- Index of the start of the mixed type feature points
label mixedStart_;
//- Index of the start of the non-feature points
label nonFeatureStart_;
//- Index of the start of the internal feature edges
label internalStart_;
//- Index of the start of the flat feature edges
label flatStart_;
//- Index of the start of the open feature edges
label openStart_;
//- Index of the start of the multiply-connected feature edges
label multipleStart_;
//- Normals of the features, to be referred to by index by both feature
// points and edges, unsorted
vectorField normals_;
//- Type per normal: which side of normal to mesh
List<sideVolumeType> normalVolumeTypes_;
//- Flat and open edges require the direction of the edge
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
labelListList edgeNormals_;
//- Indices of the normals that are adjacent to the feature points
// (only valid for 0..nonFeatureStart_-1)
labelListList featurePointNormals_;
//- Indices of feature edges attached to feature points. The edges are
// ordered so that they can be circulated.
labelListList featurePointEdges_;
//- Feature edges which are on the boundary between regions
labelList regionEdges_;
//- Search tree for all feature points
mutable autoPtr<indexedOctree<treeDataPoint>> pointTree_;
//- Search tree for all edges
mutable autoPtr<indexedOctree<treeDataEdge>> edgeTree_;
//- Individual search trees for each type of edge
mutable PtrList<indexedOctree<treeDataEdge>> edgeTreesByType_;
// Protected Member Functions
//- Classify the type of feature point. Requires valid stored member
// data for edges and normals.
pointStatus classifyFeaturePoint(label ptI) const;
//- Cut edges with surface. Return map from cut points&edges back
// to original
void cut
(
const searchableSurface&,
labelList& pMap,
labelList& eMap,
labelList& pointsFromEdge, // new points created by cutting
labelList& oldEdge, // the orginal edge
labelList& surfTri // the surface triangle index
);
//- Remove outside/inside edges. volType denotes which side to keep
void select
(
const searchableSurface& surf,
const volumeType volType,
labelList& pMap,
labelList& eMap
);
template<class Patch>
void sortPointsAndEdges
(
const Patch&,
const labelList& featureEdges,
const labelList& regionFeatureEdges,
const labelList& feaurePoints
);
public:
// Static data
//- Number of possible point types (i.e. number of slices)
static label nPointTypes;
//- Number of possible feature edge types (i.e. number of slices)
static label nEdgeTypes;
//- Can we read this file format?
static bool canRead(const fileName& name, const bool verbose=false);
//- Can we read this file format?
static bool canReadType(const word& ext, const bool verbose=false);
//- Can we write this file format type?
static bool canWriteType(const word& ext, const bool verbose=false);
static wordHashSet readTypes();
static wordHashSet writeTypes();
// Constructors
//- Construct null
extendedEdgeMesh();
//- Construct as copy
explicit extendedEdgeMesh(const extendedEdgeMesh& fem);
//- Construct from file name (uses extension to determine type)
extendedEdgeMesh(const fileName&);
//- Construct from file name (uses extension to determine type)
extendedEdgeMesh(const fileName&, const word& ext);
//- Construct from Istream
extendedEdgeMesh(Istream& is);
//- Construct from components
extendedEdgeMesh(const pointField& points, const edgeList& edges);
//- Construct by transferring components (points, edges)
extendedEdgeMesh
(
const Xfer<pointField>& pointLst,
const Xfer<edgeList>& edgeLst
);
//- Construct given a surface with selected edges,points
// (surfaceFeatures)
// Extracts, classifies and reorders the data from surfaceFeatures.
extendedEdgeMesh
(
const surfaceFeatures& sFeat,
const boolList& surfBaffleRegions
);
//- Construct from PrimitivePatch
extendedEdgeMesh
(
const PrimitivePatch<face, List, pointField, point>& surf,
const labelList& featureEdges,
const labelList& regionFeatureEdges,
const labelList& featurePoints
);
//- Construct from all components
extendedEdgeMesh
(
const pointField& pts,
const edgeList& eds,
label concaveStart,
label mixedStart,
label nonFeatureStart,
label internalStart,
label flatStart,
label openStart,
label multipleStart,
const vectorField& normals,
const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections,
const labelListList& normalDirections,
const labelListList& edgeNormals,
const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges
);
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
extendedEdgeMesh,
fileExtension,
(
const fileName& name
),
(name)
);
// Selectors
//- Select constructed from filename (explicit extension)
static autoPtr<extendedEdgeMesh> New
(
const fileName& name,
const word& ext
);
//- Select constructed from filename (implicit extension)
static autoPtr<extendedEdgeMesh> New(const fileName& name);
//- Destructor
~extendedEdgeMesh();
// Member Functions
// Find
//- Find nearest surface edge for the sample point.
void nearestFeaturePoint
(
const point& sample,
scalar searchDistSqr,
pointIndexHit& info
) const;
//- Find nearest surface edge for the sample point.
void nearestFeatureEdge
(
const point& sample,
scalar searchDistSqr,
pointIndexHit& info
) const;
//- Find nearest surface edge for each sample point.
void nearestFeatureEdge
(
const pointField& samples,
const scalarField& searchDistSqr,
List<pointIndexHit>& info
) const;
//- Find the nearest point on each type of feature edge
void nearestFeatureEdgeByType
(
const point& sample,
const scalarField& searchDistSqr,
List<pointIndexHit>& info
) const;
//- Find all the feature points within searchDistSqr of sample
void allNearestFeaturePoints
(
const point& sample,
scalar searchRadiusSqr,
List<pointIndexHit>& info
) const;
//- Find all the feature edges within searchDistSqr of sample
void allNearestFeatureEdges
(
const point& sample,
const scalar searchRadiusSqr,
List<pointIndexHit>& info
) const;
// Access
//- Return the index of the start of the convex feature points
inline label convexStart() const;
//- Return the index of the start of the concave feature points
inline label concaveStart() const;
//- Return the index of the start of the mixed type feature points
inline label mixedStart() const;
//- Return the index of the start of the non-feature points
inline label nonFeatureStart() const;
//- Return the index of the start of the external feature edges
inline label externalStart() const;
//- Return the index of the start of the internal feature edges
inline label internalStart() const;
//- Return the index of the start of the flat feature edges
inline label flatStart() const;
//- Return the index of the start of the open feature edges
inline label openStart() const;
//- Return the index of the start of the multiply-connected feature
// edges
inline label multipleStart() const;
//- Return whether or not the point index is a feature point
inline bool featurePoint(label ptI) const;
//- Return the normals of the surfaces adjacent to the feature edges
// and points
inline const vectorField& normals() const;
//- Return
inline const List<sideVolumeType>& normalVolumeTypes() const;
//- Return the edgeDirection vectors
inline const vectorField& edgeDirections() const;
//-
inline const labelListList& normalDirections() const;
//- Return the direction of edgeI, pointing away from ptI
inline vector edgeDirection(label edgeI, label ptI) const;
//- Return the indices of the normals that are adjacent to the
// feature edges
inline const labelListList& edgeNormals() const;
//- Return the normal vectors for a given set of normal indices
inline vectorField edgeNormals(const labelList& edgeNormIs) const;
//- Return the normal vectors for a given edge
inline vectorField edgeNormals(label edgeI) const;
//- Return the indices of the normals that are adjacent to the
// feature points
inline const labelListList& featurePointNormals() const;
//- Return the normal vectors for a given feature point
inline vectorField featurePointNormals(label ptI) const;
//- Return the edge labels for a given feature point. Edges are
// ordered by the faces that they share. The edge labels
// correspond to the entry in edges().
inline const labelListList& featurePointEdges() const;
//- Return the feature edges which are on the boundary between
// regions
inline const labelList& regionEdges() const;
//- Return the pointStatus of a specified point
inline pointStatus getPointStatus(label ptI) const;
//- Return the edgeStatus of a specified edge
inline edgeStatus getEdgeStatus(label edgeI) const;
//- Return the baffle faces of a specified edge
inline PackedList<2> edgeBaffles(label edgeI) const;
//- Demand driven construction of octree for feature points
const indexedOctree<treeDataPoint>& pointTree() const;
//- Demand driven construction of octree for boundary edges
const indexedOctree<treeDataEdge>& edgeTree() const;
//- Demand driven construction of octree for boundary edges by type
const PtrList<indexedOctree<treeDataEdge>>&
edgeTreesByType() const;
// Edit
//- Transfer the contents of the argument and annul the argument
void transfer(extendedEdgeMesh& mesh);
//- Transfer contents to the Xfer container
Xfer<extendedEdgeMesh> xfer();
//- Clear all storage
virtual void clear();
//- Add extendedEdgeMesh. No filtering of duplicates.
void add(const extendedEdgeMesh& fem);
//- Flip normals. All concave become convex, all internal external
// etc.
void flipNormals();
//- Update with derived geometry
void autoMap
(
const pointField& subPoints,
const edgeList& subEdges,
const labelList& pointMap,
const labelList& edgeMap
);
//- Trim to surface. Keep volType side. Return map from current back
// to original points (-1 for newly introduced points), edges
void trim
(
const searchableSurface& surf,
const volumeType volType,
labelList& pointMap,
labelList& edgeMap
);
//- Order according to point and edge status
void setFromStatus
(
const List<extendedEdgeMesh::pointStatus>& pointStat,
const List<extendedEdgeMesh::edgeStatus>& edgeStat,
labelList& sortedToOriginalPoint,
labelList& sortedToOriginalEdge
);
//- Geometric merge points. Returns true if any points merged.
// Return maps from new back to original points/edges.
bool mergePointsAndSort
(
const scalar mergeDist,
labelList& pointMap,
labelList& edgeMap
);
// Read
//- Read from file. Chooses reader based on explicit extension
bool read(const fileName& name, const word& ext);
//- Read from file. Chooses reader based on detected extension
virtual bool read(const fileName& name);
// Write
//- Write all components of the extendedEdgeMesh as obj files
void writeObj(const fileName& prefix) const;
//- Dump some information
virtual void writeStats(Ostream& os) const;
friend Istream& operator>>(Istream& is, sideVolumeType& vt);
friend Ostream& operator<<(Ostream& os, const sideVolumeType& vt);
//- Classify the type of feature edge. Requires face centre 0 to face
// centre 1 vector to distinguish internal from external
static edgeStatus classifyEdge
(
const List<vector>& norms,
const labelList& edNorms,
const vector& fC0tofC1
);
//- Determine the ordering
static void sortedOrder
(
const List<extendedEdgeMesh::pointStatus>& pointStat,
const List<extendedEdgeMesh::edgeStatus>& edgeStat,
labelList& sortedToOriginalPoint,
labelList& sortedToOriginalEdge,
label& pointConcaveStart,
label& pointMixedStart,
label& pointNonFeatStart,
label& edgeInternalStart,
label& edgeFlatStart,
label& edgeOpenStart,
label& edgeMultipleStart
);
// Ostream Operator
friend Ostream& operator<<(Ostream&, const extendedEdgeMesh&);
friend Istream& operator>>(Istream&, extendedEdgeMesh&);
};
Istream& operator>>(Istream& is, extendedEdgeMesh::sideVolumeType& vt);
Ostream& operator<<(Ostream& os, const extendedEdgeMesh::sideVolumeType& vt);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "extendedEdgeMeshI.H"
#ifdef NoRepository
#include "extendedEdgeMeshTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedEdgeMeshFormat.H"
#include "IFstream.H"
#include "Time.H"
#include "extendedFeatureEdgeMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fileFormats::extendedEdgeMeshFormat::extendedEdgeMeshFormat
(
const fileName& filename
)
{
read(filename);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::fileFormats::extendedEdgeMeshFormat::read
(
const fileName& filename
)
{
clear();
fileName dir = filename.path();
fileName caseName = dir.name();
fileName rootPath = dir.path();
// Construct dummy time to use as an objectRegistry
Time dummyTime
(
".", //rootPath,
".", //caseName,
"system", //systemName,
"constant", //constantName,
false //enableFunctionObjects
);
// Construct IOobject to re-use the headerOk & readHeader
// (so we can read ascii and binary)
IOobject io
(
filename,
dummyTime,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (!io.typeHeaderOk<extendedFeatureEdgeMesh>(false))
{
FatalErrorInFunction
<< "Cannot read file " << filename
<< exit(FatalError);
}
const fileName fName(typeFilePath<extendedFeatureEdgeMesh>(io));
autoPtr<IFstream> isPtr(new IFstream(fName));
bool ok = false;
if (isPtr().good())
{
Istream& is = isPtr();
ok = io.readHeader(is);
if (ok)
{
// Use extendedEdgeMesh IO
is >> *this;
ok = is.good();
}
}
return ok;
}
// ************************************************************************* //

View File

@ -0,0 +1,95 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fileFormats::extendedEdgeMeshFormat
Description
Provide a means of reading/writing the single-file OpenFOAM
extendedEdgeMesh format
SourceFiles
extendedEdgeMeshFormat.C
\*---------------------------------------------------------------------------*/
#ifndef extendedEdgeMeshFormat_H
#define extendedEdgeMeshFormat_H
#include "extendedEdgeMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
/*---------------------------------------------------------------------------*\
Class extendedEdgeMeshFormat Declaration
\*---------------------------------------------------------------------------*/
class extendedEdgeMeshFormat
:
public extendedEdgeMesh
{
// Private Member Functions
//- Disallow default bitwise copy construct
extendedEdgeMeshFormat(const extendedEdgeMeshFormat&);
//- Disallow default bitwise assignment
void operator=(const extendedEdgeMeshFormat&);
public:
// Constructors
//- Construct from file name
extendedEdgeMeshFormat(const fileName&);
//- Destructor
virtual ~extendedEdgeMeshFormat()
{}
// Member Functions
//- Read from file
virtual bool read(const fileName&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fileFormats
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedEdgeMeshFormat.H"
#include "extendedEdgeMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "addToMemberFunctionSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fileFormats
{
// read extendedEdgeMesh
addNamedToRunTimeSelectionTable
(
extendedEdgeMesh,
extendedEdgeMeshFormat,
fileExtension,
extendedFeatureEdgeMesh // extension
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,293 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::extendedEdgeMesh::convexStart() const
{
return convexStart_;
}
inline Foam::label Foam::extendedEdgeMesh::concaveStart() const
{
return concaveStart_;
}
inline Foam::label Foam::extendedEdgeMesh::mixedStart() const
{
return mixedStart_;
}
inline Foam::label Foam::extendedEdgeMesh::nonFeatureStart() const
{
return nonFeatureStart_;
}
inline Foam::label Foam::extendedEdgeMesh::externalStart() const
{
return externalStart_;
}
inline Foam::label Foam::extendedEdgeMesh::internalStart() const
{
return internalStart_;
}
inline Foam::label Foam::extendedEdgeMesh::flatStart() const
{
return flatStart_;
}
inline Foam::label Foam::extendedEdgeMesh::openStart() const
{
return openStart_;
}
inline Foam::label Foam::extendedEdgeMesh::multipleStart() const
{
return multipleStart_;
}
inline bool Foam::extendedEdgeMesh::featurePoint(label ptI) const
{
return ptI < nonFeatureStart_;
}
inline const Foam::vectorField& Foam::extendedEdgeMesh::normals() const
{
return normals_;
}
inline const Foam::List<Foam::extendedEdgeMesh::sideVolumeType>&
Foam::extendedEdgeMesh::normalVolumeTypes() const
{
return normalVolumeTypes_;
}
inline const Foam::vectorField& Foam::extendedEdgeMesh::edgeDirections()
const
{
return edgeDirections_;
}
inline const Foam::labelListList&
Foam::extendedEdgeMesh::normalDirections() const
{
return normalDirections_;
}
inline Foam::vector Foam::extendedEdgeMesh::edgeDirection
(
label edgeI,
label ptI
) const
{
const edge& e = edges()[edgeI];
if (ptI == e.start())
{
return edgeDirections()[edgeI];
}
else if (ptI == e.end())
{
return -edgeDirections()[edgeI];
}
else
{
FatalErrorInFunction
<< "Requested ptI " << ptI << " is not a point on the requested "
<< "edgeI " << edgeI << ". edgeI start and end: "
<< e.start() << " " << e.end()
<< exit(FatalError);
return Zero;
}
}
inline const Foam::labelListList& Foam::extendedEdgeMesh::edgeNormals()
const
{
return edgeNormals_;
}
inline Foam::vectorField Foam::extendedEdgeMesh::edgeNormals
(
const labelList& edgeNormIs
) const
{
vectorField norms(edgeNormIs.size());
forAll(edgeNormIs, i)
{
norms[i] = normals_[edgeNormIs[i]];
}
return norms;
}
inline Foam::vectorField Foam::extendedEdgeMesh::edgeNormals(label edgeI)
const
{
return edgeNormals(edgeNormals_[edgeI]);
}
inline const Foam::labelListList&
Foam::extendedEdgeMesh::featurePointNormals() const
{
return featurePointNormals_;
}
inline Foam::vectorField Foam::extendedEdgeMesh::featurePointNormals
(
label ptI
) const
{
if (!featurePoint(ptI))
{
WarningInFunction
<< "Requesting the normals of a non-feature point. "
<< "Returned zero length vectorField."
<< endl;
return vectorField(0);
}
labelList featPtNormIs(featurePointNormals_[ptI]);
vectorField norms(featPtNormIs.size());
forAll(featPtNormIs, i)
{
norms[i] = normals_[featPtNormIs[i]];
}
return norms;
}
inline const Foam::labelListList&
Foam::extendedEdgeMesh::featurePointEdges() const
{
return featurePointEdges_;
}
inline const Foam::labelList& Foam::extendedEdgeMesh::regionEdges() const
{
return regionEdges_;
}
inline Foam::extendedEdgeMesh::pointStatus
Foam::extendedEdgeMesh::getPointStatus(label ptI) const
{
if (ptI < concaveStart_)
{
return CONVEX;
}
else if (ptI < mixedStart_)
{
return CONCAVE;
}
else if (ptI < nonFeatureStart_)
{
return MIXED;
}
else
{
return NONFEATURE;
}
}
inline Foam::extendedEdgeMesh::edgeStatus
Foam::extendedEdgeMesh::getEdgeStatus(label edgeI) const
{
if (edgeI < internalStart_)
{
return EXTERNAL;
}
else if (edgeI < flatStart_)
{
return INTERNAL;
}
else if (edgeI < openStart_)
{
return FLAT;
}
else if (edgeI < multipleStart_)
{
return OPEN;
}
else
{
return MULTIPLE;
}
}
inline Foam::PackedList<2> Foam::extendedEdgeMesh::edgeBaffles
(
label edgeI
) const
{
const labelList& eNormals = edgeNormals_[edgeI];
DynamicList<label> edgeBaffles(eNormals.size());
forAll(eNormals, enI)
{
const label normI = eNormals[enI];
if (normalVolumeTypes_[normI])
{
edgeBaffles.append(normI);
}
}
return PackedList<2>(edgeBaffles);
}
// ************************************************************************* //

View File

@ -0,0 +1,76 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedEdgeMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineRunTimeSelectionTable(extendedEdgeMesh, fileExtension);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::extendedEdgeMesh> Foam::extendedEdgeMesh::New
(
const fileName& name,
const word& ext
)
{
fileExtensionConstructorTable::iterator cstrIter =
fileExtensionConstructorTablePtr_->find(ext);
if (!cstrIter.found())
{
FatalErrorInFunction
<< "Unknown file extension " << ext
<< " for file " << name << nl << nl
<< "Valid extensions are :" << nl
<< fileExtensionConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<extendedEdgeMesh>(cstrIter()(name));
}
Foam::autoPtr<Foam::extendedEdgeMesh> Foam::extendedEdgeMesh::New
(
const fileName& name
)
{
word ext = name.ext();
if (ext == "gz")
{
ext = name.lessExt().ext();
}
return New(name, ext);
}
// ************************************************************************* //

View File

@ -0,0 +1,418 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedEdgeMesh.H"
#include "ListListOps.H"
#include "unitConversion.H"
#include "PackedBoolList.H"
#include "PatchTools.H"
#include "searchableBox.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Patch>
void Foam::extendedEdgeMesh::sortPointsAndEdges
(
const Patch& surf,
const labelList& featureEdges,
const labelList& regionFeatureEdges,// subset of featureEdges: inter-region
const labelList& featurePoints
)
{
const pointField& sFeatLocalPts(surf.localPoints());
const edgeList& sFeatEds(surf.edges());
const labelListList edgeFaces = PatchTools::sortedEdgeFaces(surf);
const vectorField& faceNormals = surf.faceNormals();
const labelListList pointEdges = PatchTools::sortedPointEdges(surf);
// Extract and reorder the data from surfaceFeatures
// References to the surfaceFeatures data
// Filling the extendedEdgeMesh with the raw geometrical data.
label nFeatEds = featureEdges.size();
label nFeatPts = featurePoints.size();
DynamicList<point> tmpPts;
edgeList eds(nFeatEds);
DynamicList<vector> norms;
vectorField edgeDirections(nFeatEds);
labelListList edgeNormals(nFeatEds);
labelListList normalDirections(nFeatEds);
DynamicList<label> regionEdges;
// Keep track of the ordered feature point feature edges
labelListList featurePointFeatureEdges(nFeatPts);
forAll(featurePointFeatureEdges, pI)
{
featurePointFeatureEdges[pI] = pointEdges[featurePoints[pI]];
}
// Mapping between old and new indices, there is entry in the map for each
// of surf.localPoints, -1 means that this point hasn't been used (yet),
// >= 0 corresponds to the index
labelList pointMap(sFeatLocalPts.size(), -1);
// Mapping between surface edge index and its feature edge index. -1 if it
// is not a feature edge
labelList edgeMap(sFeatEds.size(), -1);
// Noting when the normal of a face has been used so not to duplicate
labelList faceMap(surf.size(), -1);
// Collecting the status of edge for subsequent sorting
List<edgeStatus> edStatus(nFeatEds, NONE);
forAll(featurePoints, i)
{
label sFPI = featurePoints[i];
tmpPts.append(sFeatLocalPts[sFPI]);
pointMap[sFPI] = tmpPts.size() - 1;
}
// All feature points have been added
nonFeatureStart_ = tmpPts.size();
PackedBoolList isRegionFeatureEdge(regionFeatureEdges);
forAll(featureEdges, i)
{
label sFEI = featureEdges[i];
edgeMap[sFEI] = i;
const edge& fE = sFeatEds[sFEI];
edgeDirections[i] = fE.vec(sFeatLocalPts);
// Check to see if the points have been already used
if (pointMap[fE.start()] == -1)
{
tmpPts.append(sFeatLocalPts[fE.start()]);
pointMap[fE.start()] = tmpPts.size() - 1;
}
eds[i].start() = pointMap[fE.start()];
if (pointMap[fE.end()] == -1)
{
tmpPts.append(sFeatLocalPts[fE.end()]);
pointMap[fE.end()] = tmpPts.size() - 1;
}
eds[i].end() = pointMap[fE.end()];
// Pick up the faces adjacent to the feature edge
const labelList& eFaces = edgeFaces[sFEI];
edgeNormals[i].setSize(eFaces.size());
normalDirections[i].setSize(eFaces.size());
forAll(eFaces, j)
{
label eFI = eFaces[j];
// Check to see if the points have been already used
if (faceMap[eFI] == -1)
{
norms.append(faceNormals[eFI]);
faceMap[eFI] = norms.size() - 1;
}
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(Zero);
if (eFaces.size() == 2)
{
fC0tofC1 =
surf[eFaces[1]].centre(surf.points())
- surf[eFaces[0]].centre(surf.points());
}
edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1);
if (isRegionFeatureEdge[i])
{
regionEdges.append(i);
}
}
// Populate feature point feature edges
DynamicList<label> newFeatureEdges;
forAll(featurePointFeatureEdges, pI)
{
const labelList& fpfe = featurePointFeatureEdges[pI];
newFeatureEdges.setCapacity(fpfe.size());
forAll(fpfe, eI)
{
const label oldEdgeIndex = fpfe[eI];
const label newFeatureEdgeIndex = edgeMap[oldEdgeIndex];
if (newFeatureEdgeIndex != -1)
{
newFeatureEdges.append(newFeatureEdgeIndex);
}
}
featurePointFeatureEdges[pI].transfer(newFeatureEdges);
}
// Reorder the edges by classification
List<DynamicList<label>> allEds(nEdgeTypes);
DynamicList<label>& externalEds(allEds[0]);
DynamicList<label>& internalEds(allEds[1]);
DynamicList<label>& flatEds(allEds[2]);
DynamicList<label>& openEds(allEds[3]);
DynamicList<label>& multipleEds(allEds[4]);
forAll(eds, i)
{
edgeStatus eStat = edStatus[i];
if (eStat == EXTERNAL)
{
externalEds.append(i);
}
else if (eStat == INTERNAL)
{
internalEds.append(i);
}
else if (eStat == FLAT)
{
flatEds.append(i);
}
else if (eStat == OPEN)
{
openEds.append(i);
}
else if (eStat == MULTIPLE)
{
multipleEds.append(i);
}
else if (eStat == NONE)
{
FatalErrorInFunction
<< nl << "classifyEdge returned NONE on edge "
<< eds[i]
<< ". There is a problem with definition of this edge."
<< nl << abort(FatalError);
}
}
internalStart_ = externalEds.size();
flatStart_ = internalStart_ + internalEds.size();
openStart_ = flatStart_ + flatEds.size();
multipleStart_ = openStart_ + openEds.size();
labelList edMap
(
ListListOps::combine<labelList>
(
allEds,
accessOp<labelList>()
)
);
edMap = invert(edMap.size(), edMap);
inplaceReorder(edMap, eds);
inplaceReorder(edMap, edStatus);
inplaceReorder(edMap, edgeDirections);
inplaceReorder(edMap, edgeNormals);
inplaceReorder(edMap, normalDirections);
inplaceRenumber(edMap, regionEdges);
forAll(featurePointFeatureEdges, pI)
{
inplaceRenumber(edMap, featurePointFeatureEdges[pI]);
}
pointField pts(tmpPts);
// Initialise the edgeMesh
edgeMesh::operator=(edgeMesh(pts, eds));
// Initialise sorted edge related data
edgeDirections_ = edgeDirections/(mag(edgeDirections) + VSMALL);
edgeNormals_ = edgeNormals;
normalDirections_ = normalDirections;
regionEdges_ = regionEdges;
// Normals are all now found and indirectly addressed, can also be stored
normals_ = vectorField(norms);
// Reorder the feature points by classification
List<DynamicList<label>> allPts(3);
DynamicList<label>& convexPts(allPts[0]);
DynamicList<label>& concavePts(allPts[1]);
DynamicList<label>& mixedPts(allPts[2]);
for (label i = 0; i < nonFeatureStart_; i++)
{
pointStatus ptStatus = classifyFeaturePoint(i);
if (ptStatus == CONVEX)
{
convexPts.append(i);
}
else if (ptStatus == CONCAVE)
{
concavePts.append(i);
}
else if (ptStatus == MIXED)
{
mixedPts.append(i);
}
else if (ptStatus == NONFEATURE)
{
FatalErrorInFunction
<< nl << "classifyFeaturePoint returned NONFEATURE on point at "
<< points()[i]
<< ". There is a problem with definition of this feature point."
<< nl << abort(FatalError);
}
}
concaveStart_ = convexPts.size();
mixedStart_ = concaveStart_ + concavePts.size();
labelList ftPtMap
(
ListListOps::combine<labelList>
(
allPts,
accessOp<labelList>()
)
);
ftPtMap = invert(ftPtMap.size(), ftPtMap);
// Creating the ptMap from the ftPtMap with identity values up to the size
// of pts to create an oldToNew map for inplaceReorder
labelList ptMap(identity(pts.size()));
forAll(ftPtMap, i)
{
ptMap[i] = ftPtMap[i];
}
inplaceReorder(ptMap, pts);
inplaceReorder(ptMap, featurePointFeatureEdges);
forAll(eds, i)
{
inplaceRenumber(ptMap, eds[i]);
}
// Reinitialise the edgeMesh with sorted feature points and
// renumbered edges
reset(xferMove(pts), xferMove(eds));
// Generate the featurePointNormals
labelListList featurePointNormals(nonFeatureStart_);
for (label i = 0; i < nonFeatureStart_; i++)
{
DynamicList<label> tmpFtPtNorms;
const labelList& ptEds = edgeMesh::pointEdges()[i];
forAll(ptEds, j)
{
const labelList& ptEdNorms(edgeNormals[ptEds[j]]);
forAll(ptEdNorms, k)
{
if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1)
{
bool addNormal = true;
// Check that the normal direction is unique at this feature
forAll(tmpFtPtNorms, q)
{
if
(
(normals_[ptEdNorms[k]] & normals_[tmpFtPtNorms[q]])
> cosNormalAngleTol_
)
{
// Parallel to an existing normal, do not add
addNormal = false;
break;
}
}
if (addNormal)
{
tmpFtPtNorms.append(ptEdNorms[k]);
}
}
}
}
featurePointNormals[i] = tmpFtPtNorms;
}
featurePointNormals_ = featurePointNormals;
featurePointEdges_ = featurePointFeatureEdges;
}
// ************************************************************************* //

View File

@ -0,0 +1,270 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedFeatureEdgeMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(extendedFeatureEdgeMesh, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io)
:
regIOobject(io),
extendedEdgeMesh()
{
if
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
// Warn for MUST_READ_IF_MODIFIED
warnNoRereading<extendedFeatureEdgeMesh>();
readStream(typeName) >> *this;
close();
{
// Calculate edgeDirections
const edgeList& eds(edges());
const pointField& pts(points());
edgeDirections_.setSize(eds.size());
forAll(eds, eI)
{
edgeDirections_[eI] = eds[eI].vec(pts);
}
edgeDirections_ /= (mag(edgeDirections_) + SMALL);
}
}
if (debug)
{
Pout<< "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh :"
<< " constructed from IOobject :"
<< " points:" << points().size()
<< " edges:" << edges().size()
<< endl;
}
}
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
(
const IOobject& io,
const extendedEdgeMesh& em
)
:
regIOobject(io),
extendedEdgeMesh(em)
{}
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
(
const surfaceFeatures& sFeat,
const objectRegistry& obr,
const fileName& sFeatFileName,
const boolList& surfBaffleRegions
)
:
regIOobject
(
IOobject
(
sFeatFileName,
obr.time().constant(),
"extendedFeatureEdgeMesh",
obr,
IOobject::NO_READ,
IOobject::NO_WRITE
)
),
extendedEdgeMesh(sFeat, surfBaffleRegions)
{}
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
(
const IOobject& io,
const PrimitivePatch<face, List, pointField, point>& surf,
const labelList& featureEdges,
const labelList& regionFeatureEdges,
const labelList& featurePoints
)
:
regIOobject(io),
extendedEdgeMesh(surf, featureEdges, regionFeatureEdges, featurePoints)
{}
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
(
const IOobject& io,
const pointField& pts,
const edgeList& eds,
label concaveStart,
label mixedStart,
label nonFeatureStart,
label internalStart,
label flatStart,
label openStart,
label multipleStart,
const vectorField& normals,
const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections,
const labelListList& normalDirections,
const labelListList& edgeNormals,
const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges
)
:
regIOobject(io),
extendedEdgeMesh
(
pts,
eds,
concaveStart,
mixedStart,
nonFeatureStart,
internalStart,
flatStart,
openStart,
multipleStart,
normals,
normalVolumeTypes,
edgeDirections,
normalDirections,
edgeNormals,
featurePointNormals,
featurePointEdges,
regionEdges
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::extendedFeatureEdgeMesh::~extendedFeatureEdgeMesh()
{}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
bool Foam::extendedFeatureEdgeMesh::readData(Istream& is)
{
is >> *this;
return !is.bad();
}
bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
{
os << *this;
return os.good();
}
//bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
//{
// os << "// points" << nl
// << points() << nl
// << "// edges" << nl
// << edges() << nl
// << "// concaveStart mixedStart nonFeatureStart" << nl
// << concaveStart_ << token::SPACE
// << mixedStart_ << token::SPACE
// << nonFeatureStart_ << nl
// << "// internalStart flatStart openStart multipleStart" << nl
// << internalStart_ << token::SPACE
// << flatStart_ << token::SPACE
// << openStart_ << token::SPACE
// << multipleStart_ << nl
// << "// normals" << nl
// << normals_ << nl
// << "// normal volume types" << nl
// << normalVolumeTypes_ << nl
// << "// normalDirections" << nl
// << normalDirections_ << nl
// << "// edgeNormals" << nl
// << edgeNormals_ << nl
// << "// featurePointNormals" << nl
// << featurePointNormals_ << nl
// << "// featurePointEdges" << nl
// << featurePointEdges_ << nl
// << "// regionEdges" << nl
// << regionEdges_
// << endl;
//
// return os.good();
//}
//
//Foam::Istream& Foam::operator>>
//(
// Istream& is,
// Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
//)
//{
// label type;
// is >> type;
//
// vt = static_cast<Foam::extendedFeatureEdgeMesh::sideVolumeType>(type);
//
// is.check(FUNCTION_NAME);
// return is;
//}
//
//
//Foam::Ostream& Foam::operator<<
//(
// Ostream& os,
// const Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
//)
//{
// os << static_cast<label>(vt);
//
// return os;
//}
//
// ************************************************************************* //

View File

@ -0,0 +1,170 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::extendedFeatureEdgeMesh
Description
extendedEdgeMesh + IO.
SourceFiles
extendedFeatureEdgeMesh.C
\*---------------------------------------------------------------------------*/
#ifndef extendedFeatureEdgeMesh_H
#define extendedFeatureEdgeMesh_H
#include "extendedEdgeMesh.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class objectRegistry;
/*---------------------------------------------------------------------------*\
Class extendedFeatureEdgeMesh Declaration
\*---------------------------------------------------------------------------*/
class extendedFeatureEdgeMesh
:
public regIOobject,
public extendedEdgeMesh
{
public:
//- Runtime type information
TypeName("extendedFeatureEdgeMesh");
// Constructors
//- Construct (read) given an IOobject
extendedFeatureEdgeMesh(const IOobject&);
//- Construct as copy
extendedFeatureEdgeMesh
(
const IOobject&,
const extendedEdgeMesh&
);
//- Construct given a surface with selected edges,point
// (surfaceFeatures), an objectRegistry and a
// fileName to write to.
// Extracts, classifies and reorders the data from surfaceFeatures.
extendedFeatureEdgeMesh
(
const surfaceFeatures& sFeat,
const objectRegistry& obr,
const fileName& sFeatFileName,
const boolList& surfBaffleRegions
);
//- Construct from PrimitivePatch
extendedFeatureEdgeMesh
(
const IOobject&,
const PrimitivePatch<face, List, pointField, point>& surf,
const labelList& featureEdges,
const labelList& regionFeatureEdges,
const labelList& featurePoints
);
//- Construct from all components
extendedFeatureEdgeMesh
(
const IOobject& io,
const pointField& pts,
const edgeList& eds,
label concaveStart,
label mixedStart,
label nonFeatureStart,
label internalStart,
label flatStart,
label openStart,
label multipleStart,
const vectorField& normals,
const List<sideVolumeType>& normalVolumeTypes,
const vectorField& edgeDirections,
const labelListList& normalDirections,
const labelListList& edgeNormals,
const labelListList& featurePointNormals,
const labelListList& featurePointEdges,
const labelList& regionEdges
);
//- Destructor
virtual ~extendedFeatureEdgeMesh();
// IO
//- Give precedence to the regIOobject write
using regIOobject::write;
//- ReadData function required for regIOobject read operation
virtual bool readData(Istream&);
//- WriteData function required for regIOobject write operation
virtual bool writeData(Ostream&) const;
//- Is object global
virtual bool global() const
{
return true;
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
virtual fileName filePath() const
{
return globalFilePath();
}
};
//- Template function for obtaining global status
template<>
inline bool typeGlobal<extendedFeatureEdgeMesh>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,290 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::extendedFeatureEdgeMesh::convexStart() const
{
return convexStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::concaveStart() const
{
return concaveStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::mixedStart() const
{
return mixedStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::nonFeatureStart() const
{
return nonFeatureStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::externalStart() const
{
return externalStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::internalStart() const
{
return internalStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::flatStart() const
{
return flatStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::openStart() const
{
return openStart_;
}
inline Foam::label Foam::extendedFeatureEdgeMesh::multipleStart() const
{
return multipleStart_;
}
inline bool Foam::extendedFeatureEdgeMesh::featurePoint(label ptI) const
{
return ptI < nonFeatureStart_;
}
inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::normals() const
{
return normals_;
}
inline const Foam::List<Foam::extendedFeatureEdgeMesh::sideVolumeType>&
Foam::extendedFeatureEdgeMesh::normalVolumeTypes() const
{
return normalVolumeTypes_;
}
inline const Foam::vectorField& Foam::extendedFeatureEdgeMesh::edgeDirections()
const
{
return edgeDirections_;
}
inline const Foam::labelListList&
Foam::extendedFeatureEdgeMesh::normalDirections() const
{
return normalDirections_;
}
inline Foam::vector Foam::extendedFeatureEdgeMesh::edgeDirection
(
label edgeI,
label ptI
) const
{
const edge& e = edges()[edgeI];
if (ptI == e.start())
{
return edgeDirections()[edgeI];
}
else if (ptI == e.end())
{
return -edgeDirections()[edgeI];
}
else
{
FatalErrorInFunction
<< "Requested ptI " << ptI << " is not a point on the requested "
<< "edgeI " << edgeI << ". edgeI start and end: "
<< e.start() << " " << e.end()
<< exit(FatalError);
return Zero;
}
}
inline const Foam::labelListList& Foam::extendedFeatureEdgeMesh::edgeNormals()
const
{
return edgeNormals_;
}
inline Foam::vectorField Foam::extendedFeatureEdgeMesh::edgeNormals
(
const labelList& edgeNormIs
) const
{
vectorField norms(edgeNormIs.size());
forAll(edgeNormIs, i)
{
norms[i] = normals_[edgeNormIs[i]];
}
return norms;
}
inline Foam::vectorField Foam::extendedFeatureEdgeMesh::edgeNormals(label edgeI)
const
{
return edgeNormals(edgeNormals_[edgeI]);
}
inline const Foam::labelListList&
Foam::extendedFeatureEdgeMesh::featurePointNormals() const
{
return featurePointNormals_;
}
inline Foam::vectorField Foam::extendedFeatureEdgeMesh::featurePointNormals
(
label ptI
) const
{
if (!featurePoint(ptI))
{
WarningInFunction
<< "Requesting the normals of a non-feature point. "
<< "Returned zero length vectorField."
<< endl;
return vectorField(0);
}
labelList featPtNormIs(featurePointNormals_[ptI]);
vectorField norms(featPtNormIs.size());
forAll(featPtNormIs, i)
{
norms[i] = normals_[featPtNormIs[i]];
}
return norms;
}
inline const Foam::labelListList&
Foam::extendedFeatureEdgeMesh::featurePointEdges() const
{
return featurePointEdges_;
}
inline const Foam::labelList& Foam::extendedFeatureEdgeMesh::regionEdges() const
{
return regionEdges_;
}
inline Foam::extendedFeatureEdgeMesh::pointStatus
Foam::extendedFeatureEdgeMesh::getPointStatus(label ptI) const
{
if (ptI < concaveStart_)
{
return CONVEX;
}
else if (ptI < mixedStart_)
{
return CONCAVE;
}
else if (ptI < nonFeatureStart_)
{
return MIXED;
}
else
{
return NONFEATURE;
}
}
inline Foam::extendedFeatureEdgeMesh::edgeStatus
Foam::extendedFeatureEdgeMesh::getEdgeStatus(label edgeI) const
{
if (edgeI < internalStart_)
{
return EXTERNAL;
}
else if (edgeI < flatStart_)
{
return INTERNAL;
}
else if (edgeI < openStart_)
{
return FLAT;
}
else if (edgeI < multipleStart_)
{
return OPEN;
}
else
{
return MULTIPLE;
}
}
inline Foam::PackedList<2> Foam::extendedFeatureEdgeMesh::edgeBaffles
(
label edgeI
) const
{
const labelList& eNormals = edgeNormals_[edgeI];
DynamicList<label> edgeBaffles(eNormals.size());
forAll(eNormals, enI)
{
const label normI = eNormals[enI];
if (normalVolumeTypes_[normI])
{
edgeBaffles.append(normI);
}
}
return PackedList<2>(edgeBaffles);
}
// ************************************************************************* //

View File

@ -0,0 +1,418 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extendedFeatureEdgeMesh.H"
#include "ListListOps.H"
#include "unitConversion.H"
#include "PackedBoolList.H"
#include "PatchTools.H"
#include "searchableBox.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Patch>
void Foam::extendedFeatureEdgeMesh::sortPointsAndEdges
(
const Patch& surf,
const labelList& featureEdges,
const labelList& regionFeatureEdges,// subset of featureEdges: inter-region
const labelList& featurePoints
)
{
const pointField& sFeatLocalPts(surf.localPoints());
const edgeList& sFeatEds(surf.edges());
const labelListList edgeFaces = PatchTools::sortedEdgeFaces(surf);
const vectorField& faceNormals = surf.faceNormals();
const labelListList pointEdges = PatchTools::sortedPointEdges(surf);
// Extract and reorder the data from surfaceFeatures
// References to the surfaceFeatures data
// Filling the extendedFeatureEdgeMesh with the raw geometrical data.
label nFeatEds = featureEdges.size();
label nFeatPts = featurePoints.size();
DynamicList<point> tmpPts;
edgeList eds(nFeatEds);
DynamicList<vector> norms;
vectorField edgeDirections(nFeatEds);
labelListList edgeNormals(nFeatEds);
labelListList normalDirections(nFeatEds);
DynamicList<label> regionEdges;
// Keep track of the ordered feature point feature edges
labelListList featurePointFeatureEdges(nFeatPts);
forAll(featurePointFeatureEdges, pI)
{
featurePointFeatureEdges[pI] = pointEdges[featurePoints[pI]];
}
// Mapping between old and new indices, there is entry in the map for each
// of surf.localPoints, -1 means that this point hasn't been used (yet),
// >= 0 corresponds to the index
labelList pointMap(sFeatLocalPts.size(), -1);
// Mapping between surface edge index and its feature edge index. -1 if it
// is not a feature edge
labelList edgeMap(sFeatEds.size(), -1);
// Noting when the normal of a face has been used so not to duplicate
labelList faceMap(surf.size(), -1);
// Collecting the status of edge for subsequent sorting
List<edgeStatus> edStatus(nFeatEds, NONE);
forAll(featurePoints, i)
{
label sFPI = featurePoints[i];
tmpPts.append(sFeatLocalPts[sFPI]);
pointMap[sFPI] = tmpPts.size() - 1;
}
// All feature points have been added
nonFeatureStart_ = tmpPts.size();
PackedBoolList isRegionFeatureEdge(regionFeatureEdges);
forAll(featureEdges, i)
{
label sFEI = featureEdges[i];
edgeMap[sFEI] = i;
const edge& fE = sFeatEds[sFEI];
edgeDirections[i] = fE.vec(sFeatLocalPts);
// Check to see if the points have been already used
if (pointMap[fE.start()] == -1)
{
tmpPts.append(sFeatLocalPts[fE.start()]);
pointMap[fE.start()] = tmpPts.size() - 1;
}
eds[i].start() = pointMap[fE.start()];
if (pointMap[fE.end()] == -1)
{
tmpPts.append(sFeatLocalPts[fE.end()]);
pointMap[fE.end()] = tmpPts.size() - 1;
}
eds[i].end() = pointMap[fE.end()];
// Pick up the faces adjacent to the feature edge
const labelList& eFaces = edgeFaces[sFEI];
edgeNormals[i].setSize(eFaces.size());
normalDirections[i].setSize(eFaces.size());
forAll(eFaces, j)
{
label eFI = eFaces[j];
// Check to see if the points have been already used
if (faceMap[eFI] == -1)
{
norms.append(faceNormals[eFI]);
faceMap[eFI] = norms.size() - 1;
}
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(Zero);
if (eFaces.size() == 2)
{
fC0tofC1 =
surf[eFaces[1]].centre(surf.points())
- surf[eFaces[0]].centre(surf.points());
}
edStatus[i] = classifyEdge(norms, edgeNormals[i], fC0tofC1);
if (isRegionFeatureEdge[i])
{
regionEdges.append(i);
}
}
// Populate feature point feature edges
DynamicList<label> newFeatureEdges;
forAll(featurePointFeatureEdges, pI)
{
const labelList& fpfe = featurePointFeatureEdges[pI];
newFeatureEdges.setCapacity(fpfe.size());
forAll(fpfe, eI)
{
const label oldEdgeIndex = fpfe[eI];
const label newFeatureEdgeIndex = edgeMap[oldEdgeIndex];
if (newFeatureEdgeIndex != -1)
{
newFeatureEdges.append(newFeatureEdgeIndex);
}
}
featurePointFeatureEdges[pI].transfer(newFeatureEdges);
}
// Reorder the edges by classification
List<DynamicList<label>> allEds(nEdgeTypes);
DynamicList<label>& externalEds(allEds[0]);
DynamicList<label>& internalEds(allEds[1]);
DynamicList<label>& flatEds(allEds[2]);
DynamicList<label>& openEds(allEds[3]);
DynamicList<label>& multipleEds(allEds[4]);
forAll(eds, i)
{
edgeStatus eStat = edStatus[i];
if (eStat == EXTERNAL)
{
externalEds.append(i);
}
else if (eStat == INTERNAL)
{
internalEds.append(i);
}
else if (eStat == FLAT)
{
flatEds.append(i);
}
else if (eStat == OPEN)
{
openEds.append(i);
}
else if (eStat == MULTIPLE)
{
multipleEds.append(i);
}
else if (eStat == NONE)
{
FatalErrorInFunction
<< nl << "classifyEdge returned NONE on edge "
<< eds[i]
<< ". There is a problem with definition of this edge."
<< nl << abort(FatalError);
}
}
internalStart_ = externalEds.size();
flatStart_ = internalStart_ + internalEds.size();
openStart_ = flatStart_ + flatEds.size();
multipleStart_ = openStart_ + openEds.size();
labelList edMap
(
ListListOps::combine<labelList>
(
allEds,
accessOp<labelList>()
)
);
edMap = invert(edMap.size(), edMap);
inplaceReorder(edMap, eds);
inplaceReorder(edMap, edStatus);
inplaceReorder(edMap, edgeDirections);
inplaceReorder(edMap, edgeNormals);
inplaceReorder(edMap, normalDirections);
inplaceRenumber(edMap, regionEdges);
forAll(featurePointFeatureEdges, pI)
{
inplaceRenumber(edMap, featurePointFeatureEdges[pI]);
}
pointField pts(tmpPts);
// Initialise the edgeMesh
edgeMesh::operator=(edgeMesh(pts, eds));
// Initialise sorted edge related data
edgeDirections_ = edgeDirections/(mag(edgeDirections) + VSMALL);
edgeNormals_ = edgeNormals;
normalDirections_ = normalDirections;
regionEdges_ = regionEdges;
// Normals are all now found and indirectly addressed, can also be stored
normals_ = vectorField(norms);
// Reorder the feature points by classification
List<DynamicList<label>> allPts(3);
DynamicList<label>& convexPts(allPts[0]);
DynamicList<label>& concavePts(allPts[1]);
DynamicList<label>& mixedPts(allPts[2]);
for (label i = 0; i < nonFeatureStart_; i++)
{
pointStatus ptStatus = classifyFeaturePoint(i);
if (ptStatus == CONVEX)
{
convexPts.append(i);
}
else if (ptStatus == CONCAVE)
{
concavePts.append(i);
}
else if (ptStatus == MIXED)
{
mixedPts.append(i);
}
else if (ptStatus == NONFEATURE)
{
FatalErrorInFunction
<< nl << "classifyFeaturePoint returned NONFEATURE on point at "
<< points()[i]
<< ". There is a problem with definition of this feature point."
<< nl << abort(FatalError);
}
}
concaveStart_ = convexPts.size();
mixedStart_ = concaveStart_ + concavePts.size();
labelList ftPtMap
(
ListListOps::combine<labelList>
(
allPts,
accessOp<labelList>()
)
);
ftPtMap = invert(ftPtMap.size(), ftPtMap);
// Creating the ptMap from the ftPtMap with identity values up to the size
// of pts to create an oldToNew map for inplaceReorder
labelList ptMap(identity(pts.size()));
forAll(ftPtMap, i)
{
ptMap[i] = ftPtMap[i];
}
inplaceReorder(ptMap, pts);
inplaceReorder(ptMap, featurePointFeatureEdges);
forAll(eds, i)
{
inplaceRenumber(ptMap, eds[i]);
}
// Reinitialise the edgeMesh with sorted feature points and
// renumbered edges
reset(xferMove(pts), xferMove(eds));
// Generate the featurePointNormals
labelListList featurePointNormals(nonFeatureStart_);
for (label i = 0; i < nonFeatureStart_; i++)
{
DynamicList<label> tmpFtPtNorms;
const labelList& ptEds = edgeMesh::pointEdges()[i];
forAll(ptEds, j)
{
const labelList& ptEdNorms(edgeNormals[ptEds[j]]);
forAll(ptEdNorms, k)
{
if (findIndex(tmpFtPtNorms, ptEdNorms[k]) == -1)
{
bool addNormal = true;
// Check that the normal direction is unique at this feature
forAll(tmpFtPtNorms, q)
{
if
(
(normals_[ptEdNorms[k]] & normals_[tmpFtPtNorms[q]])
> cosNormalAngleTol_
)
{
// Parallel to an existing normal, do not add
addNormal = false;
break;
}
}
if (addNormal)
{
tmpFtPtNorms.append(ptEdNorms[k]);
}
}
}
}
featurePointNormals[i] = tmpFtPtNorms;
}
featurePointNormals_ = featurePointNormals;
featurePointEdges_ = featurePointFeatureEdges;
}
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "featureEdgeMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(featureEdgeMesh, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io)
:
regIOobject(io),
edgeMesh(pointField(0), edgeList(0))
{
if
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
if (debug)
{
Pout<< "featureEdgeMesh::featureEdgeMesh :"
<< " constructed from IOobject :"
<< " points:" << points().size()
<< " edges:" << edges().size()
<< endl;
}
}
Foam::featureEdgeMesh::featureEdgeMesh
(
const IOobject& io,
const pointField& points,
const edgeList& edges
)
:
regIOobject(io),
edgeMesh(points, edges)
{}
// Construct as copy
Foam::featureEdgeMesh::featureEdgeMesh
(
const IOobject& io,
const featureEdgeMesh& em
)
:
regIOobject(io),
edgeMesh(em)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::featureEdgeMesh::readData(Istream& is)
{
is >> *this;
return !is.bad();
}
bool Foam::featureEdgeMesh::writeData(Ostream& os) const
{
os << *this;
return os.good();
}
// ************************************************************************* //

View File

@ -0,0 +1,120 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::featureEdgeMesh
Description
edgeMesh + IO.
See also
Foam::extendedFeatureEdgeMesh
SourceFiles
featureEdgeMesh.C
\*---------------------------------------------------------------------------*/
#ifndef featureEdgeMesh_H
#define featureEdgeMesh_H
#include "edgeMesh.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class featureEdgeMesh Declaration
\*---------------------------------------------------------------------------*/
class featureEdgeMesh
:
public regIOobject,
public edgeMesh
{
public:
TypeName("featureEdgeMesh");
// Constructors
//- Construct (read) given an IOobject
featureEdgeMesh(const IOobject&);
//- Construct from featureEdgeMesh data
featureEdgeMesh
(
const IOobject&,
const pointField&,
const edgeList&
);
//- Construct as copy
featureEdgeMesh(const IOobject&, const featureEdgeMesh&);
// IO
//- ReadData function required for regIOobject read operation
virtual bool readData(Istream&);
//- WriteData function required for regIOobject write operation
virtual bool writeData(Ostream&) const;
//- Is object global
virtual bool global() const
{
return true;
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
virtual fileName filePath() const
{
return globalFilePath();
}
};
//- Template function for obtaining global status
template<>
inline bool typeGlobal<featureEdgeMesh>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1070,7 +1070,7 @@ Foam::mappedPatchBase::mappedPatchBase
{
offsetMode_ = offsetModeNames_.read(dict.lookup("offsetMode"));
switch(offsetMode_)
switch (offsetMode_)
{
case UNIFORM:
{
@ -1109,7 +1109,7 @@ Foam::mappedPatchBase::mappedPatchBase
(
dict
) << "Please supply the offsetMode as one of "
<< NamedEnum<offsetMode, 3>::words()
<< offsetModeNames_
<< exit(FatalIOError);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -35,9 +35,9 @@ License
namespace Foam
{
defineTypeNameAndDebug(meshSearch, 0);
defineTypeNameAndDebug(meshSearch, 0);
scalar meshSearch::tol_ = 1e-3;
scalar meshSearch::tol_ = 1e-3;
}
@ -117,7 +117,6 @@ Foam::label Foam::meshSearch::findNearestCellTree(const point& location) const
}
// linear searching
Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const
{
const vectorField& centres = mesh_.cellCentres();
@ -137,7 +136,6 @@ Foam::label Foam::meshSearch::findNearestCellLinear(const point& location) const
}
// walking from seed
Foam::label Foam::meshSearch::findNearestCellWalk
(
const point& location,
@ -174,7 +172,6 @@ Foam::label Foam::meshSearch::findNearestCellWalk
}
// tree based searching
Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const
{
// Search nearest cell centre.
@ -214,7 +211,6 @@ Foam::label Foam::meshSearch::findNearestFaceTree(const point& location) const
}
// linear searching
Foam::label Foam::meshSearch::findNearestFaceLinear(const point& location) const
{
const vectorField& centres = mesh_.faceCentres();
@ -234,7 +230,6 @@ Foam::label Foam::meshSearch::findNearestFaceLinear(const point& location) const
}
// walking from seed
Foam::label Foam::meshSearch::findNearestFaceWalk
(
const point& location,
@ -322,7 +317,6 @@ Foam::label Foam::meshSearch::findCellLinear(const point& location) const
}
// walking from seed
Foam::label Foam::meshSearch::findCellWalk
(
const point& location,
@ -514,7 +508,6 @@ Foam::meshSearch::meshSearch
}
// Construct with a custom bounding box
Foam::meshSearch::meshSearch
(
const polyMesh& mesh,
@ -549,8 +542,8 @@ Foam::meshSearch::~meshSearch()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
const
const Foam::indexedOctree<Foam::treeDataFace>&
Foam::meshSearch::boundaryTree() const
{
if (!boundaryTreePtr_.valid())
{
@ -602,8 +595,8 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree()
}
const Foam::indexedOctree<Foam::treeDataCell>& Foam::meshSearch::cellTree()
const
const Foam::indexedOctree<Foam::treeDataCell>&
Foam::meshSearch::cellTree() const
{
if (!cellTreePtr_.valid())
{
@ -648,92 +641,6 @@ const
}
//// Is the point in the cell
//// Works by checking if there is a face inbetween the point and the cell
//// centre.
//// Check for internal uses proper face decomposition or just average normal.
//bool Foam::meshSearch::pointInCell(const point& p, label celli) const
//{
// if (faceDecomp_)
// {
// const point& ctr = mesh_.cellCentres()[celli];
//
// vector dir(p - ctr);
// scalar magDir = mag(dir);
//
// // Check if any faces are hit by ray from cell centre to p.
// // If none -> p is in cell.
// const labelList& cFaces = mesh_.cells()[celli];
//
// // Make sure half_ray does not pick up any faces on the wrong
// // side of the ray.
// scalar oldTol = intersection::setPlanarTol(0.0);
//
// forAll(cFaces, i)
// {
// label facei = cFaces[i];
//
// pointHit inter = mesh_.faces()[facei].ray
// (
// ctr,
// dir,
// mesh_.points(),
// intersection::HALF_RAY,
// intersection::VECTOR
// );
//
// if (inter.hit())
// {
// scalar dist = inter.distance();
//
// if (dist < magDir)
// {
// // Valid hit. Hit face so point is not in cell.
// intersection::setPlanarTol(oldTol);
//
// return false;
// }
// }
// }
//
// intersection::setPlanarTol(oldTol);
//
// // No face inbetween point and cell centre so point is inside.
// return true;
// }
// else
// {
// const labelList& f = mesh_.cells()[celli];
// const labelList& owner = mesh_.faceOwner();
// const vectorField& cf = mesh_.faceCentres();
// const vectorField& Sf = mesh_.faceAreas();
//
// forAll(f, facei)
// {
// label nFace = f[facei];
// vector proj = p - cf[nFace];
// vector normal = Sf[nFace];
// if (owner[nFace] == celli)
// {
// if ((normal & proj) > 0)
// {
// return false;
// }
// }
// else
// {
// if ((normal & proj) < 0)
// {
// return false;
// }
// }
// }
//
// return true;
// }
//}
Foam::label Foam::meshSearch::findNearestCell
(
const point& location,
@ -949,7 +856,6 @@ bool Foam::meshSearch::isInside(const point& p) const
}
// Delete all storage
void Foam::meshSearch::clearOut()
{
boundaryTreePtr_.clear();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -325,7 +325,6 @@ bool Foam::regionCoupledBase::order
rotation.setSize(pp.size());
rotation = 0;
// do nothing
return false;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2014-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -0,0 +1,437 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "searchableExtrudedCircle.H"
#include "addToRunTimeSelectionTable.H"
#include "Time.H"
#include "edgeMesh.H"
#include "indexedOctree.H"
#include "treeDataEdge.H"
#include "linearInterpolationWeights.H"
#include "quaternion.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(searchableExtrudedCircle, 0);
addToRunTimeSelectionTable
(
searchableSurface,
searchableExtrudedCircle,
dict
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::searchableExtrudedCircle::searchableExtrudedCircle
(
const IOobject& io,
const dictionary& dict
)
:
searchableSurface(io),
eMeshPtr_
(
edgeMesh::New
(
IOobject
(
dict.lookup("file"), // name
io.time().constant(), // instance
"geometry", // local
io.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
).objectPath()
)
),
radius_(readScalar(dict.lookup("radius")))
{
const edgeMesh& eMesh = eMeshPtr_();
const pointField& points = eMesh.points();
const edgeList& edges = eMesh.edges();
bounds() = boundBox(points, false);
vector halfSpan(0.5*bounds().span());
point ctr(bounds().midpoint());
bounds().min() = ctr - mag(halfSpan)*vector(1, 1, 1);
bounds().max() = ctr + mag(halfSpan)*vector(1, 1, 1);
// Calculate bb of all points
treeBoundBox bb(bounds());
// Slightly extended bb. Slightly off-centred just so on symmetric
// geometry there are less face/edge aligned items.
bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
edgeTree_.reset
(
new indexedOctree<treeDataEdge>
(
treeDataEdge
(
false, // do not cache bb
edges,
points,
identity(edges.size())
),
bb, // overall search domain
8, // maxLevel
10, // leafsize
3.0 // duplicity
)
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::searchableExtrudedCircle::~searchableExtrudedCircle()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::wordList& Foam::searchableExtrudedCircle::regions() const
{
if (regions_.empty())
{
regions_.setSize(1);
regions_[0] = "region0";
}
return regions_;
}
Foam::label Foam::searchableExtrudedCircle::size() const
{
return eMeshPtr_().points().size();
}
Foam::tmp<Foam::pointField> Foam::searchableExtrudedCircle::coordinates() const
{
return eMeshPtr_().points();
}
void Foam::searchableExtrudedCircle::boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const
{
centres = eMeshPtr_().points();
radiusSqr.setSize(centres.size());
radiusSqr = Foam::sqr(radius_);
// Add a bit to make sure all points are tested inside
radiusSqr += Foam::sqr(SMALL);
}
void Foam::searchableExtrudedCircle::findNearest
(
const pointField& samples,
const scalarField& nearestDistSqr,
List<pointIndexHit>& info
) const
{
const indexedOctree<treeDataEdge>& tree = edgeTree_();
info.setSize(samples.size());
forAll(samples, i)
{
info[i] = tree.findNearest(samples[i], nearestDistSqr[i]);
if (info[i].hit())
{
vector d(samples[i]-info[i].hitPoint());
info[i].setPoint(info[i].hitPoint() + d/mag(d)*radius_);
}
}
}
void Foam::searchableExtrudedCircle::findParametricNearest
(
const point& start,
const point& end,
const scalarField& rawLambdas,
const scalarField& nearestDistSqr,
List<pointIndexHit>& info
) const
{
const edgeMesh& mesh = eMeshPtr_();
const indexedOctree<treeDataEdge>& tree = edgeTree_();
const edgeList& edges = mesh.edges();
const pointField& points = mesh.points();
const labelListList& pointEdges = mesh.pointEdges();
const scalar maxDistSqr(Foam::magSqr(bounds().span()));
// Normalise lambdas
const scalarField lambdas
(
(rawLambdas-rawLambdas[0])
/(rawLambdas.last()-rawLambdas[0])
);
// Nearest point on curve and local axis direction
pointField curvePoints(lambdas.size());
vectorField axialVecs(lambdas.size());
const pointIndexHit startInfo = tree.findNearest(start, maxDistSqr);
curvePoints[0] = startInfo.hitPoint();
axialVecs[0] = edges[startInfo.index()].vec(points);
const pointIndexHit endInfo = tree.findNearest(end, maxDistSqr);
curvePoints.last() = endInfo.hitPoint();
axialVecs.last() = edges[endInfo.index()].vec(points);
scalarField curveLambdas(points.size(), -1.0);
{
scalar endDistance = -1.0;
// Determine edge lengths walking from start to end.
const point& start = curvePoints[0];
const point& end = curvePoints.last();
label edgei = startInfo.index();
const edge& startE = edges[edgei];
label pointi = startE[0];
if ((startE.vec(points)&(end-start)) > 0)
{
pointi = startE[1];
}
curveLambdas[pointi] = mag(points[pointi]-curvePoints[0]);
label otherPointi = startE.otherVertex(pointi);
curveLambdas[otherPointi] = -mag(points[otherPointi]-curvePoints[0]);
//Pout<< "for point:" << points[pointi] << " have distance "
// << curveLambdas[pointi] << endl;
while (true)
{
const labelList& pEdges = pointEdges[pointi];
if (pEdges.size() == 1)
{
break;
}
else if (pEdges.size() != 2)
{
FatalErrorInFunction << "Curve " << name()
<< " is not a single path. This is not supported"
<< exit(FatalError);
break;
}
label oldEdgei = edgei;
if (pEdges[0] == oldEdgei)
{
edgei = pEdges[1];
}
else
{
edgei = pEdges[0];
}
if (edgei == endInfo.index())
{
endDistance = curveLambdas[pointi] + mag(end-points[pointi]);
//Pout<< "Found end edge:" << edges[edgei].centre(points)
// << " endPt:" << end
// << " point before:" << points[pointi]
// << " accumulated length:" << endDistance << endl;
}
label oldPointi = pointi;
pointi = edges[edgei].otherVertex(oldPointi);
if (curveLambdas[pointi] >= 0)
{
break;
}
curveLambdas[pointi] =
curveLambdas[oldPointi] + edges[edgei].mag(points);
}
// Normalise curveLambdas
forAll(curveLambdas, i)
{
if (curveLambdas[i] >= 0)
{
curveLambdas[i] /= endDistance;
}
}
}
// Interpolation engine
linearInterpolationWeights interpolator(curveLambdas);
// Find wanted location along curve
labelList indices;
scalarField weights;
for (label i = 1; i < curvePoints.size()-1; i++)
{
interpolator.valueWeights(lambdas[i], indices, weights);
if (indices.size() == 1)
{
// On outside of curve. Choose one of the connected edges.
label pointi = indices[0];
const point& p0 = points[pointi];
label edge0 = pointEdges[pointi][0];
const edge& e0 = edges[edge0];
axialVecs[i] = e0.vec(points);
curvePoints[i] = weights[0]*p0;
}
else if (indices.size() == 2)
{
const point& p0 = points[indices[0]];
const point& p1 = points[indices[1]];
axialVecs[i] = p1-p0;
curvePoints[i] = weights[0]*p0+weights[1]*p1;
}
}
axialVecs /= mag(axialVecs);
// Now we have the lambdas, curvePoints and axialVecs.
info.setSize(lambdas.size());
info = pointIndexHit();
// Given the current lambdas interpolate radial direction inbetween
// endpoints (all projected onto the starting coordinate system)
quaternion qStart;
vector radialStart;
{
radialStart = start-curvePoints[0];
radialStart -= (radialStart&axialVecs[0])*axialVecs[0];
radialStart /= mag(radialStart);
qStart = quaternion(radialStart, 0.0);
info[0] = pointIndexHit(true, start, 0);
}
quaternion qProjectedEnd;
{
vector radialEnd(end-curvePoints.last());
radialEnd -= (radialEnd&axialVecs.last())*axialVecs.last();
radialEnd /= mag(radialEnd);
vector projectedEnd = radialEnd;
projectedEnd -= (projectedEnd&axialVecs[0])*axialVecs[0];
projectedEnd /= mag(projectedEnd);
qProjectedEnd = quaternion(projectedEnd, 0.0);
info.last() = pointIndexHit(true, end, 0);
}
for (label i = 1; i < lambdas.size()-1; i++)
{
quaternion q(slerp(qStart, qProjectedEnd, lambdas[i]));
vector radialDir(q.transform(radialStart));
radialDir -= (radialDir&axialVecs[i])*axialVecs.last();
radialDir /= mag(radialDir);
info[i] = pointIndexHit(true, curvePoints[i]+radius_*radialDir, 0);
}
}
void Foam::searchableExtrudedCircle::getRegion
(
const List<pointIndexHit>& info,
labelList& region
) const
{
region.setSize(info.size());
region = 0;
}
void Foam::searchableExtrudedCircle::getNormal
(
const List<pointIndexHit>& info,
vectorField& normal
) const
{
const edgeMesh& mesh = eMeshPtr_();
const indexedOctree<treeDataEdge>& tree = edgeTree_();
const edgeList& edges = mesh.edges();
const pointField& points = mesh.points();
normal.setSize(info.size());
normal = Zero;
forAll(info, i)
{
if (info[i].hit())
{
// Find nearest on curve
pointIndexHit curvePt = tree.findNearest
(
info[i].hitPoint(),
Foam::magSqr(bounds().span())
);
normal[i] = info[i].hitPoint()-curvePt.hitPoint();
// Subtract axial direction
vector axialVec = edges[curvePt.index()].vec(points);
axialVec /= mag(axialVec);
normal[i] -= (normal[i]&axialVec)*axialVec;
normal[i] /= mag(normal[i]);
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,236 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::searchableExtrudedCircle
Description
Searching on edgemesh with constant radius
SourceFiles
searchableExtrudedCircle.C
\*---------------------------------------------------------------------------*/
#ifndef searchableExtrudedCircle_H
#define searchableExtrudedCircle_H
#include "treeBoundBox.H"
#include "searchableSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class edgeMesh;
class treeDataEdge;
template <class Type> class indexedOctree;
/*---------------------------------------------------------------------------*\
Class searchableExtrudedCircle Declaration
\*---------------------------------------------------------------------------*/
class searchableExtrudedCircle
:
public searchableSurface
{
// Private Member Data
//- Feature
autoPtr<edgeMesh> eMeshPtr_;
//- Search structure
autoPtr<indexedOctree<treeDataEdge>> edgeTree_;
//- Radius
const scalar radius_;
//- Names of regions
mutable wordList regions_;
// Private Member Functions
//- Disallow default bitwise copy construct
searchableExtrudedCircle(const searchableExtrudedCircle&);
//- Disallow default bitwise assignment
void operator=(const searchableExtrudedCircle&);
public:
//- Runtime type information
TypeName("searchableExtrudedCircle");
// Constructors
//- Construct from dictionary (used by searchableSurface)
searchableExtrudedCircle
(
const IOobject& io,
const dictionary& dict
);
//- Destructor
virtual ~searchableExtrudedCircle();
// Member Functions
virtual const wordList& regions() const;
//- Whether supports volume type below
virtual bool hasVolumeType() const
{
return true;
}
//- Range of local indices that can be returned.
virtual label size() const;
//- Get representative set of element coordinates
// Usually the element centres (should be of length size()).
virtual tmp<pointField> coordinates() const;
//- Get bounding spheres (centre and radius squared), one per element.
// Any point on element is guaranteed to be inside.
virtual void boundingSpheres
(
pointField& centres,
scalarField& radiusSqr
) const;
//- Get the points that define the surface.
virtual tmp<pointField> points() const
{
return coordinates();
}
//- Does any part of the surface overlap the supplied bound box?
virtual bool overlaps(const boundBox& bb) const
{
NotImplemented;
return false;
}
// Multiple point queries.
virtual void findNearest
(
const pointField& sample,
const scalarField& nearestDistSqr,
List<pointIndexHit>&
) const;
//- Unique to parametric geometry: given points find
// an interpolated (along the curve) point on the surface.
// The lambdas[0] is equivalent for start, lambdas.last()
// is equivalent for end.
virtual void findParametricNearest
(
const point& start,
const point& end,
const scalarField& lambdas,
const scalarField& nearestDistSqr,
List<pointIndexHit>&
) const;
virtual void findLine
(
const pointField& start,
const pointField& end,
List<pointIndexHit>&
) const
{
NotImplemented;
}
virtual void findLineAny
(
const pointField& start,
const pointField& end,
List<pointIndexHit>&
) const
{
NotImplemented;
}
//- Get all intersections in order from start to end.
virtual void findLineAll
(
const pointField& start,
const pointField& end,
List<List<pointIndexHit>>&
) const
{
NotImplemented;
}
//- From a set of points and indices get the region
virtual void getRegion
(
const List<pointIndexHit>&,
labelList& region
) const;
//- From a set of points and indices get the normal
virtual void getNormal
(
const List<pointIndexHit>&,
vectorField& normal
) const;
//- Determine type (inside/outside/mixed) for point. unknown if
// cannot be determined (e.g. non-manifold surface)
virtual void getVolumeType
(
const pointField&,
List<volumeType>&
) const
{
NotImplemented;
}
bool writeData(Ostream&) const
{
NotImplemented;
return false;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -61,7 +61,7 @@ class mapDistribute;
class treeBoundBox;
/*---------------------------------------------------------------------------*\
Class searchableSurface Declaration
Class searchableSurface Declaration
\*---------------------------------------------------------------------------*/
class searchableSurface
@ -74,6 +74,7 @@ class searchableSurface
boundBox bounds_;
// Private Member Functions
//- Disallow default bitwise copy construct

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -35,83 +35,70 @@ License
namespace Foam
{
defineTypeNameAndDebug(triSurfaceMesh, 0);
addToRunTimeSelectionTable(searchableSurface, triSurfaceMesh, dict);
word triSurfaceMesh::meshSubDir = "triSurface";
defineTypeNameAndDebug(triSurfaceMesh, 0);
addToRunTimeSelectionTable(searchableSurface, triSurfaceMesh, dict);
word triSurfaceMesh::meshSubDir = "triSurface";
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
//// Special version of Time::findInstance that does not check headerOk
//// to search for instances of raw files
//Foam::word Foam::triSurfaceMesh::findRawInstance
//(
// const Time& runTime,
// const fileName& dir,
// const word& name
//)
//{
// // Check current time first
// if (isFile(runTime.path()/runTime.timeName()/dir/name))
// {
// return runTime.timeName();
// }
// instantList ts = runTime.times();
// label instanceI;
//
// for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
// {
// if (ts[instanceI].value() <= runTime.timeOutputValue())
// {
// break;
// }
// }
//
// // continue searching from here
// for (; instanceI >= 0; --instanceI)
// {
// if (isFile(runTime.path()/ts[instanceI].name()/dir/name))
// {
// return ts[instanceI].name();
// }
// }
//
//
// // not in any of the time directories, try constant
//
// // Note. This needs to be a hard-coded constant, rather than the
// // constant function of the time, because the latter points to
// // the case constant directory in parallel cases
//
// if (isFile(runTime.path()/runTime.constant()/dir/name))
// {
// return runTime.constant();
// }
//
// FatalErrorInFunction
// << "Cannot find file \"" << name << "\" in directory "
// << runTime.constant()/dir
// << exit(FatalError);
//
// return runTime.constant();
//}
const Foam::fileName& Foam::triSurfaceMesh::checkFile
Foam::fileName Foam::triSurfaceMesh::checkFile
(
const fileName& fName,
const fileName& objectName
const IOobject& io,
const bool isGlobal
)
{
const fileName fName
(
isGlobal
? io.globalFilePath()
: io.localFilePath()
);
if (fName.empty())
{
FatalErrorInFunction
<< "Cannot find triSurfaceMesh starting from "
<< objectName << exit(FatalError);
<< io.objectPath() << exit(FatalError);
}
return fName;
}
Foam::fileName Foam::triSurfaceMesh::checkFile
(
const IOobject& io,
const dictionary& dict,
const bool isGlobal
)
{
fileName fName;
if (dict.readIfPresent("file", fName, false, false))
{
fName.expand();
if (!fName.isAbsolute())
{
fName = io.objectPath().path()/fName;
}
if (!exists(fName))
{
FatalErrorInFunction
<< "Cannot find triSurfaceMesh at " << fName
<< exit(FatalError);
}
}
else
{
fName = (isGlobal ? io.globalFilePath() : io.localFilePath());
if (!exists(fName))
{
FatalErrorInFunction
<< "Cannot find triSurfaceMesh starting from "
<< io.objectPath() << exit(FatalError);
}
}
return fName;
}
@ -227,7 +214,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s)
(
io.name(),
io.instance(),
io.local(), //"triSurfaceFields",
io.local(),
io.db(),
io.readOpt(),
io.writeOpt(),
@ -235,7 +222,7 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const triSurface& s)
)
),
triSurface(s),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
triSurfaceRegionSearch(s),
minQuality_(-1),
surfaceClosed_(-1),
outsideVolType_(volumeType::UNKNOWN)
@ -250,43 +237,21 @@ Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io)
:
// Find instance for triSurfaceMesh
searchableSurface(io),
//(
// IOobject
// (
// io.name(),
// io.time().findInstance(io.local(), word::null),
// io.local(),
// io.db(),
// io.readOpt(),
// io.writeOpt(),
// io.registerObject()
// )
//),
// Reused found instance in objectRegistry
objectRegistry
(
IOobject
(
io.name(),
static_cast<const searchableSurface&>(*this).instance(),
io.local(), //"triSurfaceFields",
searchableSurface::instance(),
io.local(),
io.db(),
io.readOpt(),
io.writeOpt(),
false // searchableSurface already registered under name
)
),
triSurface
(
checkFile
(
typeFilePath<searchableSurface>
(
static_cast<const searchableSurface&>(*this)
),
searchableSurface::objectPath()
)
),
triSurface(checkFile(static_cast<const searchableSurface&>(*this), true)),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
minQuality_(-1),
surfaceClosed_(-1),
@ -305,26 +270,14 @@ Foam::triSurfaceMesh::triSurfaceMesh
)
:
searchableSurface(io),
//(
// IOobject
// (
// io.name(),
// io.time().findInstance(io.local(), word::null),
// io.local(),
// io.db(),
// io.readOpt(),
// io.writeOpt(),
// io.registerObject()
// )
//),
// Reused found instance in objectRegistry
objectRegistry
(
IOobject
(
io.name(),
static_cast<const searchableSurface&>(*this).instance(),
io.local(), //"triSurfaceFields",
searchableSurface::instance(),
io.local(),
io.db(),
io.readOpt(),
io.writeOpt(),
@ -333,23 +286,19 @@ Foam::triSurfaceMesh::triSurfaceMesh
),
triSurface
(
checkFile
(
typeFilePath<searchableSurface>
(
static_cast<const searchableSurface&>(*this)
),
searchableSurface::objectPath()
)
checkFile(static_cast<const searchableSurface&>(*this), dict, true)
),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
minQuality_(-1),
surfaceClosed_(-1),
outsideVolType_(volumeType::UNKNOWN)
{
// Reading from supplied file name instead of objectPath/filePath
dict.readIfPresent("file", fName_, false, false);
scalar scaleFactor = 0;
// allow rescaling of the surface points
// Allow rescaling of the surface points
// eg, CAD geometries are often done in millimeters
if (dict.readIfPresent("scale", scaleFactor) && scaleFactor > 0)
{
@ -372,6 +321,97 @@ Foam::triSurfaceMesh::triSurfaceMesh
}
Foam::triSurfaceMesh::triSurfaceMesh(const IOobject& io, const bool isGlobal)
:
// Find instance for triSurfaceMesh
searchableSurface(io),
// Reused found instance in objectRegistry
objectRegistry
(
IOobject
(
io.name(),
searchableSurface::instance(),
io.local(),
io.db(),
io.readOpt(),
io.writeOpt(),
false // searchableSurface already registered under name
)
),
triSurface
(
checkFile(static_cast<const searchableSurface&>(*this), isGlobal)
),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
minQuality_(-1),
surfaceClosed_(-1),
outsideVolType_(volumeType::UNKNOWN)
{
const pointField& pts = triSurface::points();
bounds() = boundBox(pts, isGlobal);
}
Foam::triSurfaceMesh::triSurfaceMesh
(
const IOobject& io,
const dictionary& dict,
const bool isGlobal
)
:
searchableSurface(io),
// Reused found instance in objectRegistry
objectRegistry
(
IOobject
(
io.name(),
searchableSurface::instance(),
io.local(),
io.db(),
io.readOpt(),
io.writeOpt(),
false // searchableSurface already registered under name
)
),
triSurface
(
checkFile(static_cast<const searchableSurface&>(*this), dict, isGlobal)
),
triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
minQuality_(-1),
surfaceClosed_(-1),
outsideVolType_(volumeType::UNKNOWN)
{
// Reading from supplied file name instead of objectPath/filePath
dict.readIfPresent("file", fName_, false, false);
scalar scaleFactor = 0;
// Allow rescaling of the surface points
// eg, CAD geometries are often done in millimeters
if (dict.readIfPresent("scale", scaleFactor) && scaleFactor > 0)
{
Info<< searchableSurface::name() << " : using scale " << scaleFactor
<< endl;
triSurface::scalePoints(scaleFactor);
}
const pointField& pts = triSurface::points();
bounds() = boundBox(pts, isGlobal);
// Have optional minimum quality for normal calculation
if (dict.readIfPresent("minQuality", minQuality_) && minQuality_ > 0)
{
Info<< searchableSurface::name()
<< " : ignoring triangles with quality < "
<< minQuality_ << " for normals calculation." << endl;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::triSurfaceMesh::~triSurfaceMesh()
@ -495,7 +535,7 @@ Foam::triSurfaceMesh::edgeTree() const
label nPoints;
PatchTools::calcBounds
(
static_cast<const triSurface&>(*this),
*this,
bb,
nPoints
);
@ -526,7 +566,7 @@ Foam::triSurfaceMesh::edgeTree() const
bEdges // selected edges
),
bb, // bb
maxTreeDepth(), // maxLevel
maxTreeDepth(), // maxLevel
10, // leafsize
3.0 // duplicity
)
@ -552,7 +592,6 @@ const Foam::wordList& Foam::triSurfaceMesh::regions() const
}
// Find out if surface is closed.
bool Foam::triSurfaceMesh::hasVolumeType() const
{
if (surfaceClosed_ == -1)
@ -660,7 +699,7 @@ void Foam::triSurfaceMesh::getNormal
vectorField& normal
) const
{
const triSurface& s = static_cast<const triSurface&>(*this);
const triSurface& s = *this;
const pointField& pts = s.points();
normal.setSize(info.size());
@ -865,7 +904,24 @@ bool Foam::triSurfaceMesh::writeObject
runTime.timeName();
}
fileName fullPath(searchableSurface::objectPath());
fileName fullPath;
if (fName_.size())
{
// Override file name
fullPath = fName_;
fullPath.expand();
if (!fullPath.isAbsolute())
{
// Add directory from regIOobject
fullPath = searchableSurface::objectPath().path()/fullPath;
}
}
else
{
fullPath = searchableSurface::objectPath();
}
if (!mkDir(fullPath.path()))
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
@ -68,10 +68,11 @@ class triSurfaceMesh
public triSurface,
public triSurfaceRegionSearch
{
private:
// Private member data
//- Supplied fileName override
fileName fName_;
//- Optional min triangle quality. Triangles below this get
// ignored for normal calculation
scalar minQuality_;
@ -91,19 +92,15 @@ private:
// Private Member Functions
////- Helper: find instance of files without header
//static word findRawInstance
//(
// const Time&,
// const fileName&,
// const word&
//);
//- Return fileName to load IOobject from
static fileName checkFile(const IOobject& io, const bool isGlobal);
//- Check file existence
static const fileName& checkFile
//- Return fileName to load IOobject from. Optional override of fileName
static fileName checkFile
(
const fileName& fName,
const fileName& objectName
const IOobject&,
const dictionary&,
const bool isGlobal
);
//- Helper function for isSurfaceClosed
@ -149,7 +146,7 @@ public:
//- Construct from triSurface
triSurfaceMesh(const IOobject&, const triSurface&);
//- Construct read.
//- Construct read
triSurfaceMesh(const IOobject& io);
//- Construct from IO and dictionary (used by searchableSurface).
@ -161,6 +158,19 @@ public:
);
// Special constructors for use by distributedTriSurface. File search
// status (local/global) supplied.
triSurfaceMesh(const IOobject& io, const bool isGlobal);
triSurfaceMesh
(
const IOobject& io,
const dictionary& dict,
const bool isGlobal
);
//- Destructor
virtual ~triSurfaceMesh();
@ -293,9 +303,30 @@ public:
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const;
//- Is object global
virtual bool global() const
{
return true;
}
//- Return complete path + object name if the file exists
// either in the case/processor or case otherwise null
virtual fileName filePath() const
{
return searchableSurface::globalFilePath();
}
};
//- Template function for obtaining global status
template<>
inline bool typeGlobal<triSurfaceMesh>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -27,56 +27,37 @@ License
#include "triSurface.H"
#include "surfaceIntersection.H"
#include "meshTools.H"
#include "OFstream.H"
#include "OBJstream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(edgeSurface, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Write whole pointField and edges to stream
void Foam::edgeSurface::writeOBJ
(
const pointField& points,
const edgeList& edges,
Ostream& os
)
// file-scope
// Write points in obj format
static void writeObjPoints(const UList<point>& pts, Ostream& os)
{
forAll(points, pointi)
forAll(pts, i)
{
const point& pt = points[pointi];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
}
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
os << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
const point& pt = pts[i];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
}
// Write whole pointField and selected edges to stream
void Foam::edgeSurface::writeOBJ
void writeObjEdges
(
const pointField& points,
const UList<point>& points,
const edgeList& edges,
const labelList& edgeLabels,
Ostream& os
)
{
forAll(points, pointi)
{
const point& pt = points[pointi];
writeObjPoints(points, os);
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
}
forAll(edgeLabels, i)
{
const edge& e = edges[edgeLabels[i]];
@ -85,6 +66,10 @@ void Foam::edgeSurface::writeOBJ
}
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Pointedges in edgeSurface indices only.
void Foam::edgeSurface::calcPointEdges()
@ -253,29 +238,16 @@ Foam::edgeSurface::edgeSurface
}
// Add intersection edges to faceEdges
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
forAllConstIter(labelPairLookup, inter.facePairToEdge(), iter)
forAllConstIters(inter.facePairToEdgeId(), iter)
{
// The faceId from the correct surface
const label facei = iter.key()[isFirstSurface ? 0 : 1];
// Edge label in intersection
const label edgeI = iter();
// Get the face from the correct surface
const FixedList<label, 2>& twoFaces = iter.key();
label facei;
if (isFirstSurface)
{
facei = twoFaces[0];
}
else
{
facei = twoFaces[1];
}
const label edgeI = iter.object();
// Store on face-edge addressing. (note: offset edge)
allFaceEdges[facei].append(edgeI + nSurfaceEdges_);
@ -312,18 +284,17 @@ Foam::edgeSurface::edgeSurface
<< " to " << faceFName << endl;
OFstream fStream(faceFName);
writeOBJ(points_, edges_, fEdges, fStream);
writeObjEdges(points_, edges_, fEdges, fStream);
}
}
Pout<< "edgeSurface : Dumping edges to edges.obj" << endl;
OFstream eStream("edges.obj");
writeOBJ(points_, edges_, eStream);
OBJstream("edges.obj").write(edges_, points_);
Pout<< "edgeSurface : Dumping intersectionEdges to"
<< " intersectionEdges.obj" << endl;
OFstream intEdgesStream("intersectionEdges.obj");
OFstream intEdgesStream("intersectionEdges.obj");
labelList edgeLabels(edges_.size() - nSurfaceEdges_);
label i = 0;
@ -332,7 +303,7 @@ Foam::edgeSurface::edgeSurface
edgeLabels[i++] = edgeI;
}
writeOBJ(points_, edges_, edgeLabels, intEdgesStream);
writeObjEdges(points_, edges_, edgeLabels, intEdgesStream);
}
}

View File

@ -93,25 +93,12 @@ private:
//- From face to our edges_
labelListList faceEdges_;
//- Constructed from above: pointEdges
labelListList pointEdges_;
// Private Member Functions
//- Dump edges in obj format
static void writeOBJ(const pointField&, const edgeList&, Ostream&);
//- Dump selected edges in obj format
static void writeOBJ
(
const pointField&,
const edgeList&,
const labelList&,
Ostream&
);
//- Calculate pointEdges
void calcPointEdges();

View File

@ -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) 2017 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,11 +41,20 @@ Description
hit of both faces and an edge is created between the retrieved vertex and
the new one.
Note: when doing intersecting itself uses intersection::planarTol() as a
fraction of
Note: when doing intersecting itself uses 'tolerance' as a fraction of
current edge length to determine if intersection is a point-touching one
instead of an edge-piercing action.
Some constructors allow a dictionary of intersection controls:
\table
Property | Description | Type | Default value
tolerance | Edge-length tolerance | scalar | 1e-3
allowEdgeHits | Edge-end cuts another edge | bool | true
snap | Snap near end-points | bool | true
warnDegenerate | Number of warnings about degenerate edges | label | 0
intersectionMethod | Control for self intersection | (self,region,none)
\endtable
SourceFiles
surfaceIntersection.C
surfaceIntersectionFuncs.C
@ -58,11 +67,12 @@ SourceFiles
#include "DynamicList.H"
#include "point.H"
#include "edge.H"
#include "labelPairHashes.H"
#include "typeInfo.H"
#include "edgeHashes.H"
#include "edgeList.H"
#include "labelPairHashes.H"
#include "pointIndexHit.H"
#include "typeInfo.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -74,50 +84,88 @@ class triSurfaceSearch;
class triSurface;
class edgeIntersections;
//- Key is non-commutative pair of labels. Value is commutative pair of labels
typedef LabelPairMap<edge> labelPairEdgeLookup;
//- Map from edge back to all parents (pairs of faces)
typedef EdgeMap<labelPairHashSet> edgelabelPairHashLookup;
/*---------------------------------------------------------------------------*\
Class surfaceIntersection Declaration
Class surfaceIntersection Declaration
\*---------------------------------------------------------------------------*/
class surfaceIntersection
{
public:
//- Surface intersection types for classify, doCutEdges
enum intersectionType
{
FIRST, //!< First surface
SECOND, //!< Second surface
SELF, //!< Self-intersection
SELF_REGION, //!< Self-intersection, region-wise only
NONE //!< None = invalid (for input only)
};
//- The user-selectable self-intersection enumeration names
static const Enum<intersectionType> selfIntersectionNames;
private:
// Private data
//- Tolerance for intersections
scalar tolerance_;
//- Allow edge-ends to cut another edge.
bool allowEdgeHits_;
//- Snap cut points near edge ends (default: true)
bool snapToEnd_;
//- Maximum number of warnings about degenerate edges
label warnDegenerate_;
//- Newly introduced points.
pointField cutPoints_;
//- Newly introduced edges (are on both surfaces). Reference into
// cutPoints.
//- Newly introduced edges (are on both surfaces).
// Reference into cutPoints.
edgeList cutEdges_;
//- From face on surf1 and face on surf2 to intersection point
// (label in cutPoints)
labelPairLookup facePairToVertex_;
//- From face on surf1 and face on surf2 to intersection edge
// (label in cutEdges)
labelPairLookup facePairToEdge_;
labelPairEdgeLookup facePairToEdge_;
//- Edges on surf1 that are cut. From edge on surf1 to label in cutPoint
// If multiple cuts:sorted from edge.start to edge.end
//- From face on surf1 and face on surf2 to intersection edgeId
// (label in cutEdges)
labelPairLookup facePairToEdgeId_;
//- Edges on surf1 that are cut.
// From edgeId on surf1 to location in cutPoint
labelListList surf1EdgeCuts_;
//- Edges on surf2 that are cut. From edge on surf2 to label in cutPoint
// If multiple cuts:sorted from edge.start to edge.end
//- Edges on surf2 that are cut.
// From edgeId on surf2 to location in cutPoint
labelListList surf2EdgeCuts_;
//- Temporary storage to manage edge-edge self-intersections.
edgeHashSet edgeEdgeIntersection_;
//- Temporary storage to manage cuts/intersections from the edge ends
Map<label> snappedEnds_;
//- Temporary storage
EdgeMap<label> edgeToId_;
// Private Member Functions
//- Write point in obj format.
static void writeOBJ(const point& pt, Ostream& os);
//- Write points and edges in obj format
static void writeOBJ
(
const List<point>&,
const List<edge>&,
Ostream&
);
//- Adjust intersection options according to the dictionary entries
void setOptions(const dictionary& dict);
//- Transfer contents of List<DynamicList<..>> to List<List<..>>
template<class T>
@ -138,9 +186,6 @@ class surfaceIntersection
// to new (-1 if element removed)
static void removeDuplicates(const labelList& map, labelList& labels);
//- Apply map to elements of a labelList
static void inlineRemap(const labelList& map, labelList& elems);
// Remove all duplicate and degenerate elements. Return unique elements
// and map from old to new.
static edgeList filterEdges(const edgeList&, labelList& map);
@ -148,30 +193,6 @@ class surfaceIntersection
//- Remove all duplicate elements.
static labelList filterLabels(const labelList& elems, labelList& map);
//- Do some checks if edge and face (resulting from hit)
// should not be considered. Returns true if can be discarded.
static bool excludeEdgeHit
(
const triSurface& surf,
const label edgeI,
const label facei,
const scalar tol
);
////- Given edge (eStart - eEnd) and normal direction construct plane
//// and intersect all edges of hitFace with it.
//// Return the edge and coordinate of hit.
//static pointIndexHit faceEdgeIntersection
//(
// const triSurface&,
// const label hitFacei,
//
// const vector& n,
// const point& eStart,
// const point& eEnd
//);
//- Debugging: Dump intersected edges to stream
void writeIntersectedEdges
(
@ -188,18 +209,19 @@ class surfaceIntersection
const scalar endTol,
const point& p,
const edge& e,
const pointField& points
const UList<point>& points
);
//- Update reference between faceA and faceB. Updates facePairToVertex_
// (first occurrence of face pair) and facePairToEdge_ (second occ.)
//- Update reference between faceA and faceB.
// Updates facePairToEdge_ and facePairToEdgeId_ (on the second hit)
void storeIntersection
(
const bool isFirstSurf,
const enum intersectionType cutFrom,
const labelList& facesA,
const label faceB,
DynamicList<edge>&,
DynamicList<point>&
const UList<point>& allCutPoints,
const label cutPointId,
DynamicList<edge>& allCutEdges
);
//- Investigate pHit to whether is case of point hits point,
@ -209,13 +231,12 @@ class surfaceIntersection
const triSurface& surf1,
const scalarField& surf1PointTol,
const triSurface& surf2,
const bool isFirstSurf,
const enum intersectionType cutFrom,
const label edgeI,
const scalar tolDim,
const pointIndexHit& pHit,
DynamicList<edge>& allCutEdges,
DynamicList<point>& allCutPoints,
DynamicList<edge>& allCutEdges,
List<DynamicList<label>>& surfEdgeCuts
);
@ -224,17 +245,21 @@ class surfaceIntersection
(
const triSurface& surf1,
const triSurfaceSearch& querySurf2,
const bool isFirstSurf,
const bool isSelfIntersection,
const enum intersectionType cutFrom,
DynamicList<edge>& allCutEdges,
DynamicList<point>& allCutPoints,
DynamicList<edge>& allCutEdges,
List<DynamicList<label>>& surfEdgeCuts
);
//- Join disconnected intersection points
void joinDisconnected(DynamicList<edge>& allCutEdges);
public:
// Public Data, Declarations
ClassName("surfaceIntersection");
@ -243,6 +268,23 @@ public:
//- Construct null
surfaceIntersection();
//- Construct from two surfaces.
// Does its own cutting. Has problems with degenerate cuts
surfaceIntersection
(
const triSurfaceSearch& querySurf1,
const triSurfaceSearch& querySurf2,
const dictionary& dict = dictionary::null
);
//- Construct from self-intersections.
// Does its own cutting, but has problems with degenerate cuts
surfaceIntersection
(
const triSurfaceSearch& querySurf1,
const dictionary& dict = dictionary::null
);
//- Construct from precalculated intersection information.
// Advantage: intersection information is guaranteed to have no
// degenerate cuts.
@ -254,36 +296,36 @@ public:
const edgeIntersections& intersections2
);
//- Construct from two surfaces. Does all its own cutting.
// Has problems with degenerate cuts
surfaceIntersection
(
const triSurfaceSearch& querySurf1,
const triSurfaceSearch& querySurf2
);
//- Special: intersect surface with itself. Used to check for
// self-intersection.
surfaceIntersection(const triSurfaceSearch& querySurf1);
// Member Functions
//- The list of cut points
const pointField& cutPoints() const;
//- The list of created edges
const edgeList& cutEdges() const;
const labelPairLookup& facePairToVertex() const;
const labelPairLookup& facePairToEdge() const;
//- Lookup of pairs of faces to created edges
const labelPairLookup& facePairToEdgeId() const;
//- Access either surf1EdgeCuts (isFirstSurface = true) or
// surf2EdgeCuts
const labelListList& edgeCuts(const bool) const;
const labelListList& edgeCuts(const bool isFirstSurf) const;
//- List of cut points on edges of surface1
const labelListList& surf1EdgeCuts() const;
//- List of cut points on edges of surface2
const labelListList& surf2EdgeCuts() const;
//- Geometric merge points (points within mergeDist) prior to
// automatically calling mergeEdges().
void mergePoints(const scalar mergeDist);
//- Merge duplicate edges
void mergeEdges();
};

View File

@ -24,41 +24,32 @@ License
\*---------------------------------------------------------------------------*/
#include "surfaceIntersection.H"
#include "triSurface.H"
#include "triSurfaceSearch.H"
#include "labelPairHashes.H"
#include "OFstream.H"
#include "HashSet.H"
#include "triSurface.H"
#include "pointIndexHit.H"
#include "meshTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
void Foam::surfaceIntersection::writeOBJ(const point& pt, Ostream& os)
namespace Foam
{
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
}
void Foam::surfaceIntersection::writeOBJ
(
const List<point>& pts,
const List<edge>& edges,
Ostream& os
)
// file-scope
// Write points in obj format
static void writeObjPoints(const UList<point>& pts, Ostream& os)
{
forAll(pts, i)
{
writeOBJ(pts[i], os);
}
forAll(edges, i)
{
const edge& e = edges[i];
os << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
const point& pt = pts[i];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
}
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Get minimum length of all edges connected to point
Foam::scalar Foam::surfaceIntersection::minEdgeLen
@ -162,20 +153,6 @@ void Foam::surfaceIntersection::removeDuplicates
}
// Remap.
void Foam::surfaceIntersection::inlineRemap
(
const labelList& map,
labelList& elems
)
{
forAll(elems, elemI)
{
elems[elemI] = map[elems[elemI]];
}
}
// Remove all duplicate and degenerate elements. Return unique elements and
// map from old to new.
Foam::edgeList Foam::surfaceIntersection::filterEdges
@ -265,14 +242,8 @@ void Foam::surfaceIntersection::writeIntersectedEdges
// Dump all points (surface followed by cutPoints)
const pointField& pts = surf.localPoints();
forAll(pts, pointi)
{
writeOBJ(pts[pointi], os);
}
forAll(cutPoints(), cutPointi)
{
writeOBJ(cutPoints()[cutPointi], os);
}
writeObjPoints(pts, os);
writeObjPoints(cutPoints(), os);
forAll(edgeCutVerts, edgeI)
{
@ -284,16 +255,16 @@ void Foam::surfaceIntersection::writeIntersectedEdges
// Start of original edge to first extra point
os << "l " << e.start()+1 << ' '
<< extraVerts[0] + surf.nPoints() + 1 << endl;
<< extraVerts[0] + surf.nPoints() + 1 << nl;
for (label i = 1; i < extraVerts.size(); i++)
{
os << "l " << extraVerts[i-1] + surf.nPoints() + 1 << ' '
<< extraVerts[i] + surf.nPoints() + 1 << endl;
<< extraVerts[i] + surf.nPoints() + 1 << nl;
}
os << "l " << extraVerts.last() + surf.nPoints() + 1
<< ' ' << e.end()+1 << endl;
<< ' ' << e.end()+1 << nl;
}
}
}
@ -306,7 +277,7 @@ Foam::label Foam::surfaceIntersection::classify
const scalar endTol,
const point& p,
const edge& e,
const pointField& points
const UList<point>& points
)
{
if (mag(p - points[e.start()]) < startTol)

Some files were not shown because too many files have changed in this diff Show More