diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index 7ba05f9d0e..6ce930eede 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C @@ -301,17 +301,26 @@ int main(int argc, char *argv[]) Pout<< nl << "Writing featureEdgeMesh to constant/featureEdgeMesh." << endl; + fileName sFeatFileName = surfFileName.lessExt().name(); + featureEdgeMesh feMesh ( - newSet, - runTime, - surfFileName.lessExt().name() + ".featureEdgeMesh" + IOobject + ( + sFeatFileName + ".featureEdgeMesh", + runTime.constant(), + "featureEdgeMesh", + runTime, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + newSet ); - feMesh.writeObj(surfFileName.lessExt().name()); - feMesh.write(); + feMesh.writeObj(sFeatFileName); + Info<< "End\n" << endl; return 0; diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C index da89dcf2d5..e5f89cc1c5 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.C @@ -54,6 +54,97 @@ Foam::label Foam::featureEdgeMesh::nPointTypes = 4; Foam::label Foam::featureEdgeMesh::nEdgeTypes = 5; +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +Foam::featureEdgeMesh::pointStatus Foam::featureEdgeMesh::classifyFeaturePoint +( + label ptI +) const +{ + labelList ptEds(pointEdges()[ptI]); + + label nPtEds = ptEds.size(); + label nExternal = 0; + label nInternal = 0; + + if (nPtEds == 0) + { + // There are no edges attached to the point, this is a problem + return NONFEATURE; + } + + forAll(ptEds, i) + { + edgeStatus edStat = getEdgeStatus(ptEds[i]); + + if (edStat == EXTERNAL) + { + nExternal++; + } + else if (edStat == INTERNAL) + { + nInternal++; + } + } + + if (nExternal == nPtEds) + { + return CONVEX; + } + else if (nInternal == nPtEds) + { + return CONCAVE; + } + else + { + return MIXED; + } +} + + +Foam::featureEdgeMesh::edgeStatus Foam::featureEdgeMesh::classifyEdge +( + const List& norms, + const labelList& edNorms, + const vector& fC0tofC1 +) const +{ + label nEdNorms = edNorms.size(); + + if (nEdNorms == 1) + { + return OPEN; + } + else if (nEdNorms == 2) + { + const vector n0(norms[edNorms[0]]); + const vector n1(norms[edNorms[1]]); + + if ((n0 & n1) > cosNormalAngleTol_) + { + return FLAT; + } + else if ((fC0tofC1 & n0) > 0.0) + { + return INTERNAL; + } + else + { + return EXTERNAL; + } + } + else if (nEdNorms > 2) + { + return MULTIPLE; + } + else + { + // There is a problem - the edge has no normals + return NONE; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::featureEdgeMesh::featureEdgeMesh(const IOobject& io) @@ -189,23 +280,11 @@ Foam::featureEdgeMesh::featureEdgeMesh Foam::featureEdgeMesh::featureEdgeMesh ( - const surfaceFeatures& sFeat, - const objectRegistry& obr, - const fileName& sFeatFileName + const IOobject& io, + const surfaceFeatures& sFeat ) : - regIOobject - ( - IOobject - ( - sFeatFileName, - obr.time().constant(), - "featureEdgeMesh", - obr, - IOobject::NO_READ, - IOobject::NO_WRITE - ) - ), + regIOobject(io), edgeMesh(pointField(0), edgeList(0)), concaveStart_(-1), mixedStart_(-1), @@ -367,9 +446,8 @@ Foam::featureEdgeMesh::featureEdgeMesh ( "Foam::featureEdgeMesh::featureEdgeMesh" "(" - " const surfaceFeatures& sFeat," - " const objectRegistry& obr," - " const fileName& sFeatFileName" + "const IOobject& io, " + "const surfaceFeatures& sFeat" ")" ) << nl << "classifyEdge returned NONE on edge " @@ -444,9 +522,8 @@ Foam::featureEdgeMesh::featureEdgeMesh ( "Foam::featureEdgeMesh::featureEdgeMesh" "(" - " const surfaceFeatures& sFeat," - " const objectRegistry& obr," - " const fileName& sFeatFileName" + "const IOobject& io, " + "const surfaceFeatures& sFeat" ")" ) << nl << "classifyFeaturePoint returned NONFEATURE on point at " @@ -586,97 +663,6 @@ Foam::featureEdgeMesh::~featureEdgeMesh() {} -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -Foam::featureEdgeMesh::pointStatus Foam::featureEdgeMesh::classifyFeaturePoint -( - label ptI -) const -{ - labelList ptEds(pointEdges()[ptI]); - - label nPtEds = ptEds.size(); - label nExternal = 0; - label nInternal = 0; - - if (nPtEds == 0) - { - // There are no edges attached to the point, this is a problem - return NONFEATURE; - } - - forAll(ptEds, i) - { - edgeStatus edStat = getEdgeStatus(ptEds[i]); - - if (edStat == EXTERNAL) - { - nExternal++; - } - else if (edStat == INTERNAL) - { - nInternal++; - } - } - - if (nExternal == nPtEds) - { - return CONVEX; - } - else if (nInternal == nPtEds) - { - return CONCAVE; - } - else - { - return MIXED; - } -} - - -Foam::featureEdgeMesh::edgeStatus Foam::featureEdgeMesh::classifyEdge -( - const List& norms, - const labelList& edNorms, - const vector& fC0tofC1 -) const -{ - label nEdNorms = edNorms.size(); - - if (nEdNorms == 1) - { - return OPEN; - } - else if (nEdNorms == 2) - { - const vector n0(norms[edNorms[0]]); - const vector n1(norms[edNorms[1]]); - - if ((n0 & n1) > cosNormalAngleTol_) - { - return FLAT; - } - else if ((fC0tofC1 & n0) > 0.0) - { - return INTERNAL; - } - else - { - return EXTERNAL; - } - } - else if (nEdNorms > 2) - { - return MULTIPLE; - } - else - { - // There is a problem - the edge has no normals - return NONE; - } -} - - // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // void Foam::featureEdgeMesh::nearestFeatureEdge diff --git a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H index 93f034d9aa..1afd4bf14e 100644 --- a/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H +++ b/src/edgeMesh/featureEdgeMesh/featureEdgeMesh.H @@ -27,10 +27,10 @@ Class Description Feature points are a sorted subset at the start of the overall points list: - 0 .. concaveStart_-1 : convex points (w.r.t normals) - concaveStart_-1 .. mixedStart_-1 : concave points - mixedStart_ .. nonFeatureStart_ : mixed internal/external points - nonFeatureStart_ .. size-1 : non-feature points + 0 .. concaveStart_-1 : convex points (w.r.t normals) + concaveStart_ .. mixedStart_-1 : concave points + mixedStart_ .. nonFeatureStart_ : 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) @@ -55,11 +55,9 @@ SourceFiles #include "edgeMesh.H" #include "surfaceFeatures.H" -#include "objectRegistry.H" #include "IOdictionary.H" #include "indexedOctree.H" #include "treeDataEdge.H" -#include "pointIndexHit.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -202,14 +200,12 @@ public: const Xfer& ); - //- Construct (read) given surfaceFeatures, an objectRegistry and a - // fileName to write to. Extracts, classifies and reorders the data - // from surfaceFeatures. + //- Construct given surfaceFeatures, extracts, classifies and reorders + // the data. featureEdgeMesh ( - const surfaceFeatures& sFeat, - const objectRegistry& obr, - const fileName& sFeatFileName + const IOobject& io, + const surfaceFeatures& sFeat ); //- Construct from all components diff --git a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 2651d5a500..1dbe372db0 100644 --- a/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/src/mesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -54,17 +54,25 @@ Foam::conformationSurfaces::conformationSurfaces surfaceConformationDict.subDict("geometryToConformTo") ); + const dictionary& additionalFeaturesDict + ( + surfaceConformationDict.subDict("additionalFeatures") + ); + Info<< nl << "Reading geometryToConformTo" << endl; - surfaces_.setSize(surfacesDict.size()); + surfaces_.setSize(surfacesDict.size(), -1); allGeometryToSurfaces_.setSize(allGeometry_.size(), -1); - baffleSurfaces_.setSize(surfacesDict.size()); + baffleSurfaces_.setSize(surfacesDict.size(), false); - features_.setSize(surfacesDict.size()); + // Features may be attached to host surfaces or independent + features_.setSize(surfacesDict.size() + additionalFeaturesDict.size()); - patchOffsets_.setSize(surfacesDict.size()); + label featureI = 0; + + patchOffsets_.setSize(surfacesDict.size(), -1); label surfI = 0; @@ -84,6 +92,8 @@ Foam::conformationSurfaces::conformationSurfaces << exit(FatalError); } + Info<< nl << " " << iter().keyword() << endl; + patchOffsets_[surfI] = patchNames_.size(); patchNames_.append(allGeometry.regionNames()[surfaces_[surfI]]); @@ -105,9 +115,11 @@ Foam::conformationSurfaces::conformationSurfaces { fileName feMeshName(surfaceSubDict.lookup("featureEdgeMesh")); + Info<< " features: " << feMeshName<< endl; + features_.set ( - surfI, + featureI++, new featureEdgeMesh ( IOobject @@ -115,7 +127,8 @@ Foam::conformationSurfaces::conformationSurfaces feMeshName, cvMesh_.time().findInstance ( - "featureEdgeMesh", feMeshName + "featureEdgeMesh", + feMeshName ), "featureEdgeMesh", cvMesh_.time(), @@ -135,25 +148,25 @@ Foam::conformationSurfaces::conformationSurfaces } else if (featureMethod == "none") { - fileName feMeshName(surfaceName + "_noFeatures"); + // fileName feMeshName(surfaceName + "_noFeatures"); - features_.set - ( - surfI, - new featureEdgeMesh - ( - IOobject - ( - feMeshName, - cvMesh_.time().constant(), - "featureEdgeMesh", - cvMesh_.time(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ) - ) - ); + // features_.set + // ( + // featureI++, + // new featureEdgeMesh + // ( + // IOobject + // ( + // feMeshName, + // cvMesh_.time().constant(), + // "featureEdgeMesh", + // cvMesh_.time(), + // IOobject::NO_READ, + // IOobject::NO_WRITE, + // false + // ) + // ) + // ); } else { @@ -166,6 +179,60 @@ Foam::conformationSurfaces::conformationSurfaces surfI++; } + if (!additionalFeaturesDict.empty()) + { + Info<< nl << "Reading additionalFeatures" << endl; + } + + forAllConstIter(dictionary, additionalFeaturesDict, iter) + { + word featureName = iter().keyword(); + + Info<< nl << " " << iter().keyword() << endl; + + const dictionary& featureSubDict + ( + additionalFeaturesDict.subDict(featureName) + ); + + word featureMethod = featureSubDict.lookupOrDefault + ( + "featureMethod", + word("none") + ); + + if (featureMethod == "featureEdgeMesh") + { + fileName feMeshName(featureSubDict.lookup("featureEdgeMesh")); + + Info<< " features: " << feMeshName << endl; + + features_.set + ( + featureI++, + new featureEdgeMesh + ( + IOobject + ( + feMeshName, + cvMesh_.time().findInstance + ( + "featureEdgeMesh", + feMeshName + ), + "featureEdgeMesh", + cvMesh_.time(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) + ); + } + } + + // Remove unnecessary space from the features list + features_.setSize(featureI); + bounds_ = searchableSurfacesQueries::bounds(allGeometry_, surfaces_); spanMag_ = bounds_.mag();