oscillatingDisplacementPointPatchVectorField.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) 2011-2026 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 
28 #include "Time.H"
29 #include "polyMesh.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),
47  amplitude_(dict.lookup<vector>("amplitude", dimLength)),
48  omega_(dict.lookup<scalar>("omega", units::radians/dimTime))
49 {
50  if (!dict.found("value"))
51  {
52  updateCoeffs();
53  }
54 }
55 
56 
59 (
61  const pointPatch& p,
63  const fieldMapper& mapper
64 )
65 :
66  fixedValuePointPatchVectorField(ptf, p, iF, mapper),
67  amplitude_(ptf.amplitude_),
68  omega_(ptf.omega_)
69 {}
70 
71 
74 (
77 )
78 :
79  fixedValuePointPatchVectorField(ptf, iF),
80  amplitude_(ptf.amplitude_),
81  omega_(ptf.omega_)
82 {}
83 
84 
85 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
86 
88 {
89  if (this->updated())
90  {
91  return;
92  }
93 
94  const polyMesh& mesh = this->internalField().mesh()();
95  const Time& t = mesh.time();
96 
97  Field<vector>::operator=(amplitude_*sin(omega_*t.value()));
98 
99  fixedValuePointPatchVectorField::updateCoeffs();
100 }
101 
102 
104 {
106  writeEntry(os, "amplitude", amplitude_);
107  writeEntry(os, "omega", omega_);
108  writeEntry(os, "value", *this);
109 }
110 
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
115 (
118 );
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace Foam
123 
124 // ************************************************************************* //
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...
void operator=(const Field< Type > &)
Definition: Field.C:557
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const Type & value() const
Return const reference to value.
Abstract base class for field mapping.
Definition: fieldMapper.H:48
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:433
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
oscillatingDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
Abstract base class for point-mesh patch fields.
virtual void write(Ostream &) const
Write.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const unitSet radians
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
makePointPatchTypeField(pointPatchVectorField, angularOscillatingDisplacementPointPatchVectorField)
const dimensionSet & dimLength
Definition: dimensions.C:141
dimensionedScalar sin(const dimensionedScalar &ds)
const dimensionSet & dimTime
Definition: dimensions.C:142
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dictionary dict
volScalarField & p