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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "transformField.H"
31 #include "pointPatchFields.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
39 
42 (
43  const pointPatch& p,
45 )
46 :
47  fixedValuePointPatchVectorField(p, iF),
48  SBMFPtr_()
49 {}
50 
51 
54 (
55  const pointPatch& p,
57  const dictionary& dict
58 )
59 :
60  fixedValuePointPatchVectorField(p, iF, dict, false),
61  SBMFPtr_(solidBodyMotionFunction::New(dict, this->db().time()))
62 {
63  if (!dict.found("value"))
64  {
65  // Determine current local points and offset
66  fixedValuePointPatchVectorField::operator==
67  (
68  transformPoints(SBMFPtr_().transformation(), localPoints0())
69  -localPoints0()
70  );
71  }
72 }
73 
74 
77 (
79  const pointPatch& p,
81  const pointPatchFieldMapper& mapper
82 )
83 :
84  fixedValuePointPatchVectorField(ptf, p, iF, mapper),
85  SBMFPtr_(ptf.SBMFPtr_().clone().ptr())
86 {
87  // For safety re-evaluate
88 
89  fixedValuePointPatchVectorField::operator==
90  (
91  transformPoints(SBMFPtr_().transformation(), localPoints0())
92  -localPoints0()
93  );
94 }
95 
96 
99 (
101 )
102 :
103  fixedValuePointPatchVectorField(ptf),
104  SBMFPtr_(ptf.SBMFPtr_().clone().ptr())
105 {}
106 
107 
110 (
113 )
114 :
115  fixedValuePointPatchVectorField(ptf, iF),
116  SBMFPtr_(ptf.SBMFPtr_().clone().ptr())
117 {
118  // For safety re-evaluate
119 
120  fixedValuePointPatchVectorField::operator==
121  (
122  transformPoints(SBMFPtr_().transformation(), localPoints0())
123  -localPoints0()
124  );
125 }
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
130 const pointField&
132 {
133  if (!localPoints0Ptr_.valid())
134  {
136  (
137  IOobject
138  (
139  "points",
140  this->db().time().constant(),
142  this->db(),
145  false
146  )
147  );
148 
149  localPoints0Ptr_.reset(new pointField(points0, patch().meshPoints()));
150  }
151  return *localPoints0Ptr_;
152 }
153 
154 
156 {
157  if (this->updated())
158  {
159  return;
160  }
161 
162  // Determine current local points and offset
163  fixedValuePointPatchVectorField::operator==
164  (
165  transformPoints(SBMFPtr_().transformation(), localPoints0())
166  -localPoints0()
167  );
168 
169  fixedValuePointPatchVectorField::updateCoeffs();
170 }
171 
172 
174 write(Ostream& os) const
175 {
176  // Note: write value
178 
179  os.writeEntry(solidBodyMotionFunction::typeName, SBMFPtr_->type());
180 
181  os << indent << word(SBMFPtr_->type() + "Coeffs");
182  SBMFPtr_->writeData(os);
183 }
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
189 (
192 );
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace Foam
198 
199 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
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:104
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:62
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: dictionary.C:359
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:315
Foam::solidBodyMotionDisplacementPointPatchVectorField
Enables the specification of a fixed value boundary condition using the solid body motion functions.
Definition: solidBodyMotionDisplacementPointPatchVectorField.H:52
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::pointPatchField< vector >
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:121
Foam::solidBodyMotionDisplacementPointPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: solidBodyMotionDisplacementPointPatchVectorField.C:174
Foam::transformPoints
void transformPoints(vectorField &, const septernion &, const vectorField &)
Transform given vectorField of coordinates with the given septernion.
Definition: transformField.C:73
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:307
Foam::solidBodyMotionDisplacementPointPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: solidBodyMotionDisplacementPointPatchVectorField.C:155
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::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
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:35
Foam::solidBodyMotionDisplacementPointPatchVectorField::solidBodyMotionDisplacementPointPatchVectorField
solidBodyMotionDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
Definition: solidBodyMotionDisplacementPointPatchVectorField.C:42
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:131
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:120