Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2009-01-29 15:02:40 +00:00
108 changed files with 4182 additions and 2748 deletions

View File

@ -111,6 +111,33 @@ int main(int argc, char *argv[])
Info<< "setD : " << setD << endl; Info<< "setD : " << setD << endl;
Info<< "setB ^ setC ^ setD : " << (setB ^ setC ^ setD) << endl; Info<< "setB ^ setC ^ setD : " << (setB ^ setC ^ setD) << endl;
// test operator[]
Info<< "setD : " << setD << endl;
if (setD[0])
{
Info<< "setD has 0" << endl;
}
else
{
Info<< "setD has no 0" << endl;
}
if (setD[11])
{
Info<< "setD has 11" << endl;
}
else
{
Info<< "setD has no 0" << endl;
}
Info<< "setD : " << setD << endl;
// this doesn't work (yet?)
// setD[12] = true;
return 0; return 0;
} }

View File

@ -38,7 +38,6 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
bool changed;
Info<< "PackedList max_bits() = " << PackedList<0>::max_bits() << nl; Info<< "PackedList max_bits() = " << PackedList<0>::max_bits() << nl;
Info<< "\ntest allocation with value\n"; Info<< "\ntest allocation with value\n";
@ -46,11 +45,50 @@ int main(int argc, char *argv[])
list1.print(Info); list1.print(Info);
Info<< "\ntest assign uniform value\n"; Info<< "\ntest assign uniform value\n";
list1 = 2; list1 = 3;
list1.print(Info);
Info<< "\ntest assign uniform value (with overflow)\n";
list1 = -1;
list1.print(Info);
Info<< "\ntest assign between references\n";
list1[2] = 3;
list1[4] = list1[2];
list1.print(Info);
Info<< "\ntest assign between references, with chaining\n";
list1[4] = list1[2] = 1;
list1.print(Info);
{
const PackedList<3>& constLst = list1;
Info<< "\ntest operator[] const with out-of-range index\n";
constLst.print(Info);
if (!constLst[20])
{
Info<< "[20] is false (expected) list size should be unchanged (const)\n";
}
constLst.print(Info);
Info<< "\ntest operator[] non-const with out-of-range index\n";
if (!list1[20])
{
Info<< "[20] is false (expected) but list was resized?? (non-const)\n";
}
list1.print(Info);
}
Info<< "\ntest operator[] with out-of-range index\n";
if (!list1[20])
{
Info<< "[20] is false, as expected\n";
}
list1.print(Info); list1.print(Info);
Info<< "\ntest resize with value (without reallocation)\n"; Info<< "\ntest resize with value (without reallocation)\n";
list1.resize(6, 3); list1.resize(8, list1.max_value());
list1.print(Info); list1.print(Info);
Info<< "\ntest set() function\n"; Info<< "\ntest set() function\n";
@ -96,7 +134,7 @@ int main(int argc, char *argv[])
list1.print(Info); list1.print(Info);
Info<< "\ntest setCapacity() operation\n"; Info<< "\ntest setCapacity() operation\n";
list1.setCapacity(30); list1.setCapacity(100);
list1.print(Info); list1.print(Info);
Info<< "\ntest operator[] assignment\n"; Info<< "\ntest operator[] assignment\n";
@ -108,7 +146,15 @@ int main(int argc, char *argv[])
list1.print(Info); list1.print(Info);
Info<< "\ntest setCapacity smaller\n"; Info<< "\ntest setCapacity smaller\n";
list1.setCapacity(32); list1.setCapacity(24);
list1.print(Info);
Info<< "\ntest resize much smaller\n";
list1.resize(150);
list1.print(Info);
Info<< "\ntest trim\n";
list1.trim();
list1.print(Info); list1.print(Info);
// add in some misc values // add in some misc values
@ -118,37 +164,54 @@ int main(int argc, char *argv[])
Info<< "\ntest iterator\n"; Info<< "\ntest iterator\n";
PackedList<3>::iterator iter = list1.begin(); PackedList<3>::iterator iter = list1.begin();
Info<< "iterator:" << iter() << "\n"; Info<< "begin():";
iter.print(Info) << "\n"; iter.print(Info) << "\n";
Info<< "\ntest iterator operator=\n";
changed = (iter = 5);
Info<< "iterator:" << iter() << "\n"; Info<< "iterator:" << iter() << "\n";
Info<< "changed:" << changed << "\n"; iter() = 5;
changed = (iter = 5); iter.print(Info);
Info<< "changed:" << changed << "\n";
list1.print(Info); list1.print(Info);
iter = list1[31];
Info<< "iterator:" << iter() << "\n";
iter.print(Info);
Info<< "\ntest get() method\n"; Info<< "\ntest get() method\n";
Info<< "get(10):" << list1.get(10) Info<< "get(10):" << list1.get(10) << " and list[10]:" << list1[10] << "\n";
<< " and list[10]:" << unsigned(list1[10]) << "\n";
list1.print(Info); list1.print(Info);
Info<< "\ntest iterator indexing\n"; Info<< "\ntest iterator indexing\n";
Info<< "end() "; Info<< "cend() ";
list1.end().print(Info) << "\n"; list1.cend().print(Info) << "\n";
for (iter = list1[31]; iter != list1.end(); ++iter)
{ {
iter.print(Info); Info<< "\ntest assignment of iterator\n";
list1.print(Info);
PackedList<3>::iterator cit = list1[25];
cit.print(Info);
list1.end().print(Info);
} }
Info<< "\ntest operator[] auto-vivify\n";
const unsigned int val = list1[45];
Info<< "list[45]:" << val << "\n"; for
list1.print(Info); (
PackedList<3>::iterator cit = list1[5];
cit != list1.end();
++cit
)
{
cit.print(Info);
}
// Info<< "\ntest operator[] auto-vivify\n";
// const unsigned int val = list1[45];
//
// Info<< "list[45]:" << val << "\n";
// list1[45] = list1.max_value();
// Info<< "list[45]:" << list1[45] << "\n";
// list1[49] = list1.max_value();
// list1.print(Info);
Info<< "\ntest copy constructor + append\n"; Info<< "\ntest copy constructor + append\n";
@ -161,8 +224,15 @@ int main(int argc, char *argv[])
Info<< "\ntest pattern that fills all bits\n"; Info<< "\ntest pattern that fills all bits\n";
PackedList<4> list3(8, 8); PackedList<4> list3(8, 8);
list3[list3.size()-2] = 0;
list3[list3.size()-1] = list3.max_value(); label pos = list3.size() - 1;
list3[pos--] = list3.max_value();
list3[pos--] = 0;
list3[pos--] = list3.max_value();
list3.print(Info);
Info<< "removed final value: " << list3.remove() << endl;
list3.print(Info); list3.print(Info);
Info<< "\n\nDone.\n"; Info<< "\n\nDone.\n";

View File

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

View File

@ -0,0 +1,348 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Application
Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "boolList.H"
#include "PackedBoolList.H"
#include "HashSet.H"
#include "cpuTime.H"
#include <vector>
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
const label n = 1000000;
const label nIters = 1000;
unsigned int sum = 0;
PackedBoolList packed(n, 1);
boolList unpacked(n, true);
std::vector<bool> stlVector(n, true);
labelHashSet emptyHash;
labelHashSet fullHash(1000);
for(label i = 0; i < n; i++)
{
fullHash.insert(i);
}
cpuTime timer;
for (label iter = 0; iter < nIters; ++iter)
{
packed.resize(40);
packed.shrink();
packed.resize(n, 1);
}
Info<< "resize/shrink/resize:" << timer.cpuTimeIncrement() << " s\n\n";
// set every other bit on:
Info<< "set every other bit on and count\n";
packed.storage() = 0xAAAAAAAAu;
// Count packed
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAll(packed, i)
{
sum += packed[i];
}
}
Info<< "Counting brute-force:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
// Count packed
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
sum += packed.count();
}
Info<< "Counting via count():" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
// Dummy addition
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAll(unpacked, i)
{
sum += i + 1;
}
}
Info<< "Dummy loop:" << timer.cpuTimeIncrement() << " s" << endl;
Info<< " sum " << sum << endl;
//
// Read
//
// Read stl
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
for(unsigned int i = 0; i < stlVector.size(); i++)
{
sum += stlVector[i];
}
}
Info<< "Reading stl:" << timer.cpuTimeIncrement() << " s" << endl;
Info<< " sum " << sum << endl;
// Read unpacked
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAll(unpacked, i)
{
sum += unpacked[i];
}
}
Info<< "Reading unpacked:" << timer.cpuTimeIncrement() << " s" << endl;
Info<< " sum " << sum << endl;
// Read packed
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAll(packed, i)
{
sum += packed.get(i);
}
}
Info<< "Reading packed using get:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
// Read packed
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAll(packed, i)
{
sum += packed[i];
}
}
Info<< "Reading packed using reference:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
// Read via iterator
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
for
(
PackedBoolList::iterator it = packed.begin();
it != packed.end();
++it
)
{
sum += it;
}
}
Info<< "Reading packed using iterator:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
// Read via iterator
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
for
(
PackedBoolList::const_iterator cit = packed.cbegin();
cit != packed.cend();
++cit
)
{
sum += cit();
}
}
Info<< "Reading packed using const_iterator():" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
// Read empty hash
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAll(unpacked, i)
{
sum += emptyHash.found(i);
}
}
Info<< "Reading empty labelHashSet:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
// Read full hash
sum = 0;
for (label iter = 0; iter < nIters; ++iter)
{
forAll(unpacked, i)
{
sum += fullHash.found(i);
}
}
Info<< "Reading full labelHashSet:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info<< " sum " << sum << endl;
//
// Write
//
// Write stl
for (label iter = 0; iter < nIters; ++iter)
{
for (unsigned int i = 0; i < stlVector.size(); i++)
{
stlVector[i] = true;
}
}
Info<< "Writing stl:" << timer.cpuTimeIncrement() << " s" << endl;
// Write unpacked
for (label iter = 0; iter < nIters; ++iter)
{
forAll(unpacked, i)
{
unpacked[i] = true;
}
}
Info<< "Writing unpacked:" << timer.cpuTimeIncrement() << " s" << endl;
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
forAll(packed, i)
{
packed[i] = 1;
}
}
Info<< "Writing packed using reference:" << timer.cpuTimeIncrement()
<< " s" << endl;
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
forAll(packed, i)
{
packed.set(i, 1);
}
}
Info<< "Writing packed using set:" << timer.cpuTimeIncrement()
<< " s" << endl;
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
for
(
PackedBoolList::iterator it = packed.begin();
it != packed.end();
++it
)
{
it() = 1;
}
}
Info<< "Writing packed using iterator:" << timer.cpuTimeIncrement()
<< " s" << endl;
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
packed = 0;
}
Info<< "Writing packed uniform 0:" << timer.cpuTimeIncrement()
<< " s" << endl;
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
packed = 1;
}
Info<< "Writing packed uniform 1:" << timer.cpuTimeIncrement()
<< " s" << endl;
PackedList<3> oddPacked(n, 3);
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
packed = 0;
}
Info<< "Writing packed<3> uniform 0:" << timer.cpuTimeIncrement()
<< " s" << endl;
// Write packed
for (label iter = 0; iter < nIters; ++iter)
{
packed = 1;
}
Info<< "Writing packed<3> uniform 1:" << timer.cpuTimeIncrement()
<< " s" << endl;
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -31,6 +31,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fileName.H" #include "fileName.H"
#include "SubList.H"
#include "IOstreams.H" #include "IOstreams.H"
#include "OSspecific.H" #include "OSspecific.H"
@ -50,19 +51,55 @@ int main()
fileName pathName(wrdList); fileName pathName(wrdList);
Info<< "pathName = " << pathName << endl; Info<< "pathName = " << pathName << nl
Info<< "pathName.name() = " << pathName.name() << endl; << "pathName.name() = " << pathName.name() << nl
Info<< "pathName.path() = " << pathName.path() << endl; << "pathName.path() = " << pathName.path() << nl
Info<< "pathName.ext() = " << pathName.ext() << endl; << "pathName.ext() = " << pathName.ext() << endl;
Info<< "pathName.components() = " << pathName.components() << endl; Info<< "pathName.components() = " << pathName.components() << nl
Info<< "pathName.component(2) = " << pathName.component(2) << endl; << "pathName.component(2) = " << pathName.component(2) << nl
<< endl;
// try with different combination
for (label start = 0; start < wrdList.size(); ++start)
{
fileName instance, local;
word name;
fileName path(SubList<word>(wrdList, wrdList.size()-start, start));
fileName path2 = "." / path;
path.IOobjectComponents
(
instance,
local,
name
);
Info<< "IOobjectComponents for " << path << nl
<< " instance = " << instance << nl
<< " local = " << local << nl
<< " name = " << name << endl;
path2.IOobjectComponents
(
instance,
local,
name
);
Info<< "IOobjectComponents for " << path2 << nl
<< " instance = " << instance << nl
<< " local = " << local << nl
<< " name = " << name << endl;
}
// test findEtcFile // test findEtcFile
Info<< "\n\nfindEtcFile tests:" << nl Info<< "\n\nfindEtcFile tests:" << nl
<< " controlDict => " << findEtcFile("controlDict") << nl << " controlDict => " << findEtcFile("controlDict") << nl
<< " badName => " << findEtcFile("badName") << endl; << " badName => " << findEtcFile("badName") << endl;
Info<< "This should emit a fatal error:" << endl; Info<< "This should emit a fatal error:" << endl;
Info<< " badName(die) => " << findEtcFile("badName", true) << nl Info<< " badName(die) => " << findEtcFile("badName", true) << nl
<< endl; << endl;

View File

@ -78,10 +78,10 @@ int main(int argc, char *argv[])
# include "setRootCase.H" # include "setRootCase.H"
# include "createTime.H" # include "createTime.H"
const word dictName("blockMeshDict");
word regionName; word regionName;
fileName polyMeshDir; fileName polyMeshDir;
word dictName("blockMeshDict");
fileName dictPath(runTime.constant());
if (args.options().found("region")) if (args.options().found("region"))
{ {
@ -98,55 +98,58 @@ int main(int argc, char *argv[])
polyMeshDir = polyMesh::meshSubDir; polyMeshDir = polyMesh::meshSubDir;
} }
fileName dictLocal = polyMeshDir; autoPtr<IOobject> meshDictIoPtr;
if (args.options().found("dict")) if (args.options().found("dict"))
{ {
wordList elems(fileName(args.options()["dict"]).components()); fileName dictPath(args.options()["dict"]);
dictName = elems[elems.size()-1];
dictPath = elems[0];
dictLocal = "";
if (elems.size() == 1) meshDictIoPtr.set
{
dictPath = ".";
}
else if (elems.size() > 2)
{
dictLocal = fileName(SubList<word>(elems, elems.size()-2, 1));
}
}
bool writeTopo = args.options().found("blockTopology");
IOobject meshDictIo
( (
dictName, new IOobject
dictPath, (
dictLocal, ( dictPath.isDir() ? dictPath/dictName : dictPath ),
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
)
); );
}
else
{
meshDictIoPtr.set
(
new IOobject
(
dictName,
runTime.constant(),
polyMeshDir,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
if (!meshDictIo.headerOk()) if (!meshDictIoPtr->headerOk())
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "Cannot open mesh description file\n " << "Cannot open mesh description file\n "
<< meshDictIo.objectPath() << meshDictIoPtr->objectPath()
<< nl << nl
<< exit(FatalError); << exit(FatalError);
} }
Info<< nl << "Creating block mesh from\n " Info<< nl << "Creating block mesh from\n "
<< meshDictIo.objectPath() << nl << endl; << meshDictIoPtr->objectPath() << nl << endl;
IOdictionary meshDict(meshDictIo);
IOdictionary meshDict(meshDictIoPtr());
blockMesh blocks(meshDict); blockMesh blocks(meshDict);
if (writeTopo)
if (args.options().found("blockTopology"))
{ {
// Write mesh as edges. // Write mesh as edges.
{ {

View File

@ -276,7 +276,7 @@ int main(int argc, char *argv[])
// Read point fields and subset // Read point fields and subset
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pointMesh pMesh(mesh); const pointMesh& pMesh = pointMesh::New(mesh);
wordList pointScalarNames(objects.names(pointScalarField::typeName)); wordList pointScalarNames(objects.names(pointScalarField::typeName));
PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size()); PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size());

View File

@ -161,6 +161,10 @@ surfaces
isoField rho; isoField rho;
isoValue 0.5; isoValue 0.5;
interpolate true; interpolate true;
//zone ABC; // Optional: zone only
//exposedPatchName fixedWalls; // Optional: zone only
// regularise false; // Optional: do not simplify // regularise false; // Optional: do not simplify
} }
constantIso constantIso
@ -171,7 +175,7 @@ surfaces
isoField rho; isoField rho;
isoValue 0.5; isoValue 0.5;
interpolate false; interpolate false;
// regularise false; // Optional: do not simplify regularise false; // do not simplify
} }
); );

View File

@ -78,56 +78,61 @@ int main(int argc, char *argv[])
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
const stringList& params = args.additionalArgs(); const stringList& params = args.additionalArgs();
word dictName("coordinateSystems"); const word dictName("coordinateSystems");
fileName dictPath(runTime.constant());
fileName dictLocal;
if (args.options().found("dict"))
{
wordList elems(fileName(args.options()["dict"]).components());
dictName = elems[elems.size()-1];
dictPath = elems[0];
dictLocal = "";
if (elems.size() == 1)
{
dictPath = ".";
}
else if (elems.size() > 2)
{
dictLocal = fileName(SubList<word>(elems, elems.size()-2, 1));
}
}
autoPtr<coordinateSystem> fromCsys; autoPtr<coordinateSystem> fromCsys;
autoPtr<coordinateSystem> toCsys; autoPtr<coordinateSystem> toCsys;
if (args.options().found("from") || args.options().found("to")) if (args.options().found("from") || args.options().found("to"))
{ {
IOobject csDictIo autoPtr<IOobject> csDictIoPtr;
if (args.options().found("dict"))
{
fileName dictPath(args.options()["dict"]);
csDictIoPtr.set
( (
dictName, new IOobject
dictPath, (
dictLocal, ( dictPath.isDir() ? dictPath/dictName : dictPath ),
runTime, runTime,
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
)
); );
}
else
{
csDictIoPtr.set
(
new IOobject
(
dictName,
runTime.constant(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
}
if (!csDictIo.headerOk())
if (!csDictIoPtr->headerOk())
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "Cannot open coordinateSystems file\n " << "Cannot open coordinateSystems file\n "
<< csDictIo.objectPath() << nl << csDictIoPtr->objectPath() << nl
<< exit(FatalError); << exit(FatalError);
} }
coordinateSystems csLst(csDictIo); coordinateSystems csLst(csDictIoPtr());
if (args.options().found("from")) if (args.options().found("from"))
{ {
word csName(args.options()["from"]); const word csName(args.options()["from"]);
label csId = csLst.find(csName); label csId = csLst.find(csName);
if (csId < 0) if (csId < 0)
@ -143,7 +148,7 @@ int main(int argc, char *argv[])
if (args.options().found("to")) if (args.options().found("to"))
{ {
word csName(args.options()["to"]); const word csName(args.options()["to"]);
label csId = csLst.find(csName); label csId = csLst.find(csName);
if (csId < 0) if (csId < 0)

View File

@ -56,6 +56,7 @@ Note
#include "Time.H" #include "Time.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "triSurface.H" #include "triSurface.H"
#include "PackedBoolList.H"
#include "MeshedSurfaces.H" #include "MeshedSurfaces.H"
#include "UnsortedMeshedSurfaces.H" #include "UnsortedMeshedSurfaces.H"
@ -115,7 +116,7 @@ int main(int argc, char *argv[])
if (args.options().found("orient")) if (args.options().found("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
surf.checkOrientation(true); PatchTools::checkOrientation(surf, true);
Info<< endl; Info<< endl;
} }
@ -154,7 +155,7 @@ int main(int argc, char *argv[])
if (args.options().found("orient")) if (args.options().found("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
surf.checkOrientation(true); PatchTools::checkOrientation(surf, true);
Info<< endl; Info<< endl;
} }
@ -192,7 +193,7 @@ int main(int argc, char *argv[])
if (args.options().found("orient")) if (args.options().found("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
surf.checkOrientation(true); PatchTools::checkOrientation(surf, true);
Info<< endl; Info<< endl;
} }
@ -230,7 +231,7 @@ int main(int argc, char *argv[])
if (args.options().found("orient")) if (args.options().found("orient"))
{ {
Info<< "Checking surface orientation" << endl; Info<< "Checking surface orientation" << endl;
surf.checkOrientation(true); PatchTools::checkOrientation(surf, true);
Info<< endl; Info<< endl;
} }

View File

@ -50,7 +50,7 @@ primitives/random/Random.C
containers/HashTables/HashTable/HashTableName.C containers/HashTables/HashTable/HashTableName.C
containers/HashTables/StaticHashTable/StaticHashTableName.C containers/HashTables/StaticHashTable/StaticHashTableName.C
containers/Lists/SortableList/ParSortableListName.C containers/Lists/SortableList/ParSortableListName.C
containers/Lists/PackedList/PackedListName.C containers/Lists/PackedList/PackedListCore.C
containers/Lists/ListOps/ListOps.C containers/Lists/ListOps/ListOps.C
containers/LinkedLists/linkTypes/SLListBase/SLListBase.C containers/LinkedLists/linkTypes/SLListBase/SLListBase.C
containers/LinkedLists/linkTypes/DLListBase/DLListBase.C containers/LinkedLists/linkTypes/DLListBase/DLListBase.C

View File

@ -51,6 +51,13 @@ Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& ht)
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Key, class Hash>
inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
{
return found(key);
}
template<class Key, class Hash> template<class Key, class Hash>
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
{ {

View File

@ -133,9 +133,11 @@ public:
return HashTable<nil, Key, Hash>::insert(key, nil()); return HashTable<nil, Key, Hash>::insert(key, nil());
} }
// Member Operators // Member Operators
//- Return true if the entry exists, same as found()
inline bool operator[](const Key&) const;
//- Equality. Two hashtables are equal when their contents are equal. //- Equality. Two hashtables are equal when their contents are equal.
// Independent of table size or order. // Independent of table size or order.
bool operator==(const HashSet<Key, Hash>&) const; bool operator==(const HashSet<Key, Hash>&) const;

View File

@ -28,20 +28,20 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<int nBits> template<unsigned nBits>
Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val) Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
: :
List<PackedStorage>(packedLength(size), 0u), StorageList(packedLength(size), 0u),
size_(size) size_(size)
{ {
operator=(val); operator=(val);
} }
template<int nBits> template<unsigned nBits>
Foam::PackedList<nBits>::PackedList(const UList<label>& lst) Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
: :
List<PackedStorage>(packedLength(lst.size()), 0u), StorageList(packedLength(lst.size()), 0u),
size_(lst.size()) size_(lst.size())
{ {
forAll(lst, i) forAll(lst, i)
@ -53,7 +53,116 @@ Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<int nBits>
#if (UINT_MAX == 0xFFFFFFFF)
// 32-bit counting, Hamming weight method
# define COUNT_PACKEDBITS(sum, x) \
{ \
x -= (x >> 1) & 0x55555555; \
x = (x & 0x33333333) + ((x >> 2) & 0x33333333); \
sum += (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24; \
}
#elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF)
// 64-bit counting, Hamming weight method
# define COUNT_PACKEDBITS(sum, x) \
{ \
x -= (x >> 1) & 0x5555555555555555; \
x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333); \
sum += (((x + (x >> 4)) & 0x0F0F0F0F0F0F0F0F) * 0x0101010101010101) >> 56;\
}
#else
// Arbitrary number of bits, Brian Kernighan's method
# define COUNT_PACKEDBITS(sum, x) for (; x; ++sum) { x &= x - 1; }
#endif
template<unsigned nBits>
unsigned int Foam::PackedList<nBits>::count() const
{
register unsigned int c = 0;
if (size_)
{
// mask value for complete chunks
unsigned int mask = maskLower(packing());
unsigned int endIdx = size_ / packing();
unsigned int endOff = size_ % packing();
// count bits in complete elements
for (unsigned i = 0; i < endIdx; ++i)
{
register unsigned int bits = StorageList::operator[](i) & mask;
COUNT_PACKEDBITS(c, bits);
}
// count bits in partial chunk
if (endOff)
{
mask = maskLower(endOff);
register unsigned int bits = StorageList::operator[](endIdx) & mask;
COUNT_PACKEDBITS(c, bits);
}
}
return c;
}
template<unsigned nBits>
bool Foam::PackedList<nBits>::trim()
{
if (!size_)
{
return false;
}
// mask value for complete chunks
unsigned int mask = maskLower(packing());
label currElem = packedLength(size_) - 1;
unsigned int endOff = size_ % packing();
// clear trailing bits on final segment
if (endOff)
{
StorageList::operator[](currElem) &= maskLower(endOff);
}
// test entire chunk
while (currElem > 0 && !(StorageList::operator[](currElem) &= mask))
{
currElem--;
}
// test segment
label newsize = (currElem + 1) * packing();
// mask for the final segment
mask = max_value() << (nBits * (packing() - 1));
for (endOff = packing(); endOff >= 1; --endOff, --newsize)
{
if (StorageList::operator[](currElem) & mask)
{
break;
}
mask >>= nBits;
}
if (size_ == newsize)
{
return false;
}
size_ = newsize;
return false;
}
template<unsigned nBits>
Foam::labelList Foam::PackedList<nBits>::values() const Foam::labelList Foam::PackedList<nBits>::values() const
{ {
labelList elems(size()); labelList elems(size());
@ -66,11 +175,12 @@ Foam::labelList Foam::PackedList<nBits>::values() const
} }
template<int nBits> template<unsigned nBits>
Foam::Ostream& Foam::PackedList<nBits>::iterator::print(Ostream& os) const Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
{ {
os << "iterator<" << nBits << "> [" << position() << "]" os << "iterator<" << label(nBits) << "> ["
<< " elem:" << elem_ << " offset:" << offset_ << (index_ * packing() + offset_) << "]"
<< " index:" << index_ << " offset:" << offset_
<< " value:" << unsigned(*this) << " value:" << unsigned(*this)
<< nl; << nl;
@ -78,10 +188,10 @@ Foam::Ostream& Foam::PackedList<nBits>::iterator::print(Ostream& os) const
} }
template<int nBits> template<unsigned nBits>
Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
{ {
os << "PackedList<" << nBits << ">" os << "PackedList<" << label(nBits) << ">"
<< " max_value:" << max_value() << " max_value:" << max_value()
<< " packing:" << packing() << nl << " packing:" << packing() << nl
<< "values: " << size() << "/" << capacity() << "( "; << "values: " << size() << "/" << capacity() << "( ";
@ -90,27 +200,36 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
os << get(i) << ' '; os << get(i) << ' ';
} }
label packLen = packedLength(size_);
os << ")\n" os << ")\n"
<< "storage: " << storage().size() << "( "; << "storage: " << packLen << "/" << StorageList::size() << "( ";
label count = size(); // mask value for complete chunks
unsigned int mask = maskLower(packing());
forAll(storage(), i) for (label i=0; i < packLen; i++)
{ {
const PackedStorage& rawBits = storage()[i]; const StorageType& rawBits = StorageList::operator[](i);
// create mask for unaddressed bits // the final storage may not be full, modify mask accordingly
unsigned int addressed = 0; if (i+1 == packLen)
for (unsigned packI = 0; count && packI < packing(); packI++, count--)
{ {
addressed <<= nBits; unsigned endOff = size_ % packing();
addressed |= max_value();
if (endOff)
{
mask = maskLower(endOff);
}
else
{
continue;
}
} }
for (unsigned int testBit = 0x1 << max_bits(); testBit; testBit >>= 1) for (unsigned int testBit = (1 << max_bits()); testBit; testBit >>= 1)
{ {
if (testBit & addressed) if (testBit & mask)
{ {
if (rawBits & testBit) if (rawBits & testBit)
{ {
@ -123,7 +242,7 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
} }
else else
{ {
os << '_'; os << '.';
} }
} }
cout << ' '; cout << ' ';
@ -136,15 +255,15 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<int nBits> template<unsigned nBits>
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst) void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
{ {
setCapacity(lst.size()); setCapacity(lst.size());
List<PackedStorage>::operator=(lst); StorageList::operator=(lst);
} }
template<int nBits> template<unsigned nBits>
void Foam::PackedList<nBits>::operator=(const UList<label>& lst) void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
{ {
setCapacity(lst.size()); setCapacity(lst.size());
@ -156,10 +275,9 @@ void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
} }
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
//template<int nBits> //template<unsigned nBits>
//Foam::Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>& lst) //Foam::Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>& lst)
//{ //{
// os << lst(); // os << lst();

View File

@ -28,19 +28,46 @@ Class
Description Description
A Dynamically allocatable list of packed unsigned ints. A Dynamically allocatable list of packed unsigned ints.
Gets given the number of bits per item.
Note
The list resizing is similar to DynamicList, thus the methods clear() The list resizing is similar to DynamicList, thus the methods clear()
and setSize() behave like their DynamicList counterparts and the methods and setSize() behave like their DynamicList counterparts and the methods
reserve() and setCapacity() can be used to influence the allocation. reserve() and setCapacity() can be used to influence the allocation.
The number of bits per item is specified by the template parameter nBits.
Note
In a const context, the '[]' operator simply returns the stored value,
with out-of-range elements returned as zero.
In a non-const context, the '[]' operator returns an iteratorBase, which
may not have a valid reference for out-of-range elements.
The iteratorBase class handles the assignment of new values.
Using the iteratorBase as a proxy allows assignment of values
between list elements. Thus the following bit of code works as expected:
@code
blist[1] = blist[5]; // value assignment, not iterator position
blist[2] = blist[5] = 4; // propagates value
blist[1] = blist[5] = blist[6]; // propagates value
@endcode
Using get() or the '[]' operator are similarly fast. Looping and reading
with an iterator is approx. 15% slower, but can be more flexible.
Using the set() operator (and the '[]' operator) are marginally slower
(approx. 5%) than using an iterator, but the set() method has an
advantage that it also returns a bool if the value changed. This can be
useful for branching on changed values.
@code
blist[5] = 4;
changed = blist.set(5, 8);
if (changed) ...
@endcode
SeeAlso SeeAlso
Foam::DynamicList Foam::DynamicList
ToDo ToDo
Add checks for bad template parameters (ie, nBits=0, nBits too large). Checks for bad template parameters (ie, nBits=0, nBits too large)?
The missing const_iterator might eventually still be needed.
SourceFiles SourceFiles
PackedListI.H PackedListI.H
@ -59,9 +86,9 @@ namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
template<int nBits> class PackedList; template<unsigned nBits> class PackedList;
// template<int nBits> // template<unsigned nBits>
// Ostream& operator<<(Ostream&, const PackedList<nBits>&); // Ostream& operator<<(Ostream&, const PackedList<nBits>&);
@ -75,12 +102,13 @@ TemplateName(PackedList);
Class PackedList Declaration Class PackedList Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template <int nBits> template<unsigned nBits=1>
class PackedList class PackedList
: :
private List<unsigned int> private List<unsigned int>
{ {
typedef unsigned int PackedStorage; typedef unsigned int StorageType;
typedef List<StorageType> StorageList;
// Private data // Private data
@ -110,10 +138,12 @@ public:
//- The number of entries per packed storage element //- The number of entries per packed storage element
inline static unsigned int packing(); inline static unsigned int packing();
// Forward declaration of iterator //- Masking for all bits below the offset
class iterator; inline static unsigned int maskLower(unsigned offset);
friend class iterator;
// Forward declaration of iteratorBase
class iteratorBase;
// Constructors // Constructors
@ -152,16 +182,27 @@ public:
inline bool empty() const; inline bool empty() const;
//- Get value at index I. //- Get value at index I.
// Does not auto-vivifies entries. // Does not auto-vivify entries.
inline unsigned int get(const label) const; inline unsigned int get(const label) const;
//- Set value at index I. Return true if value changed. //- Set value at index I. Return true if value changed.
// Does not auto-vivifies entries. // Does not auto-vivify entries.
inline bool set(const label, const unsigned int val); inline bool set(const label, const unsigned int val);
//- Return the underlying packed storage
inline List<unsigned int>& storage();
//- Return the underlying packed storage //- Return the underlying packed storage
inline const List<unsigned int>& storage() const; inline const List<unsigned int>& storage() const;
//- 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;
//- Trim any trailing zero elements
bool trim();
//- Return the values as a labelList //- Return the values as a labelList
labelList values() const; labelList values() const;
@ -185,7 +226,7 @@ public:
//- Reserve allocation space for at least this size. //- Reserve allocation space for at least this size.
// Never shrinks the allocated size. // Never shrinks the allocated size.
// Optionally provide an initialization value for new elements. // Optionally provide an initialization value for new elements.
inline void reserve(const label, const unsigned int& val = 0); inline void reserve(const label);
//- Clear the list, i.e. set addressable size to zero. //- Clear the list, i.e. set addressable size to zero.
// Does not adjust the underlying storage // Does not adjust the underlying storage
@ -204,22 +245,25 @@ public:
//- Transfer contents to the Xfer container //- Transfer contents to the Xfer container
inline Xfer<PackedList<nBits> > xfer(); inline Xfer<PackedList<nBits> > xfer();
// Member operators // Member operators
//- Append a value at the end of the list //- Append a value at the end of the list
inline void append(const unsigned int val); inline void append(const unsigned int val);
//- Remove and return the last element
inline unsigned int remove();
//- Get value at index I //- Get value at index I
// Auto-vivifies any new values to zero. // Does not auto-vivify entries.
inline unsigned int operator[](const label) const; inline unsigned int operator[](const label) const;
//- Set value at index I. //- Set value at index I.
// Returns proxy to perform the actual operation. // Returns iterator to perform the actual operation.
// Auto-vivifies any new values to zero. // Does not auto-vivify entries.
inline iterator operator[](const label); inline iteratorBase operator[](const label);
//- Assignment of all entries to the given value. //- Assignment of all entries to the given value. Takes linear time.
// Does set on all elements.
inline void operator=(const unsigned int val); inline void operator=(const unsigned int val);
//- Assignment operator. Takes linear time. //- Assignment operator. Takes linear time.
@ -233,73 +277,201 @@ public:
// // Write PackedList to Ostream. // // Write PackedList to Ostream.
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&); // friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
// Iterators and helpers
//- The iterator-like class used for PackedList //- The iterator base for PackedList
class iterator // Note: data and functions are protected, to allow reuse by iterator
// and prevent most external usage.
class iteratorBase
{ {
friend class PackedList; friend class PackedList;
// Private Data protected:
//- Reference to original list // Protected Data
PackedList& list_;
//- Pointer to original list
// This also lets us use the default bitwise copy/assignment
PackedList* list_;
//- Element index within storage //- Element index within storage
unsigned elem_; unsigned index_;
//- Offset within storage element //- Offset within storage element
unsigned offset_; unsigned offset_;
//- Return the raw storage element // Protected Member Functions
inline PackedStorage& chunk() const;
//- Return the position in the PackedList //- Get value as unsigned
inline label position() const; inline unsigned int get() const;
//- Set value, returning true if changed
inline bool set(unsigned int);
//- Increment to new position
inline void incr();
//- Decrement to new position
inline void decr();
//- Move to new position, but not beyond end()
inline void seek(const iteratorBase&);
// Constructors
//- Construct null
inline iteratorBase();
//- Copy construct
inline iteratorBase(const iteratorBase&);
//- Construct from base list and position index
inline iteratorBase(const PackedList*, const label);
public:
// Member Functions
//- Return true if the element is within addressable range
inline bool valid() const;
//- Move iterator to end() if it would otherwise be out-of-range
// Returns true if the element was already ok
inline bool validate();
// Member Operators
//- Compare positions
inline bool operator==(const iteratorBase&) const;
inline bool operator!=(const iteratorBase&) const;
//- Assign value, not position.
// This allows packed[0] = packed[3] for assigning values
inline unsigned int operator=(const iteratorBase&);
//- Assign value
inline unsigned int operator=(const unsigned int val);
//- Conversion operator
inline operator unsigned int () const;
//- Print value and information
Ostream& print(Ostream&) const;
};
//- The iterator class used for PackedList
class iterator
:
public iteratorBase
{
//- Should never violate const-ness!
void operator=(const const_iterator&);
public: public:
// Constructors // Constructors
//- Construct null
inline iterator();
//- Construct from iterator base, eg iter(packedlist[i])
inline iterator(const iteratorBase&);
//- Construct from base list and position index //- Construct from base list and position index
inline iterator(const PackedList&, const label i); inline iterator(const PackedList*, const label);
// Members // Member Operators
//- Assign value, returns true if the value changed //- Assign from iteratorBase, eg iter = packedlist[i]
inline bool operator=(const unsigned int val); inline iterator& operator=(const iteratorBase&);
//- Conversion operator //- Return value
inline operator unsigned int () const; inline unsigned int operator*() const;
//- Conversion operator //- Return value
inline operator bool() const;
// Member operators
inline void operator=(const iterator&);
inline bool operator==(const iterator&) const;
inline bool operator!=(const iterator&) const;
//- Return referenced value
inline unsigned int operator()() const; inline unsigned int operator()() const;
//- Return iteratorBase for assigning values
inline iteratorBase& operator*();
//- Return iteratorBase for assigning values
inline iteratorBase& operator()();
inline iterator& operator++(); inline iterator& operator++();
inline iterator operator++(int); inline iterator operator++(int);
//- Print value and information inline iterator& operator--();
Ostream& print(Ostream&) const; inline iterator operator--(int);
}; };
//- iterator set to the beginning of the PackedList
//- iterator set to the begining of the PackedList
inline iterator begin(); inline iterator begin();
//- iterator set to beyond the end of the HashTable //- iterator set to beyond the end of the HashTable
inline iterator end(); inline iterator end();
//- The const_iterator for PackedList
class const_iterator
:
public iteratorBase
{
public:
// Constructors
//- Construct null
inline const_iterator();
//- Construct from iterator base
inline const_iterator(const iteratorBase&);
//- Construct from base list and position index
inline const_iterator(const PackedList*, const label);
//- Construct from non-const iterator
inline const_iterator(const iterator&);
// Member operators
//- Assign from iteratorBase or derived
// eg, iter = packedlist[i] or iter = [non-const]list.begin()
inline const_iterator& operator=(const iteratorBase&);
//- Return referenced value directly
inline unsigned int operator*() const;
//- Return referenced value directly
inline unsigned int operator()() const;
inline const_iterator& operator++();
inline const_iterator operator++(int);
inline const_iterator& operator--();
inline const_iterator operator--(int);
}; };
//- const_iterator set to the beginning of the PackedList
inline const_iterator cbegin() const;
//- const_iterator set to beyond the end of the PackedList
inline const_iterator cend() const;
//- const_iterator set to the beginning of the PackedList
inline const_iterator begin() const;
//- const_iterator set to beyond the end of the PackedList
inline const_iterator end() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

File diff suppressed because it is too large Load Diff

View File

@ -98,6 +98,37 @@ Foam::IOobject::IOobject
} }
Foam::IOobject::IOobject
(
const fileName& path,
const objectRegistry& registry,
readOption ro,
writeOption wo,
bool registerObject
)
:
name_(),
headerClassName_(typeName),
note_(),
instance_(),
local_(),
db_(registry),
rOpt_(ro),
wOpt_(wo),
registerObject_(registerObject),
objState_(GOOD)
{
path.IOobjectComponents(instance_, local_, name_);
if (objectRegistry::debug)
{
Info<< "Constructing IOobject called " << name_
<< " of type " << headerClassName_
<< endl;
}
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::IOobject::~IOobject() Foam::IOobject::~IOobject()

View File

@ -193,6 +193,16 @@ public:
bool registerObject=true bool registerObject=true
); );
//- Construct from path, registry, io options
IOobject
(
const fileName& path,
const objectRegistry& registry,
readOption r=NO_READ,
writeOption w=NO_WRITE,
bool registerObject=true
);
//- Clone //- Clone
Foam::autoPtr<IOobject> clone() const Foam::autoPtr<IOobject> clone() const
{ {

View File

@ -60,8 +60,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
class patchZones;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class cyclicPolyPatch Declaration Class cyclicPolyPatch Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -26,21 +26,14 @@ Class
Foam::polyPatch Foam::polyPatch
Description Description
A patch is a list of labels, which address the faces in the global face A patch is a list of labels that address the faces in the global face list.
list. Based on the global faces, the patch can calculate its own edge.
The patch can calculate its own edges based on the global faces.
Patch also contains all addressing between the faces. Patch also contains all addressing between the faces.
SourceFiles SourceFiles
polyPatch.C polyPatch.C
calcPolyPatchAddressing.C
calcPolyPatchFaceCells.C
calcPolyPatchIntBdryEdges.C
calcPolyPatchMeshEdges.C
calcPolyPatchMeshData.C
calcPolyPatchPointAddressing.C
clearPolyPatch.C
newPolyPatch.C newPolyPatch.C
polyPatchTools.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -59,10 +52,9 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
class polyBoundaryMesh;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class polyBoundaryMesh;
class polyPatch; class polyPatch;
Ostream& operator<<(Ostream&, const polyPatch&); Ostream& operator<<(Ostream&, const polyPatch&);

View File

@ -223,7 +223,7 @@ public:
// PackedList versions // PackedList versions
template <int nBits, class CombineOp> template <unsigned nBits, class CombineOp>
static void syncFaceList static void syncFaceList
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -231,14 +231,14 @@ public:
const CombineOp& cop const CombineOp& cop
); );
template <int nBits> template <unsigned nBits>
static void swapFaceList static void swapFaceList
( (
const polyMesh& mesh, const polyMesh& mesh,
PackedList<nBits>& faceValues PackedList<nBits>& faceValues
); );
template <int nBits, class CombineOp> template <unsigned nBits, class CombineOp>
static void syncPointList static void syncPointList
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -247,7 +247,7 @@ public:
const unsigned int nullValue const unsigned int nullValue
); );
template <int nBits, class CombineOp> template <unsigned nBits, class CombineOp>
static void syncEdgeList static void syncEdgeList
( (
const polyMesh& mesh, const polyMesh& mesh,

View File

@ -1570,7 +1570,7 @@ void Foam::syncTools::swapFaceList
} }
template <int nBits, class CombineOp> template <unsigned nBits, class CombineOp>
void Foam::syncTools::syncFaceList void Foam::syncTools::syncFaceList
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -1582,7 +1582,7 @@ void Foam::syncTools::syncFaceList
{ {
FatalErrorIn FatalErrorIn
( (
"syncTools<int nBits, class CombineOp>::syncFaceList" "syncTools<unsigned nBits, class CombineOp>::syncFaceList"
"(const polyMesh&, PackedList<nBits>&, const CombineOp&)" "(const polyMesh&, PackedList<nBits>&, const CombineOp&)"
) << "Number of values " << faceValues.size() ) << "Number of values " << faceValues.size()
<< " is not equal to the number of faces in the mesh " << " is not equal to the number of faces in the mesh "
@ -1691,7 +1691,7 @@ void Foam::syncTools::syncFaceList
} }
template <int nBits> template <unsigned nBits>
void Foam::syncTools::swapFaceList void Foam::syncTools::swapFaceList
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -1702,7 +1702,7 @@ void Foam::syncTools::swapFaceList
} }
template <int nBits, class CombineOp> template <unsigned nBits, class CombineOp>
void Foam::syncTools::syncPointList void Foam::syncTools::syncPointList
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -1715,7 +1715,7 @@ void Foam::syncTools::syncPointList
{ {
FatalErrorIn FatalErrorIn
( (
"syncTools<int nBits, class CombineOp>::syncPointList" "syncTools<unsigned nBits, class CombineOp>::syncPointList"
"(const polyMesh&, PackedList<nBits>&, const CombineOp&" "(const polyMesh&, PackedList<nBits>&, const CombineOp&"
", const unsigned int&)" ", const unsigned int&)"
) << "Number of values " << pointValues.size() ) << "Number of values " << pointValues.size()
@ -1870,7 +1870,7 @@ void Foam::syncTools::syncPointList
} }
template <int nBits, class CombineOp> template <unsigned nBits, class CombineOp>
void Foam::syncTools::syncEdgeList void Foam::syncTools::syncEdgeList
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -1883,7 +1883,7 @@ void Foam::syncTools::syncEdgeList
{ {
FatalErrorIn FatalErrorIn
( (
"syncTools<int nBits, class CombineOp>::syncEdgeList" "syncTools<unsigned nBits, class CombineOp>::syncEdgeList"
"(const polyMesh&, PackedList<nBits>&, const CombineOp&" "(const polyMesh&, PackedList<nBits>&, const CombineOp&"
", const unsigned int&)" ", const unsigned int&)"
) << "Number of values " << edgeValues.size() ) << "Number of values " << edgeValues.size()

View File

@ -0,0 +1,37 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "PatchTools.H"
#include "PatchToolsCheck.C"
#include "PatchToolsEdgeOwner.C"
#include "PatchToolsSearch.C"
#include "PatchToolsSortEdges.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::PatchTools
Description
A collection of tools for searching, sorting PrimitivePatch information.
The class could also be extended to include more that just static methods.
SourceFiles
PatchTools.C
PatchToolsCheck.C
PatchToolsEdgeOwner.C
PatchToolsSearch.C
PatchToolsSortEdges.C
\*---------------------------------------------------------------------------*/
#ifndef PatchTools_H
#define PatchTools_H
#include "PrimitivePatch.H"
#include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class PatchTools Declaration
\*---------------------------------------------------------------------------*/
class PatchTools
{
public:
//- Check for orientation issues.
// Returns true if problems were found.
// If a normal flips across an edge, places it in the HashSet
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
static bool checkOrientation
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const bool report = false,
labelHashSet* marked = 0
);
//- Fill faceZone with currentZone for every face reachable
// from faceI without crossing edge marked in borderEdge.
// Note: faceZone has to be sized nFaces before calling.
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
static void markZone
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const BoolListType& borderEdge,
const label faceI,
const label currentZone,
labelList& faceZone
);
//- Size and fills faceZone with zone of face.
// Zone is area reachable by edge crossing without crossing borderEdge.
// Returns number of zones.
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
static label markZones
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const BoolListType& borderEdge,
labelList& faceZone
);
//- Determine the mapping for a sub-patch.
// Only include faces for which bool-list entry is true.
// @param[in] includeFaces faces to include
// @param[out] pointMap mapping new to old localPoints
// @param[out] faceMap mapping new to old faces
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
static void subsetMap
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const BoolListType& includeFaces,
labelList& pointMap,
labelList& faceMap
);
//- Return edge-face addressing sorted by angle around the edge.
// Orientation is anticlockwise looking from edge.vec(localPoints())
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
static labelListList sortedEdgeFaces
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&
);
//- If 2 face neighbours: label of face where ordering of edge
// is consistent with righthand walk.
// If 1 neighbour: label of only face.
// If >2 neighbours: undetermined.
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
static labelList edgeOwner
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PatchTools.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,180 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "PatchTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
bool
Foam::PatchTools::checkOrientation
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const bool report,
labelHashSet* setPtr
)
{
bool foundError = false;
// Check edge normals, face normals, point normals.
forAll(p.faceEdges(), faceI)
{
const labelList& edgeLabels = p.faceEdges()[faceI];
bool valid = true;
if (edgeLabels.size() < 3)
{
if (report)
{
Info<< "Face[" << faceI << "] " << p[faceI]
<< " has fewer than 3 edges. Edges: " << edgeLabels
<< nl;
}
valid = false;
}
else
{
forAll(edgeLabels, i)
{
if (edgeLabels[i] < 0 || edgeLabels[i] >= p.nEdges())
{
if (report)
{
Info<< "edge number " << edgeLabels[i] << " on face " << faceI
<< " out-of-range\n"
<< "This usually means the input surface has "
<< "edges with more than 2 faces connected." << nl;
}
valid = false;
}
}
}
if (!valid)
{
foundError = true;
continue;
}
//
//- Compute normal from 3 points, use the first as the origin
// minor warpage should not be a problem
const Face& f = p[faceI];
const point p0(p.points()[f[0]]);
const point p1(p.points()[f[1]]);
const point p2(p.points()[f[f.size()-1]]);
const vector pointNormal((p1 - p0) ^ (p2 - p0));
if ((pointNormal & p.faceNormals()[faceI]) < 0)
{
foundError = false;
if (report)
{
Info
<< "Normal calculated from points inconsistent with faceNormal"
<< nl
<< "face: " << f << nl
<< "points: " << p0 << ' ' << p1 << ' ' << p2 << nl
<< "pointNormal:" << pointNormal << nl
<< "faceNormal:" << p.faceNormals()[faceI] << nl;
}
}
}
forAll(p.edges(), edgeI)
{
const edge& e = p.edges()[edgeI];
const labelList& neighbouringFaces = p.edgeFaces()[edgeI];
if (neighbouringFaces.size() == 2)
{
// we use localFaces() since edges() are LOCAL
// these are both already available
const Face& faceA = p.localFaces()[neighbouringFaces[0]];
const Face& faceB = p.localFaces()[neighbouringFaces[1]];
// If the faces are correctly oriented, the edges must go in
// different directions on connected faces.
if (faceA.edgeDirection(e) == faceB.edgeDirection(e))
{
if (report)
{
Info<< "face orientation incorrect." << nl
<< "localEdge[" << edgeI << "] " << e
<< " between faces:" << nl
<< " face[" << neighbouringFaces[0] << "] "
<< p[neighbouringFaces[0]]
<< " localFace: " << faceA
<< nl
<< " face[" << neighbouringFaces[1] << "] "
<< p[neighbouringFaces[1]]
<< " localFace: " << faceB
<< endl;
}
if (setPtr)
{
setPtr->insert(edgeI);
}
foundError = true;
}
}
else if (neighbouringFaces.size() != 1)
{
if (report)
{
Info
<< "Wrong number of edge neighbours." << nl
<< "edge[" << edgeI << "] " << e
<< " with points:" << p.localPoints()[e.start()]
<< ' ' << p.localPoints()[e.end()]
<< " has neighbouringFaces:" << neighbouringFaces << endl;
}
if (setPtr)
{
setPtr->insert(edgeI);
}
foundError = true;
}
}
return foundError;
}
// ************************************************************************* //

View File

@ -0,0 +1,95 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "PatchTools.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::labelList
Foam::PatchTools::edgeOwner
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
)
{
const edgeList& edges = p.edges();
const labelListList& edgeFaces = p.edgeFaces();
const List<Face>& localFaces = p.localFaces();
// create the owner list
labelList edgeOwner(edges.size(), -1);
forAll(edges, edgeI)
{
const labelList& nbrFaces = edgeFaces[edgeI];
if (nbrFaces.size() == 1)
{
edgeOwner[edgeI] = nbrFaces[0];
}
else
{
// Find the first face whose vertices are aligned with the edge.
// with multiply connected edges, this is the best we can do
forAll(nbrFaces, i)
{
const Face& f = localFaces[nbrFaces[i]];
if (f.edgeDirection(edges[edgeI]) > 0)
{
edgeOwner[edgeI] = nbrFaces[i];
break;
}
}
if (edgeOwner[edgeI] == -1)
{
FatalErrorIn
(
"PatchTools::edgeOwner()"
)
<< "Edge " << edgeI << " vertices:" << edges[edgeI]
<< " is used by faces " << nbrFaces
<< " vertices:"
<< IndirectList<Face>(localFaces, nbrFaces)()
<< " none of which use the edge vertices in the same order"
<< nl << "I give up" << abort(FatalError);
}
}
}
return edgeOwner;
}
// ************************************************************************* //

View File

@ -22,35 +22,42 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Searching and marking zones of the patch.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "PrimitivePatchExtra.H" #include "PatchTools.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Finds area, starting at faceI, delimited by borderEdge. Marks all visited // Finds area, starting at faceI, delimited by borderEdge.
// faces (from face-edge-face walk) with currentZone. // Marks all visited faces (from face-edge-face walk) with currentZone.
template template
< <
class BoolListType,
class Face, class Face,
template<class> class FaceList, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
void
Foam::PatchTools::markZone
( (
const UList<bool>& borderEdge, const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const BoolListType& borderEdge,
const label faceI, const label faceI,
const label currentZone, const label currentZone,
labelList& faceZone labelList& faceZone
) const )
{ {
const labelListList& faceEdges = p.faceEdges();
const labelListList& edgeFaces = p.edgeFaces();
// List of faces whose faceZone has been set. // List of faces whose faceZone has been set.
labelList changedFaces(1, faceI); labelList changedFaces(1, faceI);
const labelListList& faceEs = this->faceEdges();
const labelListList& eFaces = this->edgeFaces();
while (true) while (true)
{ {
// Pick up neighbours of changedFaces // Pick up neighbours of changedFaces
@ -60,7 +67,7 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
{ {
label faceI = changedFaces[i]; label faceI = changedFaces[i];
const labelList& fEdges = faceEs[faceI]; const labelList& fEdges = faceEdges[faceI];
forAll(fEdges, fEdgeI) forAll(fEdges, fEdgeI)
{ {
@ -68,7 +75,7 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
if (!borderEdge[edgeI]) if (!borderEdge[edgeI])
{ {
const labelList& eFaceLst = eFaces[edgeI]; const labelList& eFaceLst = edgeFaces[edgeI];
forAll(eFaceLst, j) forAll(eFaceLst, j)
{ {
@ -83,8 +90,8 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
{ {
FatalErrorIn FatalErrorIn
( (
"PrimitivePatchExtra<Face, FaceList, PointField>::markZone" "PatchTools::markZone"
"(const boolList&, const label, const label, labelList&) const" "(const boolList&, const label, const label, labelList&)"
) )
<< "Zones " << faceZone[nbrFaceI] << "Zones " << faceZone[nbrFaceI]
<< " at face " << nbrFaceI << " at face " << nbrFaceI
@ -112,60 +119,38 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
// Fills faceZone accordingly // Fills faceZone accordingly
template template
< <
class BoolListType,
class Face, class Face,
template<class> class FaceList, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
Foam::label Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
markZones Foam::label
Foam::PatchTools::markZones
( (
const UList<bool>& borderEdge, const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const BoolListType& borderEdge,
labelList& faceZone labelList& faceZone
) const
{
const label numEdges = this->nEdges();
const label numFaces = this->size();
if (borderEdge.size() != numEdges)
{
FatalErrorIn
(
"PrimitivePatchExtra<Face, FaceList, PointField>::markZones"
"(const boolList&, labelList&)"
) )
<< "borderEdge boolList not same size as number of edges" << endl {
<< "borderEdge:" << borderEdge.size() << endl faceZone.setSize(p.size());
<< "nEdges :" << numEdges
<< exit(FatalError);
}
faceZone.setSize(numFaces);
faceZone = -1; faceZone = -1;
label zoneI = 0; label zoneI = 0;
label startFaceI = 0; for (label startFaceI = 0; startFaceI < faceZone.size();)
while (true)
{ {
// Find first non-visited face // Find next non-visited face
for (; startFaceI < numFaces; startFaceI++) for (; startFaceI < faceZone.size(); ++startFaceI)
{ {
if (faceZone[startFaceI] == -1) if (faceZone[startFaceI] == -1)
{ {
faceZone[startFaceI] = zoneI; faceZone[startFaceI] = zoneI;
markZone(borderEdge, startFaceI, zoneI, faceZone); markZone(p, borderEdge, startFaceI, zoneI, faceZone);
break;
}
}
if (startFaceI >= numFaces)
{
// Finished
break;
}
zoneI++; zoneI++;
break;
}
}
} }
return zoneI; return zoneI;
@ -177,39 +162,41 @@ markZones
// Fills faceZone accordingly // Fills faceZone accordingly
template template
< <
class BoolListType,
class Face, class Face,
template<class> class FaceList, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
subsetMap void
Foam::PatchTools::subsetMap
( (
const UList<bool>& include, const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const BoolListType& includeFaces,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const )
{ {
const List<Face>& locFaces = this->localFaces();
const label numPoints = this->nPoints();
label faceI = 0; label faceI = 0;
label pointI = 0; label pointI = 0;
faceMap.setSize(locFaces.size()); const List<Face>& localFaces = p.localFaces();
pointMap.setSize(numPoints);
boolList pointHad(numPoints, false); faceMap.setSize(localFaces.size());
pointMap.setSize(p.nPoints());
forAll(include, oldFaceI) boolList pointHad(pointMap.size(), false);
forAll(p, oldFaceI)
{ {
if (include[oldFaceI]) if (includeFaces[oldFaceI])
{ {
// Store new faces compact // Store new faces compact
faceMap[faceI++] = oldFaceI; faceMap[faceI++] = oldFaceI;
// Renumber labels for face // Renumber labels for face
const Face& f = locFaces[oldFaceI]; const Face& f = localFaces[oldFaceI];
forAll(f, fp) forAll(f, fp)
{ {
@ -229,6 +216,4 @@ subsetMap
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "PatchTools.H"
#include "SortableList.H"
#include "transform.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::labelListList
Foam::PatchTools::sortedEdgeFaces
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
)
{
const edgeList& edges = p.edges();
const labelListList& edgeFaces = p.edgeFaces();
const List<Face>& localFaces = p.localFaces();
const Field<PointType>& localPoints = p.localPoints();
// create the lists for the various results. (resized on completion)
labelListList& sortedEdgeFaces = labelListList(edgeFaces.size());
forAll(edgeFaces, edgeI)
{
const labelList& faceNbs = edgeFaces[edgeI];
if (faceNbs.size() > 2)
{
// Get point on edge and normalized direction of edge (= e2 base
// of our coordinate system)
const edge& e = edges[edgeI];
const point& edgePt = localPoints[e.start()];
vector e2 = e.vec(localPoints);
e2 /= mag(e2) + VSMALL;
// Get opposite vertex for 0th face
const Face& f = localFaces[faceNbs[0]];
label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0);
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
// Get vector normal both to e2 and to edge from opposite vertex
// to edge (will be x-axis of our coordinate system)
vector e0 = e2 ^ (localPoints[vertI] - edgePt);
e0 /= mag(e0) + VSMALL;
// Get y-axis of coordinate system
vector e1 = e2 ^ e0;
SortableList<scalar> faceAngles(faceNbs.size());
// e0 is reference so angle is 0
faceAngles[0] = 0;
for (label nbI = 1; nbI < faceNbs.size(); nbI++)
{
// Get opposite vertex
const Face& f = localFaces[faceNbs[nbI]];
label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0);
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
vector vec = e2 ^ (localPoints[vertI] - edgePt);
vec /= mag(vec) + VSMALL;
faceAngles[nbI] = pseudoAngle
(
e0,
e1,
vec
);
}
faceAngles.sort();
sortedEdgeFaces[edgeI] = IndirectList<label>
(
faceNbs,
faceAngles.indices()
);
}
else
{
// No need to sort. Just copy.
sortedEdgeFaces[edgeI] = faceNbs;
}
}
return sortedEdgeFaces;
}
// ************************************************************************* //

View File

@ -26,11 +26,6 @@ License
#include "Map.H" #include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components // Construct from components
@ -41,7 +36,9 @@ template
class PointField, class PointField,
class PointType class PointType
> >
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch
( (
const FaceList<Face>& faces, const FaceList<Face>& faces,
const Field<PointType>& points const Field<PointType>& points
@ -76,7 +73,9 @@ template
class PointField, class PointField,
class PointType class PointType
> >
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch
( (
FaceList<Face>& faces, FaceList<Face>& faces,
Field<PointType>& points, Field<PointType>& points,
@ -112,7 +111,9 @@ template
class PointField, class PointField,
class PointType class PointType
> >
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch
( (
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
) )
@ -148,7 +149,8 @@ template
class PointField, class PointField,
class PointType class PointType
> >
PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
{ {
clearOut(); clearOut();
} }
@ -164,7 +166,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::movePoints
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
movePoints
( (
const Field<PointType>& const Field<PointType>&
) )
@ -188,8 +193,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const edgeList&
PrimitivePatch<Face, FaceList, PointField, PointType>::edges() const const Foam::edgeList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edges() const
{ {
if (!edgesPtr_) if (!edgesPtr_)
{ {
@ -207,8 +214,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
label PrimitivePatch<Face, FaceList, PointField, PointType>::nInternalEdges()
const Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
nInternalEdges() const
{ {
if (!edgesPtr_) if (!edgesPtr_)
{ {
@ -226,8 +235,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelList&
PrimitivePatch<Face, FaceList, PointField, PointType>::boundaryPoints() const const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
boundaryPoints() const
{ {
if (!boundaryPointsPtr_) if (!boundaryPointsPtr_)
{ {
@ -245,8 +256,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelListList&
PrimitivePatch<Face, FaceList, PointField, PointType>::faceFaces() const const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceFaces() const
{ {
if (!faceFacesPtr_) if (!faceFacesPtr_)
{ {
@ -264,8 +277,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelListList&
PrimitivePatch<Face, FaceList, PointField, PointType>::edgeFaces() const const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edgeFaces() const
{ {
if (!edgeFacesPtr_) if (!edgeFacesPtr_)
{ {
@ -283,8 +298,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelListList&
PrimitivePatch<Face, FaceList, PointField, PointType>::faceEdges() const const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceEdges() const
{ {
if (!faceEdgesPtr_) if (!faceEdgesPtr_)
{ {
@ -302,8 +319,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelListList&
PrimitivePatch<Face, FaceList, PointField, PointType>::pointEdges() const const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointEdges() const
{ {
if (!pointEdgesPtr_) if (!pointEdgesPtr_)
{ {
@ -321,8 +340,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelListList&
PrimitivePatch<Face, FaceList, PointField, PointType>::pointFaces() const const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointFaces() const
{ {
if (!pointFacesPtr_) if (!pointFacesPtr_)
{ {
@ -340,8 +361,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const List<Face>&
PrimitivePatch<Face, FaceList, PointField, PointType>::localFaces() const const Foam::List<Face>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localFaces() const
{ {
if (!localFacesPtr_) if (!localFacesPtr_)
{ {
@ -359,8 +382,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelList&
PrimitivePatch<Face, FaceList, PointField, PointType>::meshPoints() const const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshPoints() const
{ {
if (!meshPointsPtr_) if (!meshPointsPtr_)
{ {
@ -378,8 +403,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Map<label>&
PrimitivePatch<Face, FaceList, PointField, PointType>::meshPointMap() const const Foam::Map<Foam::label>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshPointMap() const
{ {
if (!meshPointMapPtr_) if (!meshPointMapPtr_)
{ {
@ -397,8 +424,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Field<PointType>&
PrimitivePatch<Face, FaceList, PointField, PointType>::localPoints() const const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localPoints() const
{ {
if (!localPointsPtr_) if (!localPointsPtr_)
{ {
@ -416,8 +445,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelList&
PrimitivePatch<Face, FaceList, PointField, PointType>::localPointOrder() const const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localPointOrder() const
{ {
if (!localPointOrderPtr_) if (!localPointOrderPtr_)
{ {
@ -435,16 +466,19 @@ template
class PointField, class PointField,
class PointType class PointType
> >
label PrimitivePatch<Face, FaceList, PointField, PointType>::whichPoint
Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
whichPoint
( (
const label gp const label gp
) const ) const
{ {
Map<label>::const_iterator gpIter = meshPointMap().find(gp); Map<label>::const_iterator fnd = meshPointMap().find(gp);
if (gpIter != meshPointMap().end()) if (fnd != meshPointMap().end())
{ {
return gpIter(); return fnd();
} }
else else
{ {
@ -461,8 +495,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Field<PointType>&
PrimitivePatch<Face, FaceList, PointField, PointType>::faceNormals() const const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceNormals() const
{ {
if (!faceNormalsPtr_) if (!faceNormalsPtr_)
{ {
@ -480,8 +516,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const Field<PointType>&
PrimitivePatch<Face, FaceList, PointField, PointType>::pointNormals() const const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointNormals() const
{ {
if (!pointNormalsPtr_) if (!pointNormalsPtr_)
{ {
@ -501,7 +539,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::operator=
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
operator=
( (
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
) )
@ -511,11 +552,6 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::operator=
FaceList<Face>::operator=(pp); FaceList<Face>::operator=(pp);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "PrimitivePatchAddressing.C" #include "PrimitivePatchAddressing.C"

View File

@ -28,10 +28,10 @@ Class
Description Description
A list of faces which address into the list of points. A list of faces which address into the list of points.
The class is templated on the form of the face (e.g. triangle, polygon The class is templated on the face type (e.g. triangle, polygon etc.)
etc.) and on the form of list for faces and points so that it can and on the list type of faces and points so that it can refer to
refer to existing lists using UList and const pointField& or hold the existing lists using UList and const pointField& or hold the storage
storage using List and pointField. using List and pointField.
SourceFiles SourceFiles
PrimitivePatchAddressing.C PrimitivePatchAddressing.C
@ -211,6 +211,9 @@ private:
//- Calculate unit point normals //- Calculate unit point normals
void calcPointNormals() const; void calcPointNormals() const;
//- Calculate edge owner
void calcEdgeOwner() const;
//- Face-edge-face walk while remaining on a patch point. //- Face-edge-face walk while remaining on a patch point.
// Used to determine if surface multiply connected through point. // Used to determine if surface multiply connected through point.
@ -340,13 +343,13 @@ public:
//- Return orders the local points for most efficient search //- Return orders the local points for most efficient search
const labelList& localPointOrder() const; const labelList& localPointOrder() const;
//- Given a global point index, return the local point //- Given a global point index, return the local point index.
//index. If the point is not found, return -1 // If the point is not found, return -1
label whichPoint(const label gp) const; label whichPoint(const label gp) const;
//- Given an edge in local point labels, return its //- Given an edge in local point labels, return its
// index in the edge list. If the edge is not found, return -1 // index in the edge list. If the edge is not found, return -1
label whichEdge(const edge& e) const; label whichEdge(const edge&) const;
//- Return labels of patch edges in the global edge list using //- Return labels of patch edges in the global edge list using
// cell addressing // cell addressing
@ -380,8 +383,8 @@ public:
( (
const ToPatch& targetPatch, const ToPatch& targetPatch,
const Field<PointType>& projectionDirection, const Field<PointType>& projectionDirection,
const intersection::algorithm alg = intersection::FULL_RAY, const intersection::algorithm = intersection::FULL_RAY,
const intersection::direction dir = intersection::VECTOR const intersection::direction = intersection::VECTOR
) const; ) const;
//- Project vertices of patch onto another patch //- Project vertices of patch onto another patch
@ -390,8 +393,8 @@ public:
( (
const ToPatch& targetPatch, const ToPatch& targetPatch,
const Field<PointType>& projectionDirection, const Field<PointType>& projectionDirection,
const intersection::algorithm alg = intersection::FULL_RAY, const intersection::algorithm = intersection::FULL_RAY,
const intersection::direction dir = intersection::VECTOR const intersection::direction = intersection::VECTOR
) const; ) const;
//- Return list of closed loops of boundary vertices. //- Return list of closed loops of boundary vertices.
@ -409,8 +412,8 @@ public:
surfaceTopo surfaceType() const; surfaceTopo surfaceType() const;
//- Check surface formed by patch for manifoldness (see above). //- Check surface formed by patch for manifoldness (see above).
// Insert vertices of incorrect // Return true if any incorrect edges are found.
// edges set. Return true if any incorrect edge found. // Insert vertices of incorrect edges into set.
bool checkTopology bool checkTopology
( (
const bool report = false, const bool report = false,

View File

@ -39,11 +39,6 @@ Description
#include "DynamicList.H" #include "DynamicList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template template
@ -53,8 +48,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
const void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcAddressing() const
{ {
if (debug) if (debug)
{ {
@ -311,8 +308,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,10 +29,6 @@ Description
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "HashSet.H" #include "HashSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -43,8 +39,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcBdryPoints()
const void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcBdryPoints() const
{ {
if (debug) if (debug)
{ {
@ -91,8 +89,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcBdryPoints()
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -31,10 +31,6 @@ Description
#include "Map.H" #include "Map.H"
#include "ListOps.H" #include "ListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -45,7 +41,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::visitPointRegion
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
visitPointRegion
( (
const label pointI, const label pointI,
const labelList& pFaces, const labelList& pFaces,
@ -121,8 +120,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
typename PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceType() const typename Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
surfaceType() const
{ {
if (debug) if (debug)
{ {
@ -173,7 +174,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
bool PrimitivePatch<Face, FaceList, PointField, PointType>::checkTopology
bool
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
checkTopology
( (
const bool report, const bool report,
labelHashSet* setPtr labelHashSet* setPtr
@ -241,8 +245,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
bool bool
PrimitivePatch<Face, FaceList, PointField, PointType>::checkPointManifold Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
checkPointManifold
( (
const bool report, const bool report,
labelHashSet* setPtr labelHashSet* setPtr
@ -331,8 +337,4 @@ PrimitivePatch<Face, FaceList, PointField, PointType>::checkPointManifold
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -29,10 +29,6 @@ Description
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -43,7 +39,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearGeom()
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearGeom()
{ {
if (debug) if (debug)
{ {
@ -65,7 +64,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearTopology()
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearTopology()
{ {
if (debug) if (debug)
{ {
@ -91,10 +93,8 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::clearTopology()
} }
deleteDemandDrivenData(boundaryPointsPtr_); deleteDemandDrivenData(boundaryPointsPtr_);
deleteDemandDrivenData(pointEdgesPtr_); deleteDemandDrivenData(pointEdgesPtr_);
deleteDemandDrivenData(pointFacesPtr_); deleteDemandDrivenData(pointFacesPtr_);
deleteDemandDrivenData(edgeLoopsPtr_); deleteDemandDrivenData(edgeLoopsPtr_);
} }
@ -106,7 +106,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearPatchMeshAddr()
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearPatchMeshAddr()
{ {
if (debug) if (debug)
{ {
@ -129,7 +132,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearOut()
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearOut()
{ {
clearGeom(); clearGeom();
clearTopology(); clearTopology();
@ -137,8 +143,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::clearOut()
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,10 +30,7 @@ Description
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -44,8 +41,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops()
const void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcEdgeLoops() const
{ {
if (debug) if (debug)
{ {
@ -95,7 +94,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops()
// Current loop number. // Current loop number.
label loopI = 0; label loopI = 0;
for (;;) while (true)
{ {
// Find edge not yet given a loop number. // Find edge not yet given a loop number.
label currentEdgeI = -1; label currentEdgeI = -1;
@ -175,8 +174,10 @@ template
class PointField, class PointField,
class PointType class PointType
> >
const labelListList&
PrimitivePatch<Face, FaceList, PointField, PointType>::edgeLoops() const const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edgeLoops() const
{ {
if (!edgeLoopsPtr_) if (!edgeLoopsPtr_)
{ {
@ -186,8 +187,5 @@ PrimitivePatch<Face, FaceList, PointField, PointType>::edgeLoops() const
return *edgeLoopsPtr_; return *edgeLoopsPtr_;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,11 +30,6 @@ Description
#include "SLList.H" #include "SLList.H"
#include "boolList.H" #include "boolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template template
@ -44,7 +39,9 @@ template
class PointField, class PointField,
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcLocalPointOrder() const calcLocalPointOrder() const
{ {
// Note: Cannot use bandCompressing as point-point addressing does // Note: Cannot use bandCompressing as point-point addressing does
@ -140,9 +137,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,10 +27,7 @@ License
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "Map.H" #include "Map.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -42,7 +39,9 @@ template
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcMeshData() const void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcMeshData() const
{ {
if (debug) if (debug)
{ {
@ -128,8 +127,9 @@ template
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcMeshPointMap() void
const Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcMeshPointMap() const
{ {
if (debug) if (debug)
{ {
@ -179,8 +179,9 @@ template
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcLocalPoints() void
const Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcLocalPoints() const
{ {
if (debug) if (debug)
{ {
@ -231,8 +232,9 @@ template
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointNormals() void
const Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointNormals() const
{ {
if (debug) if (debug)
{ {
@ -298,8 +300,9 @@ template
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcFaceNormals() void
const Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcFaceNormals() const
{ {
if (debug) if (debug)
{ {
@ -341,8 +344,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcFaceNormals()
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -28,10 +28,6 @@ Description
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -43,7 +39,9 @@ template
class PointType class PointType
> >
labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges Foam::labelList
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshEdges
( (
const edgeList& allEdges, const edgeList& allEdges,
const labelListList& cellEdges, const labelListList& cellEdges,
@ -119,7 +117,9 @@ template
class PointType class PointType
> >
labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges Foam::labelList
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshEdges
( (
const edgeList& allEdges, const edgeList& allEdges,
const labelListList& pointEdges const labelListList& pointEdges
@ -175,7 +175,9 @@ template
class PointType class PointType
> >
label PrimitivePatch<Face, FaceList, PointField, PointType>::whichEdge Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
whichEdge
( (
const edge& e const edge& e
) const ) const
@ -201,8 +203,4 @@ label PrimitivePatch<Face, FaceList, PointField, PointType>::whichEdge
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,10 +30,6 @@ Description
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "SLList.H" #include "SLList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -45,8 +41,9 @@ template
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointEdges() void
const Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointEdges() const
{ {
if (debug) if (debug)
{ {
@ -116,8 +113,9 @@ template
class PointType class PointType
> >
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointFaces() void
const Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointFaces() const
{ {
if (debug) if (debug)
{ {
@ -183,8 +181,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointFaces()
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -33,11 +33,6 @@ Description
#include "objectHit.H" #include "objectHit.H"
#include "bandCompression.H" #include "bandCompression.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template template
@ -49,7 +44,8 @@ template
> >
template <class ToPatch> template <class ToPatch>
List<objectHit> PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::List<Foam::objectHit>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
projectPoints projectPoints
( (
const ToPatch& targetPatch, const ToPatch& targetPatch,
@ -59,7 +55,6 @@ projectPoints
) const ) const
{ {
// The current patch is slave, i.e. it is being projected onto the target // The current patch is slave, i.e. it is being projected onto the target
//
if (projectionDirection.size() != nPoints()) if (projectionDirection.size() != nPoints())
{ {
@ -297,7 +292,8 @@ template
> >
template <class ToPatch> template <class ToPatch>
List<objectHit> PrimitivePatch<Face, FaceList, PointField, PointType>:: Foam::List<Foam::objectHit>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
projectFaceCentres projectFaceCentres
( (
const ToPatch& targetPatch, const ToPatch& targetPatch,
@ -307,7 +303,6 @@ projectFaceCentres
) const ) const
{ {
// The current patch is slave, i.e. it is being projected onto the target // The current patch is slave, i.e. it is being projected onto the target
//
if (projectionDirection.size() != this->size()) if (projectionDirection.size() != this->size())
{ {
@ -532,8 +527,4 @@ projectFaceCentres
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -1,173 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "PrimitivePatchExtra.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
PrimitivePatchExtra
(
const FaceList<Face>& faces,
const Field<PointType>& points
)
:
ParentType(faces, points),
sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL)
{}
// Construct as copy
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
PrimitivePatchExtra
(
const PrimitivePatchExtra<Face, FaceList, PointField, PointType>& pp
)
:
ParentType(pp),
sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
~PrimitivePatchExtra()
{
clearOut();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
clearOut()
{
ParentType::clearOut();
clearTopology();
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
clearTopology()
{
ParentType::clearTopology();
deleteDemandDrivenData(sortedEdgeFacesPtr_);
deleteDemandDrivenData(edgeOwnerPtr_);
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::labelListList&
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
sortedEdgeFaces() const
{
if (!sortedEdgeFacesPtr_)
{
calcSortedEdgeFaces();
}
return *sortedEdgeFacesPtr_;
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::labelList&
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
edgeOwner() const
{
if (!edgeOwnerPtr_)
{
calcEdgeOwner();
}
return *edgeOwnerPtr_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "PrimitivePatchExtraAddressing.C"
#include "PrimitivePatchExtraCleanup.C"
#include "PrimitivePatchExtraSearch.C"
// ************************************************************************* //

View File

@ -1,205 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::PrimitivePatchExtra
Description
PrimitivePatch with some extra functionality.
SourceFiles
PrimitivePatchExtra.C
\*---------------------------------------------------------------------------*/
#ifndef PrimitivePatchExtra_H
#define PrimitivePatchExtra_H
#include "PrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class PrimitivePatchExtra Declaration
\*---------------------------------------------------------------------------*/
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType=point
>
class PrimitivePatchExtra
:
public PrimitivePatch<Face, FaceList, PointField, PointType>
{
public:
// Public typedefs
typedef Face FaceType;
typedef FaceList<Face> FaceListType;
typedef PointField PointFieldType;
private:
// Private typedefs
typedef PrimitivePatch<Face, FaceList, PointField, PointType> ParentType;
// Private data
// Demand driven private data
//- Edge-face addressing (sorted)
mutable labelListList* sortedEdgeFacesPtr_;
//- Label of face that 'owns' edge
// i.e. e.vec() is righthanded walk along face
mutable labelList* edgeOwnerPtr_;
// Private Member Functions
//- Calculate sorted edgeFaces
void calcSortedEdgeFaces() const;
//- Calculate owner
void calcEdgeOwner() const;
public:
// Constructors
//- Construct from components
PrimitivePatchExtra
(
const FaceList<Face>& faces,
const Field<PointType>& points
);
//- Construct as copy
PrimitivePatchExtra
(
const PrimitivePatchExtra<Face, FaceList, PointField, PointType>&
);
// Destructor
virtual ~PrimitivePatchExtra();
void clearOut();
void clearTopology();
// Member Functions
// Access functions for demand driven data
// Topological data; no mesh required.
//- Return edge-face addressing sorted by angle around the edge.
// Orientation is anticlockwise looking from edge.vec(localPoints())
const labelListList& sortedEdgeFaces() const;
//- If 2 face neighbours: label of face where ordering of edge
// is consistent with righthand walk.
// If 1 neighbour: label of only face.
// If >2 neighbours: undetermined.
const labelList& edgeOwner() const;
// Addressing into mesh
// Other patch operations
// Check
//- Check multiply-connected edges.
void checkEdges(const bool verbose) const;
//- Check orientation (normals) and normals of neighbouring faces
boolList checkOrientation(const bool verbose) const;
// Edit
//- Fill faceZone with currentZone for every face reachable
// from faceI without crossing edge marked in borderEdge.
// Note: faceZone has to be sized nFaces before calling.
void markZone
(
const UList<bool>& borderEdge,
const label faceI,
const label currentZone,
labelList& faceZone
) const;
//- (size and) fills faceZone with zone of face.
// Zone is area reachable by edge crossing without crossing borderEdge
// (bool for every edge in surface). Returns number of zones.
label markZones
(
const UList<bool>& borderEdge,
labelList& faceZone
) const;
//- Determine the mapping for a sub-mesh.
// Only include faces for which bool List entry is true
// @param[out] pointMap mapping new to old localPoints
// @param[out] faceMap mapping new to old faces
void subsetMap
(
const UList<bool>& include,
labelList& pointMap,
labelList& faceMap
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PrimitivePatchExtra.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,218 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Contains fix for PrimitivePatch addressing (which doesn't work if surface
is non-manifold). Should be moved into PrimitivePatch.
\*---------------------------------------------------------------------------*/
#include "PrimitivePatchExtra.H"
#include "HashTable.H"
#include "SortableList.H"
#include "transform.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
calcSortedEdgeFaces() const
{
if (sortedEdgeFacesPtr_)
{
FatalErrorIn
(
"PrimitivePatchExtra<Face, FaceList, PointField>::"
"calcSortedEdgeFaces()"
)
<< "sortedEdgeFacesPtr_ already set"
<< abort(FatalError);
}
const labelListList& eFaces = this->edgeFaces();
const edgeList& edgeLst = this->edges();
const Field<PointType>& locPointLst = this->localPoints();
const List<Face>& locFaceLst = this->localFaces();
// create the lists for the various results. (resized on completion)
sortedEdgeFacesPtr_ = new labelListList(eFaces.size());
labelListList& sortedEdgeFaces = *sortedEdgeFacesPtr_;
forAll(eFaces, edgeI)
{
const labelList& myFaceNbs = eFaces[edgeI];
if (myFaceNbs.size() > 2)
{
// Get point on edge and normalized direction of edge (= e2 base
// of our coordinate system)
const edge& e = edgeLst[edgeI];
const point& edgePt = locPointLst[e.start()];
vector e2 = e.vec(locPointLst);
e2 /= mag(e2) + VSMALL;
// Get opposite vertex for 0th face
const Face& f = locFaceLst[myFaceNbs[0]];
label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0);
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
// Get vector normal both to e2 and to edge from opposite vertex
// to edge (will be x-axis of our coordinate system)
vector e0 = e2 ^ (locPointLst[vertI] - edgePt);
e0 /= mag(e0) + VSMALL;
// Get y-axis of coordinate system
vector e1 = e2 ^ e0;
SortableList<scalar> faceAngles(myFaceNbs.size());
// e0 is reference so angle is 0
faceAngles[0] = 0;
for (label nbI = 1; nbI < myFaceNbs.size(); nbI++)
{
// Get opposite vertex
const Face& f = locFaceLst[myFaceNbs[nbI]];
label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0);
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
vector vec = e2 ^ (locPointLst[vertI] - edgePt);
vec /= mag(vec) + VSMALL;
faceAngles[nbI] = pseudoAngle
(
e0,
e1,
vec
);
}
faceAngles.sort();
sortedEdgeFaces[edgeI] = IndirectList<label>
(
myFaceNbs,
faceAngles.indices()
);
}
else
{
// No need to sort. Just copy.
sortedEdgeFaces[edgeI] = myFaceNbs;
}
}
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
calcEdgeOwner() const
{
if (edgeOwnerPtr_)
{
FatalErrorIn
(
"PrimitivePatchExtra<Face, FaceList, PointField>::"
"calcEdgeOwner()"
)
<< "edgeOwnerPtr_ already set"
<< abort(FatalError);
}
// create the owner list
edgeOwnerPtr_ = new labelList(this->nEdges());
labelList& edgeOwner = *edgeOwnerPtr_;
const edgeList& edgeLst = this->edges();
const labelListList& eFaces = this->edgeFaces();
const List<Face>& locFaceLst = this->localFaces();
forAll(edgeLst, edgeI)
{
const edge& e = edgeLst[edgeI];
const labelList& neighbouringFaces = eFaces[edgeI];
if (neighbouringFaces.size() == 1)
{
edgeOwner[edgeI] = neighbouringFaces[0];
}
else
{
// Find the first face whose vertices are aligned with the edge.
// with multiply connected edges, this is the best we can do
edgeOwner[edgeI] = -1;
forAll(neighbouringFaces, i)
{
const Face& f = locFaceLst[neighbouringFaces[i]];
if (f.edgeDirection(e) > 0)
{
edgeOwner[edgeI] = neighbouringFaces[i];
break;
}
}
if (edgeOwner[edgeI] == -1)
{
FatalErrorIn
(
"PrimitivePatchExtra<Face, FaceList, PointField>::"
"calcEdgeOwner()"
)
<< "Edge " << edgeI << " vertices:" << e
<< " is used by faces " << neighbouringFaces
<< " vertices:"
<< IndirectList<Face>(locFaceLst, neighbouringFaces)()
<< " none of which use the edge vertices in the same order"
<< nl << "I give up" << abort(FatalError);
}
}
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -1,239 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "PrimitivePatchExtra.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Check/fix edges with more than two faces
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
checkEdges
(
const bool verbose
) const
{
const labelListList& eFaces = this->edgeFaces();
const edgeList& edgeLst = this->edges();
forAll(eFaces, edgeI)
{
const labelList& myFaces = eFaces[edgeI];
// boundary edges have one face
// interior edges have two faces
if (myFaces.empty())
{
FatalErrorIn
(
"PrimitivePatchExtra::checkEdges(bool verbose)"
)
<< "Edge " << edgeI << " with vertices " << edgeLst[edgeI]
<< " has no edgeFaces"
<< exit(FatalError);
}
else if (myFaces.size() > 2)
{
WarningIn
(
"PrimitivePatchExtra::checkEdges(bool verbose)"
)
<< "Edge " << edgeI << " with vertices " << edgeLst[edgeI]
<< " has more than 2 faces connected to it : " << myFaces
<< endl;
}
}
}
// Check normals and orientation
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::boolList
Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
checkOrientation
(
const bool verbose
) const
{
const FaceList<Face>& faceLst = *this;
const edgeList& edgeLst = this->edges();
const labelListList& faceEs = this->faceEdges();
const label numEdges = this->nEdges();
const Field<PointType>& pointLst = this->points();
const vectorField& normLst = this->faceNormals();
if (ParentType::debug)
{
Info<<"checkOrientation:::checkOrientation(bool)" << endl;
}
// Check edge normals, face normals, point normals.
forAll(faceEs, faceI)
{
const labelList& edgeLabels = faceEs[faceI];
if (edgeLabels.size() < 3)
{
FatalErrorIn
(
"PrimitivePatchExtra::checkOrientation(bool)"
)
<< "face " << faceLst[faceI]
<< " has fewer than 3 edges. Edges:" << edgeLabels
<< exit(FatalError);
}
bool valid = true;
forAll(edgeLabels, i)
{
if (edgeLabels[i] < 0 || edgeLabels[i] >= numEdges)
{
WarningIn
(
"PrimitivePatchExtra::checkOrientation(bool)"
)
<< "edge number " << edgeLabels[i] << " on face " << faceI
<< " out-of-range\n"
<< "This usually means the input surface has "
<< "edges with more than 2 faces connected.\n"
<< endl;
valid = false;
}
}
if (!valid)
{
continue;
}
//
//- Compute normal from 3 points, use the first as the origin
// minor warpage should not be a problem
const Face& f = faceLst[faceI];
const point p0(pointLst[f[0]]);
const point p1(pointLst[f[1]]);
const point p2(pointLst[f[f.size()-1]]);
const vector pointNormal((p1 - p0) ^ (p2 - p0));
if ((pointNormal & normLst[faceI]) < 0)
{
FatalErrorIn
(
"PrimitivePatchExtra::checkOrientation(bool)"
)
<< "Normal calculated from points inconsistent with faceNormal"
<< nl
<< "face: " << f << nl
<< "points: " << p0 << ' ' << p1 << ' ' << p2 << nl
<< "pointNormal:" << pointNormal << nl
<< "faceNormal:" << normLst[faceI]
<< exit(FatalError);
}
}
const labelListList& eFaces = this->edgeFaces();
const pointField& locPointsLst = this->localPoints();
// Storage for holding status of edge.
// True if normal flips across this edge
boolList borderEdge(numEdges, false);
forAll(edgeLst, edgeI)
{
const edge& e = edgeLst[edgeI];
const labelList& neighbouringFaces = eFaces[edgeI];
if (neighbouringFaces.size() == 2)
{
// we use localFaces() since edges() are LOCAL
// these are both already available
const Face& faceA = this->localFaces()[neighbouringFaces[0]];
const Face& faceB = this->localFaces()[neighbouringFaces[1]];
// If the faces are correctly oriented, the edges must go in
// different directions on connected faces.
if (faceA.edgeDirection(e) == faceB.edgeDirection(e))
{
borderEdge[edgeI] = true;
if (verbose)
{
WarningIn
(
"PrimitivePatchExtra::checkOrientation(bool)"
)
<< "face orientation incorrect." << nl
<< "localEdge[" << edgeI << "] " << e
<< " between faces:" << nl
<< " face[" << neighbouringFaces[0] << "] "
<< faceLst[neighbouringFaces[0]]
<< " localFace: " << faceA
<< nl
<< " face[" << neighbouringFaces[1] << "] "
<< faceLst[neighbouringFaces[1]]
<< " localFace: " << faceB
<< endl;
}
}
}
else if (neighbouringFaces.size() != 1)
{
if (verbose)
{
WarningIn
(
"PrimitivePatchExtra::checkOrientation(bool)"
)
<< "Wrong number of edge neighbours." << nl
<< "edge[" << edgeI << "] " << e
<< " with points:" << locPointsLst[e.start()]
<< ' ' << locPointsLst[e.end()]
<< " has neighbouringFaces:" << neighbouringFaces << endl;
}
borderEdge[edgeI] = true;
}
}
return borderEdge;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -40,7 +40,7 @@ Description
namespace Foam namespace Foam
{ {
typedef PackedList<1> PackedBoolList; typedef PackedList<> PackedBoolList;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,6 +26,7 @@ License
#include "fileName.H" #include "fileName.H"
#include "wordList.H" #include "wordList.H"
#include "DynamicList.H"
#include "debug.H" #include "debug.H"
#include "OSspecific.H" #include "OSspecific.H"
@ -48,6 +49,30 @@ Foam::fileName::fileName(const wordList& lst)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName::Type Foam::fileName::type() const
{
return ::Foam::type(*this);
}
bool Foam::fileName::exists() const
{
return ::Foam::exists(*this);
}
bool Foam::fileName::isDir() const
{
return ::Foam::dir(*this);
}
bool Foam::fileName::isFile() const
{
return ::Foam::file(*this);
}
// Return file name (part beyond last /) // Return file name (part beyond last /)
// //
// behaviour compared to /usr/bin/basename: // behaviour compared to /usr/bin/basename:
@ -93,13 +118,13 @@ Foam::fileName Foam::fileName::path() const
{ {
return "."; return ".";
} }
else if (i == 0) else if (i)
{ {
return "/"; return substr(0, i);
} }
else else
{ {
return substr(0, i); return "/";
} }
} }
@ -145,28 +170,22 @@ Foam::word Foam::fileName::ext() const
// ----- ------ // ----- ------
// "foo" 1("foo") // "foo" 1("foo")
// "/foo" 1("foo") // "/foo" 1("foo")
// "foo/bar" 2("foo", "foo") // "foo/bar" 2("foo", "bar")
// "/foo/bar" 2("foo", "foo") // "/foo/bar" 2("foo", "bar")
// "/foo/bar/" 2("foo", "bar") // "/foo/bar/" 2("foo", "bar")
// //
Foam::wordList Foam::fileName::components(const char delimiter) const Foam::wordList Foam::fileName::components(const char delimiter) const
{ {
wordList wrdList(20); DynamicList<word> wrdList(20);
size_type start=0, end=0; size_type start=0, end=0;
label nWords=0;
while ((end = find(delimiter, start)) != npos) while ((end = find(delimiter, start)) != npos)
{ {
// avoid empty element (caused by doubled slashes) // avoid empty element (caused by doubled slashes)
if (start < end) if (start < end)
{ {
wrdList[nWords++] = substr(start, end-start); wrdList.append(substr(start, end-start));
if (nWords == wrdList.size())
{
wrdList.setSize(2*wrdList.size());
}
} }
start = end + 1; start = end + 1;
} }
@ -174,12 +193,11 @@ Foam::wordList Foam::fileName::components(const char delimiter) const
// avoid empty trailing element // avoid empty trailing element
if (start < size()) if (start < size())
{ {
wrdList[nWords++] = substr(start, npos); wrdList.append(substr(start, npos));
} }
wrdList.setSize(nWords); // transfer to wordList
return wordList(wrdList.xfer());
return wrdList;
} }
@ -194,11 +212,93 @@ Foam::word Foam::fileName::component
} }
Foam::fileName::Type Foam::fileName::type() const
// Return components following the IOobject requirements
//
// behaviour
// input IOobject(instance, local, name)
// ----- ------
// "foo" ("", "", "foo")
// "foo/bar" ("foo", "", "bar")
// "/XXX" ERROR - no absolute path
// "foo/bar/" ERROR - no name
// "foo/xxx/bar" ("foo", "xxx", "bar")
// "foo/xxx/yyy/bar" ("foo", "xxx/yyy", "bar")
bool Foam::fileName::IOobjectComponents
(
fileName& instance,
fileName& local,
word& name
)
const
{ {
return ::Foam::type(*this); instance.clear();
local.clear();
name.clear();
// called with directory
if (::Foam::dir(*this))
{
std::cerr
<< "fileName::IOobjectComponents() called with directory: "
<< this->c_str() << std::endl;
std::abort();
return false;
} }
size_type first = find('/');
if (first == 0)
{
// called with absolute path
std::cerr
<< "fileName::IOobjectComponents() called with absolute path: "
<< this->c_str() << std::endl;
std::abort();
return false;
}
if (first == npos)
{
// no '/' found - no instance or local
// check afterwards
name.string::operator=(*this);
}
else
{
instance = substr(0, first);
size_type last = rfind('/');
if (last > first)
{
// with local
local = substr(first+1, last-first-1);
}
// check afterwards
name.string::operator=(substr(last+1));
}
// check for valid (and stripped) name, regardless of the debug level
if (name.empty() || string::stripInvalid<word>(name))
{
std::cerr
<< "fileName::IOobjectComponents() has invalid word for name: "
<< name.c_str() << "\nwhile processing "
<< this->c_str() << std::endl;
std::abort();
return false;
}
return true;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //

View File

@ -129,6 +129,20 @@ public:
inline static bool valid(char); inline static bool valid(char);
// Interogation
//- Return the file type: FILE, DIRECTORY or UNDEFINED
Type type() const;
//- Does it exist (as FILE or DIRECTORY) in the file system?
bool exists() const;
//- Does it exist as DIRECTORY in the file system?
bool isDir() const;
//- Does it exist as FILE in the file system?
bool isFile() const;
// Decomposition // Decomposition
//- Return file name (part beyond last /) //- Return file name (part beyond last /)
@ -146,14 +160,16 @@ public:
//- Return path components as wordList //- Return path components as wordList
wordList components(const char delimiter='/') const; wordList components(const char delimiter='/') const;
//- Return a component of the path //- Return a single component of the path
word component(const size_type, const char delimiter='/') const; word component(const size_type, const char delimiter='/') const;
//- Return path as instance, local, name components for IOobject
// Interogation bool IOobjectComponents
(
//- Return file type fileName& instance,
Type type() const; fileName& local,
word& name
) const;
// Member operators // Member operators

View File

@ -206,7 +206,8 @@ void Foam::isoSurface::calcCutTypes
if (debug) if (debug)
{ {
Pout<< "isoSurface : detected " << nCutCells_ Pout<< "isoSurface : detected " << nCutCells_
<< " candidate cut cells." << endl; << " candidate cut cells (out of " << mesh_.nCells()
<< ")." << endl;
} }
} }
@ -814,65 +815,53 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints
tris.transfer(dynTris); tris.transfer(dynTris);
} }
// Use face centres to determine 'flat hole' situation (see RMT paper).
// Two unconnected triangles get connected because (some of) the edges
// separating them get collapsed. Below only checks for duplicate triangles,
// not non-manifold edge connectivity.
if (checkDuplicates)
{
if (debug) if (debug)
{ {
Pout<< "isoSurface : merged from " << nTris Pout<< "isoSurface : merged from " << nTris
<< " down to " << tris.size() << " triangles." << endl; << " down to " << tris.size() << " triangles." << endl;
} }
pointField centres(tris.size());
forAll(tris, triI)
{
centres[triI] = tris[triI].centre(newPoints);
}
pointField mergedCentres;
labelList oldToMerged;
bool hasMerged = mergePoints
(
centres,
mergeDistance_,
false,
oldToMerged,
mergedCentres
);
if (debug) // Determine 'flat hole' situation (see RMT paper).
// Two unconnected triangles get connected because (some of) the edges
// separating them get collapsed. Below only checks for duplicate triangles,
// not non-manifold edge connectivity.
if (checkDuplicates)
{ {
Pout<< "isoSurface : detected " labelListList pointFaces;
<< centres.size()-mergedCentres.size() invertManyToMany(newPoints.size(), tris, pointFaces);
<< " duplicate triangles." << endl;
}
if (hasMerged)
{
// Filter out duplicates. // Filter out duplicates.
label newTriI = 0;
DynamicList<label> newToOldTri(tris.size()); DynamicList<label> newToOldTri(tris.size());
labelList newToMaster(mergedCentres.size(), -1);
forAll(tris, triI) forAll(tris, triI)
{ {
label mergedI = oldToMerged[triI]; const labelledTri& tri = tris[triI];
if (newToMaster[mergedI] == -1) const labelList& pFaces = pointFaces[tri[0]];
// Find the minimum of any duplicates
label dupTriI = -1;
forAll(pFaces, i)
{ {
newToMaster[mergedI] = triI; if (pFaces[i] < triI && tris[pFaces[i]] == tri)
newToOldTri.append(triMap[triI]); {
tris[newTriI++] = tris[triI]; dupTriI = pFaces[i];
}
}
if (dupTriI == -1)
{
// There is no lower triangle
label newTriI = newToOldTri.size();
newToOldTri.append(triI);
tris[newTriI] = tris[triI];
} }
} }
triMap.transfer(newToOldTri); triMap.transfer(newToOldTri);
tris.setSize(newTriI); tris.setSize(triMap.size());
}
} }
return triSurface(tris, geometricSurfacePatchList(0), newPoints, true); return triSurface(tris, geometricSurfacePatchList(0), newPoints, true);
@ -986,7 +975,7 @@ void Foam::isoSurface::calcAddressing
{ {
Pout<< "isoSurface : detected " Pout<< "isoSurface : detected "
<< mergedCentres.size() << mergedCentres.size()
<< " edges on " << surf.size() << " triangles." << endl; << " geometric edges on " << surf.size() << " triangles." << endl;
} }
if (!hasMerged) if (!hasMerged)
@ -1013,6 +1002,10 @@ void Foam::isoSurface::calcAddressing
edgeFace1 = -1; edgeFace1 = -1;
edgeFacesRest.clear(); edgeFacesRest.clear();
// Overflow edge faces for geometric shared edges that turned
// out to be different anyway.
EdgeMap<labelList> extraEdgeFaces(mergedCentres.size()/100);
forAll(oldToMerged, oldEdgeI) forAll(oldToMerged, oldEdgeI)
{ {
label triI = oldEdgeI / 3; label triI = oldEdgeI / 3;
@ -1020,8 +1013,48 @@ void Foam::isoSurface::calcAddressing
if (edgeFace0[edgeI] == -1) if (edgeFace0[edgeI] == -1)
{ {
// First triangle for edge
edgeFace0[edgeI] = triI; edgeFace0[edgeI] = triI;
} }
else
{
//- Check that the two triangles actually topologically
// share an edge
const labelledTri& prevTri = surf[edgeFace0[edgeI]];
const labelledTri& tri = surf[triI];
label fp = oldEdgeI % 3;
edge e(tri[fp], tri[tri.fcIndex(fp)]);
label prevTriIndex = -1;
forAll(prevTri, i)
{
if (edge(prevTri[i], prevTri[prevTri.fcIndex(i)]) == e)
{
prevTriIndex = i;
break;
}
}
if (prevTriIndex == -1)
{
// Different edge. Store for later.
EdgeMap<labelList>::iterator iter = extraEdgeFaces.find(e);
if (iter != extraEdgeFaces.end())
{
labelList& eFaces = iter();
label sz = eFaces.size();
eFaces.setSize(sz+1);
eFaces[sz] = triI;
}
else
{
extraEdgeFaces.insert(e, labelList(1, triI));
}
}
else if (edgeFace1[edgeI] == -1) else if (edgeFace1[edgeI] == -1)
{ {
edgeFace1[edgeI] = triI; edgeFace1[edgeI] = triI;
@ -1029,9 +1062,10 @@ void Foam::isoSurface::calcAddressing
else else
{ {
//WarningIn("orientSurface(triSurface&)") //WarningIn("orientSurface(triSurface&)")
// << "Edge " << edgeI << " with centre " << mergedCentres[edgeI] // << "Edge " << edgeI << " with centre "
// << " used by more than two triangles: " << edgeFace0[edgeI] // << mergedCentres[edgeI]
// << ", " // << " used by more than two triangles: "
// << edgeFace0[edgeI] << ", "
// << edgeFace1[edgeI] << " and " << triI << endl; // << edgeFace1[edgeI] << " and " << triI << endl;
Map<labelList>::iterator iter = edgeFacesRest.find(edgeI); Map<labelList>::iterator iter = edgeFacesRest.find(edgeI);
@ -1050,6 +1084,59 @@ void Foam::isoSurface::calcAddressing
} }
} }
// Add extraEdgeFaces
edgeI = edgeFace0.size();
edgeFace0.setSize(edgeI + extraEdgeFaces.size());
edgeFace1.setSize(edgeI + extraEdgeFaces.size(), -1);
forAllConstIter(EdgeMap<labelList>, extraEdgeFaces, iter)
{
const labelList& eFaces = iter();
// The current edge will become edgeI. Replace all occurrences in
// faceEdges
forAll(eFaces, i)
{
label triI = eFaces[i];
const labelledTri& tri = surf[triI];
FixedList<label, 3>& fEdges = faceEdges[triI];
forAll(tri, fp)
{
edge e(tri[fp], tri[tri.fcIndex(fp)]);
if (e == iter.key())
{
fEdges[fp] = edgeI;
break;
}
}
}
// Add face to edgeFaces
edgeFace0[edgeI] = eFaces[0];
if (eFaces.size() >= 2)
{
edgeFace1[edgeI] = eFaces[1];
if (eFaces.size() > 2)
{
edgeFacesRest.insert
(
edgeI,
SubList<label>(eFaces, eFaces.size()-2, 2)
);
}
}
edgeI++;
}
}
void Foam::isoSurface::walkOrientation void Foam::isoSurface::walkOrientation
( (
@ -1097,6 +1184,24 @@ void Foam::isoSurface::walkOrientation
// nbr points // nbr points
label nbrFp = findIndex(nbrTri, p0); label nbrFp = findIndex(nbrTri, p0);
if (nbrFp == -1)
{
FatalErrorIn("isoSurface::walkOrientation(..)")
<< "triI:" << triI
<< " tri:" << tri
<< " p0:" << p0
<< " p1:" << p1
<< " fEdges:" << fEdges
<< " edgeI:" << edgeI
<< " edgeFace0:" << edgeFace0[edgeI]
<< " edgeFace1:" << edgeFace1[edgeI]
<< " nbrI:" << nbrI
<< " nbrTri:" << nbrTri
<< abort(FatalError);
}
label nbrP1 = nbrTri[nbrTri.rcIndex(nbrFp)]; label nbrP1 = nbrTri[nbrTri.rcIndex(nbrFp)];
bool sameOrientation = (p1 == nbrP1); bool sameOrientation = (p1 == nbrP1);
@ -1352,8 +1457,17 @@ Foam::isoSurface::isoSurface
iso_(iso), iso_(iso),
mergeDistance_(mergeTol*mesh_.bounds().mag()) mergeDistance_(mergeTol*mesh_.bounds().mag())
{ {
if (debug)
{
Pout<< "isoSurface :" << nl
<< " isoField : " << cVals.name() << nl
<< " isoValue : " << iso << nl
<< " regularise : " << regularise << nl
<< " mergeTol : " << mergeTol << nl
<< endl;
}
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
const labelList& own = mesh_.faceOwner();
// Check // Check
forAll(patches, patchI) forAll(patches, patchI)
@ -1442,24 +1556,6 @@ Foam::isoSurface::isoSurface
snappedCc = -1; snappedCc = -1;
} }
// Determine neighbouring snap status
labelList neiSnappedCc(mesh_.nFaces()-mesh_.nInternalFaces(), -1);
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
if (pp.coupled())
{
label faceI = pp.start();
forAll(pp, i)
{
neiSnappedCc[faceI-mesh_.nInternalFaces()] =
snappedCc[own[faceI]];
faceI++;
}
}
}
syncTools::swapBoundaryFaceList(mesh_, neiSnappedCc, false);
if (debug) if (debug)

View File

@ -299,7 +299,16 @@ void Foam::isoSurface::generateTriPoints
) )
{ {
FatalErrorIn("isoSurface::generateTriPoints(..)") FatalErrorIn("isoSurface::generateTriPoints(..)")
<< "Incorrect size." << abort(FatalError); << "Incorrect size." << endl
<< "mesh: nCells:" << mesh_.nCells()
<< " points:" << mesh_.nPoints() << endl
<< "cVals:" << cVals.size() << endl
<< "cCoords:" << cCoords.size() << endl
<< "snappedCc:" << snappedCc.size() << endl
<< "pVals:" << pVals.size() << endl
<< "pCoords:" << pCoords.size() << endl
<< "snappedPoint:" << snappedPoint.size() << endl
<< abort(FatalError);
} }
// Determine neighbouring snap status // Determine neighbouring snap status

View File

@ -29,7 +29,6 @@ License
#include "volFields.H" #include "volFields.H"
#include "volPointInterpolation.H" #include "volPointInterpolation.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -45,8 +44,6 @@ void Foam::sampledIsoSurface::getIsoFields() const
{ {
const fvMesh& fvm = static_cast<const fvMesh&>(mesh()); const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
word pointFldName = "volPointInterpolate(" + isoField_ + ')';
// Get volField // Get volField
// ~~~~~~~~~~~~ // ~~~~~~~~~~~~
@ -54,7 +51,7 @@ void Foam::sampledIsoSurface::getIsoFields() const
{ {
if (debug) if (debug)
{ {
Info<< "sampledIsoSurface::getIsoField() : lookup " Info<< "sampledIsoSurface::getIsoField() : lookup volField "
<< isoField_ << endl; << isoField_ << endl;
} }
storedVolFieldPtr_.clear(); storedVolFieldPtr_.clear();
@ -79,7 +76,7 @@ void Foam::sampledIsoSurface::getIsoFields() const
{ {
if (debug) if (debug)
{ {
Info<< "sampledIsoSurface::getIsoField() : reading " Info<< "sampledIsoSurface::getIsoField() : reading volField "
<< isoField_ << " from time " << fvm.time().timeName() << isoField_ << " from time " << fvm.time().timeName()
<< endl; << endl;
} }
@ -101,20 +98,6 @@ void Foam::sampledIsoSurface::getIsoFields() const
) )
); );
volFieldPtr_ = storedVolFieldPtr_.operator->(); volFieldPtr_ = storedVolFieldPtr_.operator->();
// Interpolate to get pointField
if (debug)
{
Info<< "sampledIsoSurface::getIsoField() : interpolating "
<< pointFldName << endl;
}
storedPointFieldPtr_.reset
(
volPointInterpolation::New(fvm).interpolate(*volFieldPtr_).ptr()
);
pointFieldPtr_ = storedPointFieldPtr_.operator->();
} }
} }
@ -123,11 +106,15 @@ void Foam::sampledIsoSurface::getIsoFields() const
// Get pointField // Get pointField
// ~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~
if (!subMeshPtr_.valid())
{
word pointFldName = "volPointInterpolate(" + isoField_ + ')';
if (fvm.foundObject<pointScalarField>(pointFldName)) if (fvm.foundObject<pointScalarField>(pointFldName))
{ {
if (debug) if (debug)
{ {
Info<< "sampledIsoSurface::getIsoField() : lookup " Info<< "sampledIsoSurface::getIsoField() : lookup pointField "
<< pointFldName << endl; << pointFldName << endl;
} }
pointFieldPtr_ = &fvm.lookupObject<pointScalarField>(pointFldName); pointFieldPtr_ = &fvm.lookupObject<pointScalarField>(pointFldName);
@ -138,9 +125,9 @@ void Foam::sampledIsoSurface::getIsoFields() const
if (debug) if (debug)
{ {
Info<< "sampledIsoSurface::getIsoField() : checking interpolate " Info<< "sampledIsoSurface::getIsoField() : checking pointField "
<< isoField_ << " for same time " << fvm.time().timeName() << pointFldName << " for same time "
<< endl; << fvm.time().timeName() << endl;
} }
if if
@ -151,14 +138,17 @@ void Foam::sampledIsoSurface::getIsoFields() const
{ {
if (debug) if (debug)
{ {
Info<< "sampledIsoSurface::getIsoField() : interpolating " Info<< "sampledIsoSurface::getIsoField() :"
<< pointFldName << endl; << " interpolating volField " << volFieldPtr_->name()
<< " to get pointField " << pointFldName << endl;
} }
storedPointFieldPtr_.reset storedPointFieldPtr_.reset
( (
volPointInterpolation::New(fvm).interpolate(*volFieldPtr_).ptr() volPointInterpolation::New(fvm)
.interpolate(*volFieldPtr_).ptr()
); );
storedPointFieldPtr_->checkOut();
pointFieldPtr_ = storedPointFieldPtr_.operator->(); pointFieldPtr_ = storedPointFieldPtr_.operator->();
} }
} }
@ -174,6 +164,147 @@ void Foam::sampledIsoSurface::getIsoFields() const
<< " max:" << gMax(pointFieldPtr_->internalField()) << endl; << " max:" << gMax(pointFieldPtr_->internalField()) << endl;
} }
} }
else
{
// Get subMesh variants
const fvMesh& subFvm = subMeshPtr_().subMesh();
// Either lookup on the submesh or subset the whole-mesh volField
if (subFvm.foundObject<volScalarField>(isoField_))
{
if (debug)
{
Info<< "sampledIsoSurface::getIsoField() :"
<< " submesh lookup volField "
<< isoField_ << endl;
}
storedVolSubFieldPtr_.clear();
volSubFieldPtr_ = &subFvm.lookupObject<volScalarField>(isoField_);
}
else
{
if (debug)
{
Info<< "sampledIsoSurface::getIsoField() : subsetting volField "
<< isoField_ << endl;
}
storedVolSubFieldPtr_.reset
(
subMeshPtr_().interpolate
(
*volFieldPtr_
).ptr()
);
storedVolSubFieldPtr_->checkOut();
volSubFieldPtr_ = storedVolSubFieldPtr_.operator->();
}
// Pointfield on submesh
word pointFldName =
"volPointInterpolate("
+ volSubFieldPtr_->name()
+ ')';
if (subFvm.foundObject<pointScalarField>(pointFldName))
{
if (debug)
{
Info<< "sampledIsoSurface::getIsoField() :"
<< " submesh lookup pointField " << pointFldName << endl;
}
storedPointSubFieldPtr_.clear();
pointSubFieldPtr_ = &subFvm.lookupObject<pointScalarField>
(
pointFldName
);
}
else
{
if (debug)
{
Info<< "sampledIsoSurface::getIsoField() :"
<< " interpolating submesh volField "
<< volSubFieldPtr_->name()
<< " to get submesh pointField " << pointFldName << endl;
}
storedPointSubFieldPtr_.reset
(
volPointInterpolation::New
(
subFvm
).interpolate(*volSubFieldPtr_).ptr()
);
storedPointSubFieldPtr_->checkOut();
pointSubFieldPtr_ = storedPointSubFieldPtr_.operator->();
}
if (debug)
{
Info<< "sampledIsoSurface::getIsoField() : volSubField "
<< volSubFieldPtr_->name()
<< " min:" << min(*volSubFieldPtr_).value()
<< " max:" << max(*volSubFieldPtr_).value() << endl;
Info<< "sampledIsoSurface::getIsoField() : pointSubField "
<< pointSubFieldPtr_->name()
<< " min:" << gMin(pointSubFieldPtr_->internalField())
<< " max:" << gMax(pointSubFieldPtr_->internalField()) << endl;
}
}
}
Foam::tmp<Foam::volScalarField> Foam::sampledIsoSurface::average
(
const fvMesh& mesh,
const pointScalarField& pfld
) const
{
tmp<volScalarField> tcellAvg
(
new volScalarField
(
IOobject
(
"cellAvg",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh,
dimensionedScalar("zero", dimless, scalar(0.0))
)
);
volScalarField& cellAvg = tcellAvg();
labelField nPointCells(mesh.nCells(), 0);
{
for (label pointI = 0; pointI < mesh.nPoints(); pointI++)
{
const labelList& pCells = mesh.pointCells(pointI);
forAll(pCells, i)
{
label cellI = pCells[i];
cellAvg[cellI] += pfld[pointI];
nPointCells[cellI]++;
}
}
}
forAll(cellAvg, cellI)
{
cellAvg[cellI] /= nPointCells[cellI];
}
// Give value to calculatedFvPatchFields
cellAvg.correctBoundaryConditions();
return tcellAvg;
}
bool Foam::sampledIsoSurface::updateGeometry() const bool Foam::sampledIsoSurface::updateGeometry() const
@ -186,6 +317,33 @@ bool Foam::sampledIsoSurface::updateGeometry() const
return false; return false;
} }
// Get any subMesh
if (zoneID_.index() != -1 && !subMeshPtr_.valid())
{
const polyBoundaryMesh& patches = mesh().boundaryMesh();
// Patch to put exposed internal faces into
label exposedPatchI = patches.findPatchID(exposedPatchName_);
if (debug)
{
Info<< "Allocating subset of size "
<< mesh().cellZones()[zoneID_.index()].size()
<< " with exposed faces into patch "
<< patches[exposedPatchI].name() << endl;
}
subMeshPtr_.reset
(
new fvMeshSubset(static_cast<const fvMesh&>(mesh()))
);
subMeshPtr_().setLargeCellSubset
(
labelHashSet(mesh().cellZones()[zoneID_.index()]),
exposedPatchI
);
}
prevTimeIndex_ = fvm.time().timeIndex(); prevTimeIndex_ = fvm.time().timeIndex();
getIsoFields(); getIsoFields();
@ -196,57 +354,53 @@ bool Foam::sampledIsoSurface::updateGeometry() const
if (average_) if (average_)
{ {
//- From point field and interpolated cell. if (subMeshPtr_.valid())
volScalarField cellAvg
(
IOobject
(
"cellAvg",
fvm.time().timeName(),
fvm.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
fvm,
dimensionedScalar("zero", dimless, scalar(0.0))
);
labelField nPointCells(fvm.nCells(), 0);
{ {
for (label pointI = 0; pointI < fvm.nPoints(); pointI++)
{
const labelList& pCells = fvm.pointCells(pointI);
forAll(pCells, i)
{
label cellI = pCells[i];
cellAvg[cellI] += (*pointFieldPtr_)[pointI];
nPointCells[cellI]++;
}
}
}
forAll(cellAvg, cellI)
{
cellAvg[cellI] /= nPointCells[cellI];
}
// Give value to calculatedFvPatchFields
cellAvg.correctBoundaryConditions();
surfPtr_.reset surfPtr_.reset
( (
new isoSurface new isoSurface
( (
cellAvg, average(subMeshPtr_().subMesh(), *pointSubFieldPtr_),
*pointFieldPtr_, *pointSubFieldPtr_,
isoVal_, isoVal_,
regularise_ regularise_,
mergeTol_
)
);
}
else
{
surfPtr_.reset
(
new isoSurface
(
average(fvm, *pointFieldPtr_),
*pointFieldPtr_,
isoVal_,
regularise_,
mergeTol_
)
);
}
}
else
{
if (subMeshPtr_.valid())
{
surfPtr_.reset
(
new isoSurface
(
*volSubFieldPtr_,
*pointSubFieldPtr_,
isoVal_,
regularise_,
mergeTol_
) )
); );
} }
else else
{ {
//- Direct from cell field and point field.
surfPtr_.reset surfPtr_.reset
( (
new isoSurface new isoSurface
@ -254,10 +408,12 @@ bool Foam::sampledIsoSurface::updateGeometry() const
*volFieldPtr_, *volFieldPtr_,
*pointFieldPtr_, *pointFieldPtr_,
isoVal_, isoVal_,
regularise_ regularise_,
mergeTol_
) )
); );
} }
}
if (debug) if (debug)
@ -267,8 +423,13 @@ bool Foam::sampledIsoSurface::updateGeometry() const
<< " regularise : " << regularise_ << nl << " regularise : " << regularise_ << nl
<< " average : " << average_ << nl << " average : " << average_ << nl
<< " isoField : " << isoField_ << nl << " isoField : " << isoField_ << nl
<< " isoValue : " << isoVal_ << nl << " isoValue : " << isoVal_ << nl;
<< " points : " << points().size() << nl if (subMeshPtr_.valid())
{
Pout<< " zone size : " << subMeshPtr_().subMesh().nCells()
<< nl;
}
Pout<< " points : " << points().size() << nl
<< " tris : " << surface().size() << nl << " tris : " << surface().size() << nl
<< " cut cells : " << surface().meshCells().size() << " cut cells : " << surface().meshCells().size()
<< endl; << endl;
@ -290,9 +451,11 @@ Foam::sampledIsoSurface::sampledIsoSurface
sampledSurface(name, mesh, dict), sampledSurface(name, mesh, dict),
isoField_(dict.lookup("isoField")), isoField_(dict.lookup("isoField")),
isoVal_(readScalar(dict.lookup("isoValue"))), isoVal_(readScalar(dict.lookup("isoValue"))),
mergeTol_(dict.lookupOrDefault("mergeTol", 1E-6)),
regularise_(dict.lookupOrDefault("regularise", true)), regularise_(dict.lookupOrDefault("regularise", true)),
average_(dict.lookupOrDefault("average", false)), average_(dict.lookupOrDefault("average", false)),
zoneName_(word::null), zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()),
exposedPatchName_(word::null),
surfPtr_(NULL), surfPtr_(NULL),
facesPtr_(NULL), facesPtr_(NULL),
prevTimeIndex_(-1), prevTimeIndex_(-1),
@ -311,16 +474,29 @@ Foam::sampledIsoSurface::sampledIsoSurface
<< " span across cells." << exit(FatalError); << " span across cells." << exit(FatalError);
} }
// dict.readIfPresent("zone", zoneName_); if (zoneID_.index() != -1)
// {
// if (debug && zoneName_.size()) dict.lookup("exposedPatchName") >> exposedPatchName_;
// {
// if (mesh.cellZones().findZoneID(zoneName_) < 0) if (mesh.boundaryMesh().findPatchID(exposedPatchName_) == -1)
// { {
// Info<< "cellZone \"" << zoneName_ FatalErrorIn
// << "\" not found - using entire mesh" << endl; (
// } "sampledIsoSurface::sampledIsoSurface"
// } "(const word&, const polyMesh&, const dictionary&)"
) << "Cannot find patch " << exposedPatchName_
<< " in which to put exposed faces." << endl
<< "Valid patches are " << mesh.boundaryMesh().names()
<< exit(FatalError);
}
if (debug && zoneID_.index() != -1)
{
Info<< "Restricting to cellZone " << zoneID_.name()
<< " with exposed internal faces into patch "
<< exposedPatchName_ << endl;
}
}
} }
@ -344,6 +520,7 @@ bool Foam::sampledIsoSurface::expire()
{ {
surfPtr_.clear(); surfPtr_.clear();
facesPtr_.clear(); facesPtr_.clear();
subMeshPtr_.clear();
// already marked as expired // already marked as expired
if (prevTimeIndex_ == -1) if (prevTimeIndex_ == -1)

View File

@ -38,8 +38,10 @@ SourceFiles
#ifndef sampledIsoSurface_H #ifndef sampledIsoSurface_H
#define sampledIsoSurface_H #define sampledIsoSurface_H
#include "sampledSurface.H"
#include "isoSurface.H" #include "isoSurface.H"
#include "sampledSurface.H"
#include "ZoneIDs.H"
#include "fvMeshSubset.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -62,14 +64,20 @@ class sampledIsoSurface
//- iso value //- iso value
const scalar isoVal_; const scalar isoVal_;
//- Merge tolerance
const scalar mergeTol_;
//- Whether to coarse //- Whether to coarse
const Switch regularise_; const Switch regularise_;
//- Whether to recalculate cell values as average of point values //- Whether to recalculate cell values as average of point values
const Switch average_; const Switch average_;
//- zone name (if restricted to zones) //- zone name/index (if restricted to zones)
word zoneName_; mutable cellZoneID zoneID_;
//- for zones: patch to put exposed faces into
mutable word exposedPatchName_;
mutable autoPtr<isoSurface> surfPtr_; mutable autoPtr<isoSurface> surfPtr_;
@ -90,6 +98,19 @@ class sampledIsoSurface
mutable autoPtr<pointScalarField> storedPointFieldPtr_; mutable autoPtr<pointScalarField> storedPointFieldPtr_;
mutable const pointScalarField* pointFieldPtr_; mutable const pointScalarField* pointFieldPtr_;
// And on subsetted mesh
//- Cached submesh
mutable autoPtr<fvMeshSubset> subMeshPtr_;
//- Cached volfield
mutable autoPtr<volScalarField> storedVolSubFieldPtr_;
mutable const volScalarField* volSubFieldPtr_;
//- Cached pointfield
mutable autoPtr<pointScalarField> storedPointSubFieldPtr_;
mutable const pointScalarField* pointSubFieldPtr_;
// Private Member Functions // Private Member Functions
@ -97,6 +118,12 @@ class sampledIsoSurface
//- Get fields needed to recreate iso surface. //- Get fields needed to recreate iso surface.
void getIsoFields() const; void getIsoFields() const;
tmp<volScalarField> average
(
const fvMesh&,
const pointScalarField&
) const;
//- Create iso surface (if time has changed) //- Create iso surface (if time has changed)
// Do nothing (and return false) if no update was needed // Do nothing (and return false) if no update was needed
bool updateGeometry() const; bool updateGeometry() const;

View File

@ -52,35 +52,48 @@ Foam::sampledIsoSurface::interpolateField
const interpolation<Type>& interpolator const interpolation<Type>& interpolator
) const ) const
{ {
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
// Get fields to sample. Assume volPointInterpolation! // Get fields to sample. Assume volPointInterpolation!
const GeometricField<Type, fvPatchField, volMesh>& volFld = const GeometricField<Type, fvPatchField, volMesh>& volFld =
interpolator.psi(); interpolator.psi();
tmp<GeometricField<Type, pointPatchField, pointMesh> > tpointFld
(
volPointInterpolation::New(fvm).interpolate(volFld)
);
const GeometricField<Type, pointPatchField, pointMesh>& pointFld =
tpointFld();
// Get pointers to sampling field (both original and interpolated one)
getIsoFields();
// Recreate geometry if time has changed // Recreate geometry if time has changed
updateGeometry(); updateGeometry();
if (subMeshPtr_.valid())
{
tmp<GeometricField<Type, fvPatchField, volMesh> > tvolSubFld =
subMeshPtr_().interpolate(volFld);
const GeometricField<Type, fvPatchField, volMesh>& volSubFld =
tvolSubFld();
tmp<GeometricField<Type, pointPatchField, pointMesh> > tpointSubFld =
volPointInterpolation::New(volSubFld.mesh()).interpolate(volSubFld);
// Sample.
return surface().interpolate
(
*volSubFieldPtr_,
*pointSubFieldPtr_,
volSubFld,
tpointSubFld()
);
}
else
{
tmp<GeometricField<Type, pointPatchField, pointMesh> > tpointFld =
volPointInterpolation::New(volFld.mesh()).interpolate(volFld);
// Sample. // Sample.
return surface().interpolate return surface().interpolate
( (
*volFieldPtr_, *volFieldPtr_,
*pointFieldPtr_, *pointFieldPtr_,
volFld, volFld,
pointFld tpointFld()
); );
} }
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,6 +27,7 @@ License
#include "BasicMeshedSurface.H" #include "BasicMeshedSurface.H"
#include "boundBox.H" #include "boundBox.H"
#include "mergePoints.H" #include "mergePoints.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Face> template<class Face>
@ -162,7 +163,7 @@ void Foam::BasicMeshedSurface<Face>::cleanup(const bool verbose)
stitchFaces(SMALL, verbose); stitchFaces(SMALL, verbose);
checkFaces(verbose); checkFaces(verbose);
this->checkEdges(verbose); this->checkTopology(verbose);
} }

View File

@ -36,7 +36,8 @@ SourceFiles
#ifndef BasicMeshedSurface_H #ifndef BasicMeshedSurface_H
#define BasicMeshedSurface_H #define BasicMeshedSurface_H
#include "PrimitivePatchExtra.H" #include "PrimitivePatch.H"
#include "PatchTools.H"
#include "pointField.H" #include "pointField.H"
#include "face.H" #include "face.H"
#include "triFace.H" #include "triFace.H"
@ -55,11 +56,11 @@ namespace Foam
template<class Face> template<class Face>
class BasicMeshedSurface class BasicMeshedSurface
: :
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point> public PrimitivePatch<Face, ::Foam::List, pointField, point>
{ {
//- Typedefs for convenience //- Typedefs for convenience
typedef PrimitivePatchExtra typedef PrimitivePatch
< <
Face, Face,
::Foam::List, ::Foam::List,
@ -83,7 +84,7 @@ protected:
return static_cast<List<Face> &>(*this); return static_cast<List<Face> &>(*this);
} }
//- Set new regions/patches from faceMap //- Set new regions from faceMap
virtual void remapFaces(const UList<label>& faceMap); virtual void remapFaces(const UList<label>& faceMap);
public: public:

View File

@ -1,6 +1,6 @@
surfGroup/surfGroup.C surfRegion/surfRegion/surfRegion.C
surfGroup/surfGroupIOList.C surfRegion/surfRegion/surfRegionIOList.C
surfPatchIdentifier/surfPatchIdentifier.C surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
MeshedSurface/MeshedSurfaces.C MeshedSurface/MeshedSurfaces.C
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C UnsortedMeshedSurface/UnsortedMeshedSurfaces.C

View File

@ -166,11 +166,11 @@ Foam::MeshedSurface<Face>::MeshedSurface
( (
const Xfer<pointField>& pointLst, const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst, const Xfer<List<Face> >& faceLst,
const Xfer<surfGroupList>& patchLst const Xfer<surfRegionList>& regionLst
) )
: :
ParentType(pointLst, faceLst), ParentType(pointLst, faceLst),
patches_(patchLst) regions_(regionLst)
{} {}
@ -179,26 +179,26 @@ Foam::MeshedSurface<Face>::MeshedSurface
( (
const Xfer<pointField>& pointLst, const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst, const Xfer<List<Face> >& faceLst,
const UList<label>& patchSizes, const UList<label>& regionSizes,
const UList<word>& patchNames const UList<word>& regionNames
) )
: :
ParentType(pointLst, faceLst) ParentType(pointLst, faceLst)
{ {
if (&patchSizes) if (&regionSizes)
{ {
if (&patchNames) if (&regionNames)
{ {
addPatches(patchSizes, patchNames); addRegions(regionSizes, regionNames);
} }
else else
{ {
addPatches(patchSizes); addRegions(regionSizes);
} }
} }
else else
{ {
onePatch(); oneRegion();
} }
} }
@ -238,15 +238,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
); );
// create patch list // create region list
surfGroupList newPatches(bPatches.size()); surfRegionList newRegions(bPatches.size());
label startFaceI = 0; label startFaceI = 0;
forAll(bPatches, patchI) forAll(bPatches, patchI)
{ {
const polyPatch& p = bPatches[patchI]; const polyPatch& p = bPatches[patchI];
newPatches[patchI] = surfGroup newRegions[patchI] = surfRegion
( (
p.name(), p.name(),
p.size(), p.size(),
@ -262,7 +262,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
( (
xferCopy(bPoints), xferCopy(bPoints),
xferCopy(bFaces), xferCopy(bFaces),
xferMove(newPatches) xferMove(newRegions)
); );
@ -285,7 +285,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
origFaces.clear(); origFaces.clear();
this->storedFaces().transfer(newFaces); this->storedFaces().transfer(newFaces);
patches_.transfer(surf.patches_); regions_.transfer(surf.regions_);
} }
else else
{ {
@ -305,15 +305,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
{ {
const surfPatchList& sPatches = sMesh.boundaryMesh(); const surfPatchList& sPatches = sMesh.boundaryMesh();
// create patch list // create regions list
List<surfGroup> newPatches(sPatches.size()); List<surfRegion> newRegions(sPatches.size());
label startFaceI = 0; label startFaceI = 0;
forAll(sPatches, patchI) forAll(sPatches, patchI)
{ {
const surfPatch& p = sPatches[patchI]; const surfPatch& p = sPatches[patchI];
newPatches[patchI] = surfGroup newRegions[patchI] = surfRegion
( (
p.name(), p.name(),
p.size(), p.size(),
@ -324,7 +324,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
startFaceI += p.size(); startFaceI += p.size();
} }
patches_.transfer(newPatches); regions_.transfer(newRegions);
} }
#endif #endif
@ -336,8 +336,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
) )
{ {
labelList faceMap; labelList faceMap;
surfGroupList patchLst = surf.sortedRegions(faceMap); surfRegionList regionLst = surf.sortedRegions(faceMap);
patches_.transfer(patchLst); regions_.transfer(regionLst);
const List<Face>& origFaces = surf.faces(); const List<Face>& origFaces = surf.faces();
List<Face> newFaces(origFaces.size()); List<Face> newFaces(origFaces.size());
@ -388,7 +388,7 @@ template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf) Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
: :
ParentType(surf), ParentType(surf),
patches_(surf.patches_) regions_(surf.regions_)
{} {}
@ -420,70 +420,70 @@ Foam::MeshedSurface<Face>::~MeshedSurface()
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::onePatch(const word& name) void Foam::MeshedSurface<Face>::oneRegion(const word& name)
{ {
word patchName(name); word regionName(name);
if (patchName.empty()) if (regionName.empty())
{ {
if (patches_.size()) if (regions_.size())
{ {
patchName = patches_[0].name(); regionName = regions_[0].name();
} }
if (patchName.empty()) if (regionName.empty())
{ {
patchName = "patch0"; regionName = "region0";
} }
} }
// set single default patch // set single default region
patches_.setSize(1); regions_.setSize(1);
patches_[0] = surfGroup regions_[0] = surfRegion
( (
patchName, regionName,
size(), // patch size size(), // region size
0, // patch start 0, // region start
0 // patch index 0 // region index
); );
} }
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::checkPatches() void Foam::MeshedSurface<Face>::checkRegions()
{ {
// extra safety, ensure we have at some patches, // extra safety, ensure we have at some regions
// and they cover all the faces - fix start silently // and they cover all the faces - fix start silently
if (patches_.size() <= 1) if (regions_.size() <= 1)
{ {
onePatch(); oneRegion();
} }
else else
{ {
label count = 0; label count = 0;
forAll(patches_, patchI) forAll(regions_, regionI)
{ {
patches_[patchI].start() = count; regions_[regionI].start() = count;
count += patches_[patchI].size(); count += regions_[regionI].size();
} }
if (count < size()) if (count < size())
{ {
WarningIn WarningIn
( (
"MeshedSurface::checkPatches()\n" "MeshedSurface::checkRegions()\n"
) )
<< "more face " << size() << " than patches " << count << "more face " << size() << " than regions " << count
<< " ... extending final patch" << " ... extending final region"
<< endl; << endl;
patches_[patches_.size()-1].size() += count - size(); regions_[regions_.size()-1].size() += count - size();
} }
else if (count > size()) else if (count > size())
{ {
FatalErrorIn FatalErrorIn
( (
"MeshedSurface::checkPatches()\n" "MeshedSurface::checkRegions()\n"
) )
<< "more patches " << count << " than faces " << size() << "more regions " << count << " than faces " << size()
<< exit(FatalError); << exit(FatalError);
} }
} }
@ -534,33 +534,33 @@ void Foam::MeshedSurface<Face>::remapFaces
const UList<label>& faceMap const UList<label>& faceMap
) )
{ {
// recalculate the patch start/size // recalculate the region start/size
if (&faceMap && faceMap.size()) if (&faceMap && faceMap.size())
{ {
if (patches_.empty()) if (regions_.empty())
{ {
onePatch(); oneRegion();
} }
else if (patches_.size() == 1) else if (regions_.size() == 1)
{ {
// optimized for one-patch case // optimized for single region case
patches_[0].size() = faceMap.size(); regions_[0].size() = faceMap.size();
} }
else else
{ {
label newFaceI = 0; label newFaceI = 0;
label oldPatchEnd = 0; label origEndI = 0;
forAll(patches_, patchI) forAll(regions_, regionI)
{ {
surfGroup& p = patches_[patchI]; surfRegion& reg = regions_[regionI];
// adjust patch start // adjust region start
p.start() = newFaceI; reg.start() = newFaceI;
oldPatchEnd += p.size(); origEndI += reg.size();
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI) for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
{ {
if (faceMap[faceI] < oldPatchEnd) if (faceMap[faceI] < origEndI)
{ {
++newFaceI; ++newFaceI;
} }
@ -570,8 +570,8 @@ void Foam::MeshedSurface<Face>::remapFaces
} }
} }
// adjust patch size // adjust region size
p.size() = newFaceI - p.start(); reg.size() = newFaceI - reg.start();
} }
} }
} }
@ -586,14 +586,14 @@ template<class Face>
void Foam::MeshedSurface<Face>::clear() void Foam::MeshedSurface<Face>::clear()
{ {
ParentType::clear(); ParentType::clear();
patches_.clear(); regions_.clear();
} }
template<class Face> template<class Face>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
( (
const UList<bool>& include, const labelHashSet& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const ) const
@ -603,7 +603,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
// Fill pointMap, faceMap // Fill pointMap, faceMap
this->subsetMap(include, pointMap, faceMap); PatchTools::subsetMap(*this, include, pointMap, faceMap);
// Create compact coordinate list and forward mapping array // Create compact coordinate list and forward mapping array
pointField newPoints(pointMap.size()); pointField newPoints(pointMap.size());
@ -614,11 +614,11 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
oldToNew[pointMap[pointI]] = pointI; oldToNew[pointMap[pointI]] = pointI;
} }
// create/copy a new patch list, each patch with zero size // create/copy a new region list, each region with zero size
surfGroupList newPatches(patches_); surfRegionList newRegions(regions_);
forAll(newPatches, patchI) forAll(newRegions, regionI)
{ {
newPatches[patchI].size() = 0; newRegions[regionI].size() = 0;
} }
// Renumber face node labels // Renumber face node labels
@ -637,22 +637,22 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
} }
oldToNew.clear(); oldToNew.clear();
// recalculate the patch start/size // recalculate the region start/size
label newFaceI = 0; label newFaceI = 0;
label oldPatchEnd = 0; label origEndI = 0;
// adjust patch sizes // adjust region sizes
forAll(newPatches, patchI) forAll(newRegions, regionI)
{ {
surfGroup& p = newPatches[patchI]; surfRegion& reg = newRegions[regionI];
// adjust patch start // adjust region start
p.start() = newFaceI; reg.start() = newFaceI;
oldPatchEnd += p.size(); origEndI += reg.size();
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI) for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
{ {
if (faceMap[faceI] < oldPatchEnd) if (faceMap[faceI] < origEndI)
{ {
++newFaceI; ++newFaceI;
} }
@ -662,8 +662,8 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
} }
} }
// adjust patch size // adjust region size
p.size() = newFaceI - p.start(); reg.size() = newFaceI - reg.start();
} }
@ -672,15 +672,16 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
( (
xferMove(newPoints), xferMove(newPoints),
xferMove(newFaces), xferMove(newFaces),
xferMove(newPatches) xferMove(newRegions)
); );
} }
template<class Face> template<class Face>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh Foam::MeshedSurface<Face>
Foam::MeshedSurface<Face>::subsetMesh
( (
const UList<bool>& include const labelHashSet& include
) const ) const
{ {
labelList pointMap, faceMap; labelList pointMap, faceMap;
@ -689,29 +690,29 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::addPatches void Foam::MeshedSurface<Face>::addRegions
( (
const UList<surfGroup>& patches, const UList<surfRegion>& regions,
const bool cullEmpty const bool cullEmpty
) )
{ {
label nPatch = 0; label nRegion = 0;
patches_.setSize(patches.size()); regions_.setSize(regions.size());
forAll(patches_, patchI) forAll(regions_, regionI)
{ {
if (patches[patchI].size() || !cullEmpty) if (regions[regionI].size() || !cullEmpty)
{ {
patches_[nPatch] = surfGroup(patches[patchI], nPatch); regions_[nRegion] = surfRegion(regions[regionI], nRegion);
nPatch++; nRegion++;
} }
} }
patches_.setSize(nPatch); regions_.setSize(nRegion);
} }
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::addPatches void Foam::MeshedSurface<Face>::addRegions
( (
const UList<label>& sizes, const UList<label>& sizes,
const UList<word>& names, const UList<word>& names,
@ -719,55 +720,55 @@ void Foam::MeshedSurface<Face>::addPatches
) )
{ {
label start = 0; label start = 0;
label nPatch = 0; label nRegion = 0;
patches_.setSize(sizes.size()); regions_.setSize(sizes.size());
forAll(patches_, patchI) forAll(regions_, regionI)
{ {
if (sizes[patchI] || !cullEmpty) if (sizes[regionI] || !cullEmpty)
{ {
patches_[nPatch] = surfGroup regions_[nRegion] = surfRegion
( (
names[patchI], names[regionI],
sizes[patchI], sizes[regionI],
start, start,
nPatch nRegion
); );
start += sizes[patchI]; start += sizes[regionI];
nPatch++; nRegion++;
} }
} }
patches_.setSize(nPatch); regions_.setSize(nRegion);
} }
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::addPatches void Foam::MeshedSurface<Face>::addRegions
( (
const UList<label>& sizes, const UList<label>& sizes,
const bool cullEmpty const bool cullEmpty
) )
{ {
label start = 0; label start = 0;
label nPatch = 0; label nRegion = 0;
patches_.setSize(sizes.size()); regions_.setSize(sizes.size());
forAll(patches_, patchI) forAll(regions_, regionI)
{ {
if (sizes[patchI] || !cullEmpty) if (sizes[regionI] || !cullEmpty)
{ {
patches_[nPatch] = surfGroup regions_[nRegion] = surfRegion
( (
word("patch") + ::Foam::name(nPatch), word("region") + ::Foam::name(nRegion),
sizes[patchI], sizes[regionI],
start, start,
nPatch nRegion
); );
start += sizes[patchI]; start += sizes[regionI];
nPatch++; nRegion++;
} }
} }
patches_.setSize(nPatch); regions_.setSize(nRegion);
} }
@ -778,7 +779,7 @@ void Foam::MeshedSurface<Face>::transfer
) )
{ {
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces())); reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
patches_.transfer(surf.patches_); regions_.transfer(surf.regions_);
surf.clear(); surf.clear();
} }
@ -793,7 +794,7 @@ void Foam::MeshedSurface<Face>::transfer
clear(); clear();
labelList faceMap; labelList faceMap;
surfGroupList patchLst = surf.sortedRegions(faceMap); surfRegionList regionLst = surf.sortedRegions(faceMap);
List<Face>& oldFaces = surf.storedFaces(); List<Face>& oldFaces = surf.storedFaces();
List<Face> newFaces(faceMap.size()); List<Face> newFaces(faceMap.size());
@ -804,7 +805,7 @@ void Foam::MeshedSurface<Face>::transfer
faceMap.clear(); faceMap.clear();
reset(xferMove(surf.storedPoints()), xferMove(newFaces)); reset(xferMove(surf.storedPoints()), xferMove(newFaces));
patches_.transfer(patchLst); regions_.transfer(regionLst);
surf.clear(); surf.clear();
} }
@ -864,7 +865,7 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
this->storedPoints() = surf.points(); this->storedPoints() = surf.points();
this->storedFaces() = surf.faces(); this->storedFaces() = surf.faces();
patches_ = surf.patches_; regions_ = surf.regions_;
} }
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //

View File

@ -26,13 +26,13 @@ Class
Foam::MeshedSurface Foam::MeshedSurface
Description Description
A surface geometry mesh with patch information, not to be confused A surface geometry mesh with region information, not to be confused
with a similarily named surfaceMesh, which actually refers to with a similarily named surfaceMesh, which actually refers to
the cell faces of a volume mesh. the cell faces of a volume mesh.
The MeshedSurface is intended to surfaces from a variety of sources. The MeshedSurface is intended to surfaces from a variety of sources.
- A set of points and faces without any patch information. - A set of points and faces without any region information.
- A set of points and faces with randomly sorted patch information. - A set of points and faces with randomly sorted region information.
This could arise, for example, from reading external file formats This could arise, for example, from reading external file formats
such as STL, etc. such as STL, etc.
@ -45,7 +45,7 @@ SourceFiles
#define MeshedSurface_H #define MeshedSurface_H
#include "BasicMeshedSurface.H" #include "BasicMeshedSurface.H"
#include "surfGroupList.H" #include "surfRegionList.H"
#include "surfaceFormatsCore.H" #include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H" #include "memberFunctionSelectionTables.H"
@ -88,9 +88,9 @@ private:
// Private Member Data // Private Member Data
//- Patch information (face ordering nFaces/startFace only used //- Region information
// during reading and writing) // (face ordering nFaces/startFace only used during reading/writing)
List<surfGroup> patches_; List<surfRegion> regions_;
// Private member functions // Private member functions
@ -101,8 +101,8 @@ protected:
// Protected Member functions // Protected Member functions
//- basic sanity check on patches //- basic sanity check on regions
void checkPatches(); void checkRegions();
//- sort faces by regions and store sorted faces //- sort faces by regions and store sorted faces
void sortFacesAndStore void sortFacesAndStore
@ -139,22 +139,22 @@ public:
//- Construct null //- Construct null
MeshedSurface(); MeshedSurface();
//- Construct by transferring components (points, faces, patches). //- Construct by transferring components (points, faces, regions).
MeshedSurface MeshedSurface
( (
const Xfer<pointField>&, const Xfer<pointField>&,
const Xfer<List<Face> >&, const Xfer<List<Face> >&,
const Xfer<surfGroupList>& const Xfer<surfRegionList>&
); );
//- Construct by transferring points, faces. //- Construct by transferring points, faces.
// Use patch information, or set single default patch. // Use region information, or set single default region.
MeshedSurface MeshedSurface
( (
const Xfer<pointField>&, const Xfer<pointField>&,
const Xfer<List<Face> >&, const Xfer<List<Face> >&,
const UList<label>& patchSizes = UList<label>::null(), const UList<label>& regionSizes = UList<label>::null(),
const UList<word>& patchNames = UList<word>::null() const UList<word>& regionNames = UList<word>::null()
); );
//- Construct from a boundary mesh with local points/faces //- Construct from a boundary mesh with local points/faces
@ -250,31 +250,31 @@ public:
return ParentType::size(); return ParentType::size();
} }
const List<surfGroup>& patches() const const List<surfRegion>& regions() const
{ {
return patches_; return regions_;
} }
//- set a single patch, optionally with a specific name //- set a single region, optionally with a specific name
void onePatch(const word& name = word::null); void oneRegion(const word& name = word::null);
//- add patches //- Add regions
void addPatches void addRegions
( (
const UList<surfGroup>&, const UList<surfRegion>&,
const bool cullEmpty=false const bool cullEmpty=false
); );
//- add patches //- Add regions
void addPatches void addRegions
( (
const UList<label>& sizes, const UList<label>& sizes,
const UList<word>& names, const UList<word>& names,
const bool cullEmpty=false const bool cullEmpty=false
); );
//- add patches //- Add regions
void addPatches void addRegions
( (
const UList<label>& sizes, const UList<label>& sizes,
const bool cullEmpty=false const bool cullEmpty=false
@ -289,7 +289,7 @@ public:
// Returns return pointMap, faceMap from subsetMeshMap // Returns return pointMap, faceMap from subsetMeshMap
MeshedSurface subsetMesh MeshedSurface subsetMesh
( (
const UList<bool>& include, const labelHashSet& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const; ) const;
@ -297,7 +297,7 @@ public:
//- Return new surface. //- Return new surface.
MeshedSurface subsetMesh MeshedSurface subsetMesh
( (
const UList<bool>& include const labelHashSet& include
) const; ) const;
//- Transfer the contents of the argument and annull the argument //- Transfer the contents of the argument and annull the argument

View File

@ -37,16 +37,16 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
{ {
clear(); clear();
List<surfGroup> patchLst(is); List<surfRegion> regionLst(is);
// copy and set the indices // copy and set the indices
patches_.setSize(patchLst.size()); regions_.setSize(regionLst.size());
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
patches_[patchI] = surfGroup regions_[regionI] = surfRegion
( (
patchLst[patchI], regionLst[regionI],
patchI regionI
); );
} }
@ -64,11 +64,11 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
Xfer<pointField>::null(), Xfer<pointField>::null(),
faceLst.xfer() faceLst.xfer()
); );
surf.addPatches(patches_); surf.addRegions(regions_);
// this will break if the triangulation needed points // this will break if the triangulation needed points
surf.triangulate(); surf.triangulate();
patches_ = surf.patches(); regions_ = surf.regions();
// transcribe from face -> triFace (Face) // transcribe from face -> triFace (Face)
const List<face>& origFaces = surf.faces(); const List<face>& origFaces = surf.faces();
@ -102,11 +102,11 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
os << "// OpenFOAM Surface Format" << nl os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl << "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl << "// regions:" << nl
<< patches_.size() << nl << token::BEGIN_LIST << incrIndent << nl; << regions_.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(patches_, patchI) forAll(regions_, regionI)
{ {
patches_[patchI].writeDict(os); regions_[regionI].writeDict(os);
} }
os << decrIndent << token::END_LIST << nl; os << decrIndent << token::END_LIST << nl;

View File

@ -164,12 +164,12 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
const Xfer<pointField>& pointLst, const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst, const Xfer<List<Face> >& faceLst,
const Xfer<List<label> >& regionIds, const Xfer<List<label> >& regionIds,
const Xfer<surfPatchIdentifierList>& patchLst const Xfer<surfRegionIdentifierList>& regionTofc
) )
: :
ParentType(pointLst, faceLst), ParentType(pointLst, faceLst),
regions_(regionIds), regionIds_(regionIds),
patches_(patchLst) regionToc_(regionTofc)
{} {}
@ -178,26 +178,26 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
( (
const Xfer<pointField>& pointLst, const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst, const Xfer<List<Face> >& faceLst,
const UList<label>& patchSizes, const UList<label>& regionSizes,
const UList<word>& patchNames const UList<word>& regionNames
) )
: :
ParentType(pointLst, faceLst) ParentType(pointLst, faceLst)
{ {
if (&patchSizes) if (&regionSizes)
{ {
if (&patchNames) if (&regionNames)
{ {
setPatches(patchSizes, patchNames); setRegions(regionSizes, regionNames);
} }
else else
{ {
setPatches(patchSizes); setRegions(regionSizes);
} }
} }
else else
{ {
onePatch(); oneRegion();
} }
} }
@ -223,7 +223,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
: :
ParentType(xferCopy(surf.points()), xferCopy(surf.faces())) ParentType(xferCopy(surf.points()), xferCopy(surf.faces()))
{ {
setPatches(surf.patches()); setRegions(surf.regions());
} }
@ -266,8 +266,8 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
) )
: :
ParentType(xferCopy(surf.points()), xferCopy(surf.faces())), ParentType(xferCopy(surf.points()), xferCopy(surf.faces())),
regions_(surf.regions_), regionIds_(surf.regionIds_),
patches_(surf.patches_) regionToc_(surf.regionToc_)
{} {}
@ -296,101 +296,105 @@ template<class Face>
Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface() Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
{} {}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::onePatch(const word& name) void Foam::UnsortedMeshedSurface<Face>::oneRegion(const word& name)
{ {
regions_.setSize(size()); regionIds_.setSize(size());
regions_ = 0; regionIds_ = 0;
word patchName(name); word regionName(name);
if (patchName.empty()) if (regionName.empty())
{ {
if (patches_.size()) if (regionToc_.size())
{ {
patchName = patches_[0].name(); regionName = regionToc_[0].name();
} }
if (patchName.empty()) if (regionName.empty())
{ {
patchName = "patch0"; regionName = "region0";
} }
} }
// set single default patch // set single default region
patches_.setSize(1); regionToc_.setSize(1);
patches_[0] = surfPatchIdentifier(patchName, 0); regionToc_[0] = surfRegionIdentifier(regionName, 0);
} }
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setPatches void Foam::UnsortedMeshedSurface<Face>::setRegions
( (
const surfGroupList& patches const surfRegionList& regionLst
) )
{ {
regions_.setSize(size()); regionIds_.setSize(size());
patches_.setSize(patches.size()); regionToc_.setSize(regionLst.size());
forAll(patches, patchI) forAll(regionToc_, regionI)
{ {
const surfGroup& p = patches[patchI]; const surfRegion& reg = regionLst[regionI];
patches_[patchI] = p; regionToc_[regionI] = reg;
SubList<label> subRegion(regions_, p.size(), p.start()); // assign sub-region Ids
subRegion = patchI; SubList<label> subRegion(regionIds_, reg.size(), reg.start());
subRegion = regionI;
} }
} }
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setPatches void Foam::UnsortedMeshedSurface<Face>::setRegions
( (
const UList<label>& sizes, const UList<label>& sizes,
const UList<word>& names const UList<word>& names
) )
{ {
regions_.setSize(size()); regionIds_.setSize(size());
patches_.setSize(sizes.size()); regionToc_.setSize(sizes.size());
label start = 0; label start = 0;
forAll(patches_, patchI) forAll(regionToc_, regionI)
{ {
patches_[patchI] = surfPatchIdentifier(names[patchI], patchI); regionToc_[regionI] = surfRegionIdentifier(names[regionI], regionI);
SubList<label> subRegion(regions_, sizes[patchI], start); // assign sub-region Ids
subRegion = patchI; SubList<label> subRegion(regionIds_, sizes[regionI], start);
subRegion = regionI;
start += sizes[patchI]; start += sizes[regionI];
} }
} }
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setPatches void Foam::UnsortedMeshedSurface<Face>::setRegions
( (
const UList<label>& sizes const UList<label>& sizes
) )
{ {
regions_.setSize(size()); regionIds_.setSize(size());
patches_.setSize(sizes.size()); regionToc_.setSize(sizes.size());
label start = 0; label start = 0;
forAll(patches_, patchI) forAll(regionToc_, regionI)
{ {
patches_[patchI] = surfPatchIdentifier regionToc_[regionI] = surfRegionIdentifier
( (
word("patch") + ::Foam::name(patchI), word("region") + ::Foam::name(regionI),
patchI regionI
); );
SubList<label> subRegion(regions_, sizes[patchI], start); // assign sub-region Ids
subRegion = patchI; SubList<label> subRegion(regionIds_, sizes[regionI], start);
subRegion = regionI;
start += sizes[patchI]; start += sizes[regionI];
} }
} }
@ -404,14 +408,14 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
// re-assign the region Ids // re-assign the region Ids
if (&faceMap && faceMap.size()) if (&faceMap && faceMap.size())
{ {
if (patches_.empty()) if (regionToc_.empty())
{ {
onePatch(); oneRegion();
} }
else if (patches_.size() == 1) else if (regionToc_.size() == 1)
{ {
// optimized for one-patch case // optimized for single-region case
regions_ = 0; regionIds_ = 0;
} }
else else
{ {
@ -419,9 +423,9 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
forAll(faceMap, faceI) forAll(faceMap, faceI)
{ {
newRegions[faceI] = regions_[faceMap[faceI]]; newRegions[faceI] = regionIds_[faceMap[faceI]];
} }
regions_.transfer(newRegions); regionIds_.transfer(newRegions);
} }
} }
} }
@ -433,8 +437,8 @@ template<class Face>
void Foam::UnsortedMeshedSurface<Face>::setSize(const label s) void Foam::UnsortedMeshedSurface<Face>::setSize(const label s)
{ {
ParentType::setSize(s); ParentType::setSize(s);
// if regions extend: set with last patchId // if regions extend: set with last regionId
regions_.setSize(s, patches_.size() - 1); regionIds_.setSize(s, regionToc_.size() - 1);
} }
@ -442,32 +446,32 @@ template<class Face>
void Foam::UnsortedMeshedSurface<Face>::clear() void Foam::UnsortedMeshedSurface<Face>::clear()
{ {
ParentType::clear(); ParentType::clear();
regions_.clear(); regionIds_.clear();
patches_.clear(); regionToc_.clear();
} }
template<class Face> template<class Face>
Foam::surfGroupList Foam::UnsortedMeshedSurface<Face>::sortedRegions Foam::surfRegionList Foam::UnsortedMeshedSurface<Face>::sortedRegions
( (
labelList& faceMap labelList& faceMap
) const ) const
{ {
// supply some patch names // supply some region names
Map<word> patchNames; Map<word> regionNames;
forAll(patches_, patchI) forAll(regionToc_, regionI)
{ {
patchNames.insert(patchI, patches_[patchI].name()); regionNames.insert(regionI, regionToc_[regionI].name());
} }
return sortedPatchRegions(regions_, patchNames, faceMap); return sortedRegionsById(regionIds_, regionNames, faceMap);
} }
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
( (
const UList<bool>& include, const labelHashSet& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const ) const
@ -476,7 +480,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
const List<Face>& locFaces = this->localFaces(); const List<Face>& locFaces = this->localFaces();
// Fill pointMap, faceMap // Fill pointMap, faceMap
this->subsetMap(include, pointMap, faceMap); PatchTools::subsetMap(*this, include, pointMap, faceMap);
// Create compact coordinate list and forward mapping array // Create compact coordinate list and forward mapping array
pointField newPoints(pointMap.size()); pointField newPoints(pointMap.size());
@ -503,7 +507,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
f[fp] = oldToNew[f[fp]]; f[fp] = oldToNew[f[fp]];
} }
newRegions[faceI] = regions_[origFaceI]; newRegions[faceI] = regionIds_[origFaceI];
} }
oldToNew.clear(); oldToNew.clear();
@ -513,7 +517,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
xferMove(newPoints), xferMove(newPoints),
xferMove(newFaces), xferMove(newFaces),
xferMove(newRegions), xferMove(newRegions),
xferCopy(patches_) xferCopy(regionToc_)
); );
} }
@ -521,7 +525,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
( (
const UList<bool>& include const labelHashSet& include
) const ) const
{ {
labelList pointMap, faceMap; labelList pointMap, faceMap;
@ -541,7 +545,7 @@ void Foam::UnsortedMeshedSurface<Face>::reset
if (&regionIds) if (&regionIds)
{ {
regions_.transfer(regionIds()); regionIds_.transfer(regionIds());
} }
} }
@ -556,9 +560,9 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
( (
xferMove(surf.storedPoints()), xferMove(surf.storedPoints()),
xferMove(surf.storedFaces()), xferMove(surf.storedFaces()),
xferMove(surf.regions_) xferMove(surf.regionIds_)
); );
patches_.transfer(surf.patches_); regionToc_.transfer(surf.regionToc_);
surf.clear(); surf.clear();
} }
@ -571,7 +575,7 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
) )
{ {
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces())); reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
setPatches(surf.patches()); setRegions(surf.regions());
surf.clear(); surf.clear();
} }
@ -634,8 +638,8 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
this->storedPoints() = surf.points(); this->storedPoints() = surf.points();
this->storedFaces() = surf.faces(); this->storedFaces() = surf.faces();
regions_ = surf.regions_; regionIds_ = surf.regionIds_;
patches_ = surf.patches_; regionToc_ = surf.regionToc_;
} }

View File

@ -26,18 +26,18 @@ Class
Foam::UnsortedMeshedSurface Foam::UnsortedMeshedSurface
Description Description
A surface geometry mesh, in which the patch information is conveyed by A surface geometry mesh, in which the region information is conveyed by
the 'region' associated with each face. the 'regionId' associated with each face.
This form of surface description is particularly useful for reading in This form of surface description is particularly useful for reading in
surface meshes from third-party formats (eg, obj, stl, gts, etc.). It surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
can also be particularly useful for situations in which the surface can also be particularly useful for situations in which the surface
many be adjusted in an arbitrary manner without worrying about needed many be adjusted in an arbitrary manner without worrying about needed
to adjust the patch information (eg, surface refinement). to adjust the region information (eg, surface refinement).
See Also See Also
The Foam::meshedSurface - which is organized as a surface mesh, but The Foam::MeshedSurface - which is organized as a surface mesh, but
with independent patch information. with independent region information.
SourceFiles SourceFiles
UnsortedMeshedSurface.C UnsortedMeshedSurface.C
@ -48,8 +48,8 @@ SourceFiles
#define UnsortedMeshedSurface_H #define UnsortedMeshedSurface_H
#include "BasicMeshedSurface.H" #include "BasicMeshedSurface.H"
#include "surfPatchIdentifierList.H" #include "surfRegionIdentifierList.H"
#include "surfGroupList.H" #include "surfRegionList.H"
#include "surfaceFormatsCore.H" #include "surfaceFormatsCore.H"
#include "runTimeSelectionTables.H" #include "runTimeSelectionTables.H"
#include "memberFunctionSelectionTables.H" #include "memberFunctionSelectionTables.H"
@ -93,12 +93,12 @@ private:
// Private Member Data // Private Member Data
//- The regions associated with the faces //- The region Ids associated with the faces
labelList regions_; labelList regionIds_;
//- Patch information (face ordering nFaces/startFace only used //- Region information (face ordering nFaces/startFace only used
// during reading and writing) // during reading and writing)
List<surfPatchIdentifier> patches_; List<surfRegionIdentifier> regionToc_;
// Private member functions // Private member functions
@ -115,16 +115,16 @@ protected:
// Protected Member functions // Protected Member functions
//- Return non-const access to the faces //- Return non-const access to the region Ids
List<label>& storedRegions() List<label>& storedRegionIds()
{ {
return regions_; return regionIds_;
} }
//- Return non-const access to the patches //- Return non-const access to the region table-of-contents
List<surfPatchIdentifier>& storedPatches() List<surfRegionIdentifier>& storedRegionToc()
{ {
return patches_; return regionToc_;
} }
//- Set new regions from faceMap //- Set new regions from faceMap
@ -155,23 +155,23 @@ public:
UnsortedMeshedSurface(); UnsortedMeshedSurface();
//- Construct by transferring components //- Construct by transferring components
// (points, faces, region ids, patches). // (points, faces, region ids, region info).
UnsortedMeshedSurface UnsortedMeshedSurface
( (
const Xfer<pointField>&, const Xfer<pointField>&,
const Xfer<List<Face> >&, const Xfer<List<Face> >&,
const Xfer<List<label> >& regionIds, const Xfer<List<label> >& regionIds,
const Xfer<surfPatchIdentifierList>& const Xfer<surfRegionIdentifierList>&
); );
//- Construct by transferring points, faces. //- Construct by transferring points, faces.
// Use patch information, or set single default patch // Use region information, or set single default region
UnsortedMeshedSurface UnsortedMeshedSurface
( (
const Xfer<pointField>&, const Xfer<pointField>&,
const Xfer<List<Face> >&, const Xfer<List<Face> >&,
const UList<label>& patchSizes = UList<label>::null(), const UList<label>& regionSizes = UList<label>::null(),
const UList<word>& patchNames = UList<word>::null() const UList<word>& regionNames = UList<word>::null()
); );
//- Construct from a boundary mesh with local points/faces //- Construct from a boundary mesh with local points/faces
@ -267,34 +267,34 @@ public:
//- Reset size of face and region list //- Reset size of face and region list
void setSize(const label); void setSize(const label);
//- Return const access to the regions //- Return const access to the regions ids
const List<label>& regions() const const List<label>& regionIds() const
{ {
return regions_; return regionIds_;
} }
//- Return const access to the patches //- Return const access to the region table-of-contents
const List<surfPatchIdentifier>& patches() const const List<surfRegionIdentifier>& regionToc() const
{ {
return patches_; return regionToc_;
} }
//- Sort faces according to region. //- Sort faces according to region.
// Returns patch list and sets faceMap to index within faces() // Returns a surfRegionList and sets faceMap to index within faces()
List<surfGroup> sortedRegions(labelList& faceMap) const; surfRegionList sortedRegions(labelList& faceMap) const;
//- Set regions to 0 and set a single patch //- Set regions to 0 and set a single region
// Optionally with a specific name // Optionally with a specific name
void onePatch(const word& name = word::null); void oneRegion(const word& name = word::null);
//- Set regions and patches //- Set region ids and regions
void setPatches(const surfGroupList&); void setRegions(const surfRegionList&);
//- Set regions and patches //- Set region ids and regions
void setPatches(const UList<label>& sizes, const UList<word>& names); void setRegions(const UList<label>& sizes, const UList<word>& names);
//- Set regions and patches with default names //- Set region ids and set regions with default names
void setPatches(const UList<label>& sizes); void setRegions(const UList<label>& sizes);
// Edit // Edit
@ -306,7 +306,7 @@ public:
// Returns return pointMap, faceMap from subsetMeshMap // Returns return pointMap, faceMap from subsetMeshMap
UnsortedMeshedSurface subsetMesh UnsortedMeshedSurface subsetMesh
( (
const UList<bool>& include, const labelHashSet& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const; ) const;
@ -314,7 +314,7 @@ public:
//- Return new surface. //- Return new surface.
UnsortedMeshedSurface subsetMesh UnsortedMeshedSurface subsetMesh
( (
const UList<bool>& include const labelHashSet& include
) const; ) const;
//- Transfer components (points, faces, region ids). //- Transfer components (points, faces, region ids).

View File

@ -49,18 +49,18 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
const List<Face>& faceLst = this->faces(); const List<Face>& faceLst = this->faces();
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = sortedRegions(faceMap); surfRegionList regionLst = sortedRegions(faceMap);
// just emit some information until we get a nice IOobject // just emit some information until we get a nice IOobject
IOobject::writeBanner(os); IOobject::writeBanner(os);
os << "// OpenFOAM Surface Format" << nl os << "// OpenFOAM Surface Format" << nl
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl << "// ~~~~~~~~~~~~~~~~~~~~~~~" << nl
<< "// regions:" << nl << "// regions:" << nl
<< patchLst.size() << nl << token::BEGIN_LIST << incrIndent << nl; << regionLst.size() << nl << token::BEGIN_LIST << incrIndent << nl;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
patchLst[patchI].writeDict(os); regionLst[regionI].writeDict(os);
} }
os << decrIndent << token::END_LIST << nl; os << decrIndent << token::END_LIST << nl;
@ -74,12 +74,12 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
os << faceLst.size() << nl << token::BEGIN_LIST << nl; os << faceLst.size() << nl << token::BEGIN_LIST << nl;
label faceI = 0; label faceI = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
os << faceLst[faceMap[faceI++]] << nl; os << faceLst[faceMap[faceI++]] << nl;
} }

View File

@ -26,28 +26,28 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "surfGroup.H" #include "surfRegion.H"
#include "dictionary.H" #include "dictionary.H"
#include "word.H" #include "word.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfGroup, 0); defineTypeNameAndDebug(Foam::surfRegion, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfGroup::surfGroup() Foam::surfRegion::surfRegion()
: :
surfPatchIdentifier(), surfRegionIdentifier(),
size_(0), size_(0),
start_(0) start_(0)
{} {}
Foam::surfGroup::surfGroup Foam::surfRegion::surfRegion
( (
const word& name, const word& name,
const label size, const label size,
@ -56,68 +56,68 @@ Foam::surfGroup::surfGroup
const word& geometricType const word& geometricType
) )
: :
surfPatchIdentifier(name, index, geometricType), surfRegionIdentifier(name, index, geometricType),
size_(size), size_(size),
start_(start) start_(start)
{} {}
Foam::surfGroup::surfGroup(Istream& is, const label index) Foam::surfRegion::surfRegion(Istream& is, const label index)
: :
surfPatchIdentifier(), surfRegionIdentifier(),
size_(0), size_(0),
start_(0) start_(0)
{ {
word name(is); word name(is);
dictionary dict(is); dictionary dict(is);
operator=(surfGroup(name, dict, index)); operator=(surfRegion(name, dict, index));
} }
Foam::surfGroup::surfGroup Foam::surfRegion::surfRegion
( (
const word& name, const word& name,
const dictionary& dict, const dictionary& dict,
const label index const label index
) )
: :
surfPatchIdentifier(name, dict, index), surfRegionIdentifier(name, dict, index),
size_(readLabel(dict.lookup("nFaces"))), size_(readLabel(dict.lookup("nFaces"))),
start_(readLabel(dict.lookup("startFace"))) start_(readLabel(dict.lookup("startFace")))
{} {}
Foam::surfGroup::surfGroup(const surfGroup& p) Foam::surfRegion::surfRegion(const surfRegion& reg)
: :
surfPatchIdentifier(p, p.index()), surfRegionIdentifier(reg, reg.index()),
size_(p.size()), size_(reg.size()),
start_(p.start()) start_(reg.start())
{} {}
Foam::surfGroup::surfGroup(const surfGroup& p, const label index) Foam::surfRegion::surfRegion(const surfRegion& reg, const label index)
: :
surfPatchIdentifier(p, index), surfRegionIdentifier(reg, index),
size_(p.size()), size_(reg.size()),
start_(p.start()) start_(reg.start())
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfGroup::write(Ostream& os) const void Foam::surfRegion::write(Ostream& os) const
{ {
writeDict(os); writeDict(os);
} }
void Foam::surfGroup::writeDict(Ostream& os) const void Foam::surfRegion::writeDict(Ostream& os) const
{ {
os << indent << name() << nl os << indent << name() << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl; << indent << token::BEGIN_BLOCK << incrIndent << nl;
surfPatchIdentifier::write(os); surfRegionIdentifier::write(os);
os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl; os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl; os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
@ -127,38 +127,38 @@ void Foam::surfGroup::writeDict(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
bool Foam::surfGroup::operator!=(const surfGroup& p) const bool Foam::surfRegion::operator!=(const surfRegion& reg) const
{ {
return !(*this == p); return !(*this == reg);
} }
bool Foam::surfGroup::operator==(const surfGroup& p) const bool Foam::surfRegion::operator==(const surfRegion& reg) const
{ {
return return
( (
(geometricType() == p.geometricType()) (geometricType() == reg.geometricType())
&& (size() == p.size()) && (size() == reg.size())
&& (start() == p.start()) && (start() == reg.start())
); );
} }
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, surfGroup& p) Foam::Istream& Foam::operator>>(Istream& is, surfRegion& reg)
{ {
p = surfGroup(is, 0); reg = surfRegion(is, 0);
is.check("Istream& operator>>(Istream&, surfGroup&)"); is.check("Istream& operator>>(Istream&, surfRegion&)");
return is; return is;
} }
Foam::Ostream& Foam::operator<<(Ostream& os, const surfGroup& p) Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegion& reg)
{ {
p.write(os); reg.write(os);
os.check("Ostream& operator<<(Ostream& f, const surfGroup& p"); os.check("Ostream& operator<<(Ostream&, const surfRegion&");
return os; return os;
} }

View File

@ -23,23 +23,24 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::surfGroup Foam::surfRegion
Description Description
'Patch' on surface as subset of triSurface. A region on a meshed surface.
Similar in concept to a faceZone on the surface.
SourceFiles SourceFiles
surfGroup.C surfRegion.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfGroup_H #ifndef surfRegion_H
#define surfGroup_H #define surfRegion_H
#include "word.H" #include "word.H"
#include "label.H" #include "label.H"
#include "className.H" #include "className.H"
#include "surfPatchIdentifier.H" #include "surfRegionIdentifier.H"
#include "autoPtr.H" #include "autoPtr.H"
#include "dictionary.H" #include "dictionary.H"
@ -50,18 +51,18 @@ namespace Foam
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class surfGroup; class surfRegion;
Istream& operator>>(Istream&, surfGroup&); Istream& operator>>(Istream&, surfRegion&);
Ostream& operator<<(Ostream&, const surfGroup&); Ostream& operator<<(Ostream&, const surfRegion&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class surfGroup Declaration Class surfRegion Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class surfGroup class surfRegion
: :
public surfPatchIdentifier public surfRegionIdentifier
{ {
// Private data // Private data
@ -74,16 +75,16 @@ class surfGroup
public: public:
//- Runtime type information //- Runtime type information
ClassName("surfGroup"); ClassName("surfRegion");
// Constructors // Constructors
//- Construct null //- Construct null
surfGroup(); surfRegion();
//- Construct from components //- Construct from components
surfGroup surfRegion
( (
const word& name, const word& name,
const label size, const label size,
@ -93,10 +94,10 @@ public:
); );
//- Construct from Istream //- Construct from Istream
surfGroup(Istream& is, const label index); surfRegion(Istream& is, const label index);
//- Construct from dictionary //- Construct from dictionary
surfGroup surfRegion
( (
const word& name, const word& name,
const dictionary& dict, const dictionary& dict,
@ -104,48 +105,48 @@ public:
); );
//- Construct as copy //- Construct as copy
surfGroup(const surfGroup&); surfRegion(const surfRegion&);
//- Construct from another patch, resetting the index //- Construct from another region, resetting the index
surfGroup(const surfGroup&, const label index); surfRegion(const surfRegion&, const label index);
//- Return clone //- Return clone
autoPtr<surfGroup> clone() const autoPtr<surfRegion> clone() const
{ {
notImplemented("autoPtr<surfGroup> clone() const"); notImplemented("autoPtr<surfRegion> clone() const");
return autoPtr<surfGroup>(NULL); return autoPtr<surfRegion>(NULL);
} }
static autoPtr<surfGroup> New(Istream& is) static autoPtr<surfRegion> New(Istream& is)
{ {
word name(is); word name(is);
dictionary dict(is); dictionary dict(is);
return autoPtr<surfGroup>(new surfGroup(name, dict, 0)); return autoPtr<surfRegion>(new surfRegion(name, dict, 0));
} }
// Member Functions // Member Functions
//- Return start label of this patch in the face list //- Return start label of this region in the face list
label start() const label start() const
{ {
return start_; return start_;
} }
//- Return start label of this patch in the face list //- Return start label of this region in the face list
label& start() label& start()
{ {
return start_; return start_;
} }
//- Return size of this patch in the face list //- Return size of this region in the face list
label size() const label size() const
{ {
return size_; return size_;
} }
//- Return size of this patch in the face list //- Return size of this region in the face list
label& size() label& size()
{ {
return size_; return size_;
@ -160,15 +161,15 @@ public:
// Member Operators // Member Operators
bool operator!=(const surfGroup&) const; bool operator!=(const surfRegion&) const;
//- compare. //- compare.
bool operator==(const surfGroup&) const; bool operator==(const surfRegion&) const;
// IOstream Operators // IOstream Operators
friend Istream& operator>>(Istream&, surfGroup&); friend Istream& operator>>(Istream&, surfRegion&);
friend Ostream& operator<<(Ostream&, const surfGroup&); friend Ostream& operator<<(Ostream&, const surfRegion&);
}; };

View File

@ -24,71 +24,71 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "surfGroupIOList.H" #include "surfRegionIOList.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::surfGroupIOList, 0); defineTypeNameAndDebug(Foam::surfRegionIOList, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfGroupIOList::surfGroupIOList Foam::surfRegionIOList::surfRegionIOList
( (
const IOobject& io const IOobject& io
) )
: :
surfGroupList(), surfRegionList(),
regIOobject(io) regIOobject(io)
{ {
Foam::string functionName = Foam::string functionName =
"surfGroupIOList::surfGroupIOList" "surfRegionIOList::surfRegionIOList"
"(const IOobject& io)"; "(const IOobject& io)";
if (readOpt() == IOobject::MUST_READ) if (readOpt() == IOobject::MUST_READ)
{ {
surfGroupList& patches = *this; surfRegionList& regions = *this;
// read polyPatchList // read polyPatchList
Istream& is = readStream(typeName); Istream& is = readStream(typeName);
PtrList<entry> patchEntries(is); PtrList<entry> dictEntries(is);
patches.setSize(patchEntries.size()); regions.setSize(dictEntries.size());
label faceI = 0; label faceI = 0;
forAll(patches, patchI) forAll(regions, regionI)
{ {
const dictionary& dict = patchEntries[patchI].dict(); const dictionary& dict = dictEntries[regionI].dict();
label patchSize = readLabel(dict.lookup("nFaces")); label regionSize = readLabel(dict.lookup("nFaces"));
label startFaceI = readLabel(dict.lookup("startFace")); label startFaceI = readLabel(dict.lookup("startFace"));
patches[patchI] = surfGroup regions[regionI] = surfRegion
( (
patchEntries[patchI].keyword(), dictEntries[regionI].keyword(),
patchSize, regionSize,
startFaceI, startFaceI,
patchI regionI
); );
word geoType; word geoType;
if (dict.readIfPresent("geometricType", geoType)) if (dict.readIfPresent("geometricType", geoType))
{ {
patches[patchI].geometricType() = geoType; regions[regionI].geometricType() = geoType;
} }
if (startFaceI != faceI) if (startFaceI != faceI)
{ {
FatalErrorIn(functionName) FatalErrorIn(functionName)
<< "Patches are not ordered. Start of patch " << patchI << "Regions are not ordered. Start of region " << regionI
<< " does not correspond to sum of preceding patches." << " does not correspond to sum of preceding regions."
<< endl << endl
<< "while reading " << io.objectPath() << "while reading " << io.objectPath()
<< exit(FatalError); << exit(FatalError);
} }
faceI += patchSize; faceI += regionSize;
} }
// Check state of IOstream // Check state of IOstream
@ -99,20 +99,20 @@ Foam::surfGroupIOList::surfGroupIOList
} }
// Construct from IOObject // Construct from IOObject
Foam::surfGroupIOList::surfGroupIOList Foam::surfRegionIOList::surfRegionIOList
( (
const IOobject& io, const IOobject& io,
const surfGroupList& patches const surfRegionList& regions
) )
: :
surfGroupList(patches), surfRegionList(regions),
regIOobject(io) regIOobject(io)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfGroupIOList::~surfGroupIOList() Foam::surfRegionIOList::~surfRegionIOList()
{} {}
@ -120,7 +120,7 @@ Foam::surfGroupIOList::~surfGroupIOList()
// writeData member function required by regIOobject // writeData member function required by regIOobject
bool Foam::surfGroupIOList::writeData(Ostream& os) const bool Foam::surfRegionIOList::writeData(Ostream& os) const
{ {
os << *this; os << *this;
return os.good(); return os.good();
@ -129,13 +129,13 @@ bool Foam::surfGroupIOList::writeData(Ostream& os) const
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const surfGroupIOList& patches) Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIOList& L)
{ {
os << patches.size() << nl << token::BEGIN_LIST; os << L.size() << nl << token::BEGIN_LIST;
forAll(patches, patchI) forAll(L, i)
{ {
patches[patchI].writeDict(os); L[i].writeDict(os);
} }
os << token::END_LIST; os << token::END_LIST;

View File

@ -23,20 +23,20 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::surfGroupIOList Foam::surfRegionIOList
Description Description
IOobject for a surfGroupList IOobject for a surfRegionList
SourceFiles SourceFiles
surfGroupIOList.C surfRegionIOList.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfGroupIOList_H #ifndef surfRegionIOList_H
#define surfGroupIOList_H #define surfRegionIOList_H
#include "surfGroupList.H" #include "surfRegionList.H"
#include "regIOobject.H" #include "regIOobject.H"
#include "faceList.H" #include "faceList.H"
#include "className.H" #include "className.H"
@ -49,12 +49,12 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class surfGroupIOList Declaration Class surfRegionIOList Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class surfGroupIOList class surfRegionIOList
: :
public surfGroupList, public surfRegionList,
public regIOobject public regIOobject
{ {
// Private data // Private data
@ -63,29 +63,29 @@ class surfGroupIOList
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
surfGroupIOList(const surfGroupIOList&); surfRegionIOList(const surfRegionIOList&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const surfGroupIOList&); void operator=(const surfRegionIOList&);
public: public:
//- Runtime type information //- Runtime type information
TypeName("surfGroupIOList"); TypeName("surfRegionIOList");
// Constructors // Constructors
//- Construct from IOobject //- Construct from IOobject
explicit surfGroupIOList(const IOobject& io); explicit surfRegionIOList(const IOobject&);
//- Construct from IOobject //- Construct from IOobject
surfGroupIOList(const IOobject& io, const surfGroupList&); surfRegionIOList(const IOobject&, const surfRegionList&);
// Destructor // Destructor
~surfGroupIOList(); ~surfRegionIOList();
// Member Functions // Member Functions
@ -102,7 +102,7 @@ public:
// IOstream Operators // IOstream Operators
friend Ostream& operator<<(Ostream&, const surfGroupIOList&); friend Ostream& operator<<(Ostream&, const surfRegionIOList&);
}; };

View File

@ -23,17 +23,18 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef Typedef
Foam::surfGroupList Foam::surfRegionList
Description Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfGroupList_H #ifndef surfRegionList_H
#define surfGroupList_H #define surfRegionList_H
#include "surfGroup.H" #include "surfRegion.H"
#include "List.H" #include "List.H"
#include "surfRegionIdentifierList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -42,7 +43,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfGroup> surfGroupList; typedef List<surfRegion> surfRegionList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -24,14 +24,14 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "surfPatchIdentifier.H" #include "surfRegionIdentifier.H"
#include "dictionary.H" #include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfPatchIdentifier::surfPatchIdentifier() Foam::surfRegionIdentifier::surfRegionIdentifier()
: :
name_(word::null), name_(word::null),
boundaryIndex_(0), boundaryIndex_(0),
@ -39,7 +39,7 @@ Foam::surfPatchIdentifier::surfPatchIdentifier()
{} {}
Foam::surfPatchIdentifier::surfPatchIdentifier Foam::surfRegionIdentifier::surfRegionIdentifier
( (
const word& name, const word& name,
const label index, const label index,
@ -52,7 +52,7 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
{} {}
Foam::surfPatchIdentifier::surfPatchIdentifier Foam::surfRegionIdentifier::surfRegionIdentifier
( (
const word& name, const word& name,
const dictionary& dict, const dictionary& dict,
@ -66,9 +66,9 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
} }
Foam::surfPatchIdentifier::surfPatchIdentifier Foam::surfRegionIdentifier::surfRegionIdentifier
( (
const surfPatchIdentifier& p, const surfRegionIdentifier& p,
const label index const label index
) )
: :
@ -79,14 +79,14 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfPatchIdentifier::~surfPatchIdentifier() Foam::surfRegionIdentifier::~surfRegionIdentifier()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfPatchIdentifier::write(Ostream& os) const void Foam::surfRegionIdentifier::write(Ostream& os) const
{ {
if (geometricType_.size()) if (geometricType_.size())
{ {
@ -98,18 +98,18 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
// bool Foam::surfPatchIdentifier::operator!= // bool Foam::surfRegionIdentifier::operator!=
// ( // (
// const surfPatchIdentifier& p // const surfRegionIdentifier& p
// ) const // ) const
// { // {
// return !(*this == p); // return !(*this == p);
// } // }
// //
// //
// bool Foam::surfPatchIdentifier::operator== // bool Foam::surfRegionIdentifier::operator==
// ( // (
// const surfPatchIdentifier& p // const surfRegionIdentifier& p
// ) const // ) const
// { // {
// return geometricType() == p.geometricType() && name() == p.name(); // return geometricType() == p.geometricType() && name() == p.name();
@ -118,7 +118,7 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// Foam::Istream& Foam::operator>>(Istream& is, surfPatchIdentifier& p) // Foam::Istream& Foam::operator>>(Istream& is, surfRegionIdentifier& p)
// { // {
// is >> p.name_ >> p.geometricType_; // is >> p.name_ >> p.geometricType_;
// //
@ -126,12 +126,12 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
// } // }
Foam::Ostream& Foam::operator<<(Ostream& os, const surfPatchIdentifier& p) Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegionIdentifier& p)
{ {
p.write(os); p.write(os);
os.check os.check
( (
"Ostream& operator<<(Ostream&, const surfPatchIdentifier&)" "Ostream& operator<<(Ostream&, const surfRegionIdentifier&)"
); );
return os; return os;
} }

View File

@ -23,19 +23,23 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::surfPatchIdentifier Foam::surfRegionIdentifier
Description Description
Like patchIdentifier but for surfaces with "geometricType" rather An identifier for a region on a meshed surface.
than "physicalType".
Similar in concept to a faceZone on the surface, but can also have a
"geometricType" rather. Despite the similarity to a 'patch' for
volume meshes (with a "physicalType"), the region does not have any
patch information per se.
SourceFiles SourceFiles
surfPatchIdentifier.C surfRegionIdentifier.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfPatchIdentifier_H #ifndef surfRegionIdentifier_H
#define surfPatchIdentifier_H #define surfRegionIdentifier_H
#include "word.H" #include "word.H"
#include "label.H" #include "label.H"
@ -50,24 +54,24 @@ class dictionary;
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class surfPatchIdentifier; class surfRegionIdentifier;
Ostream& operator<<(Ostream&, const surfPatchIdentifier&); Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class surfPatchIdentifier Declaration Class surfRegionIdentifier Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class surfPatchIdentifier class surfRegionIdentifier
{ {
// Private data // Private data
//- Name of patch //- Name of region
word name_; word name_;
//- Index of patch in boundary //- Index of region in surface mesh
label boundaryIndex_; label boundaryIndex_;
//- Type name of patch //- Type name of region
mutable word geometricType_; mutable word geometricType_;
public: public:
@ -75,10 +79,10 @@ public:
// Constructors // Constructors
//- Construct null //- Construct null
surfPatchIdentifier(); surfRegionIdentifier();
//- Construct from components //- Construct from components
surfPatchIdentifier surfRegionIdentifier
( (
const word& name, const word& name,
const label index, const label index,
@ -87,24 +91,24 @@ public:
); );
//- Construct from dictionary //- Construct from dictionary
surfPatchIdentifier surfRegionIdentifier
( (
const word& name, const word& name,
const dictionary&, const dictionary&,
const label index const label index
); );
//- Construct from another patch, resetting the index //- Construct from another region identifier, resetting the index
surfPatchIdentifier surfRegionIdentifier
( (
const surfPatchIdentifier&, const surfRegionIdentifier&,
const label index const label index
); );
// Destructor // Destructor
virtual ~surfPatchIdentifier(); virtual ~surfRegionIdentifier();
// Member Functions // Member Functions
@ -121,42 +125,42 @@ public:
return name_; return name_;
} }
//- Return the geometric type of the patch //- Return the geometric type of the region
const word& geometricType() const const word& geometricType() const
{ {
return geometricType_; return geometricType_;
} }
//- Return the geometric type of the patch for modification //- Return the geometric type of the region for modification
word& geometricType() word& geometricType()
{ {
return geometricType_; return geometricType_;
} }
//- Return the index of this patch in the boundaryMesh //- Return the index of this region in the surface mesh
label index() const label index() const
{ {
return boundaryIndex_; return boundaryIndex_;
} }
//- Write surfPatchIdentifier as a dictionary //- Write surfRegionIdentifier as a dictionary
void write(Ostream&) const; void write(Ostream&) const;
//- Write surfPatchIdentifier as a dictionary //- Write surfRegionIdentifier as a dictionary
// void writeDict(Ostream&) const; // void writeDict(Ostream&) const;
// Member Operators // Member Operators
// bool operator!=(const surfPatchIdentifier&) const; // bool operator!=(const surfRegionIdentifier&) const;
// //
// //- compare. // //- compare.
// bool operator==(const surfPatchIdentifier&) const; // bool operator==(const surfRegionIdentifier&) const;
// Ostream Operator // Ostream Operator
friend Ostream& operator<<(Ostream&, const surfPatchIdentifier&); friend Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
// friend Istream& operator>>(Istream&, surfPatchIdentifier&); // friend Istream& operator>>(Istream&, surfRegionIdentifier&);
}; };

View File

@ -23,16 +23,16 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Typedef Typedef
Foam::surfPatchIdentifierList Foam::surfRegionIdentifierList
Description Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef surfPatchIdentifierList_H #ifndef surfRegionIdentifierList_H
#define surfPatchIdentifierList_H #define surfRegionIdentifierList_H
#include "surfPatchIdentifier.H" #include "surfRegionIdentifier.H"
#include "List.H" #include "List.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -42,7 +42,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef List<surfPatchIdentifier> surfPatchIdentifierList; typedef List<surfRegionIdentifier> surfRegionIdentifierList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -99,42 +99,42 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
<< exit(FatalError); << exit(FatalError);
} }
// # of kids is the # of patches // # of kids is the # of regions
args = cueToOrDie(is, "kids"); args = cueToOrDie(is, "kids");
label nPatches = parse<int>(args); label nRegions = parse<int>(args);
// Start of vertices for object/patch // Start of vertices for object/region
label patchVertOffset = 0; label vertexOffset = 0;
DynamicList<point> dynPoints; DynamicList<point> dynPoints;
DynamicList<Face> dynFaces; DynamicList<Face> dynFaces;
List<word> names(nPatches); List<word> names(nRegions);
List<label> sizes(nPatches, 0); List<label> sizes(nRegions, 0);
for (label patchI = 0; patchI < nPatches; ++patchI) for (label regionI = 0; regionI < nRegions; ++regionI)
{ {
names[patchI] = word("patch") + Foam::name(patchI); names[regionI] = word("region") + Foam::name(regionI);
args = cueToOrDie(is, "OBJECT", "while reading " + names[patchI]); args = cueToOrDie(is, "OBJECT", "while reading " + names[regionI]);
// number of vertices for this patch // number of vertices for this region
label nPatchPoints = 0; label nRegionPoints = 0;
vector location(pTraits<vector>::zero); vector location(pTraits<vector>::zero);
// tensor rotation(I); // tensor rotation(I);
// Read all info for current patch // Read all info for current region
while (is.good()) while (is.good())
{ {
// Read line and get first word. If end of file break since // Read line and get first word. If end of file break since
// patch should always end with 'kids' command ?not sure. // region should always end with 'kids' command ?not sure.
if (!readCmd(is, cmd, args)) if (!readCmd(is, cmd, args))
{ {
FatalErrorIn FatalErrorIn
( (
"fileFormats::AC3DsurfaceFormat::read(const fileName&)" "fileFormats::AC3DsurfaceFormat::read(const fileName&)"
) )
<< "Did not read up to \"kids 0\" while reading patch " << "Did not read up to \"kids 0\" while reading region "
<< patchI << " from file " << filename << regionI << " from file " << filename
<< exit(FatalError); << exit(FatalError);
} }
@ -144,7 +144,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
string str = parse<string>(args); string str = parse<string>(args);
string::stripInvalid<word>(str); string::stripInvalid<word>(str);
names[patchI] = str; names[regionI] = str;
} }
else if (cmd == "rot") else if (cmd == "rot")
{ {
@ -164,7 +164,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
) )
<< "rot (rotation tensor) command not implemented" << "rot (rotation tensor) command not implemented"
<< "Line:" << cmd << ' ' << args << endl << "Line:" << cmd << ' ' << args << endl
<< "while reading patch " << patchI << endl; << "while reading region " << regionI << endl;
} }
else if (cmd == "loc") else if (cmd == "loc")
{ {
@ -179,9 +179,9 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
else if (cmd == "numvert") else if (cmd == "numvert")
{ {
// numvert %d // numvert %d
nPatchPoints = parse<int>(args); nRegionPoints = parse<int>(args);
for (label vertI = 0; vertI < nPatchPoints; ++vertI) for (label vertI = 0; vertI < nRegionPoints; ++vertI)
{ {
is.getLine(line); is.getLine(line);
IStringStream lineStream(line); IStringStream lineStream(line);
@ -202,8 +202,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
{ {
static string errorMsg = static string errorMsg =
string(" while reading face ") string(" while reading face ")
+ Foam::name(faceI) + " on patch " + Foam::name(faceI) + " on region "
+ Foam::name(patchI) + Foam::name(regionI)
+ " from file " + filename; + " from file " + filename;
cueToOrDie(is, "SURF", errorMsg); cueToOrDie(is, "SURF", errorMsg);
@ -216,7 +216,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
forAll(verts, vertI) forAll(verts, vertI)
{ {
is.getLine(line); is.getLine(line);
verts[vertI] = parse<int>(line) + patchVertOffset; verts[vertI] = parse<int>(line) + vertexOffset;
} }
UList<label>& f = static_cast<UList<label>&>(verts); UList<label>& f = static_cast<UList<label>&>(verts);
@ -230,23 +230,23 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
label fp2 = (fp1 + 1) % f.size(); label fp2 = (fp1 + 1) % f.size();
dynFaces.append(triFace(f[0], f[fp1], f[fp2])); dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
sizes[patchI]++; sizes[regionI]++;
} }
} }
else else
{ {
dynFaces.append(Face(f)); dynFaces.append(Face(f));
sizes[patchI]++; sizes[regionI]++;
} }
} }
// Done the current patch. // Done the current region.
// Increment the offset vertices are stored at // Increment the offset vertices are stored at
patchVertOffset += nPatchPoints; vertexOffset += nRegionPoints;
} }
else if (cmd == "kids") else if (cmd == "kids")
{ {
// 'kids' denotes the end of the current patch. // 'kids' denotes the end of the current region.
label nKids = parse<int>(args); label nKids = parse<int>(args);
if (nKids != 0) if (nKids != 0)
@ -257,11 +257,11 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
) )
<< "Can only read objects without kids." << "Can only read objects without kids."
<< " Encountered " << nKids << " kids when" << " Encountered " << nKids << " kids when"
<< " reading patch " << patchI << " reading region " << regionI
<< exit(FatalError); << exit(FatalError);
} }
// Done reading current patch // Done reading current region
break; break;
} }
} }
@ -271,8 +271,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
this->storedPoints().transfer(dynPoints); this->storedPoints().transfer(dynPoints);
this->storedFaces().transfer(dynFaces); this->storedFaces().transfer(dynFaces);
// add patches, culling empty groups // add regions, culling empty ones
this->addPatches(sizes, names, true); this->addRegions(sizes, names, true);
this->stitchFaces(SMALL); this->stitchFaces(SMALL);
return true; return true;
} }
@ -287,16 +287,16 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
writeHeader(os, patchLst); writeHeader(os, regionLst);
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
const surfGroup& p = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
os << "OBJECT poly" << nl os << "OBJECT poly" << nl
<< "name \"" << p.name() << '"' << endl; << "name \"" << reg.name() << '"' << endl;
// Temporary PrimitivePatch to calculate compact points & faces // Temporary PrimitivePatch to calculate compact points & faces
// use 'UList' to avoid allocations! // use 'UList' to avoid allocations!
@ -317,12 +317,12 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
os << "numsurf " << patch.localFaces().size() << endl; os << "numsurf " << patch.localFaces().size() << endl;
forAll(patch.localFaces(), faceI) forAll(patch.localFaces(), localFaceI)
{ {
const Face& f = patch.localFaces()[faceI]; const Face& f = patch.localFaces()[localFaceI];
os << "SURF 0x20" << nl // polygon os << "SURF 0x20" << nl // polygon
<< "mat " << patchI << nl << "mat " << regionI << nl
<< "refs " << f.size() << nl; << "refs " << f.size() << nl;
forAll(f, fp) forAll(f, fp)
@ -344,25 +344,25 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
) )
{ {
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap); List<surfRegion> regionLst = surf.sortedRegions(faceMap);
writeHeader(os, patchLst); writeHeader(os, regionLst);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
const surfGroup& p = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
os << "OBJECT poly" << nl os << "OBJECT poly" << nl
<< "name \"" << p.name() << '"' << endl; << "name \"" << reg.name() << '"' << endl;
// Create patch with only patch faces included for ease of addressing // Create region with only region faces included for ease of addressing
boolList include(surf.size(), false); labelHashSet include(surf.size());
forAll(p, patchFaceI) forAll(reg, localFaceI)
{ {
const label faceI = faceMap[faceIndex++]; const label faceI = faceMap[faceIndex++];
include[faceI] = true; include.insert(faceI);
} }
UnsortedMeshedSurface<Face> subm = surf.subsetMesh(include); UnsortedMeshedSurface<Face> subm = surf.subsetMesh(include);
@ -379,12 +379,12 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
os << "numsurf " << subm.localFaces().size() << endl; os << "numsurf " << subm.localFaces().size() << endl;
forAll(subm.localFaces(), faceI) forAll(subm.localFaces(), localFaceI)
{ {
const Face& f = subm.localFaces()[faceI]; const Face& f = subm.localFaces()[localFaceI];
os << "SURF 0x20" << nl // polygon os << "SURF 0x20" << nl // polygon
<< "mat " << patchI << nl << "mat " << regionI << nl
<< "refs " << f.size() << nl; << "refs " << f.size() << nl;
forAll(f, fp) forAll(f, fp)

View File

@ -31,7 +31,7 @@ Description
http://www.inivis.com/ac3d/man/ac3dfileformat.html http://www.inivis.com/ac3d/man/ac3dfileformat.html
Note Note
The faces are already organized as patches. The faces are already organized as regions.
The output is always sorted by regions. The output is always sorted by regions.
SourceFiles SourceFiles

View File

@ -116,12 +116,12 @@ Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
( (
Ostream& os, Ostream& os,
const List<surfGroup>& patchLst const UList<surfRegion>& regionLst
) )
{ {
// Write with patches as separate objects under "world" object. // Write with regions as separate objects under "world" object.
// Header is taken over from sample file. // Header is taken over from sample file.
// Defines separate materials for all patches. Recycle colours. // Defines separate materials for all regions. Recycle colours.
// Define 8 standard colours as r,g,b components // Define 8 standard colours as r,g,b components
static scalar colourMap[] = static scalar colourMap[] =
@ -139,14 +139,12 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
// Write header. Define materials. // Write header. Define materials.
os << "AC3Db" << nl; os << "AC3Db" << nl;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
const word& pName = patchLst[patchI].name(); label colourI = regionI % 8;
label colourI = patchI % 8;
label colourCompI = 3 * colourI; label colourCompI = 3 * colourI;
os << "MATERIAL \"" << pName << "Mat\" rgb " os << "MATERIAL \"" << regionLst[regionI].name() << "Mat\" rgb "
<< colourMap[colourCompI] << ' ' << colourMap[colourCompI+1] << colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
<< ' ' << colourMap[colourCompI+2] << ' ' << colourMap[colourCompI+2]
<< " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10" << " amb 0.2 0.2 0.2 emis 0 0 0 spec 0.5 0.5 0.5 shi 10"
@ -155,7 +153,7 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
} }
os << "OBJECT world" << nl os << "OBJECT world" << nl
<< "kids " << patchLst.size() << endl; << "kids " << regionLst.size() << endl;
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

View File

@ -77,7 +77,7 @@ protected:
); );
//- Write header with materials //- Write header with materials
static void writeHeader(Ostream&, const List<surfGroup>&); static void writeHeader(Ostream&, const UList<surfRegion>&);
}; };

View File

@ -63,40 +63,40 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
<< exit(FatalError); << exit(FatalError);
} }
List<ftrPatch> readPatches(is); List<ftrPatch> ftrPatches(is);
// read points directly // read points directly
is >> this->storedPoints(); is >> this->storedPoints();
// read faces with keys // faces read with keys
List<Keyed<triFace> > readFaces(is); List<Keyed<triFace> > facesRead(is);
List<Face> faceLst(readFaces.size()); List<Face> faceLst(facesRead.size());
List<label> regionLst(readFaces.size()); List<label> regionIds(facesRead.size());
// disentangle faces/keys - already triangulated // disentangle faces/keys - already triangulated
forAll(readFaces, faceI) forAll(facesRead, faceI)
{ {
// unfortunately cannot transfer to save memory // unfortunately cannot transfer to save memory
faceLst[faceI] = readFaces[faceI]; faceLst[faceI] = facesRead[faceI];
regionLst[faceI] = readFaces[faceI].key(); regionIds[faceI] = facesRead[faceI].key();
} }
this->storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
this->storedRegions().transfer(regionLst); this->storedRegionIds().transfer(regionIds);
// cast ftrPatch into new form // change ftrPatch into surfRegionIdentifier
List<surfPatchIdentifier> newPatches(readPatches.size()); List<surfRegionIdentifier> newRegions(ftrPatches.size());
forAll(newPatches, patchI) forAll(newRegions, regionI)
{ {
newPatches[patchI] = surfPatchIdentifier newRegions[regionI] = surfRegionIdentifier
( (
readPatches[patchI].name(), ftrPatches[regionI].name(),
patchI regionI
); );
} }
this->storedPatches().transfer(newPatches); this->storedRegionToc().transfer(newRegions);
return true; return true;
} }

View File

@ -82,11 +82,11 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
// write directly into the lists: // write directly into the lists:
pointField& pointLst = this->storedPoints(); pointField& pointLst = this->storedPoints();
List<Face>& faceLst = this->storedFaces(); List<Face>& faceLst = this->storedFaces();
List<label>& regionLst = this->storedRegions(); List<label>& regionIds = this->storedRegionIds();
pointLst.setSize(nPoints); pointLst.setSize(nPoints);
faceLst.setSize(nElems); faceLst.setSize(nElems);
regionLst.setSize(nElems); regionIds.setSize(nElems);
// Read points // Read points
forAll(pointLst, pointI) forAll(pointLst, pointI)
@ -118,7 +118,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
// Read triangles. Convert references to edges into pointlabels // Read triangles. Convert references to edges into pointlabels
label maxPatch = 0; label maxRegion = 0;
forAll(faceLst, faceI) forAll(faceLst, faceI)
{ {
label e0Label, e1Label, e2Label; label e0Label, e1Label, e2Label;
@ -138,9 +138,9 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
if (!lineStream.bad()) if (!lineStream.bad())
{ {
regionI = num; regionI = num;
if (maxPatch < regionI) if (maxRegion < regionI)
{ {
maxPatch = regionI; maxRegion = regionI;
} }
} }
} }
@ -202,21 +202,21 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
} }
faceLst[faceI] = triFace(e0Far, common01, e1Far); faceLst[faceI] = triFace(e0Far, common01, e1Far);
regionLst[faceI] = regionI; regionIds[faceI] = regionI;
} }
List<surfPatchIdentifier> newPatches(maxPatch+1); List<surfRegionIdentifier> newRegions(maxRegion+1);
forAll(newPatches, patchI) forAll(newRegions, regionI)
{ {
newPatches[patchI] = surfPatchIdentifier newRegions[regionI] = surfRegionIdentifier
( (
"patch" + ::Foam::name(patchI), "region" + ::Foam::name(regionI),
patchI regionI
); );
} }
this->storedPatches().transfer(newPatches); this->storedRegionToc().transfer(newRegions);
return true; return true;
} }
@ -230,13 +230,12 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
// check if output triangulation would be required // check if output triangulation would be required
// It is too annoying to triangulate on-the-fly // It is too annoying to triangulate on-the-fly
// just issue a warning and get out // just issue a warning and get out
//
if (!surf.isTri()) if (!surf.isTri())
{ {
label nNonTris = 0; label nNonTris = 0;
@ -261,14 +260,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
} }
} }
// Write header, print patch names as comment // Write header, print region names as comment
os << "# GTS file" << nl os << "# GTS file" << nl
<< "# Regions:" << nl; << "# Regions:" << nl;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
os << "# " << patchI << " " os << "# " << regionI << " "
<< patchLst[patchI].name() << nl; << regionLst[regionI].name() << nl;
} }
os << "#" << endl; os << "#" << endl;
@ -301,18 +300,18 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
const labelListList& faceEs = surf.faceEdges(); const labelListList& faceEs = surf.faceEdges();
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
const labelList& fEdges = faceEs[faceIndex++]; const labelList& fEdges = faceEs[faceIndex++];
os << fEdges[0] + 1 << ' ' os << fEdges[0] + 1 << ' '
<< fEdges[1] + 1 << ' ' << fEdges[1] + 1 << ' '
<< fEdges[2] + 1 << ' ' << fEdges[2] + 1 << ' '
<< patchI << endl; << regionI << endl;
} }
} }
} }
@ -327,8 +326,8 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<label>& regionLst = surf.regions(); const List<label>& regionIds = surf.regionIds();
const List<surfPatchIdentifier>& patchInfo = surf.patches(); const List<surfRegionIdentifier>& regionToc = surf.regionToc();
// check if output triangulation would be required // check if output triangulation would be required
// It is too annoying to triangulate on-the-fly // It is too annoying to triangulate on-the-fly
@ -357,18 +356,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
} }
} }
labelList faceMap; // Write header, print region names as comment
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
// Write header, print patch names as comment
os << "# GTS file" << nl os << "# GTS file" << nl
<< "# Regions:" << nl; << "# Regions:" << nl;
forAll(patchInfo, patchI) forAll(regionToc, regionI)
{ {
os << "# " << patchI << " " os << "# " << regionI << " "
<< patchInfo[patchI].name() << nl; << regionToc[regionI].name() << nl;
} }
os << "#" << endl; os << "#" << endl;
@ -409,7 +404,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
os << fEdges[0] + 1 << ' ' os << fEdges[0] + 1 << ' '
<< fEdges[1] + 1 << ' ' << fEdges[1] + 1 << ' '
<< fEdges[2] + 1 << ' ' << fEdges[2] + 1 << ' '
<< regionLst[faceI] << endl; << regionIds[faceI] << endl;
} }
} }

View File

@ -27,7 +27,7 @@ Class
Description Description
Provide a means of reading/writing GTS format. Provide a means of reading/writing GTS format.
The output is never sorted by patch. The output is never sorted by region.
SourceFiles SourceFiles
GTSsurfaceFormat.C GTSsurfaceFormat.C

View File

@ -85,7 +85,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
// Ansa tags. Denoted by $ANSA_NAME. // Ansa tags. Denoted by $ANSA_NAME.
// These will appear just before the first use of a type. // These will appear just before the first use of a type.
// We read them and store the PSHELL types which are used to name // We read them and store the PSHELL types which are used to name
// the patches. // the regions.
label ansaId = -1; label ansaId = -1;
word ansaType, ansaName; word ansaType, ansaName;
@ -211,7 +211,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
fTri[1] = readLabel(IStringStream(line.substr(32,8))()); fTri[1] = readLabel(IStringStream(line.substr(32,8))());
fTri[2] = readLabel(IStringStream(line.substr(40,8))()); fTri[2] = readLabel(IStringStream(line.substr(40,8))());
// Convert groupID into patchID // Convert groupID into regionId
Map<label>::const_iterator fnd = lookup.find(groupId); Map<label>::const_iterator fnd = lookup.find(groupId);
if (fnd != lookup.end()) if (fnd != lookup.end())
{ {
@ -227,7 +227,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
regionI = dynSizes.size(); regionI = dynSizes.size();
lookup.insert(groupId, regionI); lookup.insert(groupId, regionI);
dynSizes.append(0); dynSizes.append(0);
// Info<< "patch" << regionI << " => group " << groupId <<endl; // Info<< "region" << regionI << " => group " << groupId <<endl;
} }
dynFaces.append(fTri); dynFaces.append(fTri);
@ -245,7 +245,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
fQuad[2] = readLabel(IStringStream(line.substr(40,8))()); fQuad[2] = readLabel(IStringStream(line.substr(40,8))());
fQuad[3] = readLabel(IStringStream(line.substr(48,8))()); fQuad[3] = readLabel(IStringStream(line.substr(48,8))());
// Convert groupID into patchID // Convert groupID into regionId
Map<label>::const_iterator fnd = lookup.find(groupId); Map<label>::const_iterator fnd = lookup.find(groupId);
if (fnd != lookup.end()) if (fnd != lookup.end())
{ {
@ -261,7 +261,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
regionI = dynSizes.size(); regionI = dynSizes.size();
lookup.insert(groupId, regionI); lookup.insert(groupId, regionI);
dynSizes.append(0); dynSizes.append(0);
// Info<< "patch" << regionI << " => group " << groupId <<endl; // Info<< "region" << regionI << " => group " << groupId <<endl;
} }
@ -322,7 +322,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
} }
else if (cmd == "PSHELL") else if (cmd == "PSHELL")
{ {
// pshell type for patch names with the Ansa extension // pshell type for region names with the Ansa extension
label groupId = readLabel(IStringStream(line.substr(8,8))()); label groupId = readLabel(IStringStream(line.substr(8,8))());
if (groupId == ansaId && ansaType == "PSHELL") if (groupId == ansaId && ansaType == "PSHELL")
@ -370,29 +370,29 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
mapPointId.clear(); mapPointId.clear();
// create default patch names, or from ANSA/Hypermesh information // create default region names, or from ANSA/Hypermesh information
List<word> names(dynSizes.size()); List<word> names(dynSizes.size());
forAllConstIter(Map<label>, lookup, iter) forAllConstIter(Map<label>, lookup, iter)
{ {
const label patchI = iter(); const label regionI = iter();
const label groupI = iter.key(); const label groupI = iter.key();
Map<word>::const_iterator fnd = nameLookup.find(groupI); Map<word>::const_iterator fnd = nameLookup.find(groupI);
if (fnd != nameLookup.end()) if (fnd != nameLookup.end())
{ {
names[patchI] = fnd(); names[regionI] = fnd();
} }
else else
{ {
names[patchI] = word("patch") + ::Foam::name(patchI); names[regionI] = word("region") + ::Foam::name(regionI);
} }
} }
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted); sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
// add patches, culling empty groups // add regions, culling empty ones
this->addPatches(dynSizes, names, true); this->addRegions(dynSizes, names, true);
return true; return true;
} }

View File

@ -29,7 +29,7 @@ Description
Nastran surface reader. Nastran surface reader.
- Uses the Ansa "$ANSA_NAME" or the Hypermesh "$HMNAME COMP" extensions - Uses the Ansa "$ANSA_NAME" or the Hypermesh "$HMNAME COMP" extensions
to obtain patch names. to obtain region names.
- Handles Nastran short and long formats, but not free format. - Handles Nastran short and long formats, but not free format.
- Properly handles the Nastran compact floating point notation: \n - Properly handles the Nastran compact floating point notation: \n
@verbatim @verbatim

View File

@ -75,10 +75,10 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
DynamicList<label> dynSizes; DynamicList<label> dynSizes;
HashTable<label> lookup; HashTable<label> lookup;
// place faces without a group in patch0 // place faces without a group in region0
label regionI = 0; label regionI = 0;
lookup.insert("patch0", regionI); lookup.insert("region0", regionI);
dynNames.append("patch0"); dynNames.append("region0");
dynSizes.append(0); dynSizes.append(0);
while (is.good()) while (is.good())
@ -204,8 +204,8 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted); sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
// add patches, culling empty groups // add regions, culling empty ones
this->addPatches(dynSizes, dynNames, true); this->addRegions(dynSizes, dynNames, true);
return true; return true;
} }
@ -218,18 +218,18 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
) )
{ {
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
writeHeader(os, surf.points(), faceLst.size(), patchLst); writeHeader(os, surf.points(), faceLst.size(), regionLst);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
os << "g " << patch.name() << endl; os << "g " << reg.name() << endl;
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
const Face& f = faceLst[faceIndex++]; const Face& f = faceLst[faceIndex++];
@ -255,19 +255,19 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap); List<surfRegion> regionLst = surf.sortedRegions(faceMap);
writeHeader(os, surf.points(), faceLst.size(), patchLst); writeHeader(os, surf.points(), faceLst.size(), regionLst);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
os << "g " << patch.name() << endl; os << "g " << reg.name() << endl;
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];

View File

@ -63,14 +63,6 @@ class OBJsurfaceFormat
{ {
// Private Member Functions // Private Member Functions
static void writeHead
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfGroup>&
);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&); OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);

View File

@ -36,7 +36,7 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
Ostream& os, Ostream& os,
const pointField& pointLst, const pointField& pointLst,
const label nFaces, const label nFaces,
const List<surfGroup>& patchLst const UList<surfRegion>& regionLst
) )
{ {
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
@ -44,13 +44,13 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
<< nl << nl
<< "# points : " << pointLst.size() << nl << "# points : " << pointLst.size() << nl
<< "# faces : " << nFaces << nl << "# faces : " << nFaces << nl
<< "# patches: " << patchLst.size() << nl; << "# region : " << regionLst.size() << nl;
// Print patch names as comment // Print region names as comment
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
os << "# " << patchI << " " << patchLst[patchI].name() os << "# " << regionI << " " << regionLst[regionI].name()
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl; << " (nFaces: " << regionLst[regionI].size() << ")" << nl;
} }
os << nl os << nl

View File

@ -63,7 +63,7 @@ protected:
Ostream&, Ostream&,
const pointField&, const pointField&,
const label nFaces, const label nFaces,
const List<surfGroup>& const UList<surfRegion>&
); );
}; };

View File

@ -146,7 +146,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
reset(pointLst.xfer(), dynFaces.xfer()); reset(pointLst.xfer(), dynFaces.xfer());
// no region information // no region information
this->onePatch(); this->oneRegion();
return true; return true;
} }
@ -161,16 +161,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap); List<surfRegion> regionLst = surf.sortedRegions(faceMap);
writeHeader(os, surf.points(), faceLst.size(), patchLst); writeHeader(os, surf.points(), faceLst.size(), regionLst);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
os << "# <patch name=\"" << patchLst[patchI].name() << "\">" << endl; os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
forAll(patchLst[patchI], patchFaceI) forAll(regionLst[regionI], localFaceI)
{ {
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];
@ -181,9 +181,9 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
} }
// add optional region information // add optional region information
os << ' ' << patchI << endl; os << ' ' << regionI << endl;
} }
os << "# </patch>" << endl; os << "# </region>" << endl;
} }
os << "# </faces>" << endl; os << "# </faces>" << endl;
} }
@ -197,16 +197,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
) )
{ {
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
writeHeader(os, surf.points(), faceLst.size(), patchLst); writeHeader(os, surf.points(), faceLst.size(), regionLst);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
os << "# <patch name=\"" << patchLst[patchI].name() << "\">" << endl; os << "# <region name=\"" << regionLst[regionI].name() << "\">" << endl;
forAll(patchLst[patchI], patchFaceI) forAll(regionLst[regionI], localFaceI)
{ {
const Face& f = faceLst[faceIndex++]; const Face& f = faceLst[faceIndex++];
@ -217,9 +217,9 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
} }
// add optional region information // add optional region information
os << ' ' << patchI << endl; os << ' ' << regionI << endl;
} }
os << "# </patch>" << endl; os << "# </region>" << endl;
} }
os << "# </faces>" << endl; os << "# </faces>" << endl;
} }

View File

@ -71,14 +71,6 @@ class OFFsurfaceFormat
{ {
// Private Member Functions // Private Member Functions
static void writeHead
(
Ostream&,
const pointField&,
const List<Face>&,
const List<surfGroup>&
);
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
OFFsurfaceFormat(const OFFsurfaceFormat&); OFFsurfaceFormat(const OFFsurfaceFormat&);

View File

@ -34,7 +34,7 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
Ostream& os, Ostream& os,
const pointField& pointLst, const pointField& pointLst,
const label nFaces, const label nFaces,
const List<surfGroup>& patchLst const UList<surfRegion>& regionLst
) )
{ {
// Write header // Write header
@ -43,13 +43,13 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
<< nl << nl
<< "# points : " << pointLst.size() << nl << "# points : " << pointLst.size() << nl
<< "# faces : " << nFaces << nl << "# faces : " << nFaces << nl
<< "# patches: " << patchLst.size() << nl; << "# regions: " << regionLst.size() << nl;
// Print patch names as comment // Print region names as comment
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
os << "# " << patchI << " " << patchLst[patchI].name() os << "# " << regionI << " " << regionLst[regionI].name()
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl; << " (nFaces: " << regionLst[regionI].size() << ")" << nl;
} }
os << nl os << nl

View File

@ -63,7 +63,7 @@ protected:
Ostream&, Ostream&,
const pointField&, const pointField&,
const label nFaces, const label nFaces,
const List<surfGroup>& const UList<surfRegion>&
); );
}; };

View File

@ -46,14 +46,14 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
) )
{ {
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
writeHeader(os, surf.points(), faceLst.size()); writeHeader(os, surf.points(), faceLst.size());
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
forAll(patchLst[patchI], patchFaceI) forAll(regionLst[regionI], localFaceI)
{ {
const Face& f = faceLst[faceIndex++]; const Face& f = faceLst[faceIndex++];
@ -62,7 +62,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
{ {
os << ' ' << f[fp]; os << ' ' << f[fp];
} }
os << ' ' << patchI << endl; os << ' ' << regionI << endl;
} }
} }
@ -82,12 +82,12 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
writeHeader(os, surf.points(), faceLst.size()); writeHeader(os, surf.points(), faceLst.size());
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap); List<surfRegion> regionLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
forAll(patchLst[patchI], patchFaceI) forAll(regionLst[regionI], localFaceI)
{ {
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];
@ -96,7 +96,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
{ {
os << ' ' << f[fp]; os << ' ' << f[fp];
} }
os << ' ' << patchI << endl; os << ' ' << regionI << endl;
} }
} }

View File

@ -40,8 +40,7 @@ inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
const label cellTableId const label cellTableId
) )
{ {
os os << cellId // includes 1 offset
<< cellId // includes 1 offset
<< " " << starcdShellShape_ // 3(shell) shape << " " << starcdShellShape_ // 3(shell) shape
<< " " << f.size() << " " << f.size()
<< " " << cellTableId << " " << cellTableId
@ -54,9 +53,7 @@ inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
{ {
if ((count % 8) == 0) if ((count % 8) == 0)
{ {
os os << nl << " " << cellId;
<< nl
<< " " << cellId;
} }
os << " " << f[fp] + 1; os << " " << f[fp] + 1;
count++; count++;
@ -160,7 +157,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
if (typeId == starcdShellType_) if (typeId == starcdShellType_)
{ {
// Convert groupID into patchID // Convert groupID into regionID
Map<label>::const_iterator fnd = lookup.find(cellTableId); Map<label>::const_iterator fnd = lookup.find(cellTableId);
if (fnd != lookup.end()) if (fnd != lookup.end())
{ {
@ -214,8 +211,8 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted); sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
// add patches, culling empty groups // add regions, culling empty ones
this->addPatches(dynSizes, dynNames, true); this->addRegions(dynSizes, dynNames, true);
return true; return true;
} }
@ -234,17 +231,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
writeHeader(os, "CELL"); writeHeader(os, "CELL");
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
const Face& f = faceLst[faceIndex++]; const Face& f = faceLst[faceIndex++];
writeShell(os, f, faceIndex, patchI + 1); writeShell(os, f, faceIndex, regionI + 1);
} }
} }
@ -254,7 +251,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
OFstream(baseName + ".inp")(), OFstream(baseName + ".inp")(),
surf.points(), surf.points(),
surf.size(), surf.size(),
patchLst regionLst
); );
} }
@ -275,17 +272,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap); List<surfRegion> regionLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];
writeShell(os, f, faceIndex, patchI + 1); writeShell(os, f, faceIndex, regionI + 1);
} }
} }
@ -295,7 +292,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
OFstream(baseName + ".inp")(), OFstream(baseName + ".inp")(),
surf.points(), surf.points(),
surf.size(), surf.size(),
patchLst regionLst
); );
} }

View File

@ -166,7 +166,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
Ostream& os, Ostream& os,
const pointField& pointLst, const pointField& pointLst,
const label nFaces, const label nFaces,
const List<surfGroup>& patchLst const UList<surfRegion>& regionLst
) )
{ {
word caseName = os.name().lessExt().name(); word caseName = os.name().lessExt().name();
@ -176,10 +176,11 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
<< "! case " << caseName << nl << "! case " << caseName << nl
<< "! ------------------------------" << nl; << "! ------------------------------" << nl;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
os << "ctable " << patchI + 1 << " shell" << nl os << "ctable " << regionI + 1 << " shell" << nl
<< "ctname " << patchI + 1 << " " << patchLst[patchI].name() << nl; << "ctname " << regionI + 1 << " "
<< regionLst[regionI].name() << nl;
} }
os << "! ------------------------------" << nl os << "! ------------------------------" << nl

View File

@ -70,7 +70,7 @@ protected:
Ostream&, Ostream&,
const pointField&, const pointField&,
const label nFaces, const label nFaces,
const List<surfGroup>& const UList<surfRegion>&
); );
}; };

View File

@ -70,7 +70,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
const pointField& pointLst, const pointField& pointLst,
const Face& f, const Face& f,
const vector& norm, const vector& norm,
const label patchI const label regionI
) )
{ {
// simple triangulation about f[0]. // simple triangulation about f[0].
@ -86,7 +86,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
p0, p0,
pointLst[f[fp1]], pointLst[f[fp1]],
pointLst[f[fp2]], pointLst[f[fp2]],
patchI regionI
); );
stlTri.write(os); stlTri.write(os);
@ -104,22 +104,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
const vectorField& normLst = surf.faceNormals(); const vectorField& normLst = surf.faceNormals();
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
os << "solid " << patch.name() << endl; os << "solid " << reg.name() << endl;
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
const label faceI = faceIndex++; const label faceI = faceIndex++;
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]); writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
} }
os << "endsolid " << patch.name() << endl; os << "endsolid " << reg.name() << endl;
} }
} }
@ -136,34 +136,34 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals(); const vectorField& normLst = surf.faceNormals();
if (surf.patches().size() == 1) if (surf.regionToc().size() == 1)
{ {
// a single region - we can skip sorting // a single region - we can skip sorting
os << "solid " << surf.patches()[0].name() << endl; os << "solid " << surf.regionToc()[0].name() << endl;
forAll(faceLst, faceI) forAll(faceLst, faceI)
{ {
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]); writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
} }
os << "endsolid " << surf.patches()[0].name() << endl; os << "endsolid " << surf.regionToc()[0].name() << endl;
} }
else else
{ {
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap); List<surfRegion> regionLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
// Print all faces belonging to this region // Print all faces belonging to this region
const surfGroup& patch = patchLst[patchI]; const surfRegion& reg = regionLst[regionI];
os << "solid " << patch.name() << endl; os << "solid " << reg.name() << endl;
forAll(patch, patchFaceI) forAll(reg, localFaceI)
{ {
const label faceI = faceMap[faceIndex++]; const label faceI = faceMap[faceIndex++];
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]); writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
} }
os << "endsolid " << patch.name() << endl; os << "endsolid " << reg.name() << endl;
} }
} }
} }
@ -180,7 +180,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const vectorField& normLst = surf.faceNormals(); const vectorField& normLst = surf.faceNormals();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
unsigned int nTris = 0; unsigned int nTris = 0;
if (surf.isTri()) if (surf.isTri())
@ -200,9 +200,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris); STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
forAll(patchLst[patchI], patchFaceI) forAll(regionLst[regionI], regionFaceI)
{ {
writeShell writeShell
( (
@ -210,7 +210,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
pointLst, pointLst,
faceLst[faceIndex], faceLst[faceIndex],
normLst[faceIndex], normLst[faceIndex],
patchI regionI
); );
++faceIndex; ++faceIndex;
@ -229,7 +229,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<label>& regionLst = surf.regions(); const List<label>& regionIds = surf.regionIds();
const vectorField& normLst = surf.faceNormals(); const vectorField& normLst = surf.faceNormals();
unsigned int nTris = 0; unsigned int nTris = 0;
@ -258,7 +258,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
pointLst, pointLst,
faceLst[faceI], faceLst[faceI],
normLst[faceI], normLst[faceI],
regionLst[faceI] regionIds[faceI]
); );
} }
} }
@ -295,10 +295,10 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
// retrieve the original region information // retrieve the original region information
List<word> names(reader.names().xfer()); List<word> names(reader.names().xfer());
List<label> sizes(reader.sizes().xfer()); List<label> sizes(reader.sizes().xfer());
List<label> regions(reader.regions().xfer()); List<label> regionIds(reader.regionIds().xfer());
// generate the (sorted) faces // generate the (sorted) faces
List<Face> faceLst(regions.size()); List<Face> faceLst(regionIds.size());
if (reader.sorted()) if (reader.sorted())
{ {
@ -314,7 +314,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
// unsorted - determine the sorted order: // unsorted - determine the sorted order:
// avoid SortableList since we discard the main list anyhow // avoid SortableList since we discard the main list anyhow
List<label> faceMap; List<label> faceMap;
sortedOrder(regions, faceMap); sortedOrder(regionIds, faceMap);
// generate sorted faces // generate sorted faces
forAll(faceMap, faceI) forAll(faceMap, faceI)
@ -323,18 +323,18 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2); faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
} }
} }
regions.clear(); regionIds.clear();
// transfer: // transfer:
this->storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
if (names.size()) if (names.size())
{ {
this->addPatches(sizes, names); this->addRegions(sizes, names);
} }
else else
{ {
this->addPatches(sizes); this->addRegions(sizes);
} }
this->stitchFaces(SMALL); this->stitchFaces(SMALL);

View File

@ -79,7 +79,7 @@ class STLsurfaceFormat
const pointField&, const pointField&,
const Face&, const Face&,
const vector&, const vector&,
const label patchI const label regionI
); );

View File

@ -417,7 +417,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
// transfer to normal lists // transfer to normal lists
points_.transfer(lexer.points()); points_.transfer(lexer.points());
regions_.transfer(lexer.facets()); regionIds_.transfer(lexer.facets());
names_.transfer(lexer.names()); names_.transfer(lexer.names());
sizes_.transfer(lexer.sizes()); sizes_.transfer(lexer.sizes());

View File

@ -142,14 +142,14 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
#endif #endif
points_.setSize(3*nTris); points_.setSize(3*nTris);
regions_.setSize(nTris); regionIds_.setSize(nTris);
Map<label> lookup; Map<label> lookup;
DynamicList<label> dynSizes; DynamicList<label> dynSizes;
label ptI = 0; label ptI = 0;
label regionI = -1; label regionI = -1;
forAll(regions_, faceI) forAll(regionIds_, faceI)
{ {
// Read an STL triangle // Read an STL triangle
STLtriangle stlTri(is); STLtriangle stlTri(is);
@ -179,7 +179,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
dynSizes.append(0); dynSizes.append(0);
} }
regions_[faceI] = regionI; regionIds_[faceI] = regionI;
dynSizes[regionI]++; dynSizes[regionI]++;
#ifdef DEBUG_STLBINARY #ifdef DEBUG_STLBINARY
@ -220,7 +220,7 @@ Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
: :
sorted_(true), sorted_(true),
points_(0), points_(0),
regions_(0), regionIds_(0),
names_(0), names_(0),
sizes_(0) sizes_(0)
{ {

View File

@ -65,7 +65,7 @@ class STLsurfaceFormatCore
pointField points_; pointField points_;
//- The regions associated with the faces //- The regions associated with the faces
List<label> regions_; List<label> regionIds_;
//- The solid names, in the order of their first appearance //- The solid names, in the order of their first appearance
List<word> names_; List<word> names_;
@ -124,7 +124,7 @@ public:
{ {
sorted_ = true; sorted_ = true;
points_.clear(); points_.clear();
regions_.clear(); regionIds_.clear();
names_.clear(); names_.clear();
sizes_.clear(); sizes_.clear();
} }
@ -135,10 +135,10 @@ public:
return points_; return points_;
} }
//- Return full access to the regions //- Return full access to the regionIds
List<label>& regions() List<label>& regionIds()
{ {
return regions_; return regionIds_;
} }
//- The list of solid names in the order of their first appearance //- The list of solid names in the order of their first appearance

View File

@ -37,7 +37,6 @@ Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
//- Check if file extension corresponds to 'native' surface format
bool bool
Foam::fileFormats::surfaceFormatsCore::isNative(const word& ext) Foam::fileFormats::surfaceFormatsCore::isNative(const word& ext)
{ {
@ -75,11 +74,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
// closest to and lower than current time // closest to and lower than current time
instantList ts = d.times(); instantList ts = d.times();
label i; label instanceI;
for (i=ts.size()-1; i>=0; i--) for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
{ {
if (ts[i].value() <= d.timeOutputValue()) if (ts[instanceI].value() <= d.timeOutputValue())
{ {
break; break;
} }
@ -88,13 +87,13 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
// Noting that the current directory has already been searched // Noting that the current directory has already been searched
// for mesh data, start searching from the previously stored time directory // for mesh data, start searching from the previously stored time directory
if (i>=0) if (instanceI >= 0)
{ {
for (label j=i; j>=0; j--) for (label i = instanceI; i >= 0; --i)
{ {
if (file(d.path()/ts[j].name()/subdirName/foamName)) if (file(d.path()/ts[i].name()/subdirName/foamName))
{ {
return ts[j].name(); return ts[i].name();
} }
} }
} }
@ -116,11 +115,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
// closest to and lower than current time // closest to and lower than current time
instantList ts = d.times(); instantList ts = d.times();
label i; label instanceI;
for (i=ts.size()-1; i>=0; i--) for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
{ {
if (ts[i].value() <= d.timeOutputValue()) if (ts[instanceI].value() <= d.timeOutputValue())
{ {
break; break;
} }
@ -129,11 +128,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
// Noting that the current directory has already been searched // Noting that the current directory has already been searched
// for mesh data, start searching from the previously stored time directory // for mesh data, start searching from the previously stored time directory
if (i>=0) if (instanceI >= 0)
{ {
for (label j=i; j>=0; j--) for (label i = instanceI; i >= 0; --i)
{ {
fileName testName(d.path()/ts[j].name()/subdirName/foamName); fileName testName(d.path()/ts[i].name()/subdirName/foamName);
if (file(testName)) if (file(testName))
{ {
@ -166,14 +165,14 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
} }
// Returns patch info. // Returns region info.
// Sets faceMap to the indexing according to patch numbers. // Sets faceMap to the indexing according to region numbers.
// Patch numbers start at 0. // Region numbers start at 0.
Foam::surfGroupList Foam::surfRegionList
Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions Foam::fileFormats::surfaceFormatsCore::sortedRegionsById
( (
const UList<label>& regionLst, const UList<label>& regionIds,
const Map<word>& patchNames, const Map<word>& regionNames,
labelList& faceMap labelList& faceMap
) )
{ {
@ -185,11 +184,11 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
// Assuming that we have relatively fewer regions compared to the // Assuming that we have relatively fewer regions compared to the
// number of items, just do it ourselves // number of items, just do it ourselves
// step 1: get region sizes and store (regionId => patchI) // step 1: get region sizes and store (regionId => regionI)
Map<label> lookup; Map<label> lookup;
forAll(regionLst, faceI) forAll(regionIds, faceI)
{ {
const label regId = regionLst[faceI]; const label regId = regionIds[faceI];
Map<label>::iterator fnd = lookup.find(regId); Map<label>::iterator fnd = lookup.find(regId);
if (fnd != lookup.end()) if (fnd != lookup.end())
@ -202,52 +201,53 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
} }
} }
// step 2: assign start/size (and name) to the newPatches // step 2: assign start/size (and name) to the newRegions
// re-use the lookup to map (regionId => patchI) // re-use the lookup to map (regionId => regionI)
surfGroupList patchLst(lookup.size()); surfRegionList regionLst(lookup.size());
label start = 0; label start = 0;
label patchI = 0; label regionI = 0;
forAllIter(Map<label>, lookup, iter) forAllIter(Map<label>, lookup, iter)
{ {
label regId = iter.key(); label regId = iter.key();
word name; word name;
Map<word>::const_iterator fnd = patchNames.find(regId); Map<word>::const_iterator fnd = regionNames.find(regId);
if (fnd != patchNames.end()) if (fnd != regionNames.end())
{ {
name = fnd(); name = fnd();
} }
else else
{ {
name = word("patch") + ::Foam::name(patchI); name = word("region") + ::Foam::name(regionI);
} }
patchLst[patchI] = surfGroup regionLst[regionI] = surfRegion
( (
name, name,
0, // initialize with zero size 0, // initialize with zero size
start, start,
patchI regionI
); );
// increment the start for the next patch // increment the start for the next region
// and save the (regionId => patchI) mapping // and save the (regionId => regionI) mapping
start += iter(); start += iter();
iter() = patchI++; iter() = regionI++;
} }
// step 3: build the re-ordering // step 3: build the re-ordering
faceMap.setSize(regionLst.size()); faceMap.setSize(regionIds.size());
forAll(regionLst, faceI) forAll(regionIds, faceI)
{ {
label patchI = lookup[regionLst[faceI]]; label regionI = lookup[regionIds[faceI]];
faceMap[faceI] = patchLst[patchI].start() + patchLst[patchI].size()++; faceMap[faceI] =
regionLst[regionI].start() + regionLst[regionI].size()++;
} }
// with reordered faces registered in faceMap // with reordered faces registered in faceMap
return patchLst; return regionLst;
} }

View File

@ -36,11 +36,11 @@ SourceFiles
#ifndef surfaceFormatsCore_H #ifndef surfaceFormatsCore_H
#define surfaceFormatsCore_H #define surfaceFormatsCore_H
#include "surfPatchIdentifierList.H"
#include "surfGroupList.H"
#include "labelList.H"
#include "Map.H" #include "Map.H"
#include "HashSet.H" #include "HashSet.H"
#include "labelList.H"
#include "surfRegionList.H"
#include "surfRegionIdentifierList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -69,6 +69,7 @@ public:
static word meshSubDir; static word meshSubDir;
//- The file extension corresponding to 'native' surface format //- The file extension corresponding to 'native' surface format
// Normally "ofs" (mnemonic: OF = OpenFOAM, S = Surface)
static word nativeExt; static word nativeExt;
// Static Member Functions // Static Member Functions
@ -91,12 +92,12 @@ public:
//- Name of UnsortedMeshedSurface directory to use. //- Name of UnsortedMeshedSurface directory to use.
static fileName findMeshName(const Time&); static fileName findMeshName(const Time&);
//- Determine the sort order from the region list. //- Determine the sort order from the region ids.
// Returns patch list and sets faceMap to indices within faceLst // Returns region list and sets faceMap to indices within faceLst
static surfGroupList sortedPatchRegions static surfRegionList sortedRegionsById
( (
const UList<label>& regionLst, const UList<label>& regionIds,
const Map<word>& patchNames, const Map<word>& regionNames,
labelList& faceMap labelList& faceMap
); );

View File

@ -37,7 +37,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
Ostream& os, Ostream& os,
const pointField& pointLst, const pointField& pointLst,
const Face& f, const Face& f,
const label patchI const label regionI
) )
{ {
// simple triangulation about f[0]. // simple triangulation about f[0].
@ -54,7 +54,7 @@ inline void Foam::fileFormats::TRIsurfaceFormat<Face>::writeShell
<< p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' ' << p1.x() << ' ' << p1.y() << ' ' << p1.z() << ' '
<< p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' ' << p2.x() << ' ' << p2.y() << ' ' << p2.z() << ' '
// region as colour // region as colour
<< "0x" << hex << patchI << dec << endl; << "0x" << hex << regionI << dec << endl;
} }
} }
@ -89,10 +89,10 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
// retrieve the original region information // retrieve the original region information
List<label> sizes(reader.sizes().xfer()); List<label> sizes(reader.sizes().xfer());
List<label> regions(reader.regions().xfer()); List<label> regionIds(reader.regionIds().xfer());
// generate the (sorted) faces // generate the (sorted) faces
List<Face> faceLst(regions.size()); List<Face> faceLst(regionIds.size());
if (reader.sorted()) if (reader.sorted())
{ {
@ -108,7 +108,7 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
// unsorted - determine the sorted order: // unsorted - determine the sorted order:
// avoid SortableList since we discard the main list anyhow // avoid SortableList since we discard the main list anyhow
List<label> faceMap; List<label> faceMap;
sortedOrder(regions, faceMap); sortedOrder(regionIds, faceMap);
// generate sorted faces // generate sorted faces
forAll(faceMap, faceI) forAll(faceMap, faceI)
@ -117,12 +117,12 @@ bool Foam::fileFormats::TRIsurfaceFormat<Face>::read
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2); faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
} }
} }
regions.clear(); regionIds.clear();
// transfer: // transfer:
this->storedFaces().transfer(faceLst); this->storedFaces().transfer(faceLst);
this->addPatches(sizes); this->addRegions(sizes);
this->stitchFaces(SMALL); this->stitchFaces(SMALL);
return true; return true;
} }
@ -137,15 +137,15 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
{ {
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const List<Face>& faceLst = surf.faces(); const List<Face>& faceLst = surf.faces();
const List<surfGroup>& patchLst = surf.patches(); const List<surfRegion>& regionLst = surf.regions();
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
forAll(patchLst[patchI], patchFaceI) forAll(regionLst[regionI], localFaceI)
{ {
const Face& f = faceLst[faceIndex++]; const Face& f = faceLst[faceIndex++];
writeShell(os, pointLst, f, patchI); writeShell(os, pointLst, f, regionI);
} }
} }
} }
@ -163,7 +163,7 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
bool doSort = false; bool doSort = false;
// a single region needs no sorting // a single region needs no sorting
if (surf.patches().size() == 1) if (surf.regionToc().size() == 1)
{ {
doSort = false; doSort = false;
} }
@ -171,25 +171,25 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
if (doSort) if (doSort)
{ {
labelList faceMap; labelList faceMap;
List<surfGroup> patchLst = surf.sortedRegions(faceMap); List<surfRegion> regionLst = surf.sortedRegions(faceMap);
label faceIndex = 0; label faceIndex = 0;
forAll(patchLst, patchI) forAll(regionLst, regionI)
{ {
forAll(patchLst[patchI], patchFaceI) forAll(regionLst[regionI], localFaceI)
{ {
const Face& f = faceLst[faceMap[faceIndex++]]; const Face& f = faceLst[faceMap[faceIndex++]];
writeShell(os, pointLst, f, patchI); writeShell(os, pointLst, f, regionI);
} }
} }
} }
else else
{ {
const List<label>& regionLst = surf.regions(); const List<label>& regionIds = surf.regionIds();
forAll(faceLst, faceI) forAll(faceLst, faceI)
{ {
writeShell(os, pointLst, faceLst[faceI], regionLst[faceI]); writeShell(os, pointLst, faceLst[faceI], regionIds[faceI]);
} }
} }
} }

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