FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025     private member of block. Creates boundary patches for the block
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include <OpenFOAM/error.H>
00030 #include "block.H"
00031 
00032 
00033 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00034 
00035 void Foam::block::blockBoundary()
00036 {
00037     label ni = blockDef_.n().x();
00038     label nj = blockDef_.n().y();
00039     label nk = blockDef_.n().z();
00040 
00041     // x-direction
00042 
00043     label wallLabel = 0;
00044     label wallCellLabel = 0;
00045 
00046     // x-min
00047     boundaryPatches_[wallLabel].setSize(nj*nk);
00048     for (label k = 0; k <= nk - 1; k++)
00049     {
00050         for (label j = 0; j <= nj - 1; j++)
00051         {
00052             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00053 
00054             // set the points
00055             boundaryPatches_[wallLabel][wallCellLabel][0] =
00056                 vtxLabel(0, j, k);
00057             boundaryPatches_[wallLabel][wallCellLabel][1] =
00058                 vtxLabel(0, j, k + 1);
00059             boundaryPatches_[wallLabel][wallCellLabel][2] =
00060                 vtxLabel(0, j + 1, k + 1);
00061             boundaryPatches_[wallLabel][wallCellLabel][3] =
00062                 vtxLabel(0, j + 1, k);
00063 
00064             // update the counter
00065             wallCellLabel++;
00066         }
00067     }
00068 
00069     // x-max
00070     wallLabel++;
00071     wallCellLabel = 0;
00072 
00073     boundaryPatches_[wallLabel].setSize(nj*nk);
00074 
00075     for (label k = 0; k <= nk - 1; k++)
00076     {
00077         for (label j = 0; j <= nj - 1; j++)
00078         {
00079             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00080 
00081             // set the points
00082             boundaryPatches_[wallLabel][wallCellLabel][0] =
00083                 vtxLabel(ni, j, k);
00084             boundaryPatches_[wallLabel][wallCellLabel][1] =
00085                 vtxLabel(ni, j+1, k);
00086             boundaryPatches_[wallLabel][wallCellLabel][2] =
00087                 vtxLabel(ni, j+1, k+1);
00088             boundaryPatches_[wallLabel][wallCellLabel][3] =
00089                 vtxLabel(ni, j, k+1);
00090 
00091             // update the counter
00092             wallCellLabel++;
00093         }
00094     }
00095 
00096     // y-direction
00097 
00098     // y-min
00099     wallLabel++;
00100     wallCellLabel = 0;
00101 
00102     boundaryPatches_[wallLabel].setSize(ni*nk);
00103     for (label i = 0; i <= ni - 1; i++)
00104     {
00105         for (label k = 0; k <= nk - 1; k++)
00106         {
00107             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00108 
00109             // set the points
00110             boundaryPatches_[wallLabel][wallCellLabel][0] =
00111                 vtxLabel(i, 0, k);
00112             boundaryPatches_[wallLabel][wallCellLabel][1] =
00113                 vtxLabel(i + 1, 0, k);
00114             boundaryPatches_[wallLabel][wallCellLabel][2] =
00115                 vtxLabel(i + 1, 0, k + 1);
00116             boundaryPatches_[wallLabel][wallCellLabel][3] =
00117                 vtxLabel(i, 0, k + 1);
00118 
00119             // update the counter
00120             wallCellLabel++;
00121         }
00122     }
00123 
00124     // y-max
00125     wallLabel++;
00126     wallCellLabel = 0;
00127 
00128     boundaryPatches_[wallLabel].setSize(ni*nk);
00129 
00130     for (label i = 0; i <= ni - 1; i++)
00131     {
00132         for (label k = 0; k <= nk - 1; k++)
00133         {
00134             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00135 
00136             // set the points
00137             boundaryPatches_[wallLabel][wallCellLabel][0] =
00138                 vtxLabel(i, nj, k);
00139             boundaryPatches_[wallLabel][wallCellLabel][1] =
00140                 vtxLabel(i, nj, k + 1);
00141             boundaryPatches_[wallLabel][wallCellLabel][2] =
00142                 vtxLabel(i + 1, nj, k + 1);
00143             boundaryPatches_[wallLabel][wallCellLabel][3] =
00144                 vtxLabel(i + 1, nj, k);
00145 
00146             // update the counter
00147             wallCellLabel++;
00148         }
00149     }
00150 
00151     // z-direction
00152 
00153     // z-min
00154     wallLabel++;
00155     wallCellLabel = 0;
00156 
00157     boundaryPatches_[wallLabel].setSize(ni*nj);
00158 
00159     for (label i = 0; i <= ni - 1; i++)
00160     {
00161         for (label j = 0; j <= nj - 1; j++)
00162         {
00163             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00164 
00165             // set the points
00166             boundaryPatches_[wallLabel][wallCellLabel][0] =
00167                 vtxLabel(i, j, 0);
00168             boundaryPatches_[wallLabel][wallCellLabel][1] =
00169                 vtxLabel(i, j + 1, 0);
00170             boundaryPatches_[wallLabel][wallCellLabel][2] =
00171                 vtxLabel(i + 1, j + 1, 0);
00172             boundaryPatches_[wallLabel][wallCellLabel][3] =
00173                 vtxLabel(i + 1, j, 0);
00174 
00175             // update the counter
00176             wallCellLabel++;
00177         }
00178     }
00179 
00180     // z-max
00181     wallLabel++;
00182     wallCellLabel = 0;
00183 
00184     boundaryPatches_[wallLabel].setSize(ni*nj);
00185 
00186     for (label i = 0; i <= ni - 1; i++)
00187     {
00188         for (label j = 0; j <= nj - 1; j++)
00189         {
00190             boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
00191 
00192             // set the points
00193             boundaryPatches_[wallLabel][wallCellLabel][0] =
00194                 vtxLabel(i, j, nk);
00195             boundaryPatches_[wallLabel][wallCellLabel][1] =
00196                 vtxLabel(i + 1, j, nk);
00197             boundaryPatches_[wallLabel][wallCellLabel][2] =
00198                 vtxLabel(i + 1, j + 1, nk);
00199             boundaryPatches_[wallLabel][wallCellLabel][3] =
00200                 vtxLabel(i, j + 1, nk);
00201 
00202             // update the counter
00203             wallCellLabel++;
00204         }
00205     }
00206 }
00207 
00208 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines