mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -111,6 +111,33 @@ int main(int argc, char *argv[])
|
||||
Info<< "setD : " << 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;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,6 @@ using namespace Foam;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool changed;
|
||||
Info<< "PackedList max_bits() = " << PackedList<0>::max_bits() << nl;
|
||||
|
||||
Info<< "\ntest allocation with value\n";
|
||||
@ -46,11 +45,50 @@ int main(int argc, char *argv[])
|
||||
list1.print(Info);
|
||||
|
||||
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);
|
||||
|
||||
Info<< "\ntest resize with value (without reallocation)\n";
|
||||
list1.resize(6, 3);
|
||||
list1.resize(8, list1.max_value());
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest set() function\n";
|
||||
@ -96,7 +134,7 @@ int main(int argc, char *argv[])
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest setCapacity() operation\n";
|
||||
list1.setCapacity(30);
|
||||
list1.setCapacity(100);
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest operator[] assignment\n";
|
||||
@ -108,7 +146,15 @@ int main(int argc, char *argv[])
|
||||
list1.print(Info);
|
||||
|
||||
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);
|
||||
|
||||
// add in some misc values
|
||||
@ -118,37 +164,54 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\ntest iterator\n";
|
||||
PackedList<3>::iterator iter = list1.begin();
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
Info<< "begin():";
|
||||
iter.print(Info) << "\n";
|
||||
|
||||
Info<< "\ntest iterator operator=\n";
|
||||
changed = (iter = 5);
|
||||
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
Info<< "changed:" << changed << "\n";
|
||||
changed = (iter = 5);
|
||||
Info<< "changed:" << changed << "\n";
|
||||
iter() = 5;
|
||||
iter.print(Info);
|
||||
list1.print(Info);
|
||||
|
||||
iter = list1[31];
|
||||
Info<< "iterator:" << iter() << "\n";
|
||||
iter.print(Info);
|
||||
|
||||
|
||||
Info<< "\ntest get() method\n";
|
||||
Info<< "get(10):" << list1.get(10)
|
||||
<< " and list[10]:" << unsigned(list1[10]) << "\n";
|
||||
Info<< "get(10):" << list1.get(10) << " and list[10]:" << list1[10] << "\n";
|
||||
list1.print(Info);
|
||||
|
||||
Info<< "\ntest iterator indexing\n";
|
||||
Info<< "end() ";
|
||||
list1.end().print(Info) << "\n";
|
||||
Info<< "cend() ";
|
||||
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";
|
||||
list1.print(Info);
|
||||
for
|
||||
(
|
||||
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";
|
||||
@ -161,8 +224,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "\ntest pattern that fills all bits\n";
|
||||
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);
|
||||
|
||||
Info<< "\n\nDone.\n";
|
||||
|
||||
3
applications/test/PackedList2/Make/files
Normal file
3
applications/test/PackedList2/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
PackedListTest2.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/PackedListTest2
|
||||
0
applications/test/PackedList2/Make/options
Normal file
0
applications/test/PackedList2/Make/options
Normal file
348
applications/test/PackedList2/PackedListTest2.C
Normal file
348
applications/test/PackedList2/PackedListTest2.C
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -31,6 +31,7 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "fileName.H"
|
||||
#include "SubList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
@ -50,19 +51,55 @@ int main()
|
||||
|
||||
fileName pathName(wrdList);
|
||||
|
||||
Info<< "pathName = " << pathName << endl;
|
||||
Info<< "pathName.name() = " << pathName.name() << endl;
|
||||
Info<< "pathName.path() = " << pathName.path() << endl;
|
||||
Info<< "pathName.ext() = " << pathName.ext() << endl;
|
||||
Info<< "pathName = " << pathName << nl
|
||||
<< "pathName.name() = " << pathName.name() << nl
|
||||
<< "pathName.path() = " << pathName.path() << nl
|
||||
<< "pathName.ext() = " << pathName.ext() << endl;
|
||||
|
||||
Info<< "pathName.components() = " << pathName.components() << endl;
|
||||
Info<< "pathName.component(2) = " << pathName.component(2) << endl;
|
||||
Info<< "pathName.components() = " << pathName.components() << nl
|
||||
<< "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
|
||||
Info<< "\n\nfindEtcFile tests:" << nl
|
||||
<< " controlDict => " << findEtcFile("controlDict") << nl
|
||||
<< " badName => " << findEtcFile("badName") << endl;
|
||||
|
||||
Info<< "This should emit a fatal error:" << endl;
|
||||
Info<< " badName(die) => " << findEtcFile("badName", true) << nl
|
||||
<< endl;
|
||||
|
||||
@ -78,10 +78,10 @@ int main(int argc, char *argv[])
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
const word dictName("blockMeshDict");
|
||||
|
||||
word regionName;
|
||||
fileName polyMeshDir;
|
||||
word dictName("blockMeshDict");
|
||||
fileName dictPath(runTime.constant());
|
||||
|
||||
if (args.options().found("region"))
|
||||
{
|
||||
@ -98,55 +98,58 @@ int main(int argc, char *argv[])
|
||||
polyMeshDir = polyMesh::meshSubDir;
|
||||
}
|
||||
|
||||
fileName dictLocal = polyMeshDir;
|
||||
autoPtr<IOobject> meshDictIoPtr;
|
||||
|
||||
if (args.options().found("dict"))
|
||||
{
|
||||
wordList elems(fileName(args.options()["dict"]).components());
|
||||
dictName = elems[elems.size()-1];
|
||||
dictPath = elems[0];
|
||||
dictLocal = "";
|
||||
fileName dictPath(args.options()["dict"]);
|
||||
|
||||
if (elems.size() == 1)
|
||||
{
|
||||
dictPath = ".";
|
||||
}
|
||||
else if (elems.size() > 2)
|
||||
{
|
||||
dictLocal = fileName(SubList<word>(elems, elems.size()-2, 1));
|
||||
}
|
||||
meshDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
( dictPath.isDir() ? dictPath/dictName : dictPath ),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
meshDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
dictName,
|
||||
runTime.constant(),
|
||||
polyMeshDir,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
bool writeTopo = args.options().found("blockTopology");
|
||||
|
||||
IOobject meshDictIo
|
||||
(
|
||||
dictName,
|
||||
dictPath,
|
||||
dictLocal,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if (!meshDictIo.headerOk())
|
||||
if (!meshDictIoPtr->headerOk())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open mesh description file\n "
|
||||
<< meshDictIo.objectPath()
|
||||
<< meshDictIoPtr->objectPath()
|
||||
<< nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< nl << "Creating block mesh from\n "
|
||||
<< meshDictIo.objectPath() << nl << endl;
|
||||
|
||||
IOdictionary meshDict(meshDictIo);
|
||||
<< meshDictIoPtr->objectPath() << nl << endl;
|
||||
|
||||
IOdictionary meshDict(meshDictIoPtr());
|
||||
blockMesh blocks(meshDict);
|
||||
|
||||
if (writeTopo)
|
||||
|
||||
if (args.options().found("blockTopology"))
|
||||
{
|
||||
// Write mesh as edges.
|
||||
{
|
||||
|
||||
@ -276,7 +276,7 @@ int main(int argc, char *argv[])
|
||||
// Read point fields and subset
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
pointMesh pMesh(mesh);
|
||||
const pointMesh& pMesh = pointMesh::New(mesh);
|
||||
|
||||
wordList pointScalarNames(objects.names(pointScalarField::typeName));
|
||||
PtrList<pointScalarField> pointScalarFlds(pointScalarNames.size());
|
||||
|
||||
@ -161,6 +161,10 @@ surfaces
|
||||
isoField rho;
|
||||
isoValue 0.5;
|
||||
interpolate true;
|
||||
|
||||
//zone ABC; // Optional: zone only
|
||||
//exposedPatchName fixedWalls; // Optional: zone only
|
||||
|
||||
// regularise false; // Optional: do not simplify
|
||||
}
|
||||
constantIso
|
||||
@ -171,7 +175,7 @@ surfaces
|
||||
isoField rho;
|
||||
isoValue 0.5;
|
||||
interpolate false;
|
||||
// regularise false; // Optional: do not simplify
|
||||
regularise false; // do not simplify
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@ -78,56 +78,61 @@ int main(int argc, char *argv[])
|
||||
Time runTime(args.rootPath(), args.caseName());
|
||||
const stringList& params = args.additionalArgs();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
const word dictName("coordinateSystems");
|
||||
|
||||
autoPtr<coordinateSystem> fromCsys;
|
||||
autoPtr<coordinateSystem> toCsys;
|
||||
|
||||
if (args.options().found("from") || args.options().found("to"))
|
||||
{
|
||||
IOobject csDictIo
|
||||
(
|
||||
dictName,
|
||||
dictPath,
|
||||
dictLocal,
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
autoPtr<IOobject> csDictIoPtr;
|
||||
|
||||
if (!csDictIo.headerOk())
|
||||
if (args.options().found("dict"))
|
||||
{
|
||||
fileName dictPath(args.options()["dict"]);
|
||||
|
||||
csDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
( dictPath.isDir() ? dictPath/dictName : dictPath ),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
csDictIoPtr.set
|
||||
(
|
||||
new IOobject
|
||||
(
|
||||
dictName,
|
||||
runTime.constant(),
|
||||
runTime,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!csDictIoPtr->headerOk())
|
||||
{
|
||||
FatalErrorIn(args.executable())
|
||||
<< "Cannot open coordinateSystems file\n "
|
||||
<< csDictIo.objectPath() << nl
|
||||
<< csDictIoPtr->objectPath() << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
coordinateSystems csLst(csDictIo);
|
||||
coordinateSystems csLst(csDictIoPtr());
|
||||
|
||||
if (args.options().found("from"))
|
||||
{
|
||||
word csName(args.options()["from"]);
|
||||
const word csName(args.options()["from"]);
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
@ -143,7 +148,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (args.options().found("to"))
|
||||
{
|
||||
word csName(args.options()["to"]);
|
||||
const word csName(args.options()["to"]);
|
||||
|
||||
label csId = csLst.find(csName);
|
||||
if (csId < 0)
|
||||
|
||||
@ -56,6 +56,7 @@ Note
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "triSurface.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
#include "MeshedSurfaces.H"
|
||||
#include "UnsortedMeshedSurfaces.H"
|
||||
@ -115,7 +116,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -154,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -230,7 +231,7 @@ int main(int argc, char *argv[])
|
||||
if (args.options().found("orient"))
|
||||
{
|
||||
Info<< "Checking surface orientation" << endl;
|
||||
surf.checkOrientation(true);
|
||||
PatchTools::checkOrientation(surf, true);
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ primitives/random/Random.C
|
||||
containers/HashTables/HashTable/HashTableName.C
|
||||
containers/HashTables/StaticHashTable/StaticHashTableName.C
|
||||
containers/Lists/SortableList/ParSortableListName.C
|
||||
containers/Lists/PackedList/PackedListName.C
|
||||
containers/Lists/PackedList/PackedListCore.C
|
||||
containers/Lists/ListOps/ListOps.C
|
||||
containers/LinkedLists/linkTypes/SLListBase/SLListBase.C
|
||||
containers/LinkedLists/linkTypes/DLListBase/DLListBase.C
|
||||
|
||||
@ -51,6 +51,13 @@ Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& ht)
|
||||
|
||||
// * * * * * * * * * * * * * * * 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>
|
||||
bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
|
||||
{
|
||||
|
||||
@ -133,9 +133,11 @@ public:
|
||||
return HashTable<nil, Key, Hash>::insert(key, nil());
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
// Independent of table size or order.
|
||||
bool operator==(const HashSet<Key, Hash>&) const;
|
||||
|
||||
@ -28,20 +28,20 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<int nBits>
|
||||
template<unsigned nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
|
||||
:
|
||||
List<PackedStorage>(packedLength(size), 0u),
|
||||
StorageList(packedLength(size), 0u),
|
||||
size_(size)
|
||||
{
|
||||
operator=(val);
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
template<unsigned nBits>
|
||||
Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||
:
|
||||
List<PackedStorage>(packedLength(lst.size()), 0u),
|
||||
StorageList(packedLength(lst.size()), 0u),
|
||||
size_(lst.size())
|
||||
{
|
||||
forAll(lst, i)
|
||||
@ -53,7 +53,116 @@ Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
|
||||
|
||||
// * * * * * * * * * * * * * * * 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
|
||||
{
|
||||
labelList elems(size());
|
||||
@ -66,11 +175,12 @@ Foam::labelList Foam::PackedList<nBits>::values() const
|
||||
}
|
||||
|
||||
|
||||
template<int nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::iterator::print(Ostream& os) const
|
||||
template<unsigned nBits>
|
||||
Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
|
||||
{
|
||||
os << "iterator<" << nBits << "> [" << position() << "]"
|
||||
<< " elem:" << elem_ << " offset:" << offset_
|
||||
os << "iterator<" << label(nBits) << "> ["
|
||||
<< (index_ * packing() + offset_) << "]"
|
||||
<< " index:" << index_ << " offset:" << offset_
|
||||
<< " value:" << unsigned(*this)
|
||||
<< 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
|
||||
{
|
||||
os << "PackedList<" << nBits << ">"
|
||||
os << "PackedList<" << label(nBits) << ">"
|
||||
<< " max_value:" << max_value()
|
||||
<< " packing:" << packing() << nl
|
||||
<< "values: " << size() << "/" << capacity() << "( ";
|
||||
@ -90,27 +200,36 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
||||
os << get(i) << ' ';
|
||||
}
|
||||
|
||||
label packLen = packedLength(size_);
|
||||
|
||||
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
|
||||
unsigned int addressed = 0;
|
||||
|
||||
for (unsigned packI = 0; count && packI < packing(); packI++, count--)
|
||||
// the final storage may not be full, modify mask accordingly
|
||||
if (i+1 == packLen)
|
||||
{
|
||||
addressed <<= nBits;
|
||||
addressed |= max_value();
|
||||
unsigned endOff = size_ % packing();
|
||||
|
||||
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)
|
||||
{
|
||||
@ -123,7 +242,7 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
||||
}
|
||||
else
|
||||
{
|
||||
os << '_';
|
||||
os << '.';
|
||||
}
|
||||
}
|
||||
cout << ' ';
|
||||
@ -136,15 +255,15 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<int nBits>
|
||||
template<unsigned nBits>
|
||||
void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
|
||||
{
|
||||
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)
|
||||
{
|
||||
setCapacity(lst.size());
|
||||
@ -156,10 +275,9 @@ void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||
|
||||
//template<int nBits>
|
||||
//template<unsigned nBits>
|
||||
//Foam::Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>& lst)
|
||||
//{
|
||||
// os << lst();
|
||||
|
||||
@ -28,19 +28,46 @@ Class
|
||||
Description
|
||||
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()
|
||||
and setSize() behave like their DynamicList counterparts and the methods
|
||||
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
|
||||
Foam::DynamicList
|
||||
|
||||
ToDo
|
||||
Add checks for bad template parameters (ie, nBits=0, nBits too large).
|
||||
The missing const_iterator might eventually still be needed.
|
||||
Checks for bad template parameters (ie, nBits=0, nBits too large)?
|
||||
|
||||
SourceFiles
|
||||
PackedListI.H
|
||||
@ -59,9 +86,9 @@ namespace Foam
|
||||
{
|
||||
|
||||
// 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>&);
|
||||
|
||||
|
||||
@ -75,12 +102,13 @@ TemplateName(PackedList);
|
||||
Class PackedList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <int nBits>
|
||||
template<unsigned nBits=1>
|
||||
class PackedList
|
||||
:
|
||||
private List<unsigned int>
|
||||
{
|
||||
typedef unsigned int PackedStorage;
|
||||
typedef unsigned int StorageType;
|
||||
typedef List<StorageType> StorageList;
|
||||
|
||||
// Private data
|
||||
|
||||
@ -110,10 +138,12 @@ public:
|
||||
//- The number of entries per packed storage element
|
||||
inline static unsigned int packing();
|
||||
|
||||
// Forward declaration of iterator
|
||||
class iterator;
|
||||
friend class iterator;
|
||||
//- Masking for all bits below the offset
|
||||
inline static unsigned int maskLower(unsigned offset);
|
||||
|
||||
// Forward declaration of iteratorBase
|
||||
|
||||
class iteratorBase;
|
||||
|
||||
// Constructors
|
||||
|
||||
@ -152,16 +182,27 @@ public:
|
||||
inline bool empty() const;
|
||||
|
||||
//- Get value at index I.
|
||||
// Does not auto-vivifies entries.
|
||||
// Does not auto-vivify entries.
|
||||
inline unsigned int get(const label) const;
|
||||
|
||||
//- 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);
|
||||
|
||||
//- Return the underlying packed storage
|
||||
inline List<unsigned int>& storage();
|
||||
|
||||
//- Return the underlying packed storage
|
||||
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
|
||||
labelList values() const;
|
||||
|
||||
@ -185,7 +226,7 @@ public:
|
||||
//- Reserve allocation space for at least this size.
|
||||
// Never shrinks the allocated size.
|
||||
// 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.
|
||||
// Does not adjust the underlying storage
|
||||
@ -204,22 +245,25 @@ public:
|
||||
//- Transfer contents to the Xfer container
|
||||
inline Xfer<PackedList<nBits> > xfer();
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
//- Append a value at the end of the list
|
||||
inline void append(const unsigned int val);
|
||||
|
||||
//- Remove and return the last element
|
||||
inline unsigned int remove();
|
||||
|
||||
//- Get value at index I
|
||||
// Auto-vivifies any new values to zero.
|
||||
// Does not auto-vivify entries.
|
||||
inline unsigned int operator[](const label) const;
|
||||
|
||||
//- Set value at index I.
|
||||
// Returns proxy to perform the actual operation.
|
||||
// Auto-vivifies any new values to zero.
|
||||
inline iterator operator[](const label);
|
||||
// Returns iterator to perform the actual operation.
|
||||
// Does not auto-vivify entries.
|
||||
inline iteratorBase operator[](const label);
|
||||
|
||||
//- Assignment of all entries to the given value.
|
||||
// Does set on all elements.
|
||||
//- Assignment of all entries to the given value. Takes linear time.
|
||||
inline void operator=(const unsigned int val);
|
||||
|
||||
//- Assignment operator. Takes linear time.
|
||||
@ -230,83 +274,211 @@ public:
|
||||
|
||||
// Ostream operator
|
||||
|
||||
// // Write PackedList to Ostream.
|
||||
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
|
||||
// // Write PackedList to Ostream.
|
||||
// friend Ostream& operator<< <nBits> (Ostream&, const PackedList<nBits>&);
|
||||
|
||||
// Iterators and helpers
|
||||
|
||||
//- The iterator base for PackedList
|
||||
// Note: data and functions are protected, to allow reuse by iterator
|
||||
// and prevent most external usage.
|
||||
class iteratorBase
|
||||
{
|
||||
friend class PackedList;
|
||||
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Pointer to original list
|
||||
// This also lets us use the default bitwise copy/assignment
|
||||
PackedList* list_;
|
||||
|
||||
//- Element index within storage
|
||||
unsigned index_;
|
||||
|
||||
//- Offset within storage element
|
||||
unsigned offset_;
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Get value as unsigned
|
||||
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&);
|
||||
|
||||
|
||||
//- The iterator-like class used for PackedList
|
||||
class iterator
|
||||
{
|
||||
friend class PackedList;
|
||||
// Constructors
|
||||
|
||||
// Private Data
|
||||
//- Construct null
|
||||
inline iteratorBase();
|
||||
|
||||
//- Reference to original list
|
||||
PackedList& list_;
|
||||
//- Copy construct
|
||||
inline iteratorBase(const iteratorBase&);
|
||||
|
||||
//- Element index within storage
|
||||
unsigned elem_;
|
||||
//- Construct from base list and position index
|
||||
inline iteratorBase(const PackedList*, const label);
|
||||
|
||||
//- Offset within storage element
|
||||
unsigned offset_;
|
||||
public:
|
||||
|
||||
//- Return the raw storage element
|
||||
inline PackedStorage& chunk() const;
|
||||
// Member Functions
|
||||
|
||||
//- Return the position in the PackedList
|
||||
inline label position() const;
|
||||
//- Return true if the element is within addressable range
|
||||
inline bool valid() const;
|
||||
|
||||
public:
|
||||
//- Move iterator to end() if it would otherwise be out-of-range
|
||||
// Returns true if the element was already ok
|
||||
inline bool validate();
|
||||
|
||||
// Constructors
|
||||
// Member Operators
|
||||
|
||||
//- Construct from base list and position index
|
||||
inline iterator(const PackedList&, const label i);
|
||||
//- Compare positions
|
||||
inline bool operator==(const iteratorBase&) const;
|
||||
inline bool operator!=(const iteratorBase&) const;
|
||||
|
||||
// Members
|
||||
//- Assign value, not position.
|
||||
// This allows packed[0] = packed[3] for assigning values
|
||||
inline unsigned int operator=(const iteratorBase&);
|
||||
|
||||
//- Assign value, returns true if the value changed
|
||||
inline bool operator=(const unsigned int val);
|
||||
//- Assign value
|
||||
inline unsigned int operator=(const unsigned int val);
|
||||
|
||||
//- Conversion operator
|
||||
inline operator unsigned int () const;
|
||||
//- Conversion operator
|
||||
inline operator unsigned int () const;
|
||||
|
||||
//- Conversion operator
|
||||
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 iterator& operator++();
|
||||
inline iterator operator++(int);
|
||||
|
||||
//- Print value and information
|
||||
Ostream& print(Ostream&) const;
|
||||
|
||||
};
|
||||
//- Print value and information
|
||||
Ostream& print(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
//- iterator set to the begining of the PackedList
|
||||
inline iterator begin();
|
||||
//- The iterator class used for PackedList
|
||||
class iterator
|
||||
:
|
||||
public iteratorBase
|
||||
{
|
||||
|
||||
//- iterator set to beyond the end of the HashTable
|
||||
inline iterator end();
|
||||
//- Should never violate const-ness!
|
||||
void operator=(const const_iterator&);
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
inline iterator();
|
||||
|
||||
//- Construct from iterator base, eg iter(packedlist[i])
|
||||
inline iterator(const iteratorBase&);
|
||||
|
||||
//- Construct from base list and position index
|
||||
inline iterator(const PackedList*, const label);
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Assign from iteratorBase, eg iter = packedlist[i]
|
||||
inline iterator& operator=(const iteratorBase&);
|
||||
|
||||
//- Return value
|
||||
inline unsigned int operator*() const;
|
||||
|
||||
//- Return value
|
||||
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++(int);
|
||||
|
||||
inline iterator& operator--();
|
||||
inline iterator operator--(int);
|
||||
|
||||
};
|
||||
|
||||
//- iterator set to the beginning of the PackedList
|
||||
inline iterator begin();
|
||||
|
||||
//- iterator set to beyond the end of the HashTable
|
||||
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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
# include "PackedListI.H"
|
||||
#include "PackedListI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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 * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IOobject::~IOobject()
|
||||
|
||||
@ -193,6 +193,16 @@ public:
|
||||
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
|
||||
Foam::autoPtr<IOobject> clone() const
|
||||
{
|
||||
|
||||
@ -60,8 +60,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class patchZones;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class cyclicPolyPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -26,21 +26,14 @@ Class
|
||||
Foam::polyPatch
|
||||
|
||||
Description
|
||||
A patch is a list of labels, which address the faces in the global face
|
||||
list. Based on the global faces, the patch can calculate its own edge.
|
||||
A patch is a list of labels that address the faces in the global face list.
|
||||
|
||||
The patch can calculate its own edges based on the global faces.
|
||||
Patch also contains all addressing between the faces.
|
||||
|
||||
SourceFiles
|
||||
polyPatch.C
|
||||
calcPolyPatchAddressing.C
|
||||
calcPolyPatchFaceCells.C
|
||||
calcPolyPatchIntBdryEdges.C
|
||||
calcPolyPatchMeshEdges.C
|
||||
calcPolyPatchMeshData.C
|
||||
calcPolyPatchPointAddressing.C
|
||||
clearPolyPatch.C
|
||||
newPolyPatch.C
|
||||
polyPatchTools.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -59,10 +52,9 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
class polyBoundaryMesh;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class polyBoundaryMesh;
|
||||
class polyPatch;
|
||||
|
||||
Ostream& operator<<(Ostream&, const polyPatch&);
|
||||
|
||||
@ -223,7 +223,7 @@ public:
|
||||
|
||||
// PackedList versions
|
||||
|
||||
template <int nBits, class CombineOp>
|
||||
template <unsigned nBits, class CombineOp>
|
||||
static void syncFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -231,14 +231,14 @@ public:
|
||||
const CombineOp& cop
|
||||
);
|
||||
|
||||
template <int nBits>
|
||||
template <unsigned nBits>
|
||||
static void swapFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
PackedList<nBits>& faceValues
|
||||
);
|
||||
|
||||
template <int nBits, class CombineOp>
|
||||
template <unsigned nBits, class CombineOp>
|
||||
static void syncPointList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -247,7 +247,7 @@ public:
|
||||
const unsigned int nullValue
|
||||
);
|
||||
|
||||
template <int nBits, class CombineOp>
|
||||
template <unsigned nBits, class CombineOp>
|
||||
static void syncEdgeList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
|
||||
@ -1570,7 +1570,7 @@ void Foam::syncTools::swapFaceList
|
||||
}
|
||||
|
||||
|
||||
template <int nBits, class CombineOp>
|
||||
template <unsigned nBits, class CombineOp>
|
||||
void Foam::syncTools::syncFaceList
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -1582,7 +1582,7 @@ void Foam::syncTools::syncFaceList
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"syncTools<int nBits, class CombineOp>::syncFaceList"
|
||||
"syncTools<unsigned nBits, class CombineOp>::syncFaceList"
|
||||
"(const polyMesh&, PackedList<nBits>&, const CombineOp&)"
|
||||
) << "Number of values " << faceValues.size()
|
||||
<< " 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
|
||||
(
|
||||
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
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -1715,7 +1715,7 @@ void Foam::syncTools::syncPointList
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"syncTools<int nBits, class CombineOp>::syncPointList"
|
||||
"syncTools<unsigned nBits, class CombineOp>::syncPointList"
|
||||
"(const polyMesh&, PackedList<nBits>&, const CombineOp&"
|
||||
", const unsigned int&)"
|
||||
) << "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
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
@ -1883,7 +1883,7 @@ void Foam::syncTools::syncEdgeList
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"syncTools<int nBits, class CombineOp>::syncEdgeList"
|
||||
"syncTools<unsigned nBits, class CombineOp>::syncEdgeList"
|
||||
"(const polyMesh&, PackedList<nBits>&, const CombineOp&"
|
||||
", const unsigned int&)"
|
||||
) << "Number of values " << edgeValues.size()
|
||||
|
||||
37
src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.C
Normal file
37
src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.C
Normal 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"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
187
src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.H
Normal file
187
src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchTools.H
Normal 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
|
||||
|
||||
// ************************************************************************* //
|
||||
180
src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsCheck.C
Normal file
180
src/OpenFOAM/meshes/primitiveMesh/PatchTools/PatchToolsCheck.C
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -22,35 +22,42 @@ License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
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
|
||||
// faces (from face-edge-face walk) with currentZone.
|
||||
// Finds area, starting at faceI, delimited by borderEdge.
|
||||
// Marks all visited faces (from face-edge-face walk) with currentZone.
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
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 currentZone,
|
||||
labelList& faceZone
|
||||
) const
|
||||
labelList& faceZone
|
||||
)
|
||||
{
|
||||
const labelListList& faceEdges = p.faceEdges();
|
||||
const labelListList& edgeFaces = p.edgeFaces();
|
||||
|
||||
// List of faces whose faceZone has been set.
|
||||
labelList changedFaces(1, faceI);
|
||||
|
||||
const labelListList& faceEs = this->faceEdges();
|
||||
const labelListList& eFaces = this->edgeFaces();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Pick up neighbours of changedFaces
|
||||
@ -60,7 +67,7 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
{
|
||||
label faceI = changedFaces[i];
|
||||
|
||||
const labelList& fEdges = faceEs[faceI];
|
||||
const labelList& fEdges = faceEdges[faceI];
|
||||
|
||||
forAll(fEdges, fEdgeI)
|
||||
{
|
||||
@ -68,7 +75,7 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
|
||||
if (!borderEdge[edgeI])
|
||||
{
|
||||
const labelList& eFaceLst = eFaces[edgeI];
|
||||
const labelList& eFaceLst = edgeFaces[edgeI];
|
||||
|
||||
forAll(eFaceLst, j)
|
||||
{
|
||||
@ -83,8 +90,8 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"PrimitivePatchExtra<Face, FaceList, PointField>::markZone"
|
||||
"(const boolList&, const label, const label, labelList&) const"
|
||||
"PatchTools::markZone"
|
||||
"(const boolList&, const label, const label, labelList&)"
|
||||
)
|
||||
<< "Zones " << faceZone[nbrFaceI]
|
||||
<< " at face " << nbrFaceI
|
||||
@ -112,60 +119,38 @@ void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
|
||||
// Fills faceZone accordingly
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
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
|
||||
) 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
|
||||
<< "nEdges :" << numEdges
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
faceZone.setSize(numFaces);
|
||||
faceZone.setSize(p.size());
|
||||
faceZone = -1;
|
||||
|
||||
label zoneI = 0;
|
||||
label startFaceI = 0;
|
||||
|
||||
while (true)
|
||||
for (label startFaceI = 0; startFaceI < faceZone.size();)
|
||||
{
|
||||
// Find first non-visited face
|
||||
for (; startFaceI < numFaces; startFaceI++)
|
||||
// Find next non-visited face
|
||||
for (; startFaceI < faceZone.size(); ++startFaceI)
|
||||
{
|
||||
if (faceZone[startFaceI] == -1)
|
||||
{
|
||||
faceZone[startFaceI] = zoneI;
|
||||
markZone(borderEdge, startFaceI, zoneI, faceZone);
|
||||
markZone(p, borderEdge, startFaceI, zoneI, faceZone);
|
||||
zoneI++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (startFaceI >= numFaces)
|
||||
{
|
||||
// Finished
|
||||
break;
|
||||
}
|
||||
|
||||
zoneI++;
|
||||
}
|
||||
|
||||
return zoneI;
|
||||
@ -177,46 +162,48 @@ markZones
|
||||
// Fills faceZone accordingly
|
||||
template
|
||||
<
|
||||
class BoolListType,
|
||||
class Face,
|
||||
template<class> class FaceList,
|
||||
class PointField,
|
||||
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& faceMap
|
||||
) const
|
||||
)
|
||||
{
|
||||
const List<Face>& locFaces = this->localFaces();
|
||||
const label numPoints = this->nPoints();
|
||||
|
||||
label faceI = 0;
|
||||
label faceI = 0;
|
||||
label pointI = 0;
|
||||
|
||||
faceMap.setSize(locFaces.size());
|
||||
pointMap.setSize(numPoints);
|
||||
const List<Face>& localFaces = p.localFaces();
|
||||
|
||||
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
|
||||
faceMap[faceI++] = oldFaceI;
|
||||
|
||||
// Renumber labels for face
|
||||
const Face& f = locFaces[oldFaceI];
|
||||
const Face& f = localFaces[oldFaceI];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
const label ptLabel = f[fp];
|
||||
if (!pointHad[ptLabel])
|
||||
{
|
||||
pointHad[ptLabel] = true;
|
||||
pointHad[ptLabel] = true;
|
||||
pointMap[pointI++] = ptLabel;
|
||||
}
|
||||
}
|
||||
@ -229,6 +216,4 @@ subsetMap
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -26,11 +26,6 @@ License
|
||||
|
||||
#include "Map.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
@ -41,7 +36,9 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatch
|
||||
(
|
||||
const FaceList<Face>& faces,
|
||||
const Field<PointType>& points
|
||||
@ -76,7 +73,9 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatch
|
||||
(
|
||||
FaceList<Face>& faces,
|
||||
Field<PointType>& points,
|
||||
@ -112,7 +111,9 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::PrimitivePatch
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
PrimitivePatch
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
|
||||
)
|
||||
@ -148,7 +149,8 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
|
||||
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::~PrimitivePatch()
|
||||
{
|
||||
clearOut();
|
||||
}
|
||||
@ -164,7 +166,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::movePoints
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
movePoints
|
||||
(
|
||||
const Field<PointType>&
|
||||
)
|
||||
@ -188,8 +193,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const edgeList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::edges() const
|
||||
|
||||
const Foam::edgeList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
edges() const
|
||||
{
|
||||
if (!edgesPtr_)
|
||||
{
|
||||
@ -207,8 +214,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
label PrimitivePatch<Face, FaceList, PointField, PointType>::nInternalEdges()
|
||||
const
|
||||
|
||||
Foam::label
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
nInternalEdges() const
|
||||
{
|
||||
if (!edgesPtr_)
|
||||
{
|
||||
@ -226,8 +235,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::boundaryPoints() const
|
||||
|
||||
const Foam::labelList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
boundaryPoints() const
|
||||
{
|
||||
if (!boundaryPointsPtr_)
|
||||
{
|
||||
@ -245,8 +256,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::faceFaces() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
faceFaces() const
|
||||
{
|
||||
if (!faceFacesPtr_)
|
||||
{
|
||||
@ -264,8 +277,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::edgeFaces() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
edgeFaces() const
|
||||
{
|
||||
if (!edgeFacesPtr_)
|
||||
{
|
||||
@ -283,8 +298,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::faceEdges() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
faceEdges() const
|
||||
{
|
||||
if (!faceEdgesPtr_)
|
||||
{
|
||||
@ -302,8 +319,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::pointEdges() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
pointEdges() const
|
||||
{
|
||||
if (!pointEdgesPtr_)
|
||||
{
|
||||
@ -321,8 +340,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::pointFaces() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
pointFaces() const
|
||||
{
|
||||
if (!pointFacesPtr_)
|
||||
{
|
||||
@ -340,8 +361,10 @@ template
|
||||
class PointField,
|
||||
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_)
|
||||
{
|
||||
@ -359,8 +382,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::meshPoints() const
|
||||
|
||||
const Foam::labelList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
meshPoints() const
|
||||
{
|
||||
if (!meshPointsPtr_)
|
||||
{
|
||||
@ -378,8 +403,10 @@ template
|
||||
class PointField,
|
||||
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_)
|
||||
{
|
||||
@ -397,8 +424,10 @@ template
|
||||
class PointField,
|
||||
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_)
|
||||
{
|
||||
@ -416,8 +445,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::localPointOrder() const
|
||||
|
||||
const Foam::labelList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
localPointOrder() const
|
||||
{
|
||||
if (!localPointOrderPtr_)
|
||||
{
|
||||
@ -435,16 +466,19 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
label PrimitivePatch<Face, FaceList, PointField, PointType>::whichPoint
|
||||
|
||||
Foam::label
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
whichPoint
|
||||
(
|
||||
const label gp
|
||||
) 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
|
||||
{
|
||||
@ -461,8 +495,10 @@ template
|
||||
class PointField,
|
||||
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_)
|
||||
{
|
||||
@ -480,8 +516,10 @@ template
|
||||
class PointField,
|
||||
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_)
|
||||
{
|
||||
@ -501,7 +539,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::operator=
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
operator=
|
||||
(
|
||||
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
|
||||
)
|
||||
@ -511,11 +552,6 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::operator=
|
||||
FaceList<Face>::operator=(pp);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "PrimitivePatchAddressing.C"
|
||||
|
||||
@ -28,10 +28,10 @@ Class
|
||||
Description
|
||||
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
|
||||
etc.) and on the form of list for faces and points so that it can
|
||||
refer to existing lists using UList and const pointField& or hold the
|
||||
storage using List and pointField.
|
||||
The class is templated on the face type (e.g. triangle, polygon etc.)
|
||||
and on the list type of faces and points so that it can refer to
|
||||
existing lists using UList and const pointField& or hold the storage
|
||||
using List and pointField.
|
||||
|
||||
SourceFiles
|
||||
PrimitivePatchAddressing.C
|
||||
@ -211,9 +211,12 @@ private:
|
||||
//- Calculate unit point normals
|
||||
void calcPointNormals() const;
|
||||
|
||||
//- Calculate edge owner
|
||||
void calcEdgeOwner() const;
|
||||
|
||||
|
||||
//- 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.
|
||||
void visitPointRegion
|
||||
(
|
||||
const label pointI,
|
||||
@ -265,175 +268,175 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Return reference to global points
|
||||
const Field<PointType>& points() const
|
||||
//- Return reference to global points
|
||||
const Field<PointType>& points() const
|
||||
{
|
||||
return points_;
|
||||
}
|
||||
|
||||
|
||||
// Access functions for demand driven data
|
||||
|
||||
// Topological data; no mesh required.
|
||||
|
||||
//- Return number of points supporting patch faces
|
||||
label nPoints() const
|
||||
{
|
||||
return points_;
|
||||
return meshPoints().size();
|
||||
}
|
||||
|
||||
//- Return number of edges in patch
|
||||
label nEdges() const
|
||||
{
|
||||
return edges().size();
|
||||
}
|
||||
|
||||
// Access functions for demand driven data
|
||||
//- Return list of edges, address into LOCAL point list
|
||||
const edgeList& edges() const;
|
||||
|
||||
// Topological data; no mesh required.
|
||||
//- Number of internal edges
|
||||
label nInternalEdges() const;
|
||||
|
||||
//- Return number of points supporting patch faces
|
||||
label nPoints() const
|
||||
{
|
||||
return meshPoints().size();
|
||||
}
|
||||
//- Is internal edge?
|
||||
bool isInternalEdge(const label edgeI) const
|
||||
{
|
||||
return edgeI < nInternalEdges();
|
||||
}
|
||||
|
||||
//- Return number of edges in patch
|
||||
label nEdges() const
|
||||
{
|
||||
return edges().size();
|
||||
}
|
||||
//- Return list of boundary points,
|
||||
// address into LOCAL point list
|
||||
const labelList& boundaryPoints() const;
|
||||
|
||||
//- Return list of edges, address into LOCAL point list
|
||||
const edgeList& edges() const;
|
||||
//- Return face-face addressing
|
||||
const labelListList& faceFaces() const;
|
||||
|
||||
//- Number of internal edges
|
||||
label nInternalEdges() const;
|
||||
//- Return edge-face addressing
|
||||
const labelListList& edgeFaces() const;
|
||||
|
||||
//- Is internal edge?
|
||||
bool isInternalEdge(const label edgeI) const
|
||||
{
|
||||
return edgeI < nInternalEdges();
|
||||
}
|
||||
//- Return face-edge addressing
|
||||
const labelListList& faceEdges() const;
|
||||
|
||||
//- Return list of boundary points,
|
||||
// address into LOCAL point list
|
||||
const labelList& boundaryPoints() const;
|
||||
//- Return point-edge addressing
|
||||
const labelListList& pointEdges() const;
|
||||
|
||||
//- Return face-face addressing
|
||||
const labelListList& faceFaces() const;
|
||||
//- Return point-face addressing
|
||||
const labelListList& pointFaces() const;
|
||||
|
||||
//- Return edge-face addressing
|
||||
const labelListList& edgeFaces() const;
|
||||
|
||||
//- Return face-edge addressing
|
||||
const labelListList& faceEdges() const;
|
||||
|
||||
//- Return point-edge addressing
|
||||
const labelListList& pointEdges() const;
|
||||
|
||||
//- Return point-face addressing
|
||||
const labelListList& pointFaces() const;
|
||||
|
||||
//- Return patch faces addressing into local point list
|
||||
const List<Face>& localFaces() const;
|
||||
//- Return patch faces addressing into local point list
|
||||
const List<Face>& localFaces() const;
|
||||
|
||||
|
||||
// Addressing into mesh
|
||||
// Addressing into mesh
|
||||
|
||||
//- Return labelList of mesh points in patch
|
||||
const labelList& meshPoints() const;
|
||||
//- Return labelList of mesh points in patch
|
||||
const labelList& meshPoints() const;
|
||||
|
||||
//- Mesh point map. Given the global point index find its
|
||||
// location in the patch
|
||||
const Map<label>& meshPointMap() const;
|
||||
//- Mesh point map. Given the global point index find its
|
||||
// location in the patch
|
||||
const Map<label>& meshPointMap() const;
|
||||
|
||||
//- Return pointField of points in patch
|
||||
const Field<PointType>& localPoints() const;
|
||||
//- Return pointField of points in patch
|
||||
const Field<PointType>& localPoints() const;
|
||||
|
||||
//- Return orders the local points for most efficient search
|
||||
const labelList& localPointOrder() const;
|
||||
//- Return orders the local points for most efficient search
|
||||
const labelList& localPointOrder() const;
|
||||
|
||||
//- Given a global point index, return the local point
|
||||
//index. If the point is not found, return -1
|
||||
label whichPoint(const label gp) const;
|
||||
//- Given a global point index, return the local point index.
|
||||
// If the point is not found, return -1
|
||||
label whichPoint(const label gp) const;
|
||||
|
||||
//- Given an edge in local point labels, return its
|
||||
// index in the edge list. If the edge is not found, return -1
|
||||
label whichEdge(const edge& e) const;
|
||||
//- Given an edge in local point labels, return its
|
||||
// index in the edge list. If the edge is not found, return -1
|
||||
label whichEdge(const edge&) const;
|
||||
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// cell addressing
|
||||
labelList meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& cellEdges,
|
||||
const labelList& faceCells
|
||||
) const;
|
||||
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// basic edge addressing.
|
||||
labelList meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& pointEdges
|
||||
) const;
|
||||
|
||||
//- Return face normals for patch
|
||||
const Field<PointType>& faceNormals() const;
|
||||
|
||||
//- Return point normals for patch
|
||||
const Field<PointType>& pointNormals() const;
|
||||
|
||||
|
||||
// Other patch operations
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectPoints
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm alg = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectFaceCentres
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm alg = intersection::FULL_RAY,
|
||||
const intersection::direction dir = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Return list of closed loops of boundary vertices.
|
||||
// Edge loops are given as ordered lists of vertices
|
||||
// in local addressing
|
||||
const labelListList& edgeLoops() const;
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Calculate surface type formed by patch.
|
||||
// - all edges have two neighbours (manifold)
|
||||
// - some edges have more than two neighbours (illegal)
|
||||
// - other (open)
|
||||
surfaceTopo surfaceType() const;
|
||||
|
||||
//- Check surface formed by patch for manifoldness (see above).
|
||||
// Insert vertices of incorrect
|
||||
// edges set. Return true if any incorrect edge found.
|
||||
bool checkTopology
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// cell addressing
|
||||
labelList meshEdges
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
const edgeList& allEdges,
|
||||
const labelListList& cellEdges,
|
||||
const labelList& faceCells
|
||||
) const;
|
||||
|
||||
//- Checks primitivePatch for faces sharing point but not edge.
|
||||
// This denotes a surface that is pinched at a single point
|
||||
// (test for pinched at single edge is already in PrimitivePatch)
|
||||
// Returns true if this situation found and puts conflicting
|
||||
// (mesh)point in set. Based on all the checking routines in
|
||||
// primitiveMesh.
|
||||
bool checkPointManifold
|
||||
//- Return labels of patch edges in the global edge list using
|
||||
// basic edge addressing.
|
||||
labelList meshEdges
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
const edgeList& allEdges,
|
||||
const labelListList& pointEdges
|
||||
) const;
|
||||
|
||||
//- Return face normals for patch
|
||||
const Field<PointType>& faceNormals() const;
|
||||
|
||||
// Edit
|
||||
//- Return point normals for patch
|
||||
const Field<PointType>& pointNormals() const;
|
||||
|
||||
//- Correct patch after moving points
|
||||
virtual void movePoints(const Field<PointType>&);
|
||||
|
||||
// Other patch operations
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectPoints
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Project vertices of patch onto another patch
|
||||
template <class ToPatch>
|
||||
List<objectHit> projectFaceCentres
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
const Field<PointType>& projectionDirection,
|
||||
const intersection::algorithm = intersection::FULL_RAY,
|
||||
const intersection::direction = intersection::VECTOR
|
||||
) const;
|
||||
|
||||
//- Return list of closed loops of boundary vertices.
|
||||
// Edge loops are given as ordered lists of vertices
|
||||
// in local addressing
|
||||
const labelListList& edgeLoops() const;
|
||||
|
||||
|
||||
// Check
|
||||
|
||||
//- Calculate surface type formed by patch.
|
||||
// - all edges have two neighbours (manifold)
|
||||
// - some edges have more than two neighbours (illegal)
|
||||
// - other (open)
|
||||
surfaceTopo surfaceType() const;
|
||||
|
||||
//- Check surface formed by patch for manifoldness (see above).
|
||||
// Return true if any incorrect edges are found.
|
||||
// Insert vertices of incorrect edges into set.
|
||||
bool checkTopology
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
) const;
|
||||
|
||||
//- Checks primitivePatch for faces sharing point but not edge.
|
||||
// This denotes a surface that is pinched at a single point
|
||||
// (test for pinched at single edge is already in PrimitivePatch)
|
||||
// Returns true if this situation found and puts conflicting
|
||||
// (mesh)point in set. Based on all the checking routines in
|
||||
// primitiveMesh.
|
||||
bool checkPointManifold
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = NULL
|
||||
) const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Correct patch after moving points
|
||||
virtual void movePoints(const Field<PointType>&);
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
@ -39,11 +39,6 @@ Description
|
||||
#include "DynamicList.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
@ -53,8 +48,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
|
||||
const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcAddressing() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -311,8 +308,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcAddressing()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,10 +29,6 @@ Description
|
||||
#include "PrimitivePatch.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -43,8 +39,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcBdryPoints()
|
||||
const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcBdryPoints() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -91,8 +89,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcBdryPoints()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -31,10 +31,6 @@ Description
|
||||
#include "Map.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -45,7 +41,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::visitPointRegion
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
visitPointRegion
|
||||
(
|
||||
const label pointI,
|
||||
const labelList& pFaces,
|
||||
@ -121,8 +120,10 @@ template
|
||||
class PointField,
|
||||
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)
|
||||
{
|
||||
@ -173,7 +174,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
bool PrimitivePatch<Face, FaceList, PointField, PointType>::checkTopology
|
||||
|
||||
bool
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
checkTopology
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -241,8 +245,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
|
||||
bool
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::checkPointManifold
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
checkPointManifold
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
@ -331,8 +337,4 @@ PrimitivePatch<Face, FaceList, PointField, PointType>::checkPointManifold
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,10 +29,6 @@ Description
|
||||
#include "PrimitivePatch.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,7 +39,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearGeom()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearGeom()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -65,7 +64,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearTopology()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearTopology()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -91,10 +93,8 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::clearTopology()
|
||||
}
|
||||
|
||||
deleteDemandDrivenData(boundaryPointsPtr_);
|
||||
|
||||
deleteDemandDrivenData(pointEdgesPtr_);
|
||||
deleteDemandDrivenData(pointFacesPtr_);
|
||||
|
||||
deleteDemandDrivenData(edgeLoopsPtr_);
|
||||
}
|
||||
|
||||
@ -106,7 +106,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearPatchMeshAddr()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearPatchMeshAddr()
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -129,7 +132,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::clearOut()
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
clearOut()
|
||||
{
|
||||
clearGeom();
|
||||
clearTopology();
|
||||
@ -137,8 +143,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::clearOut()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,10 +30,7 @@ Description
|
||||
|
||||
#include "PrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -44,8 +41,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops()
|
||||
const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcEdgeLoops() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -95,7 +94,7 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcEdgeLoops()
|
||||
// Current loop number.
|
||||
label loopI = 0;
|
||||
|
||||
for (;;)
|
||||
while (true)
|
||||
{
|
||||
// Find edge not yet given a loop number.
|
||||
label currentEdgeI = -1;
|
||||
@ -175,8 +174,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
const labelListList&
|
||||
PrimitivePatch<Face, FaceList, PointField, PointType>::edgeLoops() const
|
||||
|
||||
const Foam::labelListList&
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
edgeLoops() const
|
||||
{
|
||||
if (!edgeLoopsPtr_)
|
||||
{
|
||||
@ -186,8 +187,5 @@ PrimitivePatch<Face, FaceList, PointField, PointType>::edgeLoops() const
|
||||
return *edgeLoopsPtr_;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,11 +30,6 @@ Description
|
||||
#include "SLList.H"
|
||||
#include "boolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
@ -44,8 +39,10 @@ template
|
||||
class PointField,
|
||||
class PointType
|
||||
>
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcLocalPointOrder() const
|
||||
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcLocalPointOrder() const
|
||||
{
|
||||
// Note: Cannot use bandCompressing as point-point addressing does
|
||||
// not exist and is not considered generally useful.
|
||||
@ -140,9 +137,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,10 +27,7 @@ License
|
||||
#include "PrimitivePatch.H"
|
||||
#include "Map.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -42,7 +39,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcMeshData() const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcMeshData() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -128,8 +127,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcMeshPointMap()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcMeshPointMap() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -179,8 +179,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcLocalPoints()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcLocalPoints() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -231,8 +232,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointNormals()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcPointNormals() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -298,8 +300,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcFaceNormals()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcFaceNormals() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -341,8 +344,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcFaceNormals()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -28,10 +28,6 @@ Description
|
||||
|
||||
#include "PrimitivePatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -43,7 +39,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
|
||||
Foam::labelList
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& cellEdges,
|
||||
@ -119,7 +117,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
labelList PrimitivePatch<Face, FaceList, PointField, PointType>::meshEdges
|
||||
Foam::labelList
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
meshEdges
|
||||
(
|
||||
const edgeList& allEdges,
|
||||
const labelListList& pointEdges
|
||||
@ -175,7 +175,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
label PrimitivePatch<Face, FaceList, PointField, PointType>::whichEdge
|
||||
Foam::label
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
whichEdge
|
||||
(
|
||||
const edge& e
|
||||
) const
|
||||
@ -201,8 +203,4 @@ label PrimitivePatch<Face, FaceList, PointField, PointType>::whichEdge
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,10 +30,6 @@ Description
|
||||
#include "PrimitivePatch.H"
|
||||
#include "SLList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -45,8 +41,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointEdges()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcPointEdges() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -116,8 +113,9 @@ template
|
||||
class PointType
|
||||
>
|
||||
|
||||
void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointFaces()
|
||||
const
|
||||
void
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
calcPointFaces() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
@ -183,8 +181,4 @@ void PrimitivePatch<Face, FaceList, PointField, PointType>::calcPointFaces()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -33,11 +33,6 @@ Description
|
||||
#include "objectHit.H"
|
||||
#include "bandCompression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template
|
||||
@ -49,7 +44,8 @@ template
|
||||
>
|
||||
|
||||
template <class ToPatch>
|
||||
List<objectHit> PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
Foam::List<Foam::objectHit>
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
projectPoints
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
@ -59,7 +55,6 @@ projectPoints
|
||||
) const
|
||||
{
|
||||
// The current patch is slave, i.e. it is being projected onto the target
|
||||
//
|
||||
|
||||
if (projectionDirection.size() != nPoints())
|
||||
{
|
||||
@ -297,7 +292,8 @@ template
|
||||
>
|
||||
|
||||
template <class ToPatch>
|
||||
List<objectHit> PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
Foam::List<Foam::objectHit>
|
||||
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
|
||||
projectFaceCentres
|
||||
(
|
||||
const ToPatch& targetPatch,
|
||||
@ -307,7 +303,6 @@ projectFaceCentres
|
||||
) const
|
||||
{
|
||||
// The current patch is slave, i.e. it is being projected onto the target
|
||||
//
|
||||
|
||||
if (projectionDirection.size() != this->size())
|
||||
{
|
||||
@ -532,8 +527,4 @@ projectFaceCentres
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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"
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -40,7 +40,7 @@ Description
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef PackedList<1> PackedBoolList;
|
||||
typedef PackedList<> PackedBoolList;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "fileName.H"
|
||||
#include "wordList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "debug.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
@ -48,6 +49,30 @@ Foam::fileName::fileName(const wordList& lst)
|
||||
|
||||
// * * * * * * * * * * * * * * * 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 /)
|
||||
//
|
||||
// behaviour compared to /usr/bin/basename:
|
||||
@ -93,13 +118,13 @@ Foam::fileName Foam::fileName::path() const
|
||||
{
|
||||
return ".";
|
||||
}
|
||||
else if (i == 0)
|
||||
else if (i)
|
||||
{
|
||||
return "/";
|
||||
return substr(0, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
return substr(0, i);
|
||||
return "/";
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,28 +170,22 @@ Foam::word Foam::fileName::ext() const
|
||||
// ----- ------
|
||||
// "foo" 1("foo")
|
||||
// "/foo" 1("foo")
|
||||
// "foo/bar" 2("foo", "foo")
|
||||
// "/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
|
||||
{
|
||||
wordList wrdList(20);
|
||||
DynamicList<word> wrdList(20);
|
||||
|
||||
size_type start=0, end=0;
|
||||
label nWords=0;
|
||||
|
||||
while ((end = find(delimiter, start)) != npos)
|
||||
{
|
||||
// avoid empty element (caused by doubled slashes)
|
||||
if (start < end)
|
||||
{
|
||||
wrdList[nWords++] = substr(start, end-start);
|
||||
|
||||
if (nWords == wrdList.size())
|
||||
{
|
||||
wrdList.setSize(2*wrdList.size());
|
||||
}
|
||||
wrdList.append(substr(start, end-start));
|
||||
}
|
||||
start = end + 1;
|
||||
}
|
||||
@ -174,12 +193,11 @@ Foam::wordList Foam::fileName::components(const char delimiter) const
|
||||
// avoid empty trailing element
|
||||
if (start < size())
|
||||
{
|
||||
wrdList[nWords++] = substr(start, npos);
|
||||
wrdList.append(substr(start, npos));
|
||||
}
|
||||
|
||||
wrdList.setSize(nWords);
|
||||
|
||||
return wrdList;
|
||||
// transfer to wordList
|
||||
return wordList(wrdList.xfer());
|
||||
}
|
||||
|
||||
|
||||
@ -194,12 +212,94 @@ 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 * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fileName::operator=(const fileName& str)
|
||||
|
||||
@ -129,6 +129,20 @@ public:
|
||||
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
|
||||
|
||||
//- Return file name (part beyond last /)
|
||||
@ -146,14 +160,16 @@ public:
|
||||
//- Return path components as wordList
|
||||
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;
|
||||
|
||||
|
||||
// Interogation
|
||||
|
||||
//- Return file type
|
||||
Type type() const;
|
||||
//- Return path as instance, local, name components for IOobject
|
||||
bool IOobjectComponents
|
||||
(
|
||||
fileName& instance,
|
||||
fileName& local,
|
||||
word& name
|
||||
) const;
|
||||
|
||||
|
||||
// Member operators
|
||||
|
||||
@ -206,7 +206,8 @@ void Foam::isoSurface::calcCutTypes
|
||||
if (debug)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "isoSurface : merged from " << nTris
|
||||
<< " down to " << tris.size() << " triangles." << endl;
|
||||
}
|
||||
|
||||
|
||||
// Use face centres to determine 'flat hole' situation (see RMT paper).
|
||||
|
||||
// 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)
|
||||
{
|
||||
Pout<< "isoSurface : merged from " << nTris
|
||||
<< " down to " << tris.size() << " triangles." << endl;
|
||||
}
|
||||
labelListList pointFaces;
|
||||
invertManyToMany(newPoints.size(), tris, pointFaces);
|
||||
|
||||
// Filter out duplicates.
|
||||
DynamicList<label> newToOldTri(tris.size());
|
||||
|
||||
pointField centres(tris.size());
|
||||
forAll(tris, triI)
|
||||
{
|
||||
centres[triI] = tris[triI].centre(newPoints);
|
||||
}
|
||||
const labelledTri& tri = tris[triI];
|
||||
|
||||
pointField mergedCentres;
|
||||
labelList oldToMerged;
|
||||
bool hasMerged = mergePoints
|
||||
(
|
||||
centres,
|
||||
mergeDistance_,
|
||||
false,
|
||||
oldToMerged,
|
||||
mergedCentres
|
||||
);
|
||||
const labelList& pFaces = pointFaces[tri[0]];
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "isoSurface : detected "
|
||||
<< centres.size()-mergedCentres.size()
|
||||
<< " duplicate triangles." << endl;
|
||||
}
|
||||
|
||||
if (hasMerged)
|
||||
{
|
||||
// Filter out duplicates.
|
||||
label newTriI = 0;
|
||||
DynamicList<label> newToOldTri(tris.size());
|
||||
labelList newToMaster(mergedCentres.size(), -1);
|
||||
forAll(tris, triI)
|
||||
// Find the minimum of any duplicates
|
||||
label dupTriI = -1;
|
||||
forAll(pFaces, i)
|
||||
{
|
||||
label mergedI = oldToMerged[triI];
|
||||
|
||||
if (newToMaster[mergedI] == -1)
|
||||
if (pFaces[i] < triI && tris[pFaces[i]] == tri)
|
||||
{
|
||||
newToMaster[mergedI] = triI;
|
||||
newToOldTri.append(triMap[triI]);
|
||||
tris[newTriI++] = tris[triI];
|
||||
dupTriI = pFaces[i];
|
||||
}
|
||||
}
|
||||
|
||||
triMap.transfer(newToOldTri);
|
||||
tris.setSize(newTriI);
|
||||
if (dupTriI == -1)
|
||||
{
|
||||
// There is no lower triangle
|
||||
label newTriI = newToOldTri.size();
|
||||
newToOldTri.append(triI);
|
||||
tris[newTriI] = tris[triI];
|
||||
}
|
||||
}
|
||||
|
||||
triMap.transfer(newToOldTri);
|
||||
tris.setSize(triMap.size());
|
||||
}
|
||||
|
||||
return triSurface(tris, geometricSurfacePatchList(0), newPoints, true);
|
||||
@ -986,7 +975,7 @@ void Foam::isoSurface::calcAddressing
|
||||
{
|
||||
Pout<< "isoSurface : detected "
|
||||
<< mergedCentres.size()
|
||||
<< " edges on " << surf.size() << " triangles." << endl;
|
||||
<< " geometric edges on " << surf.size() << " triangles." << endl;
|
||||
}
|
||||
|
||||
if (!hasMerged)
|
||||
@ -1013,6 +1002,10 @@ void Foam::isoSurface::calcAddressing
|
||||
edgeFace1 = -1;
|
||||
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)
|
||||
{
|
||||
label triI = oldEdgeI / 3;
|
||||
@ -1020,34 +1013,128 @@ void Foam::isoSurface::calcAddressing
|
||||
|
||||
if (edgeFace0[edgeI] == -1)
|
||||
{
|
||||
// First triangle for edge
|
||||
edgeFace0[edgeI] = triI;
|
||||
}
|
||||
else if (edgeFace1[edgeI] == -1)
|
||||
{
|
||||
edgeFace1[edgeI] = triI;
|
||||
}
|
||||
else
|
||||
{
|
||||
//WarningIn("orientSurface(triSurface&)")
|
||||
// << "Edge " << edgeI << " with centre " << mergedCentres[edgeI]
|
||||
// << " used by more than two triangles: " << edgeFace0[edgeI]
|
||||
// << ", "
|
||||
// << edgeFace1[edgeI] << " and " << triI << endl;
|
||||
Map<labelList>::iterator iter = edgeFacesRest.find(edgeI);
|
||||
//- Check that the two triangles actually topologically
|
||||
// share an edge
|
||||
const labelledTri& prevTri = surf[edgeFace0[edgeI]];
|
||||
const labelledTri& tri = surf[triI];
|
||||
|
||||
if (iter != edgeFacesRest.end())
|
||||
label fp = oldEdgeI % 3;
|
||||
|
||||
edge e(tri[fp], tri[tri.fcIndex(fp)]);
|
||||
|
||||
label prevTriIndex = -1;
|
||||
|
||||
forAll(prevTri, i)
|
||||
{
|
||||
labelList& eFaces = iter();
|
||||
label sz = eFaces.size();
|
||||
eFaces.setSize(sz+1);
|
||||
eFaces[sz] = triI;
|
||||
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)
|
||||
{
|
||||
edgeFace1[edgeI] = triI;
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeFacesRest.insert(edgeI, labelList(1, triI));
|
||||
//WarningIn("orientSurface(triSurface&)")
|
||||
// << "Edge " << edgeI << " with centre "
|
||||
// << mergedCentres[edgeI]
|
||||
// << " used by more than two triangles: "
|
||||
// << edgeFace0[edgeI] << ", "
|
||||
// << edgeFace1[edgeI] << " and " << triI << endl;
|
||||
Map<labelList>::iterator iter = edgeFacesRest.find(edgeI);
|
||||
|
||||
if (iter != edgeFacesRest.end())
|
||||
{
|
||||
labelList& eFaces = iter();
|
||||
label sz = eFaces.size();
|
||||
eFaces.setSize(sz+1);
|
||||
eFaces[sz] = triI;
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeFacesRest.insert(edgeI, labelList(1, triI));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1097,6 +1184,24 @@ void Foam::isoSurface::walkOrientation
|
||||
|
||||
// nbr points
|
||||
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)];
|
||||
|
||||
bool sameOrientation = (p1 == nbrP1);
|
||||
@ -1352,8 +1457,17 @@ Foam::isoSurface::isoSurface
|
||||
iso_(iso),
|
||||
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 labelList& own = mesh_.faceOwner();
|
||||
|
||||
// Check
|
||||
forAll(patches, patchI)
|
||||
@ -1442,24 +1556,6 @@ Foam::isoSurface::isoSurface
|
||||
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)
|
||||
|
||||
@ -299,7 +299,16 @@ void Foam::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
|
||||
|
||||
@ -29,7 +29,6 @@ License
|
||||
#include "volFields.H"
|
||||
#include "volPointInterpolation.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -45,8 +44,6 @@ void Foam::sampledIsoSurface::getIsoFields() const
|
||||
{
|
||||
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
|
||||
|
||||
word pointFldName = "volPointInterpolate(" + isoField_ + ')';
|
||||
|
||||
// Get volField
|
||||
// ~~~~~~~~~~~~
|
||||
|
||||
@ -54,7 +51,7 @@ void Foam::sampledIsoSurface::getIsoFields() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : lookup "
|
||||
Info<< "sampledIsoSurface::getIsoField() : lookup volField "
|
||||
<< isoField_ << endl;
|
||||
}
|
||||
storedVolFieldPtr_.clear();
|
||||
@ -79,7 +76,7 @@ void Foam::sampledIsoSurface::getIsoFields() const
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : reading "
|
||||
Info<< "sampledIsoSurface::getIsoField() : reading volField "
|
||||
<< isoField_ << " from time " << fvm.time().timeName()
|
||||
<< endl;
|
||||
}
|
||||
@ -101,20 +98,6 @@ void Foam::sampledIsoSurface::getIsoFields() const
|
||||
)
|
||||
);
|
||||
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,59 +106,207 @@ void Foam::sampledIsoSurface::getIsoFields() const
|
||||
// Get pointField
|
||||
// ~~~~~~~~~~~~~~
|
||||
|
||||
if (fvm.foundObject<pointScalarField>(pointFldName))
|
||||
if (!subMeshPtr_.valid())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : lookup "
|
||||
<< pointFldName << endl;
|
||||
}
|
||||
pointFieldPtr_ = &fvm.lookupObject<pointScalarField>(pointFldName);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not in registry. Interpolate.
|
||||
word pointFldName = "volPointInterpolate(" + isoField_ + ')';
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : checking interpolate "
|
||||
<< isoField_ << " for same time " << fvm.time().timeName()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
storedPointFieldPtr_.empty()
|
||||
|| (fvm.time().timeName() != storedPointFieldPtr_().instance())
|
||||
)
|
||||
if (fvm.foundObject<pointScalarField>(pointFldName))
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : interpolating "
|
||||
Info<< "sampledIsoSurface::getIsoField() : lookup pointField "
|
||||
<< pointFldName << endl;
|
||||
}
|
||||
pointFieldPtr_ = &fvm.lookupObject<pointScalarField>(pointFldName);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not in registry. Interpolate.
|
||||
|
||||
storedPointFieldPtr_.reset
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : checking pointField "
|
||||
<< pointFldName << " for same time "
|
||||
<< fvm.time().timeName() << endl;
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
volPointInterpolation::New(fvm).interpolate(*volFieldPtr_).ptr()
|
||||
);
|
||||
pointFieldPtr_ = storedPointFieldPtr_.operator->();
|
||||
storedPointFieldPtr_.empty()
|
||||
|| (fvm.time().timeName() != storedPointFieldPtr_().instance())
|
||||
)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() :"
|
||||
<< " interpolating volField " << volFieldPtr_->name()
|
||||
<< " to get pointField " << pointFldName << endl;
|
||||
}
|
||||
|
||||
storedPointFieldPtr_.reset
|
||||
(
|
||||
volPointInterpolation::New(fvm)
|
||||
.interpolate(*volFieldPtr_).ptr()
|
||||
);
|
||||
storedPointFieldPtr_->checkOut();
|
||||
pointFieldPtr_ = storedPointFieldPtr_.operator->();
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : volField "
|
||||
<< volFieldPtr_->name() << " min:" << min(*volFieldPtr_).value()
|
||||
<< " max:" << max(*volFieldPtr_).value() << endl;
|
||||
Info<< "sampledIsoSurface::getIsoField() : pointField "
|
||||
<< pointFieldPtr_->name()
|
||||
<< " min:" << gMin(pointFieldPtr_->internalField())
|
||||
<< " max:" << gMax(pointFieldPtr_->internalField()) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (debug)
|
||||
else
|
||||
{
|
||||
Info<< "sampledIsoSurface::getIsoField() : volField "
|
||||
<< volFieldPtr_->name() << " min:" << min(*volFieldPtr_).value()
|
||||
<< " max:" << max(*volFieldPtr_).value() << endl;
|
||||
Info<< "sampledIsoSurface::getIsoField() : pointField "
|
||||
<< pointFieldPtr_->name()
|
||||
<< " min:" << gMin(pointFieldPtr_->internalField())
|
||||
<< " max:" << gMax(pointFieldPtr_->internalField()) << endl;
|
||||
// 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
|
||||
{
|
||||
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
|
||||
@ -186,6 +317,33 @@ bool Foam::sampledIsoSurface::updateGeometry() const
|
||||
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();
|
||||
getIsoFields();
|
||||
@ -196,67 +354,65 @@ bool Foam::sampledIsoSurface::updateGeometry() const
|
||||
|
||||
if (average_)
|
||||
{
|
||||
//- From point field and interpolated cell.
|
||||
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);
|
||||
if (subMeshPtr_.valid())
|
||||
{
|
||||
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
|
||||
(
|
||||
new isoSurface
|
||||
surfPtr_.reset
|
||||
(
|
||||
cellAvg,
|
||||
*pointFieldPtr_,
|
||||
isoVal_,
|
||||
regularise_
|
||||
)
|
||||
);
|
||||
new isoSurface
|
||||
(
|
||||
average(subMeshPtr_().subMesh(), *pointSubFieldPtr_),
|
||||
*pointSubFieldPtr_,
|
||||
isoVal_,
|
||||
regularise_,
|
||||
mergeTol_
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
surfPtr_.reset
|
||||
(
|
||||
new isoSurface
|
||||
(
|
||||
average(fvm, *pointFieldPtr_),
|
||||
*pointFieldPtr_,
|
||||
isoVal_,
|
||||
regularise_,
|
||||
mergeTol_
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//- Direct from cell field and point field.
|
||||
surfPtr_.reset
|
||||
(
|
||||
new isoSurface
|
||||
if (subMeshPtr_.valid())
|
||||
{
|
||||
surfPtr_.reset
|
||||
(
|
||||
*volFieldPtr_,
|
||||
*pointFieldPtr_,
|
||||
isoVal_,
|
||||
regularise_
|
||||
)
|
||||
);
|
||||
new isoSurface
|
||||
(
|
||||
*volSubFieldPtr_,
|
||||
*pointSubFieldPtr_,
|
||||
isoVal_,
|
||||
regularise_,
|
||||
mergeTol_
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
surfPtr_.reset
|
||||
(
|
||||
new isoSurface
|
||||
(
|
||||
*volFieldPtr_,
|
||||
*pointFieldPtr_,
|
||||
isoVal_,
|
||||
regularise_,
|
||||
mergeTol_
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -267,8 +423,13 @@ bool Foam::sampledIsoSurface::updateGeometry() const
|
||||
<< " regularise : " << regularise_ << nl
|
||||
<< " average : " << average_ << nl
|
||||
<< " isoField : " << isoField_ << nl
|
||||
<< " isoValue : " << isoVal_ << nl
|
||||
<< " points : " << points().size() << nl
|
||||
<< " isoValue : " << isoVal_ << nl;
|
||||
if (subMeshPtr_.valid())
|
||||
{
|
||||
Pout<< " zone size : " << subMeshPtr_().subMesh().nCells()
|
||||
<< nl;
|
||||
}
|
||||
Pout<< " points : " << points().size() << nl
|
||||
<< " tris : " << surface().size() << nl
|
||||
<< " cut cells : " << surface().meshCells().size()
|
||||
<< endl;
|
||||
@ -290,9 +451,11 @@ Foam::sampledIsoSurface::sampledIsoSurface
|
||||
sampledSurface(name, mesh, dict),
|
||||
isoField_(dict.lookup("isoField")),
|
||||
isoVal_(readScalar(dict.lookup("isoValue"))),
|
||||
mergeTol_(dict.lookupOrDefault("mergeTol", 1E-6)),
|
||||
regularise_(dict.lookupOrDefault("regularise", true)),
|
||||
average_(dict.lookupOrDefault("average", false)),
|
||||
zoneName_(word::null),
|
||||
zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()),
|
||||
exposedPatchName_(word::null),
|
||||
surfPtr_(NULL),
|
||||
facesPtr_(NULL),
|
||||
prevTimeIndex_(-1),
|
||||
@ -311,16 +474,29 @@ Foam::sampledIsoSurface::sampledIsoSurface
|
||||
<< " span across cells." << exit(FatalError);
|
||||
}
|
||||
|
||||
// dict.readIfPresent("zone", zoneName_);
|
||||
//
|
||||
// if (debug && zoneName_.size())
|
||||
// {
|
||||
// if (mesh.cellZones().findZoneID(zoneName_) < 0)
|
||||
// {
|
||||
// Info<< "cellZone \"" << zoneName_
|
||||
// << "\" not found - using entire mesh" << endl;
|
||||
// }
|
||||
// }
|
||||
if (zoneID_.index() != -1)
|
||||
{
|
||||
dict.lookup("exposedPatchName") >> exposedPatchName_;
|
||||
|
||||
if (mesh.boundaryMesh().findPatchID(exposedPatchName_) == -1)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"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();
|
||||
facesPtr_.clear();
|
||||
subMeshPtr_.clear();
|
||||
|
||||
// already marked as expired
|
||||
if (prevTimeIndex_ == -1)
|
||||
@ -465,8 +642,8 @@ Foam::sampledIsoSurface::interpolate
|
||||
void Foam::sampledIsoSurface::print(Ostream& os) const
|
||||
{
|
||||
os << "sampledIsoSurface: " << name() << " :"
|
||||
<< " field:" << isoField_
|
||||
<< " value:" << isoVal_;
|
||||
<< " field :" << isoField_
|
||||
<< " value :" << isoVal_;
|
||||
//<< " faces:" << faces().size() // note: possibly no geom yet
|
||||
//<< " points:" << points().size();
|
||||
}
|
||||
|
||||
@ -38,8 +38,10 @@ SourceFiles
|
||||
#ifndef sampledIsoSurface_H
|
||||
#define sampledIsoSurface_H
|
||||
|
||||
#include "sampledSurface.H"
|
||||
#include "isoSurface.H"
|
||||
#include "sampledSurface.H"
|
||||
#include "ZoneIDs.H"
|
||||
#include "fvMeshSubset.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -62,14 +64,20 @@ class sampledIsoSurface
|
||||
//- iso value
|
||||
const scalar isoVal_;
|
||||
|
||||
//- Merge tolerance
|
||||
const scalar mergeTol_;
|
||||
|
||||
//- Whether to coarse
|
||||
const Switch regularise_;
|
||||
|
||||
//- Whether to recalculate cell values as average of point values
|
||||
const Switch average_;
|
||||
|
||||
//- zone name (if restricted to zones)
|
||||
word zoneName_;
|
||||
//- zone name/index (if restricted to zones)
|
||||
mutable cellZoneID zoneID_;
|
||||
|
||||
//- for zones: patch to put exposed faces into
|
||||
mutable word exposedPatchName_;
|
||||
|
||||
mutable autoPtr<isoSurface> surfPtr_;
|
||||
|
||||
@ -90,6 +98,19 @@ class sampledIsoSurface
|
||||
mutable autoPtr<pointScalarField> storedPointFieldPtr_;
|
||||
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
|
||||
@ -97,6 +118,12 @@ class sampledIsoSurface
|
||||
//- Get fields needed to recreate iso surface.
|
||||
void getIsoFields() const;
|
||||
|
||||
tmp<volScalarField> average
|
||||
(
|
||||
const fvMesh&,
|
||||
const pointScalarField&
|
||||
) const;
|
||||
|
||||
//- Create iso surface (if time has changed)
|
||||
// Do nothing (and return false) if no update was needed
|
||||
bool updateGeometry() const;
|
||||
|
||||
@ -52,34 +52,47 @@ Foam::sampledIsoSurface::interpolateField
|
||||
const interpolation<Type>& interpolator
|
||||
) const
|
||||
{
|
||||
const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
|
||||
|
||||
// Get fields to sample. Assume volPointInterpolation!
|
||||
const GeometricField<Type, fvPatchField, volMesh>& volFld =
|
||||
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
|
||||
updateGeometry();
|
||||
|
||||
// Sample.
|
||||
return surface().interpolate
|
||||
(
|
||||
*volFieldPtr_,
|
||||
*pointFieldPtr_,
|
||||
volFld,
|
||||
pointFld
|
||||
);
|
||||
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.
|
||||
return surface().interpolate
|
||||
(
|
||||
*volFieldPtr_,
|
||||
*pointFieldPtr_,
|
||||
volFld,
|
||||
tpointFld()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ License
|
||||
#include "BasicMeshedSurface.H"
|
||||
#include "boundBox.H"
|
||||
#include "mergePoints.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -162,7 +163,7 @@ void Foam::BasicMeshedSurface<Face>::cleanup(const bool verbose)
|
||||
stitchFaces(SMALL, verbose);
|
||||
|
||||
checkFaces(verbose);
|
||||
this->checkEdges(verbose);
|
||||
this->checkTopology(verbose);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,7 +36,8 @@ SourceFiles
|
||||
#ifndef BasicMeshedSurface_H
|
||||
#define BasicMeshedSurface_H
|
||||
|
||||
#include "PrimitivePatchExtra.H"
|
||||
#include "PrimitivePatch.H"
|
||||
#include "PatchTools.H"
|
||||
#include "pointField.H"
|
||||
#include "face.H"
|
||||
#include "triFace.H"
|
||||
@ -55,11 +56,11 @@ namespace Foam
|
||||
template<class Face>
|
||||
class BasicMeshedSurface
|
||||
:
|
||||
public PrimitivePatchExtra<Face, ::Foam::List, pointField, point>
|
||||
public PrimitivePatch<Face, ::Foam::List, pointField, point>
|
||||
{
|
||||
|
||||
//- Typedefs for convenience
|
||||
typedef PrimitivePatchExtra
|
||||
typedef PrimitivePatch
|
||||
<
|
||||
Face,
|
||||
::Foam::List,
|
||||
@ -83,7 +84,7 @@ protected:
|
||||
return static_cast<List<Face> &>(*this);
|
||||
}
|
||||
|
||||
//- Set new regions/patches from faceMap
|
||||
//- Set new regions from faceMap
|
||||
virtual void remapFaces(const UList<label>& faceMap);
|
||||
|
||||
public:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
surfGroup/surfGroup.C
|
||||
surfGroup/surfGroupIOList.C
|
||||
surfPatchIdentifier/surfPatchIdentifier.C
|
||||
surfRegion/surfRegion/surfRegion.C
|
||||
surfRegion/surfRegion/surfRegionIOList.C
|
||||
surfRegion/surfRegionIdentifier/surfRegionIdentifier.C
|
||||
|
||||
MeshedSurface/MeshedSurfaces.C
|
||||
UnsortedMeshedSurface/UnsortedMeshedSurfaces.C
|
||||
|
||||
@ -166,11 +166,11 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const Xfer<surfGroupList>& patchLst
|
||||
const Xfer<surfRegionList>& regionLst
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst),
|
||||
patches_(patchLst)
|
||||
regions_(regionLst)
|
||||
{}
|
||||
|
||||
|
||||
@ -179,26 +179,26 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const UList<label>& patchSizes,
|
||||
const UList<word>& patchNames
|
||||
const UList<label>& regionSizes,
|
||||
const UList<word>& regionNames
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst)
|
||||
{
|
||||
if (&patchSizes)
|
||||
if (®ionSizes)
|
||||
{
|
||||
if (&patchNames)
|
||||
if (®ionNames)
|
||||
{
|
||||
addPatches(patchSizes, patchNames);
|
||||
addRegions(regionSizes, regionNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
addPatches(patchSizes);
|
||||
addRegions(regionSizes);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,15 +238,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
);
|
||||
|
||||
|
||||
// create patch list
|
||||
surfGroupList newPatches(bPatches.size());
|
||||
// create region list
|
||||
surfRegionList newRegions(bPatches.size());
|
||||
|
||||
label startFaceI = 0;
|
||||
forAll(bPatches, patchI)
|
||||
{
|
||||
const polyPatch& p = bPatches[patchI];
|
||||
|
||||
newPatches[patchI] = surfGroup
|
||||
newRegions[patchI] = surfRegion
|
||||
(
|
||||
p.name(),
|
||||
p.size(),
|
||||
@ -262,7 +262,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
xferCopy(bPoints),
|
||||
xferCopy(bFaces),
|
||||
xferMove(newPatches)
|
||||
xferMove(newRegions)
|
||||
);
|
||||
|
||||
|
||||
@ -285,7 +285,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
origFaces.clear();
|
||||
|
||||
this->storedFaces().transfer(newFaces);
|
||||
patches_.transfer(surf.patches_);
|
||||
regions_.transfer(surf.regions_);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -305,15 +305,15 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
{
|
||||
const surfPatchList& sPatches = sMesh.boundaryMesh();
|
||||
|
||||
// create patch list
|
||||
List<surfGroup> newPatches(sPatches.size());
|
||||
// create regions list
|
||||
List<surfRegion> newRegions(sPatches.size());
|
||||
|
||||
label startFaceI = 0;
|
||||
forAll(sPatches, patchI)
|
||||
{
|
||||
const surfPatch& p = sPatches[patchI];
|
||||
|
||||
newPatches[patchI] = surfGroup
|
||||
newRegions[patchI] = surfRegion
|
||||
(
|
||||
p.name(),
|
||||
p.size(),
|
||||
@ -324,7 +324,7 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
startFaceI += p.size();
|
||||
}
|
||||
|
||||
patches_.transfer(newPatches);
|
||||
regions_.transfer(newRegions);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -336,8 +336,8 @@ Foam::MeshedSurface<Face>::MeshedSurface
|
||||
)
|
||||
{
|
||||
labelList faceMap;
|
||||
surfGroupList patchLst = surf.sortedRegions(faceMap);
|
||||
patches_.transfer(patchLst);
|
||||
surfRegionList regionLst = surf.sortedRegions(faceMap);
|
||||
regions_.transfer(regionLst);
|
||||
|
||||
const List<Face>& origFaces = surf.faces();
|
||||
List<Face> newFaces(origFaces.size());
|
||||
@ -388,7 +388,7 @@ template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(const MeshedSurface& surf)
|
||||
:
|
||||
ParentType(surf),
|
||||
patches_(surf.patches_)
|
||||
regions_(surf.regions_)
|
||||
{}
|
||||
|
||||
|
||||
@ -420,70 +420,70 @@ Foam::MeshedSurface<Face>::~MeshedSurface()
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::onePatch(const word& name)
|
||||
void Foam::MeshedSurface<Face>::oneRegion(const word& name)
|
||||
{
|
||||
word patchName(name);
|
||||
if (patchName.empty())
|
||||
word regionName(name);
|
||||
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
|
||||
patches_.setSize(1);
|
||||
patches_[0] = surfGroup
|
||||
// set single default region
|
||||
regions_.setSize(1);
|
||||
regions_[0] = surfRegion
|
||||
(
|
||||
patchName,
|
||||
size(), // patch size
|
||||
0, // patch start
|
||||
0 // patch index
|
||||
regionName,
|
||||
size(), // region size
|
||||
0, // region start
|
||||
0 // region index
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
if (patches_.size() <= 1)
|
||||
if (regions_.size() <= 1)
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
else
|
||||
{
|
||||
label count = 0;
|
||||
forAll(patches_, patchI)
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
patches_[patchI].start() = count;
|
||||
count += patches_[patchI].size();
|
||||
regions_[regionI].start() = count;
|
||||
count += regions_[regionI].size();
|
||||
}
|
||||
|
||||
if (count < size())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"MeshedSurface::checkPatches()\n"
|
||||
"MeshedSurface::checkRegions()\n"
|
||||
)
|
||||
<< "more face " << size() << " than patches " << count
|
||||
<< " ... extending final patch"
|
||||
<< "more face " << size() << " than regions " << count
|
||||
<< " ... extending final region"
|
||||
<< endl;
|
||||
|
||||
patches_[patches_.size()-1].size() += count - size();
|
||||
regions_[regions_.size()-1].size() += count - size();
|
||||
}
|
||||
else if (count > size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"MeshedSurface::checkPatches()\n"
|
||||
"MeshedSurface::checkRegions()\n"
|
||||
)
|
||||
<< "more patches " << count << " than faces " << size()
|
||||
<< "more regions " << count << " than faces " << size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -534,33 +534,33 @@ void Foam::MeshedSurface<Face>::remapFaces
|
||||
const UList<label>& faceMap
|
||||
)
|
||||
{
|
||||
// recalculate the patch start/size
|
||||
// recalculate the region start/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
|
||||
patches_[0].size() = faceMap.size();
|
||||
// optimized for single region case
|
||||
regions_[0].size() = faceMap.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
label newFaceI = 0;
|
||||
label oldPatchEnd = 0;
|
||||
forAll(patches_, patchI)
|
||||
label origEndI = 0;
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
surfGroup& p = patches_[patchI];
|
||||
surfRegion& reg = regions_[regionI];
|
||||
|
||||
// adjust patch start
|
||||
p.start() = newFaceI;
|
||||
oldPatchEnd += p.size();
|
||||
// adjust region start
|
||||
reg.start() = newFaceI;
|
||||
origEndI += reg.size();
|
||||
|
||||
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
||||
{
|
||||
if (faceMap[faceI] < oldPatchEnd)
|
||||
if (faceMap[faceI] < origEndI)
|
||||
{
|
||||
++newFaceI;
|
||||
}
|
||||
@ -570,8 +570,8 @@ void Foam::MeshedSurface<Face>::remapFaces
|
||||
}
|
||||
}
|
||||
|
||||
// adjust patch size
|
||||
p.size() = newFaceI - p.start();
|
||||
// adjust region size
|
||||
reg.size() = newFaceI - reg.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -586,14 +586,14 @@ template<class Face>
|
||||
void Foam::MeshedSurface<Face>::clear()
|
||||
{
|
||||
ParentType::clear();
|
||||
patches_.clear();
|
||||
regions_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const
|
||||
@ -603,7 +603,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
|
||||
|
||||
// Fill pointMap, faceMap
|
||||
this->subsetMap(include, pointMap, faceMap);
|
||||
PatchTools::subsetMap(*this, include, pointMap, faceMap);
|
||||
|
||||
// Create compact coordinate list and forward mapping array
|
||||
pointField newPoints(pointMap.size());
|
||||
@ -614,11 +614,11 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
oldToNew[pointMap[pointI]] = pointI;
|
||||
}
|
||||
|
||||
// create/copy a new patch list, each patch with zero size
|
||||
surfGroupList newPatches(patches_);
|
||||
forAll(newPatches, patchI)
|
||||
// create/copy a new region list, each region with zero size
|
||||
surfRegionList newRegions(regions_);
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
newPatches[patchI].size() = 0;
|
||||
newRegions[regionI].size() = 0;
|
||||
}
|
||||
|
||||
// Renumber face node labels
|
||||
@ -637,22 +637,22 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
}
|
||||
oldToNew.clear();
|
||||
|
||||
// recalculate the patch start/size
|
||||
// recalculate the region start/size
|
||||
label newFaceI = 0;
|
||||
label oldPatchEnd = 0;
|
||||
label origEndI = 0;
|
||||
|
||||
// adjust patch sizes
|
||||
forAll(newPatches, patchI)
|
||||
// adjust region sizes
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
surfGroup& p = newPatches[patchI];
|
||||
surfRegion& reg = newRegions[regionI];
|
||||
|
||||
// adjust patch start
|
||||
p.start() = newFaceI;
|
||||
oldPatchEnd += p.size();
|
||||
// adjust region start
|
||||
reg.start() = newFaceI;
|
||||
origEndI += reg.size();
|
||||
|
||||
for (label faceI = newFaceI; faceI < faceMap.size(); ++faceI)
|
||||
{
|
||||
if (faceMap[faceI] < oldPatchEnd)
|
||||
if (faceMap[faceI] < origEndI)
|
||||
{
|
||||
++newFaceI;
|
||||
}
|
||||
@ -662,8 +662,8 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
}
|
||||
}
|
||||
|
||||
// adjust patch size
|
||||
p.size() = newFaceI - p.start();
|
||||
// adjust region size
|
||||
reg.size() = newFaceI - reg.start();
|
||||
}
|
||||
|
||||
|
||||
@ -672,15 +672,16 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
xferMove(newPoints),
|
||||
xferMove(newFaces),
|
||||
xferMove(newPatches)
|
||||
xferMove(newRegions)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
labelList pointMap, faceMap;
|
||||
@ -689,85 +690,85 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::addPatches
|
||||
void Foam::MeshedSurface<Face>::addRegions
|
||||
(
|
||||
const UList<surfGroup>& patches,
|
||||
const UList<surfRegion>& regions,
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label nPatch = 0;
|
||||
label nRegion = 0;
|
||||
|
||||
patches_.setSize(patches.size());
|
||||
forAll(patches_, patchI)
|
||||
regions_.setSize(regions.size());
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
if (patches[patchI].size() || !cullEmpty)
|
||||
if (regions[regionI].size() || !cullEmpty)
|
||||
{
|
||||
patches_[nPatch] = surfGroup(patches[patchI], nPatch);
|
||||
nPatch++;
|
||||
regions_[nRegion] = surfRegion(regions[regionI], nRegion);
|
||||
nRegion++;
|
||||
}
|
||||
}
|
||||
patches_.setSize(nPatch);
|
||||
regions_.setSize(nRegion);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::addPatches
|
||||
void Foam::MeshedSurface<Face>::addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const UList<word>& names,
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label start = 0;
|
||||
label nPatch = 0;
|
||||
label start = 0;
|
||||
label nRegion = 0;
|
||||
|
||||
patches_.setSize(sizes.size());
|
||||
forAll(patches_, patchI)
|
||||
regions_.setSize(sizes.size());
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
if (sizes[patchI] || !cullEmpty)
|
||||
if (sizes[regionI] || !cullEmpty)
|
||||
{
|
||||
patches_[nPatch] = surfGroup
|
||||
regions_[nRegion] = surfRegion
|
||||
(
|
||||
names[patchI],
|
||||
sizes[patchI],
|
||||
names[regionI],
|
||||
sizes[regionI],
|
||||
start,
|
||||
nPatch
|
||||
nRegion
|
||||
);
|
||||
start += sizes[patchI];
|
||||
nPatch++;
|
||||
start += sizes[regionI];
|
||||
nRegion++;
|
||||
}
|
||||
}
|
||||
patches_.setSize(nPatch);
|
||||
regions_.setSize(nRegion);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::addPatches
|
||||
void Foam::MeshedSurface<Face>::addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const bool cullEmpty
|
||||
)
|
||||
{
|
||||
label start = 0;
|
||||
label nPatch = 0;
|
||||
label start = 0;
|
||||
label nRegion = 0;
|
||||
|
||||
patches_.setSize(sizes.size());
|
||||
forAll(patches_, patchI)
|
||||
regions_.setSize(sizes.size());
|
||||
forAll(regions_, regionI)
|
||||
{
|
||||
if (sizes[patchI] || !cullEmpty)
|
||||
if (sizes[regionI] || !cullEmpty)
|
||||
{
|
||||
patches_[nPatch] = surfGroup
|
||||
regions_[nRegion] = surfRegion
|
||||
(
|
||||
word("patch") + ::Foam::name(nPatch),
|
||||
sizes[patchI],
|
||||
word("region") + ::Foam::name(nRegion),
|
||||
sizes[regionI],
|
||||
start,
|
||||
nPatch
|
||||
nRegion
|
||||
);
|
||||
start += sizes[patchI];
|
||||
nPatch++;
|
||||
start += sizes[regionI];
|
||||
nRegion++;
|
||||
}
|
||||
}
|
||||
patches_.setSize(nPatch);
|
||||
regions_.setSize(nRegion);
|
||||
}
|
||||
|
||||
|
||||
@ -778,7 +779,7 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
)
|
||||
{
|
||||
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
||||
patches_.transfer(surf.patches_);
|
||||
regions_.transfer(surf.regions_);
|
||||
|
||||
surf.clear();
|
||||
}
|
||||
@ -793,7 +794,7 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
clear();
|
||||
|
||||
labelList faceMap;
|
||||
surfGroupList patchLst = surf.sortedRegions(faceMap);
|
||||
surfRegionList regionLst = surf.sortedRegions(faceMap);
|
||||
List<Face>& oldFaces = surf.storedFaces();
|
||||
|
||||
List<Face> newFaces(faceMap.size());
|
||||
@ -804,7 +805,7 @@ void Foam::MeshedSurface<Face>::transfer
|
||||
faceMap.clear();
|
||||
|
||||
reset(xferMove(surf.storedPoints()), xferMove(newFaces));
|
||||
patches_.transfer(patchLst);
|
||||
regions_.transfer(regionLst);
|
||||
|
||||
surf.clear();
|
||||
}
|
||||
@ -864,7 +865,7 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
|
||||
|
||||
this->storedPoints() = surf.points();
|
||||
this->storedFaces() = surf.faces();
|
||||
patches_ = surf.patches_;
|
||||
regions_ = surf.regions_;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -26,13 +26,13 @@ Class
|
||||
Foam::MeshedSurface
|
||||
|
||||
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
|
||||
the cell faces of a volume mesh.
|
||||
|
||||
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 with randomly sorted patch information.
|
||||
- A set of points and faces without any region information.
|
||||
- A set of points and faces with randomly sorted region information.
|
||||
This could arise, for example, from reading external file formats
|
||||
such as STL, etc.
|
||||
|
||||
@ -45,7 +45,7 @@ SourceFiles
|
||||
#define MeshedSurface_H
|
||||
|
||||
#include "BasicMeshedSurface.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "surfaceFormatsCore.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "memberFunctionSelectionTables.H"
|
||||
@ -88,9 +88,9 @@ private:
|
||||
|
||||
// Private Member Data
|
||||
|
||||
//- Patch information (face ordering nFaces/startFace only used
|
||||
// during reading and writing)
|
||||
List<surfGroup> patches_;
|
||||
//- Region information
|
||||
// (face ordering nFaces/startFace only used during reading/writing)
|
||||
List<surfRegion> regions_;
|
||||
|
||||
// Private member functions
|
||||
|
||||
@ -101,8 +101,8 @@ protected:
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
//- basic sanity check on patches
|
||||
void checkPatches();
|
||||
//- basic sanity check on regions
|
||||
void checkRegions();
|
||||
|
||||
//- sort faces by regions and store sorted faces
|
||||
void sortFacesAndStore
|
||||
@ -139,22 +139,22 @@ public:
|
||||
//- Construct null
|
||||
MeshedSurface();
|
||||
|
||||
//- Construct by transferring components (points, faces, patches).
|
||||
//- Construct by transferring components (points, faces, regions).
|
||||
MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const Xfer<surfGroupList>&
|
||||
const Xfer<surfRegionList>&
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces.
|
||||
// Use patch information, or set single default patch.
|
||||
// Use region information, or set single default region.
|
||||
MeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const UList<label>& patchSizes = UList<label>::null(),
|
||||
const UList<word>& patchNames = UList<word>::null()
|
||||
const UList<label>& regionSizes = UList<label>::null(),
|
||||
const UList<word>& regionNames = UList<word>::null()
|
||||
);
|
||||
|
||||
//- Construct from a boundary mesh with local points/faces
|
||||
@ -250,31 +250,31 @@ public:
|
||||
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
|
||||
void onePatch(const word& name = word::null);
|
||||
//- set a single region, optionally with a specific name
|
||||
void oneRegion(const word& name = word::null);
|
||||
|
||||
//- add patches
|
||||
void addPatches
|
||||
//- Add regions
|
||||
void addRegions
|
||||
(
|
||||
const UList<surfGroup>&,
|
||||
const UList<surfRegion>&,
|
||||
const bool cullEmpty=false
|
||||
);
|
||||
|
||||
//- add patches
|
||||
void addPatches
|
||||
//- Add regions
|
||||
void addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const UList<word>& names,
|
||||
const bool cullEmpty=false
|
||||
);
|
||||
|
||||
//- add patches
|
||||
void addPatches
|
||||
//- Add regions
|
||||
void addRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const bool cullEmpty=false
|
||||
@ -289,7 +289,7 @@ public:
|
||||
// Returns return pointMap, faceMap from subsetMeshMap
|
||||
MeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const;
|
||||
@ -297,7 +297,7 @@ public:
|
||||
//- Return new surface.
|
||||
MeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include
|
||||
const labelHashSet& include
|
||||
) const;
|
||||
|
||||
//- Transfer the contents of the argument and annull the argument
|
||||
|
||||
@ -37,16 +37,16 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
|
||||
{
|
||||
clear();
|
||||
|
||||
List<surfGroup> patchLst(is);
|
||||
List<surfRegion> regionLst(is);
|
||||
|
||||
// copy and set the indices
|
||||
patches_.setSize(patchLst.size());
|
||||
forAll(patchLst, patchI)
|
||||
regions_.setSize(regionLst.size());
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
patches_[patchI] = surfGroup
|
||||
regions_[regionI] = surfRegion
|
||||
(
|
||||
patchLst[patchI],
|
||||
patchI
|
||||
regionLst[regionI],
|
||||
regionI
|
||||
);
|
||||
}
|
||||
|
||||
@ -64,11 +64,11 @@ bool Foam::MeshedSurface<Face>::read(Istream& is)
|
||||
Xfer<pointField>::null(),
|
||||
faceLst.xfer()
|
||||
);
|
||||
surf.addPatches(patches_);
|
||||
surf.addRegions(regions_);
|
||||
|
||||
// this will break if the triangulation needed points
|
||||
surf.triangulate();
|
||||
patches_ = surf.patches();
|
||||
regions_ = surf.regions();
|
||||
|
||||
// transcribe from face -> triFace (Face)
|
||||
const List<face>& origFaces = surf.faces();
|
||||
@ -102,11 +102,11 @@ void Foam::MeshedSurface<Face>::write(Ostream& os) const
|
||||
os << "// OpenFOAM Surface Format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << 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;
|
||||
|
||||
|
||||
@ -164,12 +164,12 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const Xfer<List<label> >& regionIds,
|
||||
const Xfer<surfPatchIdentifierList>& patchLst
|
||||
const Xfer<surfRegionIdentifierList>& regionTofc
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst),
|
||||
regions_(regionIds),
|
||||
patches_(patchLst)
|
||||
regionIds_(regionIds),
|
||||
regionToc_(regionTofc)
|
||||
{}
|
||||
|
||||
|
||||
@ -178,26 +178,26 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const Xfer<pointField>& pointLst,
|
||||
const Xfer<List<Face> >& faceLst,
|
||||
const UList<label>& patchSizes,
|
||||
const UList<word>& patchNames
|
||||
const UList<label>& regionSizes,
|
||||
const UList<word>& regionNames
|
||||
)
|
||||
:
|
||||
ParentType(pointLst, faceLst)
|
||||
{
|
||||
if (&patchSizes)
|
||||
if (®ionSizes)
|
||||
{
|
||||
if (&patchNames)
|
||||
if (®ionNames)
|
||||
{
|
||||
setPatches(patchSizes, patchNames);
|
||||
setRegions(regionSizes, regionNames);
|
||||
}
|
||||
else
|
||||
{
|
||||
setPatches(patchSizes);
|
||||
setRegions(regionSizes);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onePatch();
|
||||
oneRegion();
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
:
|
||||
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())),
|
||||
regions_(surf.regions_),
|
||||
patches_(surf.patches_)
|
||||
regionIds_(surf.regionIds_),
|
||||
regionToc_(surf.regionToc_)
|
||||
{}
|
||||
|
||||
|
||||
@ -296,101 +296,105 @@ template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::~UnsortedMeshedSurface()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::onePatch(const word& name)
|
||||
void Foam::UnsortedMeshedSurface<Face>::oneRegion(const word& name)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
regions_ = 0;
|
||||
regionIds_.setSize(size());
|
||||
regionIds_ = 0;
|
||||
|
||||
word patchName(name);
|
||||
if (patchName.empty())
|
||||
word regionName(name);
|
||||
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
|
||||
patches_.setSize(1);
|
||||
patches_[0] = surfPatchIdentifier(patchName, 0);
|
||||
// set single default region
|
||||
regionToc_.setSize(1);
|
||||
regionToc_[0] = surfRegionIdentifier(regionName, 0);
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
||||
(
|
||||
const surfGroupList& patches
|
||||
const surfRegionList& regionLst
|
||||
)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
patches_.setSize(patches.size());
|
||||
regionIds_.setSize(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());
|
||||
subRegion = patchI;
|
||||
// assign sub-region Ids
|
||||
SubList<label> subRegion(regionIds_, reg.size(), reg.start());
|
||||
subRegion = regionI;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
||||
(
|
||||
const UList<label>& sizes,
|
||||
const UList<word>& names
|
||||
)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
patches_.setSize(sizes.size());
|
||||
regionIds_.setSize(size());
|
||||
regionToc_.setSize(sizes.size());
|
||||
|
||||
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);
|
||||
subRegion = patchI;
|
||||
// assign sub-region Ids
|
||||
SubList<label> subRegion(regionIds_, sizes[regionI], start);
|
||||
subRegion = regionI;
|
||||
|
||||
start += sizes[patchI];
|
||||
start += sizes[regionI];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::setPatches
|
||||
void Foam::UnsortedMeshedSurface<Face>::setRegions
|
||||
(
|
||||
const UList<label>& sizes
|
||||
)
|
||||
{
|
||||
regions_.setSize(size());
|
||||
patches_.setSize(sizes.size());
|
||||
regionIds_.setSize(size());
|
||||
regionToc_.setSize(sizes.size());
|
||||
|
||||
label start = 0;
|
||||
forAll(patches_, patchI)
|
||||
forAll(regionToc_, regionI)
|
||||
{
|
||||
patches_[patchI] = surfPatchIdentifier
|
||||
regionToc_[regionI] = surfRegionIdentifier
|
||||
(
|
||||
word("patch") + ::Foam::name(patchI),
|
||||
patchI
|
||||
word("region") + ::Foam::name(regionI),
|
||||
regionI
|
||||
);
|
||||
|
||||
SubList<label> subRegion(regions_, sizes[patchI], start);
|
||||
subRegion = patchI;
|
||||
// assign sub-region Ids
|
||||
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
|
||||
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
|
||||
regions_ = 0;
|
||||
// optimized for single-region case
|
||||
regionIds_ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -419,9 +423,9 @@ void Foam::UnsortedMeshedSurface<Face>::remapFaces
|
||||
|
||||
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)
|
||||
{
|
||||
ParentType::setSize(s);
|
||||
// if regions extend: set with last patchId
|
||||
regions_.setSize(s, patches_.size() - 1);
|
||||
// if regions extend: set with last regionId
|
||||
regionIds_.setSize(s, regionToc_.size() - 1);
|
||||
}
|
||||
|
||||
|
||||
@ -442,32 +446,32 @@ template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::clear()
|
||||
{
|
||||
ParentType::clear();
|
||||
regions_.clear();
|
||||
patches_.clear();
|
||||
regionIds_.clear();
|
||||
regionToc_.clear();
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::surfGroupList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
||||
Foam::surfRegionList Foam::UnsortedMeshedSurface<Face>::sortedRegions
|
||||
(
|
||||
labelList& faceMap
|
||||
) const
|
||||
{
|
||||
// supply some patch names
|
||||
Map<word> patchNames;
|
||||
forAll(patches_, patchI)
|
||||
// supply some region names
|
||||
Map<word> regionNames;
|
||||
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>
|
||||
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const
|
||||
@ -476,7 +480,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
const List<Face>& locFaces = this->localFaces();
|
||||
|
||||
// Fill pointMap, faceMap
|
||||
this->subsetMap(include, pointMap, faceMap);
|
||||
PatchTools::subsetMap(*this, include, pointMap, faceMap);
|
||||
|
||||
// Create compact coordinate list and forward mapping array
|
||||
pointField newPoints(pointMap.size());
|
||||
@ -503,7 +507,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
f[fp] = oldToNew[f[fp]];
|
||||
}
|
||||
|
||||
newRegions[faceI] = regions_[origFaceI];
|
||||
newRegions[faceI] = regionIds_[origFaceI];
|
||||
}
|
||||
oldToNew.clear();
|
||||
|
||||
@ -513,7 +517,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
xferMove(newPoints),
|
||||
xferMove(newFaces),
|
||||
xferMove(newRegions),
|
||||
xferCopy(patches_)
|
||||
xferCopy(regionToc_)
|
||||
);
|
||||
}
|
||||
|
||||
@ -521,7 +525,7 @@ Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>::subsetMesh
|
||||
(
|
||||
const UList<bool>& include
|
||||
const labelHashSet& include
|
||||
) const
|
||||
{
|
||||
labelList pointMap, faceMap;
|
||||
@ -541,7 +545,7 @@ void Foam::UnsortedMeshedSurface<Face>::reset
|
||||
|
||||
if (®ionIds)
|
||||
{
|
||||
regions_.transfer(regionIds());
|
||||
regionIds_.transfer(regionIds());
|
||||
}
|
||||
}
|
||||
|
||||
@ -556,9 +560,9 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
|
||||
(
|
||||
xferMove(surf.storedPoints()),
|
||||
xferMove(surf.storedFaces()),
|
||||
xferMove(surf.regions_)
|
||||
xferMove(surf.regionIds_)
|
||||
);
|
||||
patches_.transfer(surf.patches_);
|
||||
regionToc_.transfer(surf.regionToc_);
|
||||
|
||||
surf.clear();
|
||||
}
|
||||
@ -571,7 +575,7 @@ void Foam::UnsortedMeshedSurface<Face>::transfer
|
||||
)
|
||||
{
|
||||
reset(xferMove(surf.storedPoints()), xferMove(surf.storedFaces()));
|
||||
setPatches(surf.patches());
|
||||
setRegions(surf.regions());
|
||||
surf.clear();
|
||||
}
|
||||
|
||||
@ -634,8 +638,8 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
|
||||
|
||||
this->storedPoints() = surf.points();
|
||||
this->storedFaces() = surf.faces();
|
||||
regions_ = surf.regions_;
|
||||
patches_ = surf.patches_;
|
||||
regionIds_ = surf.regionIds_;
|
||||
regionToc_ = surf.regionToc_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -26,18 +26,18 @@ Class
|
||||
Foam::UnsortedMeshedSurface
|
||||
|
||||
Description
|
||||
A surface geometry mesh, in which the patch information is conveyed by
|
||||
the 'region' associated with each face.
|
||||
A surface geometry mesh, in which the region information is conveyed by
|
||||
the 'regionId' associated with each face.
|
||||
|
||||
This form of surface description is particularly useful for reading in
|
||||
surface meshes from third-party formats (eg, obj, stl, gts, etc.). It
|
||||
can also be particularly useful for situations in which the surface
|
||||
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
|
||||
The Foam::meshedSurface - which is organized as a surface mesh, but
|
||||
with independent patch information.
|
||||
The Foam::MeshedSurface - which is organized as a surface mesh, but
|
||||
with independent region information.
|
||||
|
||||
SourceFiles
|
||||
UnsortedMeshedSurface.C
|
||||
@ -48,8 +48,8 @@ SourceFiles
|
||||
#define UnsortedMeshedSurface_H
|
||||
|
||||
#include "BasicMeshedSurface.H"
|
||||
#include "surfPatchIdentifierList.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "surfRegionIdentifierList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "surfaceFormatsCore.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "memberFunctionSelectionTables.H"
|
||||
@ -70,7 +70,7 @@ template<class Face> class MeshedSurface;
|
||||
class polyBoundaryMesh;
|
||||
|
||||
template<class Face>
|
||||
Ostream& operator<<(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
Ostream& operator<<(Ostream&, const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -93,12 +93,12 @@ private:
|
||||
|
||||
// Private Member Data
|
||||
|
||||
//- The regions associated with the faces
|
||||
labelList regions_;
|
||||
//- The region Ids associated with the faces
|
||||
labelList regionIds_;
|
||||
|
||||
//- Patch information (face ordering nFaces/startFace only used
|
||||
//- Region information (face ordering nFaces/startFace only used
|
||||
// during reading and writing)
|
||||
List<surfPatchIdentifier> patches_;
|
||||
List<surfRegionIdentifier> regionToc_;
|
||||
|
||||
// Private member functions
|
||||
|
||||
@ -115,16 +115,16 @@ protected:
|
||||
|
||||
// Protected Member functions
|
||||
|
||||
//- Return non-const access to the faces
|
||||
List<label>& storedRegions()
|
||||
//- Return non-const access to the region Ids
|
||||
List<label>& storedRegionIds()
|
||||
{
|
||||
return regions_;
|
||||
return regionIds_;
|
||||
}
|
||||
|
||||
//- Return non-const access to the patches
|
||||
List<surfPatchIdentifier>& storedPatches()
|
||||
//- Return non-const access to the region table-of-contents
|
||||
List<surfRegionIdentifier>& storedRegionToc()
|
||||
{
|
||||
return patches_;
|
||||
return regionToc_;
|
||||
}
|
||||
|
||||
//- Set new regions from faceMap
|
||||
@ -155,23 +155,23 @@ public:
|
||||
UnsortedMeshedSurface();
|
||||
|
||||
//- Construct by transferring components
|
||||
// (points, faces, region ids, patches).
|
||||
// (points, faces, region ids, region info).
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const Xfer<List<label> >& regionIds,
|
||||
const Xfer<surfPatchIdentifierList>&
|
||||
const Xfer<surfRegionIdentifierList>&
|
||||
);
|
||||
|
||||
//- Construct by transferring points, faces.
|
||||
// Use patch information, or set single default patch
|
||||
// Use region information, or set single default region
|
||||
UnsortedMeshedSurface
|
||||
(
|
||||
const Xfer<pointField>&,
|
||||
const Xfer<List<Face> >&,
|
||||
const UList<label>& patchSizes = UList<label>::null(),
|
||||
const UList<word>& patchNames = UList<word>::null()
|
||||
const UList<label>& regionSizes = UList<label>::null(),
|
||||
const UList<word>& regionNames = UList<word>::null()
|
||||
);
|
||||
|
||||
//- Construct from a boundary mesh with local points/faces
|
||||
@ -267,34 +267,34 @@ public:
|
||||
//- Reset size of face and region list
|
||||
void setSize(const label);
|
||||
|
||||
//- Return const access to the regions
|
||||
const List<label>& regions() const
|
||||
//- Return const access to the regions ids
|
||||
const List<label>& regionIds() const
|
||||
{
|
||||
return regions_;
|
||||
return regionIds_;
|
||||
}
|
||||
|
||||
//- Return const access to the patches
|
||||
const List<surfPatchIdentifier>& patches() const
|
||||
//- Return const access to the region table-of-contents
|
||||
const List<surfRegionIdentifier>& regionToc() const
|
||||
{
|
||||
return patches_;
|
||||
return regionToc_;
|
||||
}
|
||||
|
||||
//- Sort faces according to region.
|
||||
// Returns patch list and sets faceMap to index within faces()
|
||||
List<surfGroup> sortedRegions(labelList& faceMap) const;
|
||||
// Returns a surfRegionList and sets faceMap to index within faces()
|
||||
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
|
||||
void onePatch(const word& name = word::null);
|
||||
void oneRegion(const word& name = word::null);
|
||||
|
||||
//- Set regions and patches
|
||||
void setPatches(const surfGroupList&);
|
||||
//- Set region ids and regions
|
||||
void setRegions(const surfRegionList&);
|
||||
|
||||
//- Set regions and patches
|
||||
void setPatches(const UList<label>& sizes, const UList<word>& names);
|
||||
//- Set region ids and regions
|
||||
void setRegions(const UList<label>& sizes, const UList<word>& names);
|
||||
|
||||
//- Set regions and patches with default names
|
||||
void setPatches(const UList<label>& sizes);
|
||||
//- Set region ids and set regions with default names
|
||||
void setRegions(const UList<label>& sizes);
|
||||
|
||||
|
||||
// Edit
|
||||
@ -306,7 +306,7 @@ public:
|
||||
// Returns return pointMap, faceMap from subsetMeshMap
|
||||
UnsortedMeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include,
|
||||
const labelHashSet& include,
|
||||
labelList& pointMap,
|
||||
labelList& faceMap
|
||||
) const;
|
||||
@ -314,7 +314,7 @@ public:
|
||||
//- Return new surface.
|
||||
UnsortedMeshedSurface subsetMesh
|
||||
(
|
||||
const UList<bool>& include
|
||||
const labelHashSet& include
|
||||
) const;
|
||||
|
||||
//- Transfer components (points, faces, region ids).
|
||||
|
||||
@ -49,18 +49,18 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
|
||||
const List<Face>& faceLst = this->faces();
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = sortedRegions(faceMap);
|
||||
surfRegionList regionLst = sortedRegions(faceMap);
|
||||
|
||||
// just emit some information until we get a nice IOobject
|
||||
IOobject::writeBanner(os);
|
||||
os << "// OpenFOAM Surface Format" << nl
|
||||
<< "// ~~~~~~~~~~~~~~~~~~~~~~~" << 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;
|
||||
|
||||
@ -74,12 +74,12 @@ void Foam::UnsortedMeshedSurface<Face>::write(Ostream& os) const
|
||||
os << faceLst.size() << nl << token::BEGIN_LIST << nl;
|
||||
|
||||
label faceI = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -26,28 +26,28 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfGroup.H"
|
||||
#include "surfRegion.H"
|
||||
#include "dictionary.H"
|
||||
#include "word.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::surfGroup, 0);
|
||||
defineTypeNameAndDebug(Foam::surfRegion, 0);
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfGroup::surfGroup()
|
||||
Foam::surfRegion::surfRegion()
|
||||
:
|
||||
surfPatchIdentifier(),
|
||||
surfRegionIdentifier(),
|
||||
size_(0),
|
||||
start_(0)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup
|
||||
Foam::surfRegion::surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const label size,
|
||||
@ -56,68 +56,68 @@ Foam::surfGroup::surfGroup
|
||||
const word& geometricType
|
||||
)
|
||||
:
|
||||
surfPatchIdentifier(name, index, geometricType),
|
||||
surfRegionIdentifier(name, index, geometricType),
|
||||
size_(size),
|
||||
start_(start)
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(Istream& is, const label index)
|
||||
Foam::surfRegion::surfRegion(Istream& is, const label index)
|
||||
:
|
||||
surfPatchIdentifier(),
|
||||
surfRegionIdentifier(),
|
||||
size_(0),
|
||||
start_(0)
|
||||
{
|
||||
word name(is);
|
||||
dictionary dict(is);
|
||||
|
||||
operator=(surfGroup(name, dict, index));
|
||||
operator=(surfRegion(name, dict, index));
|
||||
}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup
|
||||
Foam::surfRegion::surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const label index
|
||||
)
|
||||
:
|
||||
surfPatchIdentifier(name, dict, index),
|
||||
surfRegionIdentifier(name, dict, index),
|
||||
size_(readLabel(dict.lookup("nFaces"))),
|
||||
start_(readLabel(dict.lookup("startFace")))
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(const surfGroup& p)
|
||||
Foam::surfRegion::surfRegion(const surfRegion& reg)
|
||||
:
|
||||
surfPatchIdentifier(p, p.index()),
|
||||
size_(p.size()),
|
||||
start_(p.start())
|
||||
surfRegionIdentifier(reg, reg.index()),
|
||||
size_(reg.size()),
|
||||
start_(reg.start())
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfGroup::surfGroup(const surfGroup& p, const label index)
|
||||
Foam::surfRegion::surfRegion(const surfRegion& reg, const label index)
|
||||
:
|
||||
surfPatchIdentifier(p, index),
|
||||
size_(p.size()),
|
||||
start_(p.start())
|
||||
surfRegionIdentifier(reg, index),
|
||||
size_(reg.size()),
|
||||
start_(reg.start())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::surfGroup::write(Ostream& os) const
|
||||
void Foam::surfRegion::write(Ostream& os) const
|
||||
{
|
||||
writeDict(os);
|
||||
}
|
||||
|
||||
|
||||
void Foam::surfGroup::writeDict(Ostream& os) const
|
||||
void Foam::surfRegion::writeDict(Ostream& os) const
|
||||
{
|
||||
os << indent << name() << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
surfPatchIdentifier::write(os);
|
||||
surfRegionIdentifier::write(os);
|
||||
os.writeKeyword("nFaces") << size() << 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 * * * * * * * * * * * * * //
|
||||
|
||||
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
|
||||
(
|
||||
(geometricType() == p.geometricType())
|
||||
&& (size() == p.size())
|
||||
&& (start() == p.start())
|
||||
(geometricType() == reg.geometricType())
|
||||
&& (size() == reg.size())
|
||||
&& (start() == reg.start())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * 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;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfGroup& p)
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const surfRegion& reg)
|
||||
{
|
||||
p.write(os);
|
||||
os.check("Ostream& operator<<(Ostream& f, const surfGroup& p");
|
||||
reg.write(os);
|
||||
os.check("Ostream& operator<<(Ostream&, const surfRegion&");
|
||||
return os;
|
||||
}
|
||||
|
||||
@ -23,23 +23,24 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::surfGroup
|
||||
Foam::surfRegion
|
||||
|
||||
Description
|
||||
'Patch' on surface as subset of triSurface.
|
||||
A region on a meshed surface.
|
||||
Similar in concept to a faceZone on the surface.
|
||||
|
||||
SourceFiles
|
||||
surfGroup.C
|
||||
surfRegion.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfGroup_H
|
||||
#define surfGroup_H
|
||||
#ifndef surfRegion_H
|
||||
#define surfRegion_H
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
#include "className.H"
|
||||
#include "surfPatchIdentifier.H"
|
||||
#include "surfRegionIdentifier.H"
|
||||
#include "autoPtr.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
@ -50,18 +51,18 @@ namespace Foam
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class surfGroup;
|
||||
class surfRegion;
|
||||
|
||||
Istream& operator>>(Istream&, surfGroup&);
|
||||
Ostream& operator<<(Ostream&, const surfGroup&);
|
||||
Istream& operator>>(Istream&, surfRegion&);
|
||||
Ostream& operator<<(Ostream&, const surfRegion&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfGroup Declaration
|
||||
Class surfRegion Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfGroup
|
||||
class surfRegion
|
||||
:
|
||||
public surfPatchIdentifier
|
||||
public surfRegionIdentifier
|
||||
{
|
||||
// Private data
|
||||
|
||||
@ -74,16 +75,16 @@ class surfGroup
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
ClassName("surfGroup");
|
||||
ClassName("surfRegion");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
surfGroup();
|
||||
surfRegion();
|
||||
|
||||
//- Construct from components
|
||||
surfGroup
|
||||
surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const label size,
|
||||
@ -93,10 +94,10 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
surfGroup(Istream& is, const label index);
|
||||
surfRegion(Istream& is, const label index);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfGroup
|
||||
surfRegion
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
@ -104,48 +105,48 @@ public:
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
surfGroup(const surfGroup&);
|
||||
surfRegion(const surfRegion&);
|
||||
|
||||
//- Construct from another patch, resetting the index
|
||||
surfGroup(const surfGroup&, const label index);
|
||||
//- Construct from another region, resetting the index
|
||||
surfRegion(const surfRegion&, const label index);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<surfGroup> clone() const
|
||||
autoPtr<surfRegion> clone() const
|
||||
{
|
||||
notImplemented("autoPtr<surfGroup> clone() const");
|
||||
return autoPtr<surfGroup>(NULL);
|
||||
notImplemented("autoPtr<surfRegion> clone() const");
|
||||
return autoPtr<surfRegion>(NULL);
|
||||
}
|
||||
|
||||
static autoPtr<surfGroup> New(Istream& is)
|
||||
static autoPtr<surfRegion> New(Istream& is)
|
||||
{
|
||||
word name(is);
|
||||
dictionary dict(is);
|
||||
|
||||
return autoPtr<surfGroup>(new surfGroup(name, dict, 0));
|
||||
return autoPtr<surfRegion>(new surfRegion(name, dict, 0));
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Return start label of this patch in the face list
|
||||
//- Return start label of this region in the face list
|
||||
label& start()
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
//- Return size of this patch in the face list
|
||||
//- Return size of this region in the face list
|
||||
label size() const
|
||||
{
|
||||
return size_;
|
||||
}
|
||||
|
||||
//- Return size of this patch in the face list
|
||||
//- Return size of this region in the face list
|
||||
label& size()
|
||||
{
|
||||
return size_;
|
||||
@ -160,15 +161,15 @@ public:
|
||||
|
||||
// Member Operators
|
||||
|
||||
bool operator!=(const surfGroup&) const;
|
||||
bool operator!=(const surfRegion&) const;
|
||||
|
||||
//- compare.
|
||||
bool operator==(const surfGroup&) const;
|
||||
bool operator==(const surfRegion&) const;
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>>(Istream&, surfGroup&);
|
||||
friend Ostream& operator<<(Ostream&, const surfGroup&);
|
||||
friend Istream& operator>>(Istream&, surfRegion&);
|
||||
friend Ostream& operator<<(Ostream&, const surfRegion&);
|
||||
};
|
||||
|
||||
|
||||
@ -24,71 +24,71 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfGroupIOList.H"
|
||||
#include "surfRegionIOList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::surfGroupIOList, 0);
|
||||
defineTypeNameAndDebug(Foam::surfRegionIOList, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfGroupIOList::surfGroupIOList
|
||||
Foam::surfRegionIOList::surfRegionIOList
|
||||
(
|
||||
const IOobject& io
|
||||
)
|
||||
:
|
||||
surfGroupList(),
|
||||
surfRegionList(),
|
||||
regIOobject(io)
|
||||
{
|
||||
Foam::string functionName =
|
||||
"surfGroupIOList::surfGroupIOList"
|
||||
"surfRegionIOList::surfRegionIOList"
|
||||
"(const IOobject& io)";
|
||||
|
||||
|
||||
if (readOpt() == IOobject::MUST_READ)
|
||||
{
|
||||
surfGroupList& patches = *this;
|
||||
surfRegionList& regions = *this;
|
||||
|
||||
// read polyPatchList
|
||||
Istream& is = readStream(typeName);
|
||||
|
||||
PtrList<entry> patchEntries(is);
|
||||
patches.setSize(patchEntries.size());
|
||||
PtrList<entry> dictEntries(is);
|
||||
regions.setSize(dictEntries.size());
|
||||
|
||||
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"));
|
||||
|
||||
patches[patchI] = surfGroup
|
||||
regions[regionI] = surfRegion
|
||||
(
|
||||
patchEntries[patchI].keyword(),
|
||||
patchSize,
|
||||
dictEntries[regionI].keyword(),
|
||||
regionSize,
|
||||
startFaceI,
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
word geoType;
|
||||
if (dict.readIfPresent("geometricType", geoType))
|
||||
{
|
||||
patches[patchI].geometricType() = geoType;
|
||||
regions[regionI].geometricType() = geoType;
|
||||
}
|
||||
|
||||
if (startFaceI != faceI)
|
||||
{
|
||||
FatalErrorIn(functionName)
|
||||
<< "Patches are not ordered. Start of patch " << patchI
|
||||
<< " does not correspond to sum of preceding patches."
|
||||
<< "Regions are not ordered. Start of region " << regionI
|
||||
<< " does not correspond to sum of preceding regions."
|
||||
<< endl
|
||||
<< "while reading " << io.objectPath()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
faceI += patchSize;
|
||||
faceI += regionSize;
|
||||
}
|
||||
|
||||
// Check state of IOstream
|
||||
@ -99,20 +99,20 @@ Foam::surfGroupIOList::surfGroupIOList
|
||||
}
|
||||
|
||||
// Construct from IOObject
|
||||
Foam::surfGroupIOList::surfGroupIOList
|
||||
Foam::surfRegionIOList::surfRegionIOList
|
||||
(
|
||||
const IOobject& io,
|
||||
const surfGroupList& patches
|
||||
const surfRegionList& regions
|
||||
)
|
||||
:
|
||||
surfGroupList(patches),
|
||||
surfRegionList(regions),
|
||||
regIOobject(io)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfGroupIOList::~surfGroupIOList()
|
||||
Foam::surfRegionIOList::~surfRegionIOList()
|
||||
{}
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@ Foam::surfGroupIOList::~surfGroupIOList()
|
||||
|
||||
|
||||
// writeData member function required by regIOobject
|
||||
bool Foam::surfGroupIOList::writeData(Ostream& os) const
|
||||
bool Foam::surfRegionIOList::writeData(Ostream& os) const
|
||||
{
|
||||
os << *this;
|
||||
return os.good();
|
||||
@ -129,13 +129,13 @@ bool Foam::surfGroupIOList::writeData(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * 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;
|
||||
@ -23,20 +23,20 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::surfGroupIOList
|
||||
Foam::surfRegionIOList
|
||||
|
||||
Description
|
||||
IOobject for a surfGroupList
|
||||
IOobject for a surfRegionList
|
||||
|
||||
SourceFiles
|
||||
surfGroupIOList.C
|
||||
surfRegionIOList.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfGroupIOList_H
|
||||
#define surfGroupIOList_H
|
||||
#ifndef surfRegionIOList_H
|
||||
#define surfRegionIOList_H
|
||||
|
||||
#include "surfGroupList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "regIOobject.H"
|
||||
#include "faceList.H"
|
||||
#include "className.H"
|
||||
@ -49,12 +49,12 @@ namespace Foam
|
||||
// Forward declaration of classes
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfGroupIOList Declaration
|
||||
Class surfRegionIOList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfGroupIOList
|
||||
class surfRegionIOList
|
||||
:
|
||||
public surfGroupList,
|
||||
public surfRegionList,
|
||||
public regIOobject
|
||||
{
|
||||
// Private data
|
||||
@ -63,29 +63,29 @@ class surfGroupIOList
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
surfGroupIOList(const surfGroupIOList&);
|
||||
surfRegionIOList(const surfRegionIOList&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const surfGroupIOList&);
|
||||
void operator=(const surfRegionIOList&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("surfGroupIOList");
|
||||
TypeName("surfRegionIOList");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from IOobject
|
||||
explicit surfGroupIOList(const IOobject& io);
|
||||
explicit surfRegionIOList(const IOobject&);
|
||||
|
||||
//- Construct from IOobject
|
||||
surfGroupIOList(const IOobject& io, const surfGroupList&);
|
||||
surfRegionIOList(const IOobject&, const surfRegionList&);
|
||||
|
||||
// Destructor
|
||||
|
||||
~surfGroupIOList();
|
||||
~surfRegionIOList();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -102,7 +102,7 @@ public:
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const surfGroupIOList&);
|
||||
friend Ostream& operator<<(Ostream&, const surfRegionIOList&);
|
||||
};
|
||||
|
||||
|
||||
@ -23,17 +23,18 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
Foam::surfGroupList
|
||||
Foam::surfRegionList
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfGroupList_H
|
||||
#define surfGroupList_H
|
||||
#ifndef surfRegionList_H
|
||||
#define surfRegionList_H
|
||||
|
||||
#include "surfGroup.H"
|
||||
#include "surfRegion.H"
|
||||
#include "List.H"
|
||||
#include "surfRegionIdentifierList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -42,7 +43,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef List<surfGroup> surfGroupList;
|
||||
typedef List<surfRegion> surfRegionList;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -24,14 +24,14 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfPatchIdentifier.H"
|
||||
#include "surfRegionIdentifier.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfPatchIdentifier::surfPatchIdentifier()
|
||||
Foam::surfRegionIdentifier::surfRegionIdentifier()
|
||||
:
|
||||
name_(word::null),
|
||||
boundaryIndex_(0),
|
||||
@ -39,7 +39,7 @@ Foam::surfPatchIdentifier::surfPatchIdentifier()
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const label index,
|
||||
@ -52,7 +52,7 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
{}
|
||||
|
||||
|
||||
Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
Foam::surfRegionIdentifier::surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
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
|
||||
)
|
||||
:
|
||||
@ -79,14 +79,14 @@ Foam::surfPatchIdentifier::surfPatchIdentifier
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::surfPatchIdentifier::~surfPatchIdentifier()
|
||||
Foam::surfRegionIdentifier::~surfRegionIdentifier()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
void Foam::surfPatchIdentifier::write(Ostream& os) const
|
||||
void Foam::surfRegionIdentifier::write(Ostream& os) const
|
||||
{
|
||||
if (geometricType_.size())
|
||||
{
|
||||
@ -98,18 +98,18 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
// bool Foam::surfPatchIdentifier::operator!=
|
||||
// bool Foam::surfRegionIdentifier::operator!=
|
||||
// (
|
||||
// const surfPatchIdentifier& p
|
||||
// const surfRegionIdentifier& p
|
||||
// ) const
|
||||
// {
|
||||
// return !(*this == p);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// bool Foam::surfPatchIdentifier::operator==
|
||||
// bool Foam::surfRegionIdentifier::operator==
|
||||
// (
|
||||
// const surfPatchIdentifier& p
|
||||
// const surfRegionIdentifier& p
|
||||
// ) const
|
||||
// {
|
||||
// return geometricType() == p.geometricType() && name() == p.name();
|
||||
@ -118,7 +118,7 @@ void Foam::surfPatchIdentifier::write(Ostream& os) const
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||
|
||||
// Foam::Istream& Foam::operator>>(Istream& is, surfPatchIdentifier& p)
|
||||
// Foam::Istream& Foam::operator>>(Istream& is, surfRegionIdentifier& p)
|
||||
// {
|
||||
// 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);
|
||||
os.check
|
||||
(
|
||||
"Ostream& operator<<(Ostream&, const surfPatchIdentifier&)"
|
||||
"Ostream& operator<<(Ostream&, const surfRegionIdentifier&)"
|
||||
);
|
||||
return os;
|
||||
}
|
||||
@ -23,19 +23,23 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::surfPatchIdentifier
|
||||
Foam::surfRegionIdentifier
|
||||
|
||||
Description
|
||||
Like patchIdentifier but for surfaces with "geometricType" rather
|
||||
than "physicalType".
|
||||
An identifier for a region on a meshed surface.
|
||||
|
||||
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
|
||||
surfPatchIdentifier.C
|
||||
surfRegionIdentifier.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfPatchIdentifier_H
|
||||
#define surfPatchIdentifier_H
|
||||
#ifndef surfRegionIdentifier_H
|
||||
#define surfRegionIdentifier_H
|
||||
|
||||
#include "word.H"
|
||||
#include "label.H"
|
||||
@ -50,24 +54,24 @@ class dictionary;
|
||||
|
||||
// Forward declaration of friend functions and operators
|
||||
|
||||
class surfPatchIdentifier;
|
||||
Ostream& operator<<(Ostream&, const surfPatchIdentifier&);
|
||||
class surfRegionIdentifier;
|
||||
Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class surfPatchIdentifier Declaration
|
||||
Class surfRegionIdentifier Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class surfPatchIdentifier
|
||||
class surfRegionIdentifier
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of patch
|
||||
//- Name of region
|
||||
word name_;
|
||||
|
||||
//- Index of patch in boundary
|
||||
//- Index of region in surface mesh
|
||||
label boundaryIndex_;
|
||||
|
||||
//- Type name of patch
|
||||
//- Type name of region
|
||||
mutable word geometricType_;
|
||||
|
||||
public:
|
||||
@ -75,10 +79,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
surfPatchIdentifier();
|
||||
surfRegionIdentifier();
|
||||
|
||||
//- Construct from components
|
||||
surfPatchIdentifier
|
||||
surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const label index,
|
||||
@ -87,24 +91,24 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
surfPatchIdentifier
|
||||
surfRegionIdentifier
|
||||
(
|
||||
const word& name,
|
||||
const dictionary&,
|
||||
const label index
|
||||
);
|
||||
|
||||
//- Construct from another patch, resetting the index
|
||||
surfPatchIdentifier
|
||||
//- Construct from another region identifier, resetting the index
|
||||
surfRegionIdentifier
|
||||
(
|
||||
const surfPatchIdentifier&,
|
||||
const surfRegionIdentifier&,
|
||||
const label index
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~surfPatchIdentifier();
|
||||
virtual ~surfRegionIdentifier();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -121,42 +125,42 @@ public:
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Return the geometric type of the patch
|
||||
//- Return the geometric type of the region
|
||||
const word& geometricType() const
|
||||
{
|
||||
return geometricType_;
|
||||
}
|
||||
|
||||
//- Return the geometric type of the patch for modification
|
||||
//- Return the geometric type of the region for modification
|
||||
word& 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
|
||||
{
|
||||
return boundaryIndex_;
|
||||
}
|
||||
|
||||
//- Write surfPatchIdentifier as a dictionary
|
||||
//- Write surfRegionIdentifier as a dictionary
|
||||
void write(Ostream&) const;
|
||||
|
||||
//- Write surfPatchIdentifier as a dictionary
|
||||
//- Write surfRegionIdentifier as a dictionary
|
||||
// void writeDict(Ostream&) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
// bool operator!=(const surfPatchIdentifier&) const;
|
||||
// bool operator!=(const surfRegionIdentifier&) const;
|
||||
//
|
||||
// //- compare.
|
||||
// bool operator==(const surfPatchIdentifier&) const;
|
||||
// bool operator==(const surfRegionIdentifier&) const;
|
||||
|
||||
// Ostream Operator
|
||||
|
||||
friend Ostream& operator<<(Ostream&, const surfPatchIdentifier&);
|
||||
// friend Istream& operator>>(Istream&, surfPatchIdentifier&);
|
||||
friend Ostream& operator<<(Ostream&, const surfRegionIdentifier&);
|
||||
// friend Istream& operator>>(Istream&, surfRegionIdentifier&);
|
||||
};
|
||||
|
||||
|
||||
@ -23,16 +23,16 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Typedef
|
||||
Foam::surfPatchIdentifierList
|
||||
Foam::surfRegionIdentifierList
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef surfPatchIdentifierList_H
|
||||
#define surfPatchIdentifierList_H
|
||||
#ifndef surfRegionIdentifierList_H
|
||||
#define surfRegionIdentifierList_H
|
||||
|
||||
#include "surfPatchIdentifier.H"
|
||||
#include "surfRegionIdentifier.H"
|
||||
#include "List.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -42,7 +42,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef List<surfPatchIdentifier> surfPatchIdentifierList;
|
||||
typedef List<surfRegionIdentifier> surfRegionIdentifierList;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -99,42 +99,42 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// # of kids is the # of patches
|
||||
// # of kids is the # of regions
|
||||
args = cueToOrDie(is, "kids");
|
||||
label nPatches = parse<int>(args);
|
||||
label nRegions = parse<int>(args);
|
||||
|
||||
// Start of vertices for object/patch
|
||||
label patchVertOffset = 0;
|
||||
// Start of vertices for object/region
|
||||
label vertexOffset = 0;
|
||||
|
||||
DynamicList<point> dynPoints;
|
||||
DynamicList<Face> dynFaces;
|
||||
List<word> names(nPatches);
|
||||
List<label> sizes(nPatches, 0);
|
||||
List<word> names(nRegions);
|
||||
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
|
||||
label nPatchPoints = 0;
|
||||
// number of vertices for this region
|
||||
label nRegionPoints = 0;
|
||||
vector location(pTraits<vector>::zero);
|
||||
// tensor rotation(I);
|
||||
|
||||
// Read all info for current patch
|
||||
// Read all info for current region
|
||||
while (is.good())
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"fileFormats::AC3DsurfaceFormat::read(const fileName&)"
|
||||
)
|
||||
<< "Did not read up to \"kids 0\" while reading patch "
|
||||
<< patchI << " from file " << filename
|
||||
<< "Did not read up to \"kids 0\" while reading region "
|
||||
<< regionI << " from file " << filename
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
string str = parse<string>(args);
|
||||
string::stripInvalid<word>(str);
|
||||
|
||||
names[patchI] = str;
|
||||
names[regionI] = str;
|
||||
}
|
||||
else if (cmd == "rot")
|
||||
{
|
||||
@ -164,7 +164,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
)
|
||||
<< "rot (rotation tensor) command not implemented"
|
||||
<< "Line:" << cmd << ' ' << args << endl
|
||||
<< "while reading patch " << patchI << endl;
|
||||
<< "while reading region " << regionI << endl;
|
||||
}
|
||||
else if (cmd == "loc")
|
||||
{
|
||||
@ -179,9 +179,9 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
else if (cmd == "numvert")
|
||||
{
|
||||
// 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);
|
||||
IStringStream lineStream(line);
|
||||
@ -202,8 +202,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
{
|
||||
static string errorMsg =
|
||||
string(" while reading face ")
|
||||
+ Foam::name(faceI) + " on patch "
|
||||
+ Foam::name(patchI)
|
||||
+ Foam::name(faceI) + " on region "
|
||||
+ Foam::name(regionI)
|
||||
+ " from file " + filename;
|
||||
|
||||
cueToOrDie(is, "SURF", errorMsg);
|
||||
@ -216,7 +216,7 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
forAll(verts, vertI)
|
||||
{
|
||||
is.getLine(line);
|
||||
verts[vertI] = parse<int>(line) + patchVertOffset;
|
||||
verts[vertI] = parse<int>(line) + vertexOffset;
|
||||
}
|
||||
|
||||
UList<label>& f = static_cast<UList<label>&>(verts);
|
||||
@ -230,23 +230,23 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
label fp2 = (fp1 + 1) % f.size();
|
||||
|
||||
dynFaces.append(triFace(f[0], f[fp1], f[fp2]));
|
||||
sizes[patchI]++;
|
||||
sizes[regionI]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dynFaces.append(Face(f));
|
||||
sizes[patchI]++;
|
||||
sizes[regionI]++;
|
||||
}
|
||||
}
|
||||
|
||||
// Done the current patch.
|
||||
// Done the current region.
|
||||
// Increment the offset vertices are stored at
|
||||
patchVertOffset += nPatchPoints;
|
||||
vertexOffset += nRegionPoints;
|
||||
}
|
||||
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);
|
||||
|
||||
if (nKids != 0)
|
||||
@ -257,11 +257,11 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
)
|
||||
<< "Can only read objects without kids."
|
||||
<< " Encountered " << nKids << " kids when"
|
||||
<< " reading patch " << patchI
|
||||
<< " reading region " << regionI
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// Done reading current patch
|
||||
// Done reading current region
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -271,8 +271,8 @@ bool Foam::fileFormats::AC3DsurfaceFormat<Face>::read
|
||||
this->storedPoints().transfer(dynPoints);
|
||||
this->storedFaces().transfer(dynFaces);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(sizes, names, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(sizes, names, true);
|
||||
this->stitchFaces(SMALL);
|
||||
return true;
|
||||
}
|
||||
@ -287,16 +287,16 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
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
|
||||
<< "name \"" << p.name() << '"' << endl;
|
||||
<< "name \"" << reg.name() << '"' << endl;
|
||||
|
||||
// Temporary PrimitivePatch to calculate compact points & faces
|
||||
// use 'UList' to avoid allocations!
|
||||
@ -317,12 +317,12 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
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
|
||||
<< "mat " << patchI << nl
|
||||
<< "mat " << regionI << nl
|
||||
<< "refs " << f.size() << nl;
|
||||
|
||||
forAll(f, fp)
|
||||
@ -344,25 +344,25 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
writeHeader(os, patchLst);
|
||||
writeHeader(os, regionLst);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const surfGroup& p = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "OBJECT poly" << nl
|
||||
<< "name \"" << p.name() << '"' << endl;
|
||||
<< "name \"" << reg.name() << '"' << endl;
|
||||
|
||||
// Create patch with only patch faces included for ease of addressing
|
||||
boolList include(surf.size(), false);
|
||||
// Create region with only region faces included for ease of addressing
|
||||
labelHashSet include(surf.size());
|
||||
|
||||
forAll(p, patchFaceI)
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const label faceI = faceMap[faceIndex++];
|
||||
include[faceI] = true;
|
||||
include.insert(faceI);
|
||||
}
|
||||
|
||||
UnsortedMeshedSurface<Face> subm = surf.subsetMesh(include);
|
||||
@ -379,12 +379,12 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
|
||||
|
||||
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
|
||||
<< "mat " << patchI << nl
|
||||
<< "mat " << regionI << nl
|
||||
<< "refs " << f.size() << nl;
|
||||
|
||||
forAll(f, fp)
|
||||
|
||||
@ -31,7 +31,7 @@ Description
|
||||
http://www.inivis.com/ac3d/man/ac3dfileformat.html
|
||||
|
||||
Note
|
||||
The faces are already organized as patches.
|
||||
The faces are already organized as regions.
|
||||
The output is always sorted by regions.
|
||||
|
||||
SourceFiles
|
||||
|
||||
@ -116,12 +116,12 @@ Foam::string Foam::fileFormats::AC3DsurfaceFormatCore::cueToOrDie
|
||||
void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
||||
(
|
||||
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.
|
||||
// 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
|
||||
static scalar colourMap[] =
|
||||
@ -139,14 +139,12 @@ void Foam::fileFormats::AC3DsurfaceFormatCore::writeHeader
|
||||
// Write header. Define materials.
|
||||
os << "AC3Db" << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
const word& pName = patchLst[patchI].name();
|
||||
|
||||
label colourI = patchI % 8;
|
||||
label colourI = regionI % 8;
|
||||
label colourCompI = 3 * colourI;
|
||||
|
||||
os << "MATERIAL \"" << pName << "Mat\" rgb "
|
||||
os << "MATERIAL \"" << regionLst[regionI].name() << "Mat\" rgb "
|
||||
<< colourMap[colourCompI] << ' ' << colourMap[colourCompI+1]
|
||||
<< ' ' << colourMap[colourCompI+2]
|
||||
<< " 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
|
||||
<< "kids " << patchLst.size() << endl;
|
||||
<< "kids " << regionLst.size() << endl;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -49,7 +49,7 @@ namespace fileFormats
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AC3DfileFormat Declaration
|
||||
Class AC3DfileFormat Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class AC3DsurfaceFormatCore
|
||||
@ -77,7 +77,7 @@ protected:
|
||||
);
|
||||
|
||||
//- Write header with materials
|
||||
static void writeHeader(Ostream&, const List<surfGroup>&);
|
||||
static void writeHeader(Ostream&, const UList<surfRegion>&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -63,40 +63,40 @@ bool Foam::fileFormats::FTRsurfaceFormat<Face>::read
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
List<ftrPatch> readPatches(is);
|
||||
List<ftrPatch> ftrPatches(is);
|
||||
|
||||
// read points directly
|
||||
is >> this->storedPoints();
|
||||
|
||||
// read faces with keys
|
||||
List<Keyed<triFace> > readFaces(is);
|
||||
// faces read with keys
|
||||
List<Keyed<triFace> > facesRead(is);
|
||||
|
||||
List<Face> faceLst(readFaces.size());
|
||||
List<label> regionLst(readFaces.size());
|
||||
List<Face> faceLst(facesRead.size());
|
||||
List<label> regionIds(facesRead.size());
|
||||
|
||||
// disentangle faces/keys - already triangulated
|
||||
forAll(readFaces, faceI)
|
||||
forAll(facesRead, faceI)
|
||||
{
|
||||
// unfortunately cannot transfer to save memory
|
||||
faceLst[faceI] = readFaces[faceI];
|
||||
regionLst[faceI] = readFaces[faceI].key();
|
||||
faceLst[faceI] = facesRead[faceI];
|
||||
regionIds[faceI] = facesRead[faceI].key();
|
||||
}
|
||||
|
||||
this->storedFaces().transfer(faceLst);
|
||||
this->storedRegions().transfer(regionLst);
|
||||
this->storedRegionIds().transfer(regionIds);
|
||||
|
||||
// cast ftrPatch into new form
|
||||
List<surfPatchIdentifier> newPatches(readPatches.size());
|
||||
forAll(newPatches, patchI)
|
||||
// change ftrPatch into surfRegionIdentifier
|
||||
List<surfRegionIdentifier> newRegions(ftrPatches.size());
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
newPatches[patchI] = surfPatchIdentifier
|
||||
newRegions[regionI] = surfRegionIdentifier
|
||||
(
|
||||
readPatches[patchI].name(),
|
||||
patchI
|
||||
ftrPatches[regionI].name(),
|
||||
regionI
|
||||
);
|
||||
}
|
||||
|
||||
this->storedPatches().transfer(newPatches);
|
||||
this->storedRegionToc().transfer(newRegions);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -80,13 +80,13 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
|
||||
|
||||
// write directly into the lists:
|
||||
pointField& pointLst = this->storedPoints();
|
||||
List<Face>& faceLst = this->storedFaces();
|
||||
List<label>& regionLst = this->storedRegions();
|
||||
pointField& pointLst = this->storedPoints();
|
||||
List<Face>& faceLst = this->storedFaces();
|
||||
List<label>& regionIds = this->storedRegionIds();
|
||||
|
||||
pointLst.setSize(nPoints);
|
||||
faceLst.setSize(nElems);
|
||||
regionLst.setSize(nElems);
|
||||
regionIds.setSize(nElems);
|
||||
|
||||
// Read points
|
||||
forAll(pointLst, pointI)
|
||||
@ -118,7 +118,7 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
|
||||
|
||||
// Read triangles. Convert references to edges into pointlabels
|
||||
label maxPatch = 0;
|
||||
label maxRegion = 0;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
label e0Label, e1Label, e2Label;
|
||||
@ -138,9 +138,9 @@ bool Foam::fileFormats::GTSsurfaceFormat<Face>::read
|
||||
if (!lineStream.bad())
|
||||
{
|
||||
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);
|
||||
regionLst[faceI] = regionI;
|
||||
regionIds[faceI] = regionI;
|
||||
}
|
||||
|
||||
|
||||
List<surfPatchIdentifier> newPatches(maxPatch+1);
|
||||
forAll(newPatches, patchI)
|
||||
List<surfRegionIdentifier> newRegions(maxRegion+1);
|
||||
forAll(newRegions, regionI)
|
||||
{
|
||||
newPatches[patchI] = surfPatchIdentifier
|
||||
newRegions[regionI] = surfRegionIdentifier
|
||||
(
|
||||
"patch" + ::Foam::name(patchI),
|
||||
patchI
|
||||
"region" + ::Foam::name(regionI),
|
||||
regionI
|
||||
);
|
||||
}
|
||||
|
||||
this->storedPatches().transfer(newPatches);
|
||||
this->storedRegionToc().transfer(newRegions);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -230,13 +230,12 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
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
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
// just issue a warning and get out
|
||||
//
|
||||
if (!surf.isTri())
|
||||
{
|
||||
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
|
||||
<< "# Regions:" << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# " << patchI << " "
|
||||
<< patchLst[patchI].name() << nl;
|
||||
os << "# " << regionI << " "
|
||||
<< regionLst[regionI].name() << nl;
|
||||
}
|
||||
os << "#" << endl;
|
||||
|
||||
@ -301,18 +300,18 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
const labelListList& faceEs = surf.faceEdges();
|
||||
|
||||
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++];
|
||||
|
||||
os << fEdges[0] + 1 << ' '
|
||||
<< fEdges[1] + 1 << ' '
|
||||
<< fEdges[2] + 1 << ' '
|
||||
<< patchI << endl;
|
||||
<< regionI << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -327,8 +326,8 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const List<surfPatchIdentifier>& patchInfo = surf.patches();
|
||||
const List<label>& regionIds = surf.regionIds();
|
||||
const List<surfRegionIdentifier>& regionToc = surf.regionToc();
|
||||
|
||||
// check if output triangulation would be required
|
||||
// It is too annoying to triangulate on-the-fly
|
||||
@ -357,18 +356,14 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
}
|
||||
}
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
|
||||
|
||||
// Write header, print patch names as comment
|
||||
// Write header, print region names as comment
|
||||
os << "# GTS file" << nl
|
||||
<< "# Regions:" << nl;
|
||||
|
||||
forAll(patchInfo, patchI)
|
||||
forAll(regionToc, regionI)
|
||||
{
|
||||
os << "# " << patchI << " "
|
||||
<< patchInfo[patchI].name() << nl;
|
||||
os << "# " << regionI << " "
|
||||
<< regionToc[regionI].name() << nl;
|
||||
}
|
||||
os << "#" << endl;
|
||||
|
||||
@ -409,7 +404,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
|
||||
os << fEdges[0] + 1 << ' '
|
||||
<< fEdges[1] + 1 << ' '
|
||||
<< fEdges[2] + 1 << ' '
|
||||
<< regionLst[faceI] << endl;
|
||||
<< regionIds[faceI] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ Class
|
||||
|
||||
Description
|
||||
Provide a means of reading/writing GTS format.
|
||||
The output is never sorted by patch.
|
||||
The output is never sorted by region.
|
||||
|
||||
SourceFiles
|
||||
GTSsurfaceFormat.C
|
||||
|
||||
@ -85,7 +85,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
// Ansa tags. Denoted by $ANSA_NAME.
|
||||
// These will appear just before the first use of a type.
|
||||
// We read them and store the PSHELL types which are used to name
|
||||
// the patches.
|
||||
// the regions.
|
||||
label ansaId = -1;
|
||||
word ansaType, ansaName;
|
||||
|
||||
@ -211,7 +211,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
fTri[1] = readLabel(IStringStream(line.substr(32,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);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
@ -227,7 +227,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
regionI = dynSizes.size();
|
||||
lookup.insert(groupId, regionI);
|
||||
dynSizes.append(0);
|
||||
// Info<< "patch" << regionI << " => group " << groupId <<endl;
|
||||
// Info<< "region" << regionI << " => group " << groupId <<endl;
|
||||
}
|
||||
|
||||
dynFaces.append(fTri);
|
||||
@ -245,7 +245,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
fQuad[2] = readLabel(IStringStream(line.substr(40,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);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
@ -261,7 +261,7 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
regionI = dynSizes.size();
|
||||
lookup.insert(groupId, regionI);
|
||||
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")
|
||||
{
|
||||
// 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))());
|
||||
|
||||
if (groupId == ansaId && ansaType == "PSHELL")
|
||||
@ -370,29 +370,29 @@ bool Foam::fileFormats::NASsurfaceFormat<Face>::read
|
||||
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());
|
||||
forAllConstIter(Map<label>, lookup, iter)
|
||||
{
|
||||
const label patchI = iter();
|
||||
const label groupI = iter.key();
|
||||
const label regionI = iter();
|
||||
const label groupI = iter.key();
|
||||
|
||||
Map<word>::const_iterator fnd = nameLookup.find(groupI);
|
||||
if (fnd != nameLookup.end())
|
||||
{
|
||||
names[patchI] = fnd();
|
||||
names[regionI] = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
names[patchI] = word("patch") + ::Foam::name(patchI);
|
||||
names[regionI] = word("region") + ::Foam::name(regionI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(dynSizes, names, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(dynSizes, names, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ Description
|
||||
Nastran surface reader.
|
||||
|
||||
- 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.
|
||||
- Properly handles the Nastran compact floating point notation: \n
|
||||
@verbatim
|
||||
|
||||
@ -49,7 +49,7 @@ Foam::scalar Foam::fileFormats::NASsurfaceFormatCore::parseNASCoord
|
||||
{
|
||||
exponent = -exponent;
|
||||
}
|
||||
return mantissa*pow(10, exponent);
|
||||
return mantissa * pow(10, exponent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -75,10 +75,10 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
DynamicList<label> dynSizes;
|
||||
HashTable<label> lookup;
|
||||
|
||||
// place faces without a group in patch0
|
||||
// place faces without a group in region0
|
||||
label regionI = 0;
|
||||
lookup.insert("patch0", regionI);
|
||||
dynNames.append("patch0");
|
||||
lookup.insert("region0", regionI);
|
||||
dynNames.append("region0");
|
||||
dynSizes.append(0);
|
||||
|
||||
while (is.good())
|
||||
@ -204,8 +204,8 @@ bool Foam::fileFormats::OBJsurfaceFormat<Face>::read
|
||||
|
||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(dynSizes, dynNames, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(dynSizes, dynNames, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -218,18 +218,18 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
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;
|
||||
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++];
|
||||
|
||||
@ -255,19 +255,19 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
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;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// 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++]];
|
||||
|
||||
|
||||
@ -63,14 +63,6 @@ class OBJsurfaceFormat
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OBJsurfaceFormat(const OBJsurfaceFormat<Face>&);
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
os << "# Wavefront OBJ file written " << clock::dateTime().c_str() << nl
|
||||
@ -44,13 +44,13 @@ void Foam::fileFormats::OBJsurfaceFormatCore::writeHeader
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << nFaces << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
<< "# region : " << regionLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
// Print region names as comment
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
os << "# " << regionI << " " << regionLst[regionI].name()
|
||||
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
|
||||
@ -63,7 +63,7 @@ protected:
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
const UList<surfRegion>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@ -146,7 +146,7 @@ bool Foam::fileFormats::OFFsurfaceFormat<Face>::read
|
||||
reset(pointLst.xfer(), dynFaces.xfer());
|
||||
|
||||
// no region information
|
||||
this->onePatch();
|
||||
this->oneRegion();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -161,16 +161,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
|
||||
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;
|
||||
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++]];
|
||||
|
||||
@ -181,9 +181,9 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
}
|
||||
|
||||
// add optional region information
|
||||
os << ' ' << patchI << endl;
|
||||
os << ' ' << regionI << endl;
|
||||
}
|
||||
os << "# </patch>" << endl;
|
||||
os << "# </region>" << endl;
|
||||
}
|
||||
os << "# </faces>" << endl;
|
||||
}
|
||||
@ -197,16 +197,16 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
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;
|
||||
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++];
|
||||
|
||||
@ -217,9 +217,9 @@ void Foam::fileFormats::OFFsurfaceFormat<Face>::write
|
||||
}
|
||||
|
||||
// add optional region information
|
||||
os << ' ' << patchI << endl;
|
||||
os << ' ' << regionI << endl;
|
||||
}
|
||||
os << "# </patch>" << endl;
|
||||
os << "# </region>" << endl;
|
||||
}
|
||||
os << "# </faces>" << endl;
|
||||
}
|
||||
|
||||
@ -71,14 +71,6 @@ class OFFsurfaceFormat
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
static void writeHead
|
||||
(
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const List<Face>&,
|
||||
const List<surfGroup>&
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
OFFsurfaceFormat(const OFFsurfaceFormat&);
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
// Write header
|
||||
@ -43,13 +43,13 @@ void Foam::fileFormats::OFFsurfaceFormatCore::writeHeader
|
||||
<< nl
|
||||
<< "# points : " << pointLst.size() << nl
|
||||
<< "# faces : " << nFaces << nl
|
||||
<< "# patches: " << patchLst.size() << nl;
|
||||
<< "# regions: " << regionLst.size() << nl;
|
||||
|
||||
// Print patch names as comment
|
||||
forAll(patchLst, patchI)
|
||||
// Print region names as comment
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "# " << patchI << " " << patchLst[patchI].name()
|
||||
<< " (nFaces: " << patchLst[patchI].size() << ")" << nl;
|
||||
os << "# " << regionI << " " << regionLst[regionI].name()
|
||||
<< " (nFaces: " << regionLst[regionI].size() << ")" << nl;
|
||||
}
|
||||
|
||||
os << nl
|
||||
|
||||
@ -63,7 +63,7 @@ protected:
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
const UList<surfRegion>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@ -46,14 +46,14 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
)
|
||||
{
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
writeHeader(os, surf.points(), faceLst.size());
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceIndex++];
|
||||
|
||||
@ -62,7 +62,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
{
|
||||
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());
|
||||
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], localFaceI)
|
||||
{
|
||||
const Face& f = faceLst[faceMap[faceIndex++]];
|
||||
|
||||
@ -96,7 +96,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
|
||||
{
|
||||
os << ' ' << f[fp];
|
||||
}
|
||||
os << ' ' << patchI << endl;
|
||||
os << ' ' << regionI << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -40,8 +40,7 @@ inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
||||
const label cellTableId
|
||||
)
|
||||
{
|
||||
os
|
||||
<< cellId // includes 1 offset
|
||||
os << cellId // includes 1 offset
|
||||
<< " " << starcdShellShape_ // 3(shell) shape
|
||||
<< " " << f.size()
|
||||
<< " " << cellTableId
|
||||
@ -54,9 +53,7 @@ inline void Foam::fileFormats::STARCDsurfaceFormat<Face>::writeShell
|
||||
{
|
||||
if ((count % 8) == 0)
|
||||
{
|
||||
os
|
||||
<< nl
|
||||
<< " " << cellId;
|
||||
os << nl << " " << cellId;
|
||||
}
|
||||
os << " " << f[fp] + 1;
|
||||
count++;
|
||||
@ -160,7 +157,7 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
|
||||
if (typeId == starcdShellType_)
|
||||
{
|
||||
// Convert groupID into patchID
|
||||
// Convert groupID into regionID
|
||||
Map<label>::const_iterator fnd = lookup.find(cellTableId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
@ -214,8 +211,8 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
||||
|
||||
sortFacesAndStore(dynFaces.xfer(), dynRegions.xfer(), sorted);
|
||||
|
||||
// add patches, culling empty groups
|
||||
this->addPatches(dynSizes, dynNames, true);
|
||||
// add regions, culling empty ones
|
||||
this->addRegions(dynSizes, dynNames, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -234,17 +231,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
writeHeader(os, "CELL");
|
||||
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
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++];
|
||||
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")(),
|
||||
surf.points(),
|
||||
surf.size(),
|
||||
patchLst
|
||||
regionLst
|
||||
);
|
||||
}
|
||||
|
||||
@ -275,17 +272,17 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
|
||||
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
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++]];
|
||||
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")(),
|
||||
surf.points(),
|
||||
surf.size(),
|
||||
patchLst
|
||||
regionLst
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +166,7 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
||||
Ostream& os,
|
||||
const pointField& pointLst,
|
||||
const label nFaces,
|
||||
const List<surfGroup>& patchLst
|
||||
const UList<surfRegion>& regionLst
|
||||
)
|
||||
{
|
||||
word caseName = os.name().lessExt().name();
|
||||
@ -176,10 +176,11 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeCase
|
||||
<< "! case " << caseName << nl
|
||||
<< "! ------------------------------" << nl;
|
||||
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
os << "ctable " << patchI + 1 << " shell" << nl
|
||||
<< "ctname " << patchI + 1 << " " << patchLst[patchI].name() << nl;
|
||||
os << "ctable " << regionI + 1 << " shell" << nl
|
||||
<< "ctname " << regionI + 1 << " "
|
||||
<< regionLst[regionI].name() << nl;
|
||||
}
|
||||
|
||||
os << "! ------------------------------" << nl
|
||||
|
||||
@ -70,7 +70,7 @@ protected:
|
||||
Ostream&,
|
||||
const pointField&,
|
||||
const label nFaces,
|
||||
const List<surfGroup>&
|
||||
const UList<surfRegion>&
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
@ -70,7 +70,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
const pointField& pointLst,
|
||||
const Face& f,
|
||||
const vector& norm,
|
||||
const label patchI
|
||||
const label regionI
|
||||
)
|
||||
{
|
||||
// simple triangulation about f[0].
|
||||
@ -86,7 +86,7 @@ inline void Foam::fileFormats::STLsurfaceFormat<Face>::writeShell
|
||||
p0,
|
||||
pointLst[f[fp1]],
|
||||
pointLst[f[fp2]],
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
stlTri.write(os);
|
||||
@ -104,22 +104,22 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeASCII
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
forAll(patch, patchFaceI)
|
||||
os << "solid " << reg.name() << endl;
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const label faceI = faceIndex++;
|
||||
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 vectorField& normLst = surf.faceNormals();
|
||||
|
||||
if (surf.patches().size() == 1)
|
||||
if (surf.regionToc().size() == 1)
|
||||
{
|
||||
// a single region - we can skip sorting
|
||||
os << "solid " << surf.patches()[0].name() << endl;
|
||||
os << "solid " << surf.regionToc()[0].name() << endl;
|
||||
forAll(faceLst, faceI)
|
||||
{
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
os << "endsolid " << surf.patches()[0].name() << endl;
|
||||
os << "endsolid " << surf.regionToc()[0].name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
labelList faceMap;
|
||||
List<surfGroup> patchLst = surf.sortedRegions(faceMap);
|
||||
List<surfRegion> regionLst = surf.sortedRegions(faceMap);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
// Print all faces belonging to this region
|
||||
const surfGroup& patch = patchLst[patchI];
|
||||
const surfRegion& reg = regionLst[regionI];
|
||||
|
||||
os << "solid " << patch.name() << endl;
|
||||
forAll(patch, patchFaceI)
|
||||
os << "solid " << reg.name() << endl;
|
||||
forAll(reg, localFaceI)
|
||||
{
|
||||
const label faceI = faceMap[faceIndex++];
|
||||
writeShell(os, pointLst, faceLst[faceI], normLst[faceI]);
|
||||
}
|
||||
os << "endsolid " << patch.name() << endl;
|
||||
os << "endsolid " << reg.name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,10 +177,10 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
const List<surfGroup>& patchLst = surf.patches();
|
||||
const List<surfRegion>& regionLst = surf.regions();
|
||||
|
||||
unsigned int nTris = 0;
|
||||
if (surf.isTri())
|
||||
@ -200,9 +200,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
STLsurfaceFormatCore::writeHeaderBINARY(os, nTris);
|
||||
|
||||
label faceIndex = 0;
|
||||
forAll(patchLst, patchI)
|
||||
forAll(regionLst, regionI)
|
||||
{
|
||||
forAll(patchLst[patchI], patchFaceI)
|
||||
forAll(regionLst[regionI], regionFaceI)
|
||||
{
|
||||
writeShell
|
||||
(
|
||||
@ -210,7 +210,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
pointLst,
|
||||
faceLst[faceIndex],
|
||||
normLst[faceIndex],
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
++faceIndex;
|
||||
@ -227,9 +227,9 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
const UnsortedMeshedSurface<Face>& surf
|
||||
)
|
||||
{
|
||||
const pointField& pointLst = surf.points();
|
||||
const pointField& pointLst = surf.points();
|
||||
const List<Face>& faceLst = surf.faces();
|
||||
const List<label>& regionLst = surf.regions();
|
||||
const List<label>& regionIds = surf.regionIds();
|
||||
const vectorField& normLst = surf.faceNormals();
|
||||
|
||||
unsigned int nTris = 0;
|
||||
@ -258,7 +258,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBINARY
|
||||
pointLst,
|
||||
faceLst[faceI],
|
||||
normLst[faceI],
|
||||
regionLst[faceI]
|
||||
regionIds[faceI]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -295,10 +295,10 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
// retrieve the original region information
|
||||
List<word> names(reader.names().xfer());
|
||||
List<label> sizes(reader.sizes().xfer());
|
||||
List<label> regions(reader.regions().xfer());
|
||||
List<label> regionIds(reader.regionIds().xfer());
|
||||
|
||||
// generate the (sorted) faces
|
||||
List<Face> faceLst(regions.size());
|
||||
List<Face> faceLst(regionIds.size());
|
||||
|
||||
if (reader.sorted())
|
||||
{
|
||||
@ -314,7 +314,7 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
// unsorted - determine the sorted order:
|
||||
// avoid SortableList since we discard the main list anyhow
|
||||
List<label> faceMap;
|
||||
sortedOrder(regions, faceMap);
|
||||
sortedOrder(regionIds, faceMap);
|
||||
|
||||
// generate sorted faces
|
||||
forAll(faceMap, faceI)
|
||||
@ -323,18 +323,18 @@ bool Foam::fileFormats::STLsurfaceFormat<Face>::read
|
||||
faceLst[faceI] = triFace(startPt, startPt+1, startPt+2);
|
||||
}
|
||||
}
|
||||
regions.clear();
|
||||
regionIds.clear();
|
||||
|
||||
// transfer:
|
||||
this->storedFaces().transfer(faceLst);
|
||||
|
||||
if (names.size())
|
||||
{
|
||||
this->addPatches(sizes, names);
|
||||
this->addRegions(sizes, names);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->addPatches(sizes);
|
||||
this->addRegions(sizes);
|
||||
}
|
||||
|
||||
this->stitchFaces(SMALL);
|
||||
|
||||
@ -79,7 +79,7 @@ class STLsurfaceFormat
|
||||
const pointField&,
|
||||
const Face&,
|
||||
const vector&,
|
||||
const label patchI
|
||||
const label regionI
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -417,7 +417,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readASCII
|
||||
|
||||
// transfer to normal lists
|
||||
points_.transfer(lexer.points());
|
||||
regions_.transfer(lexer.facets());
|
||||
regionIds_.transfer(lexer.facets());
|
||||
names_.transfer(lexer.names());
|
||||
sizes_.transfer(lexer.sizes());
|
||||
|
||||
|
||||
@ -142,14 +142,14 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
||||
#endif
|
||||
|
||||
points_.setSize(3*nTris);
|
||||
regions_.setSize(nTris);
|
||||
regionIds_.setSize(nTris);
|
||||
|
||||
Map<label> lookup;
|
||||
DynamicList<label> dynSizes;
|
||||
|
||||
label ptI = 0;
|
||||
label regionI = -1;
|
||||
forAll(regions_, faceI)
|
||||
forAll(regionIds_, faceI)
|
||||
{
|
||||
// Read an STL triangle
|
||||
STLtriangle stlTri(is);
|
||||
@ -179,7 +179,7 @@ bool Foam::fileFormats::STLsurfaceFormatCore::readBINARY
|
||||
dynSizes.append(0);
|
||||
}
|
||||
|
||||
regions_[faceI] = regionI;
|
||||
regionIds_[faceI] = regionI;
|
||||
dynSizes[regionI]++;
|
||||
|
||||
#ifdef DEBUG_STLBINARY
|
||||
@ -220,7 +220,7 @@ Foam::fileFormats::STLsurfaceFormatCore::STLsurfaceFormatCore
|
||||
:
|
||||
sorted_(true),
|
||||
points_(0),
|
||||
regions_(0),
|
||||
regionIds_(0),
|
||||
names_(0),
|
||||
sizes_(0)
|
||||
{
|
||||
|
||||
@ -65,7 +65,7 @@ class STLsurfaceFormatCore
|
||||
pointField points_;
|
||||
|
||||
//- The regions associated with the faces
|
||||
List<label> regions_;
|
||||
List<label> regionIds_;
|
||||
|
||||
//- The solid names, in the order of their first appearance
|
||||
List<word> names_;
|
||||
@ -124,7 +124,7 @@ public:
|
||||
{
|
||||
sorted_ = true;
|
||||
points_.clear();
|
||||
regions_.clear();
|
||||
regionIds_.clear();
|
||||
names_.clear();
|
||||
sizes_.clear();
|
||||
}
|
||||
@ -135,10 +135,10 @@ public:
|
||||
return points_;
|
||||
}
|
||||
|
||||
//- Return full access to the regions
|
||||
List<label>& regions()
|
||||
//- Return full access to the regionIds
|
||||
List<label>& regionIds()
|
||||
{
|
||||
return regions_;
|
||||
return regionIds_;
|
||||
}
|
||||
|
||||
//- The list of solid names in the order of their first appearance
|
||||
|
||||
@ -37,7 +37,6 @@ Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
//- Check if file extension corresponds to 'native' surface format
|
||||
bool
|
||||
Foam::fileFormats::surfaceFormatsCore::isNative(const word& ext)
|
||||
{
|
||||
@ -75,11 +74,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
// closest to and lower than current time
|
||||
|
||||
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;
|
||||
}
|
||||
@ -88,13 +87,13 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
// Noting that the current directory has already been searched
|
||||
// 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
|
||||
|
||||
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;
|
||||
}
|
||||
@ -129,11 +128,11 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
|
||||
// Noting that the current directory has already been searched
|
||||
// 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))
|
||||
{
|
||||
@ -166,14 +165,14 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
|
||||
}
|
||||
|
||||
|
||||
// Returns patch info.
|
||||
// Sets faceMap to the indexing according to patch numbers.
|
||||
// Patch numbers start at 0.
|
||||
Foam::surfGroupList
|
||||
Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
|
||||
// Returns region info.
|
||||
// Sets faceMap to the indexing according to region numbers.
|
||||
// Region numbers start at 0.
|
||||
Foam::surfRegionList
|
||||
Foam::fileFormats::surfaceFormatsCore::sortedRegionsById
|
||||
(
|
||||
const UList<label>& regionLst,
|
||||
const Map<word>& patchNames,
|
||||
const UList<label>& regionIds,
|
||||
const Map<word>& regionNames,
|
||||
labelList& faceMap
|
||||
)
|
||||
{
|
||||
@ -185,11 +184,11 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
|
||||
// Assuming that we have relatively fewer regions compared to the
|
||||
// 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;
|
||||
forAll(regionLst, faceI)
|
||||
forAll(regionIds, faceI)
|
||||
{
|
||||
const label regId = regionLst[faceI];
|
||||
const label regId = regionIds[faceI];
|
||||
|
||||
Map<label>::iterator fnd = lookup.find(regId);
|
||||
if (fnd != lookup.end())
|
||||
@ -202,52 +201,53 @@ Foam::fileFormats::surfaceFormatsCore::sortedPatchRegions
|
||||
}
|
||||
}
|
||||
|
||||
// step 2: assign start/size (and name) to the newPatches
|
||||
// re-use the lookup to map (regionId => patchI)
|
||||
surfGroupList patchLst(lookup.size());
|
||||
// step 2: assign start/size (and name) to the newRegions
|
||||
// re-use the lookup to map (regionId => regionI)
|
||||
surfRegionList regionLst(lookup.size());
|
||||
label start = 0;
|
||||
label patchI = 0;
|
||||
label regionI = 0;
|
||||
forAllIter(Map<label>, lookup, iter)
|
||||
{
|
||||
label regId = iter.key();
|
||||
|
||||
word name;
|
||||
Map<word>::const_iterator fnd = patchNames.find(regId);
|
||||
if (fnd != patchNames.end())
|
||||
Map<word>::const_iterator fnd = regionNames.find(regId);
|
||||
if (fnd != regionNames.end())
|
||||
{
|
||||
name = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = word("patch") + ::Foam::name(patchI);
|
||||
name = word("region") + ::Foam::name(regionI);
|
||||
}
|
||||
|
||||
patchLst[patchI] = surfGroup
|
||||
regionLst[regionI] = surfRegion
|
||||
(
|
||||
name,
|
||||
0, // initialize with zero size
|
||||
start,
|
||||
patchI
|
||||
regionI
|
||||
);
|
||||
|
||||
// increment the start for the next patch
|
||||
// and save the (regionId => patchI) mapping
|
||||
// increment the start for the next region
|
||||
// and save the (regionId => regionI) mapping
|
||||
start += iter();
|
||||
iter() = patchI++;
|
||||
iter() = regionI++;
|
||||
}
|
||||
|
||||
|
||||
// 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]];
|
||||
faceMap[faceI] = patchLst[patchI].start() + patchLst[patchI].size()++;
|
||||
label regionI = lookup[regionIds[faceI]];
|
||||
faceMap[faceI] =
|
||||
regionLst[regionI].start() + regionLst[regionI].size()++;
|
||||
}
|
||||
|
||||
// with reordered faces registered in faceMap
|
||||
return patchLst;
|
||||
return regionLst;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,11 +36,11 @@ SourceFiles
|
||||
#ifndef surfaceFormatsCore_H
|
||||
#define surfaceFormatsCore_H
|
||||
|
||||
#include "surfPatchIdentifierList.H"
|
||||
#include "surfGroupList.H"
|
||||
#include "labelList.H"
|
||||
#include "Map.H"
|
||||
#include "HashSet.H"
|
||||
#include "labelList.H"
|
||||
#include "surfRegionList.H"
|
||||
#include "surfRegionIdentifierList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -69,6 +69,7 @@ public:
|
||||
static word meshSubDir;
|
||||
|
||||
//- The file extension corresponding to 'native' surface format
|
||||
// Normally "ofs" (mnemonic: OF = OpenFOAM, S = Surface)
|
||||
static word nativeExt;
|
||||
|
||||
// Static Member Functions
|
||||
@ -91,12 +92,12 @@ public:
|
||||
//- Name of UnsortedMeshedSurface directory to use.
|
||||
static fileName findMeshName(const Time&);
|
||||
|
||||
//- Determine the sort order from the region list.
|
||||
// Returns patch list and sets faceMap to indices within faceLst
|
||||
static surfGroupList sortedPatchRegions
|
||||
//- Determine the sort order from the region ids.
|
||||
// Returns region list and sets faceMap to indices within faceLst
|
||||
static surfRegionList sortedRegionsById
|
||||
(
|
||||
const UList<label>& regionLst,
|
||||
const Map<word>& patchNames,
|
||||
const UList<label>& regionIds,
|
||||
const Map<word>& regionNames,
|
||||
labelList& faceMap
|
||||
);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user