Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / forces / pointPatchFields / derived / uncoupledSixDoFRigidBodyDisplacement / uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C
blobaf8a089907a9f5561994c3f7ffe195425f696c65
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
29 #include "Time.H"
30 #include "fvMesh.H"
31 #include "volFields.H"
32 #include "uniformDimensionedFields.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 namespace Foam
39 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
41 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
42 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
44     const pointPatch& p,
45     const DimensionedField<vector, pointMesh>& iF
48     fixedValuePointPatchField<vector>(p, iF),
49     motion_(),
50     initialPoints_(p.localPoints())
54 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
55 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
57     const pointPatch& p,
58     const DimensionedField<vector, pointMesh>& iF,
59     const dictionary& dict
62     fixedValuePointPatchField<vector>(p, iF, dict),
63     motion_(dict)
65     if (!dict.found("value"))
66     {
67         updateCoeffs();
68     }
70     if (dict.found("initialPoints"))
71     {
72         initialPoints_ = vectorField("initialPoints", dict , p.size());
73     }
74     else
75     {
76         initialPoints_ = p.localPoints();
77     }
81 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
82 uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
84     const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
85     const pointPatch& p,
86     const DimensionedField<vector, pointMesh>& iF,
87     const pointPatchFieldMapper& mapper
90     fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
91     motion_(ptf.motion_),
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 =
129     refCast
130     <
131         const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
132     >(ptf);
134     fixedValuePointPatchField<vector>::rmap(uSDoFptf, addr);
136     initialPoints_.rmap(uSDoFptf.initialPoints_, addr);
140 void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
142     if (this->updated())
143     {
144         return;
145     }
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"))
155     {
156         uniformDimensionedVectorField g =
157         db().lookupObject<uniformDimensionedVectorField>("g");
159         gravity = g.value();
160     }
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=
166     (
167         motion_.currentPosition(initialPoints_) - initialPoints_
168     );
170     fixedValuePointPatchField<vector>::updateCoeffs();
174 void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::write
176     Ostream& os
177 ) const
179     pointPatchField<vector>::write(os);
180     motion_.write(os);
181     initialPoints_.writeEntry("initialPoints", os);
182     writeEntry("value", os);
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 makePointPatchTypeField
190     pointPatchVectorField,
191     uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 } // End namespace Foam
198 // ************************************************************************* //