OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

primitiveMeshCheckEdgeLength.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "primitiveMesh.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 bool Foam::primitiveMesh::checkEdgeLength
00032 (
00033     const bool report,
00034     const scalar reportLenSqr,
00035     labelHashSet* setPtr
00036 ) const
00037 {
00038     const pointField& points = this->points();
00039     const faceList& faces = this->faces();
00040 
00041     scalar minLenSqr = sqr(GREAT);
00042     scalar maxLenSqr = -sqr(GREAT);
00043 
00044     labelHashSet smallEdgeSet(nPoints()/100);
00045 
00046     forAll(faces, faceI)
00047     {
00048         const face& f = faces[faceI];
00049 
00050         forAll(f, fp)
00051         {
00052             label fp1 = f.fcIndex(fp);
00053 
00054             scalar magSqrE = magSqr(points[f[fp]] - points[f[fp1]]);
00055 
00056             if (magSqrE < reportLenSqr)
00057             {
00058                 smallEdgeSet.insert(f[fp]);
00059                 smallEdgeSet.insert(f[fp1]);
00060             }
00061 
00062             minLenSqr = min(minLenSqr, magSqrE);
00063             maxLenSqr = max(maxLenSqr, magSqrE);
00064         }
00065     }
00066 
00067     reduce(minLenSqr, minOp<scalar>());
00068     reduce(maxLenSqr, maxOp<scalar>());
00069 
00070     label nSmall = smallEdgeSet.size();
00071     reduce(nSmall, sumOp<label>());
00072 
00073     if (setPtr)
00074     {
00075         setPtr->transfer(smallEdgeSet);
00076     }
00077 
00078     if (nSmall > 0)
00079     {
00080         if (report)
00081         {
00082             Info<< "   *Edges too small, min/max edge length = "
00083                 << sqrt(minLenSqr) << " " << sqrt(maxLenSqr)
00084                 << ", number too small: " << nSmall << endl;
00085         }
00086 
00087         return true;
00088     }
00089     else
00090     {
00091         if (report)
00092         {
00093             Info<< "    Min/max edge length = "
00094                 << sqrt(minLenSqr) << " " << sqrt(maxLenSqr)
00095                 << " OK." << endl;
00096         }
00097 
00098         return false;
00099     }
00100 }
00101 
00102 
00103 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd