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 >> base_ >> apex_;
48  is.check(FUNCTION_NAME);
49 }
50 
51 
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53 
54 template<class Point, class PointRef, class polygonRef>
56 {
57  return apex_;
58 }
59 
60 template<class Point, class PointRef, class polygonRef>
62 {
63  return base_;
64 }
65 
66 
67 template<class Point, class PointRef, class polygonRef>
69 (
70  const UList<point>& points
71 ) const
72 {
73  return (3.0/4.0)*base_.centre(points) + (1.0/4.0)*apex_;
74 }
75 
76 
77 template<class Point, class PointRef, class polygonRef>
79 (
80  const UList<point>& points
81 ) const
82 {
83  // Height = apex - baseCentroid
84  return (apex_ - base_.centre(points));
85 }
86 
87 
88 template<class Point, class PointRef, class polygonRef>
90 (
91  const UList<point>& points
92 ) const
93 {
94  return (1.0/3.0)*(base_.areaNormal(points) & (height(points)));
95 }
96 
97 
98 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
99 
100 template<class Point, class PointRef, class polygonRef>
101 inline Foam::Istream& Foam::operator>>
102 (
103  Istream& is,
105 )
106 {
107  is >> p.base_ >> p.apex_;
108  is.check(FUNCTION_NAME);
109  return is;
110 }
111 
112 
113 template<class Point, class PointRef, class polygonRef>
114 inline Foam::Ostream& Foam::operator<<
115 (
116  Ostream& os,
117  const pyramid<Point, PointRef, polygonRef>& p
118 )
119 {
120  os << p.base_ << tab << p.apex_ << nl;
121  return os;
122 }
123 
124 
125 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
IOstreams.H
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::pyramid::pyramid
pyramid(polygonRef base, const Point &apex)
Construct from base polygon and apex point.
Definition: pyramidI.H:34
Foam::pyramid::centre
Point centre(const UList< point > &points) const
Return centre (centroid)
Definition: pyramidI.H:69
Foam::pyramid
A geometric pyramid primitive with a base of 'n' sides: i.e. a parametric pyramid....
Definition: pyramid.H:49
Foam::pyramid::mag
scalar mag(const UList< point > &points) const
Return scalar magnitude - returns volume of pyramid.
Definition: pyramidI.H:90
Foam::pyramid::base
polygonRef base() const
Return base polygon.
Definition: pyramidI.H:61
Foam::pyramid::apex
const Point & apex() const
Return apex point.
Definition: pyramidI.H:55
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::tab
constexpr char tab
Definition: Ostream.H:384
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Vector< scalar >
Foam::UList
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:103
points
const pointField & points
Definition: gmvOutputHeader.H:1
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:265
Point
CGAL::Point_3< K > Point
Definition: CGALIndexedPolyhedron.H:53
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::pyramid::height
vector height(const UList< point > &points) const
Return height vector.
Definition: pyramidI.H:79