openfoam/src/dynamicFvMesh/dynamicInkJetFvMesh/dynamicInkJetFvMesh.C
Henry Weller 56bfc75949 Rationalize the "pos" function
"pos" now returns 1 if the argument is greater than 0, otherwise it returns 0.
This is consistent with the common mathematical definition of the "pos" function:

https://en.wikipedia.org/wiki/Sign_(mathematics)

However the previous implementation in which 1 was also returned for a 0
argument is useful in many situations so the "pos0" has been added which returns
1 if the argument is greater or equal to 0.  Additionally the "neg0" has been
added which returns 1 if if the argument is less than or equal to 0.
2017-06-22 14:32:18 +01:00

129 lines
3.7 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "dynamicInkJetFvMesh.H"
#include "addToRunTimeSelectionTable.H"
#include "volFields.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(dynamicInkJetFvMesh, 0);
addToRunTimeSelectionTable(dynamicFvMesh, dynamicInkJetFvMesh, IOobject);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::dynamicInkJetFvMesh::dynamicInkJetFvMesh(const IOobject& io)
:
dynamicFvMesh(io),
dynamicMeshCoeffs_
(
IOdictionary
(
IOobject
(
"dynamicMeshDict",
io.time().constant(),
*this,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
).optionalSubDict(typeName + "Coeffs")
),
amplitude_(readScalar(dynamicMeshCoeffs_.lookup("amplitude"))),
frequency_(readScalar(dynamicMeshCoeffs_.lookup("frequency"))),
refPlaneX_(readScalar(dynamicMeshCoeffs_.lookup("refPlaneX"))),
stationaryPoints_
(
IOobject
(
"points",
io.time().constant(),
meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
{
Info<< "Performing a dynamic mesh calculation: " << endl
<< "amplitude: " << amplitude_
<< " frequency: " << frequency_
<< " refPlaneX: " << refPlaneX_ << endl;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::dynamicInkJetFvMesh::~dynamicInkJetFvMesh()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::dynamicInkJetFvMesh::update()
{
scalar scalingFunction =
0.5*
(
::cos(constant::mathematical::twoPi*frequency_*time().value())
- 1.0
);
Info<< "Mesh scaling. Time = " << time().value() << " scaling: "
<< scalingFunction << endl;
pointField newPoints = stationaryPoints_;
newPoints.replace
(
vector::X,
stationaryPoints_.component(vector::X)*
(
1.0
+ pos0
(
- (stationaryPoints_.component(vector::X))
- refPlaneX_
)*amplitude_*scalingFunction
)
);
fvMesh::movePoints(newPoints);
volVectorField& U =
const_cast<volVectorField&>(lookupObject<volVectorField>("U"));
U.correctBoundaryConditions();
return true;
}
// ************************************************************************* //