ENH: surfaceToCell: use surface orientation

This commit is contained in:
mattijs
2013-08-20 16:01:18 +01:00
parent e16d2c2019
commit 77d47e9125
4 changed files with 72 additions and 16 deletions

View File

@ -269,9 +269,10 @@ void selectCurvatureCells
querySurf.surface(), querySurf.surface(),
querySurf, querySurf,
pointField(1, mesh.cellCentres()[0]), pointField(1, mesh.cellCentres()[0]),
false, false, // includeCut
false, false, // includeInside
false, false, // includeOutside
false, // geometricOnly
nearDist, nearDist,
curvature curvature
); );

View File

@ -143,6 +143,9 @@ FoamFile
// sourceInfo // sourceInfo
// { // {
// file "www.avl.com-geometry.stl"; // file "www.avl.com-geometry.stl";
// useSurfaceOrientation false; // use closed surface inside/outside
// // test (ignores includeCut,
// // outsidePoints)
// outsidePoints ((-99 -99 -59)); // definition of outside // outsidePoints ((-99 -99 -59)); // definition of outside
// includeCut false; // cells cut by surface // includeCut false; // cells cut by surface
// includeInside false; // cells not on outside of surf // includeInside false; // cells not on outside of surf

View File

@ -157,7 +157,30 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const
{ {
cpuTime timer; 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 // 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 // Construct search engine on mesh
meshSearch queryMesh(mesh_); const meshSearch queryMesh(mesh_);
// Check all 'outside' points // 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; << timer.cpuTimeIncrement() << " s" << endl << endl;
//- Add/remove cells using set
forAll(cellType, cellI) forAll(cellType, cellI)
{ {
label cType = cellType[cellI]; label cType = cellType[cellI];
@ -326,6 +349,18 @@ void Foam::surfaceToCell::checkSettings() const
<< " or set curvature to a value -1 .. 1." << " or set curvature to a value -1 .. 1."
<< exit(FatalError); << 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 includeCut,
const bool includeInside, const bool includeInside,
const bool includeOutside, const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist, const scalar nearDist,
const scalar curvature const scalar curvature
) )
@ -350,6 +386,7 @@ Foam::surfaceToCell::surfaceToCell
includeCut_(includeCut), includeCut_(includeCut),
includeInside_(includeInside), includeInside_(includeInside),
includeOutside_(includeOutside), includeOutside_(includeOutside),
useSurfaceOrientation_(useSurfaceOrientation),
nearDist_(nearDist), nearDist_(nearDist),
curvature_(curvature), curvature_(curvature),
surfPtr_(new triSurface(surfName_)), surfPtr_(new triSurface(surfName_)),
@ -371,6 +408,7 @@ Foam::surfaceToCell::surfaceToCell
const bool includeCut, const bool includeCut,
const bool includeInside, const bool includeInside,
const bool includeOutside, const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist, const scalar nearDist,
const scalar curvature const scalar curvature
) )
@ -381,6 +419,7 @@ Foam::surfaceToCell::surfaceToCell
includeCut_(includeCut), includeCut_(includeCut),
includeInside_(includeInside), includeInside_(includeInside),
includeOutside_(includeOutside), includeOutside_(includeOutside),
useSurfaceOrientation_(useSurfaceOrientation),
nearDist_(nearDist), nearDist_(nearDist),
curvature_(curvature), curvature_(curvature),
surfPtr_(&surf), surfPtr_(&surf),
@ -404,6 +443,10 @@ Foam::surfaceToCell::surfaceToCell
includeCut_(readBool(dict.lookup("includeCut"))), includeCut_(readBool(dict.lookup("includeCut"))),
includeInside_(readBool(dict.lookup("includeInside"))), includeInside_(readBool(dict.lookup("includeInside"))),
includeOutside_(readBool(dict.lookup("includeOutside"))), includeOutside_(readBool(dict.lookup("includeOutside"))),
useSurfaceOrientation_
(
dict.lookupOrDefault<bool>("useSurfaceOrientation", false)
),
nearDist_(readScalar(dict.lookup("nearDistance"))), nearDist_(readScalar(dict.lookup("nearDistance"))),
curvature_(readScalar(dict.lookup("curvature"))), curvature_(readScalar(dict.lookup("curvature"))),
surfPtr_(new triSurface(surfName_)), surfPtr_(new triSurface(surfName_)),
@ -427,6 +470,7 @@ Foam::surfaceToCell::surfaceToCell
includeCut_(readBool(checkIs(is))), includeCut_(readBool(checkIs(is))),
includeInside_(readBool(checkIs(is))), includeInside_(readBool(checkIs(is))),
includeOutside_(readBool(checkIs(is))), includeOutside_(readBool(checkIs(is))),
useSurfaceOrientation_(false),
nearDist_(readScalar(checkIs(is))), nearDist_(readScalar(checkIs(is))),
curvature_(readScalar(checkIs(is))), curvature_(readScalar(checkIs(is))),
surfPtr_(new triSurface(surfName_)), surfPtr_(new triSurface(surfName_)),

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,6 +29,8 @@ Description
Selects: Selects:
- all cells inside/outside/cut by surface - 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
- cells with centre nearer than XXX to surface \b and with normal - cells with centre nearer than XXX to surface \b and with normal
at nearest point to centre and cell-corners differing by at nearest point to centre and cell-corners differing by
@ -67,27 +69,31 @@ class surfaceToCell
static addToUsageTable usage_; static addToUsageTable usage_;
//- Name of surface file //- Name of surface file
fileName surfName_; const fileName surfName_;
//- Points which are outside //- Points which are outside
pointField outsidePoints_; const pointField outsidePoints_;
//- Include cut cells //- Include cut cells
bool includeCut_; const bool includeCut_;
//- Include inside cells //- Include inside cells
bool includeInside_; const bool includeInside_;
//- Include outside cells //- 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 //- if > 0 : include cells with distance from cellCentre to surface
// less than nearDist. // less than nearDist.
scalar nearDist_; const scalar nearDist_;
//- if > -1 : include cells with normals at nearest surface points //- if > -1 : include cells with normals at nearest surface points
// varying more than curvature_. // varying more than curvature_.
scalar curvature_; const scalar curvature_;
//- triSurface to search on. On pointer since can be external. //- triSurface to search on. On pointer since can be external.
const triSurface* surfPtr_; const triSurface* surfPtr_;
@ -97,7 +103,7 @@ class surfaceToCell
//- whether I allocated above surface ptrs or whether they are //- whether I allocated above surface ptrs or whether they are
// external. // external.
bool IOwnPtrs_; const bool IOwnPtrs_;
// Private Member Functions // Private Member Functions
@ -155,6 +161,7 @@ public:
const bool includeCut, const bool includeCut,
const bool includeInside, const bool includeInside,
const bool includeOutside, const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist, const scalar nearDist,
const scalar curvature const scalar curvature
); );
@ -170,6 +177,7 @@ public:
const bool includeCut, const bool includeCut,
const bool includeInside, const bool includeInside,
const bool includeOutside, const bool includeOutside,
const bool useSurfaceOrientation,
const scalar nearDist, const scalar nearDist,
const scalar curvature const scalar curvature
); );