solidBodyMotionDisplacementPointPatchVectorField.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2020 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 "transformField.H"
32 #include "pointPatchFields.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
40 
43 (
44  const pointPatch& p,
46 )
47 :
48  fixedValuePointPatchVectorField(p, iF),
49  SBMFPtr_(nullptr),
50  localPoints0Ptr_(nullptr)
51 {}
52 
53 
56 (
57  const pointPatch& p,
59  const dictionary& dict
60 )
61 :
62  fixedValuePointPatchVectorField(p, iF, dict, IOobjectOption::NO_READ),
63  SBMFPtr_(solidBodyMotionFunction::New(dict, this->db().time())),
64  localPoints0Ptr_(nullptr)
65 {
66  if (!dict.found("value"))
67  {
68  // Determine current local points and offset
69  fixedValuePointPatchVectorField::operator==
70  (
71  transformPoints(SBMFPtr_().transformation(), localPoints0())
72  -localPoints0()
73  );
74  }
75 }
76 
77 
80 (
81  const solidBodyMotionDisplacementPointPatchVectorField& ptf,
82  const pointPatch& p,
83  const DimensionedField<vector, pointMesh>& iF,
84  const pointPatchFieldMapper& mapper
85 )
86 :
87  fixedValuePointPatchVectorField(ptf, p, iF, mapper),
88  SBMFPtr_(ptf.SBMFPtr_().clone()),
89  localPoints0Ptr_(nullptr)
90 {
91  // For safety re-evaluate
92 
93  fixedValuePointPatchVectorField::operator==
94  (
95  transformPoints(SBMFPtr_().transformation(), localPoints0())
97  );
98 }
99 
100 
103 (
105 )
106 :
107  fixedValuePointPatchVectorField(ptf),
108  SBMFPtr_(ptf.SBMFPtr_().clone()),
109  localPoints0Ptr_(nullptr)
110 {}
111 
112 
115 (
118 )
119 :
120  fixedValuePointPatchVectorField(ptf, iF),
121  SBMFPtr_(ptf.SBMFPtr_().clone()),
122  localPoints0Ptr_(nullptr)
123 {
124  // For safety re-evaluate
125 
126  fixedValuePointPatchVectorField::operator==
127  (
128  transformPoints(SBMFPtr_().transformation(), localPoints0())
129  -localPoints0()
130  );
131 }
132 
133 
134 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135 
136 const pointField&
138 {
139  if (!localPoints0Ptr_)
140  {
142  (
143  IOobject
144  (
145  "points",
146  this->db().time().constant(),
148  this->db(),
152  )
153  );
154 
155  localPoints0Ptr_.reset(new pointField(points0, patch().meshPoints()));
156  }
157 
158  return *localPoints0Ptr_;
159 }
160 
161 
163 {
164  if (this->updated())
165  {
166  return;
167  }
168 
169  // Determine current local points and offset
170  fixedValuePointPatchVectorField::operator==
171  (
172  transformPoints(SBMFPtr_().transformation(), localPoints0())
173  -localPoints0()
174  );
175 
176  fixedValuePointPatchVectorField::updateCoeffs();
177 }
178 
179 
181 write(Ostream& os) const
182 {
183  // Note: write value
185 
186  os.writeEntry(solidBodyMotionFunction::typeName, SBMFPtr_->type());
187 
188  os << indent << word(SBMFPtr_->type() + "Coeffs");
189  SBMFPtr_->writeData(os);
190 }
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
196 (
198  solidBodyMotionDisplacementPointPatchVectorField
199 );
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // ************************************************************************* //
dictionary dict
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:493
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
void transformPoints(vectorField &, const septernion &, const vectorField &)
Transform given vectorField of coordinates with the given septernion.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:410
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Ignore writing from objectRegistry::writeObject()
virtual void write(Ostream &) const
Write.
Macros for easy insertion into run-time selection tables.
Spatial transformation functions for primitive fields.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
Base class for defining solid-body motions.
A class for handling words, derived from Foam::string.
Definition: word.H:63
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
pointPatchField< vector > pointPatchVectorField
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Enables the specification of a fixed value boundary condition using the solid body motion functions...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
solidBodyMotionDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
const std::string patch
OpenFOAM patch number as a std::string.
makePointPatchTypeField(pointPatchVectorField, solidBodyMotionDisplacementPointPatchVectorField)
volScalarField & p
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
A primitive field of type <T> with automated input and output.
Do not request registration (bool: false)
Namespace for OpenFOAM.