diff --git a/applications/test/dimensionedType/Test-dimensionedType.C b/applications/test/dimensionedType/Test-dimensionedType.C index 965de25ead..892552fa70 100644 --- a/applications/test/dimensionedType/Test-dimensionedType.C +++ b/applications/test/dimensionedType/Test-dimensionedType.C @@ -81,6 +81,10 @@ int main(int argc, char *argv[]) } + Pout<< "zero scalar (time): " << dimensionedScalar(dimTime) << endl; + Pout<< "zero vector: " << dimensionedVector(dimLength) << endl; + Pout<< "zero tensor: " << dimensionedTensor(dimLength) << endl; + Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index dcbf38b870..0af29e1962 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -55,6 +55,7 @@ Usage #include "triangle.H" #include "triSurface.H" #include "triSurfaceSearch.H" +#include "triSurfaceTools.H" #include "argList.H" #include "OFstream.H" #include "OBJstream.H" @@ -64,79 +65,6 @@ Usage using namespace Foam; -// Does face use valid vertices? -bool validTri -( - const bool verbose, - const triSurface& surf, - const label facei -) -{ - // Simple check on indices ok. - - const labelledTri& f = surf[facei]; - - forAll(f, fp) - { - if (f[fp] < 0 || f[fp] >= surf.points().size()) - { - WarningInFunction - << "triangle " << facei << " vertices " << f - << " uses point indices outside point range 0.." - << surf.points().size()-1 << endl; - return false; - } - } - - if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2])) - { - WarningInFunction - << "triangle " << facei - << " uses non-unique vertices " << f - << " coords:" << f.points(surf.points()) - << endl; - return false; - } - - // duplicate triangle check - - const labelList& fFaces = surf.faceFaces()[facei]; - - // Check if faceNeighbours use same points as this face. - // Note: discards normal information - sides of baffle are merged. - forAll(fFaces, i) - { - label nbrFacei = fFaces[i]; - - if (nbrFacei <= facei) - { - // lower numbered faces already checked - continue; - } - - const labelledTri& nbrF = surf[nbrFacei]; - - if - ( - ((f[0] == nbrF[0]) || (f[0] == nbrF[1]) || (f[0] == nbrF[2])) - && ((f[1] == nbrF[0]) || (f[1] == nbrF[1]) || (f[1] == nbrF[2])) - && ((f[2] == nbrF[0]) || (f[2] == nbrF[1]) || (f[2] == nbrF[2])) - ) - { - WarningInFunction - << "triangle " << facei << " vertices " << f - << " has the same vertices as triangle " << nbrFacei - << " vertices " << nbrF - << " coords:" << f.points(surf.points()) - << endl; - - return false; - } - } - return true; -} - - labelList countBins ( const scalar min, @@ -377,14 +305,12 @@ int main(int argc, char *argv[]) const fileName surfFileName = args[1]; const bool checkSelfIntersect = args.optionFound("checkSelfIntersection"); - const bool verbose = args.optionFound("verbose"); const bool splitNonManifold = args.optionFound("splitNonManifold"); label outputThreshold = 10; args.optionReadIfPresent("outputThreshold", outputThreshold); Info<< "Reading surface from " << surfFileName << " ..." << nl << endl; - // Read // ~~~~ @@ -479,7 +405,7 @@ int main(int argc, char *argv[]) forAll(surf, facei) { - if (!validTri(verbose, surf, facei)) + if (!triSurfaceTools::validTri(surf, facei)) { illegalFaces.append(facei); } diff --git a/applications/utilities/surface/surfaceClean/surfaceClean.C b/applications/utilities/surface/surfaceClean/surfaceClean.C index 6c55ce14d5..b11845df04 100644 --- a/applications/utilities/surface/surfaceClean/surfaceClean.C +++ b/applications/utilities/surface/surfaceClean/surfaceClean.C @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) argList::addBoolOption ( "noClean", - "perform some surface checking/cleanup on the input surface" + "suppress surface checking/cleanup on the input surface" ); argList args(argc, argv); diff --git a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C index bc7d50f495..5f1c5e9a33 100644 --- a/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C +++ b/applications/utilities/surface/surfaceMeshConvertTesting/surfaceMeshConvertTesting.C @@ -91,7 +91,11 @@ int main(int argc, char *argv[]) argList::validArgs.append("inputFile"); argList::validArgs.append("outputFile"); - argList::addBoolOption("clean"); + argList::addBoolOption + ( + "clean", + "perform some surface checking/cleanup on the input surface" + ); argList::addBoolOption ( "orient", diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index f5381ef91e..dca595c6a3 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -169,6 +169,18 @@ Foam::dimensioned::dimensioned {} +template +Foam::dimensioned::dimensioned +( + const dimensionSet& dimSet +) +: + name_("0"), + dimensions_(dimSet), + value_(Zero) +{} + + // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H index fe817e4afe..fde67a1fc1 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -117,9 +117,12 @@ public: //- Construct from dictionary lookup with a given name and dimensions dimensioned(const word&, const dimensionSet&, const dictionary&); - //- Null constructor + //- Null constructor - a dimensionless Zero, named "undefined" dimensioned(); + //- A dimensioned Zero, named "0" + explicit dimensioned(const dimensionSet&); + // Static member functions diff --git a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C index 88c3f2d788..d9179f4274 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C @@ -41,7 +41,7 @@ Foam::surfZoneIdentifier::surfZoneIdentifier() {} -Foam::surfZoneIdentifier::surfZoneIdentifier(label index) +Foam::surfZoneIdentifier::surfZoneIdentifier(const label index) : name_(), index_(index), diff --git a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H index ff75b56afa..a084e0196a 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H @@ -86,10 +86,7 @@ public: surfZoneIdentifier(); //- Construct null with specified index - explicit surfZoneIdentifier - ( - const label index - ); + explicit surfZoneIdentifier(const label index); //- Construct from components surfZoneIdentifier diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C index 1915de7ecc..aec02f8e06 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +26,7 @@ License #include "triSurfaceTools.H" #include "triSurface.H" +#include "MeshedSurface.H" #include "OFstream.H" #include "mergePoints.H" #include "polyMesh.H" @@ -2743,8 +2744,168 @@ void Foam::triSurfaceTools::calcInterpolationWeights // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Tracking: +// Checking: +bool Foam::triSurfaceTools::validTri +( + const triSurface& surf, + const label facei +) +{ + typedef labelledTri FaceType; + const FaceType& f = surf[facei]; + + // Simple check on indices ok. + forAll(f, fp) + { + if (f[fp] < 0 || f[fp] >= surf.points().size()) + { + WarningInFunction + << "triangle " << facei << " vertices " << f + << " uses point indices outside point range 0.." + << surf.points().size()-1 + << endl; + return false; + } + } + + if (f[0] == f[1] || f[0] == f[2] || f[1] == f[2]) + { + WarningInFunction + << "triangle " << facei + << " uses non-unique vertices " << f + << " coords:" << f.points(surf.points()) + << endl; + return false; + } + + // duplicate triangle check + + const labelList& fFaces = surf.faceFaces()[facei]; + + // Check if faceNeighbours use same points as this face. + // Note: discards normal information - sides of baffle are merged. + forAll(fFaces, i) + { + label nbrFacei = fFaces[i]; + + if (nbrFacei <= facei) + { + // lower numbered faces already checked + continue; + } + + const FaceType& nbrF = surf[nbrFacei]; + + // Same as calling triFace::compare(f, nbrF) == 1 only + if + ( + (f[0] == nbrF[0] || f[0] == nbrF[1] || f[0] == nbrF[2]) + && (f[1] == nbrF[0] || f[1] == nbrF[1] || f[1] == nbrF[2]) + && (f[2] == nbrF[0] || f[2] == nbrF[1] || f[2] == nbrF[2]) + ) + { + WarningInFunction + << "triangle " << facei << " vertices " << f + << " has the same vertices as triangle " << nbrFacei + << " vertices " << nbrF + << " coords:" << f.points(surf.points()) + << endl; + + return false; + } + } + + return true; +} + + +bool Foam::triSurfaceTools::validTri +( + const MeshedSurface& surf, + const label facei +) +{ + typedef face FaceType; + const FaceType& f = surf[facei]; + + if (f.size() != 3) + { + WarningInFunction + << "face " << facei + << " is not a triangle, it has " << f.size() + << " indices" + << endl; + return false; + } + + // Simple check on indices ok. + forAll(f, fp) + { + if (f[fp] < 0 || f[fp] >= surf.points().size()) + { + WarningInFunction + << "triangle " << facei << " vertices " << f + << " uses point indices outside point range 0.." + << surf.points().size()-1 + << endl; + return false; + } + } + + if (f[0] == f[1] || f[0] == f[2] || f[1] == f[2]) + { + WarningInFunction + << "triangle " << facei + << " uses non-unique vertices " << f + << " coords:" << f.points(surf.points()) + << endl; + return false; + } + + // duplicate triangle check + + const labelList& fFaces = surf.faceFaces()[facei]; + + // Check if faceNeighbours use same points as this face. + // Note: discards normal information - sides of baffle are merged. + forAll(fFaces, i) + { + label nbrFacei = fFaces[i]; + + if (nbrFacei <= facei) + { + // lower numbered faces already checked + continue; + } + + const FaceType& nbrF = surf[nbrFacei]; + + // Same as calling triFace::compare(f, nbrF) == 1 only + if + ( + (f[0] == nbrF[0] || f[0] == nbrF[1] || f[0] == nbrF[2]) + && (f[1] == nbrF[0] || f[1] == nbrF[1] || f[1] == nbrF[2]) + && (f[2] == nbrF[0] || f[2] == nbrF[1] || f[2] == nbrF[2]) + ) + { + WarningInFunction + << "triangle " << facei << " vertices " << f + << " has the same vertices as triangle " << nbrFacei + << " vertices " << nbrF + << " coords:" << f.points(surf.points()) + << endl; + + return false; + } + } + + return true; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Tracking: // Test point on surface to see if is on face,edge or point. Foam::surfaceLocation Foam::triSurfaceTools::classify diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H index 24fd96322e..46db7124cb 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -50,11 +50,14 @@ namespace Foam { // Forward declaration of classes -class triSurface; class edge; class labelledTri; class polyBoundaryMesh; class plane; +class triSurface; +class face; +template class MeshedSurface; + /*---------------------------------------------------------------------------*\ Class triSurfaceTools Declaration @@ -516,6 +519,15 @@ public: static triSurface delaunay2D(const List&); + // Surface checking functionality + + //- Check single triangle for (topological) validity + static bool validTri(const triSurface&, const label facei); + + //- Check single triangle for (topological) validity + static bool validTri(const MeshedSurface&, const label facei); + + // Tracking //- Test point on plane of triangle to see if on edge or point or inside diff --git a/src/sampling/cuttingPlane/cuttingPlane.C b/src/sampling/cuttingPlane/cuttingPlane.C index 5cf7a37dd7..22314049af 100644 --- a/src/sampling/cuttingPlane/cuttingPlane.C +++ b/src/sampling/cuttingPlane/cuttingPlane.C @@ -55,7 +55,7 @@ void Foam::cuttingPlane::calcCutCells listSize = cellIdLabels.size(); } - cutCells_.setSize(listSize); + meshCells_.setSize(listSize); label cutcelli(0); // Find the cut cells by detecting any cell that uses points with @@ -70,9 +70,7 @@ void Foam::cuttingPlane::calcCutCells } const labelList& cEdges = cellEdges[celli]; - label nCutEdges = 0; - forAll(cEdges, i) { const edge& e = edges[cEdges[i]]; @@ -87,8 +85,7 @@ void Foam::cuttingPlane::calcCutCells if (nCutEdges > 2) { - cutCells_[cutcelli++] = celli; - + meshCells_[cutcelli++] = celli; break; } } @@ -96,7 +93,7 @@ void Foam::cuttingPlane::calcCutCells } // Set correct list size - cutCells_.setSize(cutcelli); + meshCells_.setSize(cutcelli); } @@ -114,7 +111,7 @@ void Foam::cuttingPlane::intersectEdges // Per edge -1 or the label of the intersection point edgePoint.setSize(edges.size()); - DynamicList dynCuttingPoints(4*cutCells_.size()); + DynamicList dynCuttingPoints(4*meshCells_.size()); forAll(edges, edgeI) { @@ -258,15 +255,15 @@ void Foam::cuttingPlane::walkCellCuts const pointField& cutPoints = this->points(); // use dynamic lists to handle triangulation and/or missed cuts - DynamicList dynCutFaces(cutCells_.size()); - DynamicList