mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new DESModelRegions function object to identify DES calc RAS/LES regions
This commit is contained in:
@ -0,0 +1,229 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 "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 * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(Foam::DESModelRegions, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::DESModelRegions::makeFile()
|
||||||
|
{
|
||||||
|
// Create the output file if not already created
|
||||||
|
if (outputFilePtr_.empty())
|
||||||
|
{
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Creating output file." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// File update
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
fileName outputDir;
|
||||||
|
word startTimeName =
|
||||||
|
obr_.time().timeName(obr_.time().startTime().value());
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
// Put in undecomposed case (Note: gives problems for
|
||||||
|
// distributed data running)
|
||||||
|
outputDir =
|
||||||
|
obr_.time().path()/".."/name_/startTimeName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outputDir = obr_.time().path()/name_/startTimeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create directory if does not exist
|
||||||
|
mkDir(outputDir);
|
||||||
|
|
||||||
|
// Open new file at start up
|
||||||
|
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||||
|
|
||||||
|
// Add headers to output data
|
||||||
|
outputFilePtr_() << "# DES model region coverage (% volume)" << nl
|
||||||
|
<< "# time " << token::TAB << "LES" << token::TAB << "RAS"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::DESModelRegions::DESModelRegions
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const objectRegistry& obr,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool loadFromFiles
|
||||||
|
)
|
||||||
|
:
|
||||||
|
name_(name),
|
||||||
|
obr_(obr),
|
||||||
|
active_(true),
|
||||||
|
log_(false),
|
||||||
|
outputFilePtr_(NULL)
|
||||||
|
{
|
||||||
|
// 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." << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
makeFile();
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
// Do nothing - only valid on write
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::DESModelRegions::end()
|
||||||
|
{
|
||||||
|
// Do nothing - only valid on write
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::DESModelRegions::write()
|
||||||
|
{
|
||||||
|
typedef incompressible::turbulenceModel icoModel;
|
||||||
|
typedef incompressible::DESModel icoDESModel;
|
||||||
|
|
||||||
|
typedef compressible::turbulenceModel cmpModel;
|
||||||
|
typedef compressible::DESModel cmpDESModel;
|
||||||
|
|
||||||
|
if (active_)
|
||||||
|
{
|
||||||
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
|
|
||||||
|
if (log_)
|
||||||
|
{
|
||||||
|
Info<< type() << " output:" << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp<volScalarField> result;
|
||||||
|
|
||||||
|
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);
|
||||||
|
result = 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);
|
||||||
|
result = des.LESRegion();
|
||||||
|
DESpresent = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DESpresent)
|
||||||
|
{
|
||||||
|
scalar prc =
|
||||||
|
gSum(result().internalField()*mesh.V())/gSum(mesh.V())*100.0;
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
outputFilePtr_() << obr_.time().timeName() << token::TAB
|
||||||
|
<< prc << token::TAB << 100.0 - prc << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log_)
|
||||||
|
{
|
||||||
|
Info<< " LES = " << prc << " % (volume)" << nl
|
||||||
|
<< " RES = " << 100.0 - prc << " % (volume)" << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (log_)
|
||||||
|
{
|
||||||
|
Info<< " No DES turbulence model found in database" << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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/>.
|
||||||
|
|
||||||
|
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 "volFieldsFwd.H"
|
||||||
|
#include "pointFieldFwd.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of classes
|
||||||
|
class objectRegistry;
|
||||||
|
class dictionary;
|
||||||
|
class mapPolyMesh;
|
||||||
|
class fvMesh;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class DESModelRegions Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class DESModelRegions
|
||||||
|
{
|
||||||
|
// Private 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_;
|
||||||
|
|
||||||
|
//- Output file pointer
|
||||||
|
autoPtr<OFstream> outputFilePtr_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Make the output file
|
||||||
|
virtual void makeFile();
|
||||||
|
|
||||||
|
//- 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();
|
||||||
|
|
||||||
|
//- 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 pointField&)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,6 +3,9 @@ codedFunctionObject/codedFunctionObject.C
|
|||||||
CourantNo/CourantNo.C
|
CourantNo/CourantNo.C
|
||||||
CourantNo/CourantNoFunctionObject.C
|
CourantNo/CourantNoFunctionObject.C
|
||||||
|
|
||||||
|
DESModelRegions/DESModelRegions.C
|
||||||
|
DESModelRegions/DESModelRegionsFunctionObject.C
|
||||||
|
|
||||||
dsmcFields/dsmcFields.C
|
dsmcFields/dsmcFields.C
|
||||||
dsmcFields/dsmcFieldsFunctionObject.C
|
dsmcFields/dsmcFieldsFunctionObject.C
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user