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
fvMotionSolver
pointPatchFields
derived
oscillatingVelocity
oscillatingVelocityPointPatchVectorField.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
\*---------------------------------------------------------------------------*/
25
26
#include "
oscillatingVelocityPointPatchVectorField.H
"
27
#include <
OpenFOAM/pointPatchFields.H
>
28
#include <
OpenFOAM/addToRunTimeSelectionTable.H
>
29
#include <
OpenFOAM/Time.H
>
30
#include <
OpenFOAM/polyMesh.H
>
31
32
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34
namespace
Foam
35
{
36
37
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38
39
oscillatingVelocityPointPatchVectorField::
40
oscillatingVelocityPointPatchVectorField
41
(
42
const
pointPatch
&
p
,
43
const
DimensionedField<vector, pointMesh>
& iF
44
)
45
:
46
fixedValuePointPatchField<vector>
(
p
, iF),
47
amplitude_(
vector::zero
),
48
omega_(0.0),
49
p0_(p.
localPoints
())
50
{}
51
52
53
oscillatingVelocityPointPatchVectorField::
54
oscillatingVelocityPointPatchVectorField
55
(
56
const
pointPatch
& p,
57
const
DimensionedField<vector, pointMesh>
& iF,
58
const
dictionary
& dict
59
)
60
:
61
fixedValuePointPatchField<vector>
(
p
, iF, dict),
62
amplitude_(dict.
lookup
(
"amplitude"
)),
63
omega_(
readScalar
(dict.
lookup
(
"omega"
)))
64
{
65
if
(!dict.
found
(
"value"
))
66
{
67
updateCoeffs();
68
}
69
70
if
(dict.
found
(
"p0"
))
71
{
72
p0_ =
vectorField
(
"p0"
, dict , p.
size
());
73
}
74
else
75
{
76
p0_ = p.
localPoints
();
77
}
78
}
79
80
81
oscillatingVelocityPointPatchVectorField::
82
oscillatingVelocityPointPatchVectorField
83
(
84
const
oscillatingVelocityPointPatchVectorField
& ptf,
85
const
pointPatch
& p,
86
const
DimensionedField<vector, pointMesh>
& iF,
87
const
pointPatchFieldMapper
& mapper
88
)
89
:
90
fixedValuePointPatchField<vector>
(ptf,
p
, iF, mapper),
91
amplitude_(ptf.amplitude_),
92
omega_(ptf.omega_),
93
p0_(ptf.p0_, mapper)
94
{}
95
96
97
oscillatingVelocityPointPatchVectorField::
98
oscillatingVelocityPointPatchVectorField
99
(
100
const
oscillatingVelocityPointPatchVectorField
& ptf,
101
const
DimensionedField<vector, pointMesh>
& iF
102
)
103
:
104
fixedValuePointPatchField<vector>
(ptf, iF),
105
amplitude_(ptf.amplitude_),
106
omega_(ptf.omega_),
107
p0_(ptf.p0_)
108
{}
109
110
111
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112
113
void
oscillatingVelocityPointPatchVectorField::autoMap
114
(
115
const
pointPatchFieldMapper
& m
116
)
117
{
118
fixedValuePointPatchField<vector>::autoMap
(m);
119
120
p0_.autoMap(m);
121
}
122
123
124
void
oscillatingVelocityPointPatchVectorField::rmap
125
(
126
const
pointPatchField<vector>
& ptf,
127
const
labelList
& addr
128
)
129
{
130
const
oscillatingVelocityPointPatchVectorField
& oVptf =
131
refCast<const oscillatingVelocityPointPatchVectorField>(ptf);
132
133
fixedValuePointPatchField<vector>::rmap
(oVptf, addr);
134
135
p0_.rmap(oVptf.p0_, addr);
136
}
137
138
139
void
oscillatingVelocityPointPatchVectorField::updateCoeffs
()
140
{
141
if
(this->
updated
())
142
{
143
return
;
144
}
145
146
const
polyMesh
&
mesh
= this->
dimensionedInternalField
().
mesh
()();
147
const
Time
& t = mesh.
time
();
148
const
pointPatch
& p = this->
patch
();
149
150
Field<vector>::operator
=
151
(
152
(p0_ + amplitude_*
sin
(omega_*t.
value
()) - p.
localPoints
())
153
/t.
deltaTValue
()
154
);
155
156
fixedValuePointPatchField<vector>::updateCoeffs
();
157
}
158
159
160
void
oscillatingVelocityPointPatchVectorField::write
(
Ostream
& os)
const
161
{
162
pointPatchField<vector>::write
(os);
163
os.
writeKeyword
(
"amplitude"
)
164
<< amplitude_ <<
token::END_STATEMENT
<<
nl
;
165
os.
writeKeyword
(
"omega"
)
166
<< omega_ <<
token::END_STATEMENT
<<
nl
;
167
p0_.
writeEntry
(
"p0"
, os);
168
writeEntry
(
"value"
, os);
169
}
170
171
172
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173
174
makePointPatchTypeField
175
(
176
pointPatchVectorField
,
177
oscillatingVelocityPointPatchVectorField
178
);
179
180
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181
182
}
// End namespace Foam
183
184
// ************************ vim: set sw=4 sts=4 et: ************************ //