/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020-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 . \*---------------------------------------------------------------------------*/ #include "averageNeighbourFvGeometryScheme.H" #include "addToRunTimeSelectionTable.H" #include "fvMesh.H" #include "cellAspectRatio.H" #include "syncTools.H" #include "polyMeshTools.H" #include "unitConversion.H" #include "OBJstream.H" #include "surfaceWriter.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(averageNeighbourFvGeometryScheme, 0); addToRunTimeSelectionTable ( fvGeometryScheme, averageNeighbourFvGeometryScheme, dict ); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::label Foam::averageNeighbourFvGeometryScheme::clipFaceTet ( const scalar minRatio, const vectorField& faceCentres, const vectorField& faceNormals, vectorField& faceCorrection ) const { // Clip correction vector if any triangle becomes too small. Return number // of correction vectors clipped typedef Vector solveVector; const pointField& p = mesh_.points(); label nClipped = 0; for (label facei = 0; facei < mesh_.nFaces(); facei++) { #ifdef WM_SPDP const solveVector fcCorr(faceCorrection[facei]); #else const vector& fcCorr = faceCorrection[facei]; #endif if (fcCorr != solveVector::zero) { #ifdef WM_SPDP const solveVector fn(faceNormals[facei]); const solveVector fc(faceCentres[facei]); #else const vector& fn = faceNormals[facei]; const point& fc = faceCentres[facei]; #endif const face& f = mesh_.faces()[facei]; forAll(f, fp) { const solveVector thisPt(p[f[fp]]); const solveVector nextPt(p[f.fcValue(fp)]); const solveVector d(nextPt-thisPt); // Calculate triangle area with correction const solveVector nCorr(d^(fc+fcCorr - thisPt)); if ((nCorr & fn) < 0) { // Triangle points wrong way faceCorrection[facei] = vector::zero; nClipped++; break; } else { // Calculate triangle area without correction const solveVector n(d^(fc - thisPt)); if ((n & fn) < 0) { // Original triangle points the wrong way, new one is ok } else { // Both point correctly. Make sure triangle doesn't get // too small if (mag(nCorr) < minRatio*mag(n)) { faceCorrection[facei] = vector::zero; nClipped++; break; } } } } } } return returnReduce(nClipped, sumOp