FreeFOAM The Cross-Platform CFD Toolkit
pyramidI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include <OpenFOAM/IOstreams.H>
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
37 template<class Point, class PointRef, class polygonRef>
39 (
40  polygonRef base,
41  const Point& apex
42 )
43 :
44  base_(base),
45  apex_(apex)
46 {}
47 
48 
49 template<class Point, class PointRef, class polygonRef>
51 {
52  is >> base_ >> apex_;
53  is.check("pyramid::pyramid(Istream& is)");
54 }
55 
56 
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 
59 template<class Point, class PointRef, class polygonRef>
60 inline const Point& pyramid<Point, PointRef, polygonRef>::apex() const
61 {
62  return apex_;
63 }
64 
65 template<class Point, class PointRef, class polygonRef>
67 {
68  return base_;
69 }
70 
71 
72 template<class Point, class PointRef, class polygonRef>
74 (
75  const pointField& points
76 ) const
77 {
78  return (3.0/4.0)*base_.centre(points) + (1.0/4.0)*apex_;
79 }
80 
81 
82 template<class Point, class PointRef, class polygonRef>
84 (
85  const pointField& points
86 ) const
87 {
88  // Height = apex - baseCentroid
89  return (apex_ - base_.centre(points));
90 }
91 
92 
93 template<class Point, class PointRef, class polygonRef>
95 (
96  const pointField& points
97 ) const
98 {
99  return (1.0/3.0)*(base_.normal(points)&(height(points)));
100 }
101 
102 
103 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
104 
105 template<class Point, class PointRef, class polygonRef>
106 inline Istream& operator>>
107 (
108  Istream& is,
110 )
111 {
112  is >> p.base_ >> p.apex_;
113  is.check("Istream& operator>>(Istream&, pyramid&)");
114  return is;
115 }
116 
117 
118 template<class Point, class PointRef, class polygonRef>
119 inline Ostream& operator<<
120 (
121  Ostream& os,
123 )
124 {
125  os << p.base_ << tab << p.apex_ << nl;
126  return os;
127 }
128 
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 } // End namespace Foam
133 
134 // ************************ vim: set sw=4 sts=4 et: ************************ //