Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Sergio Ferraris
2013-09-02 12:17:12 +01:00
10 changed files with 134 additions and 45 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

@ -165,6 +165,10 @@ surfaces
//- Optional: restrict to a particular zone //- Optional: restrict to a particular zone
// zone zone1; // zone zone1;
//- Optional: do not triangulate (only for surfaceFormats that support
// polygons)
//triangulate false;
} }
interpolatedPlane interpolatedPlane

View File

@ -39,6 +39,14 @@ namespace functionEntries
{ {
defineTypeNameAndDebug(codeStream, 0); defineTypeNameAndDebug(codeStream, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
codeStream,
execute,
dictionaryIstream
);
addToMemberFunctionSelectionTable addToMemberFunctionSelectionTable
( (
functionEntry, functionEntry,
@ -364,6 +372,38 @@ bool Foam::functionEntries::codeStream::execute
IStringStream resultStream(os.str()); IStringStream resultStream(os.str());
entry.read(parentDict, resultStream); entry.read(parentDict, resultStream);
return true;
}
bool Foam::functionEntries::codeStream::execute
(
dictionary& parentDict,
Istream& is
)
{
Info<< "Using #codeStream at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
dictionary codeDict("#codeStream", parentDict, is);
streamingFunctionType function = getFunction(parentDict, codeDict);
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
parentDict.read(resultStream);
return true; return true;
} }

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
@ -160,6 +160,10 @@ public:
// Member Functions // Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute(dictionary& parentDict, Istream&);
//- Execute the functionEntry in a primitiveEntry context
static bool execute static bool execute
( (
const dictionary& parentDict, const dictionary& parentDict,

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
); );

View File

@ -472,7 +472,6 @@ void Foam::topoSet::invert(const label maxLen)
insert(cellI); insert(cellI);
} }
} }
} }
@ -550,20 +549,6 @@ void Foam::topoSet::writeDebug(Ostream& os, const label maxLen) const
} }
//void Foam::topoSet::writeDebug
//(
// Ostream&,
// const primitiveMesh&,
// const label
//) const
//{
// notImplemented
// (
// "topoSet::writeDebug(Ostream&, const primitiveMesh&, const label)"
// );
//}
bool Foam::topoSet::writeData(Ostream& os) const bool Foam::topoSet::writeData(Ostream& os) const
{ {
return (os << *this).good(); return (os << *this).good();
@ -576,14 +561,6 @@ void Foam::topoSet::updateMesh(const mapPolyMesh&)
} }
////- Return max index+1.
//label topoSet::maxSize(const polyMesh&) const
//{
// notImplemented("topoSet::maxSize(const polyMesh&)");
//
// return -1;
//}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void Foam::topoSet::operator=(const topoSet& rhs) void Foam::topoSet::operator=(const topoSet& rhs)

View File

@ -45,12 +45,14 @@ Foam::sampledPlane::sampledPlane
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
const plane& planeDesc, const plane& planeDesc,
const keyType& zoneKey const keyType& zoneKey,
const bool triangulate
) )
: :
sampledSurface(name, mesh), sampledSurface(name, mesh),
cuttingPlane(planeDesc), cuttingPlane(planeDesc),
zoneKey_(zoneKey), zoneKey_(zoneKey),
triangulate_(triangulate),
needsUpdate_(true) needsUpdate_(true)
{ {
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
@ -71,6 +73,7 @@ Foam::sampledPlane::sampledPlane
sampledSurface(name, mesh, dict), sampledSurface(name, mesh, dict),
cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))), cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
zoneKey_(keyType::null), zoneKey_(keyType::null),
triangulate_(dict.lookupOrDefault("triangulate", true)),
needsUpdate_(true) needsUpdate_(true)
{ {
// make plane relative to the coordinateSystem (Cartesian) // make plane relative to the coordinateSystem (Cartesian)
@ -138,11 +141,11 @@ bool Foam::sampledPlane::update()
if (selectedCells.empty()) if (selectedCells.empty())
{ {
reCut(mesh(), true); // always triangulate. Note:Make option? reCut(mesh(), triangulate_);
} }
else else
{ {
reCut(mesh(), true, selectedCells); reCut(mesh(), triangulate_, selectedCells);
} }
if (debug) if (debug)
@ -250,6 +253,7 @@ void Foam::sampledPlane::print(Ostream& os) const
os << "sampledPlane: " << name() << " :" os << "sampledPlane: " << name() << " :"
<< " base:" << refPoint() << " base:" << refPoint()
<< " normal:" << normal() << " normal:" << normal()
<< " triangulate:" << triangulate_
<< " faces:" << faces().size() << " faces:" << faces().size()
<< " points:" << points().size(); << " points:" << points().size();
} }

View File

@ -25,7 +25,7 @@ Class
Foam::sampledPlane Foam::sampledPlane
Description Description
A sampledSurface defined by a cuttingPlane. Always triangulated. A sampledSurface defined by a cuttingPlane. Triangulated by default.
Note Note
Does not actually cut until update() called. Does not actually cut until update() called.
@ -60,6 +60,9 @@ class sampledPlane
//- If restricted to zones, name of this zone or a regular expression //- If restricted to zones, name of this zone or a regular expression
keyType zoneKey_; keyType zoneKey_;
//- Triangulated faces or keep faces as is
const bool triangulate_;
//- Track if the surface needs an update //- Track if the surface needs an update
mutable bool needsUpdate_; mutable bool needsUpdate_;
@ -92,7 +95,8 @@ public:
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
const plane& planeDesc, const plane& planeDesc,
const keyType& zoneKey = word::null const keyType& zoneKey = word::null,
const bool triangulate = true
); );
//- Construct from dictionary //- Construct from dictionary