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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "IOstreams.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Point, class PointRef, class PolygonRef>
34 (
35  PolygonRef base,
36  const Point& apex
37 )
38 :
39  base_(base),
40  apex_(apex)
41 {}
42 
43 
44 template<class Point, class PointRef, class PolygonRef>
46 {
47  is >> *this;
48 }
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
53 template<class Point, class PointRef, class PolygonRef>
55 (
56  const UList<point>& points
57 ) const
58 {
59  return (3.0/4.0)*base_.centre(points) + (1.0/4.0)*apex_;
60 }
61 
62 
63 template<class Point, class PointRef, class PolygonRef>
65 (
66  const UList<point>& points
67 ) const
68 {
69  // Height = apex - baseCentroid
70  return (apex_ - base_.centre(points));
71 }
72 
73 
74 template<class Point, class PointRef, class PolygonRef>
76 (
77  const UList<point>& points
78 ) const
79 {
80  return (1.0/3.0)*(base_.areaNormal(points) & (height(points)));
81 }
82 
83 
84 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
85 
86 template<class Point, class PointRef, class PolygonRef>
87 inline Foam::Istream& Foam::operator>>
88 (
89  Istream& is,
90  pyramid<Point, PointRef, PolygonRef>& p
91 )
92 {
93  is >> p.base_ >> p.apex_;
94  is.check(FUNCTION_NAME);
95  return is;
96 }
97 
98 
99 template<class Point, class PointRef, class PolygonRef>
100 inline Foam::Ostream& Foam::operator<<
101 (
102  Ostream& os,
103  const pyramid<Point, PointRef, PolygonRef>& p
104 )
105 {
106  os << p.base_ << tab << p.apex_ << nl;
107  return os;
108 }
109 
110 
111 // ************************************************************************* //
pyramid(PolygonRef base, const Point &apex)
Construct from base polygon and apex point.
Definition: pyramidI.H:27
scalar mag(const UList< point > &points) const
Return scalar magnitude - returns volume of pyramid.
Definition: pyramidI.H:69
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
constexpr char tab
The tab &#39;\t&#39; character(0x09)
Definition: Ostream.H:49
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
const pointField & points
vector height(const UList< point > &points) const
Return height vector.
Definition: pyramidI.H:58
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:105
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Point centre(const UList< point > &points) const
Return centre (centroid)
Definition: pyramidI.H:48
CGAL::Point_3< K > Point
volScalarField & p