BUGFIX: Illegal use of uninitialised value (backport)
[foam-extend-3.2.git] / src / dynamicMesh / dynamicFvMesh / dynamicInkJetFvMesh / dynamicInkJetFvMesh.C
blobc66169bac3f378c88f9f8564579b2c5671530588
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "dynamicInkJetFvMesh.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "volFields.H"
30 #include "mathematicalConstants.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 namespace Foam
36     defineTypeNameAndDebug(dynamicInkJetFvMesh, 0);
37     addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, IOobject);
41 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
43 Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh(const IOobject& io)
45     dynamicFvMesh(io),
46     dynamicMeshCoeffs_
47     (
48         IOdictionary
49         (
50             IOobject
51             (
52                 "dynamicMeshDict",
53                 io.time().constant(),
54                 *this,
55                 IOobject::MUST_READ,
56                 IOobject::NO_WRITE
57             )
58         ).subDict(typeName + "Coeffs")
59     ),
60     amplitude_(readScalar(dynamicMeshCoeffs_.lookup("amplitude"))),
61     frequency_(readScalar(dynamicMeshCoeffs_.lookup("frequency"))),
62     refPlaneX_(readScalar(dynamicMeshCoeffs_.lookup("refPlaneX"))),
63     stationaryPoints_
64     (
65         IOobject
66         (
67             "points",
68             io.time().constant(),
69             meshSubDir,
70             *this,
71             IOobject::MUST_READ,
72             IOobject::NO_WRITE
73         )
74     )
76     Info<< "Performing a dynamic mesh calculation: " << endl
77         << "amplitude: " << amplitude_
78         << " frequency: " << frequency_
79         << " refPlaneX: " << refPlaneX_ << endl;
82 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
84 Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh()
88 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
90 bool Foam::dynamicInkJetFvMesh::update()
92     scalar scalingFunction =
93         0.5*(::cos(2*mathematicalConstant::pi*frequency_*time().value()) - 1.0);
95     Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
96         << scalingFunction << endl;
98     pointField newPoints = stationaryPoints_;
100     newPoints.replace
101     (
102         vector::X,
103         stationaryPoints_.component(vector::X)*
104         (
105             1.0
106           + pos
107             (
108               - (stationaryPoints_.component(vector::X))
109               - refPlaneX_
110             )*amplitude_*scalingFunction
111         )
112     );
114     fvMesh::movePoints(newPoints);
116     // Mesh motion only - return false
117     return false;
121 // ************************************************************************* //