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

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