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

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