OpenFOAM logo
Open Source CFD Toolkit

arrow2DI.H

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-2005 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 Class
00026     arrow2D
00027 
00028 Description
00029     2D arrow.
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #include "Gstream.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace Foam
00038 {
00039 
00040 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00041 
00042 inline void arrow2D::createHead(const scalar headratio)
00043 {
00044     scalar headwidth(0.5);
00045     point2D back(headratio*(tail-head));
00046 
00047     point2D norm(-headwidth*back.y(), headwidth*back.x());
00048 
00049     head1 = head + back + norm;
00050     head2 = head + back - norm;
00051 }
00052 
00053 
00054 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00055 
00056 // Construct from components
00057 inline arrow2D::arrow2D
00058 (
00059     const point2D t,
00060     const point2D h,
00061     const scalar lengthratio,
00062     const scalar headratio
00063 )
00064 :
00065     tail(t),
00066     head(t+lengthratio*h),
00067     head1(0.0,0.0),
00068     head2(0.0,0.0)
00069 {
00070     createHead(headratio);
00071 }
00072 
00073 
00074 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00075 
00076 inline const point2D& arrow2D::Head() const
00077 {
00078     return head;
00079 }
00080 
00081 inline const point2D& arrow2D::Tail() const
00082 {
00083     return tail;
00084 }
00085 
00086 inline const point2D& arrow2D::Head1() const
00087 {
00088     return head1;
00089 }
00090 
00091 inline const point2D& arrow2D::Head2() const
00092 {
00093     return head2;
00094 }
00095 
00096 
00097 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00098 
00099 inline void arrow2D::operator=(const arrow2D& a)
00100 {
00101     tail = a.tail;
00102     head = a.head;
00103     head1 = a.head1;
00104     head2 = a.head2;
00105 }
00106 
00107 
00108 // * * * * * * * * * * * * * * * Friend Operators  * * * * * * * * * * * * * //
00109 
00110 inline Gstream& operator<<(Gstream& gs, arrow2D& a)
00111 {
00112     a.draw(gs);
00113     return gs;
00114 }
00115 
00116 
00117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00118 
00119 } // End namespace Foam
00120 
00121 // ************************************************************************* //
For further information go to www.openfoam.org