Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2012-03-21 17:31:04 +00:00
39 changed files with 1971 additions and 139 deletions

View File

@ -85,7 +85,7 @@ FoamFile
// {
// set p0;
// option any; // cell with any point in pointSet
// //option all; // cell with all points in pointSet
// //option edge; // cell with an edge with both points in pointSet
// }
//
// // Select based on cellShape
@ -198,6 +198,7 @@ FoamFile
// set p0;
// option any; // Faces using any point in pointSet
// //option all // Faces with all points in pointSet
// //option edge // Faces with two consecutive points in pointSet
// }
//
// // Select by explicitly providing face labels

View File

@ -366,7 +366,7 @@ fi
# ~~~~~~~~~~~~~~
boost_version=boost_1_45_0
cgal_version=CGAL-3.9
cgal_version=CGAL-4.0
export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version
export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -421,6 +421,7 @@ void Foam::Cloud<ParticleType>::autoMap
if (trackStartCell < 0)
{
trackStartCell = 0;
p.cell() = 0;
}
vector pos = p.position();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -748,7 +748,7 @@ inline void Foam::particle::initCellFacePt()
// number, but hasn't been able to find a cell to
// occupy.
if(!mesh_.pointInCellBB(position_, oldCellI, 0.1))
if (!mesh_.pointInCellBB(position_, oldCellI, 0.1))
{
// If the position is not inside the (slightly
// extended) bound-box of the cell that it thought

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -674,6 +674,17 @@ void Foam::KinematicCloud<CloudType>::motion(TrackData& td)
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::autoMap(const mapPolyMesh& mapper)
{
typedef typename particle::TrackingData<KinematicCloud<CloudType> > tdType;
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
}
template<class CloudType>
void Foam::KinematicCloud<CloudType>::info()
{

View File

@ -556,6 +556,13 @@ public:
void motion(TrackData& td);
// Mapping
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const mapPolyMesh&);
// I-O
//- Print cloud information

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -342,6 +342,17 @@ void Foam::ReactingCloud<CloudType>::evolve()
template<class CloudType>
void Foam::ReactingCloud<CloudType>::autoMap(const mapPolyMesh& mapper)
{
typedef typename particle::TrackingData<ReactingCloud<CloudType> > tdType;
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
}
template<class CloudType>
void Foam::ReactingCloud<CloudType>::info()
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -299,6 +299,13 @@ public:
void evolve();
// Mapping
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const mapPolyMesh&);
// I-O
//- Print cloud information

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -252,6 +252,21 @@ void Foam::ReactingMultiphaseCloud<CloudType>::evolve()
}
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::autoMap
(
const mapPolyMesh& mapper
)
{
typedef typename particle::TrackingData<ReactingMultiphaseCloud<CloudType> >
tdType;
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
}
template<class CloudType>
void Foam::ReactingMultiphaseCloud<CloudType>::info()
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -273,6 +273,13 @@ public:
void evolve();
// Mapping
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const mapPolyMesh&);
// I-O
//- Print cloud information

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -333,6 +333,17 @@ void Foam::ThermoCloud<CloudType>::evolve()
}
template<class CloudType>
void Foam::ThermoCloud<CloudType>::autoMap(const mapPolyMesh& mapper)
{
typedef typename particle::TrackingData<ThermoCloud<CloudType> > tdType;
tdType td(*this);
Cloud<parcelType>::template autoMap<tdType>(td, mapper);
}
template<class CloudType>
void Foam::ThermoCloud<CloudType>::info()
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -318,7 +318,14 @@ public:
void evolve();
// Check
// Mapping
//- Remap the cells of particles corresponding to the
// mesh topology change with a default tracking data object
virtual void autoMap(const mapPolyMesh&);
// I-O
//- Print cloud information
void info();

View File

@ -31,6 +31,7 @@ License
#include "FacePostProcessing.H"
#include "ParticleErosion.H"
#include "ParticleTracks.H"
#include "ParticleTrap.H"
#include "PatchPostProcessing.H"
#include "VoidFraction.H"
@ -43,6 +44,7 @@ License
makeCloudFunctionObjectType(FacePostProcessing, CloudType); \
makeCloudFunctionObjectType(ParticleErosion, CloudType); \
makeCloudFunctionObjectType(ParticleTracks, CloudType); \
makeCloudFunctionObjectType(ParticleTrap, CloudType); \
makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \
makeCloudFunctionObjectType(VoidFraction, CloudType);

View File

@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "ParticleTrap.H"
#include "fvcGrad.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ParticleTrap<CloudType>::ParticleTrap
(
const dictionary& dict,
CloudType& owner
)
:
CloudFunctionObject<CloudType>(dict, owner, typeName),
alphaName_
(
this->coeffDict().template lookupOrDefault<word>("alphaName", "alpha")
),
alphaPtr_(NULL),
gradAlphaPtr_(NULL),
threshold_(readScalar(this->coeffDict().lookup("threshold")))
{}
template<class CloudType>
Foam::ParticleTrap<CloudType>::ParticleTrap
(
const ParticleTrap<CloudType>& pt
)
:
CloudFunctionObject<CloudType>(pt),
alphaName_(pt.alphaName_),
alphaPtr_(pt.alphaPtr_),
gradAlphaPtr_(NULL),
threshold_(pt.threshold_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class CloudType>
Foam::ParticleTrap<CloudType>::~ParticleTrap()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CloudType>
void Foam::ParticleTrap<CloudType>::preEvolve()
{
if (alphaPtr_ == NULL)
{
const fvMesh& mesh = this->owner().mesh();
const volScalarField& alpha =
mesh.lookupObject<volScalarField>(alphaName_);
alphaPtr_ = &alpha;
}
if (gradAlphaPtr_.valid())
{
gradAlphaPtr_() == fvc::grad(*alphaPtr_);
}
else
{
gradAlphaPtr_.reset(new volVectorField(fvc::grad(*alphaPtr_)));
}
}
template<class CloudType>
void Foam::ParticleTrap<CloudType>::postEvolve()
{
gradAlphaPtr_.clear();
}
template<class CloudType>
void Foam::ParticleTrap<CloudType>::postMove
(
parcelType& p,
const label cellI,
const scalar
)
{
if (alphaPtr_->internalField()[cellI] < threshold_)
{
const vector& gradAlpha = gradAlphaPtr_()[cellI];
vector nHat = gradAlpha/mag(gradAlpha);
scalar nHatU = nHat & p.U();
if (nHatU < 0)
{
p.U() -= 2*nHat*nHatU;
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,147 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::ParticleTrap
Description
Traps particles within a given phase fraction for multi-phase cases
Model is activated using:
particleTrap
{
alphaName alpha; // name volume fraction field
threshold 0.95; // alpha value below which model is active
}
SourceFiles
ParticleTrap.C
\*---------------------------------------------------------------------------*/
#ifndef ParticleTrap_H
#define ParticleTrap_H
#include "CloudFunctionObject.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class ParticleTrap Declaration
\*---------------------------------------------------------------------------*/
template<class CloudType>
class ParticleTrap
:
public CloudFunctionObject<CloudType>
{
// Private Data
// Typedefs
//- Convenience typedef for parcel type
typedef typename CloudType::parcelType parcelType;
//- Name of vol fraction field
const word alphaName_;
//- Pointer to the volume fraction field
const volScalarField* alphaPtr_;
//- Gradient of the volume fraction field
autoPtr<volVectorField> gradAlphaPtr_;
//- Threshold beyond which model is active
scalar threshold_;
public:
//- Runtime type information
TypeName("particleTrap");
// Constructors
//- Construct from dictionary
ParticleTrap(const dictionary& dict, CloudType& owner);
//- Construct copy
ParticleTrap(const ParticleTrap<CloudType>& pe);
//- Construct and return a clone
virtual autoPtr<CloudFunctionObject<CloudType> > clone() const
{
return autoPtr<CloudFunctionObject<CloudType> >
(
new ParticleTrap<CloudType>(*this)
);
}
//- Destructor
virtual ~ParticleTrap();
// Member Functions
// Evaluation
//- Pre-evolve hook
virtual void preEvolve();
//- Post-evolve hook
virtual void postEvolve();
//- Post-move hook
virtual void postMove
(
typename CloudType::parcelType& p,
const label cellI,
const scalar dt
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "ParticleTrap.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,10 +41,11 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::pointToCell::pointAction,
1
2
>::names[] =
{
"any"
"any",
"edge"
};
}
@ -52,11 +53,12 @@ namespace Foam
Foam::topoSetSource::addToUsageTable Foam::pointToCell::usage_
(
pointToCell::typeName,
"\n Usage: pointToCell <pointSet> any\n\n"
" Select all cells with any point in the pointSet\n\n"
"\n Usage: pointToCell <pointSet> any|edge\n\n"
" Select all cells with any point ('any') or any edge ('edge')"
" in the pointSet\n\n"
);
const Foam::NamedEnum<Foam::pointToCell::pointAction, 1>
const Foam::NamedEnum<Foam::pointToCell::pointAction, 2>
Foam::pointToCell::pointActionNames_;
@ -82,6 +84,26 @@ void Foam::pointToCell::combine(topoSet& set, const bool add) const
}
}
}
else if (option_ == EDGE)
{
const faceList& faces = mesh_.faces();
forAll(faces, faceI)
{
const face& f = faces[faceI];
forAll(f, fp)
{
if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp)))
{
addOrDelete(set, mesh_.faceOwner()[faceI], add);
if (mesh_.isInternalFace(faceI))
{
addOrDelete(set, mesh_.faceNeighbour()[faceI], add);
}
}
}
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -55,7 +55,8 @@ public:
//- Enumeration defining the valid options
enum pointAction
{
ANY // Cells using any point in set
ANY, // Cells using any point in set
EDGE // Cells using an edge with both points in set
//ALL // Possible extension: cells whose all points are in set
};
@ -64,7 +65,7 @@ private:
//- Add usage string
static addToUsageTable usage_;
static const NamedEnum<pointAction, 1> pointActionNames_;
static const NamedEnum<pointAction, 2> pointActionNames_;
//- Name of set to use
word setName_;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,11 +41,12 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::pointToFace::pointAction,
2
3
>::names[] =
{
"any",
"all"
"all",
"edge"
};
}
@ -53,13 +54,14 @@ namespace Foam
Foam::topoSetSource::addToUsageTable Foam::pointToFace::usage_
(
pointToFace::typeName,
"\n Usage: pointToFace <pointSet> any|all\n\n"
"\n Usage: pointToFace <pointSet> any|all|edge\n\n"
" Select faces with\n"
" -any point in the pointSet\n"
" -all points in the pointSet\n\n"
" -two consecutive points (an edge) in the pointSet\n\n"
);
const Foam::NamedEnum<Foam::pointToFace::pointAction, 2>
const Foam::NamedEnum<Foam::pointToFace::pointAction, 3>
Foam::pointToFace::pointActionNames_;
@ -126,6 +128,23 @@ void Foam::pointToFace::combine(topoSet& set, const bool add) const
}
}
}
else if (option_ == EDGE)
{
const faceList& faces = mesh_.faces();
forAll(faces, faceI)
{
const face& f = faces[faceI];
forAll(f, fp)
{
if (loadedSet.found(f[fp]) && loadedSet.found(f.nextLabel(fp)))
{
addOrDelete(set, faceI, add);
break;
}
}
}
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -58,7 +58,8 @@ public:
enum pointAction
{
ANY,
ALL
ALL,
EDGE
};
@ -67,7 +68,7 @@ private:
//- Add usage string
static addToUsageTable usage_;
static const NamedEnum<pointAction, 2> pointActionNames_;
static const NamedEnum<pointAction, 3> pointActionNames_;
//- Name of set to use
word setName_;

View File

@ -156,7 +156,9 @@ void Foam::fieldMinMax::writeFileHeader()
if (fieldMinMaxFilePtr_.valid())
{
fieldMinMaxFilePtr_()
<< "# Time" << tab << "field" << tab << "min" << tab << "max"
<< "# Time" << token::TAB << "field" << token::TAB
<< "min" << token::TAB << "position(min)" << token::TAB
<< "max" << token::TAB << "position(max)" << token::TAB
<< endl;
}
}
@ -184,50 +186,27 @@ void Foam::fieldMinMax::write()
makeFile();
}
if (log_)
{
Info<< type() << " output:" << nl;
}
forAll(fieldSet_, fieldI)
{
calcMinMaxFields<scalar>(fieldSet_[fieldI]);
calcMinMaxFields<vector>(fieldSet_[fieldI]);
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldI]);
calcMinMaxFields<symmTensor>(fieldSet_[fieldI]);
calcMinMaxFields<tensor>(fieldSet_[fieldI]);
calcMinMaxFields<scalar>(fieldSet_[fieldI], mdCmpt);
calcMinMaxFields<vector>(fieldSet_[fieldI], mode_);
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldI], mode_);
calcMinMaxFields<symmTensor>(fieldSet_[fieldI], mode_);
calcMinMaxFields<tensor>(fieldSet_[fieldI], mode_);
}
}
}
template<>
void Foam::fieldMinMax::calcMinMaxFields<Foam::scalar>
(
const word& fieldName
)
{
if (obr_.foundObject<volScalarField>(fieldName))
{
const volScalarField& field =
obr_.lookupObject<volScalarField>(fieldName);
const scalar minValue = min(field).value();
const scalar maxValue = max(field).value();
if (Pstream::master())
if (log_)
{
if (write_)
{
fieldMinMaxFilePtr_()
<< obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue << endl;
}
if (log_)
{
Info<< "fieldMinMax output:" << nl
<< " min(" << fieldName << ") = " << minValue << nl
<< " max(" << fieldName << ") = " << maxValue << nl
<< endl;
}
Info<< endl;
}
}
}
// ************************************************************************* //

View File

@ -163,7 +163,11 @@ public:
//- Calculate the field min/max
template<class Type>
void calcMinMaxFields(const word& fieldName);
void calcMinMaxFields
(
const word& fieldName,
const modeType& mode
);
//- Write the fieldMinMax
virtual void write();
@ -178,11 +182,6 @@ public:
};
// Template specialisation for scalar fields
template<>
void fieldMinMax::calcMinMaxFields<scalar>(const word& fieldName);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -27,81 +27,140 @@ License
#include "volFields.H"
#include "dictionary.H"
#include "Time.H"
#include "ListOps.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
void Foam::fieldMinMax::calcMinMaxFields
(
const word& fieldName,
const modeType& mode
)
{
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
if (obr_.foundObject<fieldType>(fieldName))
{
const label procI = Pstream::myProcNo();
const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
switch (mode_)
switch (mode)
{
case mdMag:
{
const scalar minValue = min(mag(field)).value();
const scalar maxValue = max(mag(field)).value();
const scalarField magField(mag(field));
labelList minIs(Pstream::nProcs());
scalarList minVs(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
minIs[procI] = findMin(magField);
minVs[procI] = magField[minIs[procI]];
minCs[procI] = field.mesh().C()[minIs[procI]];
Pstream::gatherList(minIs);
Pstream::gatherList(minVs);
Pstream::gatherList(minCs);
labelList maxIs(Pstream::nProcs());
scalarList maxVs(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
maxIs[procI] = findMax(magField);
maxVs[procI] = magField[maxIs[procI]];
maxCs[procI] = field.mesh().C()[maxIs[procI]];
Pstream::gatherList(maxIs);
Pstream::gatherList(maxVs);
Pstream::gatherList(maxCs);
label minI = findMin(minVs);
scalar minValue = minVs[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
scalar maxValue = maxVs[maxI];
const vector& maxC = maxCs[maxI];
if (Pstream::master())
{
if (write_)
{
fieldMinMaxFilePtr_()
<< obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
<< obr_.time().value() << token::TAB
<< fieldName << token::TAB
<< minValue << token::TAB << minC << token::TAB
<< maxValue << token::TAB << maxC << endl;
}
if (log_)
{
Info<< "fieldMinMax output:" << nl
<< " min(mag(" << fieldName << ")) = "
<< minValue << nl
Info<< " min(mag(" << fieldName << ")) = "
<< minValue << " at position " << minC << nl
<< " max(mag(" << fieldName << ")) = "
<< maxValue << nl
<< endl;
<< maxValue << " at position " << maxC << nl;
}
}
break;
}
case mdCmpt:
{
const Type minValue = min(field).value();
const Type maxValue = max(field).value();
List<Type> minVs(Pstream::nProcs());
labelList minIs(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
minIs[procI] = findMin(field);
minVs[procI] = field[minIs[procI]];
minCs[procI] = field.mesh().C()[minIs[procI]];
Pstream::gatherList(minIs);
Pstream::gatherList(minVs);
Pstream::gatherList(minCs);
List<Type> maxVs(Pstream::nProcs());
labelList maxIs(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
maxIs[procI] = findMax(field);
maxVs[procI] = field[maxIs[procI]];
maxCs[procI] = field.mesh().C()[maxIs[procI]];
Pstream::gatherList(maxIs);
Pstream::gatherList(maxVs);
Pstream::gatherList(maxCs);
label minI = findMin(minVs);
Type minValue = minVs[minI];
const vector& minC = minCs[minI];
label maxI = findMax(maxVs);
Type maxValue = maxVs[maxI];
const vector& maxC = maxCs[maxI];
if (Pstream::master())
{
if (write_)
{
fieldMinMaxFilePtr_()
<< obr_.time().value() << tab
<< fieldName << tab << minValue << tab << maxValue
<< endl;
<< obr_.time().value() << token::TAB
<< fieldName << token::TAB
<< minValue << token::TAB << minC << token::TAB
<< maxValue << token::TAB << maxC << endl;
}
if (log_)
{
Info<< "fieldMinMax output:" << nl
<< " cmptMin(" << fieldName << ") = "
<< minValue << nl
<< " cmptMax(" << fieldName << ") = "
<< maxValue << nl
<< endl;
Info<< " min(" << fieldName << ") = "
<< minValue << " at position " << minC << nl
<< " max(" << fieldName << ") = "
<< maxValue << " at position " << maxC << nl;
}
}
break;
}
default:
{
FatalErrorIn
(
"Foam::fieldMinMax::calcMinMaxFields"
"(const word& fieldName)"
)<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
FatalErrorIn("Foam::fieldMinMax::calcMinMaxFields(const word&)")
<< "Unknown min/max mode: " << modeTypeNames_[mode_]
<< exit(FatalError);
}
}
}

View File

@ -67,17 +67,14 @@ functions
sourceName movingWall;
//// if sampledSurface: dictionary with a sampledSurface
//// Note: the sampledSurfaces will have cell-values, i.e.
//// non-interpolated. Also will not sample surface fields.
//// Note: will not sample surface fields.
//sampledSurfaceDict
//{
// type cuttingPlane;
// planeType pointAndNormal;
// pointAndNormalDict
// {
// basePoint (0 0.099 0);
// normalVector (0 1 0);
// }
// // Sampling on triSurface
// type sampledTriSurfaceMesh;
// surface integrationPlane.stl;
// source cells; // sample cells or boundaryFaces
// interpolate true;
//}
// Operation: areaAverage/sum/weightedAverage ...

View File

@ -53,7 +53,7 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::fieldValues::faceSource::operationType,
9
11
>::names[] =
{
"none",
@ -64,7 +64,9 @@ namespace Foam
"areaIntegrate",
"min",
"max",
"CoV"
"CoV",
"areaNormalAverage",
"areaNormalIntegrate"
};
}
@ -73,7 +75,7 @@ namespace Foam
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
Foam::fieldValues::faceSource::sourceTypeNames_;
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 9>
const Foam::NamedEnum<Foam::fieldValues::faceSource::operationType, 11>
Foam::fieldValues::faceSource::operationTypeNames_;
@ -313,6 +315,35 @@ void Foam::fieldValues::faceSource::writeFileHeader()
}
template<>
Foam::vector Foam::fieldValues::faceSource::processValues
(
const Field<vector>& values,
const vectorField& Sf,
const scalarField& weightField
) const
{
switch (operation_)
{
case opAreaNormalAverage:
{
scalar result = sum(values&Sf)/sum(mag(Sf));
return vector(result, 0.0, 0.0);
}
case opAreaNormalIntegrate:
{
scalar result = sum(values&Sf);
return vector(result, 0.0, 0.0);
}
default:
{
// Fall through to other operations
return processSameTypeValues(values, Sf, weightField);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldValues::faceSource::faceSource

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,7 +65,9 @@ Description
- min
- max
- CoV (Coefficient of variation: standard deviation/mean)
- areaNormalAverage (vector with first component (average of) inproduct
of value and face area vector)
- areaNormalIntegrate ( ,, ,, (sum of) ,,
Notes:
- faces on empty patches get ignored
@ -75,7 +77,11 @@ Description
negative pressure)
- using sampledSurfaces:
- they do not do surface fields
- they use cell values - they do not do any interpolation.
- if interpolate=true they use interpolationCellPoint
otherwise they use cell values
- each triangle in sampledSurface is logically only in one cell
so interpolation will be wrong when triangles are larger than
cells. This can only happen for sampling on triSurfaceMesh.
- take care when using isoSurfaces - these might have duplicate
triangles so integration might be wrong
@ -138,11 +144,13 @@ public:
opAreaIntegrate,
opMin,
opMax,
opCoV
opCoV,
opAreaNormalAverage,
opAreaNormalIntegrate
};
//- Operation type names
static const NamedEnum<operationType, 9> operationTypeNames_;
static const NamedEnum<operationType, 11> operationTypeNames_;
private:
@ -194,7 +202,6 @@ protected:
autoPtr<sampledSurface> surfacePtr_;
// Protected Member Functions
//- Initialise, e.g. face addressing
@ -212,12 +219,23 @@ protected:
const bool mustGet = false
) const;
//- Apply the 'operation' to the values
//- Apply the 'operation' to the values. Operation has to
// preserve Type.
template<class Type>
Type processSameTypeValues
(
const Field<Type>& values,
const vectorField& Sf,
const scalarField& weightField
) const;
//- Apply the 'operation' to the values. Wrapper around
// processSameTypeValues. See also template specialisation below.
template<class Type>
Type processValues
(
const Field<Type>& values,
const scalarField& magSf,
const vectorField& Sf,
const scalarField& weightField
) const;
@ -292,6 +310,17 @@ public:
};
//- Specialisation of processing vectors for opAreaNormalAverage,
// opAreaNormalIntegrate (use inproduct - dimension reducing operation)
template<>
vector faceSource::processValues
(
const Field<vector>& values,
const vectorField& Sf,
const scalarField& weightField
) const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fieldValues

View File

@ -27,6 +27,7 @@ License
#include "surfaceFields.H"
#include "volFields.H"
#include "sampledSurface.H"
#include "interpolationCellPoint.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -65,13 +66,44 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues
}
else if (obr_.foundObject<vf>(fieldName))
{
const vf& fld = obr_.lookupObject<vf>(fieldName);
if (surfacePtr_.valid())
{
return surfacePtr_().sample(obr_.lookupObject<vf>(fieldName));
if (surfacePtr_().interpolate())
{
const interpolationCellPoint<Type> interp(fld);
tmp<Field<Type> > tintFld(surfacePtr_().interpolate(interp));
const Field<Type>& intFld = tintFld();
// Average
const faceList& faces = surfacePtr_().faces();
tmp<Field<Type> > tavg
(
new Field<Type>(faces.size(), pTraits<Type>::zero)
);
Field<Type>& avg = tavg();
forAll(faces, faceI)
{
const face& f = faces[faceI];
forAll(f, fp)
{
avg[faceI] += intFld[f[fp]];
}
avg[faceI] /= f.size();
}
return tavg;
}
else
{
return surfacePtr_().sample(fld);
}
}
else
{
return filterField(obr_.lookupObject<vf>(fieldName), true);
return filterField(fld, true);
}
}
@ -94,12 +126,11 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues
template<class Type>
Type Foam::fieldValues::faceSource::processValues
Type Foam::fieldValues::faceSource::processSameTypeValues
(
const Field<Type>& values,
const scalarField& magSf,
const vectorField& Sf,
const scalarField& weightField
) const
{
Type result = pTraits<Type>::zero;
@ -122,11 +153,15 @@ Type Foam::fieldValues::faceSource::processValues
}
case opAreaAverage:
{
const scalarField magSf = mag(Sf);
result = sum(values*magSf)/sum(magSf);
break;
}
case opAreaIntegrate:
{
const scalarField magSf = mag(Sf);
result = sum(values*magSf);
break;
}
@ -142,6 +177,8 @@ Type Foam::fieldValues::faceSource::processValues
}
case opCoV:
{
const scalarField magSf = mag(Sf);
Type meanValue = sum(values*magSf)/sum(magSf);
const label nComp = pTraits<Type>::nComponents;
@ -169,6 +206,19 @@ Type Foam::fieldValues::faceSource::processValues
}
template<class Type>
Type Foam::fieldValues::faceSource::processValues
(
const Field<Type>& values,
const vectorField& Sf,
const scalarField& weightField
) const
{
return processSameTypeValues(values, Sf, weightField);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
@ -186,22 +236,22 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
weightField = getFieldValues<scalar>(weightFieldName_, true);
}
scalarField magSf;
vectorField Sf;
if (surfacePtr_.valid())
{
// Get unoriented magSf
magSf = surfacePtr_().magSf();
// Get oriented Sf
Sf = surfacePtr_().Sf();
}
else
{
// Get unoriented magSf
magSf = filterField(mesh().magSf(), false);
// Get oriented Sf
Sf = filterField(mesh().Sf(), false);
}
// Combine onto master
combineFields(values);
combineFields(magSf);
combineFields(Sf);
combineFields(weightField);
// apply weight field
@ -210,7 +260,7 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
if (Pstream::master())
{
Type result = processValues(values, magSf, weightField);
Type result = processValues(values, Sf, weightField);
if (valueOutput_)
{

View File

@ -1,15 +1,21 @@
codedFunctionObject/codedFunctionObject.C
dsmcFields/dsmcFields.C
dsmcFields/dsmcFieldsFunctionObject.C
pressureCoefficient/pressureCoefficient.C
pressureCoefficient/pressureCoefficientFunctionObject.C
staticPressure/staticPressure.C
staticPressure/staticPressureFunctionObject.C
dsmcFields/dsmcFields.C
dsmcFields/dsmcFieldsFunctionObject.C
timeActivatedFileUpdate/timeActivatedFileUpdate.C
timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C
yPlusLES/yPlusLES.C
yPlusLES/yPlusLESFunctionObject.C
yPlusRAS/yPlusRAS.C
yPlusRAS/yPlusRASFunctionObject.C
LIB = $(FOAM_LIBBIN)/libutilityFunctionObjects

View File

@ -3,11 +3,23 @@ EXE_INC = \
-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)/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 \
-lmeshTools \
-lsampling \
-llagrangian \
-ldsmc
-ldsmc \
-lincompressibleTransportModels \
-lcompressibleRASModels \
-lincompressibleRASModels \
-lcompressibleLESModels \
-lincompressibleLESModels \
-lbasicThermophysicalModels

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

View File

@ -0,0 +1,334 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "yPlusLES.H"
#include "volFields.H"
#include "incompressible/LES/LESModel/LESModel.H"
#include "compressible/LES/LESModel/LESModel.H"
#include "wallFvPatch.H"
#include "nearWallDist.H"
//#include "wallDist.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::yPlusLES, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::yPlusLES::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_() << "# y+ (LES)" << nl
<< "# time " << token::TAB << "patch" << token::TAB
<< "min" << token::TAB << "max" << token::TAB << "average"
<< 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 = min(Yp);
scalar maxYp = max(Yp);
scalar avgYp = average(Yp);
if (log_)
{
Info<< " patch " << currPatch.name()
<< " y+ : min = " << min(Yp) << ", max = " << max(Yp)
<< ", average = " << average(Yp) << nl;
}
if (Pstream::master())
{
outputFilePtr_() << 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 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]
*mag(U.boundaryField()[patchI].snGrad())
)
/muLam.boundaryField()[patchI];
const scalarField& Yp = yPlus.boundaryField()[patchI];
scalar minYp = min(Yp);
scalar maxYp = max(Yp);
scalar avgYp = average(Yp);
if (log_)
{
Info<< " patch " << currPatch.name()
<< " y+ : min = " << min(Yp) << ", max = " << max(Yp)
<< ", average = " << average(Yp) << nl;
}
if (Pstream::master())
{
outputFilePtr_() << 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
)
:
name_(name),
obr_(obr),
active_(true),
log_(false),
phiName_("phi"),
UName_("U"),
outputFilePtr_(NULL)
{
// 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." << nl
<< endl;
}
makeFile();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::yPlusLES::~yPlusLES()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::yPlusLES::read(const dictionary& dict)
{
if (active_)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
}
}
void Foam::yPlusLES::execute()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::end()
{
// Do nothing - only valid on write
}
void Foam::yPlusLES::write()
{
if (active_)
{
const surfaceScalarField& phi =
obr_.lookupObject<surfaceScalarField>(phiName_);
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField yPlusLES
(
IOobject
(
"yPlusLES",
mesh.time().timeName(),
mesh,
IOobject::NO_READ
),
mesh,
dimensionedScalar("0", dimless, 0.0)
);
if (log_)
{
Info<< type() << " output:" << nl;
}
if (phi.dimensions() == dimMass/dimTime)
{
calcCompressibleYPlus(mesh, U, yPlusLES);
}
else
{
calcIncompressibleYPlus(mesh, U, yPlusLES);
}
if (log_)
{
Info<< endl;
}
yPlusLES.write();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,174 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::yPlusLES
Description
Evaluates and outputs turbulence y+ for LES models. Values written to
time folders as field 'yPlusLES'
SourceFiles
yPlusLES.C
IOyPlusLES.H
\*---------------------------------------------------------------------------*/
#ifndef yPlusLES_H
#define yPlusLES_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 yPlusLES Declaration
\*---------------------------------------------------------------------------*/
class yPlusLES
{
// 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_;
//- Output file pointer
autoPtr<OFstream> outputFilePtr_;
// Private Member Functions
//- Make the output file
virtual void makeFile();
//- 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();
//- 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 pointField&)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // 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 "yPlusLESFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(yPlusLESFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
yPlusLESFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

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

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

View File

@ -0,0 +1,319 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "yPlusRAS.H"
#include "volFields.H"
#include "incompressible/RAS/RASModel/RASModel.H"
#include "nutkWallFunction/nutkWallFunctionFvPatchScalarField.H"
#include "compressible/RAS/RASModel/RASModel.H"
#include "mutkWallFunction/mutkWallFunctionFvPatchScalarField.H"
#include "wallDist.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::yPlusRAS, 0);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::yPlusRAS::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_() << "# y+ (RAS)" << nl
<< "# time " << token::TAB << "patch" << token::TAB
<< "min" << token::TAB << "max" << token::TAB << "average"
<< endl;
}
}
}
void Foam::yPlusRAS::calcIncompressibleYPlus
(
const fvMesh& mesh,
volScalarField& yPlus
)
{
typedef incompressible::RASModels::nutkWallFunctionFvPatchScalarField
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 = min(Yp);
scalar maxYp = max(Yp);
scalar avgYp = average(Yp);
if (log_)
{
Info<< " patch " << nutPw.patch().name()
<< " y+ : min = " << minYp << ", max = " << maxYp
<< ", average = " << avgYp << nl;
}
if (Pstream::master())
{
outputFilePtr_() << 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::RASModels::mutkWallFunctionFvPatchScalarField
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 = min(Yp);
scalar maxYp = max(Yp);
scalar avgYp = average(Yp);
if (log_)
{
Info<< " patch " << mutPw.patch().name()
<< " y+ : min = " << minYp << ", max = " << maxYp
<< ", average = " << avgYp << nl;
}
if (Pstream::master())
{
outputFilePtr_() << 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
)
:
name_(name),
obr_(obr),
active_(true),
log_(false),
phiName_("phi"),
outputFilePtr_(NULL)
{
// 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." << nl
<< endl;
}
makeFile();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::yPlusRAS::~yPlusRAS()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::yPlusRAS::read(const dictionary& dict)
{
if (active_)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
}
}
void Foam::yPlusRAS::execute()
{
// Do nothing - only valid on write
}
void Foam::yPlusRAS::end()
{
// Do nothing - only valid on write
}
void Foam::yPlusRAS::write()
{
if (active_)
{
const surfaceScalarField& phi =
obr_.lookupObject<surfaceScalarField>(phiName_);
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volScalarField yPlusRAS
(
IOobject
(
"yPlusRAS",
mesh.time().timeName(),
mesh,
IOobject::NO_READ
),
mesh,
dimensionedScalar("0", dimless, 0.0)
);
if (log_)
{
Info<< type() << " output:" << nl;
}
if (phi.dimensions() == dimMass/dimTime)
{
calcCompressibleYPlus(mesh, yPlusRAS);
}
else
{
calcIncompressibleYPlus(mesh, yPlusRAS);
}
if (log_)
{
Info<< endl;
}
yPlusRAS.write();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,161 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::yPlusRAS
Description
Evaluates and outputs turbulence y+ for RAS models. Values written to
time folders as field 'yPlusRAS'
SourceFiles
yPlusRAS.C
IOyPlusRAS.H
\*---------------------------------------------------------------------------*/
#ifndef yPlusRAS_H
#define yPlusRAS_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 yPlusRAS Declaration
\*---------------------------------------------------------------------------*/
class yPlusRAS
{
// 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_;
//- Output file pointer
autoPtr<OFstream> outputFilePtr_;
// Private Member Functions
//- Make the output file
virtual void makeFile();
//- 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();
//- 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 pointField&)
{}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // 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 "yPlusRASFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(yPlusRASFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
yPlusRASFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

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