From 063936cfe00692d1a3c425f83992d8427a85b46b Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 22 Oct 2008 16:13:37 +0100 Subject: [PATCH 01/18] bugfix: multiple edge gradings per block --- .../mesh/generation/blockMesh/blockPoints.C | 228 +++++++----------- 1 file changed, 86 insertions(+), 142 deletions(-) diff --git a/applications/utilities/mesh/generation/blockMesh/blockPoints.C b/applications/utilities/mesh/generation/blockMesh/blockPoints.C index 0cb024215d..2fecb21bf5 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockPoints.C +++ b/applications/utilities/mesh/generation/blockMesh/blockPoints.C @@ -41,23 +41,23 @@ namespace Foam void block::blockPoints() { // set local variables for mesh specification - label ni = blockDef_.n().x(); - label nj = blockDef_.n().y(); - label nk = blockDef_.n().z(); + const label ni = blockDef_.n().x(); + const label nj = blockDef_.n().y(); + const label nk = blockDef_.n().z(); - point start = blockDef_.points()[blockDef_.blockShape()[0]]; - point xEnd = blockDef_.points()[blockDef_.blockShape()[1]]; - point xyEnd = blockDef_.points()[blockDef_.blockShape()[2]]; - point yEnd = blockDef_.points()[blockDef_.blockShape()[3]]; + const point p000 = blockDef_.points()[blockDef_.blockShape()[0]]; + const point p100 = blockDef_.points()[blockDef_.blockShape()[1]]; + const point p110 = blockDef_.points()[blockDef_.blockShape()[2]]; + const point p010 = blockDef_.points()[blockDef_.blockShape()[3]]; - point zEnd = blockDef_.points()[blockDef_.blockShape()[4]]; - point xzEnd = blockDef_.points()[blockDef_.blockShape()[5]]; - point xyzEnd = blockDef_.points()[blockDef_.blockShape()[6]]; - point yzEnd = blockDef_.points()[blockDef_.blockShape()[7]]; + const point p001 = blockDef_.points()[blockDef_.blockShape()[4]]; + const point p101 = blockDef_.points()[blockDef_.blockShape()[5]]; + const point p111 = blockDef_.points()[blockDef_.blockShape()[6]]; + const point p011 = blockDef_.points()[blockDef_.blockShape()[7]]; - // set reference to the list of edge point and weighting factors - const List >& edgePoints = blockDef_.blockEdgePoints(); - const scalarListList& edgeWeights = blockDef_.blockEdgeWeights(); + // list of edge point and weighting factors + const List >& p = blockDef_.blockEdgePoints(); + const scalarListList& w = blockDef_.blockEdgeWeights(); // generate vertices @@ -69,193 +69,138 @@ void block::blockPoints() { label vertexNo = vtxLabel(i, j, k); - vector edgex1 = start*(1.0 - edgeWeights[0][i]) - + xEnd*edgeWeights[0][i]; + // points on edges + vector edgex1 = p000 + (p100 - p000)*w[0][i]; + vector edgex2 = p010 + (p110 - p010)*w[1][i]; + vector edgex3 = p011 + (p111 - p011)*w[2][i]; + vector edgex4 = p001 + (p101 - p001)*w[3][i]; - vector edgex2 = yEnd*(1.0 - edgeWeights[1][i]) - + xyEnd*edgeWeights[1][i]; + vector edgey1 = p000 + (p010 - p000)*w[4][j]; + vector edgey2 = p100 + (p110 - p100)*w[5][j]; + vector edgey3 = p101 + (p111 - p101)*w[6][j]; + vector edgey4 = p001 + (p011 - p001)*w[7][j]; - vector edgex3 = yzEnd*(1.0 - edgeWeights[2][i]) - + xyzEnd*edgeWeights[2][i]; - - vector edgex4 = zEnd*(1.0 - edgeWeights[3][i]) - + xzEnd*edgeWeights[3][i]; - - - - vector edgey1 = start*(1.0 - edgeWeights[4][j]) - + yEnd*edgeWeights[4][j]; - - vector edgey2 = xEnd*(1.0 - edgeWeights[5][j]) - + xyEnd*edgeWeights[5][j]; - - vector edgey3 = xzEnd*(1.0 - edgeWeights[6][j]) - + xyzEnd*edgeWeights[6][j]; - - vector edgey4 = zEnd*(1.0 - edgeWeights[7][j]) - + yzEnd*edgeWeights[7][j]; - - - - vector edgez1 = start*(1.0 - edgeWeights[8][k]) - + zEnd*edgeWeights[8][k]; - - vector edgez2 = xEnd*(1.0 - edgeWeights[9][k]) - + xzEnd*edgeWeights[9][k]; - - vector edgez3 = xyEnd*(1.0 - edgeWeights[10][k]) - + xyzEnd*edgeWeights[10][k]; - - vector edgez4 = yEnd*(1.0 - edgeWeights[11][k]) - + yzEnd*edgeWeights[11][k]; + vector edgez1 = p000 + (p001 - p000)*w[8][k]; + vector edgez2 = p100 + (p101 - p100)*w[9][k]; + vector edgez3 = p110 + (p111 - p110)*w[10][k]; + vector edgez4 = p010 + (p011 - p010)*w[11][k]; // calculate the importance factors for all edges // x - direction scalar impx1 = ( - (1.0 - edgeWeights[0][i]) - *(1.0 - edgeWeights[4][j]) - *(1.0 - edgeWeights[8][k]) - + edgeWeights[0][i] - *(1.0 - edgeWeights[5][j]) - *(1.0 - edgeWeights[9][k]) + (1.0 - w[0][i])*(1.0 - w[4][j])*(1.0 - w[8][k]) + + w[0][i]*(1.0 - w[5][j])*(1.0 - w[9][k]) ); scalar impx2 = ( - (1.0 - edgeWeights[1][i]) - *edgeWeights[4][j] - *(1.0 - edgeWeights[11][k]) - + edgeWeights[1][i] - *edgeWeights[5][j] - *(1.0 - edgeWeights[10][k]) + (1.0 - w[1][i])*w[4][j]*(1.0 - w[11][k]) + + w[1][i]*w[5][j]*(1.0 - w[10][k]) ); - scalar impx3 = - ( - (1.0 - edgeWeights[2][i]) - *edgeWeights[7][j] - *edgeWeights[11][k] - + edgeWeights[2][i] - *edgeWeights[6][j] - *edgeWeights[10][k] - ); + scalar impx3 = + ( + (1.0 - w[2][i])*w[7][j]*w[11][k] + + w[2][i]*w[6][j]*w[10][k] + ); - scalar impx4 = - ( - (1.0 - edgeWeights[3][i]) - *(1.0 - edgeWeights[7][j]) - *edgeWeights[8][k] - + edgeWeights[3][i] - *(1.0 - edgeWeights[6][j]) - *edgeWeights[9][k] - ); + scalar impx4 = + ( + (1.0 - w[3][i])*(1.0 - w[7][j])*w[8][k] + + w[3][i]*(1.0 - w[6][j])*w[9][k] + ); + scalar magImpx = impx1 + impx2 + impx3 + impx4; + impx1 /= magImpx; + impx2 /= magImpx; + impx3 /= magImpx; + impx4 /= magImpx; // y - direction scalar impy1 = ( - (1.0 - edgeWeights[4][j]) - *(1.0 - edgeWeights[0][i]) - *(1.0 - edgeWeights[8][k]) - + edgeWeights[4][j] - *(1.0 - edgeWeights[1][i]) - *(1.0 - edgeWeights[11][k]) + (1.0 - w[4][j])*(1.0 - w[0][i])*(1.0 - w[8][k]) + + w[4][j]*(1.0 - w[1][i])*(1.0 - w[11][k]) ); scalar impy2 = ( - (1.0 - edgeWeights[5][j]) - *edgeWeights[0][i] - *(1.0 - edgeWeights[9][k]) - + edgeWeights[5][j] - *edgeWeights[1][i] - *(1.0 - edgeWeights[10][k]) + (1.0 - w[5][j])*w[0][i]*(1.0 - w[9][k]) + + w[5][j]*w[1][i]*(1.0 - w[10][k]) ); scalar impy3 = ( - (1.0 - edgeWeights[6][j]) - *edgeWeights[3][i] - *edgeWeights[9][k] - + edgeWeights[6][j] - *edgeWeights[2][i] - *edgeWeights[10][k] + (1.0 - w[6][j])*w[3][i]*w[9][k] + + w[6][j]*w[2][i]*w[10][k] ); scalar impy4 = ( - (1.0 - edgeWeights[7][j]) - *(1.0 - edgeWeights[3][i]) - *edgeWeights[8][k] - + edgeWeights[7][j] - *(1.0 - edgeWeights[2][i]) - *edgeWeights[11][k] + (1.0 - w[7][j])*(1.0 - w[3][i])*w[8][k] + + w[7][j]*(1.0 - w[2][i])*w[11][k] ); + scalar magImpy = impy1 + impy2 + impy3 + impy4; + impy1 /= magImpy; + impy2 /= magImpy; + impy3 /= magImpy; + impy4 /= magImpy; // z - direction scalar impz1 = ( - (1.0 - edgeWeights[8][k]) - *(1.0 - edgeWeights[0][i]) - *(1.0 - edgeWeights[4][j]) - + edgeWeights[8][k] - *(1.0 - edgeWeights[3][i]) - *(1.0 - edgeWeights[7][j]) + (1.0 - w[8][k])*(1.0 - w[0][i])*(1.0 - w[4][j]) + + w[8][k]*(1.0 - w[3][i])*(1.0 - w[7][j]) ); scalar impz2 = ( - (1.0 - edgeWeights[9][k]) - *edgeWeights[0][i] - *(1.0 - edgeWeights[5][j]) - + edgeWeights[9][k] - *edgeWeights[3][i] - *(1.0 - edgeWeights[6][j]) + (1.0 - w[9][k])*w[0][i]*(1.0 - w[5][j]) + + w[9][k]*w[3][i]*(1.0 - w[6][j]) ); scalar impz3 = ( - (1.0 - edgeWeights[10][k]) - *edgeWeights[1][i] - *edgeWeights[5][j] - + edgeWeights[10][k] - *edgeWeights[2][i] - *edgeWeights[6][j] + (1.0 - w[10][k])*w[1][i]*w[5][j] + + w[10][k]*w[2][i]*w[6][j] ); scalar impz4 = ( - (1.0 - edgeWeights[11][k]) - *(1.0 - edgeWeights[1][i]) - *edgeWeights[4][j] - + edgeWeights[11][k] - *(1.0 - edgeWeights[2][i]) - *edgeWeights[7][j] + (1.0 - w[11][k])*(1.0 - w[1][i])*w[4][j] + + w[11][k]*(1.0 - w[2][i])*w[7][j] ); + scalar magImpz = impz1 + impz2 + impz3 + impz4; + impz1 /= magImpz; + impz2 /= magImpz; + impz3 /= magImpz; + impz4 /= magImpz; + // calculate the correction vectors - vector corx1 = impx1*(edgePoints[0][i] - edgex1); - vector corx2 = impx2*(edgePoints[1][i] - edgex2); - vector corx3 = impx3*(edgePoints[2][i] - edgex3); - vector corx4 = impx4*(edgePoints[3][i] - edgex4); + vector corx1 = impx1*(p[0][i] - edgex1); + vector corx2 = impx2*(p[1][i] - edgex2); + vector corx3 = impx3*(p[2][i] - edgex3); + vector corx4 = impx4*(p[3][i] - edgex4); - vector cory1 = impy1*(edgePoints[4][j] - edgey1); - vector cory2 = impy2*(edgePoints[5][j] - edgey2); - vector cory3 = impy3*(edgePoints[6][j] - edgey3); - vector cory4 = impy4*(edgePoints[7][j] - edgey4); + vector cory1 = impy1*(p[4][j] - edgey1); + vector cory2 = impy2*(p[5][j] - edgey2); + vector cory3 = impy3*(p[6][j] - edgey3); + vector cory4 = impy4*(p[7][j] - edgey4); - vector corz1 = impz1*(edgePoints[8][k] - edgez1); - vector corz2 = impz2*(edgePoints[9][k] - edgez2); - vector corz3 = impz3*(edgePoints[10][k] - edgez3); - vector corz4 = impz4*(edgePoints[11][k] - edgez4); + vector corz1 = impz1*(p[8][k] - edgez1); + vector corz2 = impz2*(p[9][k] - edgez2); + vector corz3 = impz3*(p[10][k] - edgez3); + vector corz4 = impz4*(p[11][k] - edgez4); // multiply by the importance factor + // x - direction edgex1 *= impx1; edgex2 *= impx2; @@ -285,7 +230,6 @@ void block::blockPoints() vertices_[vertexNo] += corx1 + corx2 + corx3 + corx4; vertices_[vertexNo] += cory1 + cory2 + cory3 + cory4; vertices_[vertexNo] += corz1 + corz2 + corz3 + corz4; - } } } From 9ea84ab62e58a97f674be76d87932c2d995c3001 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 23 Oct 2008 16:59:27 +0100 Subject: [PATCH 02/18] added error msg when sampling patch is not found --- .../directMappedFixedValueFvPatchField.C | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C index 279e72a0c5..ab3af1717e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C @@ -234,6 +234,16 @@ void directMappedFixedValueFvPatchField::updateCoeffs() ( mpp.samplePatch() ); + if (patchID < 0) + { + FatalErrorIn + ( + "void directMappedFixedValueFvPatchField::" + "updateCoeffs()" + )<< "Unable to find sample patch " << mpp.samplePatch() + << " for patch " << this->patch().name() << nl + << abort(FatalError); + } typedef GeometricField fieldType; const word& fieldName = this->dimensionedInternalField().name(); const fieldType& sendField = From 6520f35f1e9fa325094cc93d725b883a78cf7ddf Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 28 Oct 2008 21:07:05 +0000 Subject: [PATCH 03/18] nearestToPoint --- src/meshTools/Make/files | 1 + .../nearestToPoint/nearestToPoint.C | 154 ++++++++++++++++++ .../nearestToPoint/nearestToPoint.H | 122 ++++++++++++++ 3 files changed, 277 insertions(+) create mode 100644 src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C create mode 100644 src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 64437bdda8..99587f8d3c 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -107,6 +107,7 @@ $(pointSources)/faceToPoint/faceToPoint.C $(pointSources)/boxToPoint/boxToPoint.C $(pointSources)/surfaceToPoint/surfaceToPoint.C $(pointSources)/zoneToPoint/zoneToPoint.C +$(pointSources)/nearestToPoint/nearestToPoint.C surfaceSets/surfaceSets.C diff --git a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C new file mode 100644 index 0000000000..f4b759c6fe --- /dev/null +++ b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.C @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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 "nearestToPoint.H" +#include "polyMesh.H" +#include "meshSearch.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(nearestToPoint, 0); + +addToRunTimeSelectionTable(topoSetSource, nearestToPoint, word); + +addToRunTimeSelectionTable(topoSetSource, nearestToPoint, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::nearestToPoint::usage_ +( + nearestToPoint::typeName, + "\n Usage: nearestToPoint (pt0 .. ptn)\n\n" + " Select the nearest point for each of the points pt0 ..ptn\n\n" +); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::nearestToPoint::combine(topoSet& set, const bool add) const +{ + // Do linear search since usually just a few points. + + forAll(points_, pointI) + { + const pointField& pts = mesh_.points(); + + if (pts.size() > 0) + { + label minPointI = 0; + scalar minDistSqr = magSqr(pts[minPointI] - points_[pointI]); + + for (label i = 1; i < pts.size(); i++) + { + scalar distSqr = magSqr(pts[i] - points_[pointI]); + + if (distSqr < minDistSqr) + { + minDistSqr = distSqr; + minPointI = i; + } + } + + addOrDelete(set, minPointI, add); + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::nearestToPoint::nearestToPoint +( + const polyMesh& mesh, + const pointField& points +) +: + topoSetSource(mesh), + points_(points) +{} + + +// Construct from dictionary +Foam::nearestToPoint::nearestToPoint +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + points_(dict.lookup("points")) +{} + + +// Construct from Istream +Foam::nearestToPoint::nearestToPoint +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + points_(checkIs(is)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::nearestToPoint::~nearestToPoint() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::nearestToPoint::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding points nearest to " << points_ << endl; + + combine(set, true); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing points nearest to " << points_ << endl; + + combine(set, false); + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H new file mode 100644 index 0000000000..ba63cc14f2 --- /dev/null +++ b/src/meshTools/sets/pointSources/nearestToPoint/nearestToPoint.H @@ -0,0 +1,122 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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::nearestToPoint + +Description + A topoSetSource to select points nearest to points. + +SourceFiles + nearestToPoint.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nearestToPoint_H +#define nearestToPoint_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class nearestToPoint Declaration +\*---------------------------------------------------------------------------*/ + +class nearestToPoint +: + public topoSetSource +{ + + // Private data + + //- Add usage string + static addToUsageTable usage_; + + //- points to select nearest to + pointField points_; + + + // Private Member Functions + + void combine(topoSet& set, const bool add) const; + + +public: + + //- Runtime type information + TypeName("nearestToPoint"); + + // Constructors + + //- Construct from components + nearestToPoint + ( + const polyMesh& mesh, + const pointField& points + ); + + //- Construct from dictionary + nearestToPoint + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + nearestToPoint + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~nearestToPoint(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From b5ee8b6dc111b77d94d1a27e35714701f9791611 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 28 Oct 2008 21:07:37 +0000 Subject: [PATCH 04/18] detect only option --- .../mergeOrSplitBaffles/mergeOrSplitBaffles.C | 134 ++++++++++-------- 1 file changed, 78 insertions(+), 56 deletions(-) diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C index cbd2d9e419..d8d12c0845 100644 --- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C +++ b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C @@ -154,10 +154,77 @@ void insertDuplicateMerge } +labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) +{ + // Get all duplicate face labels (in boundaryFaces indices!). + labelList duplicates = localPointRegion::findDuplicateFaces + ( + mesh, + boundaryFaces + ); + + + // Check that none are on processor patches + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + forAll(duplicates, bFaceI) + { + if (duplicates[bFaceI] != -1) + { + label faceI = mesh.nInternalFaces() + bFaceI; + label patchI = patches.whichPatch(faceI); + + if (isA(patches[patchI])) + { + FatalErrorIn("findBaffles(const polyMesh&, const labelList&)") + << "Duplicate face " << faceI + << " is on a processorPolyPatch." + << "This is not allowed." << nl + << "Face:" << faceI + << " is on patch:" << patches[patchI].name() + << abort(FatalError); + } + } + } + + + // Write to faceSet for ease of postprocessing. + { + faceSet duplicateSet + ( + mesh, + "duplicateFaces", + (mesh.nFaces() - mesh.nInternalFaces())/256 + ); + + forAll(duplicates, bFaceI) + { + label otherFaceI = duplicates[bFaceI]; + + if (otherFaceI != -1 && otherFaceI > bFaceI) + { + duplicateSet.insert(mesh.nInternalFaces() + bFaceI); + duplicateSet.insert(mesh.nInternalFaces() + otherFaceI); + } + } + + Pout<< "Writing " << duplicateSet.size() + << " duplicate faces to faceSet " << duplicateSet.objectPath() + << nl << endl; + duplicateSet.write(); + } + + return duplicates; +} + + + + int main(int argc, char *argv[]) { argList::validOptions.insert("split", ""); argList::validOptions.insert("overwrite", ""); + argList::validOptions.insert("detectOnly", ""); # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); @@ -165,6 +232,7 @@ int main(int argc, char *argv[]) bool split = args.options().found("split"); bool overwrite = args.options().found("overwrite"); + bool detectOnly = args.options().found("detectOnly"); // Collect all boundary faces labelList boundaryFaces(mesh.nFaces() - mesh.nInternalFaces()); @@ -175,6 +243,15 @@ int main(int argc, char *argv[]) } + if (detectOnly) + { + findBaffles(mesh, boundaryFaces); + + return 0; + } + + + // Read objects in time directory IOobjectList objects(mesh, runTime.timeName()); @@ -238,62 +315,7 @@ int main(int argc, char *argv[]) << nl << endl; // Get all duplicate face labels (in boundaryFaces indices!). - labelList duplicates = localPointRegion::findDuplicateFaces - ( - mesh, - boundaryFaces - ); - - - // Check that none are on processor patches - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - forAll(duplicates, bFaceI) - { - if (duplicates[bFaceI] != -1) - { - label faceI = mesh.nInternalFaces() + bFaceI; - label patchI = patches.whichPatch(faceI); - - if (isA(patches[patchI])) - { - FatalErrorIn(args.executable()) - << "Duplicate face " << faceI - << " is on a processorPolyPatch." - << "This is not allowed." << nl - << "Face:" << faceI - << " is on patch:" << patches[patchI].name() - << abort(FatalError); - } - } - } - - - // Write to faceSet for ease of postprocessing. - { - faceSet duplicateSet - ( - mesh, - "duplicateFaces", - (mesh.nFaces() - mesh.nInternalFaces())/256 - ); - - forAll(duplicates, bFaceI) - { - label otherFaceI = duplicates[bFaceI]; - - if (otherFaceI != -1 && otherFaceI > bFaceI) - { - duplicateSet.insert(mesh.nInternalFaces() + bFaceI); - duplicateSet.insert(mesh.nInternalFaces() + otherFaceI); - } - } - - Pout<< "Writing " << duplicateSet.size() - << " duplicate faces to faceSet " << duplicateSet.objectPath() - << nl << endl; - duplicateSet.write(); - } + labelList duplicates(findBaffles(mesh, boundaryFaces)); // Merge into internal faces. insertDuplicateMerge(mesh, duplicates, meshMod); From 3403802282bdadb06099e9307a834926b6ca9622 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 28 Oct 2008 21:07:59 +0000 Subject: [PATCH 05/18] region option --- applications/utilities/mesh/manipulation/setSet/setSet.C | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index f8f05747f8..c0503e5bf5 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -714,9 +714,11 @@ commandStatus parseAction(const word& actionName) int main(int argc, char *argv[]) { +# include "addRegionOption.H" +# include "addTimeOptions.H" + argList::validOptions.insert("noVTK", ""); argList::validOptions.insert("batch", "file"); -# include "addTimeOptions.H" # include "setRootCase.H" # include "createTime.H" @@ -730,7 +732,7 @@ int main(int argc, char *argv[]) runTime.setTime(Times[startTime], startTime); -# include "createPolyMesh.H" +# include "createNamedPolyMesh.H" // Print some mesh info printMesh(runTime, mesh); From 8ad016dd2c87b0dada685b82ad14885a3295115a Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 28 Oct 2008 21:11:48 +0000 Subject: [PATCH 06/18] small normal tolerance. Fixed indexing error --- .../searchableSurfaceWithGaps.C | 51 +++++++++++++++---- .../searchableSurfaceWithGaps.H | 8 ++- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C index 50e851296b..b41a4409b2 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C +++ b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C @@ -26,7 +26,6 @@ License #include "searchableSurfaceWithGaps.H" #include "addToRunTimeSelectionTable.H" -#include "SortableList.H" #include "Time.H" #include "ListOps.H" @@ -82,7 +81,7 @@ Foam::Pair Foam::searchableSurfaceWithGaps::offsetVecs // Do second offset vector perp to original edge and first offset vector offsets[1] = n ^ offsets[0]; - offsets[1] *= gap_/mag(offsets[1]); + offsets[1] *= gap_; } return offsets; @@ -207,6 +206,10 @@ void Foam::searchableSurfaceWithGaps::findLine List& info ) const { + + // Test with unperturbed vectors + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + surface().findLine(start, end, info); // Count number of misses. Determine map @@ -215,6 +218,10 @@ void Foam::searchableSurfaceWithGaps::findLine if (returnReduce(nMiss, sumOp