FreeFOAM The Cross-Platform CFD Toolkit
blockBoundary.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  private member of block. Creates boundary patches for the block
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include <OpenFOAM/error.H>
30 #include "block.H"
31 
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 void Foam::block::blockBoundary()
36 {
37  label ni = blockDef_.n().x();
38  label nj = blockDef_.n().y();
39  label nk = blockDef_.n().z();
40 
41  // x-direction
42 
43  label wallLabel = 0;
44  label wallCellLabel = 0;
45 
46  // x-min
47  boundaryPatches_[wallLabel].setSize(nj*nk);
48  for (label k = 0; k <= nk - 1; k++)
49  {
50  for (label j = 0; j <= nj - 1; j++)
51  {
52  boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
53 
54  // set the points
55  boundaryPatches_[wallLabel][wallCellLabel][0] =
56  vtxLabel(0, j, k);
57  boundaryPatches_[wallLabel][wallCellLabel][1] =
58  vtxLabel(0, j, k + 1);
59  boundaryPatches_[wallLabel][wallCellLabel][2] =
60  vtxLabel(0, j + 1, k + 1);
61  boundaryPatches_[wallLabel][wallCellLabel][3] =
62  vtxLabel(0, j + 1, k);
63 
64  // update the counter
65  wallCellLabel++;
66  }
67  }
68 
69  // x-max
70  wallLabel++;
71  wallCellLabel = 0;
72 
73  boundaryPatches_[wallLabel].setSize(nj*nk);
74 
75  for (label k = 0; k <= nk - 1; k++)
76  {
77  for (label j = 0; j <= nj - 1; j++)
78  {
79  boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
80 
81  // set the points
82  boundaryPatches_[wallLabel][wallCellLabel][0] =
83  vtxLabel(ni, j, k);
84  boundaryPatches_[wallLabel][wallCellLabel][1] =
85  vtxLabel(ni, j+1, k);
86  boundaryPatches_[wallLabel][wallCellLabel][2] =
87  vtxLabel(ni, j+1, k+1);
88  boundaryPatches_[wallLabel][wallCellLabel][3] =
89  vtxLabel(ni, j, k+1);
90 
91  // update the counter
92  wallCellLabel++;
93  }
94  }
95 
96  // y-direction
97 
98  // y-min
99  wallLabel++;
100  wallCellLabel = 0;
101 
102  boundaryPatches_[wallLabel].setSize(ni*nk);
103  for (label i = 0; i <= ni - 1; i++)
104  {
105  for (label k = 0; k <= nk - 1; k++)
106  {
107  boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
108 
109  // set the points
110  boundaryPatches_[wallLabel][wallCellLabel][0] =
111  vtxLabel(i, 0, k);
112  boundaryPatches_[wallLabel][wallCellLabel][1] =
113  vtxLabel(i + 1, 0, k);
114  boundaryPatches_[wallLabel][wallCellLabel][2] =
115  vtxLabel(i + 1, 0, k + 1);
116  boundaryPatches_[wallLabel][wallCellLabel][3] =
117  vtxLabel(i, 0, k + 1);
118 
119  // update the counter
120  wallCellLabel++;
121  }
122  }
123 
124  // y-max
125  wallLabel++;
126  wallCellLabel = 0;
127 
128  boundaryPatches_[wallLabel].setSize(ni*nk);
129 
130  for (label i = 0; i <= ni - 1; i++)
131  {
132  for (label k = 0; k <= nk - 1; k++)
133  {
134  boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
135 
136  // set the points
137  boundaryPatches_[wallLabel][wallCellLabel][0] =
138  vtxLabel(i, nj, k);
139  boundaryPatches_[wallLabel][wallCellLabel][1] =
140  vtxLabel(i, nj, k + 1);
141  boundaryPatches_[wallLabel][wallCellLabel][2] =
142  vtxLabel(i + 1, nj, k + 1);
143  boundaryPatches_[wallLabel][wallCellLabel][3] =
144  vtxLabel(i + 1, nj, k);
145 
146  // update the counter
147  wallCellLabel++;
148  }
149  }
150 
151  // z-direction
152 
153  // z-min
154  wallLabel++;
155  wallCellLabel = 0;
156 
157  boundaryPatches_[wallLabel].setSize(ni*nj);
158 
159  for (label i = 0; i <= ni - 1; i++)
160  {
161  for (label j = 0; j <= nj - 1; j++)
162  {
163  boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
164 
165  // set the points
166  boundaryPatches_[wallLabel][wallCellLabel][0] =
167  vtxLabel(i, j, 0);
168  boundaryPatches_[wallLabel][wallCellLabel][1] =
169  vtxLabel(i, j + 1, 0);
170  boundaryPatches_[wallLabel][wallCellLabel][2] =
171  vtxLabel(i + 1, j + 1, 0);
172  boundaryPatches_[wallLabel][wallCellLabel][3] =
173  vtxLabel(i + 1, j, 0);
174 
175  // update the counter
176  wallCellLabel++;
177  }
178  }
179 
180  // z-max
181  wallLabel++;
182  wallCellLabel = 0;
183 
184  boundaryPatches_[wallLabel].setSize(ni*nj);
185 
186  for (label i = 0; i <= ni - 1; i++)
187  {
188  for (label j = 0; j <= nj - 1; j++)
189  {
190  boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
191 
192  // set the points
193  boundaryPatches_[wallLabel][wallCellLabel][0] =
194  vtxLabel(i, j, nk);
195  boundaryPatches_[wallLabel][wallCellLabel][1] =
196  vtxLabel(i + 1, j, nk);
197  boundaryPatches_[wallLabel][wallCellLabel][2] =
198  vtxLabel(i + 1, j + 1, nk);
199  boundaryPatches_[wallLabel][wallCellLabel][3] =
200  vtxLabel(i, j + 1, nk);
201 
202  // update the counter
203  wallCellLabel++;
204  }
205  }
206 }
207 
208 // ************************ vim: set sw=4 sts=4 et: ************************ //