FreeFOAM The Cross-Platform CFD Toolkit
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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 <finiteVolume/volFields.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 
42 Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh(const IOobject& io)
43 :
44  dynamicFvMesh(io),
45  dynamicMeshCoeffs_
46  (
48  (
49  IOobject
50  (
51  "dynamicMeshDict",
52  io.time().constant(),
53  *this,
54  IOobject::MUST_READ,
55  IOobject::NO_WRITE
56  )
57  ).subDict(typeName + "Coeffs")
58  ),
59  amplitude_(readScalar(dynamicMeshCoeffs_.lookup("amplitude"))),
60  frequency_(readScalar(dynamicMeshCoeffs_.lookup("frequency"))),
61  refPlaneX_(readScalar(dynamicMeshCoeffs_.lookup("refPlaneX"))),
62  stationaryPoints_
63  (
64  IOobject
65  (
66  "points",
67  io.time().constant(),
68  meshSubDir,
69  *this,
70  IOobject::MUST_READ,
71  IOobject::NO_WRITE
72  )
73  )
74 {
75  Info<< "Performing a dynamic mesh calculation: " << endl
76  << "amplitude: " << amplitude_
77  << " frequency: " << frequency_
78  << " refPlaneX: " << refPlaneX_ << endl;
79 }
80 
81 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
82 
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
90 {
91  scalar scalingFunction =
92  0.5*(::cos(2*mathematicalConstant::pi*frequency_*time().value()) - 1.0);
93 
94  Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
95  << scalingFunction << endl;
96 
97  pointField newPoints = stationaryPoints_;
98 
99  newPoints.replace
100  (
101  vector::X,
102  stationaryPoints_.component(vector::X)*
103  (
104  1.0
105  + pos
106  (
107  - (stationaryPoints_.component(vector::X))
108  - refPlaneX_
109  )*amplitude_*scalingFunction
110  )
111  );
112 
113  fvMesh::movePoints(newPoints);
114 
115  volVectorField& U =
116  const_cast<volVectorField&>(lookupObject<volVectorField>("U"));
118 
119  return true;
120 }
121 
122 
123 // ************************ vim: set sw=4 sts=4 et: ************************ //