initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / generation / blockMesh / blockDescriptor.C
blob7d40c4d7cb00a53ea8a84cbadf2a4cf69b3f8c5b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
27 \*---------------------------------------------------------------------------*/
29 #include "error.H"
31 #include "blockDescriptor.H"
32 #include "scalarList.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
41 void blockDescriptor::makeBlockEdges()
43     // for all edges check the list of curved edges. If the edge is curved,
44     // add it to the list. If the edge is not found, create is as a line
46     setEdge(0, 0, 1, n_.x());
47     setEdge(1, 3, 2, n_.x());
48     setEdge(2, 7, 6, n_.x());
49     setEdge(3, 4, 5, n_.x());
51     setEdge(4, 0, 3, n_.y());
52     setEdge(5, 1, 2, n_.y());
53     setEdge(6, 5, 6, n_.y());
54     setEdge(7, 4, 7, n_.y());
56     setEdge(8, 0, 4, n_.z());
57     setEdge(9, 1, 5, n_.z());
58     setEdge(10, 2, 6, n_.z());
59     setEdge(11, 3, 7, n_.z());
63 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
65 // from components
66 blockDescriptor::blockDescriptor
68     const cellShape& bshape,
69     const pointField& blockMeshPoints,
70     const curvedEdgeList& edges,
71     const Vector<label>& n,
72     const scalarList& expand,
73     const word& zoneName
76     blockMeshPoints_(blockMeshPoints),
77     blockShape_(bshape),
78     curvedEdges_(edges),
79     edgePoints_(12),
80     edgeWeights_(12),
81     n_(n),
82     expand_(expand),
83     zoneName_(zoneName)
85     if (expand_.size() != 12)
86     {
87         FatalErrorIn
88         (
89             "blockDescriptor::blockDescriptor"
90             "(const cellShape& bshape, const pointField& blockMeshPoints, "
91             "const curvedEdgeList& edges, label xnum, label ynum, label znum, "
92             "const scalarList& expand, const word& zoneName)"
93         )   << "Unknown definition of expansion ratios"
94             << exit(FatalError);
95     }
97     makeBlockEdges();
101 // from Istream
102 blockDescriptor::blockDescriptor
104     const pointField& blockMeshPoints,
105     const curvedEdgeList& edges,
106     Istream& is
109     blockMeshPoints_(blockMeshPoints),
110     blockShape_(is),
111     curvedEdges_(edges),
112     edgePoints_(12),
113     edgeWeights_(12),
114     n_(),
115     expand_(12),
116     zoneName_()
118     // Look at first token
119     token t(is);
120     is.putBack(t);
122     // Optional zone name
123     if (t.isWord())
124     {
125         zoneName_ = t.wordToken();
127         // Consume zoneName token
128         is >> t;
130         // New look-ahead
131         is >> t;
132         is.putBack(t);
133     }
135     if (t.isPunctuation())
136     {
137         if (t.pToken() == token::BEGIN_LIST)
138         {
139             is >> n_;
140         }
141         else
142         {
143             FatalIOErrorIn
144             (
145                 "blockDescriptor::blockDescriptor"
146                 "(const pointField&, const curvedEdgeList&, Istream& is)",
147                 is
148             )   << "incorrect token while reading n, expected '(', found "
149                 << t.info()
150                 << exit(FatalIOError);
151         }
152     }
153     else
154     {
155         is >> n_.x() >> n_.y() >> n_.z();
156     }
158     is >> t;
159     if (!t.isWord())
160     {
161         is.putBack(t);
162     }
164     scalarList expRatios(is);
166     if (expRatios.size() == 3)
167     {
168         expand_[0] = expRatios[0];
169         expand_[1] = expRatios[0];
170         expand_[2] = expRatios[0];
171         expand_[3] = expRatios[0];
173         expand_[4] = expRatios[1];
174         expand_[5] = expRatios[1];
175         expand_[6] = expRatios[1];
176         expand_[7] = expRatios[1];
178         expand_[8] = expRatios[2];
179         expand_[9] = expRatios[2];
180         expand_[10] = expRatios[2];
181         expand_[11] = expRatios[2];
182     }
183     else if (expRatios.size() == 12)
184     {
185         expand_ = expRatios;
186     }
187     else
188     {
189         FatalErrorIn
190         (
191             "blockDescriptor::blockDescriptor"
192             "(const pointField& blockMeshPoints, const curvedEdgeList& edges,"
193             "Istream& is)"
194         )   << "Unknown definition of expansion ratios"
195             << exit(FatalError);
196     }
198     // create a list of edges
199     makeBlockEdges();
203 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
205 const pointField& blockDescriptor::points() const
207     return blockMeshPoints_;
210 const cellShape& blockDescriptor::blockShape() const
212     return blockShape_;
215 const List<List<point> >& blockDescriptor::blockEdgePoints() const
217     return edgePoints_;
220 const scalarListList& blockDescriptor::blockEdgeWeights() const
222     return edgeWeights_;
225 const Vector<label>& blockDescriptor::n() const
227     return n_;
230 const word& blockDescriptor::zoneName() const
232     return zoneName_;
236 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
238 void blockDescriptor::operator=(const blockDescriptor&)
240     notImplemented("void blockDescriptor::operator=(const blockDescriptor&)");
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 } // End namespace Foam
248 // ************************************************************************* //