Helicity (U & curl(U)) foamCalcFunction

This commit is contained in:
Vuko Vukcevic 2018-03-15 07:59:14 +01:00
parent 88cdcdc222
commit 21f058c798
3 changed files with 282 additions and 0 deletions

View file

@ -10,6 +10,7 @@ field/magGrad/magGrad.C
field/div/div.C
field/randomise/randomise.C
field/interpolate/interpolate.C
field/helicity/helicity.C
basic/addSubtract/addSubtract.C
basic/scalarMult/scalarMult.C

View file

@ -0,0 +1,150 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "helicity.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace calcTypes
{
defineTypeNameAndDebug(helicity, 0);
addToRunTimeSelectionTable(calcType, helicity, dictionary);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::calcTypes::helicity::helicity()
:
calcType()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::calcTypes::helicity::~helicity()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::calcTypes::helicity::init()
{
argList::validArgs.append("helicity");
argList::validArgs.append("fieldName");
}
void Foam::calcTypes::helicity::preCalc
(
const argList& args,
const Time& runTime,
const fvMesh& mesh
)
{}
void Foam::calcTypes::helicity::calc
(
const argList& args,
const Time& runTime,
const fvMesh& mesh
)
{
const word& fieldName = args.additionalArgs()[1];
IOobject fieldHeader
(
fieldName,
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
// Check field exists
if (fieldHeader.headerOk())
{
bool processed = false;
writeHelicityField(fieldHeader, mesh, processed);
if (!processed)
{
FatalError
<< "Unable to process " << fieldName << nl
<< "No call to helicity for fields of type "
<< fieldHeader.headerClassName() << nl << nl
<< exit(FatalError);
}
}
else
{
Info<< " No " << fieldName << endl;
}
}
void Foam::calcTypes::helicity::writeHelicityField
(
const IOobject& header,
const fvMesh& mesh,
bool& processed
)
{
if (header.headerClassName() == volVectorField::typeName)
{
Info<< " Reading " << header.name() << endl;
volVectorField field(header, mesh);
Info<< " Calculating helicity" << header.name() << endl;
volScalarField helicityField
(
IOobject
(
"helicity" + header.name(),
mesh.time().timeName(),
mesh,
IOobject::NO_READ
),
field & (fvc::curl(field))
);
Info << "helicity(" << header.name() << "): max: "
<< gMax(helicityField.internalField())
<< " min: " << gMin(helicityField.internalField()) << endl;
helicityField.write();
processed = true;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::calcTypes::helicity
Description
Calculates and writes the helicity of a vector field for each time, defines
as: U & rot(U)
SourceFiles
helicity.C
\*---------------------------------------------------------------------------*/
#ifndef helicity_H
#define helicity_H
#include "calcType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace calcTypes
{
/*---------------------------------------------------------------------------*\
Class helicity Declaration
\*---------------------------------------------------------------------------*/
class helicity
:
public calcType
{
// Private Member Functions
//- Disallow default bitwise copy construct
helicity(const helicity&);
//- Disallow default bitwise assignment
void operator=(const helicity&);
protected:
// Member Functions
// Calculation routines
//- Initialise - typically setting static variables,
// e.g. command line arguments
virtual void init();
//- Pre-time loop calculations
virtual void preCalc
(
const argList& args,
const Time& runTime,
const fvMesh& mesh
);
//- Time loop calculations
virtual void calc
(
const argList& args,
const Time& runTime,
const fvMesh& mesh
);
// I-O
//- Write component fields
void writeHelicityField
(
const IOobject& header,
const fvMesh& mesh,
bool& processed
);
public:
//- Runtime type information
TypeName("helicity");
// Constructors
//- Construct null
helicity();
// Destructor
virtual ~helicity();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace calcTypes
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //