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
postProcessing
functionObjects
forces
pointPatchFields
derived
uncoupledSixDoFRigidBodyDisplacement
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.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 "
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H
"
27
#include <
OpenFOAM/pointPatchFields.H
>
28
#include <
OpenFOAM/addToRunTimeSelectionTable.H
>
29
#include <
OpenFOAM/Time.H
>
30
#include <
finiteVolume/fvMesh.H
>
31
#include <
finiteVolume/volFields.H
>
32
#include <
OpenFOAM/uniformDimensionedFields.H
>
33
34
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36
namespace
Foam
37
{
38
39
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
41
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
42
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
43
(
44
const
pointPatch
&
p
,
45
const
DimensionedField<vector, pointMesh>
& iF
46
)
47
:
48
fixedValuePointPatchField<vector>
(
p
, iF),
49
motion_(),
50
initialPoints_(p.
localPoints
())
51
{}
52
53
54
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
55
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
56
(
57
const
pointPatch
& p,
58
const
DimensionedField<vector, pointMesh>
& iF,
59
const
dictionary
& dict
60
)
61
:
62
fixedValuePointPatchField<vector>
(
p
, iF, dict),
63
motion_(dict)
64
{
65
if
(!dict.
found
(
"value"
))
66
{
67
updateCoeffs();
68
}
69
70
if
(dict.
found
(
"initialPoints"
))
71
{
72
initialPoints_ =
vectorField
(
"initialPoints"
, dict , p.
size
());
73
}
74
else
75
{
76
initialPoints_ = p.
localPoints
();
77
}
78
}
79
80
81
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
82
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
83
(
84
const
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
& 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
motion_(ptf.motion_),
92
initialPoints_(ptf.initialPoints_, mapper)
93
{}
94
95
96
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
97
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
98
(
99
const
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
& ptf,
100
const
DimensionedField<vector, pointMesh>
& iF
101
)
102
:
103
fixedValuePointPatchField<vector>
(ptf, iF),
104
motion_(ptf.motion_),
105
initialPoints_(ptf.initialPoints_)
106
{}
107
108
109
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110
111
void
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
112
(
113
const
pointPatchFieldMapper
& m
114
)
115
{
116
fixedValuePointPatchField<vector>::autoMap
(m);
117
118
initialPoints_.autoMap(m);
119
}
120
121
122
void
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::rmap
123
(
124
const
pointPatchField<vector>
& ptf,
125
const
labelList
& addr
126
)
127
{
128
const
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
& uSDoFptf =
129
refCast
130
<
131
const
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
132
>(ptf);
133
134
fixedValuePointPatchField<vector>::rmap
(uSDoFptf, addr);
135
136
initialPoints_.rmap(uSDoFptf.initialPoints_, addr);
137
}
138
139
140
void
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs
()
141
{
142
if
(this->
updated
())
143
{
144
return
;
145
}
146
147
const
polyMesh
&
mesh
= this->
dimensionedInternalField
().
mesh
()();
148
const
Time
& t = mesh.
time
();
149
150
motion_.
updatePosition
(t.
deltaTValue
(), t.
deltaT0Value
());
151
152
vector
gravity =
vector::zero
;
153
154
if
(
db
().
foundObject
<
uniformDimensionedVectorField
>(
"g"
))
155
{
156
uniformDimensionedVectorField
g =
157
db
().
lookupObject
<
uniformDimensionedVectorField
>(
"g"
);
158
159
gravity = g.
value
();
160
}
161
162
// Do not modify the accelerations, except with gravity, where available
163
motion_.
updateForce
(gravity*motion_.
mass
(),
vector::zero
, t.
deltaTValue
());
164
165
Field<vector>::operator
=
166
(
167
motion_.
currentPosition
(initialPoints_) - initialPoints_
168
);
169
170
fixedValuePointPatchField<vector>::updateCoeffs
();
171
}
172
173
174
void
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::write
175
(
176
Ostream
& os
177
)
const
178
{
179
pointPatchField<vector>::write
(os);
180
motion_.write(os);
181
initialPoints_.writeEntry(
"initialPoints"
, os);
182
writeEntry(
"value"
, os);
183
}
184
185
186
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187
188
makePointPatchTypeField
189
(
190
pointPatchVectorField
,
191
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
192
);
193
194
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195
196
}
// End namespace Foam
197
198
// ************************ vim: set sw=4 sts=4 et: ************************ //