solidBodyMotionDisplacementPointPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "transformField.H"
29 #include "pointPatchFields.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
37 
40 (
41  const pointPatch& p,
43  const dictionary& dict
44 )
45 :
46  fixedValuePointPatchVectorField(p, iF, dict, false),
47  SBMFPtr_(solidBodyMotionFunction::New(dict, this->db().time()))
48 {
49  if (!dict.found("value"))
50  {
51  // Determine current local points and offset
52  fixedValuePointPatchVectorField::operator==
53  (
54  transformPoints(SBMFPtr_().transformation(), localPoints0())
55  -localPoints0()
56  );
57  }
58 }
59 
60 
63 (
65  const pointPatch& p,
67  const pointPatchFieldMapper& mapper
68 )
69 :
70  fixedValuePointPatchVectorField(ptf, p, iF, mapper),
71  SBMFPtr_(ptf.SBMFPtr_().clone().ptr())
72 {
73  // For safety re-evaluate
74 
75  fixedValuePointPatchVectorField::operator==
76  (
77  transformPoints(SBMFPtr_().transformation(), localPoints0())
78  -localPoints0()
79  );
80 }
81 
82 
85 (
88 )
89 :
90  fixedValuePointPatchVectorField(ptf, iF),
91  SBMFPtr_(ptf.SBMFPtr_().clone().ptr())
92 {
93  // For safety re-evaluate
94 
95  fixedValuePointPatchVectorField::operator==
96  (
97  transformPoints(SBMFPtr_().transformation(), localPoints0())
98  -localPoints0()
99  );
100 }
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
105 const pointField&
107 {
108  if (!localPoints0Ptr_.valid())
109  {
110  pointIOField points0
111  (
112  IOobject
113  (
114  "points",
115  this->db().time().constant(),
117  this->db(),
120  false
121  )
122  );
123 
124  localPoints0Ptr_.reset(new pointField(points0, patch().meshPoints()));
125  }
126  return localPoints0Ptr_();
127 }
128 
129 
131 {
132  if (this->updated())
133  {
134  return;
135  }
136 
137  // Determine current local points and offset
138  fixedValuePointPatchVectorField::operator==
139  (
140  transformPoints(SBMFPtr_().transformation(), localPoints0())
141  -localPoints0()
142  );
143 
144  fixedValuePointPatchVectorField::updateCoeffs();
145 }
146 
147 
149 write(Ostream& os) const
150 {
151  // Note: write value
153 
154  writeEntry(os, solidBodyMotionFunction::typeName, SBMFPtr_->type());
155  os << indent << word(SBMFPtr_->type() + "Coeffs");
156  SBMFPtr_->writeData(os);
157 }
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
163 (
166 );
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace Foam
172 
173 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
A primitive field of type <Type> with automated input and output.
Definition: IOField.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Foam::pointPatchFieldMapper.
Abstract base class for point-mesh patch fields.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:57
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:271
Enables the specification of a fixed value boundary condition using the solid body motion functions.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
solidBodyMotionDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
Base class for defining solid-body motions.
A class for handling words, derived from string.
Definition: word.H:62
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
makePointPatchTypeField(pointPatchVectorField, solidBodyMotionDisplacementPointPatchVectorField)
void transformPoints(vectorField &, const spatialTransform &, const vectorField &)
Transform given vectorField of coordinates with the given spatialTransform.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
T clone(const T &t)
Definition: List.H:55
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
dictionary dict
volScalarField & p
Spatial transformation functions for primitive fields.