1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
27 #include "blockDescriptor.H"
30 #include "lineDivide.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // Calculate the geometric expension factor from the expansion ratio
38 inline scalar calcGexp(const scalar expRatio, const label dim)
40 return dim > 1 ? pow(expRatio, 1.0/(dim - 1)) : 0.0;
44 } // End namespace Foam
47 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 void Foam::blockDescriptor::makeBlockEdges()
51 const label ni = meshDensity_.x();
52 const label nj = meshDensity_.y();
53 const label nk = meshDensity_.z();
55 // these edges correspond to the "hex" cellModel
72 setEdge(10, 2, 6, nk);
73 setEdge(11, 3, 7, nk);
77 void Foam::blockDescriptor::setEdge
85 // set reference to the list of labels defining the block
86 const labelList& blockLabels = blockShape_;
88 // set reference to global list of points
89 const pointField blockPoints = blockShape_.points(blockPointField_);
91 // Set the edge points/weights
92 // The edge is a straight-line if it is not in the list of curvedEdges
94 // calc geometric expension factor from the expansion ratio
95 const scalar gExp = calcGexp(expand_[edgeI], dim);
97 forAll(curvedEdges_, cedgeI)
99 const curvedEdge& cedge = curvedEdges_[cedgeI];
101 int cmp = cedge.compare(blockLabels[start], blockLabels[end]);
107 // curve has the same orientation
110 lineDivide divEdge(cedge, dim, gExp);
112 edgePoints_[edgeI] = divEdge.points();
113 edgeWeights_[edgeI] = divEdge.lambdaDivisions();
117 // curve has the opposite orientation
120 lineDivide divEdge(cedge, dim, 1.0/(gExp+SMALL));
122 const pointField& p = divEdge.points();
123 const scalarList& d = divEdge.lambdaDivisions();
125 edgePoints_[edgeI].setSize(p.size());
126 edgeWeights_[edgeI].setSize(d.size());
128 label pMax = p.size() - 1;
131 edgePoints_[edgeI][pI] = p[pMax - pI];
132 edgeWeights_[edgeI][pI] = 1.0 - d[pMax - pI];
137 // found curved-edge: done
143 // not found: divide the edge as a straight line
147 lineEdge(blockPoints, start, end),
152 edgePoints_[edgeI] = divEdge.points();
153 edgeWeights_[edgeI] = divEdge.lambdaDivisions();
157 // ************************************************************************* //