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

setEdge.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     from the list of curved edges creates a list
00027     of edges that are not curved. It is assumed
00028     that all other edges are straight lines
00029 
00030 \*---------------------------------------------------------------------------*/
00031 
00032 #include "error.H"
00033 
00034 #include "blockDescriptor.H"
00035 #include "lineEdge.H"
00036 #include "lineDivide.H"
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 
00040 namespace Foam
00041 {
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 scalar calcGexp(const scalar expRatio, const label dim)
00046 {
00047     if (dim == 1)
00048     {
00049         return 0.0;
00050     }
00051     else
00052     {
00053         return pow(expRatio, 1.0/(dim - 1));
00054     }
00055 }
00056 
00057 
00058 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00059 
00060 void blockDescriptor::setEdge(label edgeI, label start, label end, label dim)
00061 {
00062     // for all edges check the list of curved edges. If the edge is curved,
00063     // add it to the list. If the edge is not found, create is as a line
00064 
00065     bool found = false;
00066 
00067     // set reference to the list of labels defining the block
00068     const labelList& blockLabels = blockShape_;
00069 
00070     // set reference to global list of points
00071     const pointField blockPoints = blockShape_.points(blockMeshPoints_);
00072 
00073     // x1
00074     found = false;
00075 
00076     forAll (curvedEdges_, nCEI)
00077     {
00078         if (curvedEdges_[nCEI].compare(blockLabels[start], blockLabels[end]))
00079         {
00080             found = true;
00081 
00082             // check the orientation:
00083             // if the starting point of the curve is the same as the starting
00084             // point of the edge, do the parametrisation and pick up the points
00085             if (blockLabels[start] == curvedEdges_[nCEI].start())
00086             {
00087                 // calculate the geometric expension factor out of the
00088                 // expansion ratio
00089                 scalar gExp = calcGexp(expand_[edgeI], dim);
00090 
00091                 // divide the line
00092                 lineDivide divEdge(curvedEdges_[nCEI], dim, gExp);
00093 
00094                 edgePoints_[edgeI] = divEdge.points();
00095                 edgeWeights_[edgeI] = divEdge.lambdaDivisions();
00096             }
00097             else
00098             {
00099                 // the curve has got the opposite orientation
00100                 scalar gExp = calcGexp(expand_[edgeI], dim);
00101 
00102                 // divide the line
00103                 lineDivide divEdge(curvedEdges_[nCEI], dim, 1.0/(gExp+SMALL));
00104 
00105                 pointField p = divEdge.points();
00106                 scalarList d = divEdge.lambdaDivisions();
00107 
00108                 edgePoints_[edgeI].setSize(p.size());
00109                 edgeWeights_[edgeI].setSize(d.size());
00110 
00111                 label pMax = p.size() - 1;
00112                 forAll (p, pI)
00113                 {
00114                     edgePoints_[edgeI][pI] = p[pMax - pI];
00115                     edgeWeights_[edgeI][pI] = 1.0 - d[pMax - pI];
00116                 }
00117             }
00118 
00119             break;
00120         }
00121     }
00122 
00123     if (!found)
00124     {
00125         // edge is a straight line
00126         scalar gExp = calcGexp(expand_[edgeI], dim);
00127 
00128         // divide the line
00129         lineDivide divEdge
00130         (
00131             lineEdge(blockPoints, start, end),
00132             dim,
00133             gExp
00134         );
00135 
00136         edgePoints_[edgeI] = divEdge.points();
00137         edgeWeights_[edgeI] = divEdge.lambdaDivisions();
00138     }
00139 }
00140 
00141 
00142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00143 
00144 } // End namespace Foam
00145 
00146 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd