diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C index 44a02e234a..2a958b3a3c 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C @@ -269,9 +269,10 @@ void selectCurvatureCells querySurf.surface(), querySurf, pointField(1, mesh.cellCentres()[0]), - false, - false, - false, + false, // includeCut + false, // includeInside + false, // includeOutside + false, // geometricOnly nearDist, curvature ); diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 11dccf942b..9dee4d1df9 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -143,6 +143,9 @@ FoamFile // sourceInfo // { // file "www.avl.com-geometry.stl"; +// useSurfaceOrientation false; // use closed surface inside/outside +// // test (ignores includeCut, +// // outsidePoints) // outsidePoints ((-99 -99 -59)); // definition of outside // includeCut false; // cells cut by surface // includeInside false; // cells not on outside of surf diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C index ff37610fad..f4a0009028 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C @@ -157,7 +157,30 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const { cpuTime timer; - if (includeCut_ || includeInside_ || includeOutside_) + + if (useSurfaceOrientation_ && (includeInside_ || includeOutside_)) + { + const meshSearch queryMesh(mesh_); + + //- Calculate for each searchPoint inside/outside status. + boolList isInside(querySurf().calcInside(mesh_.cellCentres())); + + Info<< " Marked inside/outside using surface orientation in = " + << timer.cpuTimeIncrement() << " s" << endl << endl; + + forAll(isInside, cellI) + { + if (isInside[cellI] && includeInside_) + { + addOrDelete(set, cellI, add); + } + else if (!isInside[cellI] && includeOutside_) + { + addOrDelete(set, cellI, add); + } + } + } + else if (includeCut_ || includeInside_ || includeOutside_) { // // Cut cells with surface and classify cells @@ -166,7 +189,7 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const // Construct search engine on mesh - meshSearch queryMesh(mesh_); + const meshSearch queryMesh(mesh_); // Check all 'outside' points @@ -196,10 +219,10 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const ); - Info<< " Marked inside/outside in = " + Info<< " Marked inside/outside using surface intersection in = " << timer.cpuTimeIncrement() << " s" << endl << endl; - + //- Add/remove cells using set forAll(cellType, cellI) { label cType = cellType[cellI]; @@ -326,6 +349,18 @@ void Foam::surfaceToCell::checkSettings() const << " or set curvature to a value -1 .. 1." << exit(FatalError); } + + if (useSurfaceOrientation_ && includeCut_) + { + FatalErrorIn + ( + "surfaceToCell:checkSettings()" + ) << "Illegal include cell specification." + << " You cannot specify both 'useSurfaceOrientation'" + << " and 'includeCut'" + << " since 'includeCut' specifies a topological split" + << exit(FatalError); + } } @@ -340,6 +375,7 @@ Foam::surfaceToCell::surfaceToCell const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature ) @@ -350,6 +386,7 @@ Foam::surfaceToCell::surfaceToCell includeCut_(includeCut), includeInside_(includeInside), includeOutside_(includeOutside), + useSurfaceOrientation_(useSurfaceOrientation), nearDist_(nearDist), curvature_(curvature), surfPtr_(new triSurface(surfName_)), @@ -371,6 +408,7 @@ Foam::surfaceToCell::surfaceToCell const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature ) @@ -381,6 +419,7 @@ Foam::surfaceToCell::surfaceToCell includeCut_(includeCut), includeInside_(includeInside), includeOutside_(includeOutside), + useSurfaceOrientation_(useSurfaceOrientation), nearDist_(nearDist), curvature_(curvature), surfPtr_(&surf), @@ -404,6 +443,10 @@ Foam::surfaceToCell::surfaceToCell includeCut_(readBool(dict.lookup("includeCut"))), includeInside_(readBool(dict.lookup("includeInside"))), includeOutside_(readBool(dict.lookup("includeOutside"))), + useSurfaceOrientation_ + ( + dict.lookupOrDefault("useSurfaceOrientation", false) + ), nearDist_(readScalar(dict.lookup("nearDistance"))), curvature_(readScalar(dict.lookup("curvature"))), surfPtr_(new triSurface(surfName_)), @@ -427,6 +470,7 @@ Foam::surfaceToCell::surfaceToCell includeCut_(readBool(checkIs(is))), includeInside_(readBool(checkIs(is))), includeOutside_(readBool(checkIs(is))), + useSurfaceOrientation_(false), nearDist_(readScalar(checkIs(is))), curvature_(readScalar(checkIs(is))), surfPtr_(new triSurface(surfName_)), diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H index cfaf80dd30..931f412a2a 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H @@ -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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,8 @@ Description Selects: - all cells inside/outside/cut by surface + - all cells inside/outside surface ('useSurfaceOrientation', requires closed + surface) - cells with centre nearer than XXX to surface - cells with centre nearer than XXX to surface \b and with normal at nearest point to centre and cell-corners differing by @@ -67,27 +69,31 @@ class surfaceToCell static addToUsageTable usage_; //- Name of surface file - fileName surfName_; + const fileName surfName_; //- Points which are outside - pointField outsidePoints_; + const pointField outsidePoints_; //- Include cut cells - bool includeCut_; + const bool includeCut_; //- Include inside cells - bool includeInside_; + const bool includeInside_; //- Include outside cells - bool includeOutside_; + const bool includeOutside_; + + //- Determine inside/outside purely using geometric test + // (does not allow includeCut) + const bool useSurfaceOrientation_; //- if > 0 : include cells with distance from cellCentre to surface // less than nearDist. - scalar nearDist_; + const scalar nearDist_; //- if > -1 : include cells with normals at nearest surface points // varying more than curvature_. - scalar curvature_; + const scalar curvature_; //- triSurface to search on. On pointer since can be external. const triSurface* surfPtr_; @@ -97,7 +103,7 @@ class surfaceToCell //- whether I allocated above surface ptrs or whether they are // external. - bool IOwnPtrs_; + const bool IOwnPtrs_; // Private Member Functions @@ -155,6 +161,7 @@ public: const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature ); @@ -170,6 +177,7 @@ public: const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature );