ENH: Added new turbulenceFields function object - to obtain fields, e.g. R, devReff, devRhoReff etc

This commit is contained in:
andy
2012-03-05 15:04:33 +00:00
parent 68d90c1742
commit f71c2c3b60
9 changed files with 701 additions and 2 deletions

View File

@ -29,6 +29,9 @@ streamLine/streamLineParticle.C
streamLine/streamLineParticleCloud.C
streamLine/streamLineFunctionObject.C
turbulenceFields/turbulenceFields.C
turbulenceFields/turbulenceFieldsFunctionObject.C
wallBoundedStreamLine/wallBoundedStreamLine.C
wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C
wallBoundedStreamLine/wallBoundedStreamLineParticle.C

View File

@ -2,10 +2,17 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lmeshTools \
-llagrangian \
-lsampling
-lsampling \
-lincompressibleTransportModels \
-lcompressibleTurbulenceModel \
-lincompressibleTurbulenceModel

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

View File

@ -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 ("libfieldFunctionObjects.so");
enabled true;
outputControl timeStep;
outputInterval 1;
fields
(
R
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,267 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "turbulenceFields.H"
#include "dictionary.H"
#include "compressible/turbulenceModel/turbulenceModel.H"
#include "incompressible/turbulenceModel/turbulenceModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(Foam::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;
}
Foam::IOobject Foam::turbulenceFields::io(const word& fieldName) const
{
return
IOobject
(
fieldName,
obr_.time().timeName(),
obr_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
);
}
// * * * * * * * * * * * * * * * * 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_))
{
active_ = false;
WarningIn
(
"turbulenceFields::turbulenceFields"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "No fvMesh available, deactivating."
<< endl;
}
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::turbulenceFields::~turbulenceFields()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::turbulenceFields::read(const dictionary& dict)
{
if (active_)
{
dict.lookup("fields") >> fieldSet_;
execute();
}
}
void Foam::turbulenceFields::execute()
{
bool comp = compressible();
if (!active_)
{
return;
}
if (comp)
{
const compressible::turbulenceModel& model =
obr_.lookupObject<compressible::turbulenceModel>(modelName);
forAll(fieldSet_, fieldI)
{
const word& f = fieldSet_[fieldI];
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);
forAll(fieldSet_, fieldI)
{
const word& f = fieldSet_[fieldI];
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()
{
// Do nothing
}
void Foam::turbulenceFields::write()
{
// Do nothing
}
// ************************************************************************* //

View File

@ -0,0 +1,192 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::turbulenceFields
Description
Stores turbulence fields on the mesh database for further manipulation.
SourceFiles
turbulenceFields.C
IOturbulenceFields.H
\*---------------------------------------------------------------------------*/
#ifndef turbulenceFields_H
#define turbulenceFields_H
#include "wordList.H"
#include "IOobject.H"
#include "NamedEnum.H"
#include "pointField.H"
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
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
wordList 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();
//- Helper function to return IOobject
IOobject io(const word& fieldName) const;
//- Process the turbulence field
template<class Type>
void processField
(
const word& fieldName,
const GeometricField<Type, fvPatchField, volMesh>& value
);
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();
//- 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
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "turbulenceFieldsTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#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 "turbulenceFieldsFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(turbulenceFieldsFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
turbulenceFieldsFunctionObject,
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::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
// ************************************************************************* //

View File

@ -0,0 +1,51 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "volFields.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::turbulenceFields::processField
(
const word& fieldName,
const GeometricField<Type, fvPatchField, volMesh>& value
)
{
typedef GeometricField<Type, fvPatchField, volMesh> FieldType;
if (obr_.foundObject<FieldType>(fieldName))
{
FieldType& fld =
const_cast<FieldType&>(obr_.lookupObject<FieldType>(fieldName));
fld == value;
}
else
{
obr_.store(new FieldType(io(fieldName), value));
}
}
// ************************************************************************* //