mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -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
|
||||
);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -165,6 +165,10 @@ surfaces
|
||||
|
||||
//- Optional: restrict to a particular zone
|
||||
// zone zone1;
|
||||
|
||||
//- Optional: do not triangulate (only for surfaceFormats that support
|
||||
// polygons)
|
||||
//triangulate false;
|
||||
}
|
||||
|
||||
interpolatedPlane
|
||||
|
||||
@ -39,6 +39,14 @@ namespace functionEntries
|
||||
{
|
||||
defineTypeNameAndDebug(codeStream, 0);
|
||||
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
codeStream,
|
||||
execute,
|
||||
dictionaryIstream
|
||||
);
|
||||
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
@ -364,6 +372,38 @@ bool Foam::functionEntries::codeStream::execute
|
||||
IStringStream resultStream(os.str());
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -160,6 +160,10 @@ public:
|
||||
|
||||
// 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
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
|
||||
@ -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<bool>("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_)),
|
||||
|
||||
@ -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
|
||||
);
|
||||
|
||||
@ -472,7 +472,6 @@ void Foam::topoSet::invert(const label maxLen)
|
||||
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
|
||||
{
|
||||
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 * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::topoSet::operator=(const topoSet& rhs)
|
||||
|
||||
@ -45,12 +45,14 @@ Foam::sampledPlane::sampledPlane
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const plane& planeDesc,
|
||||
const keyType& zoneKey
|
||||
const keyType& zoneKey,
|
||||
const bool triangulate
|
||||
)
|
||||
:
|
||||
sampledSurface(name, mesh),
|
||||
cuttingPlane(planeDesc),
|
||||
zoneKey_(zoneKey),
|
||||
triangulate_(triangulate),
|
||||
needsUpdate_(true)
|
||||
{
|
||||
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
|
||||
@ -71,6 +73,7 @@ Foam::sampledPlane::sampledPlane
|
||||
sampledSurface(name, mesh, dict),
|
||||
cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
|
||||
zoneKey_(keyType::null),
|
||||
triangulate_(dict.lookupOrDefault("triangulate", true)),
|
||||
needsUpdate_(true)
|
||||
{
|
||||
// make plane relative to the coordinateSystem (Cartesian)
|
||||
@ -138,11 +141,11 @@ bool Foam::sampledPlane::update()
|
||||
|
||||
if (selectedCells.empty())
|
||||
{
|
||||
reCut(mesh(), true); // always triangulate. Note:Make option?
|
||||
reCut(mesh(), triangulate_);
|
||||
}
|
||||
else
|
||||
{
|
||||
reCut(mesh(), true, selectedCells);
|
||||
reCut(mesh(), triangulate_, selectedCells);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
@ -250,6 +253,7 @@ void Foam::sampledPlane::print(Ostream& os) const
|
||||
os << "sampledPlane: " << name() << " :"
|
||||
<< " base:" << refPoint()
|
||||
<< " normal:" << normal()
|
||||
<< " triangulate:" << triangulate_
|
||||
<< " faces:" << faces().size()
|
||||
<< " points:" << points().size();
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::sampledPlane
|
||||
|
||||
Description
|
||||
A sampledSurface defined by a cuttingPlane. Always triangulated.
|
||||
A sampledSurface defined by a cuttingPlane. Triangulated by default.
|
||||
|
||||
Note
|
||||
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
|
||||
keyType zoneKey_;
|
||||
|
||||
//- Triangulated faces or keep faces as is
|
||||
const bool triangulate_;
|
||||
|
||||
//- Track if the surface needs an update
|
||||
mutable bool needsUpdate_;
|
||||
|
||||
@ -92,7 +95,8 @@ public:
|
||||
const word& name,
|
||||
const polyMesh& mesh,
|
||||
const plane& planeDesc,
|
||||
const keyType& zoneKey = word::null
|
||||
const keyType& zoneKey = word::null,
|
||||
const bool triangulate = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
|
||||
Reference in New Issue
Block a user