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, false),
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 (
82  const pointPatch& p,
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())
96  -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(),
151  false
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 (
199 );
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 } // End namespace Foam
205 
206 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::solidBodyMotionFunction::New
static autoPtr< solidBodyMotionFunction > New(const dictionary &SBMFCoeffs, const Time &runTime)
Select constructed from the SBMFCoeffs dictionary and Time.
Definition: solidBodyMotionFunctionNew.C:34
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:61
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::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:321
Foam::solidBodyMotionDisplacementPointPatchVectorField
Enables the specification of a fixed value boundary condition using the solid body motion functions.
Definition: solidBodyMotionDisplacementPointPatchVectorField.H:53
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:60
transformField.H
Spatial transformation functions for primitive fields.
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::makePointPatchTypeField
makePointPatchTypeField(pointPatchVectorField, solidBodyMotionDisplacementPointPatchVectorField)
Foam::Field< vector >
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::solidBodyMotionDisplacementPointPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: solidBodyMotionDisplacementPointPatchVectorField.C:181
Foam::transformPoints
void transformPoints(vectorField &, const septernion &, const vectorField &)
Transform given vectorField of coordinates with the given septernion.
Definition: transformField.C:73
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::solidBodyMotionDisplacementPointPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: solidBodyMotionDisplacementPointPatchVectorField.C:162
points0
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
pointPatchFields.H
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::solidBodyMotionDisplacementPointPatchVectorField::solidBodyMotionDisplacementPointPatchVectorField
solidBodyMotionDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
Definition: solidBodyMotionDisplacementPointPatchVectorField.C:43
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::solidBodyMotionDisplacementPointPatchVectorField::localPoints0
const pointField & localPoints0() const
Definition: solidBodyMotionDisplacementPointPatchVectorField.C:137
constant
constant condensation/saturation model.
solidBodyMotionDisplacementPointPatchVectorField.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::IOobject::MUST_READ
Definition: IOobject.H:185