1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "edgeStats.H"
30 #include "twoDPointCorrector.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 const Foam::scalar Foam::edgeStats::edgeTol_ = 1E-3;
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 Foam::direction Foam::edgeStats::getNormalDir
42 const twoDPointCorrector* correct2DPtr
49 const vector& normal = correct2DPtr->planeNormal();
51 if (mag(normal & vector(1, 0, 0)) > 1-edgeTol_)
55 else if (mag(normal & vector(0, 1, 0)) > 1-edgeTol_)
59 else if (mag(normal & vector(0, 0, 1)) > 1-edgeTol_)
68 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 // Construct from mesh
71 Foam::edgeStats::edgeStats(const polyMesh& mesh)
79 mesh.time().constant(),
81 IOobject::MUST_READ_IF_MODIFIED,
85 if (motionObj.headerOk())
87 Info<< "Reading " << mesh.time().constant() / "motionProperties"
90 IOdictionary motionProperties(motionObj);
92 Switch twoDMotion(motionProperties.lookup("twoDMotion"));
96 Info<< "Correcting for 2D motion" << endl << endl;
98 autoPtr<twoDPointCorrector> correct2DPtr
100 new twoDPointCorrector(mesh)
103 normalDir_ = getNormalDir(&correct2DPtr());
109 // Construct from components
110 Foam::edgeStats::edgeStats
112 const polyMesh& mesh,
113 const twoDPointCorrector* correct2DPtr
117 normalDir_(getNormalDir(correct2DPtr))
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
123 Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
130 scalar maxX = -GREAT;
134 scalar maxY = -GREAT;
138 scalar maxZ = -GREAT;
141 scalar minOther = GREAT;
142 scalar maxOther = -GREAT;
144 const edgeList& edges = mesh_.edges();
148 const edge& e = edges[edgeI];
150 vector eVec(e.vec(mesh_.points()));
152 scalar eMag = mag(eVec);
156 if (mag(eVec & x) > 1-edgeTol_)
158 minX = min(minX, eMag);
159 maxX = max(maxX, eMag);
162 else if (mag(eVec & y) > 1-edgeTol_)
164 minY = min(minY, eMag);
165 maxY = max(maxY, eMag);
168 else if (mag(eVec & z) > 1-edgeTol_)
170 minZ = min(minZ, eMag);
171 maxZ = max(maxZ, eMag);
176 minOther = min(minOther, eMag);
177 maxOther = max(maxOther, eMag);
181 os << "Mesh bounding box:" << boundBox(mesh_.points()) << nl << nl
182 << "Mesh edge statistics:" << nl
183 << " x aligned : number:" << nX << "\tminLen:" << minX
184 << "\tmaxLen:" << maxX << nl
185 << " y aligned : number:" << nY << "\tminLen:" << minY
186 << "\tmaxLen:" << maxY << nl
187 << " z aligned : number:" << nZ << "\tminLen:" << minZ
188 << "\tmaxLen:" << maxZ << nl
189 << " other : number:" << mesh_.nEdges() - nX - nY - nZ
190 << "\tminLen:" << minOther
191 << "\tmaxLen:" << maxOther << nl << endl;
195 return min(minY, min(minZ, minOther));
197 else if (normalDir_ == 1)
199 return min(minX, min(minZ, minOther));
201 else if (normalDir_ == 2)
203 return min(minX, min(minY, minOther));
207 return min(minX, min(minY, min(minZ, minOther)));
212 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
215 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
218 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
221 // ************************************************************************* //