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

lineEdge.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     line class : defines a straight line between the start point and the
00027     end point
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 #include "error.H"
00032 
00033 #include "lineEdge.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace Foam
00038 {
00039 
00040 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00041 
00042 defineTypeNameAndDebug(lineEdge, 0);
00043 
00044 // Add the curvedEdge constructor functions to the hash tables
00045 curvedEdge::addIstreamConstructorToTable<lineEdge>
00046     addLineEdgeIstreamConstructorToTable_;
00047 
00048 
00049 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00050 
00051 // Construct from components
00052 lineEdge::lineEdge
00053 (
00054     const pointField& points,
00055     const label start,
00056     const label end
00057 )
00058 :
00059     curvedEdge(points, start, end),
00060     startPoint_(points_[start_]),
00061     direction_(points_[end_] - points_[start_])
00062 {}
00063 
00064 
00065 // Construct from Istream
00066 lineEdge::lineEdge(const pointField& points, Istream& is)
00067 :
00068     curvedEdge(points, is),
00069     startPoint_(points_[start_]),
00070     direction_(points_[end_] - points_[start_])
00071 {}
00072 
00073 
00074 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00075 
00076 vector lineEdge::position(const scalar lambda) const
00077 {
00078     if (lambda < 0 || lambda > 1)
00079     {
00080         FatalErrorIn("lineEdge::position(const scalar)")
00081             << "Parameter out of range, lambda = " << lambda
00082             << abort(FatalError);
00083     }
00084 
00085     return startPoint_ + lambda*direction_;
00086 }
00087 
00088 
00089 //- Return the length of the curve
00090 scalar lineEdge::length() const
00091 {
00092     return mag(direction_);
00093 }
00094 
00095 
00096 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00097 
00098 } // End namespace Foam
00099 
00100 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd