From 261b4dc28f8a92cee9cda042f42a4575a14ab154 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 22 Apr 2009 18:47:13 +0100 Subject: [PATCH] Basic featureEdgeMesh functionality. Dropped intermediate edgeMesh, not serving any purpose, moved io into featureEdgeMesh. Reads and writes from file. Can construct self from surfaceFeatures object. This functionality added to surfaceFeatureExtract, writing to constant/featureEdgeMesh. --- .../surfaceFeatureExtract/Make/options | 2 + .../surfaceFeatureExtract.C | 35 +- src/edgeMesh/Make/files | 2 - src/edgeMesh/Make/options | 2 + src/edgeMesh/edgeMesh/edgeMesh.C | 109 --- src/edgeMesh/edgeMesh/edgeMesh.H | 95 --- .../featureEdgeMesh/featureEdgeMesh.C | 738 +++++++++++++++++- .../featureEdgeMesh/featureEdgeMesh.H | 143 +++- .../featureEdgeMesh/featureEdgeMeshI.H | 159 +++- .../primitiveEdgeMesh/primitiveEdgeMesh.C | 36 +- .../primitiveEdgeMesh/primitiveEdgeMesh.H | 7 + .../primitiveEdgeMesh/primitiveEdgeMeshI.H | 10 + 12 files changed, 1065 insertions(+), 273 deletions(-) delete mode 100644 src/edgeMesh/edgeMesh/edgeMesh.C delete mode 100644 src/edgeMesh/edgeMesh/edgeMesh.H diff --git a/applications/utilities/surface/surfaceFeatureExtract/Make/options b/applications/utilities/surface/surfaceFeatureExtract/Make/options index 02e49d32c6..9c37e9e1be 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/Make/options +++ b/applications/utilities/surface/surfaceFeatureExtract/Make/options @@ -1,8 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/cfdTools/general/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = \ -lmeshTools \ + -ledgeMesh \ -ltriSurface diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 8907ac46db..0522550729 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -30,10 +30,13 @@ Description \*---------------------------------------------------------------------------*/ + #include "triangle.H" #include "triSurface.H" #include "argList.H" +#include "Time.H" #include "surfaceFeatures.H" +#include "featureEdgeMesh.H" #include "treeBoundBox.H" #include "meshTools.H" #include "OFstream.H" @@ -108,9 +111,11 @@ int main(int argc, char *argv[]) argList::validOptions.insert("minElem", "number of edges in feature"); argList::validOptions.insert("subsetBox", "((x0 y0 z0)(x1 y1 z1))"); argList::validOptions.insert("deleteBox", "((x0 y0 z0)(x1 y1 z1))"); - argList args(argc, argv); - Pout<< "Feature line extraction is only valid on closed manifold surfaces." +# include "setRootCase.H" +# include "createTime.H" + + Pout<< "Feature line extraction is only valid on closed manifold surfaces." << endl; @@ -159,7 +164,7 @@ int main(int argc, char *argv[]) set = surfaceFeatures(surf, includedAngle); - Pout<< endl << "Writing initial features" << endl; + Pout<< endl << "Writing initial features" << endl; set.write("initial.fSet"); set.writeObj("initial"); } @@ -195,7 +200,7 @@ int main(int argc, char *argv[]) minLen = readScalar(IStringStream(args.options()["minLen"])()); Pout<< "Removing features of length < " << minLen << endl; } - + label minElem = 0; if (args.options().found("minElem")) { @@ -207,7 +212,7 @@ int main(int argc, char *argv[]) if (minLen > 0 || minLen > 0) { set.trimFeatures(minLen, minElem); - Pout<< endl << "Removed small features" << endl; + Pout<< endl << "Removed small features" << endl; } @@ -254,11 +259,10 @@ int main(int argc, char *argv[]) Pout<< endl << "Writing trimmed features to " << outFileName << endl; newSet.write(outFileName); - + Pout<< endl << "Writing edge objs." << endl; newSet.writeObj("final"); - Pout<< nl << "Final feature set:" << nl << " feature points : " << newSet.featurePoints().size() << nl @@ -269,7 +273,22 @@ int main(int argc, char *argv[]) << " internal edges : " << newSet.nInternalEdges() << nl << endl; - Pout<< "End\n" << endl; + // Extracting and writing a featureEdgeMesh + + Pout<< nl << "Writing featureEdgeMesh to constant/featureEdgeMesh." + << endl; + + featureEdgeMesh feMesh + ( + newSet, + runTime, + surfFileName.lessExt().name() + ".feMesh", + true + ); + + feMesh.write(); + + Pout<< nl << "End\n" << endl; return 0; } diff --git a/src/edgeMesh/Make/files b/src/edgeMesh/Make/files index 7ec66485e7..9dcdbca4ef 100644 --- a/src/edgeMesh/Make/files +++ b/src/edgeMesh/Make/files @@ -1,8 +1,6 @@ primitiveEdgeMesh/primitiveEdgeMesh.C primitiveEdgeMesh/primitiveEdgeMeshIO.C -edgeMesh/edgeMesh.C - featureEdgeMesh/featureEdgeMesh.C LIB = $(FOAM_LIBBIN)/libedgeMesh diff --git a/src/edgeMesh/Make/options b/src/edgeMesh/Make/options index 280bd02ef2..d64c26ecad 100644 --- a/src/edgeMesh/Make/options +++ b/src/edgeMesh/Make/options @@ -1,7 +1,9 @@ EXE_INC = \ + -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ + -ltriSurface \ -lmeshTools diff --git a/src/edgeMesh/edgeMesh/edgeMesh.C b/src/edgeMesh/edgeMesh/edgeMesh.C deleted file mode 100644 index f22b3163e5..0000000000 --- a/src/edgeMesh/edgeMesh/edgeMesh.C +++ /dev/null @@ -1,109 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "edgeMesh.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - -defineTypeNameAndDebug(edgeMesh, 0); - -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::edgeMesh::edgeMesh(const IOobject& io) -: - regIOobject(io), - primitiveEdgeMesh(pointField(0), edgeList(0)) -{ - if - ( - io.readOpt() == IOobject::MUST_READ - || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) - ) - { - readStream(typeName) >> *this; - close(); - } - - if (debug) - { - Pout<< "edgeMesh::edgeMesh :" - << " constructed from IOobject :" - << " points:" << points().size() - << " edges:" << edges().size() - << endl; - } -} - - -//- Construct from components -Foam::edgeMesh::edgeMesh -( - const IOobject& io, - const pointField& points, - const edgeList& edges -) -: - regIOobject(io), - primitiveEdgeMesh(points, edges) -{} - - -// Construct as copy -Foam::edgeMesh::edgeMesh -( - const IOobject& io, - const edgeMesh& em -) -: - regIOobject(io), - primitiveEdgeMesh(em) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::edgeMesh::readData(Istream& is) -{ - is >> *this; - return !is.bad(); -} - - -bool Foam::edgeMesh::writeData(Ostream& os) const -{ - os << *this; - - return os.good(); -} - - -// ************************************************************************* // diff --git a/src/edgeMesh/edgeMesh/edgeMesh.H b/src/edgeMesh/edgeMesh/edgeMesh.H deleted file mode 100644 index ec3d7b7932..0000000000 --- a/src/edgeMesh/edgeMesh/edgeMesh.H +++ /dev/null @@ -1,95 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - Foam::edgeMesh - -Description - edges (lines), readable from file - -SourceFiles - edgeMesh.C - -\*---------------------------------------------------------------------------*/ - -#ifndef edgeMesh_H -#define edgeMesh_H - -#include "primitiveEdgeMesh.H" -#include "regIOobject.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class edgeMesh Declaration -\*---------------------------------------------------------------------------*/ - -class edgeMesh -: - public regIOobject, - public primitiveEdgeMesh -{ - -public: - - TypeName("edgeMesh"); - - - // Constructors - - //- Construct (read) given an IOobject - edgeMesh(const IOobject&); - - //- Construct from edgeMesh data - edgeMesh - ( - const IOobject&, - const pointField&, - const edgeList& - ); - - //- Construct as copy - edgeMesh(const IOobject&, const edgeMesh&); - - - //- ReadData function required for regIOobject read operation - virtual bool readData(Istream&); - - //- WriteData function required for regIOobject write operation - virtual bool writeData(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C index 9045ae5cd9..eb893e0b04 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C @@ -25,22 +25,458 @@ License \*---------------------------------------------------------------------------*/ #include "featureEdgeMesh.H" +#include "triSurface.H" #include "Random.H" +#include "Time.H" #include "meshTools.H" #include "linePointRef.H" +#include "ListListOps.H" #include "OFstream.H" #include "IFstream.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(featureEdgeMesh, 0); + +} + + +Foam::scalar Foam::featureEdgeMesh::cosNormalAngleTol_ = Foam::cos +( + 0.1*mathematicalConstant::pi/180.0 +); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io) : - edgeMesh(io), - normals_(), - edgeNormals_(edges().size()), - allEdges_(identity(edges().size())) + regIOobject(io), + primitiveEdgeMesh(pointField(0), edgeList(0)), + concaveStart_(0), + mixedStart_(0), + nonFeatureStart_(0), + internalStart_(0), + flatStart_(0), + openStart_(0), + multipleStart_(0), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0) +{ + if + ( + io.readOpt() == IOobject::MUST_READ + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + dictionary edgeMeshDict(readStream(typeName)); -{} + primitiveEdgeMesh::operator= + ( + primitiveEdgeMesh + ( + edgeMeshDict.lookup("points"), + edgeMeshDict.lookup("edges") + ) + ); + + concaveStart_ = readLabel(edgeMeshDict.lookup("concaveStart")); + + mixedStart_ = readLabel(edgeMeshDict.lookup("mixedStart")); + + nonFeatureStart_ = readLabel(edgeMeshDict.lookup("nonFeatureStart")); + + internalStart_ = readLabel(edgeMeshDict.lookup("internalStart")); + + flatStart_ = readLabel(edgeMeshDict.lookup("flatStart")); + + openStart_ = readLabel(edgeMeshDict.lookup("openStart")); + + multipleStart_ = readLabel(edgeMeshDict.lookup("multipleStart")); + + normals_ = vectorField(edgeMeshDict.lookup("normals")); + + edgeDirections_ = vectorField(edgeMeshDict.lookup("edgeDirections")); + + edgeNormals_ = labelListList(edgeMeshDict.lookup("edgeNormals")); + + featurePointNormals_ = labelListList + ( + edgeMeshDict.lookup("featurePointNormals") + ); + + regionEdges_ = labelList(edgeMeshDict.lookup("regionEdges")); + + close(); + } +} + +Foam::featureEdgeMesh::featureEdgeMesh +( + const surfaceFeatures& sFeat, + const objectRegistry& obr, + const fileName& sFeatFileName, + bool write +) +: + regIOobject + ( + IOobject + ( + sFeatFileName, + obr.time().constant(), + "featureEdgeMesh", + obr, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ), + primitiveEdgeMesh(pointField(0), edgeList(0)), + concaveStart_(-1), + mixedStart_(-1), + nonFeatureStart_(-1), + internalStart_(-1), + flatStart_(-1), + openStart_(-1), + multipleStart_(-1), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0) +{ + // Extract and reorder the data from surfaceFeatures + + // References to the surfaceFeatures data + const triSurface& surf(sFeat.surface()); + const pointField& sFeatLocalPts(surf.localPoints()); + const edgeList& sFeatEds(surf.edges()); + + // Filling the featureEdgeMesh with the raw geometrical data. + + label nFeatEds = sFeat.featureEdges().size(); + + DynamicList tmpPts; + edgeList eds(nFeatEds); + DynamicList norms; + vectorField edgeDirections(nFeatEds); + labelListList edgeNormals(nFeatEds); + DynamicList