initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / generation / blockMesh / blockBoundary.C
blob8086aeea546ecba03980fc4bfe20b71aa5c3f194
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
26     private member of block. Creates boundary patches for the block
28 \*---------------------------------------------------------------------------*/
30 #include "error.H"
31 #include "block.H"
34 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
36 void Foam::block::blockBoundary()
38     label ni = blockDef_.n().x();
39     label nj = blockDef_.n().y();
40     label nk = blockDef_.n().z();
42     // x-direction
44     label wallLabel = 0;
45     label wallCellLabel = 0;
47     // x-min
48     boundaryPatches_[wallLabel].setSize(nj*nk);
49     for (label k = 0; k <= nk - 1; k++)
50     {
51         for (label j = 0; j <= nj - 1; j++)
52         {
53             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
55             // set the points
56             boundaryPatches_[wallLabel][wallCellLabel][0] =
57                 vtxLabel(0, j, k);
58             boundaryPatches_[wallLabel][wallCellLabel][1] =
59                 vtxLabel(0, j, k + 1);
60             boundaryPatches_[wallLabel][wallCellLabel][2] =
61                 vtxLabel(0, j + 1, k + 1);
62             boundaryPatches_[wallLabel][wallCellLabel][3] =
63                 vtxLabel(0, j + 1, k);
65             // update the counter
66             wallCellLabel++;
67         }
68     }
70     // x-max
71     wallLabel++;
72     wallCellLabel = 0;
74     boundaryPatches_[wallLabel].setSize(nj*nk);
76     for (label k = 0; k <= nk - 1; k++)
77     {
78         for (label j = 0; j <= nj - 1; j++)
79         {
80             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
82             // set the points
83             boundaryPatches_[wallLabel][wallCellLabel][0] =
84                 vtxLabel(ni, j, k);
85             boundaryPatches_[wallLabel][wallCellLabel][1] =
86                 vtxLabel(ni, j+1, k);
87             boundaryPatches_[wallLabel][wallCellLabel][2] =
88                 vtxLabel(ni, j+1, k+1);
89             boundaryPatches_[wallLabel][wallCellLabel][3] =
90                 vtxLabel(ni, j, k+1);
92             // update the counter
93             wallCellLabel++;
94         }
95     }
97     // y-direction
99     // y-min
100     wallLabel++;
101     wallCellLabel = 0;
103     boundaryPatches_[wallLabel].setSize(ni*nk);
104     for (label i = 0; i <= ni - 1; i++)
105     {
106         for (label k = 0; k <= nk - 1; k++)
107         {
108             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
110             // set the points
111             boundaryPatches_[wallLabel][wallCellLabel][0] =
112                 vtxLabel(i, 0, k);
113             boundaryPatches_[wallLabel][wallCellLabel][1] =
114                 vtxLabel(i + 1, 0, k);
115             boundaryPatches_[wallLabel][wallCellLabel][2] =
116                 vtxLabel(i + 1, 0, k + 1);
117             boundaryPatches_[wallLabel][wallCellLabel][3] =
118                 vtxLabel(i, 0, k + 1);
120             // update the counter
121             wallCellLabel++;
122         }
123     }
125     // y-max
126     wallLabel++;
127     wallCellLabel = 0;
129     boundaryPatches_[wallLabel].setSize(ni*nk);
131     for (label i = 0; i <= ni - 1; i++)
132     {
133         for (label k = 0; k <= nk - 1; k++)
134         {
135             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
137             // set the points
138             boundaryPatches_[wallLabel][wallCellLabel][0] =
139                 vtxLabel(i, nj, k);
140             boundaryPatches_[wallLabel][wallCellLabel][1] =
141                 vtxLabel(i, nj, k + 1);
142             boundaryPatches_[wallLabel][wallCellLabel][2] =
143                 vtxLabel(i + 1, nj, k + 1);
144             boundaryPatches_[wallLabel][wallCellLabel][3] =
145                 vtxLabel(i + 1, nj, k);
147             // update the counter
148             wallCellLabel++;
149         }
150     }
152     // z-direction
154     // z-min
155     wallLabel++;
156     wallCellLabel = 0;
158     boundaryPatches_[wallLabel].setSize(ni*nj);
160     for (label i = 0; i <= ni - 1; i++)
161     {
162         for (label j = 0; j <= nj - 1; j++)
163         {
164             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
166             // set the points
167             boundaryPatches_[wallLabel][wallCellLabel][0] =
168                 vtxLabel(i, j, 0);
169             boundaryPatches_[wallLabel][wallCellLabel][1] =
170                 vtxLabel(i, j + 1, 0);
171             boundaryPatches_[wallLabel][wallCellLabel][2] =
172                 vtxLabel(i + 1, j + 1, 0);
173             boundaryPatches_[wallLabel][wallCellLabel][3] =
174                 vtxLabel(i + 1, j, 0);
176             // update the counter
177             wallCellLabel++;
178         }
179     }
181     // z-max
182     wallLabel++;
183     wallCellLabel = 0;
185     boundaryPatches_[wallLabel].setSize(ni*nj);
187     for (label i = 0; i <= ni - 1; i++)
188     {
189         for (label j = 0; j <= nj - 1; j++)
190         {
191             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
193             // set the points
194             boundaryPatches_[wallLabel][wallCellLabel][0] =
195                 vtxLabel(i, j, nk);
196             boundaryPatches_[wallLabel][wallCellLabel][1] =
197                 vtxLabel(i + 1, j, nk);
198             boundaryPatches_[wallLabel][wallCellLabel][2] =
199                 vtxLabel(i + 1, j + 1, nk);
200             boundaryPatches_[wallLabel][wallCellLabel][3] =
201                 vtxLabel(i, j + 1, nk);
203             // update the counter
204             wallCellLabel++;
205         }
206     }
209 // ************************************************************************* //