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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "dynamicInkJetFvMesh.H"
30 #include "volFields.H"
31 #include "mathematicalConstants.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(dynamicInkJetFvMesh, 0);
38  addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, IOobject);
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
44 Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh(const IOobject& io)
45 :
46  dynamicFvMesh(io),
47  dynamicMeshCoeffs_
48  (
50  (
51  IOobject
52  (
53  "dynamicMeshDict",
54  io.time().constant(),
55  *this,
56  IOobject::MUST_READ_IF_MODIFIED,
57  IOobject::NO_WRITE,
58  false
59  )
60  ).optionalSubDict(typeName + "Coeffs")
61  ),
62  amplitude_(dynamicMeshCoeffs_.get<scalar>("amplitude")),
63  frequency_(dynamicMeshCoeffs_.get<scalar>("frequency")),
64  refPlaneX_(dynamicMeshCoeffs_.get<scalar>("refPlaneX")),
65  stationaryPoints_
66  (
67  IOobject
68  (
69  "points",
70  io.time().constant(),
71  meshSubDir,
72  *this,
73  IOobject::MUST_READ,
74  IOobject::NO_WRITE
75  )
76  )
77 {
78  Info<< "Performing a dynamic mesh calculation: " << endl
79  << "amplitude: " << amplitude_
80  << " frequency: " << frequency_
81  << " refPlaneX: " << refPlaneX_ << endl;
82 }
83 
84 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
85 
87 {}
88 
89 
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91 
93 {
94  scalar scalingFunction =
95  0.5*
96  (
97  ::cos(constant::mathematical::twoPi*frequency_*time().value())
98  - 1.0
99  );
100 
101  Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
102  << scalingFunction << endl;
103 
104  pointField newPoints = stationaryPoints_;
105 
106  newPoints.replace
107  (
108  vector::X,
109  stationaryPoints_.component(vector::X)*
110  (
111  1.0
112  + pos0
113  (
114  - (stationaryPoints_.component(vector::X))
115  - refPlaneX_
116  )*amplitude_*scalingFunction
117  )
118  );
119 
120  fvMesh::movePoints(newPoints);
121 
122  lookupObjectRef<volVectorField>("U").correctBoundaryConditions();
123 
124  return true;
125 }
126 
127 
128 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
volFields.H
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
mathematicalConstants.H
Foam::dynamicFvMesh
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:78
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::Vector< scalar >::X
Definition: Vector.H:81
Foam::Field::replace
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
Definition: Field.C:563
Foam::dynamicInkJetFvMesh::update
virtual bool update()
Update the mesh for both mesh motion and topology change.
Definition: dynamicInkJetFvMesh.C:92
Foam::constant::mathematical::twoPi
constexpr scalar twoPi(2 *M_PI)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::surfaceInterpolation::movePoints
bool movePoints()
Do what is necessary if the mesh has moved.
Definition: surfaceInterpolation.C:125
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
dynamicInkJetFvMesh.H
constant
constant condensation/saturation model.
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh
~dynamicInkJetFvMesh()
Destructor.
Definition: dynamicInkJetFvMesh.C:86
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265