diff --git a/applications/test/CircularBuffer/Test-CircularBuffer.C b/applications/test/CircularBuffer/Test-CircularBuffer.C index eed9b26ed1..aa62de3267 100644 --- a/applications/test/CircularBuffer/Test-CircularBuffer.C +++ b/applications/test/CircularBuffer/Test-CircularBuffer.C @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) while (buf1.size() > 2) { - (void) buf1.pop_front(); + buf1.pop_front(); } report(buf1); @@ -123,6 +123,8 @@ int main(int argc, char *argv[]) Info<< endl; } + Info<< nl << "list: " << flatOutput(buf2.list()) << nl; + Info<< "normal: " << flatOutput(buf2) << nl; buf2.reverse(); Info<< "reverse: " << flatOutput(buf2) << nl; diff --git a/applications/test/DLList/Test-DLList.C b/applications/test/DLList/Test-DLList.C index 731c0e671e..28042d0534 100644 --- a/applications/test/DLList/Test-DLList.C +++ b/applications/test/DLList/Test-DLList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -152,15 +152,15 @@ int main(int argc, char *argv[]) Info<< " => " << flatOutput(myList) << nl; { - myList.swapUp(myList.DLListBase::first()); - myList.swapUp(myList.DLListBase::last()); + myList.swapUp(myList.DLListBase::front()); + myList.swapUp(myList.DLListBase::back()); Info<< nl << "swapUp => " << flatOutput(myList) << nl; } { - myList.swapDown(myList.DLListBase::first()); - myList.swapDown(myList.DLListBase::last()); + myList.swapDown(myList.DLListBase::front()); + myList.swapDown(myList.DLListBase::back()); Info<< nl << "swapDown => " << flatOutput(myList) << nl; } diff --git a/applications/test/FixedList/Test-FixedList.C b/applications/test/FixedList/Test-FixedList.C index c8648ae05f..7e510d8c78 100644 --- a/applications/test/FixedList/Test-FixedList.C +++ b/applications/test/FixedList/Test-FixedList.C @@ -189,6 +189,12 @@ int main(int argc, char *argv[]) << " hash:" << FixedList::hasher()(list1) << nl << " hash:" << Hash>()(list1) << nl; + Info<< "get<0>: " << list1.get<0>() << nl; + Info<< "get<1>: " << list1.get<1>() << nl; + Info<< "get<2>: " << list1.get<2>() << nl; + Info<< "get<3>: " << list1.get<3>() << nl; +// Will not compile: Info<< "get<4>: " << list1.get<4>() << nl; + label a[4] = {0, 1, 2, 3}; FixedList list2(a); diff --git a/applications/test/IndirectList/Test-IndirectList.C b/applications/test/IndirectList/Test-IndirectList.C index 399d43906c..92c7b413a2 100644 --- a/applications/test/IndirectList/Test-IndirectList.C +++ b/applications/test/IndirectList/Test-IndirectList.C @@ -101,6 +101,9 @@ int main(int argc, char *argv[]) printInfo(idl1); + Info<< "list() = "; + idl1.list().writeList(Info, 0) << endl; + for (const label val : { 10, 30, 40, 50, 90, 80, 120 } ) { testFind(val, idl1); diff --git a/applications/test/PtrList/Test-PtrList.C b/applications/test/PtrList/Test-PtrList.C index d35e321d71..a8f91df9f9 100644 --- a/applications/test/PtrList/Test-PtrList.C +++ b/applications/test/PtrList/Test-PtrList.C @@ -108,7 +108,7 @@ Ostream& printAddr for (label i=0; i < len; ++i) { - os << "addr=" << name(list(i)) << nl; + os << "addr=" << Foam::name(list.get(i)) << nl; } // End delimiter @@ -140,7 +140,7 @@ Ostream& print for (label i=0; i < len; ++i) { - const T* ptr = list(i); + const T* ptr = list.get(i); if (ptr) { @@ -174,7 +174,7 @@ Ostream& print for (label i=0; i < len; ++i) { - const T* ptr = list(i); + const T* ptr = list.get(i); if (ptr) { @@ -192,7 +192,7 @@ Ostream& print for (label i=len; i < cap; ++i) { - const T* ptr = list(i); + const T* ptr = list.get(i); os << "unused " << name(ptr) << nl; } @@ -274,9 +274,9 @@ int main(int argc, char *argv[]) { DLPtrList llist1; - llist1.prepend(new Scalar(100)); - llist1.prepend(new Scalar(200)); - llist1.prepend(new Scalar(300)); + llist1.push_front(new Scalar(100)); + llist1.push_front(new Scalar(200)); + llist1.push_front(new Scalar(300)); auto citer = llist1.begin(); @@ -305,9 +305,9 @@ int main(int argc, char *argv[]) // Same but as SLPtrList { SLPtrList llist1; - llist1.prepend(new Scalar(100)); - llist1.prepend(new Scalar(200)); - llist1.prepend(new Scalar(300)); + llist1.push_front(new Scalar(100)); + llist1.push_front(new Scalar(200)); + llist1.push_front(new Scalar(300)); for (const auto& it : llist1) { @@ -334,7 +334,7 @@ int main(int argc, char *argv[]) { listApp.append(new Scalar(1.3*i)); } - listApp.emplace_append(100); + listApp.emplace_back(100); Info<< nl @@ -580,8 +580,8 @@ int main(int argc, char *argv[]) } PtrList planes; - planes.emplace_append(vector::one, vector::one); - planes.emplace_append(vector(1,2,3), vector::one); + planes.emplace_back(vector::one, vector::one); + planes.emplace_back(vector(1,2,3), vector::one); Info<< nl << "appended values" << nl; for (const plane& p : planes) @@ -594,15 +594,15 @@ int main(int argc, char *argv[]) PtrDynList dynPlanes; { - dynPlanes.emplace_append(vector::one, vector::one); - dynPlanes.emplace_append(vector(1,2,3), vector::one); + dynPlanes.emplace_back(vector::one, vector::one); + dynPlanes.emplace_back(vector(1,2,3), vector::one); dynPlanes.append(nullptr); dynPlanes.set(6, new plane(vector(2,2,1), vector::one)); dynPlanes.set(10, new plane(vector(4,5,6), vector::one)); dynPlanes.emplace(12, vector(3,2,1), vector::one); - dynPlanes.emplace_append(Zero, vector::one); + dynPlanes.emplace_back(Zero, vector::one); } Info<< nl << "PtrDynList: "; @@ -633,7 +633,7 @@ int main(int argc, char *argv[]) forAll(dynPlanes, i) { - const plane* pln = dynPlanes.set(i); + const plane* pln = dynPlanes.get(i); if (pln) { stdPlanes.set(i, new plane(*pln)); diff --git a/applications/test/boolVector/Test-boolVector.C b/applications/test/boolVector/Test-boolVector.C index 0c66d261f6..d345b55ddf 100644 --- a/applications/test/boolVector/Test-boolVector.C +++ b/applications/test/boolVector/Test-boolVector.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,7 @@ void print(const boolVector& v) << " any:" << Switch::name(v.any()) << " all:" << Switch::name(v.all()) << " none:" << Switch::name(v.none()) - << " count:" << v.count() << nl; + << " on:" << v.count() << " off:" << v.count(false) << nl; } @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) Info<< nl; { - boolVector vec{1, 0, 1}; + boolVector vec(1, 0, 1); print(vec); vec.flip(); diff --git a/applications/test/boundBox/Test-boundBox.C b/applications/test/boundBox/Test-boundBox.C index 39521e5d5a..d5952fcef5 100644 --- a/applications/test/boundBox/Test-boundBox.C +++ b/applications/test/boundBox/Test-boundBox.C @@ -34,7 +34,6 @@ Description #include "line.H" #include "Random.H" #include "treeBoundBox.H" -#include "cellModel.H" #include "bitSet.H" #include "HashSet.H" #include "ListOps.H" @@ -59,8 +58,7 @@ int main(int argc, char *argv[]) { #include "setRootCase.H" - Info<<"boundBox faces: " << boundBox::faces << nl - <<"hex faces: " << cellModel::ref(cellModel::HEX).modelFaces() << nl + Info<<"boundBox faces: " << boundBox::hexFaces() << nl <<"tree-bb faces: " << treeBoundBox::faces << nl <<"tree-bb edges: " << treeBoundBox::edges << endl; @@ -113,10 +111,8 @@ int main(int argc, char *argv[]) Info<<"enclose point " << pt << " -> " << bb << endl; // restart with same points - bb = boundBox::invertedBox; - bb.add(point(1,1,1)); - bb.add(point::zero); - bb.add(point(0,1.5,0.5)); + bb.reset(point::zero); + bb.add(point(1,1,1), point(0,1.5,0.5)); bb.add(point(5,2,-2)); Info<<"repeated " << bb << endl; diff --git a/applications/test/boundBox2/Make/files b/applications/test/boundBox2/Make/files new file mode 100644 index 0000000000..c55d6bf173 --- /dev/null +++ b/applications/test/boundBox2/Make/files @@ -0,0 +1,3 @@ +Test-boundBox2.C + +EXE = $(FOAM_USER_APPBIN)/Test-boundBox2 diff --git a/applications/test/boundBox2/Make/options b/applications/test/boundBox2/Make/options new file mode 100644 index 0000000000..18e6fe47af --- /dev/null +++ b/applications/test/boundBox2/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = */ +/* EXE_LIBS = */ diff --git a/applications/test/boundBox2/Test-boundBox2.C b/applications/test/boundBox2/Test-boundBox2.C new file mode 100644 index 0000000000..3c88e70d51 --- /dev/null +++ b/applications/test/boundBox2/Test-boundBox2.C @@ -0,0 +1,235 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Description + Test bounding box behaviour + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "polyMesh.H" +#include "line.H" +#include "Random.H" +#include "treeBoundBox.H" +#include "bitSet.H" +#include "HashSet.H" +#include "ListOps.H" + +using namespace Foam; + +//- simple helper to create a cube, given lower corner and width +boundBox cube(scalar start, scalar width) +{ + return boundBox + ( + point::uniform(start), + point::uniform(start + width) + ); +} + +//- simple helper to create a cube, given mid-point and width +boundBox cubeAt(const point& mid, scalar width) +{ + boundBox bb(mid); + bb.grow(0.5*width); + + return bb; +} + + +word faceName(direction whichFace) +{ + switch (whichFace) + { + case treeBoundBox::LEFT : return "-x"; + case treeBoundBox::RIGHT : return "+x"; + + case treeBoundBox::BOTTOM : return "-y"; + case treeBoundBox::TOP : return "+y"; + + case treeBoundBox::BACK : return "-z"; + case treeBoundBox::FRONT : return "+z"; + } + + return "??"; +} + + +word octantName(direction octant) +{ + word str("-x-y-z"); + + if (octant & treeBoundBox::RIGHTHALF) + { + str[0] = '+'; + } + if (octant & treeBoundBox::TOPHALF) + { + str[2] = '+'; + } + if (octant & treeBoundBox::FRONTHALF) + { + str[4] = '+'; + } + return str; +} + + +void testOverlaps(const treeBoundBox& bb, const treeBoundBox& searchBox) +{ + FixedList overlaps; + + for (direction octant = 0; octant < 8; ++octant) + { + overlaps[octant] = bb.subOverlaps(octant, searchBox); + } + + Info<< "box " << bb << " and " << searchBox << nl; + + Info<< "overlaps any:" << bb.overlaps(searchBox) + << " octants: " << overlaps << nl; +} + + +void testOverlaps +( + const treeBoundBox& bb, + const point& sample, + const scalar nearestDistSqr +) +{ + FixedList overlaps; + + for (direction octant = 0; octant < 8; ++octant) + { + overlaps[octant] = bb.subOverlaps(octant, sample, nearestDistSqr); + } + + Info<< "box " << bb << " and " + << sample << " distSqr:" << nearestDistSqr << nl; + + Info<< "overlaps any:" << bb.overlaps(sample, nearestDistSqr) + << " octants: " << overlaps << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + treeBoundBox bb(cube(0, 1)); + treeBoundBox sub(cube(0.1, 0.8)); + + Info<< nl + << "box: " << bb << nl; + + Info<< nl; + for (direction octant = 0; octant < 8; ++octant) + { + Info<< "octant:" << octant + << " (" << octantName(octant) << ") = " + << bb.subBbox(octant) << nl; + } + + Info<< nl; + for (direction facei = 0; facei < 6; ++facei) + { + Info<< "sub-half:" << facei + << " (" << faceName(facei) << ") = " + << bb.subHalf(facei) << nl; + } + + Info<< nl; + for (direction octant = 0; octant < 8; ++octant) + { + const point pt = sub.corner(octant); + const direction subOctant = bb.subOctant(pt); + + Info<< "point:" << pt + << " in octant " << subOctant + << " sub-box: " << bb.subBbox(subOctant) << nl; + } + + for (const scalar dist : {0.1}) + { + Info<< nl; + for (direction octant = 0; octant < 8; ++octant) + { + treeBoundBox searchBox(cubeAt(bb.corner(octant), dist)); + testOverlaps(bb, searchBox); + } + + Info<< nl; + for (direction facei = 0; facei < 6; ++facei) + { + treeBoundBox searchBox(cubeAt(bb.faceCentre(facei), dist)); + testOverlaps(bb, searchBox); + } + } + + { + treeBoundBox largerBox(bb); + largerBox.grow(0.2); + + // Checking at corners, + // larger by 0.2 in three directions: radius = 0.3464 + + for (const scalar dist : {0.1, 0.35}) + { + const scalar distSqr = sqr(dist); + + Info<< nl; + for (direction octant = 0; octant < 8; ++octant) + { + testOverlaps(bb, largerBox.corner(octant), distSqr); + } + } + + // Checking at face centres, + // larger by 0.2 in a single direction + + for (const scalar dist : {0.1, 0.25}) + { + const scalar distSqr = sqr(dist); + + Info<< nl; + for (direction facei = 0; facei < 6; ++facei) + { + testOverlaps(bb, largerBox.faceCentre(facei), distSqr); + } + } + } + + Info<< nl << "End" << nl << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/edges/Test-edges.C b/applications/test/edges/Test-edges.C index fb6e3fd409..43acfbda48 100644 --- a/applications/test/edges/Test-edges.C +++ b/applications/test/edges/Test-edges.C @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) Info<<"collapse? -> " << e4.collapse() << endl; printInfo(e4); - Info<< e3 << " connects " << e2 << " => " << e2.connects(e3) << endl; + Info<< e3 << " connects " << e2 << " => " << e2.connected(e3) << endl; labelPair labels(e3); diff --git a/applications/test/faces/Test-faces.C b/applications/test/faces/Test-faces.C index fab3d04ca1..9c8cfcea03 100644 --- a/applications/test/faces/Test-faces.C +++ b/applications/test/faces/Test-faces.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,6 +33,7 @@ Description #include "argList.H" #include "labelledTri.H" +#include "edge.H" #include "faceList.H" #include "triFaceList.H" #include "pointList.H" @@ -131,10 +132,25 @@ int main(int argc, char *argv[]) testSign(f1, points2, testPoints); Info<< nl; - triFace t1({1, 2, 3}); + // Initializer list + // triFace t1({1, 2, 3}); + + // Component-wise + { + edge e1(3, 2, 1); // Inadvertent sort!!! + Info<< "edge:" << e1 << nl; + } + + // Component-wise + triFace t1(1, 2, 3); Info<< "triFace:"; faceInfo(t1, points1); Info << nl; testSign(t1, points1, testPoints); + { + scalarField fld({0, 20, 20, 30}); + Info<< "avg:" << t1.average(pointField::null(), fld) << nl; + } + Info<< "triFace:"; faceInfo(t1, points2); Info << nl; testSign(t1, points2, testPoints); Info<< nl; diff --git a/applications/test/findCell-octree/Test-findCell-octree.C b/applications/test/findCell-octree/Test-findCell-octree.C index aa8db650aa..2210753eda 100644 --- a/applications/test/findCell-octree/Test-findCell-octree.C +++ b/applications/test/findCell-octree/Test-findCell-octree.C @@ -53,20 +53,17 @@ int main(int argc, char *argv[]) const polyMesh::cellDecomposition decompMode = polyMesh::CELL_TETS; treeBoundBox meshBb(mesh.bounds()); + treeBoundBox shiftedBb(meshBb); // Calculate typical cell related size to shift bb by. scalar typDim = meshBb.avgDim()/(2.0*Foam::cbrt(scalar(mesh.nCells()))); - treeBoundBox shiftedBb - ( - meshBb.min(), - meshBb.max() + vector(typDim, typDim, typDim) - ); + shiftedBb.max() += vector::uniform(typDim); Info<< "Mesh" << endl; Info<< " bounding box : " << meshBb << endl; Info<< " bounding box (shifted) : " << shiftedBb << endl; - Info<< " typical dimension : " << shiftedBb.typDim() << endl; + Info<< " typical dimension : " << shiftedBb.avgDim() << endl; Info<< "Initialised mesh in " << runTime.cpuTimeIncrement() << " s" << endl; diff --git a/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C b/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C index c87cf7543a..2714b60a42 100644 --- a/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C +++ b/applications/test/findSphereFeatureEdges-octree/Test-findSphereFeatureEdges-octree.C @@ -67,17 +67,10 @@ int main(int argc, char *argv[]) treeBoundBox bb(efem.points()); bb.grow(ROOTVSMALL); - labelList allEdges(identity(efem.edges().size())); - indexedOctree edgeTree ( - treeDataEdge - ( - false, // cachebb - efem.edges(), // edges - efem.points(), // points - allEdges // selected edges - ), + treeDataEdge(efem.edges(), efem.points()), // All edges + bb, // bb 8, // maxLevel 10, // leafsize diff --git a/applications/test/surfaceTree/Make/files b/applications/test/surfaceTree/Make/files new file mode 100644 index 0000000000..c877c9c1b4 --- /dev/null +++ b/applications/test/surfaceTree/Make/files @@ -0,0 +1,3 @@ +Test-surfaceTree.C + +EXE = $(FOAM_USER_APPBIN)/Test-surfaceTree diff --git a/applications/test/surfaceTree/Make/options b/applications/test/surfaceTree/Make/options new file mode 100644 index 0000000000..b6fa4bff16 --- /dev/null +++ b/applications/test/surfaceTree/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfileFormats \ + -lsurfMesh \ + -lmeshTools diff --git a/applications/test/surfaceTree/Test-surfaceTree.C b/applications/test/surfaceTree/Test-surfaceTree.C new file mode 100644 index 0000000000..e79b6431dd --- /dev/null +++ b/applications/test/surfaceTree/Test-surfaceTree.C @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + Test-surfaceTree + +Description + Simple tests for building indexedOctree etc. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "clockTime.H" +#include "MeshedSurfaces.H" +#include "indexedOctree.H" +#include "AABBTree.H" +#include "treeDataPrimitivePatch.H" +#include "Random.H" +#include "ListListOps.H" + +using namespace Foam; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Test octree building etc" + ); + + argList::noBanner(); + argList::noParallel(); + argList::addArgument("input", "The input surface file"); + + argList::addOption("maxLevel", "int", "The max level"); + argList::addOption("leafSize", "int", "The min leaf size"); + argList::addBoolOption("AABB", "AABBTree instead of indexedOctree"); + + argList args(argc, argv); + + const auto importName = args.get(1); + + const bool useAABB = args.found("AABB"); + + label maxLevel = 10; + label leafSize = 10; + + if (useAABB) + { + // May want different settings.. + } + + args.readIfPresent("maxLevel", maxLevel); + args.readIfPresent("leafSize", leafSize); + + meshedSurface surf(importName); + + Random rndGen(123456); + + treeBoundBox overallBb + ( + treeBoundBox(surf.box()).extend(rndGen, 1e-4, ROOTVSMALL) + ); + + Info<< "Surface with " << surf.size() << " faces, " + << surf.nPoints() << " points" << endl; + + + clockTime timing; + + if (useAABB) + { + AABBTree tree + ( + surf, + surf.points(), + true, // Equal bins + maxLevel, // maxLevel + leafSize // minLeafSize + ); + + Info<< "Built AABBTree, maxLevel:" << maxLevel + << " minLeaf:" << leafSize + << " with " << tree.boundBoxes().size() + << " leaves - " << timing.elapsedTime() << 's' << endl; + + { + OFstream os("AABBTree.obj"); + tree.writeOBJ(os); + + Info<< "Wrote " << os.name() << endl; + } + + // Info<< "sizes: "; + // ListListOps::subSizes + // ( + // tree.addressing(), + // identityOp{} + // ).writeList(Info) << endl; + } + else + { + indexedOctree> tree + ( + treeDataPrimitivePatch(surf, 1e-6), + overallBb, + maxLevel, // maxLevel + leafSize, // leafSize + 3.0 // duplicity + ); + + Info<< "Built octree, maxLevel:" << maxLevel + << " minLeaf:" << leafSize + << " with " << tree.nodes().size() + << " nodes, " << tree.nLeafs() + << " leaves - " << timing.elapsedTime() << 's' << endl; + + { + OFstream os("indexedOctree.obj"); + tree.writeOBJ(os); + + Info<< "Wrote " << os.name() << endl; + } + } + + + Info<< "\nEnd\n" << endl; + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/triTet/Test-triTet.C b/applications/test/triTet/Test-triTet.C index 5c850a4377..2f579d7a72 100644 --- a/applications/test/triTet/Test-triTet.C +++ b/applications/test/triTet/Test-triTet.C @@ -1,3 +1,4 @@ +#include "argList.H" #include "point.H" #include "triangle.H" #include "tetrahedron.H" @@ -5,7 +6,7 @@ using namespace Foam; -int main() +int main(int argc, char *argv[]) { triangle tri ( @@ -14,6 +15,12 @@ int main() vector(1, 1, 0) ); + Info<< "triangle: " << tri << nl + << " vecA: " << tri.vecA() << nl + << " vecB: " << tri.vecB() << nl + << " vecC: " << tri.vecC() << nl + << endl; + Info<< "tri circumCentre = " << tri.circumCentre() << endl; Info<< "tri circumRadius = " << tri.circumRadius() << endl; @@ -28,6 +35,8 @@ int main() Info<< "tet circumCentre = " << tet.circumCentre() << endl; Info<< "tet circumRadius = " << tet.circumRadius() << endl; + InfoErr<< "Enter four points: " << endl; + vector a(Sin); vector b(Sin); vector c(Sin); @@ -36,5 +45,6 @@ int main() Info<< "tet circumRadius = " << tetrahedron(a, b, c, d).circumRadius() << endl; + Info<< "\nEnd\n"; return 0; } diff --git a/applications/test/triangleIntersection/Make/files b/applications/test/triangleIntersection/Make/files new file mode 100644 index 0000000000..21bf7bf1b6 --- /dev/null +++ b/applications/test/triangleIntersection/Make/files @@ -0,0 +1,3 @@ +Test-triangleIntersection.C + +EXE = $(FOAM_USER_APPBIN)/Test-triangleIntersection diff --git a/applications/test/triangleIntersection/Make/options b/applications/test/triangleIntersection/Make/options new file mode 100644 index 0000000000..54c035b8f5 --- /dev/null +++ b/applications/test/triangleIntersection/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lmeshTools diff --git a/applications/test/triangleIntersection/Test-triangleIntersection.C b/applications/test/triangleIntersection/Test-triangleIntersection.C new file mode 100644 index 0000000000..1aca11601c --- /dev/null +++ b/applications/test/triangleIntersection/Test-triangleIntersection.C @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Description + Test bounding box / triangle intersection + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "line.H" +#include "Random.H" +#include "triangle.H" +#include "triangleFuncs.H" +#include "treeBoundBox.H" +#include "ListOps.H" + +using namespace Foam; + +//- simple helper to create a cube +boundBox cube(scalar start, scalar width) +{ + return boundBox + ( + point::uniform(start), + point::uniform(start + width) + ); +} + + +void printEdges(const treeBoundBox& bb) +{ + pointField pts(bb.points()); + + for (const edge& e : treeBoundBox::edges) + { + Info<< pts[e.first()] << " -> " << pts[e.second()] << nl; + } +} + + +void testIntersect(const treeBoundBox& bb, const triPoints& tri) +{ + int ninside = 0; + + if (bb.contains(tri.a())) ++ninside; + if (bb.contains(tri.b())) ++ninside; + if (bb.contains(tri.c())) ++ninside; + + Info<< "box: " << bb << endl; + Info<< "tri: " << tri << endl; + + Info<< "num inside: " << ninside << nl; + Info<< "intersects: " << bb.intersects(tri.tri()) + << ' ' << triangleFuncs::intersectBb(tri.tri(), bb) << nl << endl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList args(argc, argv); + + // Info<<"tree-bb faces: " << treeBoundBox::faces << nl + // <<"tree-bb edges: " << treeBoundBox::edges << endl; + + treeBoundBox bb; + bb = cube(0, 1); + + triPoints tri; + tri.a() = point(-0.1, 0.5, 0.5); + tri.b() = point(0.1, 0.6, 0.5); + tri.c() = point(0.2, 0.4, 0.5); + + testIntersect(bb, tri); + + tri.a().z() = 1.1; + tri.b().z() = 1.1; + tri.c().z() = 1.1; + + testIntersect(bb, tri); + + tri.a().z() = 1 + 1e-15; + tri.b().z() = 1 + 1e-15; + tri.c().z() = 1 + 1e-15; + + testIntersect(bb, tri); + + tri.a() = point(-1, -1, -1); + tri.b() = point(2, 2, -2); + tri.c() = point(0, 0, 2); + + testIntersect(bb, tri); + + tri.a() = point(0.9, 1.1, 0); + tri.b() = point(1.1, 0.9, 0); + tri.c() = point(1, 1, 1.1); + + testIntersect(bb, tri); + + + tri.a() = point(-1e-3, 1e-3, -1); + tri.b() = point( 1e-3, -1e-3, -1); + tri.c() = point(0, 0, 2); + + testIntersect(bb, tri); + + tri.a() = point(-1e-3, 1e-3, -1); + tri.b() = point( 1e-3, -1e-3, -1); + tri.c() = point(-1e-4, -1e-4, 2); + + testIntersect(bb, tri); + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C index d0bd001f6f..34f157dfa0 100644 --- a/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C +++ b/applications/utilities/mesh/advanced/modifyMesh/modifyMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2021 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,7 +88,7 @@ label findPoint(const primitivePatch& pp, const point& nearPoint) for (const label pointi : meshPoints) { - scalar distSqr = magSqr(nearPoint - points[pointi]); + scalar distSqr = nearPoint.distSqr(points[pointi]); if (distSqr < minDistSqr) { @@ -288,7 +288,7 @@ label findCell(const primitiveMesh& mesh, const point& nearPoint) if (celli != -1) { - scalar distToCcSqr = magSqr(nearPoint - mesh.cellCentres()[celli]); + scalar distToCcSqr = nearPoint.distSqr(mesh.cellCentres()[celli]); const labelList& cPoints = mesh.cellPoints()[celli]; @@ -297,7 +297,7 @@ label findCell(const primitiveMesh& mesh, const point& nearPoint) for (const label pointi : cPoints) { - scalar distSqr = magSqr(nearPoint - mesh.points()[pointi]); + scalar distSqr = nearPoint.distSqr(mesh.points()[pointi]); if (distSqr < minDistSqr) { diff --git a/applications/utilities/mesh/conversion/ensightToFoam/ensightMeshReader.C b/applications/utilities/mesh/conversion/ensightToFoam/ensightMeshReader.C index ab672e5721..25c64bbaf0 100644 --- a/applications/utilities/mesh/conversion/ensightToFoam/ensightMeshReader.C +++ b/applications/utilities/mesh/conversion/ensightToFoam/ensightMeshReader.C @@ -293,7 +293,7 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart elemIdToCells ); - const auto& model = *cellModel::ptr(cellModel::TET); + const auto& model = cellModel::ref(cellModel::TET); for (label shapei = 0; shapei < nShapes; shapei++) { readVerts(is, 4, nodeIdToPoints, verts); @@ -326,7 +326,7 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart elemIdToCells ); - const auto& model = *cellModel::ptr(cellModel::PYR); + const auto& model = cellModel::ref(cellModel::PYR); for (label shapei = 0; shapei < nShapes; shapei++) { readVerts(is, 5, nodeIdToPoints, verts); @@ -359,7 +359,7 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart elemIdToCells ); - const auto& model = *cellModel::ptr(cellModel::PRISM); + const auto& model = cellModel::ref(cellModel::PRISM); for (label shapei = 0; shapei < nShapes; shapei++) { readVerts(is, 6, nodeIdToPoints, verts); @@ -392,7 +392,7 @@ bool Foam::fileFormats::ensightMeshReader::readGoldPart elemIdToCells ); - const auto& model = *cellModel::ptr(cellModel::HEX); + const auto& model = cellModel::ref(cellModel::HEX); for (label shapei = 0; shapei < nShapes; shapei++) { readVerts(is, 8, nodeIdToPoints, verts); diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index cd84e849cc..7ea12e1f2a 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -890,11 +890,10 @@ int main(int argc, char *argv[]) const boundBox& bb = mesh.bounds(); - const vector span = bb.span(); const scalar mergeDim = mergeTol * bb.minDim(); Info<< "Mesh bounding box : " << bb << nl - << " with span : " << span << nl + << " with span : " << bb.span() << nl << "Merge distance : " << mergeDim << nl << endl; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C index ad263e559e..77774439ce 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C @@ -869,9 +869,7 @@ Foam::DistributedDelaunayMesh::rangeInsertReferredWithInfo if (!bb.contains(samplePoint)) { - const Foam::point nearestPoint = bb.nearest(samplePoint); - - distFromBbSqr = magSqr(nearestPoint - samplePoint); + distFromBbSqr = bb.nearest(samplePoint).distSqr(samplePoint); } pointsBbDistSqr.append diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 0aebe1fd4a..a224a42ebd 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -167,7 +167,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement() { if (volumeStatus[celli] == volumeType::UNKNOWN) { - treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); + treeBoundBox cellBb(mesh_.cellBb(celli)); if (geometry.overlaps(cellBb)) { @@ -279,7 +279,7 @@ void Foam::backgroundMeshDecomposition::initialRefinement() { if (volumeStatus[celli] == volumeType::UNKNOWN) { - treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); + treeBoundBox cellBb(mesh_.cellBb(celli)); if (geometry.overlaps(cellBb)) { @@ -498,7 +498,7 @@ bool Foam::backgroundMeshDecomposition::refineCell // const conformationSurfaces& geometry = geometryToConformTo_; - treeBoundBox cellBb(mesh_.cells()[celli].box(mesh_)); + treeBoundBox cellBb(mesh_.cellBb(celli)); weightEstimate = 1.0; @@ -577,7 +577,7 @@ bool Foam::backgroundMeshDecomposition::refineCell // // weightEstimate += sampleVol/pow3(s); // } // -// if (sqr(spanScale_)*sqr(minCellSize) < magSqr(cellBb.span())) +// if (sqr(spanScale_)*sqr(minCellSize) < cellBb.magSqr()) // { // return true; // } @@ -695,7 +695,7 @@ void Foam::backgroundMeshDecomposition::buildPatchAndTree() Pstream::allGatherList(allBackgroundMeshBounds_); // find global bounding box - globalBackgroundBounds_ = treeBoundBox(boundBox::invertedBox); + globalBackgroundBounds_.reset(); forAll(allBackgroundMeshBounds_, proci) { globalBackgroundBounds_.add(allBackgroundMeshBounds_[proci]); @@ -1119,10 +1119,7 @@ Foam::labelList Foam::backgroundMeshDecomposition::processorNearestPosition if (info.hit()) { - distanceSqrToCandidate[tPI] = magSqr - ( - testPoints[tPI] - info.hitPoint() - ); + distanceSqrToCandidate[tPI] = info.point().distSqr(testPoints[tPI]); } } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C index 0277cbfa59..ab7bf54aad 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -132,10 +132,7 @@ Foam::word Foam::cellShapeControlMesh::meshSubDir = "cellShapeControlMesh"; // // if (spokeHit.hit()) // { -// scalar spokeHitDistance = mag -// ( -// spokeHit.hitPoint() - pt -// ); +// scalar spokeHitDistance = spokeHit.point().dist(pt); // // if (spokeHitDistance < closestSpokeHitDistance) // { @@ -159,10 +156,7 @@ Foam::word Foam::cellShapeControlMesh::meshSubDir = "cellShapeControlMesh"; // // if (spokeHit.hit()) // { -// scalar spokeHitDistance = mag -// ( -// spokeHit.hitPoint() - mirrorPt -// ); +// scalar spokeHitDistance = spokeHit.point().dist(mirrorPt); // // if (spokeHitDistance < closestSpokeHitDistance) // { @@ -202,10 +196,10 @@ Foam::word Foam::cellShapeControlMesh::meshSubDir = "cellShapeControlMesh"; // FatalErrorInFunction // << "Parallel normals detected in spoke search." << nl // << "point: " << pt << nl -// << "closest surface point: " << surfHit.hitPoint() << nl -// << "closest spoke hit: " << closestSpokeHit.hitPoint() << nl -// << "np: " << surfHit.hitPoint() + np << nl -// << "ns: " << closestSpokeHit.hitPoint() + na << nl +// << "closest surface point: " << surfHit.point() << nl +// << "closest spoke hit: " << closestSpokeHit.point() << nl +// << "np: " << surfHit.point() + np << nl +// << "ns: " << closestSpokeHit.point() + na << nl // << exit(FatalError); // } // diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C index d6c20276f8..c8b8dc2280 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/searchableSurfaceControl/searchableSurfaceControl.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -439,7 +439,7 @@ void Foam::searchableSurfaceControl::initialVertices { // Limit cell size const vector vN = - infoList[0].hitPoint() + infoList[0].point() - 2.0*normals[0]*defaultCellSize_; List intersectionList; @@ -453,8 +453,7 @@ void Foam::searchableSurfaceControl::initialVertices // if (intersectionList[0].hit()) // { -// scalar dist = -// mag(intersectionList[0].hitPoint() - pts[pI]); +// scalar dist = intersectionList[0].point().dist(pts[pI]); // // limitedCellSize = dist/2.0; // } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C index 02d5d1709e..313a039a7b 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -739,7 +740,7 @@ Foam::label Foam::controlMeshRefinement::refineMesh if (hitPt.hit()) { - const Foam::point& pt = hitPt.hitPoint(); + const Foam::point& pt = hitPt.point(); if (!geometryToConformTo_.inside(pt)) { diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearDistance/linearDistance.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearDistance/linearDistance.C index d8ae5340a8..775ca579fd 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearDistance/linearDistance.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/linearDistance/linearDistance.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -155,10 +155,10 @@ bool Foam::linearDistance::cellSize(const point& pt, scalar& size) const if (hitInfo.hit()) { - const point& hitPt = hitInfo.hitPoint(); + const point& hitPt = hitInfo.point(); const label hitIndex = hitInfo.index(); - const scalar dist = mag(pt - hitPt); + const scalar dist = hitPt.dist(pt); if (sideMode_ == rmBothsides) { diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C index 2055f9cb1a..99d119e8a9 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -206,10 +206,10 @@ bool Foam::surfaceOffsetLinearDistance::cellSize if (hitInfo.hit()) { - const point& hitPt = hitInfo.hitPoint(); + const point& hitPt = hitInfo.point(); const label hitIndex = hitInfo.index(); - const scalar dist = mag(pt - hitPt); + const scalar dist = hitPt.dist(pt); if (sideMode_ == rmBothsides) { @@ -220,7 +220,7 @@ bool Foam::surfaceOffsetLinearDistance::cellSize // If the nearest point is essentially on the surface, do not do a // getVolumeType calculation, as it will be prone to error. - if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_) + if (hitInfo.point().dist(pt) < snapToSurfaceTol_) { size = sizeFunction(hitPt, 0, hitIndex); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniform/uniform.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniform/uniform.C index 88157088ef..cd522974fe 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniform/uniform.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniform/uniform.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -97,7 +98,7 @@ bool uniform::cellSize if (hitInfo.hit()) { - const point& hitPt = hitInfo.hitPoint(); + const point& hitPt = hitInfo.point(); const label index = hitInfo.index(); if (sideMode_ == rmBothsides) diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniformDistance/uniformDistance.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniformDistance/uniformDistance.C index 141e4aade9..c337e143fe 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniformDistance/uniformDistance.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/cellSizeFunction/uniformDistance/uniformDistance.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -134,7 +134,7 @@ bool Foam::uniformDistance::cellSize if (hitInfo.hit()) { - const point& hitPt = hitInfo.hitPoint(); + const point& hitPt = hitInfo.point(); const label index = hitInfo.index(); if (sideMode_ == rmBothsides) @@ -146,7 +146,7 @@ bool Foam::uniformDistance::cellSize // If the nearest point is essentially on the surface, do not do a // getVolumeType calculation, as it will be prone to error. - if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_) + if (hitInfo.point().dist(pt) < snapToSurfaceTol_) { size = surfaceCellSizeFunction_().interpolate(hitPt, index); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 996a9e2e13..199d23a3e7 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -231,7 +231,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs const vector& normal = norm[0]; - const Foam::point& surfacePt(surfaceHit.hitPoint()); + const Foam::point& surfacePt = surfaceHit.hitPoint(); extendedFeatureEdgeMesh::sideVolumeType meshableSide = geometryToConformTo_.meshableSide(featureIndex, surfaceHit); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 1c0a115919..c1cebc026a 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -488,7 +488,7 @@ Foam::label Foam::conformalVoronoiMesh::mergeIdenticalDualVertices //// //// if (surfHit.hit()) //// { -//// pt += (surfHit.hitPoint() - pt) +//// pt += (surfHit.point() - pt) //// *pow //// ( //// foamyHexMeshControls() @@ -969,7 +969,7 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::findOffsetPatchFaces if ( pHit.hit() - && (mag(pHit.hitPoint() - faceCentre) > allowedOffset*targetSize) + && (pHit.point().dist(faceCentre) > allowedOffset*targetSize) ) { offsetBoundaryCells.insert(fCell[pLFI]); @@ -1362,10 +1362,10 @@ void Foam::conformalVoronoiMesh::indexDualVertices if (debug) { Info<< "Dual = " << dual << nl - << " Nearest = " << fpHit.hitPoint() << endl; + << " Nearest = " << fpHit.point() << endl; } - pts[cit->cellIndex()] = fpHit.hitPoint(); + pts[cit->cellIndex()] = fpHit.point(); } } } @@ -1401,7 +1401,7 @@ void Foam::conformalVoronoiMesh::indexDualVertices // ); // // pointFromPoint nearestPointOnTet = -// tet.nearestPoint(dual).rawPoint(); +// tet.nearestPoint(dual).point(); // // // Get nearest point on surface from tet. // geometryToConformTo_.findSurfaceNearest @@ -1440,10 +1440,10 @@ void Foam::conformalVoronoiMesh::indexDualVertices // snapping2.writeLine // ( // nearestPointOnTet, -// hitInfo.hitPoint() +// hitInfo.point() // ); // -// pts[cit->cellIndex()] = hitInfo.hitPoint(); +// pts[cit->cellIndex()] = hitInfo.point(); // } // } // } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index bc1ccb10c5..7e857a1e27 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -311,7 +311,7 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation() ) { // meshTools::writeOBJ(Pout, vert); - // meshTools::writeOBJ(Pout, surfHit.hitPoint()); + // meshTools::writeOBJ(Pout, surfHit.point()); // Pout<< "l cr0 cr1" << endl; addSurfaceAndEdgeHits @@ -804,7 +804,7 @@ Foam::label Foam::conformalVoronoiMesh::synchroniseEdgeTrees if (nearest.hit()) { // Pout<< "Not inserting " << peI << " " << pt << " " -// << nearest.rawPoint() << " on proc " << proci +// << nearest.point() << " on proc " << proci // << ", near edge = " << nearest // << " near ftPt = "<< info // << " " << featureEdgeExclusionDistanceSqr(pt) @@ -1477,9 +1477,9 @@ void Foam::conformalVoronoiMesh::reportProcessorOccupancy() // << vit->type() << nl // << vit->ppMaster() << nl // << "nearFeaturePt " -// << nearFeaturePt(surfHit.hitPoint()) << nl +// << nearFeaturePt(surfHit.point()) << nl // << vert << nl -// << surfHit.hitPoint() +// << surfHit.point() // << endl; // } // } @@ -1614,7 +1614,7 @@ void Foam::conformalVoronoiMesh::limitDisplacement { limit = true; - if (magSqr(pt - surfHit.hitPoint()) <= searchDistanceSqr) + if (surfHit.point().distSqr(pt) <= searchDistanceSqr) { // Cannot limit displacement, point closer than tolerance displacement = Zero; @@ -1711,7 +1711,7 @@ bool Foam::conformalVoronoiMesh::nearSurfacePoint ( closeToSurfacePt && ( - magSqr(pt - closePoint.hitPoint()) + closePoint.hitPoint().distSqr(pt) > sqr(pointPairDistance(pt)) ) ) @@ -1807,23 +1807,25 @@ Foam::conformalVoronoiMesh::nearestFeatureEdgeLocations const Foam::point& pt ) const { + const auto& tree = edgeLocationTreePtr_(); + const scalar exclusionRangeSqr = featureEdgeExclusionDistanceSqr(pt); - labelList elems - = edgeLocationTreePtr_().findSphere(pt, exclusionRangeSqr); + labelList elems = tree.findSphere(pt, exclusionRangeSqr); - DynamicList dynPointHit; + DynamicList dynPointHit(elems.size()); - forAll(elems, elemI) + for (const label index : elems) { - label index = elems[elemI]; - - const Foam::point& pointi - = edgeLocationTreePtr_().shapes().shapePoints()[index]; - - pointIndexHit nearHit(true, pointi, index); - - dynPointHit.append(nearHit); + dynPointHit.append + ( + pointIndexHit + ( + true, + tree.shapes().centre(index), + index + ) + ); } return dynPointHit; @@ -1965,12 +1967,9 @@ void Foam::conformalVoronoiMesh::buildEdgeLocationTree { treeBoundBox overallBb ( - geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) + geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4, ROOTVSMALL) ); - overallBb.min() -= Foam::point::uniform(ROOTVSMALL); - overallBb.max() += Foam::point::uniform(ROOTVSMALL); - edgeLocationTreePtr_.reset ( new dynamicIndexedOctree @@ -1992,12 +1991,9 @@ void Foam::conformalVoronoiMesh::buildSurfacePtLocationTree { treeBoundBox overallBb ( - geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4) + geometryToConformTo_.globalBounds().extend(rndGen_, 1e-4, ROOTVSMALL) ); - overallBb.min() -= Foam::point::uniform(ROOTVSMALL); - overallBb.max() += Foam::point::uniform(ROOTVSMALL); - surfacePtLocationTreePtr_.reset ( new dynamicIndexedOctree @@ -2079,7 +2075,7 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits if (edHit.hit()) { - const Foam::point& edPt = edHit.hitPoint(); + const Foam::point& edPt = edHit.point(); if ( @@ -2095,7 +2091,7 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits { if ( - magSqr(edPt - surfPt) + surfPt.distSqr(edPt) < surfacePtReplaceDistCoeffSqr*cellSizeSqr ) { @@ -2141,7 +2137,7 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits surfacePtToEdgePtDist.insert ( existingEdgeLocations_.size() - 1, - magSqr(edPt - surfPt) + surfPt.distSqr(edPt) ); } else if (firstPass) @@ -2152,7 +2148,7 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits if ( - magSqr(edPt - surfPt) + surfPt.distSqr(edPt) < surfacePtToEdgePtDist[hitIndex] ) { @@ -2162,7 +2158,7 @@ void Foam::conformalVoronoiMesh::addSurfaceAndEdgeHits existingEdgeLocations_[hitIndex] = edHit.hitPoint(); surfacePtToEdgePtDist[hitIndex] = - magSqr(edPt - surfPt); + surfPt.distSqr(edPt); // Change edge location in featureEdgeHits // remove index from edge tree diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 03fef9501c..57cb21f66e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -564,12 +564,9 @@ Foam::conformationSurfaces::conformationSurfaces // Extend the global bounds to stop the bound box sitting on the surfaces // to be conformed to - //globalBounds_ = globalBounds_.extend(rndGen, 1e-4); + //globalBounds_.inflate(rndGen, 1e-4); - vector newSpan = 1e-4*globalBounds_.span(); - - globalBounds_.min() -= newSpan; - globalBounds_.max() += newSpan; + globalBounds_.grow(1e-4*globalBounds_.span()); // Look at all surfaces at determine whether the locationInMesh point is // inside or outside each, to establish a signature for the domain to be @@ -746,7 +743,7 @@ Foam::Field Foam::conformationSurfaces::wellInOutSide const vector hitDir = normalised ( - info[0].rawPoint() - samplePts[i] + info[0].point() - samplePts[i] ); pointIndexHit surfHit; @@ -755,7 +752,7 @@ Foam::Field Foam::conformationSurfaces::wellInOutSide findSurfaceNearestIntersection ( samplePts[i], - info[0].rawPoint() - 1e-3*mag(hitDir)*hitDir, + info[0].point() - 1e-3*mag(hitDir)*hitDir, surfHit, hitSurface ); @@ -1057,7 +1054,7 @@ void Foam::conformationSurfaces::findFeaturePointNearest if (hitInfo.hit()) { - minDistSqr = magSqr(hitInfo.hitPoint()- sample); + minDistSqr = hitInfo.point().distSqr(sample); fpHit = hitInfo; featureHit = testI; } @@ -1123,11 +1120,9 @@ void Foam::conformationSurfaces::findEdgeNearest { if (hitInfo[pointi].hit()) { - minDistSqr[pointi] = magSqr - ( - hitInfo[pointi].hitPoint() - - samples[pointi] - ); + minDistSqr[pointi] = + hitInfo[pointi].point().distSqr(samples[pointi]); + edgeHits[pointi] = hitInfo[pointi]; featuresHit[pointi] = testI; } @@ -1167,7 +1162,7 @@ void Foam::conformationSurfaces::findEdgeNearestByType { if (hitInfo[typeI].hit()) { - minDistSqr[typeI] = magSqr(hitInfo[typeI].hitPoint() - sample); + minDistSqr[typeI] = hitInfo[typeI].point().distSqr(sample); edgeHits[typeI] = hitInfo[typeI]; featuresHit[typeI] = testI; } @@ -1207,6 +1202,7 @@ void Foam::conformationSurfaces::findAllNearestEdges if (hitInfo[hitI].hit()) { anyHit = true; + break; } } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C index 62fcd4b98f..5a1c358456 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -238,7 +238,7 @@ Foam::List Foam::rayShooting::initialPoints() const if ((normStart[0] & normEnd[0]) < 0) { - line l(fC, surfHitEnd.hitPoint()); + line l(fC, surfHitEnd.point()); if (Pstream::parRun()) { @@ -256,7 +256,7 @@ Foam::List Foam::rayShooting::initialPoints() const line ( l.start(), - procIntersection.hitPoint() + procIntersection.point() ); } } diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C index e2965da1e3..add0d3c80f 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshBackgroundMesh/foamyHexMeshBackgroundMesh.C @@ -353,7 +353,7 @@ tmp signedDistance forAll(volType, i) { label pointi = surfIndices[i]; - scalar dist = mag(points[pointi] - nearest[pointi].hitPoint()); + scalar dist = points[pointi].dist(nearest[pointi].hitPoint()); volumeType vT = volType[i]; diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C index 1cfd57f9e8..442c83c700 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C @@ -122,11 +122,7 @@ int main(int argc, char *argv[]) // Extend treeBoundBox bb = geometryToConformTo.globalBounds(); - { - const vector smallVec = 0.1*bb.span(); - bb.min() -= smallVec; - bb.max() += smallVec; - } + bb.grow(0.1*bb.span()); Info<< "Meshing to bounding box " << bb << nl << endl; diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C index 080433fe39..098a4d5e7c 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertBoundaryConformPointPairs.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -113,7 +113,7 @@ bool Foam::CV2D::insertPointPairAtIntersection if (pHit.hit()) { scalar dist2 = - magSqr(toPoint2D(pHit.hitPoint()) - vertices[vi]); + toPoint2D(pHit.point()).distSqr(vertices[vi]); // Check the point is further away than the furthest so far if (dist2 > interDist2) @@ -131,7 +131,7 @@ bool Foam::CV2D::insertPointPairAtIntersection if (dist2 > mps2) { found = true; - interPoint = toPoint2D(pHit.hitPoint()); + interPoint = toPoint2D(pHit.point()); interTri = pHit.index(); interDist2 = dist2; interHitSurface = hitSurface; diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearPointPairs.C b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearPointPairs.C index f64aca738d..eb0888df4a 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearPointPairs.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/insertSurfaceNearPointPairs.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -89,7 +90,7 @@ void Foam::CV2D::insertSurfaceNearPointPairs() insertPointPair ( meshControls().ppDist(), - toPoint2D(pHit.hitPoint()), + toPoint2D(pHit.point()), toPoint2D(norm[0]) ); diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index 8aa4e36325..f461e45c43 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -871,17 +871,16 @@ Foam::label Foam::checkTopology Info<< " " << setw(20) << "PointZone" << setw(8) << "Points" - << "BoundingBox" << endl; + << "BoundingBox" << nl; for (const auto& zone : pointZones) { - boundBox bb; - for (const label pointi : zone) - { - bb.add(mesh.points()[pointi]); - } - - bb.reduce(); // Global min/max + boundBox bb + ( + mesh.points(), + static_cast(zone), + true // Reduce (global min/max) + ); Info<< " " << setw(20) << zone.name() diff --git a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C index 7c4e663b08..0bdd2ea866 100644 --- a/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C +++ b/applications/utilities/preProcessing/PDR/pdrFields/obstacles/PDRobstacle.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -389,7 +389,7 @@ Foam::meshedSurface Foam::PDRobstacle::surface() const boundBox box(obs.pt, obs.pt + obs.span); pointField pts(box.points()); - faceList fcs(boundBox::faces); + faceList fcs(boundBox::hexFaces()); surf.transfer(pts, fcs); @@ -436,7 +436,7 @@ Foam::meshedSurface Foam::PDRobstacle::surface() const ); pointField pts0(box.points()); - faceList fcs(boundBox::faces); + faceList fcs(boundBox::hexFaces()); pointField pts(cs.globalPosition(pts0)); diff --git a/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H b/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H index ef5f151db8..39175ab01b 100644 --- a/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H +++ b/applications/utilities/preProcessing/createBoxTurb/createBlockMesh.H @@ -1,5 +1,3 @@ -const cellModel& hex = cellModel::ref(cellModel::HEX); - cellShapeList cellShapes; faceListList boundary; pointField points; @@ -8,20 +6,8 @@ pointField points; block b ( - cellShape(hex, identity(8)), - pointField - ( - { - point(0, 0, 0), - point(L.x(), 0, 0), - point(L.x(), L.y(), 0), - point(0, L.y(), 0), - point(0, 0, L.z()), - point(L.x(), 0, L.z()), - point(L.x(), L.y(), L.z()), - point(0, L.y(), L.z()) - } - ), + cellShape(cellModel::HEX, identity(8)), + pointField(boundBox(point::zero, L).hexCorners()), blockEdgeList(), blockFaceList(), N diff --git a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H index df38326ded..39664a65ad 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H +++ b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H @@ -4,10 +4,7 @@ Random rndGen(653213); List meshBb ( 1, - treeBoundBox - ( - boundBox(coarseMesh.points(), false) - ).extend(rndGen, 1e-3) + treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3) ); // Dummy bounds dictionary diff --git a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H index 796e2a3dc3..66375be8b3 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H +++ b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine_CGAL.H @@ -4,10 +4,7 @@ Random rndGen(653213); List meshBb ( 1, - treeBoundBox - ( - boundBox(coarseMesh.points(), false) - ).extend(rndGen, 1e-3) + treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3) ); // Dummy bounds dictionary diff --git a/applications/utilities/preProcessing/viewFactorsGen/shootRays.H b/applications/utilities/preProcessing/viewFactorsGen/shootRays.H index c3d509e387..c3cdf974c1 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/shootRays.H +++ b/applications/utilities/preProcessing/viewFactorsGen/shootRays.H @@ -146,7 +146,7 @@ for (const int proci : Pstream::allProcs()) if (aggHitIndex[hitIndex] == startAgg[rayID]) { const vector& endP = end[rayID]; - const vector& startP = hitInfo[hitIndex].hitPoint(); + const vector& startP = hitInfo[hitIndex].point(); const vector& d = endP - startP; startHitItself.append(startP + 0.01*d); diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index ec9a5cb6db..278b84825a 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -1002,7 +1002,7 @@ int main(int argc, char *argv[]) if (intStreamPtr) { - intStreamPtr().write(hitInfo.hitPoint()); + intStreamPtr().write(hitInfo.point()); } // Try and find from other side. @@ -1014,7 +1014,7 @@ int main(int argc, char *argv[]) if (intStreamPtr) { - intStreamPtr().write(hitInfo2.hitPoint()); + intStreamPtr().write(hitInfo2.point()); } } } @@ -1044,7 +1044,7 @@ int main(int argc, char *argv[]) // // if (hitInfo.hit() && intStreamPtr) // { - // intStreamPtr().write(hitInfo.hitPoint()); + // intStreamPtr().write(hitInfo.point()); // // label nearFaceI = hitInfo.index(); // triPointRef nearTri(surf[nearFaceI].tri(surf.points())); diff --git a/applications/utilities/surface/surfaceClean/collapseBase.C b/applications/utilities/surface/surfaceClean/collapseBase.C index ca20eddbc5..5c5572c23b 100644 --- a/applications/utilities/surface/surfaceClean/collapseBase.C +++ b/applications/utilities/surface/surfaceClean/collapseBase.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -642,7 +643,7 @@ static void projectNonSpanPoints << abort(FatalError); } - scalar w = mag(pHit.hitPoint() - p0) / mag(p1 - p0); + scalar w = pHit.point().dist(p0) / p1.dist(p0); insertSorted(v, w, sortedVertices, sortedWeights); } diff --git a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C index 07f01627a3..603f07b43f 100644 --- a/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C +++ b/applications/utilities/surface/surfaceHookUp/surfaceHookUp.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -166,11 +166,7 @@ void createBoundaryEdgeTrees // Boundary edges treeBoundaryEdges[surfI] = - identity - ( - surf.nEdges() - surf.nInternalEdges(), - surf.nInternalEdges() - ); + identity(surf.nBoundaryEdges(), surf.nInternalEdges()); Random rndGen(17301893); @@ -178,12 +174,9 @@ void createBoundaryEdgeTrees // geometry there are less face/edge aligned items. treeBoundBox bb ( - treeBoundBox(UList(surf.localPoints())).extend(rndGen, 1e-4) + treeBoundBox(surf.localPoints()).extend(rndGen, 1e-4, ROOTVSMALL) ); - bb.min() -= point::uniform(ROOTVSMALL); - bb.max() += point::uniform(ROOTVSMALL); - bEdgeTrees.set ( surfI, @@ -191,9 +184,8 @@ void createBoundaryEdgeTrees ( treeDataEdge ( - false, // cachebb - surf.edges(), // edges - surf.localPoints(), // points + surf.edges(), + surf.localPoints(), treeBoundaryEdges[surfI] // selected edges ), bb, // bb @@ -238,16 +230,14 @@ public: for (const label index : indices) { - const label edgeIndex = shape.edgeLabels()[index]; + const label edgeIndex = shape.objectIndex(index); if (shapeMask_.found(edgeIndex)) { continue; } - const edge& e = shape.edges()[edgeIndex]; - - pointHit nearHit = e.line(shape.points()).nearestDist(sample); + pointHit nearHit = shape.line(index).nearestDist(sample); // Only register hit if closest point is not an edge point if (nearHit.hit()) @@ -258,7 +248,7 @@ public: { nearestDistSqr = distSqr; minIndex = index; - nearestPoint = nearHit.rawPoint(); + nearestPoint = nearHit.point(); } } } @@ -420,8 +410,8 @@ int main(int argc, char *argv[]) !nearestHit.hit() || ( - magSqr(currentHit.hitPoint() - samplePt) - < magSqr(nearestHit.hitPoint() - samplePt) + currentHit.point().distSqr(samplePt) + < nearestHit.point().distSqr(samplePt) ) ) ) @@ -431,8 +421,6 @@ int main(int argc, char *argv[]) } } - scalar dist2 = magSqr(nearestHit.rawPoint() - samplePt); - if (nearestHit.hit()) { // bool rejectEdge = @@ -444,7 +432,9 @@ int main(int argc, char *argv[]) // 30 // ); - if (dist2 > Foam::sqr(dist)) + scalar distSqr = nearestHit.point().distSqr(samplePt); + + if (distSqr > Foam::sqr(dist)) { nearestHit.setMiss(); } @@ -491,11 +481,11 @@ int main(int argc, char *argv[]) if ( ( - magSqr(pt - hitSurf.localPoints()[e.start()]) + pt.distSqr(hitSurf.localPoints()[e.start()]) < matchTolerance ) || ( - magSqr(pt - hitSurf.localPoints()[e.end()]) + pt.distSqr(hitSurf.localPoints()[e.end()]) < matchTolerance ) ) diff --git a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C index 3b8552ea55..d5d887d973 100644 --- a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C +++ b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C @@ -193,10 +193,7 @@ int main(int argc, char *argv[]) meshBb[Pstream::myProcNo()] = List ( 1, - treeBoundBox - ( - boundBox(mesh.points(), false) - ).extend(rndGen, 1e-3) + treeBoundBox(mesh.points()).extend(rndGen, 1e-3) ); Pstream::allGatherList(meshBb); } @@ -243,7 +240,7 @@ int main(int argc, char *argv[]) } else { - bbs = List(1, treeBoundBox(boundBox::invertedBox)); + bbs = List(1, treeBoundBox::null()); } dictionary dict; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index cbfa048359..d0e703cfd1 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -533,6 +533,7 @@ $(primitiveShapes)/line/line.C $(primitiveShapes)/plane/plane.C $(primitiveShapes)/triangle/intersection.C $(primitiveShapes)/objectHit/pointIndexHitIOList.C +$(primitiveShapes)/volumeType/volumeType.C meshShapes = meshes/meshShapes $(meshShapes)/edge/edge.C @@ -550,11 +551,8 @@ $(cell)/cell.C $(cell)/oppositeCellFace.C $(cell)/cellIOList.C -hexCell = $(meshShapes)/hexCell -$(hexCell)/hexCell.C - -tetCell = $(meshShapes)/tetCell -$(tetCell)/tetCell.C +$(meshShapes)/hexCell/hexCell.C +$(meshShapes)/tetCell/tetCell.C cellModel = $(meshShapes)/cellModel $(cellModel)/cellModel.C @@ -810,7 +808,7 @@ meshes/preservePatchTypes/preservePatchTypes.C interpolations = interpolations interpolation = $(interpolations)/interpolation -$(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C +$(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationBase.C $(interpolations)/interpolationTable/tableReaders/tableReaders.C $(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C @@ -822,13 +820,14 @@ $(interpolationWeights)/linearInterpolationWeights/linearInterpolationWeights.C $(interpolationWeights)/splineInterpolationWeights/splineInterpolationWeights.C -algorithms/indexedOctree/indexedOctreeName.C +algorithms/AABBTree/AABBTreeBase.C + +algorithms/indexedOctree/indexedOctreeBase.C algorithms/indexedOctree/treeDataCell.C algorithms/indexedOctree/treeDataEdge.C algorithms/indexedOctree/treeDataPoint.C -algorithms/indexedOctree/volumeType.C -algorithms/dynamicIndexedOctree/dynamicIndexedOctreeName.C +algorithms/dynamicIndexedOctree/dynamicIndexedOctreeBase.C algorithms/dynamicIndexedOctree/dynamicTreeDataPoint.C parallel/commSchedule/commSchedule.C diff --git a/src/OpenFOAM/algorithms/AABBTree/AABBTree.C b/src/OpenFOAM/algorithms/AABBTree/AABBTree.C index 4bd0231819..8bbac68837 100644 --- a/src/OpenFOAM/algorithms/AABBTree/AABBTree.C +++ b/src/OpenFOAM/algorithms/AABBTree/AABBTree.C @@ -29,51 +29,8 @@ License #include "AABBTree.H" #include "bitSet.H" -template -Foam::scalar Foam::AABBTree::tolerance_ = 1e-4; - // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // -template -void Foam::AABBTree::writeOBJ -( - const bool writeLinesOnly, - const treeBoundBox& bb, - label& vertI, - Ostream& os -) const -{ - const pointField pts(bb.points()); - - for (const point& p : pts) - { - os << "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl; - } - - if (writeLinesOnly) - { - for (const edge& e : treeBoundBox::edges) - { - os << "l " << e[0] + vertI + 1 << ' ' << e[1] + vertI + 1 << nl; - } - } - else - { - for (const face& f : treeBoundBox::faces) - { - os << 'f'; - for (const label fpi : f) - { - os << ' ' << fpi + vertI + 1; - } - os << nl; - } - } - - vertI += pts.size(); -} - - template void Foam::AABBTree::writeOBJ ( @@ -89,7 +46,7 @@ void Foam::AABBTree::writeOBJ { if (!leavesOnly || nodeI < 0) { - writeOBJ(writeLinesOnly, bb, vertI, os); + AABBTreeBase::writeOBJ(os, bb, vertI, writeLinesOnly); } // recurse to find leaves @@ -126,9 +83,9 @@ void Foam::AABBTree::createBoxes ( const bool equalBinSize, const label level, - const List& objects, + const UList& objects, const pointField& points, - const DynamicList