pyramidI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
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 "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("pyramid::pyramid(Istream&)");
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 pointField& 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 pointField& 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 pointField& points
92 ) const
93 {
94  return (1.0/3.0)*(base_.area(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("Istream& operator>>(Istream&, pyramid&)");
109  return is;
110 }
111 
112 
113 template<class Point, class PointRef, class polygonRef>
114 inline Foam::Ostream& Foam::operator<<
115 (
116  Ostream& os,
118 )
119 {
120  os << p.base_ << tab << p.apex_ << nl;
121  return os;
122 }
123 
124 
125 // ************************************************************************* //
static const char tab
Definition: Ostream.H:259
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
scalar mag(const pointField &points) const
Return scalar magnitude - returns volume of pyramid.
Definition: pyramidI.H:90
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
polygonRef base() const
Return base polygon.
Definition: pyramidI.H:61
const Point & apex() const
Return apex point.
Definition: pyramidI.H:55
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
vector height(const pointField &points) const
Return height vector.
Definition: pyramidI.H:79
Point centre(const pointField &points) const
Return centre (centroid)
Definition: pyramidI.H:69
pyramid(polygonRef base, const Point &apex)
Construct from base polygon and apex point.
Definition: pyramidI.H:34
volScalarField & p
A geometric pyramid primitive with a base of &#39;n&#39; sides: i.e. a parametric pyramid. A pyramid is constructed from a base polygon and an apex point.
Definition: pyramid.H:47