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

lineDivide.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     lineDivide class : divides a line into segments
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "error.H"
00031 
00032 #include "lineDivide.H"
00033 #include "curvedEdge.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace Foam
00038 {
00039 
00040 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00041 
00042 // Construct from components
00043 lineDivide::lineDivide(const curvedEdge& bc, const label n, const scalar xratio)
00044 :
00045     points_(n + 1),
00046     divisions_(n + 1),
00047     noPoints_(n)
00048 {
00049     scalar np(n);
00050     scalar lambda(0.0);
00051 
00052     if (xratio == 1.0)
00053     {
00054         scalar y(1.0/np);
00055         for (label i=0; i<=noPoints_; i++)
00056         {
00057             lambda = scalar(i)/np;
00058             points_[i] = bc.position(lambda);
00059             divisions_[i] = y*i;
00060         }
00061     }
00062     else
00063     {
00064         points_[0] = bc.position(0.0);
00065         divisions_[0] = 0.0;
00066         scalar xrpower = 1.0;
00067 
00068         for (label i=1; i<=noPoints_; i++)
00069         {
00070             lambda = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, np));
00071             points_[i] = bc.position(lambda);
00072             divisions_[i] = lambda;
00073             xrpower *= xratio;
00074         }
00075     }
00076 }
00077 
00078 
00079 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00080 
00081 const pointField& lineDivide::points() const
00082 {
00083     return points_;
00084 }
00085 
00086 
00087 const scalarList& lineDivide::lambdaDivisions() const
00088 {
00089     return divisions_;
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00094 
00095 } // End namespace Foam
00096 
00097 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd