oscillatingVelocityPointPatchVectorField.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 -------------------------------------------------------------------------------
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 "pointPatchFields.H"
31 #include "Time.H"
32 #include "polyMesh.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
43 (
44  const pointPatch& p,
46 )
47 :
49  amplitude_(Zero),
50  omega_(0.0),
51  p0_(p.localPoints())
52 {}
53 
54 
57 (
58  const pointPatch& p,
60  const dictionary& dict
61 )
62 :
64  amplitude_(dict.lookup("amplitude")),
65  omega_(dict.get<scalar>("omega"))
66 {
67  if (!dict.found("value"))
68  {
69  updateCoeffs();
70  }
71 
72  if (dict.found("p0"))
73  {
74  p0_ = vectorField("p0", dict , p.size());
75  }
76  else
77  {
78  p0_ = p.localPoints();
79  }
80 }
81 
82 
85 (
86  const oscillatingVelocityPointPatchVectorField& ptf,
87  const pointPatch& p,
88  const DimensionedField<vector, pointMesh>& iF,
89  const pointPatchFieldMapper& mapper
90 )
91 :
92  fixedValuePointPatchField<vector>(ptf, p, iF, mapper),
93  amplitude_(ptf.amplitude_),
94  omega_(ptf.omega_),
95  p0_(ptf.p0_, mapper)
96 {}
97 
98 
101 (
104 )
105 :
107  amplitude_(ptf.amplitude_),
108  omega_(ptf.omega_),
109  p0_(ptf.p0_)
110 {}
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
116 (
117  const pointPatchFieldMapper& m
118 )
119 {
121 
122  p0_.autoMap(m);
123 }
124 
125 
127 (
128  const pointPatchField<vector>& ptf,
129  const labelList& addr
130 )
131 {
133  refCast<const oscillatingVelocityPointPatchVectorField>(ptf);
134 
136 
137  p0_.rmap(oVptf.p0_, addr);
138 }
139 
140 
142 {
143  if (this->updated())
144  {
145  return;
146  }
147 
148  const polyMesh& mesh = this->internalField().mesh()();
149  const Time& t = mesh.time();
150  const pointPatch& p = this->patch();
151 
153  (
154  (p0_ + amplitude_*sin(omega_*t.value()) - p.localPoints())
155  /t.deltaTValue()
156  );
157 
159 }
160 
161 
163 {
165  os.writeEntry("amplitude", amplitude_);
166  os.writeEntry("omega", omega_);
167  p0_.writeEntry("p0", os);
168  writeEntry("value", os);
169 }
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
175 (
177  oscillatingVelocityPointPatchVectorField
178 );
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace Foam
183 
184 // ************************************************************************* //
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::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::sin
dimensionedScalar sin(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:257
Foam::Field< vector >::operator
friend Ostream & operator(Ostream &, const Field< Type > &)
Foam::dimensioned::value
const Type & value() const
Definition: dimensionedType.C:427
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:100
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:54
polyMesh.H
Foam::pointPatchField< vector >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:73
Foam::pointPatchField< vector >::patch
const pointPatch & patch() const
Definition: pointPatchField.H:264
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::oscillatingVelocityPointPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Definition: oscillatingVelocityPointPatchVectorField.C:134
Foam::fixedValuePointPatchField< vector >
Foam::makePointPatchTypeField
makePointPatchTypeField(pointPatchVectorField, solidBodyMotionDisplacementPointPatchVectorField)
Foam::oscillatingVelocityPointPatchVectorField::write
virtual void write(Ostream &) const
Definition: oscillatingVelocityPointPatchVectorField.C:155
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::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:57
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:379
oscillatingVelocityPointPatchVectorField.H
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
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
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::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
Foam::oscillatingVelocityPointPatchVectorField::autoMap
virtual void autoMap(const pointPatchFieldMapper &)
Definition: oscillatingVelocityPointPatchVectorField.C:109
Time.H
Foam::oscillatingVelocityPointPatchVectorField::rmap
virtual void rmap(const pointPatchField< vector > &, const labelList &)
Definition: oscillatingVelocityPointPatchVectorField.C:120
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::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
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
Foam::oscillatingVelocityPointPatchVectorField
Foam::oscillatingVelocityPointPatchVectorField.
Definition: oscillatingVelocityPointPatchVectorField.H:46
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::oscillatingVelocityPointPatchVectorField::oscillatingVelocityPointPatchVectorField
oscillatingVelocityPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Definition: oscillatingVelocityPointPatchVectorField.C:36