Loading...
Searching...
No Matches
primitiveMeshCheckEdgeLength.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2019-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27\*---------------------------------------------------------------------------*/
28
29#include "primitiveMesh.H"
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32
34(
35 const bool report,
36 const scalar reportLenSqr,
37 labelHashSet* setPtr
38) const
39{
40 const pointField& points = this->points();
41 const faceList& faces = this->faces();
42
43 scalar minLenSqr = sqr(GREAT);
44 scalar maxLenSqr = -sqr(GREAT);
45
46 labelHashSet smallEdgeSet(nPoints()/100);
47
48 forAll(faces, facei)
49 {
50 const face& f = faces[facei];
51
52 forAll(f, fp)
53 {
54 label fp1 = f.fcIndex(fp);
55
56 scalar magSqrE = magSqr(points[f[fp]] - points[f[fp1]]);
57
58 if (magSqrE < reportLenSqr)
59 {
60 smallEdgeSet.insert(f[fp]);
61 smallEdgeSet.insert(f[fp1]);
62 }
63
64 minLenSqr = min(minLenSqr, magSqrE);
65 maxLenSqr = max(maxLenSqr, magSqrE);
66 }
67 }
68
69 reduce(minLenSqr, minOp<scalar>());
70 reduce(maxLenSqr, maxOp<scalar>());
71
72 label nSmall = returnReduce(smallEdgeSet.size(), sumOp<label>());
73
74 if (setPtr)
75 {
76 setPtr->transfer(smallEdgeSet);
77 }
78
79 if (nSmall > 0)
80 {
81 if (report)
82 {
83 Info<< " *Edges too small, min/max edge length = "
84 << sqrt(minLenSqr) << " " << sqrt(maxLenSqr)
85 << ", number too small: " << nSmall << endl;
86 }
87
88 return true;
89 }
90
91 if (report)
92 {
93 Info<< " Min/max edge length = "
94 << sqrt(minLenSqr) << " " << sqrt(maxLenSqr) << " OK." << endl;
95 }
96
97 return false;
98}
99
100
101// ************************************************************************* //
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Definition HashSet.H:229
void transfer(HashTable< T, Key, Hash > &rhs)
Transfer contents into this table.
Definition HashTable.C:794
label size() const noexcept
The number of elements in table.
Definition HashTable.H:358
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
virtual bool checkEdgeLength(const bool report, const scalar minLenSqr, labelHashSet *setPtr=nullptr) const
Check edge length.
virtual const faceList & faces() const =0
Return faces.
label nPoints() const noexcept
Number of mesh points.
virtual const pointField & points() const =0
Return mesh points.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
dimensionedSymmTensor sqr(const dimensionedVector &dv)
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition HashSet.H:85
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
Definition faceListFwd.H:41
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
dimensionedScalar sqrt(const dimensionedScalar &ds)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
vectorField pointField
pointField is a vectorField.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299