1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "edgeStats.H"
27 #include "objectRegistry.H"
31 #include "twoDPointCorrector.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 const Foam::scalar Foam::edgeStats::edgeTol_ = 1E-3;
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 Foam::direction Foam::edgeStats::getNormalDir
43 const twoDPointCorrector* correct2DPtr
50 const vector& normal = correct2DPtr->planeNormal();
52 if (mag(normal & vector(1, 0, 0)) > 1-edgeTol_)
56 else if (mag(normal & vector(0, 1, 0)) > 1-edgeTol_)
60 else if (mag(normal & vector(0, 0, 1)) > 1-edgeTol_)
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 // Construct from mesh
72 Foam::edgeStats::edgeStats(const polyMesh& mesh)
80 mesh.time().constant(),
86 if (motionObj.headerOk())
88 Info<< "Reading " << mesh.time().constant() / "motionProperties"
91 IOdictionary motionProperties(motionObj);
93 Switch twoDMotion(motionProperties.lookup("twoDMotion"));
97 Info<< "Correcting for 2D motion" << endl << endl;
99 autoPtr<twoDPointCorrector> correct2DPtr
101 new twoDPointCorrector(mesh)
104 normalDir_ = getNormalDir(&correct2DPtr());
110 // Construct from components
111 Foam::edgeStats::edgeStats
113 const polyMesh& mesh,
114 const twoDPointCorrector* correct2DPtr
118 normalDir_(getNormalDir(correct2DPtr))
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 Foam::scalar Foam::edgeStats::minLen(Ostream& os) const
131 scalar maxX = -GREAT;
135 scalar maxY = -GREAT;
139 scalar maxZ = -GREAT;
142 scalar minOther = GREAT;
143 scalar maxOther = -GREAT;
145 const edgeList& edges = mesh_.edges();
149 const edge& e = edges[edgeI];
151 vector eVec(e.vec(mesh_.points()));
153 scalar eMag = mag(eVec);
157 if (mag(eVec & x) > 1-edgeTol_)
159 minX = min(minX, eMag);
160 maxX = max(maxX, eMag);
163 else if (mag(eVec & y) > 1-edgeTol_)
165 minY = min(minY, eMag);
166 maxY = max(maxY, eMag);
169 else if (mag(eVec & z) > 1-edgeTol_)
171 minZ = min(minZ, eMag);
172 maxZ = max(maxZ, eMag);
177 minOther = min(minOther, eMag);
178 maxOther = max(maxOther, eMag);
182 os << "Mesh bounding box:" << boundBox(mesh_.points()) << nl << nl
183 << "Mesh edge statistics:" << nl
184 << " x aligned : number:" << nX << "\tminLen:" << minX
185 << "\tmaxLen:" << maxX << nl
186 << " y aligned : number:" << nY << "\tminLen:" << minY
187 << "\tmaxLen:" << maxY << nl
188 << " z aligned : number:" << nZ << "\tminLen:" << minZ
189 << "\tmaxLen:" << maxZ << nl
190 << " other : number:" << mesh_.nEdges() - nX - nY - nZ
191 << "\tminLen:" << minOther
192 << "\tmaxLen:" << maxOther << nl << endl;
196 return min(minY, min(minZ, minOther));
198 else if (normalDir_ == 1)
200 return min(minX, min(minZ, minOther));
202 else if (normalDir_ == 2)
204 return min(minX, min(minY, minOther));
208 return min(minX, min(minY, min(minZ, minOther)));
213 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
216 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
219 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
222 // ************************************************************************* //