FreeFOAM The Cross-Platform CFD Toolkit
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 
29 #include <OpenFOAM/Time.H>
30 #include <finiteVolume/fvMesh.H>
31 #include <finiteVolume/volFields.H>
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
43 (
44  const pointPatch& p,
46 )
47 :
49  motion_(),
50  initialPoints_(p.localPoints())
51 {}
52 
53 
56 (
57  const pointPatch& p,
59  const dictionary& dict
60 )
61 :
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 
83 (
85  const pointPatch& p,
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 
98 (
101 )
102 :
104  motion_(ptf.motion_),
105  initialPoints_(ptf.initialPoints_)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
112 (
113  const pointPatchFieldMapper& m
114 )
115 {
117 
118  initialPoints_.autoMap(m);
119 }
120 
121 
123 (
124  const pointPatchField<vector>& ptf,
125  const labelList& addr
126 )
127 {
129  refCast
130  <
132  >(ptf);
133 
135 
136  initialPoints_.rmap(uSDoFptf.initialPoints_, addr);
137 }
138 
139 
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 
155  {
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 
166  (
167  motion_.currentPosition(initialPoints_) - initialPoints_
168  );
169 
171 }
172 
173 
175 (
176  Ostream& os
177 ) const
178 {
180  motion_.write(os);
181  initialPoints_.writeEntry("initialPoints", os);
182  writeEntry("value", os);
183 }
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
189 (
192 );
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 } // End namespace Foam
197 
198 // ************************ vim: set sw=4 sts=4 et: ************************ //