1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H"
27 #include "pointPatchFields.H"
28 #include "addToRunTimeSelectionTable.H"
31 #include "volFields.H"
32 #include "uniformDimensionedFields.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
42 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
45 const DimensionedField<vector, pointMesh>& iF
48 fixedValuePointPatchField<vector>(p, iF),
50 initialPoints_(p.localPoints())
54 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
55 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
58 const DimensionedField<vector, pointMesh>& iF,
59 const dictionary& dict
62 fixedValuePointPatchField<vector>(p, iF, dict),
65 if (!dict.found("value"))
70 if (dict.found("initialPoints"))
72 initialPoints_ = vectorField("initialPoints", dict , p.size());
76 initialPoints_ = p.localPoints();
81 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
82 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
84 const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
86 const DimensionedField<vector, pointMesh>& iF,
87 const pointPatchFieldMapper& mapper
90 fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
92 initialPoints_(ptf.initialPoints_, mapper)
96 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
97 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
99 const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
100 const DimensionedField<vector, pointMesh>& iF
103 fixedValuePointPatchField<vector>(ptf, iF),
104 motion_(ptf.motion_),
105 initialPoints_(ptf.initialPoints_)
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
113 const pointPatchFieldMapper& m
116 fixedValuePointPatchField<vector>::autoMap(m);
118 initialPoints_.autoMap(m);
122 void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::rmap
124 const pointPatchField<vector>& ptf,
125 const labelList& addr
128 const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& uSDoFptf =
131 const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
134 fixedValuePointPatchField<vector>::rmap(uSDoFptf, addr);
136 initialPoints_.rmap(uSDoFptf.initialPoints_, addr);
140 void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
147 const polyMesh& mesh = this->dimensionedInternalField().mesh()();
148 const Time& t = mesh.time();
150 motion_.updatePosition(t.deltaTValue(), t.deltaT0Value());
152 vector gravity = vector::zero;
154 if (db().foundObject<uniformDimensionedVectorField>("g"))
156 uniformDimensionedVectorField g =
157 db().lookupObject<uniformDimensionedVectorField>("g");
162 // Do not modify the accelerations, except with gravity, where available
163 motion_.updateForce(gravity*motion_.mass(), vector::zero, t.deltaTValue());
165 Field<vector>::operator=
167 motion_.currentPosition(initialPoints_) - initialPoints_
170 fixedValuePointPatchField<vector>::updateCoeffs();
174 void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::write
179 pointPatchField<vector>::write(os);
181 initialPoints_.writeEntry("initialPoints", os);
182 writeEntry("value", os);
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 makePointPatchTypeField
190 pointPatchVectorField,
191 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 } // End namespace Foam
198 // ************************************************************************* //