mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -22,13 +22,13 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::constant
|
||||
Foam::diameterModels::constant
|
||||
|
||||
Description
|
||||
Constant dispersed-phase particle diameter model.
|
||||
|
||||
SourceFiles
|
||||
constant.C
|
||||
constantDiameter.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::constantSurfaceTensionCoefficient
|
||||
Foam::surfaceTensionModels::constantSurfaceTensionCoefficient
|
||||
|
||||
Description
|
||||
Constant value surface tension model.
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::constantAspectRatio
|
||||
Foam::aspectRatioModels::constantAspectRatio
|
||||
|
||||
Description
|
||||
Constant value aspect ratio model.
|
||||
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::constantAspectRatio
|
||||
Foam::aspectRatioModels::constantAspectRatio
|
||||
|
||||
Description
|
||||
Constant value aspect ratio model.
|
||||
|
||||
@ -42,13 +42,44 @@ Description
|
||||
|
||||
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:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
IFstream is("hashingTests");
|
||||
infoHashString(8, {"asdathis1", "adsxf", "hij", "klmpq"});
|
||||
|
||||
IFstream is("hashingTests");
|
||||
|
||||
while (is.good())
|
||||
{
|
||||
|
||||
@ -26,6 +26,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "NamedEnum.H"
|
||||
#include "Enum.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
using namespace Foam;
|
||||
@ -34,15 +35,27 @@ class namedEnumTest
|
||||
{
|
||||
public:
|
||||
|
||||
enum option
|
||||
enum class option
|
||||
{
|
||||
a,
|
||||
b,
|
||||
c,
|
||||
d
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
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",
|
||||
"b",
|
||||
"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[])
|
||||
{
|
||||
const List<namedEnumTest::option> options
|
||||
= namedEnumTest::namedEnum.enums();
|
||||
Info<<"NamedEnum: " << namedEnumTest::optionNamed << nl;
|
||||
Info<<"Enum: " << namedEnumTest::optionEnum << nl;
|
||||
Info<<"Enum: " << namedEnumTest::optionEnum2 << nl;
|
||||
|
||||
dictionary testDict;
|
||||
testDict.add("lookup1", "c");
|
||||
|
||||
Info<< "enums: " << options << nl;
|
||||
|
||||
Info<< "loop over enums (as list):" << 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
|
||||
<< int(namedEnumTest::optionNamed["a"]) << nl
|
||||
<< namedEnumTest::optionNamed[namedEnumTest::option::A] << nl;
|
||||
|
||||
Info<< nl
|
||||
<< namedEnumTest::namedEnum["a"] << nl
|
||||
<< namedEnumTest::namedEnum[namedEnumTest::a] << nl;
|
||||
<< int(namedEnumTest::optionEnum["a"]) << nl
|
||||
<< namedEnumTest::optionEnum[namedEnumTest::otherOption::A] << nl;
|
||||
|
||||
Info<< "--- test dictionary lookup ---" << endl;
|
||||
{
|
||||
Info<< "dict: " << testDict << endl;
|
||||
|
||||
namedEnumTest::option gotOpt =
|
||||
namedEnumTest::namedEnum.lookupOrDefault
|
||||
(
|
||||
"test",
|
||||
testDict,
|
||||
namedEnumTest::option::a
|
||||
);
|
||||
Info<< "got: "
|
||||
<< int
|
||||
(
|
||||
namedEnumTest::optionNamed.lookupOrDefault
|
||||
(
|
||||
"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
|
||||
(
|
||||
"lookup1",
|
||||
testDict,
|
||||
namedEnumTest::option::a
|
||||
);
|
||||
|
||||
Info<< "got: " << gotOpt << endl;
|
||||
Info<< "got: "
|
||||
<< int
|
||||
(
|
||||
namedEnumTest::optionEnum2.lookupOrDefault
|
||||
(
|
||||
"lookup1",
|
||||
testDict,
|
||||
namedEnumTest::option::A
|
||||
)
|
||||
)
|
||||
<< nl;
|
||||
}
|
||||
|
||||
Info<< "--- test read construction ---" << endl;
|
||||
Info<< "--- test read ---" << endl;
|
||||
|
||||
namedEnumTest::option dummy(namedEnumTest::namedEnum.read(Sin));
|
||||
Info<< namedEnumTest::namedEnum[dummy] << endl;
|
||||
namedEnumTest::option dummy(namedEnumTest::optionNamed.read(Sin));
|
||||
Info<< namedEnumTest::optionNamed[dummy] << endl;
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
|
||||
@ -84,6 +84,12 @@ int main(int argc, char *argv[])
|
||||
packed.resize(n, 1);
|
||||
}
|
||||
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:
|
||||
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()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Count packed
|
||||
@ -110,8 +116,8 @@ int main(int argc, char *argv[])
|
||||
sum += packed.count();
|
||||
}
|
||||
Info<< "Counting via count():" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Dummy addition
|
||||
@ -123,8 +129,8 @@ int main(int argc, char *argv[])
|
||||
sum += i + 1;
|
||||
}
|
||||
}
|
||||
Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << nl
|
||||
<< " sum " << sum << " (sum is meaningless)" << endl;
|
||||
|
||||
//
|
||||
// Read
|
||||
@ -139,8 +145,8 @@ int main(int argc, char *argv[])
|
||||
sum += stlVector[i];
|
||||
}
|
||||
}
|
||||
Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read unpacked
|
||||
@ -152,8 +158,8 @@ int main(int argc, char *argv[])
|
||||
sum += unpacked[i];
|
||||
}
|
||||
}
|
||||
Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read packed
|
||||
@ -166,8 +172,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using get:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read packed
|
||||
@ -180,8 +186,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using reference:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read via iterator
|
||||
@ -194,8 +200,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read via iterator
|
||||
@ -208,8 +214,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read empty hash
|
||||
@ -222,8 +228,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read full hash
|
||||
@ -236,8 +242,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
|
||||
// Read empty static hash
|
||||
@ -250,8 +256,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
Info<< "Reading empty StaticHash:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
|
||||
#if 0
|
||||
// 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()
|
||||
<< " s" << endl;
|
||||
Info<< " sum " << sum << endl;
|
||||
<< " s" << nl
|
||||
<< " sum " << sum << endl;
|
||||
#endif
|
||||
|
||||
Info<< "Starting write tests" << endl;
|
||||
@ -319,7 +325,6 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing packed using set:" << timer.cpuTimeIncrement()
|
||||
<< " s" << endl;
|
||||
|
||||
|
||||
// Write packed
|
||||
for (label iter = 0; iter < nIters; ++iter)
|
||||
{
|
||||
|
||||
3
applications/test/surfaceIntersection/Make/files
Normal file
3
applications/test/surfaceIntersection/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-surfaceIntersection.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-surfaceIntersection
|
||||
7
applications/test/surfaceIntersection/Make/options
Normal file
7
applications/test/surfaceIntersection/Make/options
Normal 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
|
||||
221
applications/test/surfaceIntersection/Test-surfaceIntersection.C
Normal file
221
applications/test/surfaceIntersection/Test-surfaceIntersection.C
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
3
applications/test/unitConversion/Make/files
Normal file
3
applications/test/unitConversion/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-unitConversion.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-unitConversion
|
||||
0
applications/test/unitConversion/Make/options
Normal file
0
applications/test/unitConversion/Make/options
Normal file
50
applications/test/unitConversion/Test-unitConversion.C
Normal file
50
applications/test/unitConversion/Test-unitConversion.C
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -125,12 +125,6 @@ int main(int argc, char *argv[])
|
||||
"provide alternative base name when re-exporting (implies -export). "
|
||||
"Default is <meshExport>."
|
||||
);
|
||||
// This often works, but is not entirely stable
|
||||
// argList::addBoolOption
|
||||
// (
|
||||
// "combine",
|
||||
// "combine identically named patches"
|
||||
// );
|
||||
argList::addBoolOption
|
||||
(
|
||||
"noBaffles",
|
||||
@ -211,10 +205,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
rOpts.useNumberedNames(true);
|
||||
}
|
||||
else if (args.optionFound("combine"))
|
||||
{
|
||||
rOpts.combineBoundaries(true);
|
||||
}
|
||||
|
||||
if (args.optionFound("solids"))
|
||||
{
|
||||
@ -295,7 +285,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const fileName geomName = exportName + ".ccmg";
|
||||
Info<< nl << "Re-exporting geometry as " << geomName << nl;
|
||||
ccm::writer(geomName, mesh).writeGeometry();
|
||||
ccm::writer(geomName, mesh()).writeGeometry();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -44,22 +44,9 @@ void Foam::DelaunayMeshTools::writeOBJ
|
||||
OFstream str(fName);
|
||||
|
||||
Pout<< nl
|
||||
<< "Writing points of types:" << nl;
|
||||
|
||||
forAllConstIter
|
||||
(
|
||||
HashTable<int>,
|
||||
indexedVertexEnum::vertexTypeNames_,
|
||||
iter
|
||||
)
|
||||
{
|
||||
if (iter() >= startPointType && iter() <= endPointType)
|
||||
{
|
||||
Pout<< " " << iter.key() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
Pout<< "to " << str.name() << endl;
|
||||
<< "Writing points of types ("
|
||||
<< int(startPointType) << "-" << int(endPointType)
|
||||
<< ") to " << str.name() << endl;
|
||||
|
||||
for
|
||||
(
|
||||
@ -265,7 +252,7 @@ void Foam::DelaunayMeshTools::drawDelaunayCell
|
||||
<< "f " << 1 + offset << " " << 4 + offset << " " << 3 + offset << nl
|
||||
<< "f " << 1 + offset << " " << 2 + offset << " " << 4 + offset << endl;
|
||||
|
||||
// os << "# cicumcentre " << endl;
|
||||
// os << "# circumcentre " << endl;
|
||||
|
||||
// meshTools::writeOBJ(os, c->dual());
|
||||
|
||||
|
||||
@ -900,12 +900,10 @@ void Foam::conformalVoronoiMesh::writeMesh
|
||||
mesh.addFvPatches(patches);
|
||||
|
||||
|
||||
|
||||
// Add zones to the mesh
|
||||
addZones(mesh, cellCentres);
|
||||
|
||||
|
||||
|
||||
Info<< indent << "Add pointZones" << endl;
|
||||
{
|
||||
label sz = mesh.pointZones().size();
|
||||
@ -914,6 +912,9 @@ void Foam::conformalVoronoiMesh::writeMesh
|
||||
|
||||
forAll(dualMeshPointTypeNames_, typeI)
|
||||
{
|
||||
const word& znName =
|
||||
dualMeshPointTypeNames_[dualMeshPointType(typeI)];
|
||||
|
||||
forAll(boundaryPts, ptI)
|
||||
{
|
||||
const label& bPtType = boundaryPts[ptI];
|
||||
@ -928,14 +929,14 @@ void Foam::conformalVoronoiMesh::writeMesh
|
||||
|
||||
Info<< incrIndent << indent
|
||||
<< "Adding " << bPts.size()
|
||||
<< " points of type " << dualMeshPointTypeNames_.words()[typeI]
|
||||
<< " points of type " << znName
|
||||
<< decrIndent << endl;
|
||||
|
||||
mesh.pointZones().append
|
||||
(
|
||||
new pointZone
|
||||
(
|
||||
dualMeshPointTypeNames_.words()[typeI],
|
||||
znName,
|
||||
bPts,
|
||||
sz + typeI,
|
||||
mesh.pointZones()
|
||||
|
||||
@ -102,6 +102,8 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noCheckProcessorDirectories();
|
||||
|
||||
#include "addDictOption.H"
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
@ -229,7 +229,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
|
||||
word patchMapMethod;
|
||||
if (meshToMesh::interpolationMethodNames_.found(mapMethod))
|
||||
if (meshToMesh::interpolationMethodNames_.hasEnum(mapMethod))
|
||||
{
|
||||
// Lookup corresponding AMI method
|
||||
meshToMesh::interpolationMethod method =
|
||||
|
||||
@ -83,7 +83,7 @@ Description
|
||||
#include "edgeIntersections.H"
|
||||
#include "meshTools.H"
|
||||
#include "DynamicField.H"
|
||||
|
||||
#include "Enum.H"
|
||||
|
||||
#ifndef NO_CGAL
|
||||
|
||||
@ -99,7 +99,7 @@ typedef CGAL::AABB_face_graph_triangle_primitive
|
||||
typedef CGAL::AABB_traits<K, Primitive> Traits;
|
||||
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;
|
||||
|
||||
#endif // NO_CGAL
|
||||
@ -477,7 +477,6 @@ label dupNonManifoldPoints(triSurface& s, labelList& pointMap)
|
||||
List<labelledTri> newFaces(s);
|
||||
label nNonManifold = 0;
|
||||
|
||||
|
||||
forAll(pf, pointI)
|
||||
{
|
||||
const labelList& pFaces = pf[pointI];
|
||||
@ -1257,10 +1256,10 @@ autoPtr<extendedFeatureEdgeMesh> createEdgeMesh
|
||||
const triSurface& s1 = surf1;
|
||||
const triSurface& s2 = surf2;
|
||||
|
||||
forAllConstIter(labelPairLookup, inter.facePairToEdge(), iter)
|
||||
forAllConstIters(inter.facePairToEdgeId(), iter)
|
||||
{
|
||||
const label& cutEdgeI = iter();
|
||||
const labelPair& facePair = iter.key();
|
||||
const label cutEdgeI = iter.object();
|
||||
|
||||
const edge& fE = inter.cutEdges()[cutEdgeI];
|
||||
|
||||
@ -1515,8 +1514,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.append("action");
|
||||
argList::validArgs.append("surface file");
|
||||
argList::validArgs.append("surface file");
|
||||
argList::validArgs.append("surfaceFile1");
|
||||
argList::validArgs.append("surfaceFile2");
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
@ -1554,24 +1553,30 @@ int main(int argc, char *argv[])
|
||||
" 'mixed' (keep all)"
|
||||
);
|
||||
|
||||
argList::addNote
|
||||
(
|
||||
"Valid actions: \"intersection\", \"union\", \"difference\""
|
||||
);
|
||||
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
|
||||
const word action(args[1]);
|
||||
|
||||
const HashTable<booleanSurface::booleanOpType> validActions
|
||||
const Enum<booleanSurface::booleanOpType> validActions
|
||||
{
|
||||
{"intersection", booleanSurface::INTERSECTION},
|
||||
{"union", booleanSurface::UNION},
|
||||
{"difference", booleanSurface::DIFFERENCE}
|
||||
{ booleanSurface::INTERSECTION, "intersection" },
|
||||
{ booleanSurface::UNION, "union" },
|
||||
{ booleanSurface::DIFFERENCE, "difference" }
|
||||
};
|
||||
|
||||
if (!validActions.found(action))
|
||||
if (!validActions.hasEnum(action))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unsupported action " << action << endl
|
||||
<< "Supported actions:" << validActions.toc() << abort(FatalError);
|
||||
<< "Supported actions:" << validActions << nl
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
7
applications/utilities/surface/surfaceFeatureExtract/Allwclean
Executable file
7
applications/utilities/surface/surfaceFeatureExtract/Allwclean
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
|
||||
wclean libso extractionMethod
|
||||
wclean .
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
9
applications/utilities/surface/surfaceFeatureExtract/Allwmake
Executable file
9
applications/utilities/surface/surfaceFeatureExtract/Allwmake
Executable 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)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -1,9 +1,11 @@
|
||||
EXE_INC = \
|
||||
-IextractionMethod/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lsurfaceFeatureExtract \
|
||||
-lmeshTools \
|
||||
-lsampling
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
method = .
|
||||
$(method)/surfaceFeaturesExtraction.C
|
||||
$(method)/extractFromFile.C
|
||||
$(method)/extractFromNone.C
|
||||
$(method)/extractFromSurface.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libsurfaceFeatureExtract
|
||||
@ -0,0 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lmeshTools
|
||||
@ -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()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -21,50 +21,64 @@ License
|
||||
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::extractFromNone
|
||||
|
||||
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
|
||||
mergePoints.C
|
||||
extractFromNone.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef mergePoints1_H
|
||||
#define mergePoints1_H
|
||||
#ifndef surfaceFeaturesExtraction_extractFromNone_H
|
||||
#define surfaceFeaturesExtraction_extractFromNone_H
|
||||
|
||||
#include "scalar.H"
|
||||
#include "labelList.H"
|
||||
#include "surfaceFeaturesExtraction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace surfaceFeaturesExtraction
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Function mergePoints Declaration
|
||||
Class surfaceFeaturesExtraction::extractFromNone Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- 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.
|
||||
//template<class Type, template<class> class ListType=UList>
|
||||
template<class Type>
|
||||
label mergePoints
|
||||
(
|
||||
const bool dummy,
|
||||
const UIndirectList<Type>& points,
|
||||
const scalar mergeTol,
|
||||
const bool verbose,
|
||||
labelList& pointMap,
|
||||
const Type& origin = Type::zero
|
||||
);
|
||||
class extractFromNone
|
||||
:
|
||||
public method
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Construct from dictionary
|
||||
extractFromNone(const dictionary& dict);
|
||||
|
||||
//- Destructor
|
||||
virtual ~extractFromNone();
|
||||
|
||||
//- Extracted features from surface (no-op)
|
||||
virtual autoPtr<surfaceFeatures> features
|
||||
(
|
||||
const triSurface& surf
|
||||
) const override;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "mergePoints1.C"
|
||||
#endif
|
||||
} // End namespace surfaceFeaturesExtraction
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -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()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,8 +2,8 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -21,64 +21,66 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InNamspace
|
||||
Foam
|
||||
Class
|
||||
Foam::surfaceFeaturesExtraction::extractFromSurface
|
||||
|
||||
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
|
||||
ListOps.C
|
||||
ListOpsTemplates.C
|
||||
extractFromSurface.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ListOps1_H
|
||||
#define ListOps1_H
|
||||
#ifndef surfaceFeaturesExtraction_extractFromSurface_H
|
||||
#define surfaceFeaturesExtraction_extractFromSurface_H
|
||||
|
||||
#include "ListOps.H"
|
||||
#include "surfaceFeaturesExtraction.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace surfaceFeaturesExtraction
|
||||
{
|
||||
|
||||
//- Reorder the elements (indices, not values) of a list.
|
||||
// Negative ListType elements are untouched, unless pruning has been selected.
|
||||
// With pruning, these elements are skipped and the list shrinks accordingly.
|
||||
template<class ListType>
|
||||
ListType reorder
|
||||
(
|
||||
const labelUList& oldToNew,
|
||||
const ListType&,
|
||||
const bool prune
|
||||
);
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfaceFeaturesExtraction::extractFromSurface Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- Inplace reorder the elements of a list.
|
||||
// Negative ListType elements are untouched, unless pruning has been selected.
|
||||
// With pruning, these elements are skipped and the list shrinks accordingly.
|
||||
template<class ListType>
|
||||
void inplaceReorder
|
||||
(
|
||||
const labelUList& oldToNew,
|
||||
ListType&,
|
||||
const bool prune
|
||||
);
|
||||
class extractFromSurface
|
||||
:
|
||||
public method
|
||||
{
|
||||
public:
|
||||
|
||||
//- Construct from dictionary
|
||||
extractFromSurface(const dictionary& dict);
|
||||
|
||||
//- Destructor
|
||||
virtual ~extractFromSurface();
|
||||
|
||||
//- Features extracted from surface
|
||||
virtual autoPtr<surfaceFeatures> features
|
||||
(
|
||||
const triSurface& surf
|
||||
) const override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace surfaceFeaturesExtraction
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ListOps1Templates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
@ -16,38 +16,60 @@ FoamFile
|
||||
|
||||
surface1.stl
|
||||
{
|
||||
// How to obtain raw features (extractFromFile || extractFromSurface)
|
||||
// Extract raw features (none | extractFromFile | extractFromSurface)
|
||||
extractionMethod extractFromSurface;
|
||||
|
||||
extractFromSurfaceCoeffs
|
||||
{
|
||||
// Mark edges whose adjacent surface normals are at an angle less
|
||||
// than includedAngle as features
|
||||
// - 0 : selects no edges
|
||||
// - 180: selects all edges
|
||||
includedAngle 120;
|
||||
// Mark edges whose adjacent surface normals are at an angle less
|
||||
// than includedAngle as features
|
||||
// - 0 : selects no edges
|
||||
// - 180: selects all edges
|
||||
includedAngle 120;
|
||||
|
||||
// Do not mark region edges
|
||||
geometricTestOnly yes;
|
||||
}
|
||||
// Do not mark region edges
|
||||
geometricTestOnly yes;
|
||||
|
||||
// Write options
|
||||
// Generate additional intersection features (none | self | region)
|
||||
intersectionMethod none;
|
||||
|
||||
// Write features to obj format for postprocessing
|
||||
writeObj yes;
|
||||
// Tolerance for surface intersections
|
||||
// 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
|
||||
{
|
||||
// How to obtain raw features (extractFromFile || extractFromSurface)
|
||||
// Extract raw features (none | extractFromFile | extractFromSurface)
|
||||
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
|
||||
{
|
||||
@ -60,57 +82,57 @@ surface2.nas
|
||||
|
||||
subsetFeatures
|
||||
{
|
||||
// Use a plane to select feature edges
|
||||
// (normal)(basePoint)
|
||||
// Keep only edges that intersect the plane will be included
|
||||
plane (1 0 0)(0 0 0);
|
||||
// Use a plane to select feature edges (normal)(basePoint)
|
||||
// Only keep edges that intersect the plane
|
||||
plane (1 0 0)(0 0 0);
|
||||
|
||||
// Select feature edges using a box
|
||||
// (minPt)(maxPt)
|
||||
// Keep edges inside the box:
|
||||
insideBox (0 0 0)(1 1 1);
|
||||
// Keep edges outside the box:
|
||||
outsideBox (0 0 0)(1 1 1);
|
||||
// Select feature edges using a box // (minPt)(maxPt)
|
||||
// Only keep edges inside the box:
|
||||
insideBox (0 0 0)(1 1 1);
|
||||
|
||||
// Only keep edges outside the box:
|
||||
outsideBox (0 0 0)(1 1 1);
|
||||
|
||||
// Keep nonManifold edges (edges with >2 connected faces where
|
||||
// the faces form more than two different normal planes)
|
||||
nonManifoldEdges yes;
|
||||
nonManifoldEdges yes;
|
||||
|
||||
// Keep open edges (edges with 1 connected face)
|
||||
openEdges yes;
|
||||
openEdges yes;
|
||||
}
|
||||
|
||||
addFeatures
|
||||
{
|
||||
// Add (without merging) another extendedFeatureEdgeMesh
|
||||
name axZ.extendedFeatureEdgeMesh;
|
||||
|
||||
// Optionally flip features (invert all normals, making
|
||||
// convex<->concave etc)
|
||||
//flip false;
|
||||
name axZ.extendedFeatureEdgeMesh;
|
||||
}
|
||||
|
||||
// Output the curvature of the surface
|
||||
curvature no;
|
||||
|
||||
// Output the proximity of feature points and edges to each other
|
||||
featureProximity no;
|
||||
// Generate additional intersection features (none | self | region)
|
||||
intersectionMethod none;
|
||||
|
||||
// The maximum search distance to use when looking for other feature
|
||||
// points and edges
|
||||
maxFeatureProximity 1;
|
||||
// Tolerance for surface intersections
|
||||
// tolerance 1e-3;
|
||||
|
||||
// Out put the closeness of surface elements to other surface elements.
|
||||
closeness no;
|
||||
// Output options:
|
||||
|
||||
// Write options
|
||||
// Output the closeness of surface elements to other surface elements.
|
||||
closeness no;
|
||||
|
||||
// Write features to obj format for postprocessing
|
||||
writeObj yes;
|
||||
// Output surface curvature
|
||||
curvature no;
|
||||
|
||||
// Write surface proximity and curvature fields to vtk format
|
||||
// for postprocessing
|
||||
writeVTK no;
|
||||
// Output the proximity of feature points and edges to another
|
||||
featureProximity 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -129,8 +129,7 @@ void dumpFaces
|
||||
const Map<label>& connectedFaces
|
||||
)
|
||||
{
|
||||
Info<< "Dumping connectedFaces as Lightwave .obj file to " << fName
|
||||
<< "\nThis can be visualized with e.g. javaview (www.javaview.de)\n\n";
|
||||
Info<< "Dumping connectedFaces as .obj file to " << fName << nl;
|
||||
|
||||
OFstream os(fName);
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
|
||||
|
||||
set boost_version=boost_1_62_0
|
||||
set cgal_version=CGAL-4.9
|
||||
set boost_version=boost_1_64_0
|
||||
set cgal_version=CGAL-4.9.1
|
||||
|
||||
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
|
||||
|
||||
@ -66,6 +66,9 @@ case ThirdParty:
|
||||
case Gcc63:
|
||||
set gcc_version=gcc-6.3.0
|
||||
breaksw
|
||||
case Gcc71:
|
||||
set gcc_version=gcc-7.1.0
|
||||
breaksw
|
||||
case Clang:
|
||||
set clang_version=llvm-3.7.1
|
||||
breaksw
|
||||
|
||||
@ -50,8 +50,8 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
|
||||
|
||||
boost_version=boost_1_62_0
|
||||
cgal_version=CGAL-4.9
|
||||
boost_version=boost_1_64_0
|
||||
cgal_version=CGAL-4.9.1
|
||||
|
||||
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
|
||||
|
||||
@ -65,6 +65,9 @@ ThirdParty)
|
||||
Gcc63)
|
||||
gcc_version=gcc-6.3.0
|
||||
;;
|
||||
Gcc71)
|
||||
gcc_version=gcc-7.1.0
|
||||
;;
|
||||
Clang)
|
||||
clang_version=llvm-3.7.1
|
||||
;;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inewt)
|
||||
|
||||
if (s)
|
||||
{
|
||||
if (2*s > this->tableSize_)
|
||||
if (2*s > this->capacity())
|
||||
{
|
||||
this->resize(2*s);
|
||||
}
|
||||
|
||||
@ -29,7 +29,6 @@ License
|
||||
#include "HashTable.H"
|
||||
#include "List.H"
|
||||
#include "FixedList.H"
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -112,14 +111,14 @@ Foam::HashTable<T, Key, Hash>::HashTable
|
||||
template<class T, class Key, class Hash>
|
||||
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())
|
||||
{
|
||||
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>
|
||||
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()
|
||||
@ -904,7 +903,7 @@ void Foam::HashTable<T, Key, Hash>::operator=
|
||||
|
||||
for (const auto& pair : lst)
|
||||
{
|
||||
insert(pair.first(), pair.second());
|
||||
insert(pair.first, pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -57,11 +57,13 @@ SourceFiles
|
||||
#include "uLabel.H"
|
||||
#include "word.H"
|
||||
#include "Xfer.H"
|
||||
#include "Hash.H"
|
||||
#include "className.H"
|
||||
#include "nullObject.H"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -73,7 +75,6 @@ namespace Foam
|
||||
template<class T> class List;
|
||||
template<class T> class UList;
|
||||
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>
|
||||
@ -212,7 +213,7 @@ private:
|
||||
|
||||
// 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
|
||||
{
|
||||
//- The lookup key
|
||||
@ -224,7 +225,7 @@ private:
|
||||
//- Pointer to next hashedEntry in sub-list
|
||||
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);
|
||||
|
||||
private:
|
||||
@ -296,7 +297,7 @@ public:
|
||||
HashTable(const Xfer<HashTable<T, Key, Hash>>& ht);
|
||||
|
||||
//- Construct from an initializer list
|
||||
HashTable(std::initializer_list<Tuple2<Key, T>> lst);
|
||||
HashTable(std::initializer_list<std::pair<Key, T>> lst);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -558,7 +559,7 @@ public:
|
||||
void operator=(const HashTable<T, Key, Hash>& rhs);
|
||||
|
||||
//- 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.
|
||||
// Independent of table storage size and table order.
|
||||
|
||||
@ -96,7 +96,7 @@ public:
|
||||
{}
|
||||
|
||||
//- 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)
|
||||
{}
|
||||
|
||||
@ -57,25 +57,41 @@ static const List<Type>& emptyList()
|
||||
|
||||
|
||||
//- 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>
|
||||
ListType renumber(const labelUList& oldToNew, const ListType& lst);
|
||||
|
||||
//- Inplace renumber the values of a list.
|
||||
// Negative ListType elements are left as is.
|
||||
//- Inplace renumber the values (not the indices) of a list.
|
||||
// Negative ListType elements are left untouched.
|
||||
template<class ListType>
|
||||
void inplaceRenumber(const labelUList& oldToNew, ListType& lst);
|
||||
|
||||
|
||||
//- Reorder the elements (indices, not values) of a list.
|
||||
// Negative ListType elements are left as is.
|
||||
//- Reorder the elements of a list.
|
||||
// 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>
|
||||
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.
|
||||
// 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>
|
||||
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.
|
||||
@ -156,12 +172,20 @@ void inplaceSubset(const BoolListType& select, ListType& lst);
|
||||
//- Copy a subset of the input list when predicate is true.
|
||||
// Do not use FixedList for the input list, since it doesn't resize.
|
||||
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.
|
||||
// Do not use FixedList for the input list, since it doesn't resize.
|
||||
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.
|
||||
|
||||
@ -70,23 +70,42 @@ template<class ListType>
|
||||
ListType Foam::reorder
|
||||
(
|
||||
const labelUList& oldToNew,
|
||||
const ListType& lst
|
||||
const ListType& lst,
|
||||
const bool prune
|
||||
)
|
||||
{
|
||||
ListType newLst(lst.size());
|
||||
newLst.setSize(lst.size()); // Consistent sizes (eg, DynamicList)
|
||||
const label sz = lst.size();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -95,24 +114,42 @@ template<class ListType>
|
||||
void Foam::inplaceReorder
|
||||
(
|
||||
const labelUList& oldToNew,
|
||||
ListType& lst
|
||||
ListType& lst,
|
||||
const bool prune
|
||||
)
|
||||
{
|
||||
ListType newLst(lst.size());
|
||||
newLst.setSize(lst.size()); // Consistent sizing (eg, DynamicList)
|
||||
const label sz = lst.size();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -126,9 +163,13 @@ void Foam::inplaceMapValue
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
(
|
||||
const ListType& lst,
|
||||
UnaryPredicate pred
|
||||
const UnaryPredicate& pred
|
||||
)
|
||||
{
|
||||
ListType newLst(lst.size());
|
||||
@ -447,7 +492,7 @@ template<class ListType, class UnaryPredicate>
|
||||
void Foam::inplaceSubsetList
|
||||
(
|
||||
ListType& lst,
|
||||
UnaryPredicate pred
|
||||
const UnaryPredicate& pred
|
||||
)
|
||||
{
|
||||
label nElem = 0;
|
||||
|
||||
@ -286,7 +286,7 @@ Foam::Xfer<Foam::labelList> Foam::PackedBoolList::used() const
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::PackedBoolList::operator=(const Foam::UList<bool>& lst)
|
||||
void Foam::PackedBoolList::operator=(const UList<bool>& lst)
|
||||
{
|
||||
this->setSize(lst.size());
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ public:
|
||||
inline PackedBoolList();
|
||||
|
||||
//- Construct from Istream
|
||||
PackedBoolList(Istream&);
|
||||
PackedBoolList(Istream& is);
|
||||
|
||||
//- Construct with given size, initializes list to 0
|
||||
explicit inline PackedBoolList(const label size);
|
||||
@ -103,19 +103,19 @@ public:
|
||||
inline PackedBoolList(const label size, const bool val);
|
||||
|
||||
//- Copy constructor
|
||||
inline PackedBoolList(const PackedBoolList&);
|
||||
inline PackedBoolList(const PackedBoolList& lst);
|
||||
|
||||
//- Copy constructor
|
||||
explicit inline PackedBoolList(const PackedList<1>&);
|
||||
explicit inline PackedBoolList(const PackedList<1>& lst);
|
||||
|
||||
//- Construct by transferring the parameter contents
|
||||
inline PackedBoolList(const Xfer<PackedBoolList>&);
|
||||
inline PackedBoolList(const Xfer<PackedBoolList>& lst);
|
||||
|
||||
//- 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
|
||||
explicit inline PackedBoolList(const Foam::UList<bool>&);
|
||||
explicit inline PackedBoolList(const UList<bool>& lst);
|
||||
|
||||
//- Construct from a list of labels
|
||||
// using the labels as indices to indicate which bits are set
|
||||
@ -131,132 +131,132 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
using PackedList<1>::set;
|
||||
using PackedList<1>::unset;
|
||||
using PackedList<1>::set;
|
||||
using PackedList<1>::unset;
|
||||
|
||||
//- Set specified bits.
|
||||
void set(const PackedList<1>&);
|
||||
//- Set specified bits.
|
||||
void set(const PackedList<1>& lst);
|
||||
|
||||
//- Set the listed indices. Return number of elements changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
label set(const labelUList& indices);
|
||||
//- Set the listed indices. Return number of elements changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
label set(const labelUList& indices);
|
||||
|
||||
//- Set the listed indices. Return number of elements changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
label set(const UIndirectList<label>& indices);
|
||||
//- Set the listed indices. Return number of elements changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
label set(const UIndirectList<label>& indices);
|
||||
|
||||
//- Unset specified bits.
|
||||
void unset(const PackedList<1>&);
|
||||
//- Unset specified bits.
|
||||
void unset(const PackedList<1>& lst);
|
||||
|
||||
//- Unset the listed indices. Return number of elements changed.
|
||||
// Never auto-vivify entries.
|
||||
label unset(const labelUList& indices);
|
||||
//- Unset the listed indices. Return number of elements changed.
|
||||
// Never auto-vivify entries.
|
||||
label unset(const labelUList& indices);
|
||||
|
||||
//- Unset the listed indices. Return number of elements changed.
|
||||
// Never auto-vivify entries.
|
||||
label unset(const UIndirectList<label>& indices);
|
||||
//- Unset the listed indices. Return number of elements changed.
|
||||
// Never auto-vivify entries.
|
||||
label unset(const UIndirectList<label>& indices);
|
||||
|
||||
//- Subset with the specified list.
|
||||
void subset(const PackedList<1>&);
|
||||
//- Subset with the specified list.
|
||||
void subset(const PackedList<1>& lst);
|
||||
|
||||
//- Subset with the listed indices.
|
||||
// Return number of elements subsetted.
|
||||
label subset(const labelUList& indices);
|
||||
//- Subset with the listed indices.
|
||||
// Return number of elements subsetted.
|
||||
label subset(const labelUList& indices);
|
||||
|
||||
//- Subset with the listed indices.
|
||||
// Return number of elements subsetted.
|
||||
label subset(const UIndirectList<label>& indices);
|
||||
//- Subset with the listed indices.
|
||||
// Return number of elements subsetted.
|
||||
label subset(const UIndirectList<label>& indices);
|
||||
|
||||
|
||||
//- Return indices of the used (true) elements as a list of labels
|
||||
Xfer<labelList> used() const;
|
||||
//- Return indices of the used (true) elements as a list of labels
|
||||
Xfer<labelList> used() const;
|
||||
|
||||
|
||||
// Edit
|
||||
// Edit
|
||||
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedBoolList&);
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedBoolList& lst);
|
||||
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedList<1>&);
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedList<1>& lst);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedBoolList> xfer();
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedBoolList> xfer();
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assignment of all entries to the given value.
|
||||
inline void operator=(const bool val);
|
||||
//- Assignment of all entries to the given value.
|
||||
inline void operator=(const bool val);
|
||||
|
||||
//- Assignment operator.
|
||||
inline void operator=(const PackedBoolList&);
|
||||
//- Assignment operator.
|
||||
inline void operator=(const PackedBoolList& lst);
|
||||
|
||||
//- Assignment operator.
|
||||
inline void operator=(const PackedList<1>&);
|
||||
//- Assignment operator.
|
||||
inline void operator=(const PackedList<1>& lst);
|
||||
|
||||
//- Assignment operator.
|
||||
void operator=(const Foam::UList<bool>&);
|
||||
//- Assignment operator.
|
||||
void operator=(const UList<bool>& lst);
|
||||
|
||||
//- Assignment operator,
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline void operator=(const labelUList& indices);
|
||||
//- Assignment operator,
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline void operator=(const labelUList& indices);
|
||||
|
||||
//- Assignment operator,
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline void operator=(const UIndirectList<label>&);
|
||||
//- Assignment operator,
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline void operator=(const UIndirectList<label>& indices);
|
||||
|
||||
//- Complement operator
|
||||
inline PackedBoolList operator~() const;
|
||||
//- Complement operator
|
||||
inline PackedBoolList operator~() const;
|
||||
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
inline PackedBoolList& operator&=(const PackedList<1>&);
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
inline PackedBoolList& operator&=(const PackedList<1>& lst);
|
||||
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator&=(const labelUList& indices);
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator&=(const labelUList& indices);
|
||||
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator&=(const UIndirectList<label>&);
|
||||
//- And operator (lists may be dissimilar sizes)
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator&=(const UIndirectList<label>& indices);
|
||||
|
||||
//- Xor operator (lists may be dissimilar sizes)
|
||||
// Retains unique entries
|
||||
PackedBoolList& operator^=(const PackedList<1>&);
|
||||
//- Xor operator (lists may be dissimilar sizes)
|
||||
// Retains unique entries
|
||||
PackedBoolList& operator^=(const PackedList<1>& lst);
|
||||
|
||||
//- Or operator (lists may be dissimilar sizes)
|
||||
inline PackedBoolList& operator|=(const PackedList<1>&);
|
||||
//- Or operator (lists may be dissimilar sizes)
|
||||
inline PackedBoolList& operator|=(const PackedList<1>& lst);
|
||||
|
||||
//- Or operator (lists may be dissimilar sizes),
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator|=(const labelUList& indices);
|
||||
//- Or operator (lists may be dissimilar sizes),
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator|=(const labelUList& indices);
|
||||
|
||||
//- Or operator (lists may be dissimilar sizes),
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator|=(const UIndirectList<label>&);
|
||||
//- Or operator (lists may be dissimilar sizes),
|
||||
// using the labels as indices to indicate which bits are set
|
||||
inline PackedBoolList& operator|=(const UIndirectList<label>& indices);
|
||||
|
||||
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const PackedList<1>&);
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const PackedList<1>& lst);
|
||||
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const labelUList& indices);
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const labelUList& indices);
|
||||
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const UIndirectList<label>&);
|
||||
//- Add entries to this list, synonymous with the or operator
|
||||
inline PackedBoolList& operator+=(const UIndirectList<label>& indices);
|
||||
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const PackedList<1>&);
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const PackedList<1>& lst);
|
||||
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const labelUList& indices);
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const labelUList& indices);
|
||||
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const UIndirectList<label>&);
|
||||
//- Remove entries from this list - unset the specified bits
|
||||
inline PackedBoolList& operator-=(const UIndirectList<label>& indices);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -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>()
|
||||
{
|
||||
|
||||
@ -118,9 +118,9 @@ class Ostream;
|
||||
template<unsigned nBits> class PackedList;
|
||||
|
||||
template<unsigned nBits>
|
||||
Istream& operator>>(Istream&, PackedList<nBits>&);
|
||||
Istream& operator>>(Istream& is, PackedList<nBits>& lst);
|
||||
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);
|
||||
|
||||
//- 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.
|
||||
// For bool specialization, read a single index value
|
||||
inline void setPair(Istream&);
|
||||
inline void setPair(Istream& is);
|
||||
|
||||
|
||||
private:
|
||||
@ -252,167 +252,167 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- The number of elements that can be stored before reallocating
|
||||
inline label capacity() const;
|
||||
//- The number of elements that can be stored before reallocating
|
||||
inline label capacity() const;
|
||||
|
||||
//- Number of entries.
|
||||
inline label size() const;
|
||||
//- Number of entries.
|
||||
inline label size() const;
|
||||
|
||||
//- Return true if the list is empty (ie, size() is zero).
|
||||
inline bool empty() const;
|
||||
//- Return true if the list is empty (ie, size() is zero).
|
||||
inline bool empty() const;
|
||||
|
||||
//- Get value at index I.
|
||||
// Never auto-vivify entries.
|
||||
inline unsigned int get(const label i) const;
|
||||
//- Get value at index I.
|
||||
// Never auto-vivify entries.
|
||||
inline unsigned int get(const label i) const;
|
||||
|
||||
//- Set value at index I. Return true if value changed.
|
||||
// Does auto-vivify for non-existent entries.
|
||||
// Default value set is the max_value.
|
||||
inline bool set(const label i, const unsigned int val = ~0u);
|
||||
//- Set value at index I. Return true if value changed.
|
||||
// Does auto-vivify for non-existent, non-zero entries.
|
||||
// Default value set is the max_value.
|
||||
inline bool set(const label i, const unsigned int val = ~0u);
|
||||
|
||||
//- Unset the entry at index I. Return true if value changed.
|
||||
// Never auto-vivify entries.
|
||||
inline bool unset(const label i);
|
||||
//- Unset the entry at index I. Return true if value changed.
|
||||
// Never auto-vivify entries.
|
||||
inline bool unset(const label i);
|
||||
|
||||
//- Return the underlying packed storage
|
||||
// Manipulate with utmost caution
|
||||
inline List<unsigned int>& storage();
|
||||
//- Return the underlying packed storage
|
||||
// Manipulate with utmost caution
|
||||
inline List<unsigned int>& storage();
|
||||
|
||||
//- Return the underlying packed storage
|
||||
inline const List<unsigned int>& storage() const;
|
||||
//- Return the underlying packed storage
|
||||
inline const List<unsigned int>& storage() const;
|
||||
|
||||
//- The list length when packed
|
||||
inline label packedLength() const;
|
||||
//- The list length when packed
|
||||
inline label packedLength() const;
|
||||
|
||||
//- Return the binary size in number of characters
|
||||
// used in the underlying storage
|
||||
inline std::streamsize byteSize() const;
|
||||
//- Return the binary size in number of characters
|
||||
// used in the underlying storage
|
||||
inline std::streamsize byteSize() const;
|
||||
|
||||
//- Count number of bits set, O(log(n))
|
||||
// Uses the Hamming weight (population count) method
|
||||
// http://en.wikipedia.org/wiki/Hamming_weight
|
||||
unsigned int count() const;
|
||||
//- Count number of bits set, O(log(n))
|
||||
// Uses the Hamming weight (population count) method
|
||||
// http://en.wikipedia.org/wiki/Hamming_weight
|
||||
unsigned int count() const;
|
||||
|
||||
//- Return the values as a list of labels
|
||||
Xfer<labelList> values() const;
|
||||
//- Return the values as a list of labels
|
||||
Xfer<labelList> values() const;
|
||||
|
||||
//- Print bit patterns, optionally output unused elements
|
||||
//
|
||||
// addressable bits:
|
||||
// on: '1', off: '-'
|
||||
//
|
||||
// non-addressable bits:
|
||||
// on: '!', off: '.'
|
||||
//
|
||||
Ostream& printBits(Ostream&, const bool fullOutput=false) const;
|
||||
//- Print bit patterns, optionally output unused elements
|
||||
//
|
||||
// addressable bits:
|
||||
// on: '1', off: '-'
|
||||
//
|
||||
// non-addressable bits:
|
||||
// on: '!', off: '.'
|
||||
//
|
||||
Ostream& printBits(Ostream& os, const bool fullOutput=false) const;
|
||||
|
||||
//- Print information and bit patterns (with printBits)
|
||||
Ostream& printInfo(Ostream&, const bool fullOutput=false) const;
|
||||
//- Print information and bit patterns (with printBits)
|
||||
Ostream& printInfo(Ostream& os, const bool fullOutput=false) const;
|
||||
|
||||
|
||||
// Edit
|
||||
// Edit
|
||||
|
||||
//- Trim any trailing zero elements
|
||||
bool trim();
|
||||
//- Trim any trailing zero elements
|
||||
bool trim();
|
||||
|
||||
//- Invert the bits in the addressable region
|
||||
void flip();
|
||||
//- Invert the bits in the addressable region
|
||||
void flip();
|
||||
|
||||
//- Clear all bits
|
||||
inline void reset();
|
||||
//- Clear all bits
|
||||
inline void reset();
|
||||
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
inline void setCapacity(const label);
|
||||
//- Alter the size of the underlying storage.
|
||||
// The addressed size will be truncated if needed to fit, but will
|
||||
// remain otherwise untouched.
|
||||
inline void setCapacity(const label nElem);
|
||||
|
||||
//- Reset addressable list size, does not shrink the allocated size.
|
||||
// Optionally specify a value for new elements.
|
||||
inline void resize(const label, const unsigned int val = 0u);
|
||||
//- Reset addressable list size, does not shrink the allocated size.
|
||||
// Optionally specify a value for new elements.
|
||||
inline void resize(const label nElem, const unsigned int val = 0u);
|
||||
|
||||
//- Alias for resize()
|
||||
inline void setSize(const label, const unsigned int val = 0u);
|
||||
//- Alias for resize()
|
||||
inline void setSize(const label nElem, const unsigned int val = 0u);
|
||||
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size.
|
||||
// The list size is adjusted as per DynamicList with
|
||||
// SizeInc=0, SizeMult=2, SizeDiv=1
|
||||
inline void reserve(const label);
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size.
|
||||
// The list size is adjusted as per DynamicList with
|
||||
// SizeInc=0, SizeMult=2, SizeDiv=1
|
||||
inline void reserve(const label nElem);
|
||||
|
||||
//- Clear the list, i.e. set addressable size to zero.
|
||||
// Does not adjust the underlying storage
|
||||
inline void clear();
|
||||
//- Clear the list, i.e. set addressable size to zero.
|
||||
// Does not adjust the underlying storage
|
||||
inline void clear();
|
||||
|
||||
//- Clear the list and delete storage.
|
||||
inline void clearStorage();
|
||||
//- Clear the list and delete storage.
|
||||
inline void clearStorage();
|
||||
|
||||
//- Shrink the allocated space to what is actually used.
|
||||
inline void shrink();
|
||||
//- Shrink the allocated space to what is actually used.
|
||||
inline void shrink();
|
||||
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedList<nBits>&);
|
||||
//- Transfer the contents of the argument list into this list
|
||||
// and annul the argument list.
|
||||
inline void transfer(PackedList<nBits>& lst);
|
||||
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedList<nBits>> xfer();
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedList<nBits>> xfer();
|
||||
|
||||
|
||||
// IO
|
||||
// IO
|
||||
|
||||
//- Clear list and read from stream
|
||||
Istream& read(Istream& is);
|
||||
//- Clear list and read from stream
|
||||
Istream& read(Istream& is);
|
||||
|
||||
//- Write the List, with line-breaks in ASCII if the list length
|
||||
// exceeds shortListLen. Using '0' suppresses line-breaks entirely.
|
||||
// A special indexed output (ASCII only) is triggered by specifying
|
||||
// a negative value for shortListLen.
|
||||
//
|
||||
// The indexed output may be convenient in some situations.
|
||||
// The general format is a group of index/value pairs:
|
||||
// \verbatim
|
||||
// { (index1 value1) (index2 value2) (index3 value3) }
|
||||
// \endverbatim
|
||||
// The bool specialization just uses the indices corresponding to
|
||||
// non-zero entries instead of a index/value pair:
|
||||
// \verbatim
|
||||
// { index1 index2 index3 }
|
||||
// \endverbatim
|
||||
Ostream& writeList(Ostream& os, const label shortListLen=0) const;
|
||||
//- Write the List, with line-breaks in ASCII if the list length
|
||||
// exceeds shortListLen. Using '0' suppresses line-breaks entirely.
|
||||
// A special indexed output (ASCII only) is triggered by specifying
|
||||
// a negative value for shortListLen.
|
||||
//
|
||||
// The indexed output may be convenient in some situations.
|
||||
// The general format is a group of index/value pairs:
|
||||
// \verbatim
|
||||
// { (index1 value1) (index2 value2) (index3 value3) }
|
||||
// \endverbatim
|
||||
// The bool specialization just uses the indices corresponding to
|
||||
// non-zero entries instead of a index/value pair:
|
||||
// \verbatim
|
||||
// { index1 index2 index3 }
|
||||
// \endverbatim
|
||||
Ostream& writeList(Ostream& os, const label shortListLen=0) const;
|
||||
|
||||
//- Write as a dictionary entry with keyword
|
||||
void writeEntry(const word& keyword, Ostream& os) const;
|
||||
//- Write as a dictionary entry with keyword
|
||||
void writeEntry(const word& keyword, Ostream& os) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
// Member operators
|
||||
|
||||
//- Append a value at the end of the list
|
||||
inline PackedList<nBits>& append(const unsigned int val);
|
||||
//- Append a value at the end of the list
|
||||
inline PackedList<nBits>& append(const unsigned int val);
|
||||
|
||||
//- Remove and return the last element
|
||||
inline unsigned int remove();
|
||||
//- Remove and return the last element
|
||||
inline unsigned int remove();
|
||||
|
||||
//- Get value at index I
|
||||
// Never auto-vivify entries.
|
||||
inline unsigned int operator[](const label i) const;
|
||||
//- Get value at index I
|
||||
// Never auto-vivify entries.
|
||||
inline unsigned int operator[](const label i) const;
|
||||
|
||||
//- Set value at index I.
|
||||
// Returns iterator to perform the actual operation.
|
||||
// Does not auto-vivify entries, but will when assigned to.
|
||||
inline iteratorBase operator[](const label i);
|
||||
//- Set value at index I.
|
||||
// Returns iterator to perform the actual operation.
|
||||
// Does not auto-vivify entries, but will when assigned to.
|
||||
inline iteratorBase operator[](const label i);
|
||||
|
||||
//- Assignment of all entries to the given value. Takes linear time.
|
||||
inline void operator=(const unsigned int val);
|
||||
//- Assignment of all entries to the given value. Takes linear time.
|
||||
inline void operator=(const unsigned int val);
|
||||
|
||||
//- Assignment operator.
|
||||
void operator=(const PackedList<nBits>& lst);
|
||||
//- Assignment operator.
|
||||
void operator=(const PackedList<nBits>& lst);
|
||||
|
||||
//- Assignment operator.
|
||||
void operator=(const labelUList& lst);
|
||||
//- Assignment operator.
|
||||
void operator=(const labelUList& lst);
|
||||
|
||||
//- Assignment operator.
|
||||
void operator=(const UIndirectList<label>& lst);
|
||||
//- Assignment operator.
|
||||
void operator=(const UIndirectList<label>& lst);
|
||||
|
||||
|
||||
// Iterators and helpers
|
||||
@ -442,7 +442,7 @@ public:
|
||||
inline unsigned int get() const;
|
||||
|
||||
//- Set value, returning true if changed, no range-checking
|
||||
inline bool set(unsigned int);
|
||||
inline bool set(unsigned int val);
|
||||
|
||||
|
||||
// Constructors
|
||||
@ -451,7 +451,7 @@ public:
|
||||
inline iteratorBase();
|
||||
|
||||
//- Construct from base list and position index
|
||||
inline iteratorBase(const PackedList*, const label);
|
||||
inline iteratorBase(const PackedList* lst, const label i);
|
||||
|
||||
|
||||
public:
|
||||
@ -463,17 +463,17 @@ public:
|
||||
|
||||
//- Write index/value for a non-zero entry
|
||||
// The bool specialization writes the index only
|
||||
inline bool writeIfSet(Ostream&) const;
|
||||
inline bool writeIfSet(Ostream& os) const;
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Compare values (not positions)
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
inline bool operator==(const iteratorBase& iter) const;
|
||||
inline bool operator!=(const iteratorBase& iter) const;
|
||||
|
||||
//- Assign value, not position.
|
||||
// This allows packed[0] = packed[3] for assigning values
|
||||
inline void operator=(const iteratorBase&);
|
||||
inline void operator=(const iteratorBase& iter);
|
||||
|
||||
//- Assign value.
|
||||
// A non-existent entry will be auto-vivified.
|
||||
@ -484,7 +484,7 @@ public:
|
||||
inline operator unsigned int () const;
|
||||
|
||||
//- Print information and values
|
||||
Ostream& printInfo(Ostream&) const;
|
||||
Ostream& printInfo(Ostream& os) const;
|
||||
};
|
||||
|
||||
|
||||
@ -496,11 +496,11 @@ public:
|
||||
|
||||
//- Disallow copy constructor from const_iterator
|
||||
// This would violate const-ness!
|
||||
iterator(const const_iterator&);
|
||||
iterator(const const_iterator& iter);
|
||||
|
||||
//- Disallow assignment from const_iterator
|
||||
// This would violate const-ness!
|
||||
void operator=(const const_iterator&);
|
||||
void operator=(const const_iterator& iter);
|
||||
|
||||
|
||||
public:
|
||||
@ -513,21 +513,21 @@ public:
|
||||
//- Construct from iterator base, eg iter(packedlist[i])
|
||||
// but also "iterator iter = packedlist[i];"
|
||||
// An out-of-range iterator is assigned end()
|
||||
inline iterator(const iteratorBase&);
|
||||
inline iterator(const iteratorBase& iter);
|
||||
|
||||
//- Construct from base list and position index
|
||||
inline iterator(const PackedList*, const label);
|
||||
inline iterator(const PackedList* lst, const label i);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Compare positions (not values)
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
inline bool operator==(const iteratorBase& iter) const;
|
||||
inline bool operator!=(const iteratorBase& iter) const;
|
||||
|
||||
//- Assign from iteratorBase, eg iter = packedlist[i]
|
||||
// An out-of-range iterator is assigned end()
|
||||
inline void operator=(const iteratorBase&);
|
||||
inline void operator=(const iteratorBase& iter);
|
||||
|
||||
//- Return value
|
||||
inline unsigned int operator*() const;
|
||||
@ -571,24 +571,24 @@ public:
|
||||
//- Construct from iterator base, eg iter(packedlist[i])
|
||||
// but also "const_iterator iter = packedlist[i];"
|
||||
// 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
|
||||
inline const_iterator(const PackedList*, const label);
|
||||
inline const_iterator(const PackedList* lst, const label i);
|
||||
|
||||
//- Construct from iterator
|
||||
inline const_iterator(const iterator&);
|
||||
inline const_iterator(const iterator& iter);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Compare positions (not values)
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
inline bool operator==(const iteratorBase& iter) const;
|
||||
inline bool operator!=(const iteratorBase& iter) const;
|
||||
|
||||
//- Assign from iteratorBase or derived
|
||||
// eg, iter = packedlist[i] or even iter = list.begin()
|
||||
inline void operator=(const iteratorBase&);
|
||||
inline void operator=(const iteratorBase& iter);
|
||||
|
||||
//- Return referenced value directly
|
||||
inline unsigned int operator*() const;
|
||||
@ -621,14 +621,14 @@ public:
|
||||
|
||||
friend Istream& operator>> <nBits>
|
||||
(
|
||||
Istream&,
|
||||
PackedList<nBits>&
|
||||
Istream& is,
|
||||
PackedList<nBits>& lst
|
||||
);
|
||||
|
||||
friend Ostream& operator<< <nBits>
|
||||
(
|
||||
Ostream&,
|
||||
const PackedList<nBits>&
|
||||
Ostream& os,
|
||||
const PackedList<nBits>& lst
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@ -267,7 +267,7 @@ Foam::PackedList<nBits>::clone() const
|
||||
template<unsigned nBits>
|
||||
inline Foam::PackedList<nBits>::iteratorBase::iteratorBase()
|
||||
:
|
||||
list_(0),
|
||||
list_(nullptr),
|
||||
index_(0)
|
||||
{}
|
||||
|
||||
@ -1002,6 +1002,12 @@ inline bool Foam::PackedList<nBits>::set
|
||||
}
|
||||
else if (i >= size_)
|
||||
{
|
||||
if (!val)
|
||||
{
|
||||
// Same as unset out-of-bounds = noop
|
||||
return false;
|
||||
}
|
||||
|
||||
// Lazy evaluation - increase size on assigment
|
||||
resize(i + 1);
|
||||
}
|
||||
@ -1013,7 +1019,7 @@ inline bool Foam::PackedList<nBits>::set
|
||||
template<unsigned nBits>
|
||||
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_)
|
||||
{
|
||||
return false;
|
||||
|
||||
@ -43,6 +43,7 @@ License
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::argList::bannerEnabled_ = true;
|
||||
bool Foam::argList::checkProcessorDirectories_ = true;
|
||||
Foam::SLList<Foam::string> Foam::argList::validArgs;
|
||||
Foam::HashTable<Foam::string> Foam::argList::validOptions;
|
||||
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
|
||||
(
|
||||
const label location,
|
||||
@ -759,7 +766,7 @@ void Foam::argList::parse
|
||||
// - normal running : nProcs = dictNProcs = nProcDirs
|
||||
// - decomposition to more processors : nProcs = dictNProcs
|
||||
// - decomposition to fewer processors : nProcs = nProcDirs
|
||||
if (dictNProcs > Pstream::nProcs())
|
||||
if (checkProcessorDirectories_ && dictNProcs > Pstream::nProcs())
|
||||
{
|
||||
FatalError
|
||||
<< source
|
||||
@ -814,7 +821,11 @@ void Foam::argList::parse
|
||||
{
|
||||
// Possibly going to fewer processors.
|
||||
// Check if all procDirs are there.
|
||||
if (dictNProcs < Pstream::nProcs())
|
||||
if
|
||||
(
|
||||
checkProcessorDirectories_
|
||||
&& dictNProcs < Pstream::nProcs()
|
||||
)
|
||||
{
|
||||
label nProcDirs = 0;
|
||||
while
|
||||
@ -1337,15 +1348,30 @@ bool Foam::argList::checkRootCase() const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Pstream::master() && !isDir(path()))
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Allow slaves on non-existing processor directories, created later
|
||||
FatalError
|
||||
<< executable_
|
||||
<< ": cannot open case directory " << path()
|
||||
<< endl;
|
||||
if (Pstream::master() && (checkProcessorDirectories_ && !isDir(path())))
|
||||
{
|
||||
// Allow slaves on non-existing processor directories created later
|
||||
FatalError
|
||||
<< 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;
|
||||
|
||||
@ -119,6 +119,9 @@ class argList
|
||||
//- Track enabled/disabled banner state
|
||||
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
|
||||
// so destructor is done last.
|
||||
ParRunControl parRunControl_;
|
||||
@ -387,6 +390,9 @@ public:
|
||||
//- Remove the parallel options
|
||||
static void noParallel();
|
||||
|
||||
//- Remove checking of processor directories
|
||||
static void noCheckProcessorDirectories();
|
||||
|
||||
//- Return true if the post-processing option is specified
|
||||
static bool postProcess(int argc, char *argv[]);
|
||||
|
||||
|
||||
@ -47,13 +47,13 @@ namespace mathematical
|
||||
|
||||
static const char* const group = "mathematical";
|
||||
|
||||
const scalar e(M_E);
|
||||
const scalar pi(M_PI);
|
||||
const scalar twoPi(2*pi);
|
||||
const scalar piByTwo(0.5*pi);
|
||||
constexpr scalar e(M_E);
|
||||
constexpr scalar pi(M_PI);
|
||||
constexpr scalar twoPi(2*M_PI);
|
||||
constexpr scalar piByTwo(0.5*M_PI);
|
||||
|
||||
//- Euler's constant
|
||||
const scalar Eu(0.57721566490153286060651209);
|
||||
constexpr scalar Eu(0.57721566490153286060651209);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ SourceFiles
|
||||
|
||||
#include "profilingTrigger.H"
|
||||
#include "HashPtrTable.H"
|
||||
#include "Tuple2.H"
|
||||
#include "LIFOStack.H"
|
||||
#include "Map.H"
|
||||
#include "Time.H"
|
||||
|
||||
@ -42,29 +42,43 @@ namespace Foam
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- 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
|
||||
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
|
||||
inline scalar atmToPa(const scalar atm)
|
||||
inline constexpr scalar atmToPa(const scalar atm) noexcept
|
||||
{
|
||||
return (atm*101325.0);
|
||||
}
|
||||
|
||||
//- Conversion from atm to Pa
|
||||
inline scalar paToAtm(const scalar pa)
|
||||
inline constexpr scalar paToAtm(const scalar pa) noexcept
|
||||
{
|
||||
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
|
||||
|
||||
@ -123,10 +123,10 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
|
||||
const scalar lookupValue
|
||||
) const
|
||||
{
|
||||
label n = data.size();
|
||||
const label n = data.size();
|
||||
|
||||
scalar minLimit = data.first().first();
|
||||
scalar maxLimit = data.last().first();
|
||||
const scalar minLimit = data.first().first();
|
||||
const scalar maxLimit = data.last().first();
|
||||
|
||||
if (lookupValue < minLimit)
|
||||
{
|
||||
@ -147,7 +147,9 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
|
||||
<< "bound (" << minLimit << ")" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
return data.first().second();
|
||||
break;
|
||||
}
|
||||
case interpolation2DTable::CLAMP:
|
||||
{
|
||||
@ -175,7 +177,9 @@ Type Foam::interpolation2DTable<Type>::interpolateValue
|
||||
<< "bound (" << maxLimit << ")" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
return data.last().second();
|
||||
break;
|
||||
}
|
||||
case interpolation2DTable::CLAMP:
|
||||
{
|
||||
@ -251,16 +255,19 @@ Foam::label Foam::interpolation2DTable<Type>::Xi
|
||||
WarningInFunction
|
||||
<< "value (" << valueX << ") out of bounds"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
return limitI;
|
||||
break;
|
||||
}
|
||||
case interpolation2DTable::CLAMP:
|
||||
{
|
||||
return limitI;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Un-handled enumeration " << boundsHandling_
|
||||
<< "Unhandled enumeration " << boundsHandling_
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
@ -299,7 +306,7 @@ Type Foam::interpolation2DTable<Type>::operator()
|
||||
) const
|
||||
{
|
||||
// Considers all of the list in Y being equal
|
||||
label nX = this->size();
|
||||
const label nX = this->size();
|
||||
|
||||
const table& t = *this;
|
||||
|
||||
@ -320,8 +327,8 @@ Type Foam::interpolation2DTable<Type>::operator()
|
||||
// have 2-D data, interpolate
|
||||
|
||||
// find low and high indices in the X range that bound valueX
|
||||
label x0i = Xi(lessOp<scalar>(), valueX, false);
|
||||
label x1i = Xi(greaterOp<scalar>(), valueX, true);
|
||||
const label x0i = Xi(lessOp<scalar>(), valueX, false);
|
||||
const label x1i = Xi(greaterOp<scalar>(), valueX, true);
|
||||
|
||||
if (x0i == x1i)
|
||||
{
|
||||
@ -333,8 +340,8 @@ Type Foam::interpolation2DTable<Type>::operator()
|
||||
Type y1(interpolateValue(t[x1i].second(), valueY));
|
||||
|
||||
// gradient in X
|
||||
scalar x0 = t[x0i].first();
|
||||
scalar x1 = t[x1i].first();
|
||||
const scalar x0 = t[x0i].first();
|
||||
const scalar x1 = t[x1i].first();
|
||||
Type mX = (y1 - y0)/(x1 - x0);
|
||||
|
||||
// interpolate
|
||||
@ -420,7 +427,7 @@ Foam::interpolation2DTable<Type>::outOfBounds
|
||||
template<class Type>
|
||||
void Foam::interpolation2DTable<Type>::checkOrder() const
|
||||
{
|
||||
label n = this->size();
|
||||
const label n = this->size();
|
||||
const table& t = *this;
|
||||
|
||||
scalar prevValue = t[0].first();
|
||||
@ -445,10 +452,8 @@ void Foam::interpolation2DTable<Type>::checkOrder() const
|
||||
template<class Type>
|
||||
void Foam::interpolation2DTable<Type>::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("file")
|
||||
<< fileName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("outOfBounds")
|
||||
<< boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
|
||||
os.writeEntry("file", fileName_);
|
||||
os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
|
||||
|
||||
os << *this;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ public:
|
||||
CLAMP //!< Clamp value to the start/end value
|
||||
};
|
||||
|
||||
//- Cconvenience typedef
|
||||
//- Convenience typedef
|
||||
typedef List<Tuple2<scalar, List<Tuple2<scalar, Type>>>> table;
|
||||
|
||||
|
||||
@ -156,7 +156,7 @@ public:
|
||||
const List<Tuple2<scalar, Type>>& operator[](const label) const;
|
||||
|
||||
//- Return an interpolated value
|
||||
Type operator()(const scalar, const scalar) const;
|
||||
Type operator()(const scalar valueX, const scalar valueY) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -205,8 +205,8 @@ Foam::interpolationTable<Type>::outOfBounds
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::check() const
|
||||
{
|
||||
label n = this->size();
|
||||
scalar prevValue = List<Tuple2<scalar, Type>>::operator[](0).first();
|
||||
const label n = this->size();
|
||||
scalar prevValue = this->first().first();
|
||||
|
||||
for (label i=1; i<n; ++i)
|
||||
{
|
||||
@ -229,10 +229,8 @@ void Foam::interpolationTable<Type>::check() const
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("file")
|
||||
<< fileName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("outOfBounds")
|
||||
<< boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl;
|
||||
os.writeEntry("file", fileName_);
|
||||
os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
|
||||
if (reader_.valid())
|
||||
{
|
||||
reader_->write(os);
|
||||
@ -251,8 +249,8 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
scalar minLimit = List<Tuple2<scalar, Type>>::operator[](0).first();
|
||||
scalar maxLimit = List<Tuple2<scalar, Type>>::operator[](n-1).first();
|
||||
const scalar minLimit = this->first().first();
|
||||
const scalar maxLimit = this->last().first();
|
||||
scalar lookupValue = value;
|
||||
|
||||
if (lookupValue < minLimit)
|
||||
@ -272,7 +270,9 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
|
||||
<< "value (" << lookupValue << ") underflow" << nl
|
||||
<< " Zero rate of change."
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// behaviour as per 'CLAMP'
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
@ -305,7 +305,9 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
|
||||
<< "value (" << lookupValue << ") overflow" << nl
|
||||
<< " Zero rate of change."
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
@ -346,7 +348,7 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
|
||||
}
|
||||
else if (hi == 0)
|
||||
{
|
||||
// this treatment should should only occur under these conditions:
|
||||
// this treatment should only occur under these conditions:
|
||||
// -> the 'REPEAT' treatment
|
||||
// -> (0 <= value <= minLimit)
|
||||
// -> minLimit > 0
|
||||
@ -414,7 +416,9 @@ Foam::interpolationTable<Type>::operator[](const label i) const
|
||||
<< "index (" << ii << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
ii = 0;
|
||||
break;
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
@ -448,7 +452,9 @@ Foam::interpolationTable<Type>::operator[](const label i) const
|
||||
<< "index (" << ii << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
ii = n - 1;
|
||||
break;
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
@ -477,11 +483,11 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
return List<Tuple2<scalar, Type>>::operator[](0).second();
|
||||
return this->first().second();
|
||||
}
|
||||
|
||||
scalar minLimit = List<Tuple2<scalar, Type>>::operator[](0).first();
|
||||
scalar maxLimit = List<Tuple2<scalar, Type>>::operator[](n-1).first();
|
||||
const scalar minLimit = this->first().first();
|
||||
const scalar maxLimit = this->last().first();
|
||||
scalar lookupValue = value;
|
||||
|
||||
if (lookupValue < minLimit)
|
||||
@ -501,17 +507,19 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
<< "value (" << lookupValue << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
return this->first().second();
|
||||
break;
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
return List<Tuple2<scalar, Type>>::operator[](0).second();
|
||||
return this->first().second();
|
||||
break;
|
||||
}
|
||||
case interpolationTable::REPEAT:
|
||||
{
|
||||
// adjust lookupValue to >= minLimit
|
||||
scalar span = maxLimit-minLimit;
|
||||
const scalar span = maxLimit-minLimit;
|
||||
lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
|
||||
break;
|
||||
}
|
||||
@ -534,17 +542,19 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
<< "value (" << lookupValue << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
return this->last().second();
|
||||
break;
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
return List<Tuple2<scalar, Type>>::operator[](n-1).second();
|
||||
return this->last().second();
|
||||
break;
|
||||
}
|
||||
case interpolationTable::REPEAT:
|
||||
{
|
||||
// adjust lookupValue <= maxLimit
|
||||
scalar span = maxLimit-minLimit;
|
||||
const scalar span = maxLimit-minLimit;
|
||||
lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
|
||||
break;
|
||||
}
|
||||
@ -575,7 +585,7 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
}
|
||||
else if (hi == 0)
|
||||
{
|
||||
// this treatment should should only occur under these conditions:
|
||||
// this treatment should only occur under these conditions:
|
||||
// -> the 'REPEAT' treatment
|
||||
// -> (0 <= value <= minLimit)
|
||||
// -> minLimit > 0
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -29,16 +29,18 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
template<class PointList>
|
||||
Foam::label Foam::mergePoints
|
||||
(
|
||||
const UList<Type>& points,
|
||||
const PointList& points,
|
||||
const scalar mergeTol,
|
||||
const bool verbose,
|
||||
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
|
||||
pointMap.setSize(points.size());
|
||||
pointMap = -1;
|
||||
@ -49,10 +51,10 @@ Foam::label Foam::mergePoints
|
||||
}
|
||||
|
||||
// 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;
|
||||
if (origin == Type::max)
|
||||
point_type compareOrigin = origin;
|
||||
if (origin == point_type::max)
|
||||
{
|
||||
compareOrigin = sum(tPoints())/points.size();
|
||||
}
|
||||
@ -69,7 +71,7 @@ Foam::label Foam::mergePoints
|
||||
const scalar mergeTolSqr = Foam::sqr(scalar(mergeTol));
|
||||
|
||||
// Sort points by magSqr
|
||||
const Field<Type> d(tPoints - compareOrigin);
|
||||
const Field<point_type> d(tPoints - compareOrigin);
|
||||
|
||||
List<scalar> magSqrD(d.size());
|
||||
forAll(d, pointi)
|
||||
@ -77,15 +79,16 @@ Foam::label Foam::mergePoints
|
||||
magSqrD[pointi] = magSqr(d[pointi]);
|
||||
}
|
||||
labelList order;
|
||||
sortedOrder(magSqrD, order);
|
||||
Foam::sortedOrder(magSqrD, order);
|
||||
|
||||
|
||||
Field<scalar> sortedTol(points.size());
|
||||
forAll(order, sortI)
|
||||
{
|
||||
label pointi = order[sortI];
|
||||
const label pointi = order[sortI];
|
||||
|
||||
// Convert to scalar precision
|
||||
// NOTE: not yet using point_type template parameter
|
||||
const point pt
|
||||
(
|
||||
scalar(d[pointi].x()),
|
||||
@ -104,9 +107,11 @@ Foam::label Foam::mergePoints
|
||||
for (label sortI = 1; sortI < order.size(); sortI++)
|
||||
{
|
||||
// Get original point index
|
||||
label pointi = order[sortI];
|
||||
const label pointi = order[sortI];
|
||||
const scalar mag2 = magSqrD[order[sortI]];
|
||||
|
||||
// Convert to scalar precision
|
||||
// NOTE: not yet using point_type template parameter
|
||||
const point pt
|
||||
(
|
||||
scalar(points[pointi].x()),
|
||||
@ -126,7 +131,10 @@ Foam::label Foam::mergePoints
|
||||
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
|
||||
(
|
||||
scalar(points[prevPointi].x()),
|
||||
@ -169,18 +177,18 @@ Foam::label Foam::mergePoints
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
template<class PointList>
|
||||
bool Foam::mergePoints
|
||||
(
|
||||
const UList<Type>& points,
|
||||
const PointList& points,
|
||||
const scalar mergeTol,
|
||||
const bool verbose,
|
||||
labelList& pointMap,
|
||||
List<Type>& newPoints,
|
||||
const Type& origin
|
||||
List<typename PointList::value_type>& newPoints,
|
||||
typename PointList::const_reference origin
|
||||
)
|
||||
{
|
||||
label nUnique = mergePoints
|
||||
const label nUnique = mergePoints
|
||||
(
|
||||
points,
|
||||
mergeTol,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,27 +46,28 @@ namespace Foam
|
||||
|
||||
//- 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.
|
||||
template<class Type>
|
||||
template<class PointList>
|
||||
label mergePoints
|
||||
(
|
||||
const UList<Type>& points,
|
||||
const PointList& points,
|
||||
const scalar mergeTol,
|
||||
const bool verbose,
|
||||
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
|
||||
// merged (though newPoints still sorted even if not merged).
|
||||
template<class Type>
|
||||
template<class PointList>
|
||||
bool mergePoints
|
||||
(
|
||||
const UList<Type>& points,
|
||||
const PointList& points,
|
||||
const scalar mergeTol,
|
||||
const bool verbose,
|
||||
labelList& pointMap,
|
||||
List<Type>& newPoints,
|
||||
const Type& origin = Type::zero
|
||||
List<typename PointList::value_type>& newPoints,
|
||||
typename PointList::const_reference origin = PointList::value_type::zero
|
||||
);
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
238
src/OpenFOAM/primitives/enums/Enum.C
Normal file
238
src/OpenFOAM/primitives/enums/Enum.C
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
220
src/OpenFOAM/primitives/enums/Enum.H
Normal file
220
src/OpenFOAM/primitives/enums/Enum.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
103
src/OpenFOAM/primitives/enums/EnumI.H
Normal file
103
src/OpenFOAM/primitives/enums/EnumI.H
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -25,14 +25,48 @@ License
|
||||
|
||||
#include "NamedEnum.H"
|
||||
#include "dictionary.H"
|
||||
#include "stdFoam.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
template<class StringType>
|
||||
Foam::List<StringType> Foam::NamedEnum<Enum, nEnum>::getNamesList()
|
||||
template<class EnumType, int nEnum>
|
||||
Foam::NamedEnum<EnumType, nEnum>::NamedEnum()
|
||||
:
|
||||
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;
|
||||
for (int enumi=0; enumi < nEnum; ++enumi)
|
||||
@ -48,93 +82,74 @@ Foam::List<StringType> Foam::NamedEnum<Enum, nEnum>::getNamesList()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
Foam::NamedEnum<Enum, nEnum>::NamedEnum()
|
||||
:
|
||||
table_type(2*nEnum)
|
||||
template<class EnumType, int nEnum>
|
||||
Foam::List<int> Foam::NamedEnum<EnumType, nEnum>::values() const
|
||||
{
|
||||
List<int> lst(nEnum);
|
||||
|
||||
label count = 0;
|
||||
for (int enumi=0; enumi < nEnum; ++enumi)
|
||||
{
|
||||
if (names[enumi] && names[enumi][0])
|
||||
{
|
||||
insert(names[enumi], enumi);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bad name - generate error message
|
||||
stringList goodNames(enumi);
|
||||
auto iter = lookup_.cfind(names[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 Enum, int nEnum>
|
||||
Enum Foam::NamedEnum<Enum, nEnum>::read(Istream& is) const
|
||||
template<class EnumType, int nEnum>
|
||||
bool Foam::NamedEnum<EnumType, nEnum>::hasName(const EnumType e) const
|
||||
{
|
||||
const word enumName(is);
|
||||
table_type::const_iterator iter = find(enumName);
|
||||
const int enumValue(e);
|
||||
|
||||
if (!iter.found())
|
||||
forAllConstIters(lookup_, iter)
|
||||
{
|
||||
FatalIOErrorInFunction(is)
|
||||
<< enumName << " is not in enumeration: "
|
||||
<< sortedToc() << exit(FatalIOError);
|
||||
if (iter.object() == enumValue)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return Enum(iter.object());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
void Foam::NamedEnum<Enum, nEnum>::write(const Enum e, Ostream& os) const
|
||||
{
|
||||
os << names[int(e)];
|
||||
}
|
||||
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
Enum Foam::NamedEnum<Enum, nEnum>::lookup
|
||||
template<class EnumType, int nEnum>
|
||||
EnumType Foam::NamedEnum<EnumType, nEnum>::lookup
|
||||
(
|
||||
const word& key,
|
||||
const dictionary& dict
|
||||
) const
|
||||
{
|
||||
const word enumName(dict.lookup(key));
|
||||
table_type::const_iterator iter = find(enumName);
|
||||
auto iter = lookup_.cfind(enumName);
|
||||
|
||||
if (!iter.found())
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< 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>
|
||||
Enum Foam::NamedEnum<Enum, nEnum>::lookupOrDefault
|
||||
template<class EnumType, int nEnum>
|
||||
EnumType Foam::NamedEnum<EnumType, nEnum>::lookupOrDefault
|
||||
(
|
||||
const word& key,
|
||||
const dictionary& dict,
|
||||
const enum_type deflt
|
||||
const EnumType deflt
|
||||
) const
|
||||
{
|
||||
if (dict.found(key))
|
||||
@ -148,36 +163,49 @@ Enum Foam::NamedEnum<Enum, nEnum>::lookupOrDefault
|
||||
}
|
||||
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
Foam::List<Enum> Foam::NamedEnum<Enum, nEnum>::enums()
|
||||
template<class EnumType, int nEnum>
|
||||
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;
|
||||
for (int enumi = 0; enumi < nEnum; ++enumi)
|
||||
if (!iter.found())
|
||||
{
|
||||
if (names[enumi] && names[enumi][0])
|
||||
{
|
||||
lst[count++] = Enum(enumi);
|
||||
}
|
||||
FatalIOErrorInFunction(is)
|
||||
<< enumName << " is not in enumeration: "
|
||||
<< lookup_.sortedToc() << nl
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
lst.setSize(count);
|
||||
return lst;
|
||||
return EnumType(iter.object());
|
||||
}
|
||||
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
Foam::stringList Foam::NamedEnum<Enum, nEnum>::strings()
|
||||
template<class EnumType, int nEnum>
|
||||
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>
|
||||
Foam::wordList Foam::NamedEnum<Enum, nEnum>::words()
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -25,9 +25,8 @@ Class
|
||||
Foam::NamedEnum
|
||||
|
||||
Description
|
||||
A NamedEnum is a wrapper around a static list of names that represent
|
||||
a particular enumeration. Internally it uses a HashTable for quicker
|
||||
lookups.
|
||||
A NamedEnum is a wrapper around a list of names that represent
|
||||
particular enumeration values.
|
||||
|
||||
SourceFiles
|
||||
NamedEnum.C
|
||||
@ -38,7 +37,6 @@ SourceFiles
|
||||
#define NamedEnum_H
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "stringList.H"
|
||||
#include "wordList.H"
|
||||
#include <type_traits>
|
||||
|
||||
@ -46,33 +44,32 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
// Forward declarations
|
||||
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
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Enum, int nEnum>
|
||||
template<class EnumType, int nEnum>
|
||||
class NamedEnum
|
||||
:
|
||||
public HashTable<int>
|
||||
{
|
||||
//- The nEnum must be positive (non-zero)
|
||||
static_assert(nEnum > 0, "nEnum must be positive (non-zero)");
|
||||
|
||||
//- The type of HashTable used for the lookup.
|
||||
typedef HashTable<int> table_type;
|
||||
// Private Member Data
|
||||
|
||||
//- The values for the enum
|
||||
HashTable<int> lookup_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- The names as a list of strings
|
||||
template<class StringType>
|
||||
static List<StringType> getNamesList();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
NamedEnum(const NamedEnum&) = delete;
|
||||
|
||||
@ -83,12 +80,12 @@ class NamedEnum
|
||||
public:
|
||||
|
||||
//- The type of enumeration wrapped by NamedEnum
|
||||
typedef Enum enum_type;
|
||||
typedef EnumType value_type;
|
||||
|
||||
|
||||
// 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];
|
||||
|
||||
|
||||
@ -100,17 +97,42 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read a word from Istream and return the corresponding
|
||||
// enumeration element
|
||||
enum_type read(Istream& is) const;
|
||||
// Access
|
||||
|
||||
//- Write the name representation of the enumeration to an Ostream
|
||||
void write(const enum_type e, Ostream& os) const;
|
||||
//- The number of lookup names for the enumeration
|
||||
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
|
||||
// enumeration element based on its name.
|
||||
// Fatal if anything is incorrect.
|
||||
enum_type lookup
|
||||
EnumType lookup
|
||||
(
|
||||
const word& key,
|
||||
const dictionary& dict
|
||||
@ -120,42 +142,42 @@ public:
|
||||
// enumeration element based on its name.
|
||||
// Return the default value if the key was not found in the dictionary.
|
||||
// Fatal if enumerated name was incorrect.
|
||||
enum_type lookupOrDefault
|
||||
EnumType lookupOrDefault
|
||||
(
|
||||
const word& key,
|
||||
const dictionary& dict,
|
||||
const enum_type deflt
|
||||
const EnumType deflt
|
||||
) const;
|
||||
|
||||
//- List of enumerations
|
||||
static List<enum_type> enums();
|
||||
|
||||
//- The set of names as a list of strings
|
||||
static stringList strings();
|
||||
// IO
|
||||
|
||||
//- The set of names as a list of words
|
||||
static wordList words();
|
||||
//- 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;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return the enumeration element corresponding to the given name
|
||||
inline const enum_type operator[](const char* 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));
|
||||
}
|
||||
inline const EnumType operator[](const word& name) const;
|
||||
|
||||
//- Return the name of the given enumeration element
|
||||
inline const char* operator[](const enum_type e) const
|
||||
{
|
||||
return names[int(e)];
|
||||
}
|
||||
inline const char* operator[](const EnumType e) const;
|
||||
|
||||
|
||||
// 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
|
||||
#include "NamedEnum.C"
|
||||
#endif
|
||||
91
src/OpenFOAM/primitives/enums/NamedEnumI.H
Normal file
91
src/OpenFOAM/primitives/enums/NamedEnumI.H
Normal 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)];
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -195,7 +195,7 @@ void Foam::Function1Types::TableBase<Type>::check() const
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
label n = table_.size();
|
||||
const label n = table_.size();
|
||||
scalar prevValue = table_[0].first();
|
||||
|
||||
for (label i = 1; i < n; ++i)
|
||||
@ -221,7 +221,7 @@ bool Foam::Function1Types::TableBase<Type>::checkMinBounds
|
||||
scalar& xDash
|
||||
) const
|
||||
{
|
||||
if (x < table_[0].first())
|
||||
if (x < table_.first().first())
|
||||
{
|
||||
switch (boundsHandling_)
|
||||
{
|
||||
@ -238,19 +238,28 @@ bool Foam::Function1Types::TableBase<Type>::checkMinBounds
|
||||
<< "value (" << x << ") underflow" << nl
|
||||
<< endl;
|
||||
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
xDash = table_.first().first();
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case CLAMP:
|
||||
{
|
||||
xDash = table_[0].first();
|
||||
xDash = table_.first().first();
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case REPEAT:
|
||||
{
|
||||
// adjust x to >= minX
|
||||
scalar span = table_.last().first() - table_[0].first();
|
||||
xDash = fmod(x - table_[0].first(), span) + table_[0].first();
|
||||
const scalar span =
|
||||
table_.last().first() - table_.first().first();
|
||||
|
||||
xDash =
|
||||
(
|
||||
fmod(x - table_.first().first(), span)
|
||||
+ table_.first().first()
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -288,7 +297,10 @@ bool Foam::Function1Types::TableBase<Type>::checkMaxBounds
|
||||
<< "value (" << x << ") overflow" << nl
|
||||
<< endl;
|
||||
|
||||
// fall-through to 'CLAMP'
|
||||
// Behaviour as per 'CLAMP'
|
||||
xDash = table_.last().first();
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case CLAMP:
|
||||
{
|
||||
@ -299,8 +311,14 @@ bool Foam::Function1Types::TableBase<Type>::checkMaxBounds
|
||||
case REPEAT:
|
||||
{
|
||||
// adjust x to >= minX
|
||||
scalar span = table_.last().first() - table_[0].first();
|
||||
xDash = fmod(x - table_[0].first(), span) + table_[0].first();
|
||||
const scalar span =
|
||||
table_.last().first() - table_.first().first();
|
||||
|
||||
xDash =
|
||||
(
|
||||
fmod(x - table_.first().first(), span)
|
||||
+ table_.first().first()
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -335,7 +353,7 @@ Type Foam::Function1Types::TableBase<Type>::value(const scalar x) const
|
||||
|
||||
if (checkMinBounds(x, xDash))
|
||||
{
|
||||
return table_[0].second();
|
||||
return table_.first().second();
|
||||
}
|
||||
|
||||
if (checkMaxBounds(xDash, xDash))
|
||||
@ -411,13 +429,11 @@ void Foam::Function1Types::TableBase<Type>::writeEntries(Ostream& os) const
|
||||
{
|
||||
if (boundsHandling_ != CLAMP)
|
||||
{
|
||||
os.writeKeyword("outOfBounds") << boundsHandlingToWord(boundsHandling_)
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeEntry("outOfBounds", boundsHandlingToWord(boundsHandling_));
|
||||
}
|
||||
if (interpolationScheme_ != "linear")
|
||||
{
|
||||
os.writeKeyword("interpolationScheme") << interpolationScheme_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeEntry("interpolationScheme", interpolationScheme_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -308,7 +308,7 @@ Foam::string Foam::stringOps::getVariable
|
||||
}
|
||||
}
|
||||
|
||||
if (value.empty())
|
||||
if (!allowEmpty && value.empty())
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
@ -317,7 +317,8 @@ Foam::string Foam::stringOps::getVariable
|
||||
<< name << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (!allowEmpty && value.empty())
|
||||
{
|
||||
FatalIOErrorInFunction
|
||||
(
|
||||
|
||||
@ -111,7 +111,7 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
|
||||
{
|
||||
typedef compressible::turbulenceModel turbulenceModel;
|
||||
|
||||
word turbName(turbulenceModel::propertiesName);
|
||||
const word turbName(turbulenceModel::propertiesName);
|
||||
|
||||
if
|
||||
(
|
||||
@ -205,8 +205,8 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
|
||||
<< " on mesh " << mesh.name() << " patch " << patch_.name()
|
||||
<< nl
|
||||
<< "Please set 'kappaMethod' to one of "
|
||||
<< KMethodTypeNames_.toc()
|
||||
<< " and 'kappa' to the name of the volScalar"
|
||||
<< flatOutput(KMethodTypeNames_.sortedToc()) << nl
|
||||
<< "and 'kappa' to the name of the volScalar"
|
||||
<< " or volSymmTensor field (if kappaMethod=lookup)"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
@ -219,8 +219,8 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa
|
||||
FatalErrorInFunction
|
||||
<< "Unimplemented method " << KMethodTypeNames_[method_] << nl
|
||||
<< "Please set 'kappaMethod' to one of "
|
||||
<< KMethodTypeNames_.toc()
|
||||
<< " and 'kappa' to the name of the volScalar"
|
||||
<< flatOutput(KMethodTypeNames_.sortedToc()) << nl
|
||||
<< "and 'kappa' to the name of the volScalar"
|
||||
<< " or volSymmTensor field (if kappaMethod=lookup)"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -11,6 +11,4 @@ writer/ccmWriter.C
|
||||
writer/ccmWriterMesh.C
|
||||
writer/ccmWriterSolution.C
|
||||
|
||||
/* misc/mergePoints1.C */
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libccm
|
||||
|
||||
@ -111,7 +111,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Explicity close the file and terminate ccmio access.
|
||||
// Return false if it was already closed.
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Containers for holding STARCCM boundary information
|
||||
Container for holding STARCCM boundary information
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
#ifndef ccmBoundaryInfo_H
|
||||
@ -40,8 +40,11 @@ namespace Foam
|
||||
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
|
||||
@ -95,6 +98,7 @@ public:
|
||||
return ccmIndex != rhs.ccmIndex;
|
||||
}
|
||||
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<(Ostream& os, const ccmBoundaryInfo& entry)
|
||||
{
|
||||
|
||||
@ -38,8 +38,14 @@ namespace Foam
|
||||
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
|
||||
@ -57,6 +63,7 @@ public:
|
||||
//- The second boundary
|
||||
label bnd1;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
@ -106,6 +113,12 @@ public:
|
||||
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
|
||||
word canonicalName0() const
|
||||
@ -161,42 +174,57 @@ class interfaceDefinitions
|
||||
:
|
||||
public Map<interfaceEntry>
|
||||
{
|
||||
|
||||
inline Map<interfaceEntry>& map()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline const Map<interfaceEntry>& map() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
|
||||
//- Null construct
|
||||
interfaceDefinitions()
|
||||
:
|
||||
Map<interfaceEntry>()
|
||||
{}
|
||||
|
||||
|
||||
//- Scan available interface entries for one matching this boundary id
|
||||
bool add(interfaceEntry entry)
|
||||
//- Size
|
||||
label size() const
|
||||
{
|
||||
if
|
||||
(
|
||||
entry.id >= 0
|
||||
&& entry.bnd0 >= 0 && entry.bnd1 >= 0
|
||||
&& entry.bnd0 != entry.bnd1
|
||||
)
|
||||
{
|
||||
this->set(entry.id, entry);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return map().size();
|
||||
}
|
||||
|
||||
//- Size
|
||||
bool empty() const
|
||||
{
|
||||
return map().empty();
|
||||
}
|
||||
|
||||
//- Clear
|
||||
void clear()
|
||||
{
|
||||
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
|
||||
bool isInterface(label bndId)
|
||||
{
|
||||
forAllConstIter(Map<interfaceEntry>, *this, iter)
|
||||
forAllConstIters(map(), iter)
|
||||
{
|
||||
if (iter().inInterface(bndId))
|
||||
if (iter.object().inInterface(bndId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -210,9 +238,9 @@ public:
|
||||
word interfaceName(label bndId)
|
||||
{
|
||||
word ifname;
|
||||
forAllConstIter(Map<interfaceEntry>, *this, iter)
|
||||
forAllConstIters(map(), iter)
|
||||
{
|
||||
ifname = iter().canonicalName(bndId);
|
||||
ifname = iter.object().canonicalName(bndId);
|
||||
if (!ifname.empty())
|
||||
{
|
||||
break;
|
||||
@ -231,9 +259,7 @@ public:
|
||||
const interfaceDefinitions& defs
|
||||
)
|
||||
{
|
||||
os << static_cast<const Map<interfaceEntry>& >(defs)
|
||||
<< nl;
|
||||
|
||||
os << defs.map() << nl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@ -368,7 +368,7 @@ private:
|
||||
void validateInterface(List<labelPair>&);
|
||||
|
||||
//- Renumber interface faces
|
||||
void renumberInterfaces(const List<label>&);
|
||||
void renumberInterfaces(const labelUList& oldToNew);
|
||||
|
||||
//- Remove interfaces between domains (fluid/porosity; fluid/solid, etc)
|
||||
// reorganize baffle interfaces into [0-N/2; N/2-N] lists at the
|
||||
@ -394,23 +394,27 @@ private:
|
||||
) const;
|
||||
|
||||
// polyMesh Friend Functions
|
||||
void addPatches(polyMesh&) const;
|
||||
void addPatches(polyMesh& mesh) const;
|
||||
|
||||
//- Add faceZones based on monitoring boundary conditions
|
||||
void addFaceZones(polyMesh&) const;
|
||||
void addFaceZones(polyMesh& mesh) const;
|
||||
|
||||
//- Get information about all available solutions
|
||||
bool detectSolution();
|
||||
|
||||
//- Get information about available fields
|
||||
// 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
|
||||
|
||||
//- Get map of porous regions
|
||||
static Map<word> selectPorous(const Map<dictionary>&);
|
||||
static Map<word> selectPorous(const Map<dictionary>& table);
|
||||
|
||||
|
||||
public:
|
||||
@ -418,13 +422,13 @@ public:
|
||||
// Static Members
|
||||
|
||||
//- Warn about repeated name
|
||||
static void warnDuplicates(const word& context, const wordList&);
|
||||
static void warnDuplicates(const word& context, const wordList& lst);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Open a file for reading
|
||||
reader(const fileName&, const options& opts);
|
||||
reader(const fileName& file, const reader::options& opts);
|
||||
|
||||
|
||||
//- Destructor (closes file)
|
||||
@ -433,7 +437,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Reference to the reader options
|
||||
const reader::options& option() const;
|
||||
@ -459,7 +463,7 @@ public:
|
||||
// const pointField& points() const { return points_; }
|
||||
|
||||
|
||||
// Check
|
||||
// Check
|
||||
|
||||
//- Return true if file has geometry associated with it
|
||||
bool hasGeometry();
|
||||
@ -468,7 +472,7 @@ public:
|
||||
bool hasSolution();
|
||||
|
||||
|
||||
// Edit
|
||||
// Edit
|
||||
|
||||
//- Remap cellTable and boundaryRegion according to dictionary
|
||||
bool remapMeshInfo
|
||||
@ -478,17 +482,17 @@ public:
|
||||
);
|
||||
|
||||
|
||||
// Write
|
||||
// Write
|
||||
|
||||
//- Write the polyMesh
|
||||
void writeMesh
|
||||
(
|
||||
const polyMesh&,
|
||||
const polyMesh& mesh,
|
||||
IOstream::streamFormat fmt = IOstream::BINARY
|
||||
) const;
|
||||
|
||||
//- Write cellTable, boundaryRegion and interface information
|
||||
void writeAux(const objectRegistry&) const;
|
||||
void writeAux(const objectRegistry& registry) const;
|
||||
|
||||
//- Detect and read geometry if possible
|
||||
bool readGeometry(const scalar scaleFactor = 1.0);
|
||||
@ -593,12 +597,10 @@ class reader::options
|
||||
//- Merge in-place interfaces (default true)
|
||||
bool mergeInterfaces_;
|
||||
|
||||
//- Rename interface boundaries as InterfaceN_0, InterfaceN_1 (default true)
|
||||
//- Rename interface boundaries as InterfaceN_0, InterfaceN_1
|
||||
// (default true)
|
||||
bool renameInterfaces_;
|
||||
|
||||
//- Combine identically named boundaries (default false)
|
||||
bool combineBoundaries_;
|
||||
|
||||
//- Remove baffles by merging their respective faces (default false)
|
||||
bool removeBaffles_;
|
||||
|
||||
@ -623,7 +625,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Keep fluid regions (default true)
|
||||
bool keepFluid() const;
|
||||
@ -640,12 +642,10 @@ public:
|
||||
//- Merge in-place interfaces (default true)
|
||||
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;
|
||||
|
||||
//- Combine identically named boundaries (default false)
|
||||
bool combineBoundaries() const;
|
||||
|
||||
//- Remove baffles by merging their respective faces (default false)
|
||||
bool removeBaffles() const;
|
||||
|
||||
@ -660,37 +660,35 @@ public:
|
||||
scalar undefScalar() const;
|
||||
|
||||
|
||||
// Edit
|
||||
// Edit
|
||||
|
||||
//- Keep fluid regions
|
||||
void keepFluid(bool);
|
||||
void keepFluid(bool b);
|
||||
|
||||
//- Keep porous regions
|
||||
void keepPorous(bool);
|
||||
void keepPorous(bool b);
|
||||
|
||||
//- Keep solid regions
|
||||
void keepSolid(bool);
|
||||
void keepSolid(bool b);
|
||||
|
||||
//- Merge in-place interfaces
|
||||
void mergeInterfaces(bool);
|
||||
void mergeInterfaces(bool b);
|
||||
|
||||
//- 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
|
||||
void removeBaffles(bool);
|
||||
void removeBaffles(bool b);
|
||||
|
||||
//- 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)
|
||||
void mergeTol(const scalar&);
|
||||
void mergeTol(const scalar& tol);
|
||||
|
||||
//- Value to assign for undefined solutions (default: NaN)
|
||||
void undefScalar(const scalar&);
|
||||
void undefScalar(const scalar& val);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -44,7 +44,7 @@ Foam::Map<Foam::word> Foam::ccm::reader::selectPorous
|
||||
{
|
||||
Map<word> lookup;
|
||||
|
||||
forAllConstIter(Map<dictionary>, table, iter)
|
||||
forAllConstIters(table, iter)
|
||||
{
|
||||
if (iter().lookupOrDefault<label>("PorosityId", 0) != 0)
|
||||
{
|
||||
@ -70,21 +70,21 @@ void Foam::ccm::reader::warnDuplicates
|
||||
const wordList& lst
|
||||
)
|
||||
{
|
||||
HashTable<label> hashed(lst.size());
|
||||
HashTable<label> hashed(2*lst.size());
|
||||
bool duplicates = false;
|
||||
|
||||
forAll(lst, elemI)
|
||||
for (const word& item : lst)
|
||||
{
|
||||
// Check duplicate name
|
||||
HashTable<label>::iterator iter = hashed.find(lst[elemI]);
|
||||
if (iter != hashed.end())
|
||||
// Check duplicate names
|
||||
auto iter = hashed.find(item);
|
||||
if (iter.found())
|
||||
{
|
||||
(*iter)++;
|
||||
duplicates = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hashed.insert(lst[elemI], 1);
|
||||
hashed.insert(item, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,9 +92,9 @@ void Foam::ccm::reader::warnDuplicates
|
||||
if (duplicates)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,8 +37,8 @@ License
|
||||
#include "PackedList.H"
|
||||
#include "uindirectPrimitivePatch.H"
|
||||
#include "SortableList.H"
|
||||
#include "mergePoints1.H"
|
||||
#include "ListOps1.H"
|
||||
#include "mergePoints.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
#include "ccmInternal.H" // include last to avoid any strange interactions
|
||||
|
||||
@ -479,8 +479,8 @@ void Foam::ccm::reader::readCells
|
||||
info.setPatchName(ccmReadOptstr("Label", nodeId));
|
||||
|
||||
// Lookup the name, type from boundary region info:
|
||||
Map<dictionary>::iterator dictIter = boundaryRegion_.find(info.ccmIndex);
|
||||
if (dictIter != boundaryRegion_.end())
|
||||
auto dictIter = boundaryRegion_.find(info.ccmIndex);
|
||||
if (dictIter.found())
|
||||
{
|
||||
word patchName(dictIter()["Label"]);
|
||||
word patchType(dictIter()["BoundaryType"]);
|
||||
@ -517,51 +517,6 @@ void Foam::ccm::reader::readCells
|
||||
origBndId_ = -1;
|
||||
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)
|
||||
{
|
||||
ccmBoundaryInfo& info = bndInfo[infoI];
|
||||
@ -573,27 +528,8 @@ void Foam::ccm::reader::readCells
|
||||
}
|
||||
else
|
||||
{
|
||||
if (option().combineBoundaries())
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
info.patchId = nPatches++;
|
||||
origBndId_[info.patchId] = info.ccmIndex;
|
||||
}
|
||||
|
||||
patchSizes_[info.patchId] += info.size;
|
||||
@ -622,20 +558,6 @@ void Foam::ccm::reader::readCells
|
||||
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
|
||||
@ -775,7 +697,11 @@ void Foam::ccm::reader::readCells
|
||||
kCCMIOStart,
|
||||
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
|
||||
// ccmFaces are organized as [nVert vrt1 .. vrtN]
|
||||
@ -797,7 +723,11 @@ void Foam::ccm::reader::readCells
|
||||
}
|
||||
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;
|
||||
#endif
|
||||
|
||||
Map<dictionary>::const_iterator
|
||||
iter = boundaryRegion_.find(ccmRegionId);
|
||||
auto iter = boundaryRegion_.cfind(ccmRegionId);
|
||||
|
||||
word zoneName;
|
||||
if (iter != boundaryRegion_.end())
|
||||
if (iter.found())
|
||||
{
|
||||
iter().lookup("Label") >> zoneName;
|
||||
}
|
||||
@ -1314,7 +1243,7 @@ void Foam::ccm::reader::removeUnwanted()
|
||||
{
|
||||
Map<word> keepMap;
|
||||
|
||||
forAllConstIter(Map<dictionary>, cellTable_, iter)
|
||||
forAllConstIters(cellTable_, iter)
|
||||
{
|
||||
const label tableId = iter.key();
|
||||
if (!removeMap.found(tableId))
|
||||
@ -1326,17 +1255,19 @@ void Foam::ccm::reader::removeUnwanted()
|
||||
Info<<"remove "<< nRemove << " cells in "
|
||||
<< 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 "
|
||||
<< 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
|
||||
(
|
||||
const labelList& oldToNew
|
||||
const labelUList& oldToNew
|
||||
)
|
||||
{
|
||||
forAll(domInterfaces_, elemI)
|
||||
@ -1544,8 +1475,8 @@ void Foam::ccm::reader::cleanupInterfaces()
|
||||
|
||||
if (bafInterfaces_.size() <= 0 && domInterfaces_.size() <= 0)
|
||||
{
|
||||
Info<<"0 baffle interface pairs" << endl;
|
||||
Info<<"0 domain interface pairs" << endl;
|
||||
Info<<"0 baffle interface pairs" << nl
|
||||
<<"0 domain interface pairs" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1559,8 +1490,8 @@ void Foam::ccm::reader::cleanupInterfaces()
|
||||
|
||||
forAll(domInterfaces_, elemI)
|
||||
{
|
||||
label face0 = domInterfaces_[elemI][0];
|
||||
label face1 = domInterfaces_[elemI][1];
|
||||
const label face0 = domInterfaces_[elemI][0];
|
||||
const label face1 = domInterfaces_[elemI][1];
|
||||
|
||||
Info<< "interface [" << elemI << "] = "
|
||||
<< face0 << " - " << face1 << " own/neigh = "
|
||||
@ -1821,7 +1752,7 @@ void Foam::ccm::reader::cleanupInterfaces()
|
||||
// << SubList<label>(oldToNew, nFaces_ - nInternalFaces_, nInternalFaces_)
|
||||
// << endl;
|
||||
|
||||
forAllIter(HashTable<labelList>, monitoringSets_, iter)
|
||||
forAllIters(monitoringSets_, iter)
|
||||
{
|
||||
inplaceRenumber(oldToNew, iter());
|
||||
}
|
||||
@ -1893,9 +1824,11 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|
||||
// List of patch pairs that are interfaces
|
||||
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
|
||||
(
|
||||
@ -1903,10 +1836,15 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|
||||
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
|
||||
Info<<"Warning : bad interface " << interI << " " << ifentry
|
||||
Info<<"Warning : bad interface " << ifentry.id << " " << ifentry
|
||||
<<" on patches " << patchPair << endl;
|
||||
}
|
||||
else if
|
||||
@ -1916,11 +1854,18 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|
||||
|| patchSizes_[patchPair[1]] == 0
|
||||
)
|
||||
{
|
||||
Info<<"Warning : skip interface " << interI << " " << ifentry
|
||||
<<" on patches " << patchPair << nl
|
||||
<<" has zero or different number of faces: ("
|
||||
<< patchSizes_[patchPair[0]] << " " << patchSizes_[patchPair[1]] << ")"
|
||||
<< endl;
|
||||
if (!nWarn++)
|
||||
{
|
||||
Info<<"Warning: skip interface with zero or different"
|
||||
<< " number of faces" << nl;
|
||||
}
|
||||
|
||||
Info<<" Interface:" << ifentry.id << " " << ifentry
|
||||
<<" patches " << patchPair
|
||||
<<" sizes ("
|
||||
<< patchSizes_[patchPair[0]]
|
||||
<< " " << patchSizes_[patchPair[1]] << ")"
|
||||
<< nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1947,7 +1892,8 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|
||||
// Markup points to merge
|
||||
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());
|
||||
forAll(interfacePatches, interI)
|
||||
@ -1985,12 +1931,11 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|
||||
|
||||
const UIndirectList<point> pointsToMerge(points_, addr);
|
||||
|
||||
Info<< " patch " << patch0 << ", " << patch1 << ": ("
|
||||
Info<< " patch " << patch0 << "," << patch1 << ": ("
|
||||
<< nPatch0Faces << " and " << nPatch1Faces << " faces) " << flush;
|
||||
|
||||
label nMerged = mergePoints
|
||||
const label nMerged = mergePoints
|
||||
(
|
||||
true,
|
||||
pointsToMerge,
|
||||
option().mergeTol(),
|
||||
false,
|
||||
@ -2003,9 +1948,9 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|
||||
if (nMerged)
|
||||
{
|
||||
// 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);
|
||||
@ -2175,11 +2120,11 @@ void Foam::ccm::reader::mergeInplaceInterfaces()
|
||||
// Note which one were successful
|
||||
labelHashSet done(failed0.size());
|
||||
|
||||
forAllConstIter(labelHashSet, failed0, iter0)
|
||||
forAllConstIters(failed0, iter0)
|
||||
{
|
||||
const label face0I = iter0.key();
|
||||
|
||||
forAllConstIter(labelHashSet, failed1, iter1)
|
||||
forAllConstIters(failed1, iter1)
|
||||
{
|
||||
const label face1I = iter1.key();
|
||||
|
||||
@ -2421,10 +2366,10 @@ void Foam::ccm::reader::reorderMesh()
|
||||
inplaceReorder(oldToNew, faceNeighbour_);
|
||||
inplaceReorder(oldToNew, origFaceId_);
|
||||
|
||||
forAllIter(HashTable<labelList>, monitoringSets_, iter)
|
||||
forAllIters(monitoringSets_, iter)
|
||||
{
|
||||
inplaceRenumber(oldToNew, iter());
|
||||
labelList &lst = iter();
|
||||
labelList& lst = iter.object();
|
||||
inplaceRenumber(oldToNew, lst);
|
||||
|
||||
// disallow monitoring on boundaries
|
||||
label nElem = 0;
|
||||
@ -2436,7 +2381,7 @@ void Foam::ccm::reader::reorderMesh()
|
||||
{
|
||||
lst[nElem] = lst[i];
|
||||
}
|
||||
nElem++;
|
||||
++nElem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2478,10 +2423,9 @@ void Foam::ccm::reader::addPatches
|
||||
word patchName;
|
||||
word patchType;
|
||||
|
||||
Map<dictionary>::const_iterator
|
||||
citer = boundaryRegion_.find(origBndId_[patchI]);
|
||||
auto citer = boundaryRegion_.cfind(origBndId_[patchI]);
|
||||
|
||||
if (citer != boundaryRegion_.end())
|
||||
if (citer.found())
|
||||
{
|
||||
citer().lookup("Label") >> patchName;
|
||||
citer().lookup("BoundaryType") >> patchType;
|
||||
@ -2593,7 +2537,7 @@ void Foam::ccm::reader::addFaceZones
|
||||
}
|
||||
|
||||
nZone = 0;
|
||||
forAllConstIter(HashTable<labelList>, monitoringSets_, iter)
|
||||
forAllConstIters(monitoringSets_, iter)
|
||||
{
|
||||
Info<< "faceZone " << nZone
|
||||
<< " (size: " << iter().size() << ") name: "
|
||||
@ -2612,7 +2556,7 @@ void Foam::ccm::reader::addFaceZones
|
||||
)
|
||||
);
|
||||
|
||||
nZone++;
|
||||
++nZone;
|
||||
}
|
||||
|
||||
mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
|
||||
|
||||
@ -34,7 +34,6 @@ Foam::ccm::reader::options::options()
|
||||
keepSolid_(true),
|
||||
mergeInterfaces_(false),
|
||||
renameInterfaces_(true),
|
||||
combineBoundaries_(false),
|
||||
removeBaffles_(false),
|
||||
useNumberedNames_(false),
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
removeBaffles_ = b;
|
||||
|
||||
@ -622,7 +622,7 @@ Foam::ccm::reader::readField
|
||||
// transcribe to output list
|
||||
forAll(mapData, i)
|
||||
{
|
||||
label cellId = mapData[i];
|
||||
const label cellId = mapData[i];
|
||||
scalarData[cellId] = rawData[i];
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,8 +29,8 @@ Description
|
||||
#define ccmSolutionTable_H
|
||||
|
||||
#include "SLList.H"
|
||||
#include "stringListOps.H"
|
||||
#include "Ostream.H"
|
||||
#include "stringListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -39,8 +39,16 @@ namespace Foam
|
||||
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
|
||||
@ -50,8 +58,8 @@ class namesList
|
||||
public SLList<T>
|
||||
{
|
||||
public:
|
||||
typedef typename SLList<T>::const_iterator const_iterator;
|
||||
typedef typename SLList<T>::iterator iterator;
|
||||
using const_iterator = typename SLList<T>::const_iterator;
|
||||
using iterator = typename SLList<T>::iterator;
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -65,12 +73,7 @@ public:
|
||||
//- Return true if a list element has a name that matches key
|
||||
bool found(const word& key) const
|
||||
{
|
||||
for
|
||||
(
|
||||
const_iterator iter = SLList<T>::begin();
|
||||
iter != SLList<T>::end();
|
||||
++iter
|
||||
)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
if (iter().name() == key)
|
||||
{
|
||||
@ -85,12 +88,7 @@ public:
|
||||
//- Find a list element has a name matching key
|
||||
iterator find(const word& key)
|
||||
{
|
||||
for
|
||||
(
|
||||
iterator iter = SLList<T>::begin();
|
||||
iter != SLList<T>::end();
|
||||
++iter
|
||||
)
|
||||
forAllIters(*this, iter)
|
||||
{
|
||||
if (iter().name() == key)
|
||||
{
|
||||
@ -112,12 +110,7 @@ public:
|
||||
List<word> matched(SLList<T>::size());
|
||||
|
||||
label matchI = 0;
|
||||
for
|
||||
(
|
||||
const_iterator iter = SLList<T>::begin();
|
||||
iter != SLList<T>::end();
|
||||
++iter
|
||||
)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
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
|
||||
@ -223,15 +216,6 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Set the field units
|
||||
void units(const char* units)
|
||||
{
|
||||
if (units && *units)
|
||||
{
|
||||
units_ = units;
|
||||
}
|
||||
}
|
||||
|
||||
//- Set the field 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
|
||||
@ -306,8 +291,8 @@ public:
|
||||
solutionEntry
|
||||
(
|
||||
const word& name,
|
||||
const label& iteration,
|
||||
const scalar& timeValue = 0
|
||||
const label iteration,
|
||||
const scalar timeValue = 0
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
@ -355,7 +340,7 @@ public:
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ccm::solutionTable Declaration
|
||||
Class Foam::ccm::solutionTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// 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
|
||||
@ -382,15 +367,16 @@ public:
|
||||
namesList<fieldEntry>()
|
||||
{}
|
||||
|
||||
|
||||
// Access
|
||||
|
||||
//- The maximum cell Id referenced in the list
|
||||
label maxCellId() const
|
||||
{
|
||||
label maxId = 0;
|
||||
forAllConstIter(namesList<fieldEntry>, *this, iter)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
label currMax = (iter()).maxCellId();
|
||||
const label currMax = iter().maxCellId();
|
||||
|
||||
if (maxId < currMax)
|
||||
{
|
||||
@ -406,10 +392,9 @@ public:
|
||||
label maxFaceId() const
|
||||
{
|
||||
label maxId = 0;
|
||||
|
||||
forAllConstIter(namesList<fieldEntry>, *this, iter)
|
||||
forAllConstIters(*this, iter)
|
||||
{
|
||||
label currMax = (iter()).maxFaceId();
|
||||
const label currMax = iter().maxFaceId();
|
||||
|
||||
if (maxId < currMax)
|
||||
{
|
||||
|
||||
@ -95,7 +95,7 @@ void Foam::ccm::writer::writeBoundaryRegion
|
||||
// Create dictionary lookup for constant/boundaryRegion
|
||||
dictionary typeDict;
|
||||
|
||||
forAllConstIter(Map<dictionary>, boundaryRegion_, iter)
|
||||
forAllConstIters(boundaryRegion_, iter)
|
||||
{
|
||||
const dictionary& dict = iter();
|
||||
if
|
||||
@ -207,7 +207,7 @@ void Foam::ccm::writer::writeCellTable
|
||||
|
||||
ccmID nodeId;
|
||||
|
||||
forAllConstIter(Map<dictionary>, cellTable_, iter)
|
||||
forAllConstIters(cellTable_, iter)
|
||||
{
|
||||
label intVal = iter.key();
|
||||
const dictionary& dict = iter();
|
||||
@ -292,7 +292,6 @@ void Foam::ccm::writer::writeProblem
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct for writing geometry
|
||||
Foam::ccm::writer::writer
|
||||
(
|
||||
const fileName& file,
|
||||
|
||||
@ -219,7 +219,12 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- 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)
|
||||
@ -228,7 +233,7 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Write
|
||||
// Write
|
||||
|
||||
//- Write the mesh
|
||||
void writeGeometry();
|
||||
@ -237,7 +242,7 @@ public:
|
||||
// provide optional remapping dictionary
|
||||
void writeSolution
|
||||
(
|
||||
const IOobjectList&,
|
||||
const IOobjectList& objects,
|
||||
const fileName& remappingDictName = fileName::null
|
||||
);
|
||||
|
||||
|
||||
@ -567,9 +567,9 @@ void Foam::ccm::writer::writeCells
|
||||
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");
|
||||
label tableId = cellTable_.append(dict);
|
||||
|
||||
forAll(mapData, i)
|
||||
for (auto& id : mapData)
|
||||
{
|
||||
if (mapData[i] < 0)
|
||||
if (id < 0)
|
||||
{
|
||||
mapData[i] = tableId;
|
||||
id = tableId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,8 +463,6 @@ void Foam::ccm::writer::writeSolution
|
||||
&phaseNode
|
||||
);
|
||||
|
||||
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
word fieldName = (*iter()).name();
|
||||
|
||||
@ -375,7 +375,7 @@ bool Foam::fileFormats::FIREMeshReader::readGeometry(const scalar scaleFactor)
|
||||
IOstream::streamFormat fmt = IOstream::ASCII;
|
||||
|
||||
const word ext = geometryFile_.ext();
|
||||
bool supported = FIRECore::file3dExtensions.found(ext);
|
||||
bool supported = FIRECore::file3dExtensions.hasEnum(ext);
|
||||
if (supported)
|
||||
{
|
||||
FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext];
|
||||
|
||||
@ -278,7 +278,7 @@ bool Foam::fileFormats::FIREMeshWriter::write(const fileName& meshName) const
|
||||
{
|
||||
const word ext = baseName.ext();
|
||||
|
||||
if (FIRECore::file3dExtensions.found(ext))
|
||||
if (FIRECore::file3dExtensions.hasEnum(ext))
|
||||
{
|
||||
FIRECore::fileExt3d fireFileType = FIRECore::file3dExtensions[ext];
|
||||
if (fireFileType == FIRECore::POLY_ASCII)
|
||||
|
||||
@ -90,9 +90,13 @@ void Foam::meshSubsetHelper::correct(bool verbose)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -83,6 +83,7 @@ Foam::functionObjects::volRegion::volRegion
|
||||
? regionTypeNames_.read(dict.lookup("regionType"))
|
||||
: vrtAll
|
||||
),
|
||||
regionName_(polyMesh::defaultRegion),
|
||||
regionID_(-1)
|
||||
{
|
||||
read(dict);
|
||||
@ -143,7 +144,7 @@ bool Foam::functionObjects::volRegion::read
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "Unknown region type. Valid region types are:"
|
||||
<< regionTypeNames_
|
||||
<< regionTypeNames_.toc()
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -564,9 +564,10 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": "
|
||||
<< regionTypeNames_[regionType_] << "(" << regionName_ << "):"
|
||||
<< int(regionType_) << "(" << regionName_ << "):"
|
||||
<< nl << " Unknown region type. Valid region types are:"
|
||||
<< regionTypeNames_.sortedToc() << nl << exit(FatalError);
|
||||
<< regionTypeNames_ << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -217,12 +217,17 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
word outName = fieldName + '_' + regionTypeNames_[regionType_];
|
||||
if (this->volRegion::regionName_ != polyMesh::defaultRegion)
|
||||
{
|
||||
outName = outName + '-' + this->volRegion::regionName_;
|
||||
}
|
||||
|
||||
IOField<Type>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName + '_' + regionTypeNames_[regionType_]
|
||||
+ '-' + volRegion::regionName_,
|
||||
outName,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ,
|
||||
@ -241,13 +246,17 @@ bool Foam::functionObjects::fieldValues::volFieldValue::writeValues
|
||||
file()<< tab << result;
|
||||
|
||||
Log << " " << operationTypeNames_[operation_]
|
||||
<< "(" << volRegion::regionName_ << ") of " << fieldName
|
||||
<< "(" << this->volRegion::regionName_ << ") of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
|
||||
// Write state/results information
|
||||
const word& opName = operationTypeNames_[operation_];
|
||||
word resultName =
|
||||
opName + '(' + volRegion::regionName_ + ',' + fieldName + ')';
|
||||
word outName = fieldName;
|
||||
if (this->volRegion::regionName_ != polyMesh::defaultRegion)
|
||||
{
|
||||
outName = this->volRegion::regionName_ + ',' + outName;
|
||||
}
|
||||
word resultName = opName + '(' + outName + ')';
|
||||
this->setResult(resultName, result);
|
||||
}
|
||||
|
||||
|
||||
@ -71,14 +71,14 @@ void Foam::functionObjects::mapFields::createInterpolation
|
||||
)
|
||||
);
|
||||
const fvMesh& mapRegion = mapRegionPtr_();
|
||||
word mapMethodName(dict.lookup("mapMethod"));
|
||||
if (!meshToMesh::interpolationMethodNames_.found(mapMethodName))
|
||||
const word mapMethodName(dict.lookup("mapMethod"));
|
||||
if (!meshToMesh::interpolationMethodNames_.hasEnum(mapMethodName))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << " " << name() << ": unknown map method "
|
||||
<< mapMethodName << nl
|
||||
<< "Available methods include: "
|
||||
<< meshToMesh::interpolationMethodNames_.sortedToc()
|
||||
<< meshToMesh::interpolationMethodNames_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
@ -196,7 +196,8 @@ bool Foam::functionObjects::writeObjects::write()
|
||||
FatalErrorInFunction
|
||||
<< "Unknown writeOption "
|
||||
<< writeOptionNames_[writeOption_]
|
||||
<< ". Valid writeOption types are" << writeOptionNames_
|
||||
<< ". Valid writeOption types are "
|
||||
<< writeOptionNames_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,8 @@ void Foam::fv::cellSetOption::setSelection(const dictionary& dict)
|
||||
FatalErrorInFunction
|
||||
<< "Unknown selectionMode "
|
||||
<< selectionModeTypeNames_[selectionMode_]
|
||||
<< ". Valid selectionMode types are" << selectionModeTypeNames_
|
||||
<< ". Valid selectionMode types are "
|
||||
<< selectionModeTypeNames_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -186,7 +187,8 @@ void Foam::fv::cellSetOption::setCellSet()
|
||||
FatalErrorInFunction
|
||||
<< "Unknown selectionMode "
|
||||
<< selectionModeTypeNames_[selectionMode_]
|
||||
<< ". Valid selectionMode types are" << selectionModeTypeNames_
|
||||
<< ". Valid selectionMode types are "
|
||||
<< selectionModeTypeNames_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,7 +236,7 @@ directionalPressureGradientExplicitSource
|
||||
<< "Did not find mode " << model_
|
||||
<< nl
|
||||
<< "Please set 'model' to one of "
|
||||
<< PressureDropModelNames_.toc()
|
||||
<< PressureDropModelNames_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -290,7 +290,6 @@ void Foam::fv::directionalPressureGradientExplicitSource::correct
|
||||
const scalarField nu(turbModel.nu(), cells_);
|
||||
|
||||
gradPporous_ = -flowDir_*(D_*nu + I_*0.5*magUn)*magUn*length_;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -307,6 +306,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::correct
|
||||
gradPporous_ =
|
||||
- flowDir_*(D_*mu + I_*0.5*rho*magUn)*magUn*length_;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case pConstant:
|
||||
{
|
||||
|
||||
@ -376,7 +376,8 @@ void Foam::fv::rotorDiskSource::createCoordinateSystem()
|
||||
FatalErrorInFunction
|
||||
<< "Unknown geometryMode " << geometryModeTypeNames_[gm]
|
||||
<< ". Available geometry modes include "
|
||||
<< geometryModeTypeNames_ << exit(FatalError);
|
||||
<< geometryModeTypeNames_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -493,9 +493,22 @@ void Foam::snappyLayerDriver::handleNonStringConnected
|
||||
// warning from checkMesh. These faces cannot be extruded so
|
||||
// there is no need to even attempt it.
|
||||
|
||||
List<extrudeMode> oldExtrudeStatus(extrudeStatus);
|
||||
OBJstream str(meshRefiner_.mesh().time().path()/"nonStringConnected.obj");
|
||||
Pout<< "Dumping string edges to " << str.name();
|
||||
List<extrudeMode> oldExtrudeStatus;
|
||||
autoPtr<OBJstream> str;
|
||||
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
|
||||
Map<label> nCommonPoints(100);
|
||||
@ -521,18 +534,24 @@ Pout<< "Dumping string edges to " << str.name();
|
||||
|
||||
// 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.
|
||||
void Foam::snappyLayerDriver::handleNonManifolds
|
||||
(
|
||||
|
||||
@ -25,6 +25,12 @@ $(edgeMeshFormats)/starcd/STARCDedgeFormatRunTime.C
|
||||
$(edgeMeshFormats)/vtk/VTKedgeFormat.C
|
||||
$(edgeMeshFormats)/vtk/VTKedgeFormatRunTime.C
|
||||
|
||||
|
||||
edgeMeshTools = $(em)/edgeMeshTools
|
||||
$(edgeMeshTools)/edgeMeshTools.C
|
||||
$(edgeMeshTools)/edgeMeshFeatureProximity.C
|
||||
|
||||
|
||||
$(em)/featureEdgeMesh/featureEdgeMesh.C
|
||||
|
||||
eem = $(em)/extendedEdgeMesh
|
||||
@ -215,6 +221,8 @@ triSurface/triangleFuncs/triangleFuncs.C
|
||||
triSurface/surfaceFeatures/surfaceFeatures.C
|
||||
triSurface/triSurfaceLoader/triSurfaceLoader.C
|
||||
triSurface/triSurfaceTools/triSurfaceTools.C
|
||||
triSurface/triSurfaceTools/triSurfaceCloseness.C
|
||||
triSurface/triSurfaceTools/triSurfaceCurvature.C
|
||||
triSurface/triSurfaceTools/geompack/geompack.C
|
||||
triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C
|
||||
|
||||
|
||||
228
src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C
Normal file
228
src/meshTools/edgeMesh/edgeMeshTools/edgeMeshFeatureProximity.C
Normal 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
Reference in New Issue
Block a user