dynamicInkJetFvMesh.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-2017 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 
29 #include "dynamicInkJetFvMesh.H"
31 #include "volFields.H"
32 #include "mathematicalConstants.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(dynamicInkJetFvMesh, 0);
39  addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, IOobject);
41 }
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
46 Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh
47 (
48  const IOobject& io,
49  const bool doInit
50 )
51 :
52  dynamicFvMesh(io, doInit),
53  dynamicMeshCoeffs_
54  (
56  (
57  IOobject
58  (
59  "dynamicMeshDict",
60  io.time().constant(),
61  *this,
62  IOobject::MUST_READ,
63  IOobject::NO_WRITE,
64  IOobject::NO_REGISTER
65  )
66  ).optionalSubDict(typeName + "Coeffs")
67  ),
68  amplitude_(dynamicMeshCoeffs_.get<scalar>("amplitude")),
69  frequency_(dynamicMeshCoeffs_.get<scalar>("frequency")),
70  refPlaneX_(dynamicMeshCoeffs_.get<scalar>("refPlaneX")),
71  stationaryPoints_
72  (
73  IOobject
74  (
75  "points",
76  io.time().constant(),
77  meshSubDir,
78  *this,
79  IOobject::MUST_READ,
80  IOobject::NO_WRITE
81  )
82  )
83 {
84  Info<< "Performing a dynamic mesh calculation: " << endl
85  << "amplitude: " << amplitude_
86  << " frequency: " << frequency_
87  << " refPlaneX: " << refPlaneX_ << endl;
88 }
89 
90 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
91 
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97 
99 {
100  scalar scalingFunction =
101  0.5*
102  (
103  ::cos(constant::mathematical::twoPi*frequency_*time().value())
104  - 1.0
105  );
106 
107  Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
108  << scalingFunction << endl;
109 
110  pointField newPoints = stationaryPoints_;
111 
112  newPoints.replace
113  (
114  vector::X,
115  stationaryPoints_.component(vector::X)*
116  (
117  1.0
118  + pos0
119  (
120  - (stationaryPoints_.component(vector::X))
121  - refPlaneX_
122  )*amplitude_*scalingFunction
123  )
124  );
125 
126  fvMesh::movePoints(newPoints);
127 
128  lookupObjectRef<volVectorField>("U").correctBoundaryConditions();
129 
130  return true;
131 }
132 
133 
134 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
cellMask correctBoundaryConditions()
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
virtual bool movePoints()
Do what is necessary if the mesh has moved.
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
Definition: Field.C:620
Mesh motion specifically for the "pumping" system of an ink-jet injector.
Macros for easy insertion into run-time selection tables.
virtual bool update()
Update the mesh for both mesh motion and topology change.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
dimensionedScalar cos(const dimensionedScalar &ds)
constexpr scalar twoPi(2 *M_PI)
dimensionedScalar pos0(const dimensionedScalar &ds)
defineTypeNameAndDebug(combustionModel, 0)
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:74
messageStream Info
Information stream (stdout output on master, null elsewhere)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)