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

pyramidI.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-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 
00026 \*---------------------------------------------------------------------------*/
00027 
00028 #include <OpenFOAM/IOstreams.H>
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 template<class Point, class PointRef, class polygonRef>
00038 inline pyramid<Point, PointRef, polygonRef>::pyramid
00039 (
00040     polygonRef base,
00041     const Point& apex
00042 )
00043 :
00044     base_(base),
00045     apex_(apex)
00046 {}
00047 
00048 
00049 template<class Point, class PointRef, class polygonRef>
00050 inline pyramid<Point, PointRef, polygonRef>::pyramid(Istream& is)
00051 {
00052     is >> base_ >> apex_;
00053     is.check("pyramid::pyramid(Istream& is)");
00054 }
00055 
00056 
00057 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00058 
00059 template<class Point, class PointRef, class polygonRef>
00060 inline const Point& pyramid<Point, PointRef, polygonRef>::apex() const
00061 {
00062     return apex_;
00063 }
00064 
00065 template<class Point, class PointRef, class polygonRef>
00066 inline polygonRef pyramid<Point, PointRef, polygonRef>::base() const
00067 {
00068     return base_;
00069 }
00070 
00071 
00072 template<class Point, class PointRef, class polygonRef>
00073 inline Point pyramid<Point, PointRef, polygonRef>::centre
00074 (
00075     const pointField& points
00076 ) const
00077 {
00078     return (3.0/4.0)*base_.centre(points) + (1.0/4.0)*apex_;
00079 }
00080 
00081 
00082 template<class Point, class PointRef, class polygonRef>
00083 inline vector pyramid<Point, PointRef, polygonRef>::height
00084 (
00085     const pointField& points
00086 ) const
00087 {
00088     // Height = apex - baseCentroid
00089     return (apex_ - base_.centre(points));
00090 }
00091 
00092 
00093 template<class Point, class PointRef, class polygonRef>
00094 inline scalar pyramid<Point, PointRef, polygonRef>::mag
00095 (
00096     const pointField& points
00097 ) const
00098 {
00099     return (1.0/3.0)*(base_.normal(points)&(height(points)));
00100 }
00101 
00102 
00103 // * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * * //
00104 
00105 template<class Point, class PointRef, class polygonRef>
00106 inline Istream& operator>>
00107 (
00108     Istream& is,
00109     pyramid<Point, PointRef, polygonRef>& p
00110 )
00111 {
00112     is >> p.base_ >> p.apex_;
00113     is.check("Istream& operator>>(Istream&, pyramid&)");
00114     return is;
00115 }
00116 
00117 
00118 template<class Point, class PointRef, class polygonRef>
00119 inline Ostream& operator<<
00120 (
00121     Ostream& os,
00122     const pyramid<Point, PointRef, polygonRef>& p
00123 )
00124 {
00125     os << p.base_ << tab << p.apex_ << nl;
00126     return os;
00127 }
00128 
00129 
00130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00131 
00132 } // End namespace Foam
00133 
00134 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines