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 -------------------------------------------------------------------------------
11 License
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 
39 namespace Foam
40 {
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
46 (
47  const pointPatch& p,
49 )
50 :
52  motion_(db().time()),
53  initialPoints_(p.localPoints()),
54  curTimeIndex_(-1)
55 {}
56 
57 
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  {
72  updateCoeffs();
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 
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 
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 
168  if (db().time().foundObject<uniformDimensionedVectorField>("g"))
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 // ************************************************************************* //
volFields.H
Foam::sixDoFRigidBodyMotion::newTime
void newTime()
Store the motion state at the beginning of the time-step.
Definition: sixDoFRigidBodyMotionI.H:279
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::sixDoFRigidBodyMotion::mass
scalar mass() const
Return the mass.
Definition: sixDoFRigidBodyMotionI.H:211
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:119
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::rmap
virtual void rmap(const pointPatchField< vector > &, const labelList &)
Reverse map the given pointPatchField onto this pointPatchField.
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:130
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:147
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::dictionary::found
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
Foam::pointPatchField< vector >::db
const objectRegistry & db() const
Return local objectRegistry.
Definition: pointPatchField.C:110
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:46
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::pointPatchField< vector >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::TimeState::deltaTValue
scalar deltaTValue() const noexcept
Return time step value.
Definition: TimeStateI.H:43
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::TimeState::deltaT0Value
scalar deltaT0Value() const noexcept
Return old time step value.
Definition: TimeStateI.H:49
Foam::sixDoFRigidBodyMotion::update
void update(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Symplectic integration of velocities, orientation and position.
Definition: sixDoFRigidBodyMotion.C:308
Foam::TimeState::timeIndex
label timeIndex() const noexcept
Return current time index.
Definition: TimeStateI.H:37
Foam::fixedValuePointPatchField< vector >
Foam::UniformDimensionedField< vector >
Foam::makePointPatchTypeField
makePointPatchTypeField(pointPatchVectorField, solidBodyMotionDisplacementPointPatchVectorField)
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::valuePointPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: valuePointPatchField.C:135
Foam::pointPatchField< vector >::internalField
const DimensionedField< vector, pointMesh > & internalField() const
Return dimensioned internal field reference.
Definition: pointPatchField.H:275
Foam::pointPatchField::write
virtual void write(Ostream &) const
Write.
Definition: pointPatchField.C:117
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:196
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
fvMesh.H
g
const uniformDimensionedVectorField & g
Definition: createFluidFields.H:26
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::valuePointPatchField::autoMap
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: valuePointPatchField.C:108
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H:51
Foam::refCast
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
Foam::pointPatchField< vector >::updated
bool updated() const
Return true if the boundary condition has already been updated.
Definition: pointPatchField.H:311
Time.H
uniformDimensionedFields.H
Foam::sixDoFRigidBodyMotion::transform
point transform(const point &initialPoints) const
Transform the given initial state point by the current motion.
Definition: sixDoFRigidBodyMotionI.H:301
Foam::Vector< scalar >
Foam::List< label >
Foam::valuePointPatchField::rmap
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given PointPatchField onto.
Definition: valuePointPatchField.C:118
pointPatchFields.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H
Foam::objectRegistry::time
const Time & time() const noexcept
Return time registry.
Definition: objectRegistry.H:178
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54