Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
graph
curve
curve.C
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 "
curve.H
"
29
//#include "curveTools.H"
30
#include <
OpenFOAM/Ostream.H
>
31
32
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34
namespace
Foam
35
{
36
37
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38
39
// construct as interpolation
40
/*
41
curve::curve(const curve& Curve, const label nFacets)
42
:
43
Name("Interpolated" + Curve.Name),
44
Style(Curve.Style),
45
X(2*nFacets),
46
Y(2*nFacets)
47
{
48
// Calculate curve length
49
scalar curveLength=0;
50
register label i;
51
for (i=0; i<Curve.size()-1; i++)
52
{
53
curveLength += distance(Curve[i], Curve[i+1]);
54
}
55
56
scalar stepLength = curveLength/nFacets;
57
label nPoints = 0;
58
label previous=0, next=1;
59
bool endOfCurve;
60
vector presentPoint=Curve[0], nextPoint;
61
62
do
63
{
64
endOfCurve =
65
stepForwardsToNextPoint
66
(
67
presentPoint,
68
nextPoint,
69
previous,
70
next,
71
stepLength,
72
Curve
73
);
74
75
if (!endOfCurve)
76
{
77
if (nPoints >= size()-1)
78
{
79
setSize(label(1.5*size()));
80
}
81
82
presentPoint = nextPoint;
83
84
x()[nPoints] = nextPoint.x();
85
y()[nPoints] = nextPoint.y();
86
87
nPoints++;
88
}
89
90
} while (!endOfCurve);
91
92
setSize(nPoints);
93
}
94
*/
95
96
97
// construct given name, style and size
98
curve::curve
99
(
100
const
string
&
name
,
101
const
curveStyle
& style,
102
const
label l
103
)
104
:
105
scalarField
(l, 0.0),
106
name_(name),
107
style_(style)
108
{}
109
110
111
// construct from the bits
112
curve::curve
113
(
114
const
string
& name,
115
const
curveStyle
& style,
116
const
scalarField
&
y
117
)
118
:
119
scalarField
(y),
120
name_(name),
121
style_(style)
122
{}
123
124
125
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
126
127
// Gradient operation
128
/*
129
curve grad(const curve& Curve)
130
{
131
curve gradCurve(Curve);
132
133
register label i;
134
for (i=1; i<Curve.size()-1; i++)
135
{
136
scalar deltaIm1 = Curve[i].x() - Curve[i-1].x();
137
scalar deltaI = Curve[i+1].x() - Curve[i].x();
138
139
scalar deltaAv = 1.0/deltaIm1 + 1.0/deltaI;
140
141
gradCurve.y()[i] =
142
(
143
(Curve[i+1].y() - Curve[i].y())/sqr(deltaI)
144
+ (Curve[i].y() - Curve[i-1].y())/sqr(deltaIm1)
145
)/deltaAv;
146
}
147
148
gradCurve.y()[0] =
149
(Curve[1].y() - Curve[0].y())/(Curve[1].x() - Curve[0].x());
150
151
label n = Curve.size()-1;
152
153
gradCurve.y()[n] =
154
(Curve[n].y() - Curve[n-1].y())/(Curve[n].x() - Curve[n-1].x());
155
156
return gradCurve;
157
}
158
*/
159
160
161
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
162
163
Ostream
&
operator<<
(
Ostream
& os,
const
curve
& c)
164
{
165
os <<
nl
166
<< c.name_ <<
nl
167
<< c.style_ <<
nl
168
<<
static_cast<
const
scalarField
&
>
(c);
169
170
os.
check
(
"Ostream& operator>>(Ostream&, const curve&)"
);
171
172
return
os;
173
}
174
175
176
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177
178
}
// End namespace Foam
179
180
// ************************ vim: set sw=4 sts=4 et: ************************ //