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 \*---------------------------------------------------------------------------*/
27 #include "blockDescriptor.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 Foam::blockDescriptor::blockDescriptor
33 const cellShape& bshape,
34 const pointField& blockPointField,
35 const curvedEdgeList& edges,
36 const Vector<label>& meshDensity,
37 const UList<scalar>& expand,
41 blockPointField_(blockPointField),
44 meshDensity_(meshDensity),
50 if (expand_.size() != 12)
54 "blockDescriptor::blockDescriptor"
55 "(const cellShape&, const pointField& blockPointField, "
56 "const curvedEdgeList&, const Vector<label>& meshDensity, "
57 "const scalarList& expand, const word& zoneName)"
58 ) << "Unknown definition of expansion ratios"
62 // create a list of edges
67 Foam::blockDescriptor::blockDescriptor
69 const pointField& blockPointField,
70 const curvedEdgeList& edges,
74 blockPointField_(blockPointField),
89 zoneName_ = t.wordToken();
96 if (t.isPunctuation())
98 // new-style: read a list of 3 values
99 if (t.pToken() == token::BEGIN_LIST)
107 "blockDescriptor::blockDescriptor"
108 "(const pointField&, const curvedEdgeList&, Istream&)",
110 ) << "incorrect token while reading n, expected '(', found "
112 << exit(FatalIOError);
117 // old-style: read three labels
118 is >> meshDensity_.x()
129 scalarList expRatios(is);
131 if (expRatios.size() == 1)
133 // identical in x/y/z-directions
134 expand_ = expRatios[0];
136 else if (expRatios.size() == 3)
139 expand_[0] = expRatios[0];
140 expand_[1] = expRatios[0];
141 expand_[2] = expRatios[0];
142 expand_[3] = expRatios[0];
145 expand_[4] = expRatios[1];
146 expand_[5] = expRatios[1];
147 expand_[6] = expRatios[1];
148 expand_[7] = expRatios[1];
151 expand_[8] = expRatios[2];
152 expand_[9] = expRatios[2];
153 expand_[10] = expRatios[2];
154 expand_[11] = expRatios[2];
156 else if (expRatios.size() == 12)
164 "blockDescriptor::blockDescriptor"
165 "(const pointField&, const curvedEdgeList&, Istream&)"
166 ) << "Unknown definition of expansion ratios: " << expRatios
170 // create a list of edges
175 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
177 Foam::blockDescriptor::~blockDescriptor()
181 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
183 const Foam::pointField& Foam::blockDescriptor::blockPointField() const
185 return blockPointField_;
189 const Foam::cellShape& Foam::blockDescriptor::blockShape() const
195 const Foam::List< Foam::List< Foam::point > >&
196 Foam::blockDescriptor::blockEdgePoints() const
202 const Foam::scalarListList& Foam::blockDescriptor::blockEdgeWeights() const
208 const Foam::Vector<Foam::label>& Foam::blockDescriptor::meshDensity() const
214 const Foam::word& Foam::blockDescriptor::zoneName() const
220 Foam::label Foam::blockDescriptor::nPoints() const
224 (meshDensity_.x() + 1)
225 * (meshDensity_.y() + 1)
226 * (meshDensity_.z() + 1)
231 Foam::label Foam::blockDescriptor::nCells() const
242 const Foam::point& Foam::blockDescriptor::blockPoint(const label i) const
244 return blockPointField_[blockShape_[i]];
248 // * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
250 Foam::Ostream& Foam::operator<<(Ostream& os, const blockDescriptor& bd)
252 const cellShape& bshape = bd.blockShape();
253 const labelList& blockLabels = bshape;
255 os << bshape.model().name() << " (";
257 forAll(blockLabels, labelI)
263 os << blockLabels[labelI];
267 if (bd.zoneName().size())
269 os << ' ' << bd.zoneName();
272 os << ' ' << bd.meshDensity()
273 << " simpleGrading (";
276 const scalarList& expand = bd.expand_;
278 // can we use a compact notation?
283 expand[0] == expand[1]
284 && expand[0] == expand[2]
285 && expand[0] == expand[3]
289 expand[4] == expand[5]
290 && expand[4] == expand[6]
291 && expand[4] == expand[7]
295 expand[8] == expand[9]
296 && expand[8] == expand[10]
297 && expand[8] == expand[11]
301 os << expand[0] << ' ' << expand[4] << ' ' << expand[8];
305 forAll(expand, edgeI)
322 // ************************************************************************* //