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);
40  addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, doInit);
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_IF_MODIFIED,
63  IOobject::NO_WRITE,
64  false
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 // ************************************************************************* //
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:169
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:369
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
Foam::IOobject::time
const Time & time() const
Return Time associated with the objectRegistry.
Definition: IOobject.C:493
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
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:551
Foam::dynamicInkJetFvMesh::update
virtual bool update()
Update the mesh for both mesh motion and topology change.
Definition: dynamicInkJetFvMesh.C:98
Foam::constant::mathematical::twoPi
constexpr scalar twoPi(2 *M_PI)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::surfaceInterpolation::movePoints
virtual bool movePoints()
Do what is necessary if the mesh has moved.
Definition: surfaceInterpolation.C:151
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
dynamicInkJetFvMesh.H
Foam::dictionary::optionalSubDict
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:577
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh
~dynamicInkJetFvMesh()
Destructor.
Definition: dynamicInkJetFvMesh.C:92
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265