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 (
89  const uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField& ptf,
90  const pointPatch& p,
91  const DimensionedField<vector, pointMesh>& iF,
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 
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 (
212  uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
213 );
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 } // End namespace Foam
218 
219 // ************************************************************************* //
volFields.H
Foam::sixDoFRigidBodyMotion::newTime
void newTime()
Definition: sixDoFRigidBodyMotionI.H:272
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:69
Foam::sixDoFRigidBodyMotion::mass
scalar mass() const
Definition: sixDoFRigidBodyMotionI.H:204
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
virtual void autoMap(const pointPatchFieldMapper &)
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:112
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::rmap
virtual void rmap(const pointPatchField< vector > &, const labelList &)
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:123
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:140
Foam::Field::autoMap
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Definition: Field.C:396
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryI.H:80
Foam::Field< vector >::operator
friend Ostream & operator(Ostream &, const Field< Type > &)
Foam::pointPatchField< vector >::db
const objectRegistry & db() const
Definition: pointPatchField.C:103
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:39
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:54
Foam::pointPatchField< vector >
Foam::objectRegistry::foundObject
bool foundObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:372
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:73
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:42
Foam::TimeState::deltaTValue
scalar deltaTValue() const noexcept
Definition: TimeStateI.H:36
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:48
Foam::sixDoFRigidBodyMotion::write
void write(Ostream &) const
Definition: sixDoFRigidBodyMotionIO.C:46
Foam::TimeState::deltaT0Value
scalar deltaT0Value() const noexcept
Definition: TimeStateI.H:42
Foam::sixDoFRigidBodyMotion::update
void update(bool firstIter, const vector &fGlobal, const vector &tauGlobal, scalar deltaT, scalar deltaT0)
Definition: sixDoFRigidBodyMotion.C:301
Foam::TimeState::timeIndex
label timeIndex() const noexcept
Definition: TimeStateI.H:30
Foam::fixedValuePointPatchField< vector >
Foam::UniformDimensionedField< vector >
Foam::makePointPatchTypeField
makePointPatchTypeField(pointPatchVectorField, solidBodyMotionDisplacementPointPatchVectorField)
Foam::Field
Generic templated field type.
Definition: Field.H:59
Foam::valuePointPatchField::updateCoeffs
virtual void updateCoeffs()
Definition: valuePointPatchField.C:128
Foam::pointPatchField< vector >::internalField
const DimensionedField< Type, pointMesh > & internalField() const
Definition: pointPatchField.H:271
Foam::pointPatchField::write
virtual void write(Ostream &) const
Definition: pointPatchField.C:110
Foam::uniformDimensionedVectorField
UniformDimensionedField< vector > uniformDimensionedVectorField
Definition: uniformDimensionedFields.H:46
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:427
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Field::rmap
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
Definition: Field.C:459
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::write
virtual void write(Ostream &) const
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C:189
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
Definition: atmBoundaryLayer.C:26
Foam::valuePointPatchField::autoMap
virtual void autoMap(const pointPatchFieldMapper &)
Definition: valuePointPatchField.C:101
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:47
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField
Foam::uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.
Definition: uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H:47
Foam::refCast
To & refCast(From &r)
Definition: typeInfo.H:136
Foam::pointPatchField< vector >::updated
bool updated() const
Definition: pointPatchField.H:307
Foam::Field::writeEntry
void writeEntry(const word &keyword, Ostream &os) const
Definition: Field.C:601
Time.H
uniformDimensionedFields.H
Foam::sixDoFRigidBodyMotion::transform
point transform(const point &initialPoints) const
Definition: sixDoFRigidBodyMotionI.H:294
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::valuePointPatchField::rmap
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Definition: valuePointPatchField.C:111
pointPatchFields.H
Foam::pointPatchVectorField
pointPatchField< vector > pointPatchVectorField
Definition: pointPatchFieldsFwd.H:36
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H
Foam::objectRegistry::time
const Time & time() const noexcept
Definition: objectRegistry.H:174
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50