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

blockPoints.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 vertices for cells filling the block.
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "error.H"
00031 #include "block.H"
00032 
00033 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00034 
00035 void Foam::block::blockPoints()
00036 {
00037     // set local variables for mesh specification
00038     const label ni = blockDef_.n().x();
00039     const label nj = blockDef_.n().y();
00040     const label nk = blockDef_.n().z();
00041 
00042     const point p000 = blockDef_.points()[blockDef_.blockShape()[0]];
00043     const point p100 = blockDef_.points()[blockDef_.blockShape()[1]];
00044     const point p110 = blockDef_.points()[blockDef_.blockShape()[2]];
00045     const point p010 = blockDef_.points()[blockDef_.blockShape()[3]];
00046 
00047     const point p001 = blockDef_.points()[blockDef_.blockShape()[4]];
00048     const point p101 = blockDef_.points()[blockDef_.blockShape()[5]];
00049     const point p111 = blockDef_.points()[blockDef_.blockShape()[6]];
00050     const point p011 = blockDef_.points()[blockDef_.blockShape()[7]];
00051 
00052     // list of edge point and weighting factors
00053     const List<List<point> >& p = blockDef_.blockEdgePoints();
00054     const scalarListList& w = blockDef_.blockEdgeWeights();
00055 
00056     // generate vertices
00057 
00058     for (label k = 0; k <= nk; k++)
00059     {
00060         for (label j = 0; j <= nj; j++)
00061         {
00062             for (label i = 0; i <= ni; i++)
00063             {
00064                 label vertexNo = vtxLabel(i, j, k);
00065 
00066                 // points on edges
00067                 vector edgex1 = p000 + (p100 - p000)*w[0][i];
00068                 vector edgex2 = p010 + (p110 - p010)*w[1][i];
00069                 vector edgex3 = p011 + (p111 - p011)*w[2][i];
00070                 vector edgex4 = p001 + (p101 - p001)*w[3][i];
00071 
00072                 vector edgey1 = p000 + (p010 - p000)*w[4][j];
00073                 vector edgey2 = p100 + (p110 - p100)*w[5][j];
00074                 vector edgey3 = p101 + (p111 - p101)*w[6][j];
00075                 vector edgey4 = p001 + (p011 - p001)*w[7][j];
00076 
00077                 vector edgez1 = p000 + (p001 - p000)*w[8][k];
00078                 vector edgez2 = p100 + (p101 - p100)*w[9][k];
00079                 vector edgez3 = p110 + (p111 - p110)*w[10][k];
00080                 vector edgez4 = p010 + (p011 - p010)*w[11][k];
00081 
00082                 // calculate the importance factors for all edges
00083                 // x - direction
00084                 scalar impx1 =
00085                 (
00086                     (1.0 - w[0][i])*(1.0 - w[4][j])*(1.0 - w[8][k])
00087                   + w[0][i]*(1.0 - w[5][j])*(1.0 - w[9][k])
00088                 );
00089 
00090                 scalar impx2 =
00091                 (
00092                     (1.0 - w[1][i])*w[4][j]*(1.0 - w[11][k])
00093                   + w[1][i]*w[5][j]*(1.0 - w[10][k])
00094                 );
00095 
00096                 scalar impx3 =
00097                 (
00098                      (1.0 - w[2][i])*w[7][j]*w[11][k]
00099                    + w[2][i]*w[6][j]*w[10][k]
00100                 );
00101 
00102 
00103                 scalar impx4 =
00104                 (
00105                     (1.0 - w[3][i])*(1.0 - w[7][j])*w[8][k]
00106                   + w[3][i]*(1.0 - w[6][j])*w[9][k]
00107                 );
00108 
00109                 scalar magImpx = impx1 + impx2 + impx3 + impx4;
00110                 impx1 /= magImpx;
00111                 impx2 /= magImpx;
00112                 impx3 /= magImpx;
00113                 impx4 /= magImpx;
00114 
00115 
00116                 // y - direction
00117                 scalar impy1 =
00118                 (
00119                     (1.0 - w[4][j])*(1.0 - w[0][i])*(1.0 - w[8][k])
00120                   + w[4][j]*(1.0 - w[1][i])*(1.0 - w[11][k])
00121                 );
00122 
00123                 scalar impy2 =
00124                 (
00125                     (1.0 - w[5][j])*w[0][i]*(1.0 - w[9][k])
00126                   + w[5][j]*w[1][i]*(1.0 - w[10][k])
00127                 );
00128 
00129                 scalar impy3 =
00130                 (
00131                     (1.0 - w[6][j])*w[3][i]*w[9][k]
00132                   + w[6][j]*w[2][i]*w[10][k]
00133                 );
00134 
00135                 scalar impy4 =
00136                 (
00137                     (1.0 - w[7][j])*(1.0 - w[3][i])*w[8][k]
00138                   + w[7][j]*(1.0 - w[2][i])*w[11][k]
00139                 );
00140 
00141                 scalar magImpy = impy1 + impy2 + impy3 + impy4;
00142                 impy1 /= magImpy;
00143                 impy2 /= magImpy;
00144                 impy3 /= magImpy;
00145                 impy4 /= magImpy;
00146 
00147 
00148                 // z - direction
00149                 scalar impz1 =
00150                 (
00151                     (1.0 - w[8][k])*(1.0 - w[0][i])*(1.0 - w[4][j])
00152                   + w[8][k]*(1.0 - w[3][i])*(1.0 - w[7][j])
00153                 );
00154 
00155                 scalar impz2 =
00156                 (
00157                     (1.0 - w[9][k])*w[0][i]*(1.0 - w[5][j])
00158                   + w[9][k]*w[3][i]*(1.0 - w[6][j])
00159                 );
00160 
00161                 scalar impz3 =
00162                 (
00163                     (1.0 - w[10][k])*w[1][i]*w[5][j]
00164                   + w[10][k]*w[2][i]*w[6][j]
00165                 );
00166 
00167                 scalar impz4 =
00168                 (
00169                     (1.0 - w[11][k])*(1.0 - w[1][i])*w[4][j]
00170                   + w[11][k]*(1.0 - w[2][i])*w[7][j]
00171                 );
00172 
00173                 scalar magImpz = impz1 + impz2 + impz3 + impz4;
00174                 impz1 /= magImpz;
00175                 impz2 /= magImpz;
00176                 impz3 /= magImpz;
00177                 impz4 /= magImpz;
00178 
00179                 // calculate the correction vectors
00180                 vector corx1 = impx1*(p[0][i] - edgex1);
00181                 vector corx2 = impx2*(p[1][i] - edgex2);
00182                 vector corx3 = impx3*(p[2][i] - edgex3);
00183                 vector corx4 = impx4*(p[3][i] - edgex4);
00184 
00185                 vector cory1 = impy1*(p[4][j] - edgey1);
00186                 vector cory2 = impy2*(p[5][j] - edgey2);
00187                 vector cory3 = impy3*(p[6][j] - edgey3);
00188                 vector cory4 = impy4*(p[7][j] - edgey4);
00189 
00190                 vector corz1 = impz1*(p[8][k] - edgez1);
00191                 vector corz2 = impz2*(p[9][k] - edgez2);
00192                 vector corz3 = impz3*(p[10][k] - edgez3);
00193                 vector corz4 = impz4*(p[11][k] - edgez4);
00194 
00195 
00196                 // multiply by the importance factor
00197 
00198                 // x - direction
00199                 edgex1 *= impx1;
00200                 edgex2 *= impx2;
00201                 edgex3 *= impx3;
00202                 edgex4 *= impx4;
00203 
00204                 // y - direction
00205                 edgey1 *= impy1;
00206                 edgey2 *= impy2;
00207                 edgey3 *= impy3;
00208                 edgey4 *= impy4;
00209 
00210                 // z - direction
00211                 edgez1 *= impz1;
00212                 edgez2 *= impz2;
00213                 edgez3 *= impz3;
00214                 edgez4 *= impz4;
00215 
00216 
00217                 // add the contributions
00218                 vertices_[vertexNo] = edgex1 + edgex2 + edgex3 + edgex4;
00219                 vertices_[vertexNo] += edgey1 + edgey2 + edgey3 + edgey4;
00220                 vertices_[vertexNo] += edgez1 + edgez2 + edgez3 + edgez4;
00221 
00222                 vertices_[vertexNo] /= 3.0;
00223 
00224                 vertices_[vertexNo] += corx1 + corx2 + corx3 + corx4;
00225                 vertices_[vertexNo] += cory1 + cory2 + cory3 + cory4;
00226                 vertices_[vertexNo] += corz1 + corz2 + corz3 + corz4;
00227             }
00228         }
00229     }
00230 }
00231 
00232 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd