ENH: Added new DESModelRegions function object from internal dev line

Object generates an indicator field for DES turbulence models to show
in which regions LES or RAS modelling is active.
This commit is contained in:
Andrew Heather 2015-11-27 15:30:26 +00:00
parent dc40eb98d2
commit ecdfe31f2d
6 changed files with 551 additions and 0 deletions

View File

@ -0,0 +1,217 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "DESModelBase.H"
#include "turbulenceModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(DESModelRegions, 0);
}
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
void Foam::DESModelRegions::writeFileHeader(Ostream& os) const
{
writeHeader(os, "DES model region coverage (% volume)");
writeCommented(os, "Time");
writeTabbed(os, "LES");
writeTabbed(os, "RAS");
os << endl;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::DESModelRegions::DESModelRegions
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
functionObjectFile(obr, name, typeName, dict),
name_(name),
obr_(obr),
active_(true),
resultName_(name),
log_(true)
{
// 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;
}
read(dict);
if (active_)
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField* DESModelRegionsPtr
(
new volScalarField
(
IOobject
(
resultName_,
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("0", dimless, 0.0)
)
);
mesh.objectRegistry::store(DESModelRegionsPtr);
writeFileHeader(file());
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::DESModelRegions::~DESModelRegions()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::DESModelRegions::read(const dictionary& dict)
{
if (active_)
{
functionObjectFile::read(dict);
log_.readIfPresent("log", dict);
dict.readIfPresent("resultName", resultName_);
}
}
void Foam::DESModelRegions::execute()
{
if (active_)
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
if (log_) Info<< type() << " " << name_ << " output:" << nl;
volScalarField& DESModelRegions =
const_cast<volScalarField&>
(
mesh.lookupObject<volScalarField>(resultName_)
);
if (mesh.foundObject<DESModelBase>(turbulenceModel::propertiesName))
{
const DESModelBase& model =
mesh.lookupObject<DESModelBase>
(
turbulenceModel::propertiesName
);
DESModelRegions == model.LESRegion();
scalar prc =
gSum(DESModelRegions.internalField()*mesh.V())
/gSum(mesh.V())*100.0;
file() << obr_.time().value()
<< token::TAB << prc
<< token::TAB << 100.0 - prc
<< endl;
if (log_) Info
<< " LES = " << prc << " % (volume)" << nl
<< " RAS = " << 100.0 - prc << " % (volume)" << nl
<< endl;
}
else
{
if (log_) Info
<< " 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 (active_)
{
const volScalarField& DESModelRegions =
obr_.lookupObject<volScalarField>(resultName_);
if (log_) Info
<< type() << " " << name_ << " output:" << nl
<< " writing field " << DESModelRegions.name() << nl
<< endl;
DESModelRegions.write();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,186 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 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
The field is stored on the mesh database so that it can be retrieved and
used for other applications.
Example of function object specification to generate DES indicator field:
\verbatim
DESModelRegions1
{
type DESModelRegions;
functionObjectLibs ("libutilityFunctionObjects.so");
...
}
\endverbatim
\heading Function object usage
\table
Property | Description | Required | Default value
type | type name: DESModelRegions| yes |
resultName | Name of DES indicator field | no | <function name>
log | log to standard output | no | yes
\endtable
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_;
//- Result name
word resultName_;
//- Switch to send output to Info as well as to file
Switch log_;
// Protected Member Functions
//- File header information
virtual void writeFileHeader(Ostream& os) const;
//- 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
// ************************************************************************* //

View File

@ -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
);
}
// ************************************************************************* //

View File

@ -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
// ************************************************************************* //

View 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::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
// ************************************************************************* //

View File

@ -6,6 +6,9 @@ codedFunctionObject/codedFunctionObject.C
CourantNo/CourantNo.C
CourantNo/CourantNoFunctionObject.C
DESModelRegions/DESModelRegions.C
DESModelRegions/DESModelRegionsFunctionObject.C
dsmcFields/dsmcFields.C
dsmcFields/dsmcFieldsFunctionObject.C