dynamicInkJetFvMesh.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-2019 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 
26 #include "dynamicInkJetFvMesh.H"
28 #include "volFields.H"
29 #include "mathematicalConstants.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(dynamicInkJetFvMesh, 0);
36  addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, IOobject);
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 :
44  dynamicFvMesh(io),
45  dynamicMeshCoeffs_(dynamicMeshDict().optionalSubDict(typeName + "Coeffs")),
46  amplitude_(dynamicMeshCoeffs_.lookup<scalar>("amplitude")),
47  frequency_(dynamicMeshCoeffs_.lookup<scalar>("frequency")),
48  refPlaneX_(dynamicMeshCoeffs_.lookup<scalar>("refPlaneX")),
49  stationaryPoints_
50  (
51  IOobject
52  (
53  "points",
54  io.time().constant(),
55  meshSubDir,
56  *this,
57  IOobject::MUST_READ,
58  IOobject::NO_WRITE
59  )
60  ),
61  velocityMotionCorrection_(*this, dynamicMeshDict())
62 {
63  Info<< "Performing a dynamic mesh calculation: " << endl
64  << "amplitude: " << amplitude_
65  << " frequency: " << frequency_
66  << " refPlaneX: " << refPlaneX_ << endl;
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
71 
73 {}
74 
75 
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
77 
79 {
80  scalar scalingFunction =
81  0.5*
82  (
83  ::cos(constant::mathematical::twoPi*frequency_*time().value())
84  - 1.0
85  );
86 
87  Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
88  << scalingFunction << endl;
89 
90  pointField newPoints = stationaryPoints_;
91 
92  newPoints.replace
93  (
94  vector::X,
95  stationaryPoints_.component(vector::X)*
96  (
97  1.0
98  + pos0
99  (
100  - (stationaryPoints_.component(vector::X))
101  - refPlaneX_
102  )*amplitude_*scalingFunction
103  )
104  );
105 
106  fvMesh::movePoints(newPoints);
107 
108  velocityMotionCorrection_.update();
109 
110  return true;
111 }
112 
113 
114 // ************************************************************************* //
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool movePoints()
Do what is necessary if the mesh has moved.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:239
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
Definition: Field.C:453
Macros for easy insertion into run-time selection tables.
virtual bool update()
Update the mesh for both mesh motion and topology change.
stressControl lookup("compactNormalStress") >> compactNormalStress
dimensionedScalar cos(const dimensionedScalar &ds)
const Type & value() const
Return const reference to value.
const scalar twoPi(2 *pi)
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: Field.C:441
dynamicInkJetFvMesh(const IOobject &io)
Construct from IOobject.
dimensionedScalar pos0(const dimensionedScalar &ds)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:49
messageStream Info
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.