Add the OpenFOAM source tree
This commit is contained in:
@ -0,0 +1,217 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "CourantNo.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "fvcSurfaceIntegrate.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(CourantNo, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::CourantNo::rho
|
||||
(
|
||||
const surfaceScalarField& phi
|
||||
) const
|
||||
{
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
return (obr_.lookupObject<volScalarField>(rhoName_));
|
||||
}
|
||||
else
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
return tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rho",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("rho", dimless, 1.0)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::CourantNo::CourantNo
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
phiName_("phi"),
|
||||
rhoName_("rho")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"CourantNo::CourantNo"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* CourantNoPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(CourantNoPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::CourantNo::~CourantNo()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::CourantNo::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::CourantNo::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
volScalarField& CourantNo =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh.lookupObject<volScalarField>(type())
|
||||
);
|
||||
|
||||
scalarField& iField = CourantNo.internalField();
|
||||
|
||||
const scalarField sumPhi
|
||||
(
|
||||
fvc::surfaceSum(mag(phi))().internalField()
|
||||
/rho(phi)().internalField()
|
||||
);
|
||||
|
||||
iField = 0.5*sumPhi/mesh.V().field()*mesh.time().deltaTValue();
|
||||
|
||||
CourantNo.correctBoundaryConditions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::CourantNo::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::CourantNo::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::CourantNo::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const volScalarField& CourantNo =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << CourantNo.name() << nl
|
||||
<< endl;
|
||||
|
||||
CourantNo.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,161 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::CourantNo
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates and outputs the Courant number as a
|
||||
volScalarField. The field is stored on the mesh database so that it can
|
||||
be retrieved and used for other applications.
|
||||
|
||||
SourceFiles
|
||||
CourantNo.C
|
||||
IOCourantNo.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CourantNo_H
|
||||
#define CourantNo_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class CourantNo Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class CourantNo
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of CourantNo objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of flux field, default is "phi"
|
||||
word phiName_;
|
||||
|
||||
//- Name of density field (optional)
|
||||
word rhoName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return 1 if the flux field is volumetric, otherwise return rho
|
||||
// from the database
|
||||
tmp<volScalarField> rho(const surfaceScalarField& p) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
CourantNo(const CourantNo&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const CourantNo&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("CourantNo");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
CourantNo
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~CourantNo();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of CourantNo
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the CourantNo data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the CourantNo and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "CourantNoFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(CourantNoFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
CourantNoFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::CourantNoFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around CourantNo to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
CourantNoFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef CourantNoFunctionObject_H
|
||||
#define CourantNoFunctionObject_H
|
||||
|
||||
#include "CourantNo.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<CourantNo> CourantNoFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOCourantNo
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for CourantNo.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOCourantNo_H
|
||||
#define IOCourantNo_H
|
||||
|
||||
#include "CourantNo.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<CourantNo> IOCourantNo;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,242 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "DESModelRegions.H"
|
||||
#include "volFields.H"
|
||||
#include "compressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "compressible/LES/DESModel/DESModel.H"
|
||||
#include "incompressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "incompressible/LES/DESModel/DESModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(DESModelRegions, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::DESModelRegions::writeFileHeader(const label i)
|
||||
{
|
||||
writeHeader(file(), "DES model region coverage (% volume)");
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "LES");
|
||||
writeTabbed(file(), "RAS");
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::DESModelRegions::DESModelRegions
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(false)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"DESModelRegions::DESModelRegions"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* DESModelRegionsPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(DESModelRegionsPtr);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::DESModelRegions::~DESModelRegions()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::DESModelRegions::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::DESModelRegions::execute()
|
||||
{
|
||||
typedef incompressible::turbulenceModel icoModel;
|
||||
typedef incompressible::DESModel icoDESModel;
|
||||
|
||||
typedef compressible::turbulenceModel cmpModel;
|
||||
typedef compressible::DESModel cmpDESModel;
|
||||
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
Info(log_)<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
volScalarField& DESModelRegions =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh.lookupObject<volScalarField>(type())
|
||||
);
|
||||
|
||||
|
||||
label DESpresent = false;
|
||||
if (mesh.foundObject<icoModel>("turbulenceModel"))
|
||||
{
|
||||
const icoModel& model =
|
||||
mesh.lookupObject<icoModel>("turbulenceModel");
|
||||
|
||||
if (isA<icoDESModel>(model))
|
||||
{
|
||||
const icoDESModel& des =
|
||||
dynamic_cast<const icoDESModel&>(model);
|
||||
DESModelRegions == des.LESRegion();
|
||||
DESpresent = true;
|
||||
}
|
||||
}
|
||||
else if (mesh.foundObject<cmpModel>("turbulenceModel"))
|
||||
{
|
||||
const cmpModel& model =
|
||||
mesh.lookupObject<cmpModel>("turbulenceModel");
|
||||
|
||||
if (isA<cmpDESModel>(model))
|
||||
{
|
||||
const cmpDESModel& des =
|
||||
dynamic_cast<const cmpDESModel&>(model);
|
||||
DESModelRegions == des.LESRegion();
|
||||
DESpresent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (DESpresent)
|
||||
{
|
||||
scalar prc =
|
||||
gSum(DESModelRegions.internalField()*mesh.V())
|
||||
/gSum(mesh.V())*100.0;
|
||||
|
||||
if (Pstream::master() && log_)
|
||||
{
|
||||
file() << obr_.time().value()
|
||||
<< token::TAB << prc
|
||||
<< token::TAB << 100.0 - prc
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Info(log_)
|
||||
<< " LES = " << prc << " % (volume)" << nl
|
||||
<< " RAS = " << 100.0 - prc << " % (volume)" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(log_)<< " No DES turbulence model found in database" << nl
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::DESModelRegions::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::DESModelRegions::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::DESModelRegions::write()
|
||||
{
|
||||
if (log_)
|
||||
{
|
||||
const volScalarField& DESModelRegions =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << DESModelRegions.name() << nl
|
||||
<< endl;
|
||||
|
||||
DESModelRegions.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::DESModelRegions
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object writes out an indicator field for DES turbulence
|
||||
calculations, that is:
|
||||
|
||||
- 0 for RAS regions
|
||||
- 1 for LES regions
|
||||
|
||||
SourceFiles
|
||||
DESModelRegions.C
|
||||
IODESModelRegions.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DESModelRegions_H
|
||||
#define DESModelRegions_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class DESModelRegions Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class DESModelRegions
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of DESModelRegions object
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
DESModelRegions(const DESModelRegions&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const DESModelRegions&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("DESModelRegions");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
DESModelRegions
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~DESModelRegions();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of DESModelRegions
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the DESModelRegions data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the DESModelRegions and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "DESModelRegionsFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(DESModelRegionsFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
DESModelRegionsFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::DESModelRegionsFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around DESModelRegions to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
DESModelRegionsFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DESModelRegionsFunctionObject_H
|
||||
#define DESModelRegionsFunctionObject_H
|
||||
|
||||
#include "DESModelRegions.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<DESModelRegions>
|
||||
DESModelRegionsFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IODESModelRegions
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for DESModelRegions.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IODESModelRegions_H
|
||||
#define IODESModelRegions_H
|
||||
|
||||
#include "DESModelRegions.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<DESModelRegions> IODESModelRegions;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOLambda2
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for Lambda2.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOLambda2_H
|
||||
#define IOLambda2_H
|
||||
|
||||
#include "Lambda2.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<Lambda2> IOLambda2;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
176
src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C
Normal file
176
src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.C
Normal file
@ -0,0 +1,176 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "Lambda2.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "fvcGrad.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(Lambda2, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Lambda2::Lambda2
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
UName_("U")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"Lambda2::Lambda2"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* Lambda2Ptr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless/sqr(dimTime), 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(Lambda2Ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Lambda2::~Lambda2()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Lambda2::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
UName_ = dict.lookupOrDefault<word>("UName", "U");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Lambda2::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
const volVectorField& U =
|
||||
mesh.lookupObject<volVectorField>(UName_);
|
||||
|
||||
const volTensorField gradU(fvc::grad(U));
|
||||
|
||||
const volTensorField SSplusWW
|
||||
(
|
||||
(symm(gradU) & symm(gradU))
|
||||
+ (skew(gradU) & skew(gradU))
|
||||
);
|
||||
|
||||
volScalarField& Lambda2 =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh.lookupObject<volScalarField>(type())
|
||||
);
|
||||
|
||||
Lambda2 = -eigenValues(SSplusWW)().component(vector::Y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Lambda2::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Lambda2::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::Lambda2::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const volScalarField& Lambda2 =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << Lambda2.name() << nl
|
||||
<< endl;
|
||||
|
||||
Lambda2.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
154
src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H
Normal file
154
src/postProcessing/functionObjects/utilities/Lambda2/Lambda2.H
Normal file
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::Lambda2
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates and outputs the second largest eigenvalue
|
||||
of the sum of the square of the symmetrical and anti-symmetrical parts of
|
||||
the velocity gradient tensor.
|
||||
|
||||
SourceFiles
|
||||
Lambda2.C
|
||||
IOLambda2.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Lambda2_H
|
||||
#define Lambda2_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Lambda2 Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class Lambda2
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of Lambda2 objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of velocity field, default is "U"
|
||||
word UName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
Lambda2(const Lambda2&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Lambda2&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Lambda2");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
Lambda2
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Lambda2();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of Lambda2
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the Lambda2 data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the Lambda2 and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "Lambda2FunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(Lambda2FunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
Lambda2FunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::Lambda2FunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around Lambda2 to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
Lambda2FunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Lambda2FunctionObject_H
|
||||
#define Lambda2FunctionObject_H
|
||||
|
||||
#include "Lambda2.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<Lambda2> Lambda2FunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
50
src/postProcessing/functionObjects/utilities/Make/files
Normal file
50
src/postProcessing/functionObjects/utilities/Make/files
Normal file
@ -0,0 +1,50 @@
|
||||
codedFunctionObject/codedFunctionObject.C
|
||||
|
||||
CourantNo/CourantNo.C
|
||||
CourantNo/CourantNoFunctionObject.C
|
||||
|
||||
Lambda2/Lambda2.C
|
||||
Lambda2/Lambda2FunctionObject.C
|
||||
|
||||
Peclet/Peclet.C
|
||||
Peclet/PecletFunctionObject.C
|
||||
|
||||
Q/Q.C
|
||||
Q/QFunctionObject.C
|
||||
|
||||
blendingFactor/blendingFactor.C
|
||||
blendingFactor/blendingFactorFunctionObject.C
|
||||
|
||||
DESModelRegions/DESModelRegions.C
|
||||
DESModelRegions/DESModelRegionsFunctionObject.C
|
||||
|
||||
dsmcFields/dsmcFields.C
|
||||
dsmcFields/dsmcFieldsFunctionObject.C
|
||||
|
||||
pressureTools/pressureTools.C
|
||||
pressureTools/pressureToolsFunctionObject.C
|
||||
|
||||
scalarTransport/scalarTransport.C
|
||||
scalarTransport/scalarTransportFunctionObject.C
|
||||
|
||||
timeActivatedFileUpdate/timeActivatedFileUpdate.C
|
||||
timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C
|
||||
|
||||
turbulenceFields/turbulenceFields.C
|
||||
turbulenceFields/turbulenceFieldsFunctionObject.C
|
||||
|
||||
vorticity/vorticity.C
|
||||
vorticity/vorticityFunctionObject.C
|
||||
|
||||
wallShearStress/wallShearStress.C
|
||||
wallShearStress/wallShearStressFunctionObject.C
|
||||
|
||||
yPlusLES/yPlusLES.C
|
||||
yPlusLES/yPlusLESFunctionObject.C
|
||||
|
||||
yPlusRAS/yPlusRAS.C
|
||||
yPlusRAS/yPlusRASFunctionObject.C
|
||||
|
||||
setTimeStep/setTimeStepFunctionObject.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects
|
||||
27
src/postProcessing/functionObjects/utilities/Make/options
Normal file
27
src/postProcessing/functionObjects/utilities/Make/options
Normal file
@ -0,0 +1,27 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/fvOptions/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/dsmc/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/sampling/lnInclude \
|
||||
-I$(LIB_SRC)/transportModels \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions \
|
||||
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-lfvOptions \
|
||||
-lmeshTools \
|
||||
-lsampling \
|
||||
-llagrangian \
|
||||
-ldsmc \
|
||||
-lincompressibleTransportModels \
|
||||
-lcompressibleRASModels \
|
||||
-lincompressibleRASModels \
|
||||
-lcompressibleLESModels \
|
||||
-lincompressibleLESModels \
|
||||
-lfluidThermophysicalModels
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOPeclet
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for Peclet.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOPeclet_H
|
||||
#define IOPeclet_H
|
||||
|
||||
#include "Peclet.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<Peclet> IOPeclet;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
228
src/postProcessing/functionObjects/utilities/Peclet/Peclet.C
Normal file
228
src/postProcessing/functionObjects/utilities/Peclet/Peclet.C
Normal file
@ -0,0 +1,228 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "Peclet.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "incompressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "compressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "surfaceInterpolate.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(Peclet, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Peclet::Peclet
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
phiName_("phi"),
|
||||
rhoName_("rho")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"Peclet::Peclet"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
surfaceScalarField* PecletPtr
|
||||
(
|
||||
new surfaceScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(PecletPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Peclet::~Peclet()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Peclet::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Peclet::execute()
|
||||
{
|
||||
typedef compressible::turbulenceModel cmpTurbModel;
|
||||
typedef incompressible::turbulenceModel icoTurbModel;
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
tmp<volScalarField> nuEff;
|
||||
if (mesh.foundObject<cmpTurbModel>("turbulenceModel"))
|
||||
{
|
||||
const cmpTurbModel& model =
|
||||
mesh.lookupObject<cmpTurbModel>("turbulenceModel");
|
||||
|
||||
const volScalarField& rho =
|
||||
mesh.lookupObject<volScalarField>(rhoName_);
|
||||
|
||||
nuEff = model.muEff()/rho;
|
||||
}
|
||||
else if (mesh.foundObject<icoTurbModel>("turbulenceModel"))
|
||||
{
|
||||
const icoTurbModel& model =
|
||||
mesh.lookupObject<icoTurbModel>("turbulenceModel");
|
||||
|
||||
nuEff = model.nuEff();
|
||||
}
|
||||
else if (mesh.foundObject<dictionary>("transportProperties"))
|
||||
{
|
||||
const dictionary& model =
|
||||
mesh.lookupObject<dictionary>("transportProperties");
|
||||
|
||||
nuEff =
|
||||
tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"nuEff",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar(model.lookup("nu"))
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("void Foam::Peclet::write()")
|
||||
<< "Unable to determine the viscosity"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
surfaceScalarField& Peclet =
|
||||
const_cast<surfaceScalarField&>
|
||||
(
|
||||
mesh.lookupObject<surfaceScalarField>(type())
|
||||
);
|
||||
|
||||
Peclet =
|
||||
mag(phi)
|
||||
/(
|
||||
mesh.magSf()
|
||||
*mesh.surfaceInterpolation::deltaCoeffs()
|
||||
*fvc::interpolate(nuEff)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Peclet::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::Peclet::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::Peclet::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const surfaceScalarField& Peclet =
|
||||
obr_.lookupObject<surfaceScalarField>(type());
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << Peclet.name() << nl
|
||||
<< endl;
|
||||
|
||||
Peclet.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
156
src/postProcessing/functionObjects/utilities/Peclet/Peclet.H
Normal file
156
src/postProcessing/functionObjects/utilities/Peclet/Peclet.H
Normal file
@ -0,0 +1,156 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::Peclet
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates and outputs the Peclet number as a
|
||||
surfaceScalarField.
|
||||
|
||||
SourceFiles
|
||||
Peclet.C
|
||||
IOPeclet.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Peclet_H
|
||||
#define Peclet_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Peclet Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class Peclet
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of Peclet objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of flux field, default is "phi"
|
||||
word phiName_;
|
||||
|
||||
//- Name of density field (compressible cases only), default is "rho"
|
||||
word rhoName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
Peclet(const Peclet&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Peclet&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Peclet");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
Peclet
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Peclet();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of Peclet
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the Peclet data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the Peclet and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "PecletFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(PecletFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
PecletFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::PecletFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around Peclet to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
PecletFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PecletFunctionObject_H
|
||||
#define PecletFunctionObject_H
|
||||
|
||||
#include "Peclet.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<Peclet> PecletFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
49
src/postProcessing/functionObjects/utilities/Q/IOQ.H
Normal file
49
src/postProcessing/functionObjects/utilities/Q/IOQ.H
Normal file
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOQ
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for Q.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOQ_H
|
||||
#define IOQ_H
|
||||
|
||||
#include "Q.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<Q> IOQ;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
169
src/postProcessing/functionObjects/utilities/Q/Q.C
Normal file
169
src/postProcessing/functionObjects/utilities/Q/Q.C
Normal file
@ -0,0 +1,169 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "Q.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "fvcGrad.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(Q, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Q::Q
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
UName_("U")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"Q::Q"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* QPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless/sqr(dimTime), 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(QPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Q::~Q()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Q::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
UName_ = dict.lookupOrDefault<word>("UName", "U");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Q::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
const volVectorField& U =
|
||||
mesh.lookupObject<volVectorField>(UName_);
|
||||
|
||||
const volTensorField gradU(fvc::grad(U));
|
||||
|
||||
volScalarField& Q =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh.lookupObject<volScalarField>(type())
|
||||
);
|
||||
|
||||
Q = 0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Q::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::Q::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::Q::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const volScalarField& Q =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << Q.name() << nl
|
||||
<< endl;
|
||||
|
||||
Q.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
157
src/postProcessing/functionObjects/utilities/Q/Q.H
Normal file
157
src/postProcessing/functionObjects/utilities/Q/Q.H
Normal file
@ -0,0 +1,157 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::Q
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates and outputs the second invariant of the
|
||||
velocity gradient tensor [1/s^2].
|
||||
|
||||
\f[
|
||||
Q = 0.5(sqr(tr(\nabla U)) - tr(((\nabla U) \cdot (\nabla U))))
|
||||
\f]
|
||||
|
||||
SourceFiles
|
||||
Q.C
|
||||
IOQ.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Q_H
|
||||
#define Q_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Q Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class Q
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of Q objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of velocity field, default is "U"
|
||||
word UName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
Q(const Q&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const Q&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("Q");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
Q
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Q();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of Q
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the Q data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the Q and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "QFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(QFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
QFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::QFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around Q to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
QFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef QFunctionObject_H
|
||||
#define QFunctionObject_H
|
||||
|
||||
#include "Q.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<Q> QFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOblendingFactor
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for blendingFactor.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOblendingFactor_H
|
||||
#define IOblendingFactor_H
|
||||
|
||||
#include "blendingFactor.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<blendingFactor> IOblendingFactor;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "blendingFactor.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(blendingFactor, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::blendingFactor::blendingFactor
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
phiName_("unknown-phiName"),
|
||||
fieldName_("unknown-fieldName")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"blendingFactor::blendingFactor"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::blendingFactor::~blendingFactor()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::blendingFactor::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
dict.lookup("fieldName") >> fieldName_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::blendingFactor::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
calc<scalar>();
|
||||
calc<vector>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::blendingFactor::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
void Foam::blendingFactor::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::blendingFactor::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const word fieldName = "blendingFactor:" + fieldName_;
|
||||
|
||||
const volScalarField& blendingFactor =
|
||||
obr_.lookupObject<volScalarField>(fieldName);
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << blendingFactor.name() << nl
|
||||
<< endl;
|
||||
|
||||
blendingFactor.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,175 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::blendingFactor
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates and outputs the blendingFactor as used by
|
||||
the bended convection schemes. The output is a volume field (cells) whose
|
||||
value is calculated via the maximum blending factor for any cell face.
|
||||
|
||||
|
||||
SourceFiles
|
||||
blendingFactor.C
|
||||
IOblendingFactor.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef blendingFactor_H
|
||||
#define blendingFactor_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "OFstream.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class blendingFactor Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class blendingFactor
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of blendingFactor objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of flux field, default is "phi"
|
||||
word phiName_;
|
||||
|
||||
//- Field name
|
||||
word fieldName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
blendingFactor(const blendingFactor&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const blendingFactor&);
|
||||
|
||||
//- Return the blending factor field from the database
|
||||
template<class Type>
|
||||
volScalarField& factor
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
);
|
||||
|
||||
//- Calculate the blending factor
|
||||
template<class Type>
|
||||
void calc();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("blendingFactor");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
blendingFactor
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~blendingFactor();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of blendingFactor
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the blendingFactor data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the blendingFactor and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "blendingFactorTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "blendingFactorFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(blendingFactorFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
blendingFactorFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::blendingFactorFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around blendingFactor to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
blendingFactorFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef blendingFactorFunctionObject_H
|
||||
#define blendingFactorFunctionObject_H
|
||||
|
||||
#include "blendingFactor.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<blendingFactor>
|
||||
blendingFactorFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,119 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "gaussConvectionScheme.H"
|
||||
#include "blendedSchemeBase.H"
|
||||
#include "fvcCellReduce.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::volScalarField& Foam::blendingFactor::factor
|
||||
(
|
||||
const GeometricField<Type, fvPatchField, volMesh>& field
|
||||
)
|
||||
{
|
||||
const word fieldName = "blendingFactor:" + field.name();
|
||||
|
||||
if (!obr_.foundObject<volScalarField>(fieldName))
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* factorPtr =
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0),
|
||||
zeroGradientFvPatchScalarField::typeName
|
||||
);
|
||||
|
||||
obr_.store(factorPtr);
|
||||
}
|
||||
|
||||
return
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
obr_.lookupObject<volScalarField>(fieldName)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::blendingFactor::calc()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
|
||||
|
||||
if (!obr_.foundObject<fieldType>(fieldName_))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
const fieldType& field = mesh.lookupObject<fieldType>(fieldName_);
|
||||
|
||||
const word divScheme("div(" + phiName_ + ',' + fieldName_ + ')');
|
||||
ITstream& its = mesh.divScheme(divScheme);
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
tmp<fv::convectionScheme<Type> > cs =
|
||||
fv::convectionScheme<Type>::New(mesh, phi, its);
|
||||
|
||||
const fv::gaussConvectionScheme<Type>& gcs =
|
||||
refCast<const fv::gaussConvectionScheme<Type> >(cs());
|
||||
|
||||
const surfaceInterpolationScheme<Type>& interpScheme =
|
||||
gcs.interpScheme();
|
||||
|
||||
if (!isA<blendedSchemeBase<Type> >(interpScheme))
|
||||
{
|
||||
FatalErrorIn("void Foam::blendingFactor::execute()")
|
||||
<< interpScheme.typeName << " is not a blended scheme"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
// retrieve the face-based blending factor
|
||||
const blendedSchemeBase<Type>& blendedScheme =
|
||||
refCast<const blendedSchemeBase<Type> >(interpScheme);
|
||||
const surfaceScalarField factorf(blendedScheme.blendingFactor(field));
|
||||
|
||||
// convert into vol field whose values represent the local face maxima
|
||||
volScalarField& factor = this->factor(field);
|
||||
factor = fvc::cellReduce(factorf, maxEqOp<scalar>());
|
||||
factor.correctBoundaryConditions();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,303 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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 "codedFunctionObject.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "SHA1Digest.H"
|
||||
#include "dynamicCode.H"
|
||||
#include "dynamicCodeContext.H"
|
||||
#include "stringOps.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(codedFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
codedFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::codedFunctionObject::prepare
|
||||
(
|
||||
dynamicCode& dynCode,
|
||||
const dynamicCodeContext& context
|
||||
) const
|
||||
{
|
||||
// Set additional rewrite rules
|
||||
dynCode.setFilterVariable("typeName", redirectType_);
|
||||
dynCode.setFilterVariable("codeRead", codeRead_);
|
||||
dynCode.setFilterVariable("codeExecute", codeExecute_);
|
||||
dynCode.setFilterVariable("codeEnd", codeEnd_);
|
||||
dynCode.setFilterVariable("codeData", codeData_);
|
||||
dynCode.setFilterVariable("codeTimeSet", codeTimeSet_);
|
||||
//dynCode.setFilterVariable("codeWrite", codeWrite_);
|
||||
|
||||
// compile filtered C template
|
||||
dynCode.addCompileFile("functionObjectTemplate.C");
|
||||
dynCode.addCompileFile("FilterFunctionObjectTemplate.C");
|
||||
|
||||
// copy filtered H template
|
||||
dynCode.addCopyFile("FilterFunctionObjectTemplate.H");
|
||||
dynCode.addCopyFile("functionObjectTemplate.H");
|
||||
dynCode.addCopyFile("IOfunctionObjectTemplate.H");
|
||||
|
||||
// debugging: make BC verbose
|
||||
// dynCode.setFilterVariable("verbose", "true");
|
||||
// Info<<"compile " << redirectType_ << " sha1: "
|
||||
// << context.sha1() << endl;
|
||||
|
||||
// define Make/options
|
||||
dynCode.setMakeOptions
|
||||
(
|
||||
"EXE_INC = -g \\\n"
|
||||
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
||||
+ context.options()
|
||||
+ "\n\nLIB_LIBS = \\\n"
|
||||
+ " -lOpenFOAM \\\n"
|
||||
+ " -lfiniteVolume \\\n"
|
||||
+ context.libs()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::dlLibraryTable& Foam::codedFunctionObject::libs() const
|
||||
{
|
||||
return const_cast<Time&>(time_).libs();
|
||||
}
|
||||
|
||||
|
||||
Foam::string Foam::codedFunctionObject::description() const
|
||||
{
|
||||
return "functionObject " + name();
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFunctionObject::clearRedirect() const
|
||||
{
|
||||
redirectFunctionObjectPtr_.clear();
|
||||
}
|
||||
|
||||
|
||||
const Foam::dictionary& Foam::codedFunctionObject::codeDict() const
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::codedFunctionObject::codedFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& time,
|
||||
const dictionary& dict,
|
||||
bool readNow
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
codedBase(),
|
||||
time_(time),
|
||||
dict_(dict)
|
||||
{
|
||||
if (readNow)
|
||||
{
|
||||
read(dict_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::codedFunctionObject::~codedFunctionObject()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObject&
|
||||
Foam::codedFunctionObject::redirectFunctionObject() const
|
||||
{
|
||||
if (!redirectFunctionObjectPtr_.valid())
|
||||
{
|
||||
dictionary constructDict(dict_);
|
||||
constructDict.set("type", redirectType_);
|
||||
|
||||
redirectFunctionObjectPtr_ = functionObject::New
|
||||
(
|
||||
redirectType_,
|
||||
time_,
|
||||
constructDict
|
||||
);
|
||||
}
|
||||
return redirectFunctionObjectPtr_();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::start()
|
||||
{
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().start();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::execute(const bool forceWrite)
|
||||
{
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().execute(forceWrite);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::end()
|
||||
{
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().end();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::timeSet()
|
||||
{
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().timeSet();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("redirectType") >> redirectType_;
|
||||
|
||||
const entry* dataPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeData",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (dataPtr)
|
||||
{
|
||||
codeData_ = stringOps::trim(dataPtr->stream());
|
||||
stringOps::inplaceExpand(codeData_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeData_,
|
||||
dataPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* readPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeRead",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (readPtr)
|
||||
{
|
||||
codeRead_ = stringOps::trim(readPtr->stream());
|
||||
stringOps::inplaceExpand(codeRead_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeRead_,
|
||||
readPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* execPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeExecute",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (execPtr)
|
||||
{
|
||||
codeExecute_ = stringOps::trim(execPtr->stream());
|
||||
stringOps::inplaceExpand(codeExecute_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeExecute_,
|
||||
execPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* endPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeEnd",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (endPtr)
|
||||
{
|
||||
codeEnd_ = stringOps::trim(endPtr->stream());
|
||||
stringOps::inplaceExpand(codeEnd_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeEnd_,
|
||||
endPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
const entry* timeSetPtr = dict.lookupEntryPtr
|
||||
(
|
||||
"codeTimeSet",
|
||||
false,
|
||||
false
|
||||
);
|
||||
if (timeSetPtr)
|
||||
{
|
||||
codeTimeSet_ = stringOps::trim(timeSetPtr->stream());
|
||||
stringOps::inplaceExpand(codeTimeSet_, dict);
|
||||
dynamicCodeContext::addLineDirective
|
||||
(
|
||||
codeTimeSet_,
|
||||
timeSetPtr->startLineNumber(),
|
||||
dict.name()
|
||||
);
|
||||
}
|
||||
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().read(dict);
|
||||
}
|
||||
|
||||
|
||||
void Foam::codedFunctionObject::updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::codedFunctionObject::movePoints(const polyMesh&)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,207 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::codedFunctionObject
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object provides a general interface to enable dynamic code
|
||||
compilation.
|
||||
|
||||
The entries are
|
||||
code : c++; upon functionObject::write()
|
||||
codeInclude : include files
|
||||
codeOptions : include paths; inserted into EXE_INC in Make/options
|
||||
codeLibs : link line; inserted into LIB_LIBS in Make/options
|
||||
|
||||
codeExecute : c++;upon functionObject::execute();
|
||||
codeRead : c++; upon functionObject::read();
|
||||
codeEnd : c++; upon functionObject::end();
|
||||
codeData : c++; local member data (null constructed);
|
||||
codeTimeSet : c++; upon functionObject::timeSet();
|
||||
localCode : c++; local static functions
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
difference
|
||||
{
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
|
||||
type coded;
|
||||
// Name of on-the-fly generated functionObject
|
||||
redirectType writeMagU;
|
||||
code
|
||||
#{
|
||||
// Lookup U
|
||||
const volVectorField& U = mesh().lookupObject<volVectorField>("U");
|
||||
// Write
|
||||
mag(U).write();
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::OutputFilterFunctionObject
|
||||
Foam::codedBase
|
||||
|
||||
SourceFiles
|
||||
codedFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef codedFunctionObject_H
|
||||
#define codedFunctionObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "codedBase.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class codedFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class codedFunctionObject
|
||||
:
|
||||
public functionObject,
|
||||
public codedBase
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Reference to the time database
|
||||
const Time& time_;
|
||||
|
||||
//- Input dictionary
|
||||
dictionary dict_;
|
||||
|
||||
word redirectType_;
|
||||
|
||||
string codeData_;
|
||||
string codeRead_;
|
||||
string codeExecute_;
|
||||
string codeEnd_;
|
||||
string codeTimeSet_;
|
||||
|
||||
//- Underlying functionObject
|
||||
mutable autoPtr<functionObject> redirectFunctionObjectPtr_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- get the loaded dynamic libraries
|
||||
virtual dlLibraryTable& libs() const;
|
||||
|
||||
//- adapt the context for the current object
|
||||
virtual void prepare(dynamicCode &,const dynamicCodeContext&) const;
|
||||
|
||||
// Return a description (type + name) for the output
|
||||
virtual string description() const;
|
||||
|
||||
// Clear any redirected objects
|
||||
virtual void clearRedirect() const;
|
||||
|
||||
// Get the dictionary to initialize the codeContext
|
||||
virtual const dictionary& codeDict() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
codedFunctionObject(const codedFunctionObject&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const codedFunctionObject&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("coded");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
codedFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& time,
|
||||
const dictionary& dict,
|
||||
bool readNow=true // allow child-classes to avoid compilation
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~codedFunctionObject();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Dynamically compiled functionObject
|
||||
functionObject& redirectFunctionObject() const;
|
||||
|
||||
//- Called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- Called at each ++ or += of the time-loop. forceWrite overrides the
|
||||
// outputControl behaviour.
|
||||
virtual bool execute(const bool forceWrite);
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits.
|
||||
// By default it simply calls execute().
|
||||
virtual bool end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual bool timeSet();
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Update mesh
|
||||
virtual void updateMesh(const mapPolyMesh&);
|
||||
|
||||
//- Move points
|
||||
virtual void movePoints(const polyMesh&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 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/>.
|
||||
|
||||
\defgroup grpUtilitiesFunctionObjects Utility function objects
|
||||
@{
|
||||
\ingroup grpFunctionObjects
|
||||
This group contains utility-based function objects
|
||||
@}
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOdsmcFields
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for dsmcFields.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOdsmcFields_H
|
||||
#define IOdsmcFields_H
|
||||
|
||||
#include "dsmcFields.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<dsmcFields> IOdsmcFields;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,289 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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 "dsmcFields.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "dsmcCloud.H"
|
||||
|
||||
#include "constants.H"
|
||||
|
||||
using namespace Foam::constant;
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(dsmcFields, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::dsmcFields::dsmcFields
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"dsmcFields::dsmcFields"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::dsmcFields::~dsmcFields()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::dsmcFields::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::dsmcFields::execute()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::dsmcFields::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::dsmcFields::timeSet()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::dsmcFields::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
word rhoNMeanName = "rhoNMean";
|
||||
word rhoMMeanName = "rhoMMean";
|
||||
word momentumMeanName = "momentumMean";
|
||||
word linearKEMeanName = "linearKEMean";
|
||||
word internalEMeanName = "internalEMean";
|
||||
word iDofMeanName = "iDofMean";
|
||||
word fDMeanName = "fDMean";
|
||||
|
||||
const volScalarField& rhoNMean = obr_.lookupObject<volScalarField>
|
||||
(
|
||||
rhoNMeanName
|
||||
);
|
||||
|
||||
const volScalarField& rhoMMean = obr_.lookupObject<volScalarField>
|
||||
(
|
||||
rhoMMeanName
|
||||
);
|
||||
|
||||
const volVectorField& momentumMean = obr_.lookupObject<volVectorField>
|
||||
(
|
||||
momentumMeanName
|
||||
);
|
||||
|
||||
const volScalarField& linearKEMean = obr_.lookupObject<volScalarField>
|
||||
(
|
||||
linearKEMeanName
|
||||
);
|
||||
|
||||
const volScalarField& internalEMean = obr_.lookupObject<volScalarField>
|
||||
(
|
||||
internalEMeanName
|
||||
);
|
||||
|
||||
const volScalarField& iDofMean = obr_.lookupObject<volScalarField>
|
||||
(
|
||||
iDofMeanName
|
||||
);
|
||||
|
||||
const volVectorField& fDMean = obr_.lookupObject<volVectorField>
|
||||
(
|
||||
fDMeanName
|
||||
);
|
||||
|
||||
if (min(mag(rhoNMean)).value() > VSMALL)
|
||||
{
|
||||
Info<< "Calculating dsmcFields." << endl;
|
||||
|
||||
Info<< " Calculating UMean field." << endl;
|
||||
volVectorField UMean
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"UMean",
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
momentumMean/rhoMMean
|
||||
);
|
||||
|
||||
Info<< " Calculating translationalT field." << endl;
|
||||
volScalarField translationalT
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"translationalT",
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
|
||||
2.0/(3.0*physicoChemical::k.value()*rhoNMean)
|
||||
*(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
|
||||
);
|
||||
|
||||
Info<< " Calculating internalT field." << endl;
|
||||
volScalarField internalT
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"internalT",
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
(2.0/physicoChemical::k.value())*(internalEMean/iDofMean)
|
||||
);
|
||||
|
||||
Info<< " Calculating overallT field." << endl;
|
||||
volScalarField overallT
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"overallT",
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
2.0/(physicoChemical::k.value()*(3.0*rhoNMean + iDofMean))
|
||||
*(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
|
||||
);
|
||||
|
||||
Info<< " Calculating pressure field." << endl;
|
||||
volScalarField p
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"p",
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
physicoChemical::k.value()*rhoNMean*translationalT
|
||||
);
|
||||
|
||||
const fvMesh& mesh = fDMean.mesh();
|
||||
|
||||
forAll(mesh.boundaryMesh(), i)
|
||||
{
|
||||
const polyPatch& patch = mesh.boundaryMesh()[i];
|
||||
|
||||
if (isA<wallPolyPatch>(patch))
|
||||
{
|
||||
p.boundaryField()[i] =
|
||||
fDMean.boundaryField()[i]
|
||||
& (patch.faceAreas()/mag(patch.faceAreas()));
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " mag(UMean) max/min : "
|
||||
<< max(mag(UMean)).value() << " "
|
||||
<< min(mag(UMean)).value() << endl;
|
||||
|
||||
Info<< " translationalT max/min : "
|
||||
<< max(translationalT).value() << " "
|
||||
<< min(translationalT).value() << endl;
|
||||
|
||||
Info<< " internalT max/min : "
|
||||
<< max(internalT).value() << " "
|
||||
<< min(internalT).value() << endl;
|
||||
|
||||
Info<< " overallT max/min : "
|
||||
<< max(overallT).value() << " "
|
||||
<< min(overallT).value() << endl;
|
||||
|
||||
Info<< " p max/min : "
|
||||
<< max(p).value() << " "
|
||||
<< min(p).value() << endl;
|
||||
|
||||
UMean.write();
|
||||
|
||||
translationalT.write();
|
||||
|
||||
internalT.write();
|
||||
|
||||
overallT.write();
|
||||
|
||||
p.write();
|
||||
|
||||
Info<< "dsmcFields written." << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Small value (" << min(mag(rhoNMean))
|
||||
<< ") found in rhoNMean field. "
|
||||
<< "Not calculating dsmcFields to avoid division by zero."
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,150 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::dsmcFields
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Calculate intensive fields:
|
||||
- UMean
|
||||
- translationalT
|
||||
- internalT
|
||||
- overallT
|
||||
from averaged extensive fields from a DSMC calculation.
|
||||
|
||||
SourceFiles
|
||||
dsmcFields.C
|
||||
IOdsmcFields.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dsmcFields_H
|
||||
#define dsmcFields_H
|
||||
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class dsmcFields Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class dsmcFields
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of dsmcFields objects
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
dsmcFields(const dsmcFields&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const dsmcFields&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("dsmcFields");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
dsmcFields
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~dsmcFields();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of dsmcFields
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the dsmcFields data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the dsmcFields and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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 "dsmcFieldsFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(dsmcFieldsFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
dsmcFieldsFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::dsmcFieldsFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around dsmcFields to allow it to be created via
|
||||
the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
dsmcFieldsFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dsmcFieldsFunctionObject_H
|
||||
#define dsmcFieldsFunctionObject_H
|
||||
|
||||
#include "dsmcFields.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<dsmcFields>
|
||||
dsmcFieldsFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOpressureTools
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for pressureTools.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOpressureTools_H
|
||||
#define IOpressureTools_H
|
||||
|
||||
#include "pressureTools.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<pressureTools> IOpressureTools;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,352 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 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 "pressureTools.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(pressureTools, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::word Foam::pressureTools::pName() const
|
||||
{
|
||||
word fieldName = pName_;
|
||||
|
||||
if (calcTotal_)
|
||||
{
|
||||
fieldName = "total(" + fieldName + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldName = "static(" + fieldName + ")";
|
||||
}
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
fieldName = fieldName + "_coeff";
|
||||
}
|
||||
|
||||
return fieldName;
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionedScalar Foam::pressureTools::rhoScale
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
if (p.dimensions() == dimPressure)
|
||||
{
|
||||
return dimensionedScalar("1", dimless, 1.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return dimensionedScalar("rhoRef", dimDensity, rhoInf_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::pressureTools::rho
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
if (p.dimensions() == dimPressure)
|
||||
{
|
||||
return p.mesh().lookupObject<volScalarField>(rhoName_);
|
||||
}
|
||||
else
|
||||
{
|
||||
return
|
||||
tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"rho",
|
||||
p.mesh().time().timeName(),
|
||||
p.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
p.mesh(),
|
||||
dimensionedScalar("zero", dimDensity, rhoInf_)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensionedScalar Foam::pressureTools::pRef() const
|
||||
{
|
||||
dimensionedScalar value("pRef", dimPressure, 0.0);
|
||||
|
||||
if (calcTotal_)
|
||||
{
|
||||
value.value() += pRef_;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::pressureTools::pDyn
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
tmp<volScalarField> tpDyn
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pDyn",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("zero", dimPressure, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
if (calcTotal_)
|
||||
{
|
||||
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
|
||||
|
||||
tpDyn() == rho(p)*0.5*magSqr(U);
|
||||
}
|
||||
|
||||
return tpDyn;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::pressureTools::convertToCoeff
|
||||
(
|
||||
const volScalarField& p
|
||||
) const
|
||||
{
|
||||
tmp<volScalarField> tCoeff(p);
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
tCoeff() -= dimensionedScalar("pInf", dimPressure, pInf_);
|
||||
|
||||
const dimensionedScalar p0("p0", dimPressure, SMALL);
|
||||
const dimensionedVector U("U", dimVelocity, UInf_);
|
||||
const dimensionedScalar rho("rho", dimDensity, rhoInf_);
|
||||
|
||||
tCoeff() /= 0.5*rho*magSqr(U) + p0;
|
||||
}
|
||||
|
||||
return tCoeff;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pressureTools::pressureTools
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
pName_("p"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
calcTotal_(false),
|
||||
pRef_(0.0),
|
||||
calcCoeff_(false),
|
||||
pInf_(0.0),
|
||||
UInf_(vector::zero),
|
||||
rhoInf_(0.0)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"pressureTools::pressureTools"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
dimensionSet pDims(dimPressure);
|
||||
|
||||
if (calcCoeff_)
|
||||
{
|
||||
pDims /= dimPressure;
|
||||
}
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* pPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
pName(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", pDims, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(pPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::pressureTools::~pressureTools()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::pressureTools::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
dict.readIfPresent("pName", pName_);
|
||||
dict.readIfPresent("UName", UName_);
|
||||
dict.readIfPresent("rhoName", rhoName_);
|
||||
|
||||
if (rhoName_ == "rhoInf")
|
||||
{
|
||||
dict.lookup("rhoInf") >> rhoInf_;
|
||||
}
|
||||
|
||||
dict.lookup("calcTotal") >> calcTotal_;
|
||||
if (calcTotal_)
|
||||
{
|
||||
dict.lookup("pRef") >> pRef_;
|
||||
}
|
||||
|
||||
dict.lookup("calcCoeff") >> calcCoeff_;
|
||||
if (calcCoeff_)
|
||||
{
|
||||
dict.lookup("pInf") >> pInf_;
|
||||
dict.lookup("UInf") >> UInf_;
|
||||
dict.lookup("rhoInf") >> rhoInf_;
|
||||
|
||||
scalar zeroCheck = 0.5*rhoInf_*magSqr(UInf_) + pInf_;
|
||||
|
||||
if (mag(zeroCheck) < ROOTVSMALL)
|
||||
{
|
||||
WarningIn("void Foam::pressureTools::read(const dictionary&)")
|
||||
<< type() << " " << name_ << ": "
|
||||
<< "Coefficient calculation requested, but reference "
|
||||
<< "pressure level is zero. Please check the supplied "
|
||||
<< "values of pInf, UInf and rhoInf" << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::pressureTools::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
|
||||
|
||||
volScalarField& pResult =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
obr_.lookupObject<volScalarField>(pName())
|
||||
);
|
||||
|
||||
pResult == convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::pressureTools::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::pressureTools::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::pressureTools::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const volScalarField& pResult =
|
||||
obr_.lookupObject<volScalarField>(pName());
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << pResult.name() << nl
|
||||
<< endl;
|
||||
|
||||
pResult.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,268 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::pressureTools
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object includes tools to manipulate the pressure into
|
||||
different forms. These currently include:
|
||||
|
||||
- static pressure
|
||||
\f[
|
||||
p_s = \rho p_k
|
||||
\f]
|
||||
- total pressure
|
||||
\f[
|
||||
p_T = p_{ref} + p_s + 0.5 \rho |U|^2
|
||||
\f]
|
||||
- static pressure coefficient
|
||||
\f[
|
||||
Cp_s = \frac{p_s - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
|
||||
\f]
|
||||
- total pressure coefficient
|
||||
\f[
|
||||
Cp_T = \frac{p_T - p_{\inf}}{0.5 \rho_{\inf} |U_{\inf}|^2}
|
||||
\f]
|
||||
|
||||
where
|
||||
\vartable
|
||||
\rho | density [kg/m3]
|
||||
U | velocity [m/s]
|
||||
\rho_{\inf} | freestream density [kg/m3]
|
||||
p_{\inf} | freestream pressure [Pa]
|
||||
U_{\inf} | freestream velocity [m/s]
|
||||
p_k | kinematic pressure (p/rho)[m2/s2]
|
||||
p_s | pressure [Pa]
|
||||
p_T | total pressure [Pa]
|
||||
p_{ref} | reference pressure level [Pa]
|
||||
Cp_{s} | pressure coefficient
|
||||
Cp_{T} | total pressure coefficient
|
||||
\endvartable
|
||||
|
||||
The function object will operate on both kinematic (\f$ p_k \f$) and static
|
||||
pressure (\f$ p_s \f$) fields, and the result is written as a
|
||||
volScalarField.
|
||||
|
||||
The modes of operation are:
|
||||
\table
|
||||
Mode | calcTotal | calcCoeff
|
||||
static pressure | no | no
|
||||
total pressure | yes | no
|
||||
pressure coefficient | no | yes
|
||||
total pressure coefficient | yes | yes
|
||||
\endtable
|
||||
|
||||
Example of function object specification to calculate pressure coefficient:
|
||||
\verbatim
|
||||
pressureTools1
|
||||
{
|
||||
type pressureTools;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
calcTotal no;
|
||||
calcCoeff yes;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: pressureTools| yes |
|
||||
calcTotal | Calculate total coefficient | yes |
|
||||
pRef | Reference pressure for total pressure | no | 0.0
|
||||
calcCoeff | Calculate pressure coefficient | yes |
|
||||
pInf | Freestream pressure for coefficient calculation | no |
|
||||
UInf | Freestream velocity for coefficient calculation | no |
|
||||
rhoInf | Freestream density for coefficient calculation | no |
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
pressureTools.C
|
||||
IOpressureTools.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pressureTools_H
|
||||
#define pressureTools_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "dimensionedScalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class pressureTools Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class pressureTools
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of pressureTools objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of pressure field, default is "p"
|
||||
word pName_;
|
||||
|
||||
//- Name of velocity field, default is "U"
|
||||
word UName_;
|
||||
|
||||
//- Name of density field, default is "rho"
|
||||
word rhoName_;
|
||||
|
||||
|
||||
// Total pressure calculation
|
||||
|
||||
//- Flag to calculate total pressure
|
||||
bool calcTotal_;
|
||||
|
||||
//- Reference pressure level
|
||||
scalar pRef_;
|
||||
|
||||
|
||||
// Pressure coefficient calculation
|
||||
|
||||
//- Flag to calculate pressure coefficient
|
||||
bool calcCoeff_;
|
||||
|
||||
//- Freestream pressure
|
||||
scalar pInf_;
|
||||
|
||||
//- Freestream velocity
|
||||
vector UInf_;
|
||||
|
||||
//- Freestream density
|
||||
scalar rhoInf_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return the name of the derived pressure field
|
||||
word pName() const;
|
||||
|
||||
//- Return the density scaling if supplied with kinematic pressure
|
||||
dimensionedScalar rhoScale(const volScalarField& p) const;
|
||||
|
||||
//- Return the density field
|
||||
tmp<volScalarField> rho(const volScalarField& p) const;
|
||||
|
||||
//- Return the reference pressure
|
||||
dimensionedScalar pRef() const;
|
||||
|
||||
//- Calculate and return the dynamic pressure
|
||||
tmp<volScalarField> pDyn(const volScalarField& p) const;
|
||||
|
||||
//- Convert to coeff by applying the freestream dynamic pressure scaling
|
||||
tmp<volScalarField> convertToCoeff(const volScalarField& p) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
pressureTools(const pressureTools&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const pressureTools&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("pressureTools");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
pressureTools
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~pressureTools();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of pressureTools
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the pressureTools data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the pressureTools and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "pressureToolsFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(pressureToolsFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
pressureToolsFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::pressureToolsFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around pressureTools to allow it to be created via
|
||||
the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
pressureToolsFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef pressureToolsFunctionObject_H
|
||||
#define pressureToolsFunctionObject_H
|
||||
|
||||
#include "pressureTools.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<pressureTools>
|
||||
pressureToolsFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOscalarTransport
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for scalarTransport.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOscalarTransport_H
|
||||
#define IOscalarTransport_H
|
||||
|
||||
#include "scalarTransport.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<scalarTransport> IOscalarTransport;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,323 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 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 "scalarTransport.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "fvScalarMatrix.H"
|
||||
#include "fvmDdt.H"
|
||||
#include "fvmDiv.H"
|
||||
#include "fvcDiv.H"
|
||||
#include "fvmLaplacian.H"
|
||||
#include "fvmSup.H"
|
||||
#include "incompressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "compressible/turbulenceModel/turbulenceModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(scalarTransport, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::wordList Foam::scalarTransport::boundaryTypes() const
|
||||
{
|
||||
const volVectorField& U = mesh_.lookupObject<volVectorField>(UName_);
|
||||
|
||||
wordList bTypes(U.boundaryField().size());
|
||||
|
||||
forAll(bTypes, patchI)
|
||||
{
|
||||
const fvPatchField<vector>& pf = U.boundaryField()[patchI];
|
||||
if (isA<fixedValueFvPatchVectorField>(pf))
|
||||
{
|
||||
bTypes[patchI] = fixedValueFvPatchScalarField::typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
bTypes[patchI] = zeroGradientFvPatchScalarField::typeName;
|
||||
}
|
||||
}
|
||||
|
||||
return bTypes;
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::volScalarField> Foam::scalarTransport::DT
|
||||
(
|
||||
const surfaceScalarField& phi
|
||||
) const
|
||||
{
|
||||
typedef incompressible::turbulenceModel icoModel;
|
||||
typedef compressible::turbulenceModel cmpModel;
|
||||
|
||||
if (userDT_)
|
||||
{
|
||||
return tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"DT",
|
||||
mesh_.time().timeName(),
|
||||
mesh_.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("DT", phi.dimensions()/dimLength, DT_)
|
||||
)
|
||||
);
|
||||
}
|
||||
else if (mesh_.foundObject<icoModel>("turbulenceModel"))
|
||||
{
|
||||
const icoModel& model = mesh_.lookupObject<icoModel>("turbulenceModel");
|
||||
|
||||
return model.nuEff();
|
||||
}
|
||||
else if (mesh_.foundObject<cmpModel>("turbulenceModel"))
|
||||
{
|
||||
const cmpModel& model = mesh_.lookupObject<cmpModel>("turbulenceModel");
|
||||
|
||||
return model.muEff();
|
||||
}
|
||||
else
|
||||
{
|
||||
return tmp<volScalarField>
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"DT",
|
||||
mesh_.time().timeName(),
|
||||
mesh_.time(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("DT", phi.dimensions()/dimLength, 0.0)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalarTransport::scalarTransport
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
mesh_(refCast<const fvMesh>(obr)),
|
||||
active_(true),
|
||||
phiName_("phi"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
DT_(0.0),
|
||||
userDT_(false),
|
||||
resetOnStartUp_(false),
|
||||
nCorr_(0),
|
||||
autoSchemes_(false),
|
||||
fvOptions_(mesh_),
|
||||
T_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
name,
|
||||
mesh_.time().timeName(),
|
||||
mesh_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
mesh_,
|
||||
dimensionedScalar("zero", dimless, 0.0),
|
||||
boundaryTypes()
|
||||
)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
if (resetOnStartUp_)
|
||||
{
|
||||
T_ == dimensionedScalar("zero", dimless, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalarTransport::~scalarTransport()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::scalarTransport::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
Info<< type() << ":" << nl;
|
||||
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
UName_ = dict.lookupOrDefault<word>("UName", "U");
|
||||
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
|
||||
|
||||
userDT_ = false;
|
||||
if (dict.readIfPresent("DT", DT_))
|
||||
{
|
||||
userDT_ = true;
|
||||
}
|
||||
|
||||
dict.lookup("resetOnStartUp") >> resetOnStartUp_;
|
||||
|
||||
dict.readIfPresent("nCorr", nCorr_);
|
||||
|
||||
dict.lookup("autoSchemes") >> autoSchemes_;
|
||||
|
||||
fvOptions_.reset(dict.subDict("fvOptions"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::scalarTransport::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
Info<< type() << " output:" << endl;
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
mesh_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
// calculate the diffusivity
|
||||
volScalarField DT(this->DT(phi));
|
||||
|
||||
// set schemes
|
||||
word schemeVar = T_.name();
|
||||
if (autoSchemes_)
|
||||
{
|
||||
schemeVar = UName_;
|
||||
}
|
||||
|
||||
word divScheme("div(phi," + schemeVar + ")");
|
||||
word laplacianScheme("laplacian(" + DT.name() + "," + schemeVar + ")");
|
||||
|
||||
// set under-relaxation coeff
|
||||
scalar relaxCoeff = 0.0;
|
||||
if (mesh_.relaxEquation(schemeVar))
|
||||
{
|
||||
relaxCoeff = mesh_.equationRelaxationFactor(schemeVar);
|
||||
}
|
||||
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
const volScalarField& rho =
|
||||
mesh_.lookupObject<volScalarField>(rhoName_);
|
||||
|
||||
// solve
|
||||
for (label i = 0; i <= nCorr_; i++)
|
||||
{
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::ddt(rho, T_)
|
||||
+ fvm::div(phi, T_, divScheme)
|
||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
||||
==
|
||||
fvOptions_(rho, T_)
|
||||
);
|
||||
|
||||
TEqn.relax(relaxCoeff);
|
||||
|
||||
fvOptions_.constrain(TEqn);
|
||||
|
||||
TEqn.solve(mesh_.solverDict(schemeVar));
|
||||
}
|
||||
}
|
||||
else if (phi.dimensions() == dimVolume/dimTime)
|
||||
{
|
||||
// solve
|
||||
for (label i = 0; i <= nCorr_; i++)
|
||||
{
|
||||
fvScalarMatrix TEqn
|
||||
(
|
||||
fvm::ddt(T_)
|
||||
+ fvm::div(phi, T_, divScheme)
|
||||
- fvm::laplacian(DT, T_, laplacianScheme)
|
||||
==
|
||||
fvOptions_(T_)
|
||||
);
|
||||
|
||||
TEqn.relax(relaxCoeff);
|
||||
|
||||
fvOptions_.constrain(TEqn);
|
||||
|
||||
TEqn.solve(mesh_.solverDict(schemeVar));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("void Foam::scalarTransport::execute()")
|
||||
<< "Incompatible dimensions for phi: " << phi.dimensions() << nl
|
||||
<< "Dimensions should be " << dimMass/dimTime << " or "
|
||||
<< dimVolume/dimTime << endl;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::scalarTransport::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::scalarTransport::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::scalarTransport::write()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,194 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::scalarTransport
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object evolves a passive scalar transport equation. The
|
||||
field in ininitially zero, to which sources are added. The field name
|
||||
is assigned the name of the function object. Boundary conditions are
|
||||
automatically applied, based on the velocity boundary conditions.
|
||||
|
||||
- the field can be zeroed on start-up using the resetOnStartUp flag
|
||||
- to employ the same numerical schemes as the flow velocity, use the
|
||||
autoSchemes flag
|
||||
- the diffusivity can be set manually using the DT entry, or retrieved
|
||||
from the turbulence model (if applicable)
|
||||
|
||||
SourceFiles
|
||||
scalarTransport.C
|
||||
IOscalarTransport.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef scalarTransport_H
|
||||
#define scalarTransport_H
|
||||
|
||||
#include "volFields.H"
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "fvMatricesFwd.H"
|
||||
#include "fvOptionList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class scalarTransport Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class scalarTransport
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of scalarTransport objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the mesh database
|
||||
const fvMesh& mesh_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of flux field (optional)
|
||||
word phiName_;
|
||||
|
||||
//- Name of velocity field (optional)
|
||||
word UName_;
|
||||
|
||||
//- Name of density field (optional)
|
||||
word rhoName_;
|
||||
|
||||
//- Diffusion coefficient (optional)
|
||||
scalar DT_;
|
||||
|
||||
//- Flag to indicate whether user DT_ is used
|
||||
bool userDT_;
|
||||
|
||||
//- Flag to reset scalar field on start-up
|
||||
bool resetOnStartUp_;
|
||||
|
||||
//- Number of corrector iterations (optional)
|
||||
label nCorr_;
|
||||
|
||||
//- Flag to employ schemes for velocity for scalar transport
|
||||
bool autoSchemes_;
|
||||
|
||||
//- Run-time selectable finite volume options, e.g. sources, constraints
|
||||
fv::optionList fvOptions_;
|
||||
|
||||
//- The scalar field
|
||||
volScalarField T_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Return the boundary types for the scalar field
|
||||
wordList boundaryTypes() const;
|
||||
|
||||
//- Return the diffusivity field
|
||||
tmp<volScalarField> DT(const surfaceScalarField& phi) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
scalarTransport(const scalarTransport&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const scalarTransport&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("scalarTransport");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
scalarTransport
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~scalarTransport();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of scalarTransport
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the scalarTransport data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the scalarTransport and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "scalarTransportFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(scalarTransportFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
scalarTransportFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::scalarTransportFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around scalarTransport to allow it to be
|
||||
created via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
scalarTransportFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef scalarTransportFunctionObject_H
|
||||
#define scalarTransportFunctionObject_H
|
||||
|
||||
#include "scalarTransport.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<scalarTransport>
|
||||
scalarTransportFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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 "setTimeStepFunctionObject.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(setTimeStepFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
setTimeStepFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::setTimeStepFunctionObject::setTimeStepFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
time_(runTime),
|
||||
enabled_(true)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::setTimeStepFunctionObject::on()
|
||||
{
|
||||
enabled_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::setTimeStepFunctionObject::off()
|
||||
{
|
||||
enabled_ = false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::setTimeStepFunctionObject::start()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::setTimeStepFunctionObject::execute(const bool forceWrite)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::setTimeStepFunctionObject::end()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::setTimeStepFunctionObject::timeSet()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::setTimeStepFunctionObject::adjustTimeStep()
|
||||
{
|
||||
if (enabled())
|
||||
{
|
||||
// Wanted timestep
|
||||
scalar newDeltaT = timeStepPtr_().value(time_.timeOutputValue());
|
||||
|
||||
const_cast<Time&>(time()).setDeltaT(newDeltaT, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::setTimeStepFunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
enabled_ = dict.lookupOrDefault("enabled", true);
|
||||
|
||||
if (enabled_)
|
||||
{
|
||||
timeStepPtr_ = DataEntry<scalar>::New("deltaT", dict);
|
||||
|
||||
// Check that time has adjustTimeStep
|
||||
const dictionary& controlDict = time_.controlDict();
|
||||
|
||||
Switch adjust;
|
||||
if
|
||||
(
|
||||
!controlDict.readIfPresent<Switch>("adjustTimeStep", adjust)
|
||||
|| !adjust
|
||||
)
|
||||
{
|
||||
FatalIOErrorIn("setTimeStep::read(const dictionary&)", dict)
|
||||
<< "Need to have 'adjustTimeStep' true to enable external"
|
||||
<< " timestep control" << exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::setTimeStepFunctionObject::updateMesh(const mapPolyMesh& mpm)
|
||||
{}
|
||||
|
||||
|
||||
void Foam::setTimeStepFunctionObject::movePoints(const polyMesh& mesh)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,159 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::setTimeStepFunctionObject
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Overrides the timeStep. Can only be used with
|
||||
solvers with adjustTimeStep control (e.g. pimpleFoam). Makes no attempt
|
||||
to cooperate with other timeStep 'controllers' (maxCo, other
|
||||
functionObjects). Supports 'enabled' flag but none of othe other ones
|
||||
'timeStart', 'timeEnd', 'outputControl' etc.
|
||||
|
||||
SourceFiles
|
||||
setTimeStepFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef setTimeStepFunctionObject_H
|
||||
#define setTimeStepFunctionObject_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "dictionary.H"
|
||||
#include "DataEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class setTimeStepFunctionObject Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class setTimeStepFunctionObject
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to the time database
|
||||
const Time& time_;
|
||||
|
||||
|
||||
// Optional user inputs
|
||||
|
||||
//- Switch for the execution - defaults to 'yes/on'
|
||||
bool enabled_;
|
||||
|
||||
//- Time step
|
||||
autoPtr<DataEntry<scalar> > timeStepPtr_;
|
||||
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
setTimeStepFunctionObject(const setTimeStepFunctionObject&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const setTimeStepFunctionObject&);
|
||||
|
||||
|
||||
public:
|
||||
//- Runtime type information
|
||||
TypeName("setTimeStep");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
setTimeStepFunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return time database
|
||||
virtual const Time& time() const
|
||||
{
|
||||
return time_;
|
||||
}
|
||||
|
||||
//- Return the enabled flag
|
||||
virtual bool enabled() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
|
||||
// Function object control
|
||||
|
||||
//- Switch the function object on
|
||||
virtual void on();
|
||||
|
||||
//- Switch the function object off
|
||||
virtual void off();
|
||||
|
||||
|
||||
//- Called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- Called at each ++ or += of the time-loop
|
||||
virtual bool execute(const bool forceWrite);
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits
|
||||
virtual bool end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual bool timeSet();
|
||||
|
||||
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
|
||||
virtual bool adjustTimeStep();
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh& mpm);
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh& mesh);
|
||||
|
||||
};
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOtimeActivatedFileUpdate
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for timeActivatedFileUpdate.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOtimeActivatedFileUpdate_H
|
||||
#define IOtimeActivatedFileUpdate_H
|
||||
|
||||
#include "timeActivatedFileUpdate.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<timeActivatedFileUpdate> IOtimeActivatedFileUpdate;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,67 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object controlDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
application icoFoam;
|
||||
|
||||
startFrom startTime;
|
||||
|
||||
startTime 0;
|
||||
|
||||
stopAt endTime;
|
||||
|
||||
endTime 0.5;
|
||||
|
||||
deltaT 0.005;
|
||||
|
||||
writeControl timeStep;
|
||||
|
||||
writeInterval 20;
|
||||
|
||||
purgeWrite 0;
|
||||
|
||||
writeFormat ascii;
|
||||
|
||||
writePrecision 6;
|
||||
|
||||
writeCompression off;
|
||||
|
||||
timeFormat general;
|
||||
|
||||
timePrecision 6;
|
||||
|
||||
runTimeModifiable true;
|
||||
|
||||
functions
|
||||
{
|
||||
fileUpdate1
|
||||
{
|
||||
type timeActivatedFileUpdate;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
outputControl timeStep;
|
||||
outputInterval 1;
|
||||
fileToUpdate "$FOAM_CASE/system/fvSolution";
|
||||
|
||||
timeVsFile
|
||||
(
|
||||
( -1 "$FOAM_CASE/system/fvSolution.0" )
|
||||
( 0.10 "$FOAM_CASE/system/fvSolution.10" )
|
||||
( 0.20 "$FOAM_CASE/system/fvSolution.20" )
|
||||
( 0.35 "$FOAM_CASE/system/fvSolution.35" )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,154 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 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 "timeActivatedFileUpdate.H"
|
||||
#include "objectRegistry.H"
|
||||
#include "Time.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(timeActivatedFileUpdate, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::timeActivatedFileUpdate::updateFile()
|
||||
{
|
||||
label i = lastIndex_;
|
||||
while
|
||||
(
|
||||
i < timeVsFile_.size()-1
|
||||
&& timeVsFile_[i+1].first() < obr_.time().value()
|
||||
)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > lastIndex_)
|
||||
{
|
||||
Info<< nl << type() << ": copying file" << nl << timeVsFile_[i].second()
|
||||
<< nl << "to:" << nl << fileToUpdate_ << nl << endl;
|
||||
|
||||
cp(timeVsFile_[i].second(), fileToUpdate_);
|
||||
lastIndex_ = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::timeActivatedFileUpdate::timeActivatedFileUpdate
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
fileToUpdate_(dict.lookup("fileToUpdate")),
|
||||
timeVsFile_(),
|
||||
lastIndex_(-1)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::timeActivatedFileUpdate::~timeActivatedFileUpdate()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::timeActivatedFileUpdate::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
dict.lookup("fileToUpdate") >> fileToUpdate_;
|
||||
dict.lookup("timeVsFile") >> timeVsFile_;
|
||||
|
||||
lastIndex_ = -1;
|
||||
fileToUpdate_.expand();
|
||||
|
||||
Info<< type() << ": time vs file list:" << nl;
|
||||
forAll(timeVsFile_, i)
|
||||
{
|
||||
timeVsFile_[i].second() = timeVsFile_[i].second().expand();
|
||||
if (!isFile(timeVsFile_[i].second()))
|
||||
{
|
||||
FatalErrorIn("timeActivatedFileUpdate::read(const dictionary&)")
|
||||
<< "File: " << timeVsFile_[i].second() << " not found"
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< " " << timeVsFile_[i].first() << tab
|
||||
<< timeVsFile_[i].second() << endl;
|
||||
}
|
||||
Info<< endl;
|
||||
|
||||
updateFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeActivatedFileUpdate::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
updateFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeActivatedFileUpdate::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeActivatedFileUpdate::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeActivatedFileUpdate::write()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,179 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 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/>.
|
||||
|
||||
Class
|
||||
Foam::timeActivatedFileUpdate
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Performs a file copy/replacement once a specified time has been reached.
|
||||
|
||||
Example usage to update the fvSolution dictionary at various times
|
||||
throughout the calculation:
|
||||
|
||||
\verbatim
|
||||
fileUpdate1
|
||||
{
|
||||
type timeActivatedFileUpdate;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
outputControl timeStep;
|
||||
outputInterval 1;
|
||||
fileToUpdate "$FOAM_CASE/system/fvSolution";
|
||||
timeVsFile
|
||||
(
|
||||
(-1 "$FOAM_CASE/system/fvSolution.0")
|
||||
(0.10 "$FOAM_CASE/system/fvSolution.10")
|
||||
(0.20 "$FOAM_CASE/system/fvSolution.20")
|
||||
(0.35 "$FOAM_CASE/system/fvSolution.35")
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
timeActivatedFileUpdate.C
|
||||
IOtimeActivatedFileUpdate.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeActivatedFileUpdate_H
|
||||
#define timeActivatedFileUpdate_H
|
||||
|
||||
#include "Tuple2.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class timeActivatedFileUpdate Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class timeActivatedFileUpdate
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of timeActivatedFileUpdate objects
|
||||
word name_;
|
||||
|
||||
//- Owner database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of file to update
|
||||
fileName fileToUpdate_;
|
||||
|
||||
//- List of times vs filenames
|
||||
List<Tuple2<scalar, fileName> > timeVsFile_;
|
||||
|
||||
//- Index of last file copied
|
||||
label lastIndex_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update file
|
||||
void updateFile();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
timeActivatedFileUpdate(const timeActivatedFileUpdate&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const timeActivatedFileUpdate&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("timeActivatedFileUpdate");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
timeActivatedFileUpdate
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~timeActivatedFileUpdate();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of timeActivatedFileUpdate
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the timeActivatedFileUpdate data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the timeActivatedFileUpdate and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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 "timeActivatedFileUpdateFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug
|
||||
(
|
||||
timeActivatedFileUpdateFunctionObject,
|
||||
0
|
||||
);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
timeActivatedFileUpdateFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::timeActivatedFileUpdateFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around timeActivatedFileUpdate to allow it to be
|
||||
created via the functions list within controlDict.
|
||||
|
||||
SourceFiles
|
||||
timeActivatedFileUpdateFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeActivatedFileUpdateFunctionObject_H
|
||||
#define timeActivatedFileUpdateFunctionObject_H
|
||||
|
||||
#include "timeActivatedFileUpdate.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<timeActivatedFileUpdate>
|
||||
timeActivatedFileUpdateFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOturbulenceFields
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for turbulenceFields.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOturbulenceFields_H
|
||||
#define IOturbulenceFields_H
|
||||
|
||||
#include "turbulenceFields.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<turbulenceFields> IOturbulenceFields;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,34 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object postProcessingDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
functions
|
||||
{
|
||||
turbulenceFields1
|
||||
{
|
||||
type turbulenceFields;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
enabled true;
|
||||
outputControl timeStep;
|
||||
outputInterval 1;
|
||||
|
||||
fields
|
||||
(
|
||||
R
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,277 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "turbulenceFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "compressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "incompressible/turbulenceModel/turbulenceModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(turbulenceFields, 0);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<turbulenceFields::compressibleField, 6>::names[] =
|
||||
{
|
||||
"R",
|
||||
"devRhoReff",
|
||||
"mut",
|
||||
"muEff",
|
||||
"alphat",
|
||||
"alphaEff"
|
||||
};
|
||||
const NamedEnum<turbulenceFields::compressibleField, 6>
|
||||
turbulenceFields::compressibleFieldNames_;
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<turbulenceFields::incompressibleField, 4>::names[] =
|
||||
{
|
||||
"R",
|
||||
"devReff",
|
||||
"nut",
|
||||
"nuEff"
|
||||
};
|
||||
const NamedEnum<turbulenceFields::incompressibleField, 4>
|
||||
turbulenceFields::incompressibleFieldNames_;
|
||||
|
||||
const word turbulenceFields::modelName = "turbulenceModel";
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::turbulenceFields::compressible()
|
||||
{
|
||||
if (obr_.foundObject<compressible::turbulenceModel>(modelName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (obr_.foundObject<incompressible::turbulenceModel>(modelName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("Foam::word& Foam::turbulenceFields::compressible() const")
|
||||
<< "Turbulence model not found in database, deactivating";
|
||||
active_ = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::turbulenceFields::turbulenceFields
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
fieldSet_()
|
||||
{
|
||||
// Check if the available mesh is an fvMesh otherise deactivate
|
||||
if (isA<fvMesh>(obr_))
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"turbulenceFields::turbulenceFields"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::turbulenceFields::~turbulenceFields()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::turbulenceFields::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
fieldSet_.insert(wordList(dict.lookup("fields")));
|
||||
|
||||
Info<< type() << " " << name_ << ": ";
|
||||
if (fieldSet_.size())
|
||||
{
|
||||
Info<< "storing fields:" << nl;
|
||||
forAllConstIter(wordHashSet, fieldSet_, iter)
|
||||
{
|
||||
Info<< " " << modelName << ':' << iter.key() << nl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "no fields requested to be stored" << nl << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::turbulenceFields::execute()
|
||||
{
|
||||
bool comp = compressible();
|
||||
|
||||
if (!active_)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (comp)
|
||||
{
|
||||
const compressible::turbulenceModel& model =
|
||||
obr_.lookupObject<compressible::turbulenceModel>(modelName);
|
||||
|
||||
forAllConstIter(wordHashSet, fieldSet_, iter)
|
||||
{
|
||||
const word& f = iter.key();
|
||||
switch (compressibleFieldNames_[f])
|
||||
{
|
||||
case cfR:
|
||||
{
|
||||
processField<symmTensor>(f, model.R());
|
||||
break;
|
||||
}
|
||||
case cfDevRhoReff:
|
||||
{
|
||||
processField<symmTensor>(f, model.devRhoReff());
|
||||
break;
|
||||
}
|
||||
case cfMut:
|
||||
{
|
||||
processField<scalar>(f, model.mut());
|
||||
break;
|
||||
}
|
||||
case cfMuEff:
|
||||
{
|
||||
processField<scalar>(f, model.muEff());
|
||||
break;
|
||||
}
|
||||
case cfAlphat:
|
||||
{
|
||||
processField<scalar>(f, model.alphat());
|
||||
break;
|
||||
}
|
||||
case cfAlphaEff:
|
||||
{
|
||||
processField<scalar>(f, model.alphaEff());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("void Foam::turbulenceFields::execute()")
|
||||
<< "Invalid field selection" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const incompressible::turbulenceModel& model =
|
||||
obr_.lookupObject<incompressible::turbulenceModel>(modelName);
|
||||
|
||||
forAllConstIter(wordHashSet, fieldSet_, iter)
|
||||
{
|
||||
const word& f = iter.key();
|
||||
switch (incompressibleFieldNames_[f])
|
||||
{
|
||||
case ifR:
|
||||
{
|
||||
processField<symmTensor>(f, model.R());
|
||||
break;
|
||||
}
|
||||
case ifDevReff:
|
||||
{
|
||||
processField<symmTensor>(f, model.devReff());
|
||||
break;
|
||||
}
|
||||
case ifNut:
|
||||
{
|
||||
processField<scalar>(f, model.nut());
|
||||
break;
|
||||
}
|
||||
case ifNuEff:
|
||||
{
|
||||
processField<scalar>(f, model.nuEff());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
FatalErrorIn("void Foam::turbulenceFields::execute()")
|
||||
<< "Invalid field selection" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::turbulenceFields::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::turbulenceFields::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::turbulenceFields::write()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,239 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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/>.
|
||||
|
||||
Class
|
||||
Foam::turbulenceFields
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object stores turbulence fields on the mesh database for
|
||||
further manipulation.
|
||||
|
||||
Fields are stored as copies of the original, with the prefix
|
||||
"tubulenceModel:", e.g.
|
||||
|
||||
turbulenceModel:R
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
turbulenceFields1
|
||||
{
|
||||
type turbulenceFields;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
fields
|
||||
(
|
||||
R
|
||||
devRhoReff
|
||||
);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: processorField | yes |
|
||||
fields | fields to store (see below) | yes |
|
||||
\endtable
|
||||
|
||||
Where \c fields can include:
|
||||
\plaintable
|
||||
R | Stress tensor
|
||||
devRhoReff |
|
||||
mut | turbulence viscosity (compressible)
|
||||
muEff | effective turbulence viscosity (compressible)
|
||||
alphat | turbulence thermal diffusivity (compressible)
|
||||
alphaEff | effective turbulence thermal diffusivity (compressible)
|
||||
devReff |
|
||||
nut | turbulence viscosity (incompressible)
|
||||
nuEff | effective turbulence viscosity (incompressible)
|
||||
\endplaintable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::OutputFilterFunctionObject
|
||||
|
||||
SourceFiles
|
||||
turbulenceFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef turbulenceFields_H
|
||||
#define turbulenceFields_H
|
||||
|
||||
#include "HashSet.H"
|
||||
#include "IOobject.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class turbulenceFields Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class turbulenceFields
|
||||
{
|
||||
public:
|
||||
|
||||
enum compressibleField
|
||||
{
|
||||
cfR,
|
||||
cfDevRhoReff,
|
||||
cfMut,
|
||||
cfMuEff,
|
||||
cfAlphat,
|
||||
cfAlphaEff
|
||||
};
|
||||
static const NamedEnum<compressibleField, 6> compressibleFieldNames_;
|
||||
|
||||
enum incompressibleField
|
||||
{
|
||||
ifR,
|
||||
ifDevReff,
|
||||
ifNut,
|
||||
ifNuEff
|
||||
};
|
||||
static const NamedEnum<incompressibleField, 4> incompressibleFieldNames_;
|
||||
|
||||
static const word modelName;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of turbulenceFields object
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Fields to load
|
||||
wordHashSet fieldSet_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
turbulenceFields(const turbulenceFields&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const turbulenceFields&);
|
||||
|
||||
//- Return true if compressible turbulence model is identified
|
||||
bool compressible();
|
||||
|
||||
//- Process the turbulence field
|
||||
template<class Type>
|
||||
void processField
|
||||
(
|
||||
const word& fieldName,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("turbulenceFields");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
turbulenceFields
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~turbulenceFields();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the turbulenceFields object
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the field min/max data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "turbulenceFieldsTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 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 "turbulenceFieldsFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(turbulenceFieldsFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
turbulenceFieldsFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::turbulenceFieldsFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around turbulenceFields to allow them to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
turbulenceFieldsFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef turbulenceFieldsFunctionObject_H
|
||||
#define turbulenceFieldsFunctionObject_H
|
||||
|
||||
#include "turbulenceFields.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<turbulenceFields>
|
||||
turbulenceFieldsFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,81 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 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 "volFields.H"
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::turbulenceFields::processField
|
||||
(
|
||||
const word& fieldName,
|
||||
const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvalue
|
||||
)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
|
||||
|
||||
const word scopedName = modelName + ':' + fieldName;
|
||||
|
||||
if (obr_.foundObject<FieldType>(scopedName))
|
||||
{
|
||||
FieldType& fld =
|
||||
const_cast<FieldType&>(obr_.lookupObject<FieldType>(scopedName));
|
||||
fld == tvalue();
|
||||
}
|
||||
else if (obr_.found(scopedName))
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"void Foam::turbulenceFields::processField"
|
||||
"("
|
||||
"const word&, "
|
||||
"const tmp<GeometricField<Type, fvPatchField, volMesh> >&"
|
||||
")"
|
||||
) << "Cannot store turbulence field " << scopedName
|
||||
<< " since an object with that name already exists"
|
||||
<< nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
obr_.store
|
||||
(
|
||||
new FieldType
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
scopedName,
|
||||
obr_.time().timeName(),
|
||||
obr_,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
tvalue
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOvorticity
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for vorticity.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOvorticity_H
|
||||
#define IOvorticity_H
|
||||
|
||||
#include "vorticity.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<vorticity> IOvorticity;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,169 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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 "vorticity.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "fvcCurl.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(vorticity, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vorticity::vorticity
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
UName_("U"),
|
||||
outputName_(typeName)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"vorticity::vorticity"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField* vorticityPtr
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
outputName_,
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector("0", dimless/dimTime, vector::zero)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(vorticityPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::vorticity::~vorticity()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::vorticity::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
UName_ = dict.lookupOrDefault<word>("UName", "U");
|
||||
if (UName_ != "U")
|
||||
{
|
||||
outputName_ = typeName + "(" + UName_ + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vorticity::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
|
||||
|
||||
volVectorField& vorticity =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
obr_.lookupObject<volVectorField>(outputName_)
|
||||
);
|
||||
|
||||
vorticity = fvc::curl(U);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vorticity::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::vorticity::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::vorticity::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const volVectorField& vorticity =
|
||||
obr_.lookupObject<volVectorField>(outputName_);
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << vorticity.name() << nl
|
||||
<< endl;
|
||||
|
||||
vorticity.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,152 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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/>.
|
||||
|
||||
Class
|
||||
Foam::vorticity
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object calculates the vorticity, the curl of the velocity.
|
||||
|
||||
SourceFiles
|
||||
vorticity.C
|
||||
IOvorticity.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vorticity_H
|
||||
#define vorticity_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class vorticity Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class vorticity
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of vorticity objects
|
||||
word name_;
|
||||
|
||||
//- Reference to the database
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- On/off switch
|
||||
bool active_;
|
||||
|
||||
//- Name of velocity field, default is "U"
|
||||
word UName_;
|
||||
|
||||
//- Name of vorticity field
|
||||
word outputName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
vorticity(const vorticity&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const vorticity&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("vorticity");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
vorticity
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~vorticity();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of vorticity
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the vorticity data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the vorticity and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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 "vorticityFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(vorticityFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
vorticityFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2014 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::vorticityFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around vorticity to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
vorticityFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef vorticityFunctionObject_H
|
||||
#define vorticityFunctionObject_H
|
||||
|
||||
#include "vorticity.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<vorticity> vorticityFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOwallShearStress
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for wallShearStress.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOwallShearStress_H
|
||||
#define IOwallShearStress_H
|
||||
|
||||
#include "wallShearStress.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<wallShearStress> IOwallShearStress;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,304 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "wallShearStress.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "incompressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "compressible/turbulenceModel/turbulenceModel.H"
|
||||
#include "wallPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(wallShearStress, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::wallShearStress::writeFileHeader(const label i)
|
||||
{
|
||||
// Add headers to output data
|
||||
writeHeader(file(), "Wall shear stress");
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "patch");
|
||||
writeTabbed(file(), "min");
|
||||
writeTabbed(file(), "max");
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::wallShearStress::calcShearStress
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volSymmTensorField& Reff,
|
||||
volVectorField& shearStress
|
||||
)
|
||||
{
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchI = iter.key();
|
||||
const polyPatch& pp = mesh.boundaryMesh()[patchI];
|
||||
|
||||
vectorField& ssp = shearStress.boundaryField()[patchI];
|
||||
const vectorField& Sfp = mesh.Sf().boundaryField()[patchI];
|
||||
const scalarField& magSfp = mesh.magSf().boundaryField()[patchI];
|
||||
const symmTensorField& Reffp = Reff.boundaryField()[patchI];
|
||||
|
||||
ssp = (-Sfp/magSfp) & Reffp;
|
||||
|
||||
vector minSsp = gMin(ssp);
|
||||
vector maxSsp = gMax(ssp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << mesh.time().value()
|
||||
<< token::TAB << pp.name()
|
||||
<< token::TAB << minSsp
|
||||
<< token::TAB << maxSsp
|
||||
<< endl;
|
||||
}
|
||||
|
||||
Info(log_)<< " min/max(" << pp.name() << ") = "
|
||||
<< minSsp << ", " << maxSsp << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wallShearStress::wallShearStress
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(true),
|
||||
patchSet_()
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"wallShearStress::wallShearStress"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField* wallShearStressPtr
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector
|
||||
(
|
||||
"0",
|
||||
sqr(dimLength)/sqr(dimTime),
|
||||
vector::zero
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(wallShearStressPtr);
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::wallShearStress::~wallShearStress()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::wallShearStress::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
|
||||
patchSet_ =
|
||||
mesh.boundaryMesh().patchSet
|
||||
(
|
||||
wordReList(dict.lookupOrDefault("patches", wordReList()))
|
||||
);
|
||||
|
||||
Info<< type() << " " << name_ << ":" << nl;
|
||||
|
||||
if (patchSet_.empty())
|
||||
{
|
||||
forAll(pbm, patchI)
|
||||
{
|
||||
if (isA<wallPolyPatch>(pbm[patchI]))
|
||||
{
|
||||
patchSet_.insert(patchI);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " processing all wall patches" << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " processing wall patches: " << nl;
|
||||
labelHashSet filteredPatchSet;
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchI = iter.key();
|
||||
if (isA<wallPolyPatch>(pbm[patchI]))
|
||||
{
|
||||
filteredPatchSet.insert(patchI);
|
||||
Info<< " " << pbm[patchI].name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("void wallShearStress::read(const dictionary&)")
|
||||
<< "Requested wall shear stress on non-wall boundary "
|
||||
<< "type patch: " << pbm[patchI].name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
|
||||
patchSet_ = filteredPatchSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::wallShearStress::execute()
|
||||
{
|
||||
typedef compressible::turbulenceModel cmpModel;
|
||||
typedef incompressible::turbulenceModel icoModel;
|
||||
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField& wallShearStress =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
mesh.lookupObject<volVectorField>(type())
|
||||
);
|
||||
|
||||
Info(log_)<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
|
||||
tmp<volSymmTensorField> Reff;
|
||||
if (mesh.foundObject<cmpModel>("turbulenceModel"))
|
||||
{
|
||||
const cmpModel& model =
|
||||
mesh.lookupObject<cmpModel>("turbulenceModel");
|
||||
|
||||
Reff = model.devRhoReff();
|
||||
}
|
||||
else if (mesh.foundObject<icoModel>("turbulenceModel"))
|
||||
{
|
||||
const icoModel& model =
|
||||
mesh.lookupObject<icoModel>("turbulenceModel");
|
||||
|
||||
Reff = model.devReff();
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn("void Foam::wallShearStress::write()")
|
||||
<< "Unable to find turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
}
|
||||
|
||||
calcShearStress(mesh, Reff(), wallShearStress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::wallShearStress::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::wallShearStress::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::wallShearStress::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const volVectorField& wallShearStress =
|
||||
obr_.lookupObject<volVectorField>(type());
|
||||
|
||||
Info(log_)<< type() << " " << name_ << " output:" << nl
|
||||
<< " writing field " << wallShearStress.name() << nl
|
||||
<< endl;
|
||||
|
||||
wallShearStress.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,204 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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/>.
|
||||
|
||||
Class
|
||||
Foam::wallShearStress
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object evaluates and outputs the shear stress at wall
|
||||
patches. The result is written as a volVectorField to time directories as
|
||||
field 'wallShearStress'
|
||||
|
||||
\f[
|
||||
Stress = R \dot n
|
||||
\f]
|
||||
|
||||
where
|
||||
\vartable
|
||||
R | stress tensor
|
||||
n | patch normal vector (into the domain)
|
||||
\endvartable
|
||||
|
||||
The shear stress (symmetrical) tensor field is retrieved from the
|
||||
turbulence model. All wall patches are included by default; to restrict
|
||||
the calculation to certain patches, use the optional 'patches' entry.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
wallShearStress1
|
||||
{
|
||||
type wallShearStress;
|
||||
functionObjectLibs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
patches (".*Wall");
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: wallShearStress | yes |
|
||||
patches | list of patches to process | no | all wall patches
|
||||
\endtable
|
||||
|
||||
SourceFiles
|
||||
wallShearStress.C
|
||||
IOwallShearStress.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef wallShearStress_H
|
||||
#define wallShearStress_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class wallShearStress Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wallShearStress
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of wallShearStress object
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Optional list of patches to process
|
||||
labelHashSet patchSet_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate the shear stress
|
||||
void calcShearStress
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volSymmTensorField& Reff,
|
||||
volVectorField& shearStress
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
wallShearStress(const wallShearStress&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const wallShearStress&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("wallShearStress");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
wallShearStress
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~wallShearStress();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of wallShearStress
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the wallShearStress data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the wallShearStress and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "wallShearStressFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(wallShearStressFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
wallShearStressFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::wallShearStressFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around wallShearStress to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
wallShearStressFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef wallShearStressFunctionObject_H
|
||||
#define wallShearStressFunctionObject_H
|
||||
|
||||
#include "wallShearStress.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<wallShearStress>
|
||||
wallShearStressFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOyPlusLES
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for yPlusLES.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOyPlusLES_H
|
||||
#define IOyPlusLES_H
|
||||
|
||||
#include "yPlusLES.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<yPlusLES> IOyPlusLES;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
329
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C
Normal file
329
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C
Normal file
@ -0,0 +1,329 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "yPlusLES.H"
|
||||
#include "volFields.H"
|
||||
|
||||
#include "incompressible/LES/LESModel/LESModel.H"
|
||||
#include "compressible/LES/LESModel/LESModel.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "nearWallDist.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(yPlusLES, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusLES::writeFileHeader(const label i)
|
||||
{
|
||||
writeHeader(file(), "y+ (LES)");
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "patch");
|
||||
writeTabbed(file(), "min");
|
||||
writeTabbed(file(), "max");
|
||||
writeTabbed(file(), "average");
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::calcIncompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
)
|
||||
{
|
||||
const incompressible::LESModel& model =
|
||||
mesh.lookupObject<incompressible::LESModel>("LESProperties");
|
||||
|
||||
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
|
||||
volScalarField nuEff(model.nuEff());
|
||||
|
||||
const fvPatchList& patches = mesh.boundary();
|
||||
|
||||
const volScalarField nuLam(model.nu());
|
||||
|
||||
bool foundPatch = false;
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const fvPatch& currPatch = patches[patchi];
|
||||
|
||||
if (isA<wallFvPatch>(currPatch))
|
||||
{
|
||||
foundPatch = true;
|
||||
yPlus.boundaryField()[patchi] =
|
||||
d[patchi]
|
||||
*sqrt
|
||||
(
|
||||
nuEff.boundaryField()[patchi]
|
||||
*mag(U.boundaryField()[patchi].snGrad())
|
||||
)
|
||||
/nuLam.boundaryField()[patchi];
|
||||
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchi];
|
||||
|
||||
scalar minYp = gMin(Yp);
|
||||
scalar maxYp = gMax(Yp);
|
||||
scalar avgYp = gAverage(Yp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info(log_)<< " patch " << currPatch.name()
|
||||
<< " y+ : min = " << minYp << ", max = " << maxYp
|
||||
<< ", average = " << avgYp << nl;
|
||||
|
||||
file() << obr_.time().value()
|
||||
<< token::TAB << currPatch.name()
|
||||
<< token::TAB << minYp
|
||||
<< token::TAB << maxYp
|
||||
<< token::TAB << avgYp
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFvPatch::typeName << " patches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::calcCompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
)
|
||||
{
|
||||
const compressible::LESModel& model =
|
||||
mesh.lookupObject<compressible::LESModel>("LESProperties");
|
||||
|
||||
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
|
||||
volScalarField muEff(model.muEff());
|
||||
const volScalarField& rho(model.rho());
|
||||
|
||||
const fvPatchList& patches = mesh.boundary();
|
||||
|
||||
const volScalarField muLam(model.mu());
|
||||
|
||||
Info<< type() << " output:" << nl;
|
||||
|
||||
bool foundPatch = false;
|
||||
forAll(patches, patchi)
|
||||
{
|
||||
const fvPatch& currPatch = patches[patchi];
|
||||
|
||||
if (isA<wallFvPatch>(currPatch))
|
||||
{
|
||||
foundPatch = true;
|
||||
yPlus.boundaryField()[patchi] =
|
||||
d[patchi]
|
||||
*sqrt
|
||||
(
|
||||
(muEff.boundaryField()[patchi]/rho.boundaryField()[patchi])
|
||||
*mag(U.boundaryField()[patchi].snGrad())
|
||||
)
|
||||
/(muLam.boundaryField()[patchi]/rho.boundaryField()[patchi]);
|
||||
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchi];
|
||||
|
||||
scalar minYp = gMin(Yp);
|
||||
scalar maxYp = gMax(Yp);
|
||||
scalar avgYp = gAverage(Yp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info(log_)<< " patch " << currPatch.name()
|
||||
<< " y+ : min = " << minYp << ", max = " << maxYp
|
||||
<< ", average = " << avgYp << nl;
|
||||
|
||||
file() << obr_.time().value()
|
||||
<< token::TAB << currPatch.name()
|
||||
<< token::TAB << minYp
|
||||
<< token::TAB << maxYp
|
||||
<< token::TAB << avgYp
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFvPatch::typeName << " patches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::yPlusLES::yPlusLES
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(true),
|
||||
phiName_("phi"),
|
||||
UName_("U")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"yPlusLES::yPlusLES"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* yPlusLESPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(yPlusLESPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::yPlusLES::~yPlusLES()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusLES::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
obr_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField& yPlusLES =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh.lookupObject<volScalarField>(type())
|
||||
);
|
||||
|
||||
Info(log_)<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
calcCompressibleYPlus(mesh, U, yPlusLES);
|
||||
}
|
||||
else
|
||||
{
|
||||
calcIncompressibleYPlus(mesh, U, yPlusLES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const volScalarField& yPlusLES =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
Info(log_)<< " writing field " << yPlusLES.name() << nl << endl;
|
||||
|
||||
yPlusLES.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
180
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H
Normal file
180
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H
Normal file
@ -0,0 +1,180 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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/>.
|
||||
|
||||
Class
|
||||
Foam::yPlusLES
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Evaluates and outputs turbulence y+ for LES models. Values written to
|
||||
time directories as field 'yPlusLES'
|
||||
|
||||
SourceFiles
|
||||
yPlusLES.C
|
||||
IOyPlusLES.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef yPlusLES_H
|
||||
#define yPlusLES_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class yPlusLES Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class yPlusLES
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of yPlusLES objects
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Name of mass/volume flux field (optional, default = phi)
|
||||
word phiName_;
|
||||
|
||||
//- Name of velocity field
|
||||
word UName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate incompressible form of y+
|
||||
void calcIncompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
);
|
||||
|
||||
//- Calculate compressible form of y+
|
||||
void calcCompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
yPlusLES(const yPlusLES&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const yPlusLES&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("yPlusLES");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
yPlusLES
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~yPlusLES();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of yPlusLES
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the yPlusLES data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the yPlusLES and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "yPlusLESFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(yPlusLESFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
yPlusLESFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::yPlusLESFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around yPlusLES to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
yPlusLESFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef yPlusLESFunctionObject_H
|
||||
#define yPlusLESFunctionObject_H
|
||||
|
||||
#include "yPlusLES.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<yPlusLES> yPlusLESFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOyPlusRAS
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for yPlusRAS.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOyPlusRAS_H
|
||||
#define IOyPlusRAS_H
|
||||
|
||||
#include "yPlusRAS.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<yPlusRAS> IOyPlusRAS;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
312
src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C
Normal file
312
src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C
Normal file
@ -0,0 +1,312 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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 "yPlusRAS.H"
|
||||
#include "volFields.H"
|
||||
|
||||
#include "incompressible/RAS/RASModel/RASModel.H"
|
||||
#include "nutWallFunction/nutWallFunctionFvPatchScalarField.H"
|
||||
#include "compressible/RAS/RASModel/RASModel.H"
|
||||
#include "mutWallFunction/mutWallFunctionFvPatchScalarField.H"
|
||||
#include "wallDist.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(yPlusRAS, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusRAS::writeFileHeader(const label i)
|
||||
{
|
||||
writeHeader(file(), "y+ (RAS)");
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "patch");
|
||||
writeTabbed(file(), "min");
|
||||
writeTabbed(file(), "max");
|
||||
writeTabbed(file(), "average");
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusRAS::calcIncompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
volScalarField& yPlus
|
||||
)
|
||||
{
|
||||
typedef incompressible::nutWallFunctionFvPatchScalarField
|
||||
wallFunctionPatchField;
|
||||
|
||||
const incompressible::RASModel& model =
|
||||
mesh.lookupObject<incompressible::RASModel>("RASProperties");
|
||||
|
||||
const volScalarField nut(model.nut());
|
||||
const volScalarField::GeometricBoundaryField& nutPatches =
|
||||
nut.boundaryField();
|
||||
|
||||
bool foundPatch = false;
|
||||
forAll(nutPatches, patchi)
|
||||
{
|
||||
if (isA<wallFunctionPatchField>(nutPatches[patchi]))
|
||||
{
|
||||
foundPatch = true;
|
||||
|
||||
const wallFunctionPatchField& nutPw =
|
||||
dynamic_cast<const wallFunctionPatchField&>(nutPatches[patchi]);
|
||||
|
||||
yPlus.boundaryField()[patchi] = nutPw.yPlus();
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchi];
|
||||
|
||||
scalar minYp = gMin(Yp);
|
||||
scalar maxYp = gMax(Yp);
|
||||
scalar avgYp = gAverage(Yp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info(log_)<< " patch " << nutPw.patch().name()
|
||||
<< " y+ : min = " << minYp << ", max = " << maxYp
|
||||
<< ", average = " << avgYp << nl;
|
||||
|
||||
file() << obr_.time().value()
|
||||
<< token::TAB << nutPw.patch().name()
|
||||
<< token::TAB << minYp
|
||||
<< token::TAB << maxYp
|
||||
<< token::TAB << avgYp
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFunctionPatchField::typeName << " patches"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusRAS::calcCompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
volScalarField& yPlus
|
||||
)
|
||||
{
|
||||
typedef compressible::mutWallFunctionFvPatchScalarField
|
||||
wallFunctionPatchField;
|
||||
|
||||
const compressible::RASModel& model =
|
||||
mesh.lookupObject<compressible::RASModel>("RASProperties");
|
||||
|
||||
const volScalarField mut(model.mut());
|
||||
const volScalarField::GeometricBoundaryField& mutPatches =
|
||||
mut.boundaryField();
|
||||
|
||||
bool foundPatch = false;
|
||||
forAll(mutPatches, patchi)
|
||||
{
|
||||
if (isA<wallFunctionPatchField>(mutPatches[patchi]))
|
||||
{
|
||||
foundPatch = true;
|
||||
|
||||
const wallFunctionPatchField& mutPw =
|
||||
dynamic_cast<const wallFunctionPatchField&>(mutPatches[patchi]);
|
||||
|
||||
yPlus.boundaryField()[patchi] = mutPw.yPlus();
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchi];
|
||||
|
||||
scalar minYp = gMin(Yp);
|
||||
scalar maxYp = gMax(Yp);
|
||||
scalar avgYp = gAverage(Yp);
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info(log_)<< " patch " << mutPw.patch().name()
|
||||
<< " y+ : min = " << minYp << ", max = " << maxYp
|
||||
<< ", average = " << avgYp << nl;
|
||||
|
||||
file() << obr_.time().value()
|
||||
<< token::TAB << mutPw.patch().name()
|
||||
<< token::TAB << minYp
|
||||
<< token::TAB << maxYp
|
||||
<< token::TAB << avgYp
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFunctionPatchField::typeName << " patches"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::yPlusRAS::yPlusRAS
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(true),
|
||||
phiName_("phi")
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"yPlusRAS::yPlusRAS"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating " << name_ << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (active_)
|
||||
{
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField* yPlusRASPtr
|
||||
(
|
||||
new volScalarField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(yPlusRASPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::yPlusRAS::~yPlusRAS()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusRAS::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusRAS::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
obr_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField& yPlusRAS =
|
||||
const_cast<volScalarField&>
|
||||
(
|
||||
mesh.lookupObject<volScalarField>(type())
|
||||
);
|
||||
|
||||
Info(log_)<< type() << " " << name_ << " output:" << nl;
|
||||
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
calcCompressibleYPlus(mesh, yPlusRAS);
|
||||
}
|
||||
else
|
||||
{
|
||||
calcIncompressibleYPlus(mesh, yPlusRAS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusRAS::end()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusRAS::timeSet()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusRAS::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
const volScalarField& yPlusRAS =
|
||||
obr_.lookupObject<volScalarField>(type());
|
||||
|
||||
Info(log_)<< " writing field " << yPlusRAS.name() << nl << endl;
|
||||
|
||||
yPlusRAS.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
167
src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H
Normal file
167
src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H
Normal file
@ -0,0 +1,167 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-2014 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/>.
|
||||
|
||||
Class
|
||||
Foam::yPlusRAS
|
||||
|
||||
Group
|
||||
grpUtilitiesFunctionObjects
|
||||
|
||||
Description
|
||||
Evaluates and outputs turbulence y+ for RAS models. Values written to
|
||||
time directories as field 'yPlusRAS'
|
||||
|
||||
SourceFiles
|
||||
yPlusRAS.C
|
||||
IOyPlusRAS.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef yPlusRAS_H
|
||||
#define yPlusRAS_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class yPlusRAS Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class yPlusRAS
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of yPlusRAS objects
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Name of mass/volume flux field (optional, default = phi)
|
||||
word phiName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate incompressible form of y+
|
||||
void calcIncompressibleYPlus(const fvMesh& mesh, volScalarField& yPlus);
|
||||
|
||||
//- Calculate compressible form of y+
|
||||
void calcCompressibleYPlus(const fvMesh& mesh, volScalarField& yPlus);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
yPlusRAS(const yPlusRAS&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const yPlusRAS&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("yPlusRAS");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
yPlusRAS
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~yPlusRAS();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of yPlusRAS
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the yPlusRAS data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual void timeSet();
|
||||
|
||||
//- Calculate the yPlusRAS and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const polyMesh&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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 "yPlusRASFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(yPlusRASFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
yPlusRASFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 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/>.
|
||||
|
||||
Typedef
|
||||
Foam::yPlusRASFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around yPlusRAS to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
yPlusRASFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef yPlusRASFunctionObject_H
|
||||
#define yPlusRASFunctionObject_H
|
||||
|
||||
#include "yPlusRAS.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<yPlusRAS> yPlusRASFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user