Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
32template<class Point, class PointRef, class PolygonRef>
34(
35 PolygonRef base,
36 const Point& apex
37)
39 base_(base),
40 apex_(apex)
41{}
42
43
44template<class Point, class PointRef, class PolygonRef>
46{
47 is >> *this;
48}
49
50
51// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52
53template<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
63template<class Point, class PointRef, class PolygonRef>
65(
66 const UList<point>& points
67) const
69 // Height = apex - baseCentroid
70 return (apex_ - base_.centre(points));
71}
72
73
74template<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
86template<class Point, class PointRef, class PolygonRef>
87inline 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
99template<class Point, class PointRef, class PolygonRef>
100inline 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// ************************************************************************* //
CGAL::Point_3< K > Point
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
A geometric pyramid primitive with a base of 'n' sides: i.e. a parametric pyramid....
Definition pyramid.H:79
const Point & apex() const
The apex point.
Definition pyramid.H:117
vector height(const UList< point > &points) const
Return height vector.
Definition pyramidI.H:58
scalar mag(const UList< point > &points) const
Return scalar magnitude - returns volume of pyramid.
Definition pyramidI.H:69
pyramid(PolygonRef base, const Point &apex)
Construct from base polygon and apex point.
Definition pyramidI.H:27
Point centre(const UList< point > &points) const
Return centre (centroid).
Definition pyramidI.H:48
PolygonRef base() const
The base polygon.
Definition pyramid.H:122
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
#define FUNCTION_NAME
Vector< scalar > vector
Definition vector.H:57
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
constexpr char tab
The tab '\t' character(0x09).
Definition Ostream.H:49