OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

blockBoundary.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     private member of block. Creates boundary patches for the block
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "error.H"
00031 #include "block.H"
00032 
00033 
00034 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00035 
00036 void Foam::block::blockBoundary()
00037 {
00038     label ni = blockDef_.n().x();
00039     label nj = blockDef_.n().y();
00040     label nk = blockDef_.n().z();
00041 
00042     // x-direction
00043 
00044     label wallLabel = 0;
00045     label wallCellLabel = 0;
00046 
00047     // x-min
00048     boundaryPatches_[wallLabel].setSize(nj*nk);
00049     for (label k = 0; k <= nk - 1; k++)
00050     {
00051         for (label j = 0; j <= nj - 1; j++)
00052         {
00053             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00054 
00055             // set the points
00056             boundaryPatches_[wallLabel][wallCellLabel][0] =
00057                 vtxLabel(0, j, k);
00058             boundaryPatches_[wallLabel][wallCellLabel][1] =
00059                 vtxLabel(0, j, k + 1);
00060             boundaryPatches_[wallLabel][wallCellLabel][2] =
00061                 vtxLabel(0, j + 1, k + 1);
00062             boundaryPatches_[wallLabel][wallCellLabel][3] =
00063                 vtxLabel(0, j + 1, k);
00064 
00065             // update the counter
00066             wallCellLabel++;
00067         }
00068     }
00069 
00070     // x-max
00071     wallLabel++;
00072     wallCellLabel = 0;
00073 
00074     boundaryPatches_[wallLabel].setSize(nj*nk);
00075 
00076     for (label k = 0; k <= nk - 1; k++)
00077     {
00078         for (label j = 0; j <= nj - 1; j++)
00079         {
00080             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00081 
00082             // set the points
00083             boundaryPatches_[wallLabel][wallCellLabel][0] =
00084                 vtxLabel(ni, j, k);
00085             boundaryPatches_[wallLabel][wallCellLabel][1] =
00086                 vtxLabel(ni, j+1, k);
00087             boundaryPatches_[wallLabel][wallCellLabel][2] =
00088                 vtxLabel(ni, j+1, k+1);
00089             boundaryPatches_[wallLabel][wallCellLabel][3] =
00090                 vtxLabel(ni, j, k+1);
00091 
00092             // update the counter
00093             wallCellLabel++;
00094         }
00095     }
00096 
00097     // y-direction
00098 
00099     // y-min
00100     wallLabel++;
00101     wallCellLabel = 0;
00102 
00103     boundaryPatches_[wallLabel].setSize(ni*nk);
00104     for (label i = 0; i <= ni - 1; i++)
00105     {
00106         for (label k = 0; k <= nk - 1; k++)
00107         {
00108             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00109 
00110             // set the points
00111             boundaryPatches_[wallLabel][wallCellLabel][0] =
00112                 vtxLabel(i, 0, k);
00113             boundaryPatches_[wallLabel][wallCellLabel][1] =
00114                 vtxLabel(i + 1, 0, k);
00115             boundaryPatches_[wallLabel][wallCellLabel][2] =
00116                 vtxLabel(i + 1, 0, k + 1);
00117             boundaryPatches_[wallLabel][wallCellLabel][3] =
00118                 vtxLabel(i, 0, k + 1);
00119 
00120             // update the counter
00121             wallCellLabel++;
00122         }
00123     }
00124 
00125     // y-max
00126     wallLabel++;
00127     wallCellLabel = 0;
00128 
00129     boundaryPatches_[wallLabel].setSize(ni*nk);
00130 
00131     for (label i = 0; i <= ni - 1; i++)
00132     {
00133         for (label k = 0; k <= nk - 1; k++)
00134         {
00135             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00136 
00137             // set the points
00138             boundaryPatches_[wallLabel][wallCellLabel][0] =
00139                 vtxLabel(i, nj, k);
00140             boundaryPatches_[wallLabel][wallCellLabel][1] =
00141                 vtxLabel(i, nj, k + 1);
00142             boundaryPatches_[wallLabel][wallCellLabel][2] =
00143                 vtxLabel(i + 1, nj, k + 1);
00144             boundaryPatches_[wallLabel][wallCellLabel][3] =
00145                 vtxLabel(i + 1, nj, k);
00146 
00147             // update the counter
00148             wallCellLabel++;
00149         }
00150     }
00151 
00152     // z-direction
00153 
00154     // z-min
00155     wallLabel++;
00156     wallCellLabel = 0;
00157 
00158     boundaryPatches_[wallLabel].setSize(ni*nj);
00159 
00160     for (label i = 0; i <= ni - 1; i++)
00161     {
00162         for (label j = 0; j <= nj - 1; j++)
00163         {
00164             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00165 
00166             // set the points
00167             boundaryPatches_[wallLabel][wallCellLabel][0] =
00168                 vtxLabel(i, j, 0);
00169             boundaryPatches_[wallLabel][wallCellLabel][1] =
00170                 vtxLabel(i, j + 1, 0);
00171             boundaryPatches_[wallLabel][wallCellLabel][2] =
00172                 vtxLabel(i + 1, j + 1, 0);
00173             boundaryPatches_[wallLabel][wallCellLabel][3] =
00174                 vtxLabel(i + 1, j, 0);
00175 
00176             // update the counter
00177             wallCellLabel++;
00178         }
00179     }
00180 
00181     // z-max
00182     wallLabel++;
00183     wallCellLabel = 0;
00184 
00185     boundaryPatches_[wallLabel].setSize(ni*nj);
00186 
00187     for (label i = 0; i <= ni - 1; i++)
00188     {
00189         for (label j = 0; j <= nj - 1; j++)
00190         {
00191             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00192 
00193             // set the points
00194             boundaryPatches_[wallLabel][wallCellLabel][0] =
00195                 vtxLabel(i, j, nk);
00196             boundaryPatches_[wallLabel][wallCellLabel][1] =
00197                 vtxLabel(i + 1, j, nk);
00198             boundaryPatches_[wallLabel][wallCellLabel][2] =
00199                 vtxLabel(i + 1, j + 1, nk);
00200             boundaryPatches_[wallLabel][wallCellLabel][3] =
00201                 vtxLabel(i, j + 1, nk);
00202 
00203             // update the counter
00204             wallCellLabel++;
00205         }
00206     }
00207 }
00208 
00209 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd