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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30#include "pointPatchFields.H"
32#include "Time.H"
33#include "fvMesh.H"
34#include "volFields.H"
36
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39namespace Foam
40{
41
42// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43
44uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
45uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
46(
47 const pointPatch& p,
49)
50:
52 motion_(db().time()),
53 initialPoints_(p.localPoints()),
54 curTimeIndex_(-1)
55{}
56
57
58uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
59uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
60(
61 const pointPatch& p,
63 const dictionary& dict
64)
65:
67 motion_(dict, dict, db().time()),
68 curTimeIndex_(-1)
69{
70 if (!dict.found("value"))
71 {
73 }
74
75 if (dict.found("initialPoints"))
76 {
77 initialPoints_ = vectorField("initialPoints", dict , p.size());
78 }
79 else
80 {
81 initialPoints_ = p.localPoints();
82 }
83}
84
85
86uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
87uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
88(
90 const pointPatch& p,
92 const pointPatchFieldMapper& mapper
93)
94:
95 fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
96 motion_(ptf.motion_),
97 initialPoints_(ptf.initialPoints_, mapper),
98 curTimeIndex_(-1)
99{}
100
101
102uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::
103uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
104(
107)
108:
110 motion_(ptf.motion_),
111 initialPoints_(ptf.initialPoints_),
112 curTimeIndex_(-1)
113{}
114
115
116// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117
119(
120 const pointPatchFieldMapper& m
121)
122{
124
125 initialPoints_.autoMap(m);
126}
127
128
130(
131 const pointPatchField<vector>& ptf,
132 const labelList& addr
133)
134{
136 refCast
137 <
139 >(ptf);
140
142
143 initialPoints_.rmap(uSDoFptf.initialPoints_, addr);
144}
145
146
148{
149 if (this->updated())
150 {
151 return;
152 }
153
154 const polyMesh& mesh = this->internalField().mesh()();
155 const Time& t = mesh.time();
156
157 // Store the motion state at the beginning of the time-step
158 bool firstIter = false;
159 if (curTimeIndex_ != t.timeIndex())
160 {
161 motion_.newTime();
162 curTimeIndex_ = t.timeIndex();
163 firstIter = true;
164 }
165
166 vector gravity = Zero;
167
169 {
172
173 gravity = g.value();
174 }
175
176 // Do not modify the accelerations, except with gravity, where available
177 motion_.update
178 (
179 firstIter,
180 gravity*motion_.mass(),
181 Zero,
182 t.deltaTValue(),
183 t.deltaT0Value()
184 );
185
187 (
188 motion_.transform(initialPoints_) - initialPoints_
189 );
190
192}
193
194
196(
197 Ostream& os
198) const
199{
201 motion_.write(os);
202 initialPoints_.writeEntry("initialPoints", os);
203 writeEntry("value", os);
204}
205
206
207// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208
210(
213);
214
215// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216
217} // End namespace Foam
218
219// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
const uniformDimensionedVectorField & g
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const Mesh & mesh() const
Return mesh.
Generic templated field type.
Definition: Field.H:82
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition: Field.C:403
void writeEntry(const word &keyword, Ostream &os) const
Write the field as a dictionary entry.
Definition: Field.C:614
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Definition: Field.C:466
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
label timeIndex() const noexcept
Return current time index.
Definition: TimeStateI.H:37
scalar deltaTValue() const noexcept
Return time step value.
Definition: TimeStateI.H:43
scalar deltaT0Value() const noexcept
Return old time step value.
Definition: TimeStateI.H:49
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
void rmap(const atmBoundaryLayer &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
const Type & value() const
Return const reference to value.
A FixedValue boundary condition for pointField.
virtual bool write()
Write the output fields.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
const Time & time() const noexcept
Return time registry.
const Type & lookupObject(const word &name, const bool recursive=false) const
Foam::pointPatchFieldMapper.
Abstract base class for point-mesh patch fields.
const objectRegistry & db() const
Return local objectRegistry.
const DimensionedField< Type, pointMesh > & internalField() const
Return dimensioned internal field reference.
bool updated() const
Return true if the boundary condition has already been updated.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
void newTime()
Store the motion state at the beginning of the time-step.
void update(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Symplectic integration of velocities, orientation and position.
void write(Ostream &) const
Write.
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
scalar mass() const
Return the mass.
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void rmap(const pointPatchField< vector > &, const labelList &)
Reverse map the given pointPatchField onto this pointPatchField.
volScalarField & p
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
#define makePointPatchTypeField(PatchTypeField, typePatchTypeField)
dictionary dict