FreeFOAM The Cross-Platform CFD Toolkit
blockDescriptor.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include <OpenFOAM/error.H>
29 
30 #include "blockDescriptor.H"
31 #include <OpenFOAM/scalarList.H>
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 
40 void blockDescriptor::makeBlockEdges()
41 {
42  // for all edges check the list of curved edges. If the edge is curved,
43  // add it to the list. If the edge is not found, create is as a line
44 
45  setEdge(0, 0, 1, n_.x());
46  setEdge(1, 3, 2, n_.x());
47  setEdge(2, 7, 6, n_.x());
48  setEdge(3, 4, 5, n_.x());
49 
50  setEdge(4, 0, 3, n_.y());
51  setEdge(5, 1, 2, n_.y());
52  setEdge(6, 5, 6, n_.y());
53  setEdge(7, 4, 7, n_.y());
54 
55  setEdge(8, 0, 4, n_.z());
56  setEdge(9, 1, 5, n_.z());
57  setEdge(10, 2, 6, n_.z());
58  setEdge(11, 3, 7, n_.z());
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
64 // from components
66 (
67  const cellShape& bshape,
68  const pointField& blockMeshPoints,
69  const curvedEdgeList& edges,
70  const Vector<label>& n,
71  const scalarList& expand,
72  const word& zoneName
73 )
74 :
75  blockMeshPoints_(blockMeshPoints),
76  blockShape_(bshape),
77  curvedEdges_(edges),
78  edgePoints_(12),
79  edgeWeights_(12),
80  n_(n),
81  expand_(expand),
82  zoneName_(zoneName)
83 {
84  if (expand_.size() != 12)
85  {
87  (
88  "blockDescriptor::blockDescriptor"
89  "(const cellShape& bshape, const pointField& blockMeshPoints, "
90  "const curvedEdgeList& edges, label xnum, label ynum, label znum, "
91  "const scalarList& expand, const word& zoneName)"
92  ) << "Unknown definition of expansion ratios"
93  << exit(FatalError);
94  }
95 
96  makeBlockEdges();
97 }
98 
99 
100 // from Istream
102 (
103  const pointField& blockMeshPoints,
104  const curvedEdgeList& edges,
105  Istream& is
106 )
107 :
108  blockMeshPoints_(blockMeshPoints),
109  blockShape_(is),
110  curvedEdges_(edges),
111  edgePoints_(12),
112  edgeWeights_(12),
113  n_(),
114  expand_(12),
115  zoneName_()
116 {
117  // Look at first token
118  token t(is);
119  is.putBack(t);
120 
121  // Optional zone name
122  if (t.isWord())
123  {
124  zoneName_ = t.wordToken();
125 
126  // Consume zoneName token
127  is >> t;
128 
129  // New look-ahead
130  is >> t;
131  is.putBack(t);
132  }
133 
134  if (t.isPunctuation())
135  {
136  if (t.pToken() == token::BEGIN_LIST)
137  {
138  is >> n_;
139  }
140  else
141  {
143  (
144  "blockDescriptor::blockDescriptor"
145  "(const pointField&, const curvedEdgeList&, Istream& is)",
146  is
147  ) << "incorrect token while reading n, expected '(', found "
148  << t.info()
149  << exit(FatalIOError);
150  }
151  }
152  else
153  {
154  is >> n_.x() >> n_.y() >> n_.z();
155  }
156 
157  is >> t;
158  if (!t.isWord())
159  {
160  is.putBack(t);
161  }
162 
163  scalarList expRatios(is);
164 
165  if (expRatios.size() == 3)
166  {
167  expand_[0] = expRatios[0];
168  expand_[1] = expRatios[0];
169  expand_[2] = expRatios[0];
170  expand_[3] = expRatios[0];
171 
172  expand_[4] = expRatios[1];
173  expand_[5] = expRatios[1];
174  expand_[6] = expRatios[1];
175  expand_[7] = expRatios[1];
176 
177  expand_[8] = expRatios[2];
178  expand_[9] = expRatios[2];
179  expand_[10] = expRatios[2];
180  expand_[11] = expRatios[2];
181  }
182  else if (expRatios.size() == 12)
183  {
184  expand_ = expRatios;
185  }
186  else
187  {
189  (
190  "blockDescriptor::blockDescriptor"
191  "(const pointField& blockMeshPoints, const curvedEdgeList& edges,"
192  "Istream& is)"
193  ) << "Unknown definition of expansion ratios"
194  << exit(FatalError);
195  }
196 
197  // create a list of edges
198  makeBlockEdges();
199 }
200 
201 
202 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
203 
204 const pointField& blockDescriptor::points() const
205 {
206  return blockMeshPoints_;
207 }
208 
209 const cellShape& blockDescriptor::blockShape() const
210 {
211  return blockShape_;
212 }
213 
214 const List<List<point> >& blockDescriptor::blockEdgePoints() const
215 {
216  return edgePoints_;
217 }
218 
220 {
221  return edgeWeights_;
222 }
223 
224 const Vector<label>& blockDescriptor::n() const
225 {
226  return n_;
227 }
228 
229 const word& blockDescriptor::zoneName() const
230 {
231  return zoneName_;
232 }
233 
234 
235 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
236 
237 void blockDescriptor::operator=(const blockDescriptor&)
238 {
239  notImplemented("void blockDescriptor::operator=(const blockDescriptor&)");
240 }
241 
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 } // End namespace Foam
246 
247 // ************************ vim: set sw=4 sts=4 et: ************************ //