Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

This commit is contained in:
sergio
2017-06-02 13:36:09 -07:00
167 changed files with 6533 additions and 3820 deletions

View File

@ -22,13 +22,13 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::constant Foam::diameterModels::constant
Description Description
Constant dispersed-phase particle diameter model. Constant dispersed-phase particle diameter model.
SourceFiles SourceFiles
constant.C constantDiameter.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::constantSurfaceTensionCoefficient Foam::surfaceTensionModels::constantSurfaceTensionCoefficient
Description Description
Constant value surface tension model. Constant value surface tension model.

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::constantAspectRatio Foam::aspectRatioModels::constantAspectRatio
Description Description
Constant value aspect ratio model. Constant value aspect ratio model.

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::constantAspectRatio Foam::aspectRatioModels::constantAspectRatio
Description Description
Constant value aspect ratio model. Constant value aspect ratio model.

View File

@ -42,13 +42,44 @@ Description
using namespace Foam; using namespace Foam;
void infoHashString
(
unsigned modulus,
std::initializer_list<std::string> lst
)
{
if (modulus)
{
Info<< "basic string hashing (mod " << label(modulus) << ")" << endl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< (Hash<string>()(str) % modulus) << nl;
}
}
else
{
Info<< "basic string hashing" << nl;
for (const auto& str : lst)
{
Info<<"hash(" << str.c_str() << ")="
<< Hash<string>()(str) << nl;
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program: // Main program:
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
IFstream is("hashingTests"); infoHashString(8, {"asdathis1", "adsxf", "hij", "klmpq"});
IFstream is("hashingTests");
while (is.good()) while (is.good())
{ {

View File

@ -26,6 +26,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "NamedEnum.H" #include "NamedEnum.H"
#include "Enum.H"
#include "IOstreams.H" #include "IOstreams.H"
using namespace Foam; using namespace Foam;
@ -34,15 +35,27 @@ class namedEnumTest
{ {
public: public:
enum option enum class option
{ {
a, A,
b, B,
c, C,
d D
}; };
static const Foam::NamedEnum<option, 4> namedEnum; enum class otherOption
{
A,
B,
C,
D
};
static const Foam::NamedEnum<option, 4> optionNamed;
static const Foam::Enum<otherOption> optionEnum;
static const Foam::Enum<option> optionEnum2;
}; };
@ -52,10 +65,25 @@ const char* Foam::NamedEnum<namedEnumTest::option, 4>::names[] =
"a", "a",
"b", "b",
"c", "c",
"d" "d",
}; };
const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::namedEnum; const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::optionNamed;
const Foam::Enum<namedEnumTest::otherOption> namedEnumTest::optionEnum
{
{ namedEnumTest::otherOption::A, "a" },
{ namedEnumTest::otherOption::B, "b" },
{ namedEnumTest::otherOption::C, "c" },
{ namedEnumTest::otherOption::D, "d" },
};
const Foam::Enum<namedEnumTest::option> namedEnumTest::optionEnum2
(
namedEnumTest::option::C,
{ "c", "d" }
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -63,62 +91,66 @@ const Foam::NamedEnum<namedEnumTest::option, 4> namedEnumTest::namedEnum;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const List<namedEnumTest::option> options Info<<"NamedEnum: " << namedEnumTest::optionNamed << nl;
= namedEnumTest::namedEnum.enums(); Info<<"Enum: " << namedEnumTest::optionEnum << nl;
Info<<"Enum: " << namedEnumTest::optionEnum2 << nl;
dictionary testDict; dictionary testDict;
testDict.add("lookup1", "c"); testDict.add("lookup1", "c");
Info<< "enums: " << options << nl; Info<< nl
<< int(namedEnumTest::optionNamed["a"]) << nl
Info<< "loop over enums (as list):" << nl; << namedEnumTest::optionNamed[namedEnumTest::option::A] << nl;
forAll(options, i)
{
const namedEnumTest::option& opt = options[i];
Info<< "option[" << opt
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
}
Info<< "loop over enums (C++11 for range):" << nl;
for (const auto& opt : options)
{
Info<< "option[" << opt
<< "] = '" << namedEnumTest::namedEnum[opt] << "'" << nl;
}
Info<< nl Info<< nl
<< namedEnumTest::namedEnum["a"] << nl << int(namedEnumTest::optionEnum["a"]) << nl
<< namedEnumTest::namedEnum[namedEnumTest::a] << nl; << namedEnumTest::optionEnum[namedEnumTest::otherOption::A] << nl;
Info<< "--- test dictionary lookup ---" << endl; Info<< "--- test dictionary lookup ---" << endl;
{ {
Info<< "dict: " << testDict << endl; Info<< "dict: " << testDict << endl;
namedEnumTest::option gotOpt = Info<< "got: "
namedEnumTest::namedEnum.lookupOrDefault << int
( (
"test", namedEnumTest::optionNamed.lookupOrDefault
testDict, (
namedEnumTest::option::a "notFound",
); testDict,
namedEnumTest::option::A
)
)
<< nl;
Info<< "got: " << gotOpt << endl; Info<< "got: "
<< int
(
namedEnumTest::optionNamed.lookupOrDefault
(
"lookup1",
testDict,
namedEnumTest::option::A
)
)
<< nl;
gotOpt = namedEnumTest::namedEnum.lookupOrDefault Info<< "got: "
( << int
"lookup1", (
testDict, namedEnumTest::optionEnum2.lookupOrDefault
namedEnumTest::option::a (
); "lookup1",
testDict,
Info<< "got: " << gotOpt << endl; namedEnumTest::option::A
)
)
<< nl;
} }
Info<< "--- test read construction ---" << endl; Info<< "--- test read ---" << endl;
namedEnumTest::option dummy(namedEnumTest::namedEnum.read(Sin)); namedEnumTest::option dummy(namedEnumTest::optionNamed.read(Sin));
Info<< namedEnumTest::namedEnum[dummy] << endl; Info<< namedEnumTest::optionNamed[dummy] << endl;
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -84,6 +84,12 @@ int main(int argc, char *argv[])
packed.resize(n, 1); packed.resize(n, 1);
} }
Info<< "resize/shrink/resize:" << timer.cpuTimeIncrement() << " s\n\n"; Info<< "resize/shrink/resize:" << timer.cpuTimeIncrement() << " s\n\n";
Info<< "packed bool size=" << packed.size() << nl;
// Neither of these should affect the size
packed.unset(2*n-1);
packed.set(2*n-1, 0);
Info<< "packed bool size=" << packed.size() << nl;
// set every other bit on: // set every other bit on:
Info<< "set every other bit on and count\n"; Info<< "set every other bit on and count\n";
@ -99,8 +105,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Counting brute-force:" << timer.cpuTimeIncrement() Info<< "Counting brute-force:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Count packed // Count packed
@ -110,8 +116,8 @@ int main(int argc, char *argv[])
sum += packed.count(); sum += packed.count();
} }
Info<< "Counting via count():" << timer.cpuTimeIncrement() Info<< "Counting via count():" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Dummy addition // Dummy addition
@ -123,8 +129,8 @@ int main(int argc, char *argv[])
sum += i + 1; sum += i + 1;
} }
} }
Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << endl; Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << " (sum is meaningless)" << endl;
// //
// Read // Read
@ -139,8 +145,8 @@ int main(int argc, char *argv[])
sum += stlVector[i]; sum += stlVector[i];
} }
} }
Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << endl; Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read unpacked // Read unpacked
@ -152,8 +158,8 @@ int main(int argc, char *argv[])
sum += unpacked[i]; sum += unpacked[i];
} }
} }
Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << endl; Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read packed // Read packed
@ -166,8 +172,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading packed using get:" << timer.cpuTimeIncrement() Info<< "Reading packed using get:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read packed // Read packed
@ -180,8 +186,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading packed using reference:" << timer.cpuTimeIncrement() Info<< "Reading packed using reference:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read via iterator // Read via iterator
@ -194,8 +200,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement() Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read via iterator // Read via iterator
@ -208,8 +214,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement() Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read empty hash // Read empty hash
@ -222,8 +228,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement() Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read full hash // Read full hash
@ -236,8 +242,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement() Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
// Read empty static hash // Read empty static hash
@ -250,8 +256,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement() Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
#if 0 #if 0
// we can skip this test - it is usually quite slow // we can skip this test - it is usually quite slow
@ -265,8 +271,8 @@ int main(int argc, char *argv[])
} }
} }
Info<< "Reading full StaticHash:" << timer.cpuTimeIncrement() Info<< "Reading full StaticHash:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << nl
Info<< " sum " << sum << endl; << " sum " << sum << endl;
#endif #endif
Info<< "Starting write tests" << endl; Info<< "Starting write tests" << endl;
@ -319,7 +325,6 @@ int main(int argc, char *argv[])
Info<< "Writing packed using set:" << timer.cpuTimeIncrement() Info<< "Writing packed using set:" << timer.cpuTimeIncrement()
<< " s" << endl; << " s" << endl;
// Write packed // Write packed
for (label iter = 0; iter < nIters; ++iter) for (label iter = 0; iter < nIters; ++iter)
{ {

View File

@ -0,0 +1,3 @@
Test-surfaceIntersection.C
EXE = $(FOAM_USER_APPBIN)/Test-surfaceIntersection

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \
-lmeshTools

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-surfaceIntersection
Description
Test surface-surface intersection
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "triSurface.H"
#include "triSurfaceMesh.H"
#include "surfaceIntersection.H"
#include "OBJstream.H"
using namespace Foam;
autoPtr<triSurface> loadSurface
(
const Foam::Time& runTime,
const fileName& surfName
)
{
Info<< "Reading surface " << surfName << endl;
const fileName fallback =
runTime.constantPath()/triSurfaceMesh::meshSubDir/surfName;
autoPtr<triSurface> surfPtr;
if (isFile(surfName))
{
surfPtr.set(new triSurface(surfName));
}
else if (isFile(fallback))
{
surfPtr.set(new triSurface(fallback));
}
else
{
FatalErrorInFunction
<< "No such file:" << surfName << exit(FatalError);
}
return surfPtr;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Intersection of two surfaces. Writes obj file"
);
argList::addBoolOption
(
"debug2",
"set surfaceIntersection debug=2"
);
argList::addBoolOption
(
"debug4",
"set surfaceIntersection debug=4"
);
argList::addBoolOption
(
"print",
"print information about cuts, etc"
);
argList::addBoolOption
(
"mergeEdges",
"merge duplicate edges"
);
argList::addOption
(
"mergePoints",
"mergeTol",
"merge points (and edges) using the specified tolerance"
);
#include "addDictOption.H"
argList::addNote
(
"test intersect of two surfaces. Writes obj file"
);
argList::noParallel();
argList::noFunctionObjects();
argList::validArgs.append("surface file");
argList::validArgs.append("surface file");
#include "setRootCase.H"
#include "createTime.H"
const word outputFile(args.executable() + ".obj");
const fileName surf1Name(args[1]);
triSurface surf1 = loadSurface(runTime, surf1Name)();
Info<< surf1Name << " statistics:" << endl;
surf1.writeStats(Info);
Info<< endl;
const fileName surf2Name(args[2]);
triSurface surf2 = loadSurface(runTime, surf2Name)();
Info<< surf2Name << " statistics:" << endl;
surf2.writeStats(Info);
Info<< endl;
if (args.optionFound("debug2"))
{
surfaceIntersection::debug |= 2;
}
if (args.optionFound("debug4"))
{
surfaceIntersection::debug |= 4;
}
const bool optPrint = args.optionFound("print");
dictionary intersectOptions;
if (args.optionFound("dict"))
{
intersectOptions = IOdictionary
(
IOobject
(
args["dict"],
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
}
intersectOptions.writeEntry("intersectOptions", Info);
Info<< endl;
triSurfaceSearch query1(surf1);
triSurfaceSearch query2(surf2);
surfaceIntersection cuts(query1, query2, intersectOptions);
Info<<"intersection "
<< cuts.cutPoints().size() << " points "
<< cuts.cutEdges().size() << " edges" << nl;
if (optPrint)
{
Info<< "surf1-cuts: " << cuts.surf1EdgeCuts() << nl
<< "surf2-cuts: " << cuts.surf2EdgeCuts() << nl
<< "face-pairs: " << cuts.facePairToEdgeId() << nl
<< "edges: " << cuts.cutEdges() << nl;
}
word mergeOp;
if (args.optionFound("mergePoints"))
{
cuts.mergePoints(args.optionRead<scalar>("mergePoints"));
mergeOp = "mergePoints";
}
else if (args.optionFound("mergeEdges"))
{
cuts.mergeEdges();
mergeOp = "mergeEdges";
}
if (!mergeOp.empty())
{
Info<< mergeOp << ": "
<< cuts.cutPoints().size() << " points "
<< cuts.cutEdges().size() << " edges" << nl;
if (optPrint)
{
Info<< "surf1-cuts: " << cuts.surf1EdgeCuts() << nl
<< "surf2-cuts: " << cuts.surf2EdgeCuts() << nl
<< "face-pairs: " << cuts.facePairToEdgeId() << nl
<< "edges: " << cuts.cutEdges() << nl;
}
}
const pointField& points = cuts.cutPoints();
const edgeList& edges = cuts.cutEdges();
if (points.size() || edges.size())
{
Info<<"write to " << outputFile << nl;
OBJstream(outputFile).write(edges, points);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
Test-unitConversion.C
EXE = $(FOAM_USER_APPBIN)/Test-unitConversion

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-unitConversion
\*---------------------------------------------------------------------------*/
#include "IOstreams.H"
#include "unitConversion.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
Info<< "30_deg: " << 30_deg << nl;
Info<< "30.0_deg: " << 30.0_deg << nl;
Info<< "3e+1_deg: " << 3e+1_deg << nl;
Info<< "degToRad(30): " << degToRad(30) << nl;
Info<< "cos(30_deg): " << ::cos(30_deg) << nl;
return 0;
}
// ************************************************************************* //

View File

@ -125,12 +125,6 @@ int main(int argc, char *argv[])
"provide alternative base name when re-exporting (implies -export). " "provide alternative base name when re-exporting (implies -export). "
"Default is <meshExport>." "Default is <meshExport>."
); );
// This often works, but is not entirely stable
// argList::addBoolOption
// (
// "combine",
// "combine identically named patches"
// );
argList::addBoolOption argList::addBoolOption
( (
"noBaffles", "noBaffles",
@ -211,10 +205,6 @@ int main(int argc, char *argv[])
{ {
rOpts.useNumberedNames(true); rOpts.useNumberedNames(true);
} }
else if (args.optionFound("combine"))
{
rOpts.combineBoundaries(true);
}
if (args.optionFound("solids")) if (args.optionFound("solids"))
{ {
@ -295,7 +285,7 @@ int main(int argc, char *argv[])
{ {
const fileName geomName = exportName + ".ccmg"; const fileName geomName = exportName + ".ccmg";
Info<< nl << "Re-exporting geometry as " << geomName << nl; Info<< nl << "Re-exporting geometry as " << geomName << nl;
ccm::writer(geomName, mesh).writeGeometry(); ccm::writer(geomName, mesh()).writeGeometry();
} }
} }
else else

View File

@ -44,22 +44,9 @@ void Foam::DelaunayMeshTools::writeOBJ
OFstream str(fName); OFstream str(fName);
Pout<< nl Pout<< nl
<< "Writing points of types:" << nl; << "Writing points of types ("
<< int(startPointType) << "-" << int(endPointType)
forAllConstIter << ") to " << str.name() << endl;
(
HashTable<int>,
indexedVertexEnum::vertexTypeNames_,
iter
)
{
if (iter() >= startPointType && iter() <= endPointType)
{
Pout<< " " << iter.key() << nl;
}
}
Pout<< "to " << str.name() << endl;
for for
( (
@ -265,7 +252,7 @@ void Foam::DelaunayMeshTools::drawDelaunayCell
<< "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl << "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl
<< "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl; << "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl;
// os << "# cicumcentre " << endl; // os << "# circumcentre " << endl;
// meshTools::writeOBJ(os, c->dual()); // meshTools::writeOBJ(os, c->dual());

View File

@ -900,12 +900,10 @@ void Foam::conformalVoronoiMesh::writeMesh
mesh.addFvPatches(patches); mesh.addFvPatches(patches);
// Add zones to the mesh // Add zones to the mesh
addZones(mesh, cellCentres); addZones(mesh, cellCentres);
Info<< indent << "Add pointZones" << endl; Info<< indent << "Add pointZones" << endl;
{ {
label sz = mesh.pointZones().size(); label sz = mesh.pointZones().size();
@ -914,6 +912,9 @@ void Foam::conformalVoronoiMesh::writeMesh
forAll(dualMeshPointTypeNames_, typeI) forAll(dualMeshPointTypeNames_, typeI)
{ {
const word& znName =
dualMeshPointTypeNames_[dualMeshPointType(typeI)];
forAll(boundaryPts, ptI) forAll(boundaryPts, ptI)
{ {
const label& bPtType = boundaryPts[ptI]; const label& bPtType = boundaryPts[ptI];
@ -928,14 +929,14 @@ void Foam::conformalVoronoiMesh::writeMesh
Info<< incrIndent << indent Info<< incrIndent << indent
<< "Adding " << bPts.size() << "Adding " << bPts.size()
<< " points of type " << dualMeshPointTypeNames_.words()[typeI] << " points of type " << znName
<< decrIndent << endl; << decrIndent << endl;
mesh.pointZones().append mesh.pointZones().append
( (
new pointZone new pointZone
( (
dualMeshPointTypeNames_.words()[typeI], znName,
bPts, bPts,
sz + typeI, sz + typeI,
mesh.pointZones() mesh.pointZones()

View File

@ -102,6 +102,8 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noCheckProcessorDirectories();
#include "addDictOption.H" #include "addDictOption.H"
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"

View File

@ -229,7 +229,7 @@ int main(int argc, char *argv[])
word patchMapMethod; word patchMapMethod;
if (meshToMesh::interpolationMethodNames_.found(mapMethod)) if (meshToMesh::interpolationMethodNames_.hasEnum(mapMethod))
{ {
// Lookup corresponding AMI method // Lookup corresponding AMI method
meshToMesh::interpolationMethod method = meshToMesh::interpolationMethod method =

View File

@ -83,7 +83,7 @@ Description
#include "edgeIntersections.H" #include "edgeIntersections.H"
#include "meshTools.H" #include "meshTools.H"
#include "DynamicField.H" #include "DynamicField.H"
#include "Enum.H"
#ifndef NO_CGAL #ifndef NO_CGAL
@ -99,7 +99,7 @@ typedef CGAL::AABB_face_graph_triangle_primitive
typedef CGAL::AABB_traits<K, Primitive> Traits; typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree; typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type > typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
Segment_intersection; Segment_intersection;
#endif // NO_CGAL #endif // NO_CGAL
@ -477,7 +477,6 @@ label dupNonManifoldPoints(triSurface& s, labelList& pointMap)
List<labelledTri> newFaces(s); List<labelledTri> newFaces(s);
label nNonManifold = 0; label nNonManifold = 0;
forAll(pf, pointI) forAll(pf, pointI)
{ {
const labelList& pFaces = pf[pointI]; const labelList& pFaces = pf[pointI];
@ -1257,10 +1256,10 @@ autoPtr<extendedFeatureEdgeMesh> createEdgeMesh
const triSurface& s1 = surf1; const triSurface& s1 = surf1;
const triSurface& s2 = surf2; const triSurface& s2 = surf2;
forAllConstIter(labelPairLookup, inter.facePairToEdge(), iter) forAllConstIters(inter.facePairToEdgeId(), iter)
{ {
const label& cutEdgeI = iter();
const labelPair& facePair = iter.key(); const labelPair& facePair = iter.key();
const label cutEdgeI = iter.object();
const edge& fE = inter.cutEdges()[cutEdgeI]; const edge& fE = inter.cutEdges()[cutEdgeI];
@ -1515,8 +1514,8 @@ int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("action"); argList::validArgs.append("action");
argList::validArgs.append("surface file"); argList::validArgs.append("surfaceFile1");
argList::validArgs.append("surface file"); argList::validArgs.append("surfaceFile2");
argList::addBoolOption argList::addBoolOption
( (
@ -1554,24 +1553,30 @@ int main(int argc, char *argv[])
" 'mixed' (keep all)" " 'mixed' (keep all)"
); );
argList::addNote
(
"Valid actions: \"intersection\", \"union\", \"difference\""
);
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
const word action(args[1]); const word action(args[1]);
const HashTable<booleanSurface::booleanOpType> validActions const Enum<booleanSurface::booleanOpType> validActions
{ {
{"intersection", booleanSurface::INTERSECTION}, { booleanSurface::INTERSECTION, "intersection" },
{"union", booleanSurface::UNION}, { booleanSurface::UNION, "union" },
{"difference", booleanSurface::DIFFERENCE} { booleanSurface::DIFFERENCE, "difference" }
}; };
if (!validActions.found(action)) if (!validActions.hasEnum(action))
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unsupported action " << action << endl << "Unsupported action " << action << endl
<< "Supported actions:" << validActions.toc() << abort(FatalError); << "Supported actions:" << validActions << nl
<< abort(FatalError);
} }

View File

@ -0,0 +1,7 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
wclean libso extractionMethod
wclean .
#------------------------------------------------------------------------------

View File

@ -0,0 +1,9 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
(wmake libso extractionMethod && wmake)
#------------------------------------------------------------------------------

View File

@ -1,9 +1,11 @@
EXE_INC = \ EXE_INC = \
-IextractionMethod/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude -I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lsurfaceFeatureExtract \
-lmeshTools \ -lmeshTools \
-lsampling -lsampling

View File

@ -0,0 +1,7 @@
method = .
$(method)/surfaceFeaturesExtraction.C
$(method)/extractFromFile.C
$(method)/extractFromNone.C
$(method)/extractFromSurface.C
LIB = $(FOAM_LIBBIN)/libsurfaceFeatureExtract

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lmeshTools

View File

@ -0,0 +1,103 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extractFromFile.H"
#include "edgeMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceFeaturesExtraction
{
addNamedToRunTimeSelectionTable
(
method,
extractFromFile,
dictionary,
extractFromFile
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::extractFromFile::extractFromFile
(
const dictionary& dict
)
:
method()
{
const dictionary& coeffDict =
dict.optionalSubDict("extractFromFileCoeffs");
coeffDict.lookup("featureEdgeFile") >> featureEdgeFile_;
coeffDict.readIfPresent("geometricTestOnly", geometricTestOnly_);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::extractFromFile::~extractFromFile()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceFeatures>
Foam::surfaceFeaturesExtraction::extractFromFile::features
(
const triSurface& surf
) const
{
edgeMesh eMesh(featureEdgeFile_);
// Sometimes duplicate edges are present. Remove them.
eMesh.mergeEdges();
Info<< nl << "Reading existing feature edges from file "
<< featureEdgeFile_ << nl
<< "Selecting edges based purely on geometric tests: "
<< geometricTestOnly().asText() << endl;
return autoPtr<surfaceFeatures>
(
new surfaceFeatures
(
surf,
eMesh.points(),
eMesh.edges(),
1e-6, // mergeTol
geometricTestOnly()
)
);
}
// ************************************************************************* //

View File

@ -0,0 +1,88 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceFeaturesExtraction::extractFromFile
Description
Run-time selectable surface feature extraction.
Selectable as "extractFromFile".
Mandatory dictionary entries: "featureEdgeFile".
Optional dictionary entries: "geometricTestOnly".
SourceFiles
extractFromFile.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceFeaturesExtraction_extractFromFile_H
#define surfaceFeaturesExtraction_extractFromFile_H
#include "surfaceFeaturesExtraction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceFeaturesExtraction
{
/*---------------------------------------------------------------------------*\
Class surfaceFeaturesExtraction::extractFromFile Declaration
\*---------------------------------------------------------------------------*/
class extractFromFile
:
public method
{
fileName featureEdgeFile_;
public:
//- Construct from dictionary
extractFromFile(const dictionary& dict);
//- Destructor
virtual ~extractFromFile();
//- Features loaded (extracted) from featureEdgeFile
virtual autoPtr<surfaceFeatures> features
(
const triSurface& surf
) const override;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace surfaceFeaturesExtraction
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extractFromNone.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceFeaturesExtraction
{
addNamedToRunTimeSelectionTable
(
method,
extractFromNone,
dictionary,
none
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::extractFromNone::extractFromNone
(
const dictionary& dict
)
:
method()
{
// A "noneCoeffs" sub-dictionary doesn't make much sense.
dict.readIfPresent("includedAngle", includedAngle_);
dict.readIfPresent("geometricTestOnly", geometricTestOnly_);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::extractFromNone::~extractFromNone()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceFeatures>
Foam::surfaceFeaturesExtraction::extractFromNone::features
(
const triSurface& surf
) const
{
return autoPtr<surfaceFeatures>(new surfaceFeatures(surf));
}
// ************************************************************************* //

View File

@ -2,8 +2,8 @@
========= | ========= |
\\ / 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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -21,50 +21,64 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::surfaceFeaturesExtraction::extractFromNone
Description Description
Merge points. See below. Run-time selectable surface feature extraction - no extraction.
Primarily useful with self-intersection methods.
Selectable as "none".
Optional dictionary entries: "includedAngle", "geometricTestOnly".
SourceFiles SourceFiles
mergePoints.C extractFromNone.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef mergePoints1_H #ifndef surfaceFeaturesExtraction_extractFromNone_H
#define mergePoints1_H #define surfaceFeaturesExtraction_extractFromNone_H
#include "scalar.H" #include "surfaceFeaturesExtraction.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace surfaceFeaturesExtraction
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Function mergePoints Declaration Class surfaceFeaturesExtraction::extractFromNone Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- Sorts and merges points. All points closer than/equal mergeTol get merged. class extractFromNone
// Returns the number of unique points and a map from old to new. :
//template<class Type, template<class> class ListType=UList> public method
template<class Type> {
label mergePoints
( public:
const bool dummy,
const UIndirectList<Type>& points, //- Construct from dictionary
const scalar mergeTol, extractFromNone(const dictionary& dict);
const bool verbose,
labelList& pointMap, //- Destructor
const Type& origin = Type::zero virtual ~extractFromNone();
);
//- Extracted features from surface (no-op)
virtual autoPtr<surfaceFeatures> features
(
const triSurface& surf
) const override;
};
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository } // End namespace surfaceFeaturesExtraction
#include "mergePoints1.C" } // End namespace Foam
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "extractFromSurface.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceFeaturesExtraction
{
addNamedToRunTimeSelectionTable
(
method,
extractFromSurface,
dictionary,
extractFromSurface
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::extractFromSurface::extractFromSurface
(
const dictionary& dict
)
:
method()
{
const dictionary& coeffDict =
dict.optionalSubDict("extractFromSurfaceCoeffs");
coeffDict.lookup("includedAngle") >> includedAngle_;
coeffDict.readIfPresent("geometricTestOnly", geometricTestOnly_);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::extractFromSurface::~extractFromSurface()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceFeatures>
Foam::surfaceFeaturesExtraction::extractFromSurface::features
(
const triSurface& surf
) const
{
Info<< nl << "Constructing feature set from included angle "
<< includedAngle() << nl
<< "Selecting edges based purely on geometric tests: "
<< geometricTestOnly().asText() << endl;
return autoPtr<surfaceFeatures>
(
new surfaceFeatures
(
surf,
includedAngle(),
0, // minLen
0, // minElems
geometricTestOnly()
)
);
}
// ************************************************************************* //

View File

@ -2,8 +2,8 @@
========= | ========= |
\\ / 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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -21,64 +21,66 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
InNamspace Class
Foam Foam::surfaceFeaturesExtraction::extractFromSurface
Description Description
Various functions to operate on Lists. Run-time selectable surface feature extraction - extract from surface.
Selectable as "extractFromSurface".
Mandatory dictionary entries: "includedAngle".
Optional dictionary entries: "geometricTestOnly".
SourceFiles SourceFiles
ListOps.C extractFromSurface.C
ListOpsTemplates.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ListOps1_H #ifndef surfaceFeaturesExtraction_extractFromSurface_H
#define ListOps1_H #define surfaceFeaturesExtraction_extractFromSurface_H
#include "ListOps.H" #include "surfaceFeaturesExtraction.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace surfaceFeaturesExtraction
{
//- Reorder the elements (indices, not values) of a list. /*---------------------------------------------------------------------------*\
// Negative ListType elements are untouched, unless pruning has been selected. Class surfaceFeaturesExtraction::extractFromSurface Declaration
// With pruning, these elements are skipped and the list shrinks accordingly. \*---------------------------------------------------------------------------*/
template<class ListType>
ListType reorder
(
const labelUList& oldToNew,
const ListType&,
const bool prune
);
//- Inplace reorder the elements of a list. class extractFromSurface
// Negative ListType elements are untouched, unless pruning has been selected. :
// With pruning, these elements are skipped and the list shrinks accordingly. public method
template<class ListType> {
void inplaceReorder public:
(
const labelUList& oldToNew, //- Construct from dictionary
ListType&, extractFromSurface(const dictionary& dict);
const bool prune
); //- Destructor
virtual ~extractFromSurface();
//- Features extracted from surface
virtual autoPtr<surfaceFeatures> features
(
const triSurface& surf
) const override;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace surfaceFeaturesExtraction
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "ListOps1Templates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "surfaceFeaturesExtraction.H"
#include "dictionary.H"
#include "ListOps.H"
#include "error.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceFeaturesExtraction
{
defineTypeName(method);
defineRunTimeSelectionTable
(
method,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::method::method()
:
includedAngle_(0),
geometricTestOnly_(Switch::NO)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfaceFeaturesExtraction::method::~method()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceFeaturesExtraction::method>
Foam::surfaceFeaturesExtraction::method::New
(
const dictionary& dict
)
{
const word methodName = dict.lookup("extractionMethod");
auto cstrIter = dictionaryConstructorTablePtr_->cfind(methodName);
if (!cstrIter.found())
{
FatalIOErrorInFunction
(
dict
) << "Unknown extractionMethod " << methodName << nl << nl
<< "Valid extraction methods:" << nl
<< flatOutput(dictionaryConstructorTablePtr_->sortedToc())
<< exit(FatalIOError);
}
return autoPtr<method>(cstrIter.object()(dict));
}
// ************************************************************************* //

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Namespace
Foam::surfaceFeaturesExtraction
Description
Namespace for run-time selectable surface feature extraction methods.
Class
Foam::surfaceFeaturesExtraction::method
Description
Abstract base for run-time selectable surface feature extraction methods.
SourceFiles
surfaceFeaturesExtraction.C
\*---------------------------------------------------------------------------*/
#ifndef surfaceFeaturesExtraction_method_H
#define surfaceFeaturesExtraction_method_H
#include "surfaceFeatures.H"
#include "dictionary.H"
#include "Switch.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace surfaceFeaturesExtraction
{
/*---------------------------------------------------------------------------*\
Class surfaceFeaturesExtraction::method Declaration
\*---------------------------------------------------------------------------*/
class method
{
protected:
scalar includedAngle_;
Switch geometricTestOnly_;
//- Construct null
method();
public:
//- Runtime type information
ClassNameNoDebug("method");
// Constructors
//- Construct from dictionary
method(const dictionary& dict);
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
method,
dictionary,
(
const dictionary& dict
),
(dict)
);
// Selectors
//- Select constructed from dictionary
static autoPtr<method> New
(
const dictionary& dict
);
//- Destructor
virtual ~method();
// Member Functions
//- The included angle, if set
inline scalar includedAngle() const
{
return includedAngle_;
}
//- Use geometric test only
inline Switch geometricTestOnly() const
{
return geometricTestOnly_;
}
//- Extracted features
virtual autoPtr<surfaceFeatures> features
(
const triSurface& surf
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace surfaceFeaturesExtraction
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -16,38 +16,60 @@ FoamFile
surface1.stl surface1.stl
{ {
// How to obtain raw features (extractFromFile || extractFromSurface) // Extract raw features (none | extractFromFile | extractFromSurface)
extractionMethod extractFromSurface; extractionMethod extractFromSurface;
extractFromSurfaceCoeffs // Mark edges whose adjacent surface normals are at an angle less
{ // than includedAngle as features
// Mark edges whose adjacent surface normals are at an angle less // - 0 : selects no edges
// than includedAngle as features // - 180: selects all edges
// - 0 : selects no edges includedAngle 120;
// - 180: selects all edges
includedAngle 120;
// Do not mark region edges // Do not mark region edges
geometricTestOnly yes; geometricTestOnly yes;
}
// Write options // Generate additional intersection features (none | self | region)
intersectionMethod none;
// Write features to obj format for postprocessing // Tolerance for surface intersections
writeObj yes; // tolerance 1e-3;
// Output options:
// Write features to obj format for postprocessing
writeObj yes;
}
// Self intersection (single or multiple surfaces).
// - Use 'surfaces' entry (a wordRe list) if it exists.
// - If the dictionary name does not have an extension, 'surfaces' is mandatory.
outputName1
{
extractionMethod none;
surfaces (surface1.stl surface2.nas);
// Generate additional intersection features (none | self | region)
intersectionMethod self;
// Tolerance for surface intersections
// tolerance 1e-3;
// Output options:
// Write features to OBJ format for postprocessing
writeObj yes;
} }
surface2.nas surface2.nas
{ {
// How to obtain raw features (extractFromFile || extractFromSurface) // Extract raw features (none | extractFromFile | extractFromSurface)
extractionMethod extractFromFile; extractionMethod extractFromFile;
extractFromFileCoeffs // Load from an existing feature edge file
{ featureEdgeFile "constant/triSurface/featureEdges.nas";
// Load from an existing feature edge file
featureEdgeFile "constant/triSurface/featureEdges.nas";
}
trimFeatures trimFeatures
{ {
@ -60,57 +82,57 @@ surface2.nas
subsetFeatures subsetFeatures
{ {
// Use a plane to select feature edges // Use a plane to select feature edges (normal)(basePoint)
// (normal)(basePoint) // Only keep edges that intersect the plane
// Keep only edges that intersect the plane will be included plane (1 0 0)(0 0 0);
plane (1 0 0)(0 0 0);
// Select feature edges using a box // Select feature edges using a box // (minPt)(maxPt)
// (minPt)(maxPt) // Only keep edges inside the box:
// Keep edges inside the box: insideBox (0 0 0)(1 1 1);
insideBox (0 0 0)(1 1 1);
// Keep edges outside the box: // Only keep edges outside the box:
outsideBox (0 0 0)(1 1 1); outsideBox (0 0 0)(1 1 1);
// Keep nonManifold edges (edges with >2 connected faces where // Keep nonManifold edges (edges with >2 connected faces where
// the faces form more than two different normal planes) // the faces form more than two different normal planes)
nonManifoldEdges yes; nonManifoldEdges yes;
// Keep open edges (edges with 1 connected face) // Keep open edges (edges with 1 connected face)
openEdges yes; openEdges yes;
} }
addFeatures addFeatures
{ {
// Add (without merging) another extendedFeatureEdgeMesh // Add (without merging) another extendedFeatureEdgeMesh
name axZ.extendedFeatureEdgeMesh; name axZ.extendedFeatureEdgeMesh;
// Optionally flip features (invert all normals, making
// convex<->concave etc)
//flip false;
} }
// Output the curvature of the surface
curvature no;
// Output the proximity of feature points and edges to each other // Generate additional intersection features (none | self | region)
featureProximity no; intersectionMethod none;
// The maximum search distance to use when looking for other feature // Tolerance for surface intersections
// points and edges // tolerance 1e-3;
maxFeatureProximity 1;
// Out put the closeness of surface elements to other surface elements. // Output options:
closeness no;
// Write options // Output the closeness of surface elements to other surface elements.
closeness no;
// Write features to obj format for postprocessing // Output surface curvature
writeObj yes; curvature no;
// Write surface proximity and curvature fields to vtk format // Output the proximity of feature points and edges to another
// for postprocessing featureProximity no;
writeVTK no;
// The maximum search distance when checking feature proximity
maxFeatureProximity 1;
// Write features to OBJ format for postprocessing
writeObj no;
// Write closeness/curvature/proximity fields as VTK for postprocessing
writeVTK no;
} }

View File

@ -129,8 +129,7 @@ void dumpFaces
const Map<label>& connectedFaces const Map<label>& connectedFaces
) )
{ {
Info<< "Dumping connectedFaces as Lightwave .obj file to " << fName Info<< "Dumping connectedFaces as .obj file to " << fName << nl;
<< "\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n";
OFstream os(fName); OFstream os(fName);

View File

@ -51,8 +51,8 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade # USER EDITABLE PART: Changes made here may be lost with the next upgrade
set boost_version=boost_1_62_0 set boost_version=boost_1_64_0
set cgal_version=CGAL-4.9 set cgal_version=CGAL-4.9.1
setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
setenv CGAL_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version setenv CGAL_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version

View File

@ -66,6 +66,9 @@ case ThirdParty:
case Gcc63: case Gcc63:
set gcc_version=gcc-6.3.0 set gcc_version=gcc-6.3.0
breaksw breaksw
case Gcc71:
set gcc_version=gcc-7.1.0
breaksw
case Clang: case Clang:
set clang_version=llvm-3.7.1 set clang_version=llvm-3.7.1
breaksw breaksw

View File

@ -50,8 +50,8 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade # USER EDITABLE PART: Changes made here may be lost with the next upgrade
boost_version=boost_1_62_0 boost_version=boost_1_64_0
cgal_version=CGAL-4.9 cgal_version=CGAL-4.9.1
export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version

View File

@ -65,6 +65,9 @@ ThirdParty)
Gcc63) Gcc63)
gcc_version=gcc-6.3.0 gcc_version=gcc-6.3.0
;; ;;
Gcc71)
gcc_version=gcc-7.1.0
;;
Clang) Clang)
clang_version=llvm-3.7.1 clang_version=llvm-3.7.1
;; ;;

View File

@ -943,7 +943,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
} }
} }
// fall-through: nothing to do // fallthrough: nothing to do
return false; return false;
} }

View File

@ -54,7 +54,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
if (s) if (s)
{ {
if (2*s > this->tableSize_) if (2*s > this->capacity())
{ {
this->resize(2*s); this->resize(2*s);
} }

View File

@ -29,7 +29,6 @@ License
#include "HashTable.H" #include "HashTable.H"
#include "List.H" #include "List.H"
#include "FixedList.H" #include "FixedList.H"
#include "Tuple2.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -112,14 +111,14 @@ Foam::HashTable<T, Key, Hash>::HashTable
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
Foam::HashTable<T, Key, Hash>::HashTable Foam::HashTable<T, Key, Hash>::HashTable
( (
std::initializer_list<Tuple2<Key, T>> lst std::initializer_list<std::pair<Key, T>> lst
) )
: :
HashTable<T, Key, Hash>(2*lst.size()) HashTable<T, Key, Hash>(2*lst.size())
{ {
for (const Tuple2<Key, T>& pair : lst) for (const auto& pair : lst)
{ {
insert(pair.first(), pair.second()); insert(pair.first, pair.second);
} }
} }
@ -889,7 +888,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
void Foam::HashTable<T, Key, Hash>::operator= void Foam::HashTable<T, Key, Hash>::operator=
( (
std::initializer_list<Tuple2<Key, T>> lst std::initializer_list<std::pair<Key, T>> lst
) )
{ {
// Could be zero-sized from a previous transfer() // Could be zero-sized from a previous transfer()
@ -904,7 +903,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
for (const auto& pair : lst) for (const auto& pair : lst)
{ {
insert(pair.first(), pair.second()); insert(pair.first, pair.second);
} }
} }

View File

@ -57,11 +57,13 @@ SourceFiles
#include "uLabel.H" #include "uLabel.H"
#include "word.H" #include "word.H"
#include "Xfer.H" #include "Xfer.H"
#include "Hash.H"
#include "className.H" #include "className.H"
#include "nullObject.H" #include "nullObject.H"
#include <initializer_list> #include <initializer_list>
#include <iterator> #include <iterator>
#include <utility>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +75,6 @@ namespace Foam
template<class T> class List; template<class T> class List;
template<class T> class UList; template<class T> class UList;
template<class T, unsigned Size> class FixedList; template<class T, unsigned Size> class FixedList;
template<class T1, class T2> class Tuple2;
template<class T, class Key, class Hash> class HashTable; template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
@ -212,7 +213,7 @@ private:
// Private data type for table entries // Private data type for table entries
//- Structure to hold a hashed entry, with a SLList for collisions //- Structure to hold a hashed entry, with a linked-list for collisions
struct hashedEntry struct hashedEntry
{ {
//- The lookup key //- The lookup key
@ -224,7 +225,7 @@ private:
//- Pointer to next hashedEntry in sub-list //- Pointer to next hashedEntry in sub-list
hashedEntry* next_; hashedEntry* next_;
//- Construct from key, next pointer and object //- Construct from key, object, next pointer
inline hashedEntry(const Key& key, const T& obj, hashedEntry* next); inline hashedEntry(const Key& key, const T& obj, hashedEntry* next);
private: private:
@ -296,7 +297,7 @@ public:
HashTable(const Xfer<HashTable<T, Key, Hash>>& ht); HashTable(const Xfer<HashTable<T, Key, Hash>>& ht);
//- Construct from an initializer list //- Construct from an initializer list
HashTable(std::initializer_list<Tuple2<Key, T>> lst); HashTable(std::initializer_list<std::pair<Key, T>> lst);
//- Destructor //- Destructor
@ -558,7 +559,7 @@ public:
void operator=(const HashTable<T, Key, Hash>& rhs); void operator=(const HashTable<T, Key, Hash>& rhs);
//- Assignment from an initializer list //- Assignment from an initializer list
void operator=(std::initializer_list<Tuple2<Key, T>> lst); void operator=(std::initializer_list<std::pair<Key, T>> lst);
//- Equality. Hash tables are equal if the keys and values are equal. //- Equality. Hash tables are equal if the keys and values are equal.
// Independent of table storage size and table order. // Independent of table storage size and table order.

View File

@ -96,7 +96,7 @@ public:
{} {}
//- Construct from an initializer list //- Construct from an initializer list
Map(std::initializer_list<Tuple2<label, T>> map) Map(std::initializer_list<std::pair<label, T>> map)
: :
parent_type(map) parent_type(map)
{} {}

View File

@ -57,25 +57,41 @@ static const List<Type>& emptyList()
//- Renumber the values (not the indices) of a list. //- Renumber the values (not the indices) of a list.
// Negative ListType elements are left as is. // Negative ListType elements are left untouched.
template<class ListType> template<class ListType>
ListType renumber(const labelUList& oldToNew, const ListType& lst); ListType renumber(const labelUList& oldToNew, const ListType& lst);
//- Inplace renumber the values of a list. //- Inplace renumber the values (not the indices) of a list.
// Negative ListType elements are left as is. // Negative ListType elements are left untouched.
template<class ListType> template<class ListType>
void inplaceRenumber(const labelUList& oldToNew, ListType& lst); void inplaceRenumber(const labelUList& oldToNew, ListType& lst);
//- Reorder the elements (indices, not values) of a list. //- Reorder the elements of a list.
// Negative ListType elements are left as is. // Locations with negative oldToNew values are left as is (copy-through).
// However, if pruning is activated, these negative oldToNew values are
// instead skipped over and the resulting list shrunk to the max index
// actually used.
template<class ListType> template<class ListType>
ListType reorder(const labelUList& oldToNew, const ListType& lst); ListType reorder
(
const labelUList& oldToNew,
const ListType& lst,
const bool prune = false
);
//- Inplace reorder the elements of a list. //- Inplace reorder the elements of a list.
// Negative ListType elements are left as is. // Locations with negative oldToNew values are left as is (copy-through).
// However, if pruning is activated, these negative oldToNew values are
// instead skipped over and the resulting list shrunk to the max index
// actually used.
template<class ListType> template<class ListType>
void inplaceReorder(const labelUList& oldToNew, ListType& lst); void inplaceReorder
(
const labelUList& oldToNew,
ListType& lst,
const bool prune = false
);
// Variants to work with iterators and sparse tables. // Variants to work with iterators and sparse tables.
@ -156,12 +172,20 @@ void inplaceSubset(const BoolListType& select, ListType& lst);
//- Copy a subset of the input list when predicate is true. //- Copy a subset of the input list when predicate is true.
// Do not use FixedList for the input list, since it doesn't resize. // Do not use FixedList for the input list, since it doesn't resize.
template<class ListType, class UnaryPredicate> template<class ListType, class UnaryPredicate>
ListType subsetList(const ListType& input, UnaryPredicate pred); ListType subsetList
(
const ListType& input,
const UnaryPredicate& pred
);
//- Inplace subset of the list when predicate is true. //- Inplace subset of the list when predicate is true.
// Do not use FixedList for the input list, since it doesn't resize. // Do not use FixedList for the input list, since it doesn't resize.
template<class ListType, class UnaryPredicate> template<class ListType, class UnaryPredicate>
void inplaceSubsetList(ListType& input, UnaryPredicate pred); void inplaceSubsetList
(
ListType& input,
const UnaryPredicate& pred
);
//- Invert one-to-one map. Unmapped elements will be -1. //- Invert one-to-one map. Unmapped elements will be -1.

View File

@ -70,23 +70,42 @@ template<class ListType>
ListType Foam::reorder ListType Foam::reorder
( (
const labelUList& oldToNew, const labelUList& oldToNew,
const ListType& lst const ListType& lst,
const bool prune
) )
{ {
ListType newLst(lst.size()); const label sz = lst.size();
newLst.setSize(lst.size()); // Consistent sizes (eg, DynamicList)
forAll(lst, elemI) ListType newLst(sz);
newLst.setSize(sz); // Consistent sizing (eg, DynamicList)
label maxIdx = -1; // For pruning: newSize = maxIdx+1
forAll(lst, i)
{ {
if (oldToNew[elemI] >= 0) const label newIdx = oldToNew[i];
if (newIdx >= 0)
{ {
newLst[oldToNew[elemI]] = lst[elemI]; // Could additionally enforce (newIdx < lst.size())
// ... or just rely on FULLDEBUG from UList
newLst[newIdx] = lst[i];
if (maxIdx < newIdx)
{
maxIdx = newIdx;
}
} }
else else if (!prune)
{ {
newLst[elemI] = lst[elemI]; newLst[i] = lst[i];
} }
} }
if (prune)
{
newLst.setSize(maxIdx+1);
}
return newLst; return newLst;
} }
@ -95,24 +114,42 @@ template<class ListType>
void Foam::inplaceReorder void Foam::inplaceReorder
( (
const labelUList& oldToNew, const labelUList& oldToNew,
ListType& lst ListType& lst,
const bool prune
) )
{ {
ListType newLst(lst.size()); const label sz = lst.size();
newLst.setSize(lst.size()); // Consistent sizing (eg, DynamicList)
forAll(lst, elemI) ListType newLst(sz);
newLst.setSize(sz); // Consistent sizing (eg, DynamicList)
label maxIdx = -1; // For pruning: newSize = maxIdx+1
forAll(lst, i)
{ {
if (oldToNew[elemI] >= 0) const label newIdx = oldToNew[i];
if (newIdx >= 0)
{ {
newLst[oldToNew[elemI]] = lst[elemI]; // Could additionally enforce (newIdx < lst.size())
// ... or just rely on FULLDEBUG from UList
newLst[newIdx] = lst[i];
if (maxIdx < newIdx)
{
maxIdx = newIdx;
}
} }
else else if (!prune)
{ {
newLst[elemI] = lst[elemI]; newLst[i] = lst[i];
} }
} }
if (prune)
{
newLst.setSize(maxIdx+1);
}
lst.transfer(newLst); lst.transfer(newLst);
} }
@ -126,9 +163,13 @@ void Foam::inplaceMapValue
{ {
for (auto iter = lst.begin(); iter != lst.end(); ++iter) for (auto iter = lst.begin(); iter != lst.end(); ++iter)
{ {
if (iter.object() >= 0) const label oldIdx = iter.object();
if (oldIdx >= 0)
{ {
iter.object() = oldToNew[iter.object()]; // Could additionally enforce (oldIdx < oldToNew.size())
// ... or just rely on FULLDEBUG from UList
iter.object() = oldToNew[oldIdx];
} }
} }
} }
@ -145,9 +186,13 @@ void Foam::inplaceMapKey
for (auto iter = lst.begin(); iter != lst.end(); ++iter) for (auto iter = lst.begin(); iter != lst.end(); ++iter)
{ {
if (iter.key() >= 0) const label oldIdx = iter.key();
if (oldIdx >= 0)
{ {
newLst.insert(oldToNew[iter.key()], iter.object()); // Could additionally enforce (oldIdx < oldToNew.size())
// ... or just rely on FULLDEBUG from UList
newLst.insert(oldToNew[oldIdx], iter.object());
} }
} }
@ -423,7 +468,7 @@ template<class ListType, class UnaryPredicate>
ListType Foam::subsetList ListType Foam::subsetList
( (
const ListType& lst, const ListType& lst,
UnaryPredicate pred const UnaryPredicate& pred
) )
{ {
ListType newLst(lst.size()); ListType newLst(lst.size());
@ -447,7 +492,7 @@ template<class ListType, class UnaryPredicate>
void Foam::inplaceSubsetList void Foam::inplaceSubsetList
( (
ListType& lst, ListType& lst,
UnaryPredicate pred const UnaryPredicate& pred
) )
{ {
label nElem = 0; label nElem = 0;

View File

@ -286,7 +286,7 @@ Foam::Xfer<Foam::labelList> Foam::PackedBoolList::used() const
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
void Foam::PackedBoolList::operator=(const Foam::UList<bool>& lst) void Foam::PackedBoolList::operator=(const UList<bool>& lst)
{ {
this->setSize(lst.size()); this->setSize(lst.size());

View File

@ -94,7 +94,7 @@ public:
inline PackedBoolList(); inline PackedBoolList();
//- Construct from Istream //- Construct from Istream
PackedBoolList(Istream&); PackedBoolList(Istream& is);
//- Construct with given size, initializes list to 0 //- Construct with given size, initializes list to 0
explicit inline PackedBoolList(const label size); explicit inline PackedBoolList(const label size);
@ -103,19 +103,19 @@ public:
inline PackedBoolList(const label size, const bool val); inline PackedBoolList(const label size, const bool val);
//- Copy constructor //- Copy constructor
inline PackedBoolList(const PackedBoolList&); inline PackedBoolList(const PackedBoolList& lst);
//- Copy constructor //- Copy constructor
explicit inline PackedBoolList(const PackedList<1>&); explicit inline PackedBoolList(const PackedList<1>& lst);
//- Construct by transferring the parameter contents //- Construct by transferring the parameter contents
inline PackedBoolList(const Xfer<PackedBoolList>&); inline PackedBoolList(const Xfer<PackedBoolList>& lst);
//- Construct by transferring the parameter contents //- Construct by transferring the parameter contents
inline PackedBoolList(const Xfer<PackedList<1>>&); inline PackedBoolList(const Xfer<PackedList<1>>& lst);
//- Construct from a list of bools //- Construct from a list of bools
explicit inline PackedBoolList(const Foam::UList<bool>&); explicit inline PackedBoolList(const UList<bool>& lst);
//- Construct from a list of labels //- Construct from a list of labels
// using the labels as indices to indicate which bits are set // using the labels as indices to indicate which bits are set
@ -131,132 +131,132 @@ public:
// Member Functions // Member Functions
// Access // Access
using PackedList<1>::set; using PackedList<1>::set;
using PackedList<1>::unset; using PackedList<1>::unset;
//- Set specified bits. //- Set specified bits.
void set(const PackedList<1>&); void set(const PackedList<1>& lst);
//- Set the listed indices. Return number of elements changed. //- Set the listed indices. Return number of elements changed.
// Does auto-vivify for non-existent entries. // Does auto-vivify for non-existent entries.
label set(const labelUList& indices); label set(const labelUList& indices);
//- Set the listed indices. Return number of elements changed. //- Set the listed indices. Return number of elements changed.
// Does auto-vivify for non-existent entries. // Does auto-vivify for non-existent entries.
label set(const UIndirectList<label>& indices); label set(const UIndirectList<label>& indices);
//- Unset specified bits. //- Unset specified bits.
void unset(const PackedList<1>&); void unset(const PackedList<1>& lst);
//- Unset the listed indices. Return number of elements changed. //- Unset the listed indices. Return number of elements changed.
// Never auto-vivify entries. // Never auto-vivify entries.
label unset(const labelUList& indices); label unset(const labelUList& indices);
//- Unset the listed indices. Return number of elements changed. //- Unset the listed indices. Return number of elements changed.
// Never auto-vivify entries. // Never auto-vivify entries.
label unset(const UIndirectList<label>& indices); label unset(const UIndirectList<label>& indices);
//- Subset with the specified list. //- Subset with the specified list.
void subset(const PackedList<1>&); void subset(const PackedList<1>& lst);
//- Subset with the listed indices. //- Subset with the listed indices.
// Return number of elements subsetted. // Return number of elements subsetted.
label subset(const labelUList& indices); label subset(const labelUList& indices);
//- Subset with the listed indices. //- Subset with the listed indices.
// Return number of elements subsetted. // Return number of elements subsetted.
label subset(const UIndirectList<label>& indices); label subset(const UIndirectList<label>& indices);
//- Return indices of the used (true) elements as a list of labels //- Return indices of the used (true) elements as a list of labels
Xfer<labelList> used() const; Xfer<labelList> used() const;
// Edit // Edit
//- Transfer the contents of the argument list into this list //- Transfer the contents of the argument list into this list
// and annul the argument list. // and annul the argument list.
inline void transfer(PackedBoolList&); inline void transfer(PackedBoolList& lst);
//- Transfer the contents of the argument list into this list //- Transfer the contents of the argument list into this list
// and annul the argument list. // and annul the argument list.
inline void transfer(PackedList<1>&); inline void transfer(PackedList<1>& lst);
//- Transfer contents to the Xfer container //- Transfer contents to the Xfer container
inline Xfer<PackedBoolList> xfer(); inline Xfer<PackedBoolList> xfer();
// Member Operators // Member Operators
//- Assignment of all entries to the given value. //- Assignment of all entries to the given value.
inline void operator=(const bool val); inline void operator=(const bool val);
//- Assignment operator. //- Assignment operator.
inline void operator=(const PackedBoolList&); inline void operator=(const PackedBoolList& lst);
//- Assignment operator. //- Assignment operator.
inline void operator=(const PackedList<1>&); inline void operator=(const PackedList<1>& lst);
//- Assignment operator. //- Assignment operator.
void operator=(const Foam::UList<bool>&); void operator=(const UList<bool>& lst);
//- Assignment operator, //- Assignment operator,
// using the labels as indices to indicate which bits are set // using the labels as indices to indicate which bits are set
inline void operator=(const labelUList& indices); inline void operator=(const labelUList& indices);
//- Assignment operator, //- Assignment operator,
// using the labels as indices to indicate which bits are set // using the labels as indices to indicate which bits are set
inline void operator=(const UIndirectList<label>&); inline void operator=(const UIndirectList<label>& indices);
//- Complement operator //- Complement operator
inline PackedBoolList operator~() const; inline PackedBoolList operator~() const;
//- And operator (lists may be dissimilar sizes) //- And operator (lists may be dissimilar sizes)
inline PackedBoolList& operator&=(const PackedList<1>&); inline PackedBoolList& operator&=(const PackedList<1>& lst);
//- And operator (lists may be dissimilar sizes) //- And operator (lists may be dissimilar sizes)
// using the labels as indices to indicate which bits are set // using the labels as indices to indicate which bits are set
inline PackedBoolList& operator&=(const labelUList& indices); inline PackedBoolList& operator&=(const labelUList& indices);
//- And operator (lists may be dissimilar sizes) //- And operator (lists may be dissimilar sizes)
// using the labels as indices to indicate which bits are set // using the labels as indices to indicate which bits are set
inline PackedBoolList& operator&=(const UIndirectList<label>&); inline PackedBoolList& operator&=(const UIndirectList<label>& indices);
//- Xor operator (lists may be dissimilar sizes) //- Xor operator (lists may be dissimilar sizes)
// Retains unique entries // Retains unique entries
PackedBoolList& operator^=(const PackedList<1>&); PackedBoolList& operator^=(const PackedList<1>& lst);
//- Or operator (lists may be dissimilar sizes) //- Or operator (lists may be dissimilar sizes)
inline PackedBoolList& operator|=(const PackedList<1>&); inline PackedBoolList& operator|=(const PackedList<1>& lst);
//- Or operator (lists may be dissimilar sizes), //- Or operator (lists may be dissimilar sizes),
// using the labels as indices to indicate which bits are set // using the labels as indices to indicate which bits are set
inline PackedBoolList& operator|=(const labelUList& indices); inline PackedBoolList& operator|=(const labelUList& indices);
//- Or operator (lists may be dissimilar sizes), //- Or operator (lists may be dissimilar sizes),
// using the labels as indices to indicate which bits are set // using the labels as indices to indicate which bits are set
inline PackedBoolList& operator|=(const UIndirectList<label>&); inline PackedBoolList& operator|=(const UIndirectList<label>& indices);
//- Add entries to this list, synonymous with the or operator //- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const PackedList<1>&); inline PackedBoolList& operator+=(const PackedList<1>& lst);
//- Add entries to this list, synonymous with the or operator //- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const labelUList& indices); inline PackedBoolList& operator+=(const labelUList& indices);
//- Add entries to this list, synonymous with the or operator //- Add entries to this list, synonymous with the or operator
inline PackedBoolList& operator+=(const UIndirectList<label>&); inline PackedBoolList& operator+=(const UIndirectList<label>& indices);
//- Remove entries from this list - unset the specified bits //- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const PackedList<1>&); inline PackedBoolList& operator-=(const PackedList<1>& lst);
//- Remove entries from this list - unset the specified bits //- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const labelUList& indices); inline PackedBoolList& operator-=(const labelUList& indices);
//- Remove entries from this list - unset the specified bits //- Remove entries from this list - unset the specified bits
inline PackedBoolList& operator-=(const UIndirectList<label>&); inline PackedBoolList& operator-=(const UIndirectList<label>& indices);
}; };

View File

@ -73,7 +73,7 @@ inline Foam::PackedBoolList::PackedBoolList(const Xfer<PackedList<1>>& lst)
{} {}
inline Foam::PackedBoolList::PackedBoolList(const Foam::UList<bool>& lst) inline Foam::PackedBoolList::PackedBoolList(const UList<bool>& lst)
: :
PackedList<1>() PackedList<1>()
{ {

View File

@ -118,9 +118,9 @@ class Ostream;
template<unsigned nBits> class PackedList; template<unsigned nBits> class PackedList;
template<unsigned nBits> template<unsigned nBits>
Istream& operator>>(Istream&, PackedList<nBits>&); Istream& operator>>(Istream& is, PackedList<nBits>& lst);
template<unsigned nBits> template<unsigned nBits>
Ostream& operator<<(Ostream&, const PackedList<nBits>&); Ostream& operator<<(Ostream& os, const PackedList<nBits>& lst);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -160,11 +160,11 @@ protected:
inline static label packedLength(const label); inline static label packedLength(const label);
//- Read a list entry (allows for specialization) //- Read a list entry (allows for specialization)
inline static unsigned int readValue(Istream&); inline static unsigned int readValue(Istream& is);
//- Read an index/value pair and set accordingly. //- Read an index/value pair and set accordingly.
// For bool specialization, read a single index value // For bool specialization, read a single index value
inline void setPair(Istream&); inline void setPair(Istream& is);
private: private:
@ -252,167 +252,167 @@ public:
// Member Functions // Member Functions
// Access // Access
//- The number of elements that can be stored before reallocating //- The number of elements that can be stored before reallocating
inline label capacity() const; inline label capacity() const;
//- Number of entries. //- Number of entries.
inline label size() const; inline label size() const;
//- Return true if the list is empty (ie, size() is zero). //- Return true if the list is empty (ie, size() is zero).
inline bool empty() const; inline bool empty() const;
//- Get value at index I. //- Get value at index I.
// Never auto-vivify entries. // Never auto-vivify entries.
inline unsigned int get(const label i) const; inline unsigned int get(const label i) const;
//- Set value at index I. Return true if value changed. //- Set value at index I. Return true if value changed.
// Does auto-vivify for non-existent entries. // Does auto-vivify for non-existent, non-zero entries.
// Default value set is the max_value. // Default value set is the max_value.
inline bool set(const label i, const unsigned int val = ~0u); inline bool set(const label i, const unsigned int val = ~0u);
//- Unset the entry at index I. Return true if value changed. //- Unset the entry at index I. Return true if value changed.
// Never auto-vivify entries. // Never auto-vivify entries.
inline bool unset(const label i); inline bool unset(const label i);
//- Return the underlying packed storage //- Return the underlying packed storage
// Manipulate with utmost caution // Manipulate with utmost caution
inline List<unsigned int>& storage(); inline List<unsigned int>& storage();
//- Return the underlying packed storage //- Return the underlying packed storage
inline const List<unsigned int>& storage() const; inline const List<unsigned int>& storage() const;
//- The list length when packed //- The list length when packed
inline label packedLength() const; inline label packedLength() const;
//- Return the binary size in number of characters //- Return the binary size in number of characters
// used in the underlying storage // used in the underlying storage
inline std::streamsize byteSize() const; inline std::streamsize byteSize() const;
//- Count number of bits set, O(log(n)) //- Count number of bits set, O(log(n))
// Uses the Hamming weight (population count) method // Uses the Hamming weight (population count) method
// http://en.wikipedia.org/wiki/Hamming_weight // http://en.wikipedia.org/wiki/Hamming_weight
unsigned int count() const; unsigned int count() const;
//- Return the values as a list of labels //- Return the values as a list of labels
Xfer<labelList> values() const; Xfer<labelList> values() const;
//- Print bit patterns, optionally output unused elements //- Print bit patterns, optionally output unused elements
// //
// addressable bits: // addressable bits:
// on: '1', off: '-' // on: '1', off: '-'
// //
// non-addressable bits: // non-addressable bits:
// on: '!', off: '.' // on: '!', off: '.'
// //
Ostream& printBits(Ostream&, const bool fullOutput=false) const; Ostream& printBits(Ostream& os, const bool fullOutput=false) const;
//- Print information and bit patterns (with printBits) //- Print information and bit patterns (with printBits)
Ostream& printInfo(Ostream&, const bool fullOutput=false) const; Ostream& printInfo(Ostream& os, const bool fullOutput=false) const;
// Edit // Edit
//- Trim any trailing zero elements //- Trim any trailing zero elements
bool trim(); bool trim();
//- Invert the bits in the addressable region //- Invert the bits in the addressable region
void flip(); void flip();
//- Clear all bits //- Clear all bits
inline void reset(); inline void reset();
//- Alter the size of the underlying storage. //- Alter the size of the underlying storage.
// The addressed size will be truncated if needed to fit, but will // The addressed size will be truncated if needed to fit, but will
// remain otherwise untouched. // remain otherwise untouched.
inline void setCapacity(const label); inline void setCapacity(const label nElem);
//- Reset addressable list size, does not shrink the allocated size. //- Reset addressable list size, does not shrink the allocated size.
// Optionally specify a value for new elements. // Optionally specify a value for new elements.
inline void resize(const label, const unsigned int val = 0u); inline void resize(const label nElem, const unsigned int val = 0u);
//- Alias for resize() //- Alias for resize()
inline void setSize(const label, const unsigned int val = 0u); inline void setSize(const label nElem, const unsigned int val = 0u);
//- Reserve allocation space for at least this size. //- Reserve allocation space for at least this size.
// Never shrinks the allocated size. // Never shrinks the allocated size.
// The list size is adjusted as per DynamicList with // The list size is adjusted as per DynamicList with
// SizeInc=0, SizeMult=2, SizeDiv=1 // SizeInc=0, SizeMult=2, SizeDiv=1
inline void reserve(const label); inline void reserve(const label nElem);
//- Clear the list, i.e. set addressable size to zero. //- Clear the list, i.e. set addressable size to zero.
// Does not adjust the underlying storage // Does not adjust the underlying storage
inline void clear(); inline void clear();
//- Clear the list and delete storage. //- Clear the list and delete storage.
inline void clearStorage(); inline void clearStorage();
//- Shrink the allocated space to what is actually used. //- Shrink the allocated space to what is actually used.
inline void shrink(); inline void shrink();
//- Transfer the contents of the argument list into this list //- Transfer the contents of the argument list into this list
// and annul the argument list. // and annul the argument list.
inline void transfer(PackedList<nBits>&); inline void transfer(PackedList<nBits>& lst);
//- Transfer contents to the Xfer container //- Transfer contents to the Xfer container
inline Xfer<PackedList<nBits>> xfer(); inline Xfer<PackedList<nBits>> xfer();
// IO // IO
//- Clear list and read from stream //- Clear list and read from stream
Istream& read(Istream& is); Istream& read(Istream& is);
//- Write the List, with line-breaks in ASCII if the list length //- Write the List, with line-breaks in ASCII if the list length
// exceeds shortListLen. Using '0' suppresses line-breaks entirely. // exceeds shortListLen. Using '0' suppresses line-breaks entirely.
// A special indexed output (ASCII only) is triggered by specifying // A special indexed output (ASCII only) is triggered by specifying
// a negative value for shortListLen. // a negative value for shortListLen.
// //
// The indexed output may be convenient in some situations. // The indexed output may be convenient in some situations.
// The general format is a group of index/value pairs: // The general format is a group of index/value pairs:
// \verbatim // \verbatim
// { (index1 value1) (index2 value2) (index3 value3) } // { (index1 value1) (index2 value2) (index3 value3) }
// \endverbatim // \endverbatim
// The bool specialization just uses the indices corresponding to // The bool specialization just uses the indices corresponding to
// non-zero entries instead of a index/value pair: // non-zero entries instead of a index/value pair:
// \verbatim // \verbatim
// { index1 index2 index3 } // { index1 index2 index3 }
// \endverbatim // \endverbatim
Ostream& writeList(Ostream& os, const label shortListLen=0) const; Ostream& writeList(Ostream& os, const label shortListLen=0) const;
//- Write as a dictionary entry with keyword //- Write as a dictionary entry with keyword
void writeEntry(const word& keyword, Ostream& os) const; void writeEntry(const word& keyword, Ostream& os) const;
// Member operators // Member operators
//- Append a value at the end of the list //- Append a value at the end of the list
inline PackedList<nBits>& append(const unsigned int val); inline PackedList<nBits>& append(const unsigned int val);
//- Remove and return the last element //- Remove and return the last element
inline unsigned int remove(); inline unsigned int remove();
//- Get value at index I //- Get value at index I
// Never auto-vivify entries. // Never auto-vivify entries.
inline unsigned int operator[](const label i) const; inline unsigned int operator[](const label i) const;
//- Set value at index I. //- Set value at index I.
// Returns iterator to perform the actual operation. // Returns iterator to perform the actual operation.
// Does not auto-vivify entries, but will when assigned to. // Does not auto-vivify entries, but will when assigned to.
inline iteratorBase operator[](const label i); inline iteratorBase operator[](const label i);
//- Assignment of all entries to the given value. Takes linear time. //- Assignment of all entries to the given value. Takes linear time.
inline void operator=(const unsigned int val); inline void operator=(const unsigned int val);
//- Assignment operator. //- Assignment operator.
void operator=(const PackedList<nBits>& lst); void operator=(const PackedList<nBits>& lst);
//- Assignment operator. //- Assignment operator.
void operator=(const labelUList& lst); void operator=(const labelUList& lst);
//- Assignment operator. //- Assignment operator.
void operator=(const UIndirectList<label>& lst); void operator=(const UIndirectList<label>& lst);
// Iterators and helpers // Iterators and helpers
@ -442,7 +442,7 @@ public:
inline unsigned int get() const; inline unsigned int get() const;
//- Set value, returning true if changed, no range-checking //- Set value, returning true if changed, no range-checking
inline bool set(unsigned int); inline bool set(unsigned int val);
// Constructors // Constructors
@ -451,7 +451,7 @@ public:
inline iteratorBase(); inline iteratorBase();
//- Construct from base list and position index //- Construct from base list and position index
inline iteratorBase(const PackedList*, const label); inline iteratorBase(const PackedList* lst, const label i);
public: public:
@ -463,17 +463,17 @@ public:
//- Write index/value for a non-zero entry //- Write index/value for a non-zero entry
// The bool specialization writes the index only // The bool specialization writes the index only
inline bool writeIfSet(Ostream&) const; inline bool writeIfSet(Ostream& os) const;
// Member Operators // Member Operators
//- Compare values (not positions) //- Compare values (not positions)
inline bool operator==(const iteratorBase&) const; inline bool operator==(const iteratorBase& iter) const;
inline bool operator!=(const iteratorBase&) const; inline bool operator!=(const iteratorBase& iter) const;
//- Assign value, not position. //- Assign value, not position.
// This allows packed[0] = packed[3] for assigning values // This allows packed[0] = packed[3] for assigning values
inline void operator=(const iteratorBase&); inline void operator=(const iteratorBase& iter);
//- Assign value. //- Assign value.
// A non-existent entry will be auto-vivified. // A non-existent entry will be auto-vivified.
@ -484,7 +484,7 @@ public:
inline operator unsigned int () const; inline operator unsigned int () const;
//- Print information and values //- Print information and values
Ostream& printInfo(Ostream&) const; Ostream& printInfo(Ostream& os) const;
}; };
@ -496,11 +496,11 @@ public:
//- Disallow copy constructor from const_iterator //- Disallow copy constructor from const_iterator
// This would violate const-ness! // This would violate const-ness!
iterator(const const_iterator&); iterator(const const_iterator& iter);
//- Disallow assignment from const_iterator //- Disallow assignment from const_iterator
// This would violate const-ness! // This would violate const-ness!
void operator=(const const_iterator&); void operator=(const const_iterator& iter);
public: public:
@ -513,21 +513,21 @@ public:
//- Construct from iterator base, eg iter(packedlist[i]) //- Construct from iterator base, eg iter(packedlist[i])
// but also "iterator iter = packedlist[i];" // but also "iterator iter = packedlist[i];"
// An out-of-range iterator is assigned end() // An out-of-range iterator is assigned end()
inline iterator(const iteratorBase&); inline iterator(const iteratorBase& iter);
//- Construct from base list and position index //- Construct from base list and position index
inline iterator(const PackedList*, const label); inline iterator(const PackedList* lst, const label i);
// Member Operators // Member Operators
//- Compare positions (not values) //- Compare positions (not values)
inline bool operator==(const iteratorBase&) const; inline bool operator==(const iteratorBase& iter) const;
inline bool operator!=(const iteratorBase&) const; inline bool operator!=(const iteratorBase& iter) const;
//- Assign from iteratorBase, eg iter = packedlist[i] //- Assign from iteratorBase, eg iter = packedlist[i]
// An out-of-range iterator is assigned end() // An out-of-range iterator is assigned end()
inline void operator=(const iteratorBase&); inline void operator=(const iteratorBase& iter);
//- Return value //- Return value
inline unsigned int operator*() const; inline unsigned int operator*() const;
@ -571,24 +571,24 @@ public:
//- Construct from iterator base, eg iter(packedlist[i]) //- Construct from iterator base, eg iter(packedlist[i])
// but also "const_iterator iter = packedlist[i];" // but also "const_iterator iter = packedlist[i];"
// An out-of-range iterator is assigned cend() // An out-of-range iterator is assigned cend()
inline const_iterator(const iteratorBase&); inline const_iterator(const iteratorBase& iter);
//- Construct from base list and position index //- Construct from base list and position index
inline const_iterator(const PackedList*, const label); inline const_iterator(const PackedList* lst, const label i);
//- Construct from iterator //- Construct from iterator
inline const_iterator(const iterator&); inline const_iterator(const iterator& iter);
// Member operators // Member operators
//- Compare positions (not values) //- Compare positions (not values)
inline bool operator==(const iteratorBase&) const; inline bool operator==(const iteratorBase& iter) const;
inline bool operator!=(const iteratorBase&) const; inline bool operator!=(const iteratorBase& iter) const;
//- Assign from iteratorBase or derived //- Assign from iteratorBase or derived
// eg, iter = packedlist[i] or even iter = list.begin() // eg, iter = packedlist[i] or even iter = list.begin()
inline void operator=(const iteratorBase&); inline void operator=(const iteratorBase& iter);
//- Return referenced value directly //- Return referenced value directly
inline unsigned int operator*() const; inline unsigned int operator*() const;
@ -621,14 +621,14 @@ public:
friend Istream& operator>> <nBits> friend Istream& operator>> <nBits>
( (
Istream&, Istream& is,
PackedList<nBits>& PackedList<nBits>& lst
); );
friend Ostream& operator<< <nBits> friend Ostream& operator<< <nBits>
( (
Ostream&, Ostream& os,
const PackedList<nBits>& const PackedList<nBits>& lst
); );
}; };

View File

@ -267,7 +267,7 @@ Foam::PackedList<nBits>::clone() const
template<unsigned nBits> template<unsigned nBits>
inline Foam::PackedList<nBits>::iteratorBase::iteratorBase() inline Foam::PackedList<nBits>::iteratorBase::iteratorBase()
: :
list_(0), list_(nullptr),
index_(0) index_(0)
{} {}
@ -1002,6 +1002,12 @@ inline bool Foam::PackedList<nBits>::set
} }
else if (i >= size_) else if (i >= size_)
{ {
if (!val)
{
// Same as unset out-of-bounds = noop
return false;
}
// Lazy evaluation - increase size on assigment // Lazy evaluation - increase size on assigment
resize(i + 1); resize(i + 1);
} }
@ -1013,7 +1019,7 @@ inline bool Foam::PackedList<nBits>::set
template<unsigned nBits> template<unsigned nBits>
inline bool Foam::PackedList<nBits>::unset(const label i) inline bool Foam::PackedList<nBits>::unset(const label i)
{ {
// lazy evaluation - ignore out-of-bounds // Unset out-of-bounds = noop
if (i < 0 || i >= size_) if (i < 0 || i >= size_)
{ {
return false; return false;

View File

@ -43,6 +43,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
bool Foam::argList::bannerEnabled_ = true; bool Foam::argList::bannerEnabled_ = true;
bool Foam::argList::checkProcessorDirectories_ = true;
Foam::SLList<Foam::string> Foam::argList::validArgs; Foam::SLList<Foam::string> Foam::argList::validArgs;
Foam::HashTable<Foam::string> Foam::argList::validOptions; Foam::HashTable<Foam::string> Foam::argList::validOptions;
Foam::HashTable<Foam::string> Foam::argList::validParOptions; Foam::HashTable<Foam::string> Foam::argList::validParOptions;
@ -194,6 +195,12 @@ void Foam::argList::noParallel()
} }
void Foam::argList::noCheckProcessorDirectories()
{
checkProcessorDirectories_ = false;
}
void Foam::argList::printOptionUsage void Foam::argList::printOptionUsage
( (
const label location, const label location,
@ -759,7 +766,7 @@ void Foam::argList::parse
// - normal running : nProcs = dictNProcs = nProcDirs // - normal running : nProcs = dictNProcs = nProcDirs
// - decomposition to more processors : nProcs = dictNProcs // - decomposition to more processors : nProcs = dictNProcs
// - decomposition to fewer processors : nProcs = nProcDirs // - decomposition to fewer processors : nProcs = nProcDirs
if (dictNProcs > Pstream::nProcs()) if (checkProcessorDirectories_ && dictNProcs > Pstream::nProcs())
{ {
FatalError FatalError
<< source << source
@ -814,7 +821,11 @@ void Foam::argList::parse
{ {
// Possibly going to fewer processors. // Possibly going to fewer processors.
// Check if all procDirs are there. // Check if all procDirs are there.
if (dictNProcs < Pstream::nProcs()) if
(
checkProcessorDirectories_
&& dictNProcs < Pstream::nProcs()
)
{ {
label nProcDirs = 0; label nProcDirs = 0;
while while
@ -1337,15 +1348,30 @@ bool Foam::argList::checkRootCase() const
return false; return false;
} }
if (Pstream::master() && !isDir(path())) if (Pstream::parRun())
{ {
// Allow slaves on non-existing processor directories, created later if (Pstream::master() && (checkProcessorDirectories_ && !isDir(path())))
FatalError {
<< executable_ // Allow slaves on non-existing processor directories created later
<< ": cannot open case directory " << path() FatalError
<< endl; << executable_
<< ": cannot open case directory " << path()
<< endl;
return false; return false;
}
}
else
{
if (!isDir(path()))
{
FatalError
<< executable_
<< ": cannot open case directory " << path()
<< endl;
return false;
}
} }
return true; return true;

View File

@ -119,6 +119,9 @@ class argList
//- Track enabled/disabled banner state //- Track enabled/disabled banner state
static bool bannerEnabled_; static bool bannerEnabled_;
//- Track enabled/disabled checking of processor directories state
static bool checkProcessorDirectories_;
//- Switch on/off parallel mode. Has to be first to be constructed //- Switch on/off parallel mode. Has to be first to be constructed
// so destructor is done last. // so destructor is done last.
ParRunControl parRunControl_; ParRunControl parRunControl_;
@ -387,6 +390,9 @@ public:
//- Remove the parallel options //- Remove the parallel options
static void noParallel(); static void noParallel();
//- Remove checking of processor directories
static void noCheckProcessorDirectories();
//- Return true if the post-processing option is specified //- Return true if the post-processing option is specified
static bool postProcess(int argc, char *argv[]); static bool postProcess(int argc, char *argv[]);

View File

@ -47,13 +47,13 @@ namespace mathematical
static const char* const group = "mathematical"; static const char* const group = "mathematical";
const scalar e(M_E); constexpr scalar e(M_E);
const scalar pi(M_PI); constexpr scalar pi(M_PI);
const scalar twoPi(2*pi); constexpr scalar twoPi(2*M_PI);
const scalar piByTwo(0.5*pi); constexpr scalar piByTwo(0.5*M_PI);
//- Euler's constant //- Euler's constant
const scalar Eu(0.57721566490153286060651209); constexpr scalar Eu(0.57721566490153286060651209);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -54,6 +54,7 @@ SourceFiles
#include "profilingTrigger.H" #include "profilingTrigger.H"
#include "HashPtrTable.H" #include "HashPtrTable.H"
#include "Tuple2.H"
#include "LIFOStack.H" #include "LIFOStack.H"
#include "Map.H" #include "Map.H"
#include "Time.H" #include "Time.H"

View File

@ -42,29 +42,43 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Conversion from degrees to radians //- Conversion from degrees to radians
inline scalar degToRad(const scalar deg) inline constexpr scalar degToRad(const scalar deg) noexcept
{ {
return (deg*constant::mathematical::pi/180.0); return (deg*M_PI/180.0);
} }
//- Conversion from radians to degrees //- Conversion from radians to degrees
inline scalar radToDeg(const scalar rad) inline constexpr scalar radToDeg(const scalar rad) noexcept
{ {
return (rad*180.0/constant::mathematical::pi); return (rad*180.0/M_PI);
} }
//- Conversion from atm to Pa //- Conversion from atm to Pa
inline scalar atmToPa(const scalar atm) inline constexpr scalar atmToPa(const scalar atm) noexcept
{ {
return (atm*101325.0); return (atm*101325.0);
} }
//- Conversion from atm to Pa //- Conversion from atm to Pa
inline scalar paToAtm(const scalar pa) inline constexpr scalar paToAtm(const scalar pa) noexcept
{ {
return (pa/101325.0); return (pa/101325.0);
} }
//- User literal for degrees to radians conversion (integers)
inline constexpr scalar operator "" _deg(unsigned long long int deg) noexcept
{
return (deg*M_PI/180.0);
}
//- User literal for degrees to radians conversion (floats)
inline constexpr scalar operator "" _deg(long double deg) noexcept
{
return (deg*M_PI/180.0);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -123,10 +123,10 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
const scalar lookupValue const scalar lookupValue
) const ) const
{ {
label n = data.size(); const label n = data.size();
scalar minLimit = data.first().first(); const scalar minLimit = data.first().first();
scalar maxLimit = data.last().first(); const scalar maxLimit = data.last().first();
if (lookupValue < minLimit) if (lookupValue < minLimit)
{ {
@ -147,7 +147,9 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
<< "bound (" << minLimit << ")" << nl << "bound (" << minLimit << ")" << nl
<< " Continuing with the first entry" << " Continuing with the first entry"
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
return data.first().second();
break;
} }
case interpolation2DTable::CLAMP: case interpolation2DTable::CLAMP:
{ {
@ -175,7 +177,9 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
<< "bound (" << maxLimit << ")" << nl << "bound (" << maxLimit << ")" << nl
<< " Continuing with the last entry" << " Continuing with the last entry"
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
return data.last().second();
break;
} }
case interpolation2DTable::CLAMP: case interpolation2DTable::CLAMP:
{ {
@ -251,16 +255,19 @@ Foam::label Foam::interpolation2DTable<Type>::Xi
WarningInFunction WarningInFunction
<< "value (" << valueX << ") out of bounds" << "value (" << valueX << ") out of bounds"
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
return limitI;
break;
} }
case interpolation2DTable::CLAMP: case interpolation2DTable::CLAMP:
{ {
return limitI; return limitI;
break;
} }
default: default:
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Un-handled enumeration " << boundsHandling_ << "Unhandled enumeration " << boundsHandling_
<< abort(FatalError); << abort(FatalError);
} }
} }
@ -299,7 +306,7 @@ Type Foam::interpolation2DTable<Type>::operator()
) const ) const
{ {
// Considers all of the list in Y being equal // Considers all of the list in Y being equal
label nX = this->size(); const label nX = this->size();
const table& t = *this; const table& t = *this;
@ -320,8 +327,8 @@ Type Foam::interpolation2DTable<Type>::operator()
// have 2-D data, interpolate // have 2-D data, interpolate
// find low and high indices in the X range that bound valueX // find low and high indices in the X range that bound valueX
label x0i = Xi(lessOp<scalar>(), valueX, false); const label x0i = Xi(lessOp<scalar>(), valueX, false);
label x1i = Xi(greaterOp<scalar>(), valueX, true); const label x1i = Xi(greaterOp<scalar>(), valueX, true);
if (x0i == x1i) if (x0i == x1i)
{ {
@ -333,8 +340,8 @@ Type Foam::interpolation2DTable<Type>::operator()
Type y1(interpolateValue(t[x1i].second(), valueY)); Type y1(interpolateValue(t[x1i].second(), valueY));
// gradient in X // gradient in X
scalar x0 = t[x0i].first(); const scalar x0 = t[x0i].first();
scalar x1 = t[x1i].first(); const scalar x1 = t[x1i].first();
Type mX = (y1 - y0)/(x1 - x0); Type mX = (y1 - y0)/(x1 - x0);
// interpolate // interpolate
@ -420,7 +427,7 @@ Foam::interpolation2DTable<Type>::outOfBounds
template<class Type> template<class Type>
void Foam::interpolation2DTable<Type>::checkOrder() const void Foam::interpolation2DTable<Type>::checkOrder() const
{ {
label n = this->size(); const label n = this->size();
const table& t = *this; const table& t = *this;
scalar prevValue = t[0].first(); scalar prevValue = t[0].first();
@ -445,10 +452,8 @@ void Foam::interpolation2DTable<Type>::checkOrder() const
template<class Type> template<class Type>
void Foam::interpolation2DTable<Type>::write(Ostream& os) const void Foam::interpolation2DTable<Type>::write(Ostream& os) const
{ {
os.writeKeyword("file") os.writeEntry("file", fileName_);
<< fileName_ << token::END_STATEMENT << nl; os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
os.writeKeyword("outOfBounds")
<< boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
os << *this; os << *this;
} }

View File

@ -66,7 +66,7 @@ public:
CLAMP //!< Clamp value to the start/end value CLAMP //!< Clamp value to the start/end value
}; };
//- Cconvenience typedef //- Convenience typedef
typedef List<Tuple2<scalar, List<Tuple2<scalar, Type>>>> table; typedef List<Tuple2<scalar, List<Tuple2<scalar, Type>>>> table;
@ -156,7 +156,7 @@ public:
const List<Tuple2<scalar, Type>>& operator[](const label) const; const List<Tuple2<scalar, Type>>& operator[](const label) const;
//- Return an interpolated value //- Return an interpolated value
Type operator()(const scalar, const scalar) const; Type operator()(const scalar valueX, const scalar valueY) const;
}; };

View File

@ -205,8 +205,8 @@ Foam::interpolationTable<Type>::outOfBounds
template<class Type> template<class Type>
void Foam::interpolationTable<Type>::check() const void Foam::interpolationTable<Type>::check() const
{ {
label n = this->size(); const label n = this->size();
scalar prevValue = List<Tuple2<scalar, Type>>::operator[](0).first(); scalar prevValue = this->first().first();
for (label i=1; i<n; ++i) for (label i=1; i<n; ++i)
{ {
@ -229,10 +229,8 @@ void Foam::interpolationTable<Type>::check() const
template<class Type> template<class Type>
void Foam::interpolationTable<Type>::write(Ostream& os) const void Foam::interpolationTable<Type>::write(Ostream& os) const
{ {
os.writeKeyword("file") os.writeEntry("file", fileName_);
<< fileName_ << token::END_STATEMENT << nl; os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
os.writeKeyword("outOfBounds")
<< boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
if (reader_.valid()) if (reader_.valid())
{ {
reader_->write(os); reader_->write(os);
@ -251,8 +249,8 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
return 0; return 0;
} }
scalar minLimit = List<Tuple2<scalar, Type>>::operator[](0).first(); const scalar minLimit = this->first().first();
scalar maxLimit = List<Tuple2<scalar, Type>>::operator[](n-1).first(); const scalar maxLimit = this->last().first();
scalar lookupValue = value; scalar lookupValue = value;
if (lookupValue < minLimit) if (lookupValue < minLimit)
@ -272,7 +270,9 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
<< "value (" << lookupValue << ") underflow" << nl << "value (" << lookupValue << ") underflow" << nl
<< " Zero rate of change." << " Zero rate of change."
<< endl; << endl;
// fall-through to 'CLAMP' // behaviour as per 'CLAMP'
return 0;
break;
} }
case interpolationTable::CLAMP: case interpolationTable::CLAMP:
{ {
@ -305,7 +305,9 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
<< "value (" << lookupValue << ") overflow" << nl << "value (" << lookupValue << ") overflow" << nl
<< " Zero rate of change." << " Zero rate of change."
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
return 0;
break;
} }
case interpolationTable::CLAMP: case interpolationTable::CLAMP:
{ {
@ -346,7 +348,7 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
} }
else if (hi == 0) else if (hi == 0)
{ {
// this treatment should should only occur under these conditions: // this treatment should only occur under these conditions:
// -> the 'REPEAT' treatment // -> the 'REPEAT' treatment
// -> (0 <= value <= minLimit) // -> (0 <= value <= minLimit)
// -> minLimit > 0 // -> minLimit > 0
@ -414,7 +416,9 @@ Foam::interpolationTable<Type>::operator[](const label i) const
<< "index (" << ii << ") underflow" << nl << "index (" << ii << ") underflow" << nl
<< " Continuing with the first entry" << " Continuing with the first entry"
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
ii = 0;
break;
} }
case interpolationTable::CLAMP: case interpolationTable::CLAMP:
{ {
@ -448,7 +452,9 @@ Foam::interpolationTable<Type>::operator[](const label i) const
<< "index (" << ii << ") overflow" << nl << "index (" << ii << ") overflow" << nl
<< " Continuing with the last entry" << " Continuing with the last entry"
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
ii = n - 1;
break;
} }
case interpolationTable::CLAMP: case interpolationTable::CLAMP:
{ {
@ -477,11 +483,11 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
if (n <= 1) if (n <= 1)
{ {
return List<Tuple2<scalar, Type>>::operator[](0).second(); return this->first().second();
} }
scalar minLimit = List<Tuple2<scalar, Type>>::operator[](0).first(); const scalar minLimit = this->first().first();
scalar maxLimit = List<Tuple2<scalar, Type>>::operator[](n-1).first(); const scalar maxLimit = this->last().first();
scalar lookupValue = value; scalar lookupValue = value;
if (lookupValue < minLimit) if (lookupValue < minLimit)
@ -501,17 +507,19 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
<< "value (" << lookupValue << ") underflow" << nl << "value (" << lookupValue << ") underflow" << nl
<< " Continuing with the first entry" << " Continuing with the first entry"
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
return this->first().second();
break;
} }
case interpolationTable::CLAMP: case interpolationTable::CLAMP:
{ {
return List<Tuple2<scalar, Type>>::operator[](0).second(); return this->first().second();
break; break;
} }
case interpolationTable::REPEAT: case interpolationTable::REPEAT:
{ {
// adjust lookupValue to >= minLimit // adjust lookupValue to >= minLimit
scalar span = maxLimit-minLimit; const scalar span = maxLimit-minLimit;
lookupValue = fmod(lookupValue-minLimit, span) + minLimit; lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
break; break;
} }
@ -534,17 +542,19 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
<< "value (" << lookupValue << ") overflow" << nl << "value (" << lookupValue << ") overflow" << nl
<< " Continuing with the last entry" << " Continuing with the last entry"
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
return this->last().second();
break;
} }
case interpolationTable::CLAMP: case interpolationTable::CLAMP:
{ {
return List<Tuple2<scalar, Type>>::operator[](n-1).second(); return this->last().second();
break; break;
} }
case interpolationTable::REPEAT: case interpolationTable::REPEAT:
{ {
// adjust lookupValue <= maxLimit // adjust lookupValue <= maxLimit
scalar span = maxLimit-minLimit; const scalar span = maxLimit-minLimit;
lookupValue = fmod(lookupValue-minLimit, span) + minLimit; lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
break; break;
} }
@ -575,7 +585,7 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
} }
else if (hi == 0) else if (hi == 0)
{ {
// this treatment should should only occur under these conditions: // this treatment should only occur under these conditions:
// -> the 'REPEAT' treatment // -> the 'REPEAT' treatment
// -> (0 <= value <= minLimit) // -> (0 <= value <= minLimit)
// -> minLimit > 0 // -> minLimit > 0

View File

@ -3,7 +3,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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,16 +29,18 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class PointList>
Foam::label Foam::mergePoints Foam::label Foam::mergePoints
( (
const UList<Type>& points, const PointList& points,
const scalar mergeTol, const scalar mergeTol,
const bool verbose, const bool verbose,
labelList& pointMap, labelList& pointMap,
const Type& origin typename PointList::const_reference origin
) )
{ {
typedef typename PointList::value_type point_type;
// Create a old to new point mapping array // Create a old to new point mapping array
pointMap.setSize(points.size()); pointMap.setSize(points.size());
pointMap = -1; pointMap = -1;
@ -49,10 +51,10 @@ Foam::label Foam::mergePoints
} }
// Explicitly convert to Field to support various list types // Explicitly convert to Field to support various list types
tmp<Field<Type>> tPoints(new Field<Type>(points)); tmp<Field<point_type>> tPoints(new Field<point_type>(points));
Type compareOrigin = origin; point_type compareOrigin = origin;
if (origin == Type::max) if (origin == point_type::max)
{ {
compareOrigin = sum(tPoints())/points.size(); compareOrigin = sum(tPoints())/points.size();
} }
@ -69,7 +71,7 @@ Foam::label Foam::mergePoints
const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol)); const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol));
// Sort points by magSqr // Sort points by magSqr
const Field<Type> d(tPoints - compareOrigin); const Field<point_type> d(tPoints - compareOrigin);
List<scalar> magSqrD(d.size()); List<scalar> magSqrD(d.size());
forAll(d, pointi) forAll(d, pointi)
@ -77,15 +79,16 @@ Foam::label Foam::mergePoints
magSqrD[pointi] = magSqr(d[pointi]); magSqrD[pointi] = magSqr(d[pointi]);
} }
labelList order; labelList order;
sortedOrder(magSqrD, order); Foam::sortedOrder(magSqrD, order);
Field<scalar> sortedTol(points.size()); Field<scalar> sortedTol(points.size());
forAll(order, sortI) forAll(order, sortI)
{ {
label pointi = order[sortI]; const label pointi = order[sortI];
// Convert to scalar precision // Convert to scalar precision
// NOTE: not yet using point_type template parameter
const point pt const point pt
( (
scalar(d[pointi].x()), scalar(d[pointi].x()),
@ -104,9 +107,11 @@ Foam::label Foam::mergePoints
for (label sortI = 1; sortI < order.size(); sortI++) for (label sortI = 1; sortI < order.size(); sortI++)
{ {
// Get original point index // Get original point index
label pointi = order[sortI]; const label pointi = order[sortI];
const scalar mag2 = magSqrD[order[sortI]]; const scalar mag2 = magSqrD[order[sortI]];
// Convert to scalar precision // Convert to scalar precision
// NOTE: not yet using point_type template parameter
const point pt const point pt
( (
scalar(points[pointi].x()), scalar(points[pointi].x()),
@ -126,7 +131,10 @@ Foam::label Foam::mergePoints
prevSortI-- prevSortI--
) )
{ {
label prevPointi = order[prevSortI]; const label prevPointi = order[prevSortI];
// Convert to scalar precision
// NOTE: not yet using point_type template parameter
const point prevPt const point prevPt
( (
scalar(points[prevPointi].x()), scalar(points[prevPointi].x()),
@ -169,18 +177,18 @@ Foam::label Foam::mergePoints
} }
template<class Type> template<class PointList>
bool Foam::mergePoints bool Foam::mergePoints
( (
const UList<Type>& points, const PointList& points,
const scalar mergeTol, const scalar mergeTol,
const bool verbose, const bool verbose,
labelList& pointMap, labelList& pointMap,
List<Type>& newPoints, List<typename PointList::value_type>& newPoints,
const Type& origin typename PointList::const_reference origin
) )
{ {
label nUnique = mergePoints const label nUnique = mergePoints
( (
points, points,
mergeTol, mergeTol,

View File

@ -3,7 +3,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-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,27 +46,28 @@ namespace Foam
//- Sorts and merges points. All points closer than/equal mergeTol get merged. //- Sorts and merges points. All points closer than/equal mergeTol get merged.
// Returns the number of unique points and a map from old to new. // Returns the number of unique points and a map from old to new.
template<class Type> template<class PointList>
label mergePoints label mergePoints
( (
const UList<Type>& points, const PointList& points,
const scalar mergeTol, const scalar mergeTol,
const bool verbose, const bool verbose,
labelList& pointMap, labelList& pointMap,
const Type& origin = Type::zero typename PointList::const_reference origin = PointList::value_type::zero
); );
//- Sorts and merges points. Determines new points. Returns true if anything //- Sorts and merges points. Determines new points. Returns true if anything
// merged (though newPoints still sorted even if not merged). // merged (though newPoints still sorted even if not merged).
template<class Type> template<class PointList>
bool mergePoints bool mergePoints
( (
const UList<Type>& points, const PointList& points,
const scalar mergeTol, const scalar mergeTol,
const bool verbose, const bool verbose,
labelList& pointMap, labelList& pointMap,
List<Type>& newPoints, List<typename PointList::value_type>& newPoints,
const Type& origin = Type::zero typename PointList::const_reference origin = PointList::value_type::zero
); );
} // End namespace Foam } // End namespace Foam

View File

@ -0,0 +1,238 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "Enum.H"
#include "dictionary.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class EnumType>
Foam::label Foam::Enum<EnumType>::getIndex(const word& enumName) const
{
const label n = size();
for (label idx=0; idx < n; ++idx)
{
if (names_[idx] == enumName)
{
return idx;
}
}
return -1;
}
template<class EnumType>
Foam::label Foam::Enum<EnumType>::getIndex(const EnumType e) const
{
const int val = int(e);
const label n = size();
for (label idx=0; idx < n; ++idx)
{
if (values_[idx] == val)
{
return idx;
}
}
return -1;
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::getEnum(const word& enumName) const
{
const label idx = getIndex(enumName);
if (idx < 0)
{
FatalErrorInFunction
<< enumName << " is not in enumeration: "
<< names_ << exit(FatalError);
}
return EnumType(values_[idx]);
}
template<class EnumType>
const Foam::word& Foam::Enum<EnumType>::getName(const EnumType e) const
{
const label idx = getIndex(e);
if (idx < 0)
{
return word::null;
}
else
{
return names_[idx];
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class EnumType>
Foam::Enum<EnumType>::Enum
(
std::initializer_list<std::pair<EnumType, word>> lst
)
:
names_(lst.size()),
values_(lst.size())
{
int idx = 0;
for (const auto& pair : lst)
{
names_[idx] = pair.second;
values_[idx] = int(pair.first);
++idx;
}
}
template<class EnumType>
Foam::Enum<EnumType>::Enum
(
const EnumType start,
std::initializer_list<word> lst
)
:
names_(lst.size()),
values_(lst.size())
{
int val = int(start);
int idx = 0;
for (const auto& key : lst)
{
names_[idx] = key;
values_[idx] = val;
++val;
++idx;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType>
Foam::List<Foam::word> Foam::Enum<EnumType>::sortedToc() const
{
wordList lst(names_);
Foam::sort(lst);
return lst;
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::read(Istream& is) const
{
const word enumName(is);
const label idx = getIndex(enumName);
if (idx < 0)
{
FatalIOErrorInFunction(is)
<< enumName << " is not in enumeration: "
<< names_ << nl
<< exit(FatalIOError);
}
return EnumType(values_[idx]);
}
template<class EnumType>
void Foam::Enum<EnumType>::write(const EnumType e, Ostream& os) const
{
const label idx = getIndex(e);
if (idx >= 0)
{
os << names_[idx];
}
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::lookup
(
const word& key,
const dictionary& dict
) const
{
const word enumName(dict.lookup(key));
const label idx = getIndex(enumName);
if (idx < 0)
{
FatalIOErrorInFunction(dict)
<< enumName << " is not in enumeration: "
<< names_ << nl
<< exit(FatalIOError);
}
return EnumType(values_[idx]);
}
template<class EnumType>
EnumType Foam::Enum<EnumType>::lookupOrDefault
(
const word& key,
const dictionary& dict,
const EnumType deflt
) const
{
if (dict.found(key))
{
return lookup(key, dict);
}
else
{
return deflt;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class EnumType>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const Enum<EnumType>& wrapped
)
{
return wrapped.names().writeList(os, 10);
}
// ************************************************************************* //

View File

@ -0,0 +1,220 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::Enum
Description
A Enum is a wrapper around a list of names/values that represent
particular enumeration values.
SourceFiles
Enum.C
\*---------------------------------------------------------------------------*/
#ifndef Enum_H
#define Enum_H
#include "wordList.H"
#include <initializer_list>
#include <utility>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class dictionary;
template<class EnumType> class Enum;
template<class EnumType>
Ostream& operator<<(Ostream& os, const Enum<EnumType>& wrapped);
/*---------------------------------------------------------------------------*\
Class Enum Declaration
\*---------------------------------------------------------------------------*/
template<class EnumType>
class Enum
{
// Private Member Data
//- The names for the enum
List<word> names_;
//- The values for the enum
List<int> values_;
// Private Member Functions
//- The index for the given name. -1 if not found.
label getIndex(const word& enumName) const;
//- The index for the given enumeration. -1 if not found.
label getIndex(const EnumType e) const;
//- Lookup enumeration corresponding to the given name.
// FatalError if not found.
EnumType getEnum(const word& enumName) const;
//- Lookup name corresponding to the given enumeration.
// Return empty word if not found.
const word& getName(const EnumType e) const;
//- Disallow default bitwise copy construct
Enum(const Enum&) = delete;
//- Disallow default bitwise assignment
void operator=(const Enum&) = delete;
public:
//- The type of enumeration wrapped by Enum
typedef EnumType value_type;
// Constructors
//- Construct from a values/names list.
// Duplicate values are permitted (eg, for aliases).
// Duplicate names are permitted, but won't make much sense.
explicit Enum(std::initializer_list<std::pair<EnumType, word>> lst);
//- Construct from a list of names with values incremented from the
// specified start value.
Enum(const EnumType start, std::initializer_list<word> lst);
// Member Functions
// Access
//- The number of lookup names for the enumeration
inline label size() const;
//- The list of enum names, in construction order
inline const List<word>& names() const;
//- The list of enum names, in construction order
inline const List<word>& toc() const;
//- The sorted list of enum names
List<word> sortedToc() const;
//- The list of enum values, in construction order
inline const List<int>& values() const;
// Query
//- Test if there is an enumeration corresponding to the given name.
inline bool hasEnum(const word& enumName) const;
//- Test if there is a name corresponding to the given enumeration.
inline bool hasName(const EnumType e) const;
// Lookup
//- Lookup the key in the dictionary and return the corresponding
// enumeration element based on its name.
// Fatal if anything is incorrect.
EnumType lookup
(
const word& key,
const dictionary& dict
) const;
//- Find the key in the dictionary and return the corresponding
// enumeration element based on its name.
// Return the default value if the key was not found in the dictionary.
// Fatal if the enumerated name was incorrect.
EnumType lookupOrDefault
(
const word& key,
const dictionary& dict,
const EnumType deflt
) const;
// IO
//- Read a word from Istream and return the corresponding enumeration
EnumType read(Istream& is) const;
//- Write the name representation of the enumeration to an Ostream
// A noop if the enumeration wasn't found.
void write(const EnumType e, Ostream& os) const;
//- Write the names as a list to an Ostream
inline Ostream& writeList
(
Ostream& os,
const label shortListLen=0
) const;
// Member Operators
//- Return the enumeration corresponding to the given name
// Fatal if the name cannot be found.
inline const EnumType operator[](const word& name) const;
//- Return the first name corresponding to the given enumeration.
// Returns an empty word on failure.
inline const word& operator[](const EnumType e) const;
// IOstream operators
//- Write names to Ostream, as per writeList() with shortListLen=10
friend Ostream& operator<< <EnumType>
(
Ostream& os,
const Enum<EnumType>& wrapped
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "EnumI.H"
#ifdef NoRepository
#include "Enum.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,103 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType>
inline Foam::label Foam::Enum<EnumType>::size() const
{
return names_.size();
}
template<class EnumType>
inline const Foam::wordList& Foam::Enum<EnumType>::names() const
{
return names_;
}
template<class EnumType>
inline const Foam::wordList& Foam::Enum<EnumType>::toc() const
{
return names_;
}
template<class EnumType>
inline const Foam::List<int>& Foam::Enum<EnumType>::values() const
{
return values_;
}
template<class EnumType>
inline bool Foam::Enum<EnumType>::hasEnum(const word& enumName) const
{
return getIndex(enumName) >= 0;
}
template<class EnumType>
inline bool Foam::Enum<EnumType>::hasName(const EnumType e) const
{
return getIndex(e) >= 0;
}
template<class EnumType>
inline Foam::Ostream& Foam::Enum<EnumType>::writeList
(
Ostream& os,
const label shortListLen
) const
{
return names_.writeList(os, shortListLen);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class EnumType>
inline const EnumType Foam::Enum<EnumType>::operator[]
(
const word& name
) const
{
return getEnum(name);
}
template<class EnumType>
inline const Foam::word& Foam::Enum<EnumType>::operator[]
(
const EnumType e
) const
{
return getName(e);
}
// ************************************************************************* //

View File

@ -25,14 +25,48 @@ License
#include "NamedEnum.H" #include "NamedEnum.H"
#include "dictionary.H" #include "dictionary.H"
#include "stdFoam.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Enum, int nEnum> template<class EnumType, int nEnum>
template<class StringType> Foam::NamedEnum<EnumType, nEnum>::NamedEnum()
Foam::List<StringType> Foam::NamedEnum<Enum, nEnum>::getNamesList() :
lookup_(2*nEnum)
{ {
List<StringType> lst(nEnum); for (int enumi=0; enumi < nEnum; ++enumi)
{
if (names[enumi] && names[enumi][0])
{
lookup_.insert(names[enumi], enumi);
}
else
{
// Bad name - generate error message
List<string> goodNames(enumi);
for (int i = 0; i < enumi; ++i)
{
goodNames[i] = names[i];
}
FatalErrorInFunction
<< "Illegal enumeration name at position " << enumi << nl
<< "after entries " << goodNames << nl
<< "Possibly your NamedEnum<EnumType, nEnum>::names array"
<< " is not of size " << nEnum << endl
<< abort(FatalError);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType, int nEnum>
Foam::wordList Foam::NamedEnum<EnumType, nEnum>::words() const
{
List<word> lst(nEnum);
label count = 0; label count = 0;
for (int enumi=0; enumi < nEnum; ++enumi) for (int enumi=0; enumi < nEnum; ++enumi)
@ -48,93 +82,74 @@ Foam::List<StringType> Foam::NamedEnum<Enum, nEnum>::getNamesList()
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class EnumType, int nEnum>
Foam::List<int> Foam::NamedEnum<EnumType, nEnum>::values() const
template<class Enum, int nEnum>
Foam::NamedEnum<Enum, nEnum>::NamedEnum()
:
table_type(2*nEnum)
{ {
List<int> lst(nEnum);
label count = 0;
for (int enumi=0; enumi < nEnum; ++enumi) for (int enumi=0; enumi < nEnum; ++enumi)
{ {
if (names[enumi] && names[enumi][0]) if (names[enumi] && names[enumi][0])
{ {
insert(names[enumi], enumi); auto iter = lookup_.cfind(names[enumi]);
}
else
{
// Bad name - generate error message
stringList goodNames(enumi);
for (int i = 0; i < enumi; ++i) if (iter.found())
{ {
goodNames[i] = names[i]; lst[count++] = iter.object();
} }
FatalErrorInFunction
<< "Illegal enumeration name at position " << enumi << nl
<< "after entries " << goodNames << nl
<< "Possibly your NamedEnum<Enum, nEnum>::names array"
<< " is not of size " << nEnum << endl
<< abort(FatalError);
} }
} }
lst.setSize(count);
return lst;
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class EnumType, int nEnum>
bool Foam::NamedEnum<EnumType, nEnum>::hasName(const EnumType e) const
template<class Enum, int nEnum>
Enum Foam::NamedEnum<Enum, nEnum>::read(Istream& is) const
{ {
const word enumName(is); const int enumValue(e);
table_type::const_iterator iter = find(enumName);
if (!iter.found()) forAllConstIters(lookup_, iter)
{ {
FatalIOErrorInFunction(is) if (iter.object() == enumValue)
<< enumName << " is not in enumeration: " {
<< sortedToc() << exit(FatalIOError); return true;
}
} }
return false;
return Enum(iter.object());
} }
template<class Enum, int nEnum> template<class EnumType, int nEnum>
void Foam::NamedEnum<Enum, nEnum>::write(const Enum e, Ostream& os) const EnumType Foam::NamedEnum<EnumType, nEnum>::lookup
{
os << names[int(e)];
}
template<class Enum, int nEnum>
Enum Foam::NamedEnum<Enum, nEnum>::lookup
( (
const word& key, const word& key,
const dictionary& dict const dictionary& dict
) const ) const
{ {
const word enumName(dict.lookup(key)); const word enumName(dict.lookup(key));
table_type::const_iterator iter = find(enumName); auto iter = lookup_.cfind(enumName);
if (!iter.found()) if (!iter.found())
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< enumName << " is not in enumeration: " << enumName << " is not in enumeration: "
<< sortedToc() << exit(FatalIOError); << lookup_.sortedToc() << nl
<< exit(FatalIOError);
} }
return Enum(iter.object()); return EnumType(iter.object());
} }
template<class Enum, int nEnum> template<class EnumType, int nEnum>
Enum Foam::NamedEnum<Enum, nEnum>::lookupOrDefault EnumType Foam::NamedEnum<EnumType, nEnum>::lookupOrDefault
( (
const word& key, const word& key,
const dictionary& dict, const dictionary& dict,
const enum_type deflt const EnumType deflt
) const ) const
{ {
if (dict.found(key)) if (dict.found(key))
@ -148,36 +163,49 @@ Enum Foam::NamedEnum<Enum, nEnum>::lookupOrDefault
} }
template<class Enum, int nEnum> template<class EnumType, int nEnum>
Foam::List<Enum> Foam::NamedEnum<Enum, nEnum>::enums() EnumType Foam::NamedEnum<EnumType, nEnum>::read(Istream& is) const
{ {
List<Enum> lst(nEnum); const word enumName(is);
auto iter = lookup_.cfind(enumName);
label count = 0; if (!iter.found())
for (int enumi = 0; enumi < nEnum; ++enumi)
{ {
if (names[enumi] && names[enumi][0]) FatalIOErrorInFunction(is)
{ << enumName << " is not in enumeration: "
lst[count++] = Enum(enumi); << lookup_.sortedToc() << nl
} << exit(FatalIOError);
} }
lst.setSize(count); return EnumType(iter.object());
return lst;
} }
template<class Enum, int nEnum> template<class EnumType, int nEnum>
Foam::stringList Foam::NamedEnum<Enum, nEnum>::strings() void Foam::NamedEnum<EnumType, nEnum>::write
(
const EnumType e,
Ostream& os
) const
{ {
return getNamesList<string>(); const int idx = int(e);
if (idx >= 0 && idx < nEnum)
{
os << names[idx];
}
} }
template<class Enum, int nEnum> // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::wordList Foam::NamedEnum<Enum, nEnum>::words()
template<class EnumType, int nEnum>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const NamedEnum<EnumType, nEnum>& wrapped
)
{ {
return getNamesList<word>(); return wrapped.lookup_.writeKeys(os, 10);
} }

View File

@ -25,9 +25,8 @@ Class
Foam::NamedEnum Foam::NamedEnum
Description Description
A NamedEnum is a wrapper around a static list of names that represent A NamedEnum is a wrapper around a list of names that represent
a particular enumeration. Internally it uses a HashTable for quicker particular enumeration values.
lookups.
SourceFiles SourceFiles
NamedEnum.C NamedEnum.C
@ -38,7 +37,6 @@ SourceFiles
#define NamedEnum_H #define NamedEnum_H
#include "HashTable.H" #include "HashTable.H"
#include "stringList.H"
#include "wordList.H" #include "wordList.H"
#include <type_traits> #include <type_traits>
@ -46,33 +44,32 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations
class dictionary; class dictionary;
template<class EnumType, int nEnum> class NamedEnum;
template<class EnumType, int nEnum>
Ostream& operator<<(Ostream& os, const NamedEnum<EnumType, nEnum>& wrapped);
// Forward declaration
template<class Enum, int> class NamedEnum;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class NamedEnum Declaration Class NamedEnum Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Enum, int nEnum> template<class EnumType, int nEnum>
class NamedEnum class NamedEnum
:
public HashTable<int>
{ {
//- The nEnum must be positive (non-zero) //- The nEnum must be positive (non-zero)
static_assert(nEnum > 0, "nEnum must be positive (non-zero)"); static_assert(nEnum > 0, "nEnum must be positive (non-zero)");
//- The type of HashTable used for the lookup. // Private Member Data
typedef HashTable<int> table_type;
//- The values for the enum
HashTable<int> lookup_;
// Private Member Functions // Private Member Functions
//- The names as a list of strings
template<class StringType>
static List<StringType> getNamesList();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
NamedEnum(const NamedEnum&) = delete; NamedEnum(const NamedEnum&) = delete;
@ -83,12 +80,12 @@ class NamedEnum
public: public:
//- The type of enumeration wrapped by NamedEnum //- The type of enumeration wrapped by NamedEnum
typedef Enum enum_type; typedef EnumType value_type;
// Static data members // Static data members
//- The set of names corresponding to the enumeration Enum //- The set of names corresponding to the enumeration EnumType
static const char* names[nEnum]; static const char* names[nEnum];
@ -100,17 +97,42 @@ public:
// Member Functions // Member Functions
//- Read a word from Istream and return the corresponding // Access
// enumeration element
enum_type read(Istream& is) const;
//- Write the name representation of the enumeration to an Ostream //- The number of lookup names for the enumeration
void write(const enum_type e, Ostream& os) const; inline label size() const;
//- The list of enum names
inline wordList toc() const;
//- The sorted list of enum names
inline wordList sortedToc() const;
//- The list of enum names, in construction order
wordList words() const;
//- The list of enum values, in construction order
List<int> values() const;
// Query
//- Test if there is an enumeration corresponding to the given name.
inline bool found(const word& enumName) const;
//- Test if there is an enumeration corresponding to the given name.
inline bool hasEnum(const word& enumName) const;
//- Test if there is a name corresponding to the given enumeration.
bool hasName(const EnumType e) const;
// Lookup
//- Lookup the key in the dictionary and return the corresponding //- Lookup the key in the dictionary and return the corresponding
// enumeration element based on its name. // enumeration element based on its name.
// Fatal if anything is incorrect. // Fatal if anything is incorrect.
enum_type lookup EnumType lookup
( (
const word& key, const word& key,
const dictionary& dict const dictionary& dict
@ -120,42 +142,42 @@ public:
// enumeration element based on its name. // enumeration element based on its name.
// Return the default value if the key was not found in the dictionary. // Return the default value if the key was not found in the dictionary.
// Fatal if enumerated name was incorrect. // Fatal if enumerated name was incorrect.
enum_type lookupOrDefault EnumType lookupOrDefault
( (
const word& key, const word& key,
const dictionary& dict, const dictionary& dict,
const enum_type deflt const EnumType deflt
) const; ) const;
//- List of enumerations
static List<enum_type> enums();
//- The set of names as a list of strings // IO
static stringList strings();
//- The set of names as a list of words //- Read a word from Istream and return the corresponding enumeration
static wordList words(); EnumType read(Istream& is) const;
//- Write the name representation of the enumeration to an Ostream
// A noop if the enumeration wasn't found.
void write(const EnumType e, Ostream& os) const;
// Member Operators // Member Operators
//- Return the enumeration element corresponding to the given name //- Return the enumeration element corresponding to the given name
inline const enum_type operator[](const char* name) const inline const EnumType operator[](const word& name) const;
{
return enum_type(table_type::operator[](name));
}
//- Return the enumeration element corresponding to the given name
inline const enum_type operator[](const word& name) const
{
return enum_type(table_type::operator[](name));
}
//- Return the name of the given enumeration element //- Return the name of the given enumeration element
inline const char* operator[](const enum_type e) const inline const char* operator[](const EnumType e) const;
{
return names[int(e)];
} // IOstream operators
//- Write names to Ostream, as per writeKeys() with shortListLen=10
friend Ostream& operator<< <EnumType, nEnum>
(
Ostream& os,
const NamedEnum<EnumType, nEnum>& wrapped
);
}; };
@ -165,6 +187,8 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "NamedEnumI.H"
#ifdef NoRepository #ifdef NoRepository
#include "NamedEnum.C" #include "NamedEnum.C"
#endif #endif

View File

@ -0,0 +1,91 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class EnumType, int nEnum>
inline Foam::label Foam::NamedEnum<EnumType, nEnum>::size() const
{
return lookup_.size();
}
template<class EnumType, int nEnum>
inline Foam::wordList Foam::NamedEnum<EnumType, nEnum>::toc() const
{
return lookup_.toc();
}
template<class EnumType, int nEnum>
inline Foam::wordList Foam::NamedEnum<EnumType, nEnum>::sortedToc() const
{
return lookup_.sortedToc();
}
template<class EnumType, int nEnum>
inline bool Foam::NamedEnum<EnumType, nEnum>::found
(
const word& enumName
) const
{
return lookup_.found(enumName);
}
template<class EnumType, int nEnum>
inline bool Foam::NamedEnum<EnumType, nEnum>::hasEnum
(
const word& enumName
) const
{
return lookup_.found(enumName);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class EnumType, int nEnum>
inline const EnumType Foam::NamedEnum<EnumType, nEnum>::operator[]
(
const word& name
) const
{
return EnumType(lookup_[name]);
}
template<class EnumType, int nEnum>
inline const char* Foam::NamedEnum<EnumType, nEnum>::operator[]
(
const EnumType e
) const
{
return names[int(e)];
}
// ************************************************************************* //

View File

@ -195,7 +195,7 @@ void Foam::Function1Types::TableBase<Type>::check() const
<< nl << exit(FatalError); << nl << exit(FatalError);
} }
label n = table_.size(); const label n = table_.size();
scalar prevValue = table_[0].first(); scalar prevValue = table_[0].first();
for (label i = 1; i < n; ++i) for (label i = 1; i < n; ++i)
@ -221,7 +221,7 @@ bool Foam::Function1Types::TableBase<Type>::checkMinBounds
scalar& xDash scalar& xDash
) const ) const
{ {
if (x < table_[0].first()) if (x < table_.first().first())
{ {
switch (boundsHandling_) switch (boundsHandling_)
{ {
@ -238,19 +238,28 @@ bool Foam::Function1Types::TableBase<Type>::checkMinBounds
<< "value (" << x << ") underflow" << nl << "value (" << x << ") underflow" << nl
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
xDash = table_.first().first();
return true;
break;
} }
case CLAMP: case CLAMP:
{ {
xDash = table_[0].first(); xDash = table_.first().first();
return true; return true;
break; break;
} }
case REPEAT: case REPEAT:
{ {
// adjust x to >= minX // adjust x to >= minX
scalar span = table_.last().first() - table_[0].first(); const scalar span =
xDash = fmod(x - table_[0].first(), span) + table_[0].first(); table_.last().first() - table_.first().first();
xDash =
(
fmod(x - table_.first().first(), span)
+ table_.first().first()
);
break; break;
} }
} }
@ -288,7 +297,10 @@ bool Foam::Function1Types::TableBase<Type>::checkMaxBounds
<< "value (" << x << ") overflow" << nl << "value (" << x << ") overflow" << nl
<< endl; << endl;
// fall-through to 'CLAMP' // Behaviour as per 'CLAMP'
xDash = table_.last().first();
return true;
break;
} }
case CLAMP: case CLAMP:
{ {
@ -299,8 +311,14 @@ bool Foam::Function1Types::TableBase<Type>::checkMaxBounds
case REPEAT: case REPEAT:
{ {
// adjust x to >= minX // adjust x to >= minX
scalar span = table_.last().first() - table_[0].first(); const scalar span =
xDash = fmod(x - table_[0].first(), span) + table_[0].first(); table_.last().first() - table_.first().first();
xDash =
(
fmod(x - table_.first().first(), span)
+ table_.first().first()
);
break; break;
} }
} }
@ -335,7 +353,7 @@ Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
if (checkMinBounds(x, xDash)) if (checkMinBounds(x, xDash))
{ {
return table_[0].second(); return table_.first().second();
} }
if (checkMaxBounds(xDash, xDash)) if (checkMaxBounds(xDash, xDash))
@ -411,13 +429,11 @@ void Foam::Function1Types::TableBase<Type>::writeEntries(Ostream& os) const
{ {
if (boundsHandling_ != CLAMP) if (boundsHandling_ != CLAMP)
{ {
os.writeKeyword("outOfBounds") << boundsHandlingToWord(boundsHandling_) os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
<< token::END_STATEMENT << nl;
} }
if (interpolationScheme_ != "linear") if (interpolationScheme_ != "linear")
{ {
os.writeKeyword("interpolationScheme") << interpolationScheme_ os.writeEntry("interpolationScheme", interpolationScheme_);
<< token::END_STATEMENT << nl;
} }
} }

View File

@ -308,7 +308,7 @@ Foam::string Foam::stringOps::getVariable
} }
} }
if (value.empty()) if (!allowEmpty && value.empty())
{ {
FatalIOErrorInFunction FatalIOErrorInFunction
( (
@ -317,7 +317,8 @@ Foam::string Foam::stringOps::getVariable
<< name << exit(FatalIOError); << name << exit(FatalIOError);
} }
} }
else
if (!allowEmpty && value.empty())
{ {
FatalIOErrorInFunction FatalIOErrorInFunction
( (

View File

@ -111,7 +111,7 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
{ {
typedef compressible::turbulenceModel turbulenceModel; typedef compressible::turbulenceModel turbulenceModel;
word turbName(turbulenceModel::propertiesName); const word turbName(turbulenceModel::propertiesName);
if if
( (
@ -205,8 +205,8 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
<< " on mesh " << mesh.name() << " patch " << patch_.name() << " on mesh " << mesh.name() << " patch " << patch_.name()
<< nl << nl
<< "Please set 'kappaMethod' to one of " << "Please set 'kappaMethod' to one of "
<< KMethodTypeNames_.toc() << flatOutput(KMethodTypeNames_.sortedToc()) << nl
<< " and 'kappa' to the name of the volScalar" << "and 'kappa' to the name of the volScalar"
<< " or volSymmTensor field (if kappaMethod=lookup)" << " or volSymmTensor field (if kappaMethod=lookup)"
<< exit(FatalError); << exit(FatalError);
} }
@ -219,8 +219,8 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
FatalErrorInFunction FatalErrorInFunction
<< "Unimplemented method " << KMethodTypeNames_[method_] << nl << "Unimplemented method " << KMethodTypeNames_[method_] << nl
<< "Please set 'kappaMethod' to one of " << "Please set 'kappaMethod' to one of "
<< KMethodTypeNames_.toc() << flatOutput(KMethodTypeNames_.sortedToc()) << nl
<< " and 'kappa' to the name of the volScalar" << "and 'kappa' to the name of the volScalar"
<< " or volSymmTensor field (if kappaMethod=lookup)" << " or volSymmTensor field (if kappaMethod=lookup)"
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -11,6 +11,4 @@ writer/ccmWriter.C
writer/ccmWriterMesh.C writer/ccmWriterMesh.C
writer/ccmWriterSolution.C writer/ccmWriterSolution.C
/* misc/mergePoints1.C */
LIB = $(FOAM_LIBBIN)/libccm LIB = $(FOAM_LIBBIN)/libccm

View File

@ -111,7 +111,7 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Explicity close the file and terminate ccmio access. //- Explicity close the file and terminate ccmio access.
// Return false if it was already closed. // Return false if it was already closed.

View File

@ -1,117 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ListOps1.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class ListType>
ListType Foam::reorder
(
const labelUList& oldToNew,
const ListType& lst,
const bool prune
)
{
const label sz = lst.size();
// Create copy
ListType newLst(sz);
// Ensure consistent addressable size (eg, DynamicList)
newLst.setSize(sz);
label maxIdx = 0;
forAll(lst, elemI)
{
const label newIdx = oldToNew[elemI];
if (newIdx >= 0) // could also require newIdx < sz
{
newLst[newIdx] = lst[elemI];
if (prune && maxIdx < newIdx)
{
maxIdx = newIdx;
}
}
else if (!prune)
{
newLst[elemI] = lst[elemI];
}
}
if (prune && maxIdx < sz)
{
newLst.setSize(maxIdx);
}
return newLst;
}
template<class ListType>
void Foam::inplaceReorder
(
const labelUList& oldToNew,
ListType& lst,
const bool prune
)
{
const label sz = lst.size();
// Create copy
ListType newLst(sz);
// Ensure consistent addressable size (eg, DynamicList)
newLst.setSize(sz);
label maxIdx = 0;
forAll(lst, elemI)
{
const label newIdx = oldToNew[elemI];
if (newIdx >= 0) // could also require newIdx < sz
{
newLst[newIdx] = lst[elemI];
if (prune && maxIdx < newIdx)
{
maxIdx = newIdx;
}
}
else if (!prune)
{
newLst[elemI] = lst[elemI];
}
}
if (prune && maxIdx < sz)
{
newLst.setSize(maxIdx);
}
lst.transfer(newLst);
}
// ************************************************************************* //

View File

@ -1,177 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ListOps.H"
#include "point.H"
#include "Field.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// template<class Type, template<class> class ListType=UList>
template<class Type>
Foam::label Foam::mergePoints
(
const bool dummy,
const UIndirectList<Type>& points,
const scalar mergeTol,
const bool verbose,
labelList& pointMap,
const Type& origin
)
{
// Create a old to new point mapping array
pointMap.setSize(points.size());
pointMap = -1;
if (points.empty())
{
return 0;
}
// No normal field operations on UIndirectList.
// Use a tmp pointField instead.
tmp<Field<Type>> tPoints(new pointField(points));
Type compareOrigin = origin;
if (origin == Type::max)
{
compareOrigin = sum(tPoints())/points.size();
}
// We're comparing distance squared to origin first.
// Say if starting from two close points:
// x, y, z
// x+mergeTol, y+mergeTol, z+mergeTol
// Then the magSqr of both will be
// x^2+y^2+z^2
// x^2+y^2+z^2 + 2*mergeTol*(x+z+y) + mergeTol^2*...
// so the difference will be 2*mergeTol*(x+y+z)
const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol));
// Sort points by magSqr
const Field<Type> d(tPoints - compareOrigin);
List<scalar> magSqrD(d.size());
forAll(d, pointI)
{
magSqrD[pointI] = magSqr(d[pointI]);
}
labelList order;
sortedOrder(magSqrD, order);
Field<scalar> sortedTol(points.size());
forAll(order, sortI)
{
label pointI = order[sortI];
// Convert to scalar precision
const point pt
(
scalar(d[pointI].x()),
scalar(d[pointI].y()),
scalar(d[pointI].z())
);
sortedTol[sortI] = 2*mergeTol*(mag(pt.x())+mag(pt.y())+mag(pt.z()));
}
label newPointI = 0;
// Handle 0th point separately (is always unique)
label pointI = order[0];
pointMap[pointI] = newPointI++;
for (label sortI = 1; sortI < order.size(); sortI++)
{
// Get original point index
label pointI = order[sortI];
const scalar mag2 = magSqrD[order[sortI]];
// Convert to scalar precision
const point pt
(
scalar(points[pointI].x()),
scalar(points[pointI].y()),
scalar(points[pointI].z())
);
// Compare to previous points to find equal one.
label equalPointI = -1;
for
(
label prevSortI = sortI - 1;
prevSortI >= 0
&& (mag(magSqrD[order[prevSortI]] - mag2) <= sortedTol[sortI]);
prevSortI--
)
{
label prevPointI = order[prevSortI];
const point prevPt
(
scalar(points[prevPointI].x()),
scalar(points[prevPointI].y()),
scalar(points[prevPointI].z())
);
if (magSqr(pt - prevPt) <= mergeTolSqr)
{
// Found match.
equalPointI = prevPointI;
break;
}
}
if (equalPointI != -1)
{
// Same coordinate as equalPointI. Map to same new point.
pointMap[pointI] = pointMap[equalPointI];
if (verbose)
{
Pout<< "Foam::mergePoints : Merging points "
<< pointI << " and " << equalPointI
<< " with coordinates:" << points[pointI]
<< " and " << points[equalPointI]
<< endl;
}
}
else
{
// Differs. Store new point.
pointMap[pointI] = newPointI++;
}
}
return newPointI;
}
// ************************************************************************* //

View File

@ -22,7 +22,7 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description Description
Containers for holding STARCCM boundary information Container for holding STARCCM boundary information
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef ccmBoundaryInfo_H #ifndef ccmBoundaryInfo_H
@ -40,8 +40,11 @@ namespace Foam
namespace ccm namespace ccm
{ {
class ccmBoundaryInfo;
Ostream& operator<<(Ostream& os, const ccmBoundaryInfo& entry);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ccm::ccmBoundaryInfo Declaration Class Foam::ccm::ccmBoundaryInfo Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- Helper when reading raw boundary information //- Helper when reading raw boundary information
@ -95,6 +98,7 @@ public:
return ccmIndex != rhs.ccmIndex; return ccmIndex != rhs.ccmIndex;
} }
//- Ostream Operator //- Ostream Operator
friend Ostream& operator<<(Ostream& os, const ccmBoundaryInfo& entry) friend Ostream& operator<<(Ostream& os, const ccmBoundaryInfo& entry)
{ {

View File

@ -38,8 +38,14 @@ namespace Foam
namespace ccm namespace ccm
{ {
class interfaceEntry;
class interfaceDefinitions;
Ostream& operator<<(Ostream& os, const interfaceEntry& entry);
Ostream& operator<<(Ostream& os, const interfaceDefinitions& defs);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ccm::interfaceEntry Declaration Class Foam::ccm::interfaceEntry Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- A STARCCM interface definition is a pair of boundary ids //- A STARCCM interface definition is a pair of boundary ids
@ -57,6 +63,7 @@ public:
//- The second boundary //- The second boundary
label bnd1; label bnd1;
// Constructors // Constructors
//- Construct null //- Construct null
@ -106,6 +113,12 @@ public:
return bndId == bnd0 || bndId == bnd1; return bndId == bnd0 || bndId == bnd1;
} }
//- True if all internal ids are non-negative
bool valid() const
{
return (id >= 0 && bnd0 >= 0 && bnd1 >= 0 && bnd0 != bnd1);
}
//- Canonical name for boundary 0 //- Canonical name for boundary 0
word canonicalName0() const word canonicalName0() const
@ -161,42 +174,57 @@ class interfaceDefinitions
: :
public Map<interfaceEntry> public Map<interfaceEntry>
{ {
inline Map<interfaceEntry>& map()
{
return *this;
}
inline const Map<interfaceEntry>& map() const
{
return *this;
}
public: public:
// Constructor // Constructor
//- Null construct //- Null construct
interfaceDefinitions() interfaceDefinitions()
:
Map<interfaceEntry>()
{} {}
//- Size
//- Scan available interface entries for one matching this boundary id label size() const
bool add(interfaceEntry entry)
{ {
if return map().size();
( }
entry.id >= 0
&& entry.bnd0 >= 0 && entry.bnd1 >= 0 //- Size
&& entry.bnd0 != entry.bnd1 bool empty() const
) {
{ return map().empty();
this->set(entry.id, entry); }
return true;
} //- Clear
else void clear()
{ {
return false; map().clear();
} }
//- Add (valid) interface entry
bool add(const interfaceEntry& entry)
{
return (entry.valid() && map().set(entry.id, entry));
} }
//- Scan available interface entries for one matching this boundary id //- Scan available interface entries for one matching this boundary id
bool isInterface(label bndId) bool isInterface(label bndId)
{ {
forAllConstIter(Map<interfaceEntry>, *this, iter) forAllConstIters(map(), iter)
{ {
if (iter().inInterface(bndId)) if (iter.object().inInterface(bndId))
{ {
return true; return true;
} }
@ -210,9 +238,9 @@ public:
word interfaceName(label bndId) word interfaceName(label bndId)
{ {
word ifname; word ifname;
forAllConstIter(Map<interfaceEntry>, *this, iter) forAllConstIters(map(), iter)
{ {
ifname = iter().canonicalName(bndId); ifname = iter.object().canonicalName(bndId);
if (!ifname.empty()) if (!ifname.empty())
{ {
break; break;
@ -231,9 +259,7 @@ public:
const interfaceDefinitions& defs const interfaceDefinitions& defs
) )
{ {
os << static_cast<const Map<interfaceEntry>& >(defs) os << defs.map() << nl;
<< nl;
return os; return os;
} }

View File

@ -368,7 +368,7 @@ private:
void validateInterface(List<labelPair>&); void validateInterface(List<labelPair>&);
//- Renumber interface faces //- Renumber interface faces
void renumberInterfaces(const List<label>&); void renumberInterfaces(const labelUList& oldToNew);
//- Remove interfaces between domains (fluid/porosity; fluid/solid, etc) //- Remove interfaces between domains (fluid/porosity; fluid/solid, etc)
// reorganize baffle interfaces into [0-N/2; N/2-N] lists at the // reorganize baffle interfaces into [0-N/2; N/2-N] lists at the
@ -394,23 +394,27 @@ private:
) const; ) const;
// polyMesh Friend Functions // polyMesh Friend Functions
void addPatches(polyMesh&) const; void addPatches(polyMesh& mesh) const;
//- Add faceZones based on monitoring boundary conditions //- Add faceZones based on monitoring boundary conditions
void addFaceZones(polyMesh&) const; void addFaceZones(polyMesh& mesh) const;
//- Get information about all available solutions //- Get information about all available solutions
bool detectSolution(); bool detectSolution();
//- Get information about available fields //- Get information about available fields
// assume that all fields are available for all solution intervals // assume that all fields are available for all solution intervals
void determineFieldInfo(const ccmID& fieldSetNode, fieldTable&); void determineFieldInfo
(
const ccmID& fieldSetNode,
fieldTable& table
);
// Static Members // Static Members
//- Get map of porous regions //- Get map of porous regions
static Map<word> selectPorous(const Map<dictionary>&); static Map<word> selectPorous(const Map<dictionary>& table);
public: public:
@ -418,13 +422,13 @@ public:
// Static Members // Static Members
//- Warn about repeated name //- Warn about repeated name
static void warnDuplicates(const word& context, const wordList&); static void warnDuplicates(const word& context, const wordList& lst);
// Constructors // Constructors
//- Open a file for reading //- Open a file for reading
reader(const fileName&, const options& opts); reader(const fileName& file, const reader::options& opts);
//- Destructor (closes file) //- Destructor (closes file)
@ -433,7 +437,7 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Reference to the reader options //- Reference to the reader options
const reader::options& option() const; const reader::options& option() const;
@ -459,7 +463,7 @@ public:
// const pointField& points() const { return points_; } // const pointField& points() const { return points_; }
// Check // Check
//- Return true if file has geometry associated with it //- Return true if file has geometry associated with it
bool hasGeometry(); bool hasGeometry();
@ -468,7 +472,7 @@ public:
bool hasSolution(); bool hasSolution();
// Edit // Edit
//- Remap cellTable and boundaryRegion according to dictionary //- Remap cellTable and boundaryRegion according to dictionary
bool remapMeshInfo bool remapMeshInfo
@ -478,17 +482,17 @@ public:
); );
// Write // Write
//- Write the polyMesh //- Write the polyMesh
void writeMesh void writeMesh
( (
const polyMesh&, const polyMesh& mesh,
IOstream::streamFormat fmt = IOstream::BINARY IOstream::streamFormat fmt = IOstream::BINARY
) const; ) const;
//- Write cellTable, boundaryRegion and interface information //- Write cellTable, boundaryRegion and interface information
void writeAux(const objectRegistry&) const; void writeAux(const objectRegistry& registry) const;
//- Detect and read geometry if possible //- Detect and read geometry if possible
bool readGeometry(const scalar scaleFactor = 1.0); bool readGeometry(const scalar scaleFactor = 1.0);
@ -593,12 +597,10 @@ class reader::options
//- Merge in-place interfaces (default true) //- Merge in-place interfaces (default true)
bool mergeInterfaces_; bool mergeInterfaces_;
//- Rename interface boundaries as InterfaceN_0, InterfaceN_1 (default true) //- Rename interface boundaries as InterfaceN_0, InterfaceN_1
// (default true)
bool renameInterfaces_; bool renameInterfaces_;
//- Combine identically named boundaries (default false)
bool combineBoundaries_;
//- Remove baffles by merging their respective faces (default false) //- Remove baffles by merging their respective faces (default false)
bool removeBaffles_; bool removeBaffles_;
@ -623,7 +625,7 @@ public:
// Member Functions // Member Functions
// Access // Access
//- Keep fluid regions (default true) //- Keep fluid regions (default true)
bool keepFluid() const; bool keepFluid() const;
@ -640,12 +642,10 @@ public:
//- Merge in-place interfaces (default true) //- Merge in-place interfaces (default true)
bool mergeInterfaces() const; bool mergeInterfaces() const;
//- Rename interface boundaries as InterfaceN_0, InterfaceN_1 (default true) //- Rename interface boundaries as InterfaceN_0, InterfaceN_1
// (default true)
bool renameInterfaces() const; bool renameInterfaces() const;
//- Combine identically named boundaries (default false)
bool combineBoundaries() const;
//- Remove baffles by merging their respective faces (default false) //- Remove baffles by merging their respective faces (default false)
bool removeBaffles() const; bool removeBaffles() const;
@ -660,37 +660,35 @@ public:
scalar undefScalar() const; scalar undefScalar() const;
// Edit // Edit
//- Keep fluid regions //- Keep fluid regions
void keepFluid(bool); void keepFluid(bool b);
//- Keep porous regions //- Keep porous regions
void keepPorous(bool); void keepPorous(bool b);
//- Keep solid regions //- Keep solid regions
void keepSolid(bool); void keepSolid(bool b);
//- Merge in-place interfaces //- Merge in-place interfaces
void mergeInterfaces(bool); void mergeInterfaces(bool b);
//- Rename interface boundaries as InterfaceN_0, InterfaceN_1 //- Rename interface boundaries as InterfaceN_0, InterfaceN_1
void renameInterfaces(bool); void renameInterfaces(bool b);
//- Combine identically named boundaries
void combineBoundaries(bool);
//- Remove baffles by merging their respective faces //- Remove baffles by merging their respective faces
void removeBaffles(bool); void removeBaffles(bool b);
//- Use numbered names (eg, patch_0, zone_0) instead of human-readable //- Use numbered names (eg, patch_0, zone_0) instead of human-readable
void useNumberedNames(bool); void useNumberedNames(bool b);
//- Merge tolerance for points (default 0.05e-3) //- Merge tolerance for points (default 0.05e-3)
void mergeTol(const scalar&); void mergeTol(const scalar& tol);
//- Value to assign for undefined solutions (default: NaN) //- Value to assign for undefined solutions (default: NaN)
void undefScalar(const scalar&); void undefScalar(const scalar& val);
}; };

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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -44,7 +44,7 @@ Foam::Map<Foam::word> Foam::ccm::reader::selectPorous
{ {
Map<word> lookup; Map<word> lookup;
forAllConstIter(Map<dictionary>, table, iter) forAllConstIters(table, iter)
{ {
if (iter().lookupOrDefault<label>("PorosityId", 0) != 0) if (iter().lookupOrDefault<label>("PorosityId", 0) != 0)
{ {
@ -70,21 +70,21 @@ void Foam::ccm::reader::warnDuplicates
const wordList& lst const wordList& lst
) )
{ {
HashTable<label> hashed(lst.size()); HashTable<label> hashed(2*lst.size());
bool duplicates = false; bool duplicates = false;
forAll(lst, elemI) for (const word& item : lst)
{ {
// Check duplicate name // Check duplicate names
HashTable<label>::iterator iter = hashed.find(lst[elemI]); auto iter = hashed.find(item);
if (iter != hashed.end()) if (iter.found())
{ {
(*iter)++; (*iter)++;
duplicates = true; duplicates = true;
} }
else else
{ {
hashed.insert(lst[elemI], 1); hashed.insert(item, 1);
} }
} }
@ -92,9 +92,9 @@ void Foam::ccm::reader::warnDuplicates
if (duplicates) if (duplicates)
{ {
Info << nl << "WARNING: " << context << " with identical names:"; Info << nl << "WARNING: " << context << " with identical names:";
forAllConstIter(HashTable<label>, hashed, iter) forAllConstIters(hashed, iter)
{ {
if (*iter > 1) if (iter.object() > 1)
{ {
Info << " " << iter.key(); Info << " " << iter.key();
} }

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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,8 +37,8 @@ License
#include "PackedList.H" #include "PackedList.H"
#include "uindirectPrimitivePatch.H" #include "uindirectPrimitivePatch.H"
#include "SortableList.H" #include "SortableList.H"
#include "mergePoints1.H" #include "mergePoints.H"
#include "ListOps1.H" #include "ListOps.H"
#include "ccmInternal.H" // include last to avoid any strange interactions #include "ccmInternal.H" // include last to avoid any strange interactions
@ -479,8 +479,8 @@ void Foam::ccm::reader::readCells
info.setPatchName(ccmReadOptstr("Label", nodeId)); info.setPatchName(ccmReadOptstr("Label", nodeId));
// Lookup the name, type from boundary region info: // Lookup the name, type from boundary region info:
Map<dictionary>::iterator dictIter = boundaryRegion_.find(info.ccmIndex); auto dictIter = boundaryRegion_.find(info.ccmIndex);
if (dictIter != boundaryRegion_.end()) if (dictIter.found())
{ {
word patchName(dictIter()["Label"]); word patchName(dictIter()["Label"]);
word patchType(dictIter()["BoundaryType"]); word patchType(dictIter()["BoundaryType"]);
@ -517,51 +517,6 @@ void Foam::ccm::reader::readCells
origBndId_ = -1; origBndId_ = -1;
nPatches = 0; nPatches = 0;
HashTable<label, std::string> hashedNames;
if (option().combineBoundaries())
{
// Ensure all the interfaces are orderd up-front:
forAll(interfaceDefinitions_, interI)
{
const interfaceEntry& ifentry = interfaceDefinitions_[interI];
label info0Index = -1;
label info1Index = -1;
forAll(bndInfo, infoI)
{
if (bndInfo[infoI].ccmIndex == ifentry.bnd0)
{
info0Index = infoI;
}
else if (bndInfo[infoI].ccmIndex == ifentry.bnd1)
{
info1Index = infoI;
}
}
if (info0Index == info1Index || info0Index < 0 || info1Index < 0)
{
// this should never be able to happen
continue;
}
ccmBoundaryInfo& info0 = bndInfo[info0Index];
ccmBoundaryInfo& info1 = bndInfo[info1Index];
// Preserve interface order
info0.patchId = nPatches++;
info1.patchId = nPatches++;
// full safety:
info0.patchName = ifentry.canonicalName0();
info1.patchName = ifentry.canonicalName1();
hashedNames.insert(info0.patchName, info0Index);
hashedNames.insert(info1.patchName, info1Index);
}
}
forAll(bndInfo, infoI) forAll(bndInfo, infoI)
{ {
ccmBoundaryInfo& info = bndInfo[infoI]; ccmBoundaryInfo& info = bndInfo[infoI];
@ -573,27 +528,8 @@ void Foam::ccm::reader::readCells
} }
else else
{ {
if (option().combineBoundaries()) info.patchId = nPatches++;
{ origBndId_[info.patchId] = info.ccmIndex;
// Check if patch name was already seen
HashTable<label, std::string>::const_iterator citer = hashedNames.find(info.patchName);
if (citer != hashedNames.end())
{
info.patchId = bndInfo[citer()].patchId;
}
else
{
hashedNames.insert(info.patchName, infoI);
info.patchId = nPatches++;
origBndId_[info.patchId] = info.ccmIndex;
}
}
else
{
info.patchId = nPatches++;
origBndId_[info.patchId] = info.ccmIndex;
}
} }
patchSizes_[info.patchId] += info.size; patchSizes_[info.patchId] += info.size;
@ -622,20 +558,6 @@ void Foam::ccm::reader::readCells
ccmLookupOrder.resetAddressing(addr.xfer()); ccmLookupOrder.resetAddressing(addr.xfer());
} }
if (option().combineBoundaries())
{
Info<<"patches combined by name: ";
if (nPatches == bndInfo.size())
{
Info<<"none" << endl;
}
else
{
Info<< bndInfo.size() << " into " << nPatches << endl;
}
// Info<< ccmLookupOrder << endl;
}
// //
// Now we are ready to do the reading // Now we are ready to do the reading
@ -775,7 +697,11 @@ void Foam::ccm::reader::readCells
kCCMIOStart, kCCMIOStart,
kCCMIOEnd kCCMIOEnd
); );
assertNoError("Error reading boundary face cells - index " + ::Foam::name(info.ccmIndex)); assertNoError
(
"Error reading boundary face cells - index "
+ ::Foam::name(info.ccmIndex)
);
// Copy into Foam list // Copy into Foam list
// ccmFaces are organized as [nVert vrt1 .. vrtN] // ccmFaces are organized as [nVert vrt1 .. vrtN]
@ -797,7 +723,11 @@ void Foam::ccm::reader::readCells
} }
else else
{ {
assertNoError("Error reading boundary faces - index " + ::Foam::name(info.ccmIndex)); assertNoError
(
"Error reading boundary faces - index "
+ ::Foam::name(info.ccmIndex)
);
} }
} }
@ -1106,11 +1036,10 @@ void Foam::ccm::reader::readMonitoring
<< "ccmRegionId: " << ccmRegionId << endl; << "ccmRegionId: " << ccmRegionId << endl;
#endif #endif
Map<dictionary>::const_iterator auto iter = boundaryRegion_.cfind(ccmRegionId);
iter = boundaryRegion_.find(ccmRegionId);
word zoneName; word zoneName;
if (iter != boundaryRegion_.end()) if (iter.found())
{ {
iter().lookup("Label") >> zoneName; iter().lookup("Label") >> zoneName;
} }
@ -1314,7 +1243,7 @@ void Foam::ccm::reader::removeUnwanted()
{ {
Map<word> keepMap; Map<word> keepMap;
forAllConstIter(Map<dictionary>, cellTable_, iter) forAllConstIters(cellTable_, iter)
{ {
const label tableId = iter.key(); const label tableId = iter.key();
if (!removeMap.found(tableId)) if (!removeMap.found(tableId))
@ -1326,17 +1255,19 @@ void Foam::ccm::reader::removeUnwanted()
Info<<"remove "<< nRemove << " cells in " Info<<"remove "<< nRemove << " cells in "
<< removeMap.size() << " unwanted cellZone(s)" << nl; << removeMap.size() << " unwanted cellZone(s)" << nl;
forAllConstIter(Map<word>, removeMap, iter) forAllConstIters(removeMap, iter)
{ {
Info<< " zone " << iter.key() << " : "<< iter() << nl; Info<< " zone "
<< iter.key() << " : " << iter.object() << nl;
} }
Info<<"retain "<< (nCells_ - nRemove) << " cells in " Info<<"retain "<< (nCells_ - nRemove) << " cells in "
<< keepMap.size() << " cellZone(s)" << nl; << keepMap.size() << " cellZone(s)" << nl;
forAllConstIter(Map<word>, keepMap, iter) forAllConstIters(keepMap, iter)
{ {
Info<< " zone " << iter.key() << " : "<< iter() << nl; Info<< " zone "
<< iter.key() << " : " << iter.object() << nl;
} }
} }
} }
@ -1512,7 +1443,7 @@ void Foam::ccm::reader::validateInterface
void Foam::ccm::reader::renumberInterfaces void Foam::ccm::reader::renumberInterfaces
( (
const labelList& oldToNew const labelUList& oldToNew
) )
{ {
forAll(domInterfaces_, elemI) forAll(domInterfaces_, elemI)
@ -1544,8 +1475,8 @@ void Foam::ccm::reader::cleanupInterfaces()
if (bafInterfaces_.size() <= 0 && domInterfaces_.size() <= 0) if (bafInterfaces_.size() <= 0 && domInterfaces_.size() <= 0)
{ {
Info<<"0 baffle interface pairs" << endl; Info<<"0 baffle interface pairs" << nl
Info<<"0 domain interface pairs" << endl; <<"0 domain interface pairs" << endl;
return; return;
} }
@ -1559,8 +1490,8 @@ void Foam::ccm::reader::cleanupInterfaces()
forAll(domInterfaces_, elemI) forAll(domInterfaces_, elemI)
{ {
label face0 = domInterfaces_[elemI][0]; const label face0 = domInterfaces_[elemI][0];
label face1 = domInterfaces_[elemI][1]; const label face1 = domInterfaces_[elemI][1];
Info<< "interface [" << elemI << "] = " Info<< "interface [" << elemI << "] = "
<< face0 << " - " << face1 << " own/neigh = " << face0 << " - " << face1 << " own/neigh = "
@ -1821,7 +1752,7 @@ void Foam::ccm::reader::cleanupInterfaces()
// << SubList<label>(oldToNew, nFaces_ - nInternalFaces_, nInternalFaces_) // << SubList<label>(oldToNew, nFaces_ - nInternalFaces_, nInternalFaces_)
// << endl; // << endl;
forAllIter(HashTable<labelList>, monitoringSets_, iter) forAllIters(monitoringSets_, iter)
{ {
inplaceRenumber(oldToNew, iter()); inplaceRenumber(oldToNew, iter());
} }
@ -1893,9 +1824,11 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
// List of patch pairs that are interfaces // List of patch pairs that are interfaces
DynamicList<labelPair> interfacePatches(interfaceDefinitions_.size()); DynamicList<labelPair> interfacePatches(interfaceDefinitions_.size());
forAll(interfaceDefinitions_, interI) label nWarn = 0;
forAllConstIters(interfaceDefinitions_, iter)
{ {
const interfaceEntry& ifentry = interfaceDefinitions_[interI]; const interfaceEntry& ifentry = iter.object();
labelPair patchPair labelPair patchPair
( (
@ -1903,10 +1836,15 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
findIndex(origBndId_, ifentry.bnd1) findIndex(origBndId_, ifentry.bnd1)
); );
if (patchPair[0] == patchPair[1] || patchPair[0] < 0 || patchPair[1] < 0) if
(
patchPair[0] == patchPair[1]
|| patchPair[0] < 0
|| patchPair[1] < 0
)
{ {
// This should not happen // This should not happen
Info<<"Warning : bad interface " << interI << " " << ifentry Info<<"Warning : bad interface " << ifentry.id << " " << ifentry
<<" on patches " << patchPair << endl; <<" on patches " << patchPair << endl;
} }
else if else if
@ -1916,11 +1854,18 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|| patchSizes_[patchPair[1]] == 0 || patchSizes_[patchPair[1]] == 0
) )
{ {
Info<<"Warning : skip interface " << interI << " " << ifentry if (!nWarn++)
<<" on patches " << patchPair << nl {
<<" has zero or different number of faces: (" Info<<"Warning: skip interface with zero or different"
<< patchSizes_[patchPair[0]] << " " << patchSizes_[patchPair[1]] << ")" << " number of faces" << nl;
<< endl; }
Info<<" Interface:" << ifentry.id << " " << ifentry
<<" patches " << patchPair
<<" sizes ("
<< patchSizes_[patchPair[0]]
<< " " << patchSizes_[patchPair[1]] << ")"
<< nl;
} }
else else
{ {
@ -1947,7 +1892,8 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
// Markup points to merge // Markup points to merge
PackedBoolList whichPoints(points_.size()); PackedBoolList whichPoints(points_.size());
Info<< "interface merge points (tol=" << option().mergeTol() << "):" << endl; Info<< "interface merge points (tol="
<< option().mergeTol() << "):" << endl;
DynamicList<label> interfacesToMerge(interfacePatches.size()); DynamicList<label> interfacesToMerge(interfacePatches.size());
forAll(interfacePatches, interI) forAll(interfacePatches, interI)
@ -1985,12 +1931,11 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
const UIndirectList<point> pointsToMerge(points_, addr); const UIndirectList<point> pointsToMerge(points_, addr);
Info<< " patch " << patch0 << ", " << patch1 << ": (" Info<< " patch " << patch0 << "," << patch1 << ": ("
<< nPatch0Faces << " and " << nPatch1Faces << " faces) " << flush; << nPatch0Faces << " and " << nPatch1Faces << " faces) " << flush;
label nMerged = mergePoints const label nMerged = mergePoints
( (
true,
pointsToMerge, pointsToMerge,
option().mergeTol(), option().mergeTol(),
false, false,
@ -2003,9 +1948,9 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
if (nMerged) if (nMerged)
{ {
// Transcribe local to global addressing // Transcribe local to global addressing
forAll(mergedPointMap, lookupI) forAll(mergedPointMap, i)
{ {
oldToNew[addr[lookupI]] = addr[mergedPointMap[lookupI]]; oldToNew[addr[i]] = addr[mergedPointMap[i]];
} }
interfacesToMerge.append(interI); interfacesToMerge.append(interI);
@ -2175,11 +2120,11 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
// Note which one were successful // Note which one were successful
labelHashSet done(failed0.size()); labelHashSet done(failed0.size());
forAllConstIter(labelHashSet, failed0, iter0) forAllConstIters(failed0, iter0)
{ {
const label face0I = iter0.key(); const label face0I = iter0.key();
forAllConstIter(labelHashSet, failed1, iter1) forAllConstIters(failed1, iter1)
{ {
const label face1I = iter1.key(); const label face1I = iter1.key();
@ -2421,10 +2366,10 @@ void Foam::ccm::reader::reorderMesh()
inplaceReorder(oldToNew, faceNeighbour_); inplaceReorder(oldToNew, faceNeighbour_);
inplaceReorder(oldToNew, origFaceId_); inplaceReorder(oldToNew, origFaceId_);
forAllIter(HashTable<labelList>, monitoringSets_, iter) forAllIters(monitoringSets_, iter)
{ {
inplaceRenumber(oldToNew, iter()); labelList& lst = iter.object();
labelList &lst = iter(); inplaceRenumber(oldToNew, lst);
// disallow monitoring on boundaries // disallow monitoring on boundaries
label nElem = 0; label nElem = 0;
@ -2436,7 +2381,7 @@ void Foam::ccm::reader::reorderMesh()
{ {
lst[nElem] = lst[i]; lst[nElem] = lst[i];
} }
nElem++; ++nElem;
} }
} }
@ -2478,10 +2423,9 @@ void Foam::ccm::reader::addPatches
word patchName; word patchName;
word patchType; word patchType;
Map<dictionary>::const_iterator auto citer = boundaryRegion_.cfind(origBndId_[patchI]);
citer = boundaryRegion_.find(origBndId_[patchI]);
if (citer != boundaryRegion_.end()) if (citer.found())
{ {
citer().lookup("Label") >> patchName; citer().lookup("Label") >> patchName;
citer().lookup("BoundaryType") >> patchType; citer().lookup("BoundaryType") >> patchType;
@ -2593,7 +2537,7 @@ void Foam::ccm::reader::addFaceZones
} }
nZone = 0; nZone = 0;
forAllConstIter(HashTable<labelList>, monitoringSets_, iter) forAllConstIters(monitoringSets_, iter)
{ {
Info<< "faceZone " << nZone Info<< "faceZone " << nZone
<< " (size: " << iter().size() << ") name: " << " (size: " << iter().size() << ") name: "
@ -2612,7 +2556,7 @@ void Foam::ccm::reader::addFaceZones
) )
); );
nZone++; ++nZone;
} }
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE; mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;

View File

@ -34,7 +34,6 @@ Foam::ccm::reader::options::options()
keepSolid_(true), keepSolid_(true),
mergeInterfaces_(false), mergeInterfaces_(false),
renameInterfaces_(true), renameInterfaces_(true),
combineBoundaries_(false),
removeBaffles_(false), removeBaffles_(false),
useNumberedNames_(false), useNumberedNames_(false),
mergeTol_(0.05e-3), mergeTol_(0.05e-3),
@ -80,12 +79,6 @@ bool Foam::ccm::reader::options::renameInterfaces() const
} }
bool Foam::ccm::reader::options::combineBoundaries() const
{
return combineBoundaries_;
}
bool Foam::ccm::reader::options::removeBaffles() const bool Foam::ccm::reader::options::removeBaffles() const
{ {
return removeBaffles_; return removeBaffles_;
@ -141,12 +134,6 @@ void Foam::ccm::reader::options::renameInterfaces(bool b)
} }
void Foam::ccm::reader::options::combineBoundaries(bool b)
{
combineBoundaries_ = b;
}
void Foam::ccm::reader::options::removeBaffles(bool b) void Foam::ccm::reader::options::removeBaffles(bool b)
{ {
removeBaffles_ = b; removeBaffles_ = b;

View File

@ -622,7 +622,7 @@ Foam::ccm::reader::readField
// transcribe to output list // transcribe to output list
forAll(mapData, i) forAll(mapData, i)
{ {
label cellId = mapData[i]; const label cellId = mapData[i];
scalarData[cellId] = rawData[i]; scalarData[cellId] = rawData[i];
} }

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) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -29,8 +29,8 @@ Description
#define ccmSolutionTable_H #define ccmSolutionTable_H
#include "SLList.H" #include "SLList.H"
#include "stringListOps.H"
#include "Ostream.H" #include "Ostream.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,8 +39,16 @@ namespace Foam
namespace ccm namespace ccm
{ {
class fieldEntry;
class fieldTable;
class solutionEntry;
Ostream& operator<<(Ostream& os, const fieldEntry& entry);
Ostream& operator<<(Ostream& os, const fieldTable& entry);
Ostream& operator<<(Ostream& os, const solutionEntry& entry);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ccm::namesList Declaration Class Foam::ccm::namesList Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- A linked-list that is searchable by the 'name()' of the items //- A linked-list that is searchable by the 'name()' of the items
@ -50,8 +58,8 @@ class namesList
public SLList<T> public SLList<T>
{ {
public: public:
typedef typename SLList<T>::const_iterator const_iterator; using const_iterator = typename SLList<T>::const_iterator;
typedef typename SLList<T>::iterator iterator; using iterator = typename SLList<T>::iterator;
// Constructors // Constructors
@ -65,12 +73,7 @@ public:
//- Return true if a list element has a name that matches key //- Return true if a list element has a name that matches key
bool found(const word& key) const bool found(const word& key) const
{ {
for forAllConstIters(*this, iter)
(
const_iterator iter = SLList<T>::begin();
iter != SLList<T>::end();
++iter
)
{ {
if (iter().name() == key) if (iter().name() == key)
{ {
@ -85,12 +88,7 @@ public:
//- Find a list element has a name matching key //- Find a list element has a name matching key
iterator find(const word& key) iterator find(const word& key)
{ {
for forAllIters(*this, iter)
(
iterator iter = SLList<T>::begin();
iter != SLList<T>::end();
++iter
)
{ {
if (iter().name() == key) if (iter().name() == key)
{ {
@ -112,12 +110,7 @@ public:
List<word> matched(SLList<T>::size()); List<word> matched(SLList<T>::size());
label matchI = 0; label matchI = 0;
for forAllConstIters(*this, iter)
(
const_iterator iter = SLList<T>::begin();
iter != SLList<T>::end();
++iter
)
{ {
const word& name = iter().name(); const word& name = iter().name();
@ -139,7 +132,7 @@ public:
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ccm::fieldEntry Declaration Class Foam::ccm::fieldEntry Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- A ccm field entry with short name, name, maxId and type //- A ccm field entry with short name, name, maxId and type
@ -223,15 +216,6 @@ public:
// Edit // Edit
//- Set the field units
void units(const char* units)
{
if (units && *units)
{
units_ = units;
}
}
//- Set the field units //- Set the field units
void units(const std::string& units) void units(const std::string& units)
{ {
@ -279,8 +263,9 @@ public:
}; };
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ccm::solutionEntry Declaration Class Foam::ccm::solutionEntry Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- A ccm solution entry with name, iteration and time //- A ccm solution entry with name, iteration and time
@ -306,8 +291,8 @@ public:
solutionEntry solutionEntry
( (
const word& name, const word& name,
const label& iteration, const label iteration,
const scalar& timeValue = 0 const scalar timeValue = 0
) )
: :
name_(name), name_(name),
@ -355,7 +340,7 @@ public:
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ccm::solutionTable Declaration Class Foam::ccm::solutionTable Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
// Typedef: ccm::solutionTable // Typedef: ccm::solutionTable
@ -364,7 +349,7 @@ typedef namesList<solutionEntry> solutionTable;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ccm::fieldTable Declaration Class Foam::ccm::fieldTable Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- A list of the available fields //- A list of the available fields
@ -382,15 +367,16 @@ public:
namesList<fieldEntry>() namesList<fieldEntry>()
{} {}
// Access // Access
//- The maximum cell Id referenced in the list //- The maximum cell Id referenced in the list
label maxCellId() const label maxCellId() const
{ {
label maxId = 0; label maxId = 0;
forAllConstIter(namesList<fieldEntry>, *this, iter) forAllConstIters(*this, iter)
{ {
label currMax = (iter()).maxCellId(); const label currMax = iter().maxCellId();
if (maxId < currMax) if (maxId < currMax)
{ {
@ -406,10 +392,9 @@ public:
label maxFaceId() const label maxFaceId() const
{ {
label maxId = 0; label maxId = 0;
forAllConstIters(*this, iter)
forAllConstIter(namesList<fieldEntry>, *this, iter)
{ {
label currMax = (iter()).maxFaceId(); const label currMax = iter().maxFaceId();
if (maxId < currMax) if (maxId < currMax)
{ {

View File

@ -95,7 +95,7 @@ void Foam::ccm::writer::writeBoundaryRegion
// Create dictionary lookup for constant/boundaryRegion // Create dictionary lookup for constant/boundaryRegion
dictionary typeDict; dictionary typeDict;
forAllConstIter(Map<dictionary>, boundaryRegion_, iter) forAllConstIters(boundaryRegion_, iter)
{ {
const dictionary& dict = iter(); const dictionary& dict = iter();
if if
@ -207,7 +207,7 @@ void Foam::ccm::writer::writeCellTable
ccmID nodeId; ccmID nodeId;
forAllConstIter(Map<dictionary>, cellTable_, iter) forAllConstIters(cellTable_, iter)
{ {
label intVal = iter.key(); label intVal = iter.key();
const dictionary& dict = iter(); const dictionary& dict = iter();
@ -292,7 +292,6 @@ void Foam::ccm::writer::writeProblem
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct for writing geometry
Foam::ccm::writer::writer Foam::ccm::writer::writer
( (
const fileName& file, const fileName& file,

View File

@ -219,7 +219,12 @@ public:
// Constructors // Constructors
//- Open a file for writing, with backup/overwrite existing file //- Open a file for writing, with backup/overwrite existing file
writer(const fileName&, const polyMesh&, const bool backup=true); writer
(
const fileName& file,
const polyMesh& mesh,
const bool backup=true
);
//- Destructor (closes file) //- Destructor (closes file)
@ -228,7 +233,7 @@ public:
// Member Functions // Member Functions
// Write // Write
//- Write the mesh //- Write the mesh
void writeGeometry(); void writeGeometry();
@ -237,7 +242,7 @@ public:
// provide optional remapping dictionary // provide optional remapping dictionary
void writeSolution void writeSolution
( (
const IOobjectList&, const IOobjectList& objects,
const fileName& remappingDictName = fileName::null const fileName& remappingDictName = fileName::null
); );

View File

@ -567,9 +567,9 @@ void Foam::ccm::writer::writeCells
tableId = cellTable_.append(dict); tableId = cellTable_.append(dict);
} }
forAll(cZone, i) for (auto id : cZone)
{ {
mapData[cZone[i]] = tableId; mapData[id] = tableId;
} }
} }
} }
@ -582,11 +582,11 @@ void Foam::ccm::writer::writeCells
dict.add("MaterialType", "fluid"); dict.add("MaterialType", "fluid");
label tableId = cellTable_.append(dict); label tableId = cellTable_.append(dict);
forAll(mapData, i) for (auto& id : mapData)
{ {
if (mapData[i] < 0) if (id < 0)
{ {
mapData[i] = tableId; id = tableId;
} }
} }
} }

View File

@ -463,8 +463,6 @@ void Foam::ccm::writer::writeSolution
&phaseNode &phaseNode
); );
forAllConstIter(IOobjectList, objects, iter) forAllConstIter(IOobjectList, objects, iter)
{ {
word fieldName = (*iter()).name(); word fieldName = (*iter()).name();

View File

@ -375,7 +375,7 @@ bool Foam::fileFormats::FIREMeshReader::readGeometry(const scalar scaleFactor)
IOstream::streamFormat fmt = IOstream::ASCII; IOstream::streamFormat fmt = IOstream::ASCII;
const word ext = geometryFile_.ext(); const word ext = geometryFile_.ext();
bool supported = FIRECore::file3dExtensions.found(ext); bool supported = FIRECore::file3dExtensions.hasEnum(ext);
if (supported) if (supported)
{ {
FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext]; FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext];

View File

@ -278,7 +278,7 @@ bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const
{ {
const word ext = baseName.ext(); const word ext = baseName.ext();
if (FIRECore::file3dExtensions.found(ext)) if (FIRECore::file3dExtensions.hasEnum(ext))
{ {
FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext]; FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext];
if (fireFileType == FIRECore::POLY_ASCII) if (fireFileType == FIRECore::POLY_ASCII)

View File

@ -90,9 +90,13 @@ void Foam::meshSubsetHelper::correct(bool verbose)
Foam::polyMesh::readUpdateState Foam::meshSubsetHelper::readUpdate() Foam::polyMesh::readUpdateState Foam::meshSubsetHelper::readUpdate()
{ {
polyMesh::readUpdateState meshState = baseMesh_.readUpdate(); const polyMesh::readUpdateState meshState = baseMesh_.readUpdate();
if (meshState == polyMesh::TOPO_CHANGE || polyMesh::TOPO_PATCH_CHANGE) if
(
meshState == polyMesh::TOPO_CHANGE
|| meshState == polyMesh::TOPO_PATCH_CHANGE
)
{ {
correct(true); correct(true);
} }

View File

@ -83,6 +83,7 @@ Foam::functionObjects::volRegion::volRegion
? regionTypeNames_.read(dict.lookup("regionType")) ? regionTypeNames_.read(dict.lookup("regionType"))
: vrtAll : vrtAll
), ),
regionName_(polyMesh::defaultRegion),
regionID_(-1) regionID_(-1)
{ {
read(dict); read(dict);
@ -143,7 +144,7 @@ bool Foam::functionObjects::volRegion::read
{ {
FatalIOErrorInFunction(dict) FatalIOErrorInFunction(dict)
<< "Unknown region type. Valid region types are:" << "Unknown region type. Valid region types are:"
<< regionTypeNames_ << regionTypeNames_.toc()
<< exit(FatalIOError); << exit(FatalIOError);
} }
} }

View File

@ -564,9 +564,10 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
{ {
FatalErrorInFunction FatalErrorInFunction
<< type() << " " << name() << ": " << type() << " " << name() << ": "
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):" << int(regionType_) << "(" << regionName_ << "):"
<< nl << " Unknown region type. Valid region types are:" << nl << " Unknown region type. Valid region types are:"
<< regionTypeNames_.sortedToc() << nl << exit(FatalError); << regionTypeNames_ << nl
<< exit(FatalError);
} }
} }

View File

@ -217,12 +217,17 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
if (Pstream::master()) if (Pstream::master())
{ {
word outName = fieldName + '_' + regionTypeNames_[regionType_];
if (this->volRegion::regionName_ != polyMesh::defaultRegion)
{
outName = outName + '-' + this->volRegion::regionName_;
}
IOField<Type> IOField<Type>
( (
IOobject IOobject
( (
fieldName + '_' + regionTypeNames_[regionType_] outName,
+ '-' + volRegion::regionName_,
obr_.time().timeName(), obr_.time().timeName(),
obr_, obr_,
IOobject::NO_READ, IOobject::NO_READ,
@ -241,13 +246,17 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
file()<< tab << result; file()<< tab << result;
Log << " " << operationTypeNames_[operation_] Log << " " << operationTypeNames_[operation_]
<< "(" << volRegion::regionName_ << ") of " << fieldName << "(" << this->volRegion::regionName_ << ") of " << fieldName
<< " = " << result << endl; << " = " << result << endl;
// Write state/results information // Write state/results information
const word& opName = operationTypeNames_[operation_]; const word& opName = operationTypeNames_[operation_];
word resultName = word outName = fieldName;
opName + '(' + volRegion::regionName_ + ',' + fieldName + ')'; if (this->volRegion::regionName_ != polyMesh::defaultRegion)
{
outName = this->volRegion::regionName_ + ',' + outName;
}
word resultName = opName + '(' + outName + ')';
this->setResult(resultName, result); this->setResult(resultName, result);
} }

View File

@ -71,14 +71,14 @@ void Foam::functionObjects::mapFields::createInterpolation
) )
); );
const fvMesh& mapRegion = mapRegionPtr_(); const fvMesh& mapRegion = mapRegionPtr_();
word mapMethodName(dict.lookup("mapMethod")); const word mapMethodName(dict.lookup("mapMethod"));
if (!meshToMesh::interpolationMethodNames_.found(mapMethodName)) if (!meshToMesh::interpolationMethodNames_.hasEnum(mapMethodName))
{ {
FatalErrorInFunction FatalErrorInFunction
<< type() << " " << name() << ": unknown map method " << type() << " " << name() << ": unknown map method "
<< mapMethodName << nl << mapMethodName << nl
<< "Available methods include: " << "Available methods include: "
<< meshToMesh::interpolationMethodNames_.sortedToc() << meshToMesh::interpolationMethodNames_
<< exit(FatalError); << exit(FatalError);
} }

View File

@ -196,7 +196,8 @@ bool Foam::functionObjects::writeObjects::write()
FatalErrorInFunction FatalErrorInFunction
<< "Unknown writeOption " << "Unknown writeOption "
<< writeOptionNames_[writeOption_] << writeOptionNames_[writeOption_]
<< ". Valid writeOption types are" << writeOptionNames_ << ". Valid writeOption types are "
<< writeOptionNames_
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -82,7 +82,8 @@ void Foam::fv::cellSetOption::setSelection(const dictionary& dict)
FatalErrorInFunction FatalErrorInFunction
<< "Unknown selectionMode " << "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_] << selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_ << ". Valid selectionMode types are "
<< selectionModeTypeNames_
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -186,7 +187,8 @@ void Foam::fv::cellSetOption::setCellSet()
FatalErrorInFunction FatalErrorInFunction
<< "Unknown selectionMode " << "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_] << selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_ << ". Valid selectionMode types are "
<< selectionModeTypeNames_
<< exit(FatalError); << exit(FatalError);
} }
} }

View File

@ -236,7 +236,7 @@ directionalPressureGradientExplicitSource
<< "Did not find mode " << model_ << "Did not find mode " << model_
<< nl << nl
<< "Please set 'model' to one of " << "Please set 'model' to one of "
<< PressureDropModelNames_.toc() << PressureDropModelNames_
<< exit(FatalError); << exit(FatalError);
} }
@ -290,7 +290,6 @@ void Foam::fv::directionalPressureGradientExplicitSource::correct
const scalarField nu(turbModel.nu(), cells_); const scalarField nu(turbModel.nu(), cells_);
gradPporous_ = -flowDir_*(D_*nu + I_*0.5*magUn)*magUn*length_; gradPporous_ = -flowDir_*(D_*nu + I_*0.5*magUn)*magUn*length_;
break;
} }
else else
{ {
@ -307,6 +306,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::correct
gradPporous_ = gradPporous_ =
- flowDir_*(D_*mu + I_*0.5*rho*magUn)*magUn*length_; - flowDir_*(D_*mu + I_*0.5*rho*magUn)*magUn*length_;
} }
break;
} }
case pConstant: case pConstant:
{ {

View File

@ -376,7 +376,8 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
FatalErrorInFunction FatalErrorInFunction
<< "Unknown geometryMode " << geometryModeTypeNames_[gm] << "Unknown geometryMode " << geometryModeTypeNames_[gm]
<< ". Available geometry modes include " << ". Available geometry modes include "
<< geometryModeTypeNames_ << exit(FatalError); << geometryModeTypeNames_
<< exit(FatalError);
} }
} }

View File

@ -493,9 +493,22 @@ void Foam::snappyLayerDriver::handleNonStringConnected
// warning from checkMesh. These faces cannot be extruded so // warning from checkMesh. These faces cannot be extruded so
// there is no need to even attempt it. // there is no need to even attempt it.
List<extrudeMode> oldExtrudeStatus(extrudeStatus); List<extrudeMode> oldExtrudeStatus;
OBJstream str(meshRefiner_.mesh().time().path()/"nonStringConnected.obj"); autoPtr<OBJstream> str;
Pout<< "Dumping string edges to " << str.name(); if (debug&meshRefinement::LAYERINFO)
{
oldExtrudeStatus = extrudeStatus;
str.reset
(
new OBJstream
(
meshRefiner_.mesh().time().path()
/"nonStringConnected.obj"
)
);
Pout<< "Dumping string edges to " << str().name();
}
// 1) Local // 1) Local
Map<label> nCommonPoints(100); Map<label> nCommonPoints(100);
@ -521,18 +534,24 @@ Pout<< "Dumping string edges to " << str.name();
// 2) TDB. Other face remote // 2) TDB. Other face remote
forAll(extrudeStatus, pointi)
{
if (extrudeStatus[pointi] != oldExtrudeStatus[pointi]) if (debug&meshRefinement::LAYERINFO)
{ {
str.write(meshRefiner_.mesh().points()[pp.meshPoints()[pointi]]); forAll(extrudeStatus, pointi)
{
if (extrudeStatus[pointi] != oldExtrudeStatus[pointi])
{
str().write
(
meshRefiner_.mesh().points()[pp.meshPoints()[pointi]]
);
}
}
} }
} }
}
// No extrusion at non-manifold points. // No extrusion at non-manifold points.
void Foam::snappyLayerDriver::handleNonManifolds void Foam::snappyLayerDriver::handleNonManifolds
( (

View File

@ -25,6 +25,12 @@ $(edgeMeshFormats)/starcd/STARCDedgeFormatRunTime.C
$(edgeMeshFormats)/vtk/VTKedgeFormat.C $(edgeMeshFormats)/vtk/VTKedgeFormat.C
$(edgeMeshFormats)/vtk/VTKedgeFormatRunTime.C $(edgeMeshFormats)/vtk/VTKedgeFormatRunTime.C
edgeMeshTools = $(em)/edgeMeshTools
$(edgeMeshTools)/edgeMeshTools.C
$(edgeMeshTools)/edgeMeshFeatureProximity.C
$(em)/featureEdgeMesh/featureEdgeMesh.C $(em)/featureEdgeMesh/featureEdgeMesh.C
eem = $(em)/extendedEdgeMesh eem = $(em)/extendedEdgeMesh
@ -215,6 +221,8 @@ triSurface/triangleFuncs/triangleFuncs.C
triSurface/surfaceFeatures/surfaceFeatures.C triSurface/surfaceFeatures/surfaceFeatures.C
triSurface/triSurfaceLoader/triSurfaceLoader.C triSurface/triSurfaceLoader/triSurfaceLoader.C
triSurface/triSurfaceTools/triSurfaceTools.C triSurface/triSurfaceTools/triSurfaceTools.C
triSurface/triSurfaceTools/triSurfaceCloseness.C
triSurface/triSurfaceTools/triSurfaceCurvature.C
triSurface/triSurfaceTools/geompack/geompack.C triSurface/triSurfaceTools/geompack/geompack.C
triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C

View File

@ -0,0 +1,228 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "edgeMeshTools.H"
#include "extendedEdgeMesh.H"
#include "triSurface.H"
#include "triSurfaceFields.H"
#include "pointIndexHit.H"
#include "MeshedSurface.H"
#include "OFstream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
static scalar calcProximityOfFeaturePoints
(
const List<pointIndexHit>& hitList,
const scalar defaultCellSize
)
{
scalar minDist = defaultCellSize;
for
(
label hI1 = 0;
hI1 < hitList.size() - 1;
++hI1
)
{
const pointIndexHit& pHit1 = hitList[hI1];
if (pHit1.hit())
{
for
(
label hI2 = hI1 + 1;
hI2 < hitList.size();
++hI2
)
{
const pointIndexHit& pHit2 = hitList[hI2];
if (pHit2.hit())
{
scalar curDist = mag(pHit1.hitPoint() - pHit2.hitPoint());
minDist = min(curDist, minDist);
}
}
}
}
return minDist;
}
scalar calcProximityOfFeatureEdges
(
const edgeMesh& emesh,
const List<pointIndexHit>& hitList,
const scalar defaultCellSize
)
{
scalar minDist = defaultCellSize;
for
(
label hI1 = 0;
hI1 < hitList.size() - 1;
++hI1
)
{
const pointIndexHit& pHit1 = hitList[hI1];
if (pHit1.hit())
{
const edge& e1 = emesh.edges()[pHit1.index()];
for
(
label hI2 = hI1 + 1;
hI2 < hitList.size();
++hI2
)
{
const pointIndexHit& pHit2 = hitList[hI2];
if (pHit2.hit())
{
const edge& e2 = emesh.edges()[pHit2.index()];
// Don't refine if the edges are connected to each other
if (!e1.connects(e2))
{
scalar curDist =
mag(pHit1.hitPoint() - pHit2.hitPoint());
minDist = min(curDist, minDist);
}
}
}
}
}
return minDist;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::edgeMeshTools::featureProximity
(
const extendedEdgeMesh& emesh,
const triSurface& surf,
const scalar searchDistance
)
{
tmp<scalarField> tfld(new scalarField(surf.size(), searchDistance));
scalarField& featureProximity = tfld.ref();
Info<< "Extracting proximity of close feature points and "
<< "edges to the surface" << endl;
forAll(surf, fI)
{
const triPointRef& tri = surf[fI].tri(surf.points());
const point& triCentre = tri.circumCentre();
const scalar radiusSqr = min
(
sqr(4*tri.circumRadius()),
sqr(searchDistance)
);
List<pointIndexHit> hitList;
emesh.allNearestFeatureEdges(triCentre, radiusSqr, hitList);
featureProximity[fI] =
calcProximityOfFeatureEdges
(
emesh,
hitList,
featureProximity[fI]
);
emesh.allNearestFeaturePoints(triCentre, radiusSqr, hitList);
featureProximity[fI] =
calcProximityOfFeaturePoints
(
hitList,
featureProximity[fI]
);
}
return tfld;
}
Foam::tmp<Foam::scalarField> Foam::edgeMeshTools::writeFeatureProximity
(
const Time& runTime,
const word& basename,
const extendedEdgeMesh& emesh,
const triSurface& surf,
const scalar searchDistance
)
{
Info<< nl << "Extracting curvature of surface at the points."
<< endl;
tmp<scalarField> tfld =
edgeMeshTools::featureProximity(emesh, surf, searchDistance);
scalarField& featureProximity = tfld.ref();
triSurfaceScalarField outputField
(
IOobject
(
basename + ".featureProximity",
runTime.constant(),
"triSurface",
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE
),
surf,
dimLength,
scalarField()
);
outputField.swap(featureProximity);
outputField.write();
outputField.swap(featureProximity);
return tfld;
}
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More