diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 5b8a4b73bb..4c2180f21d 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -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 diff --git a/etc/config/settings.sh b/etc/config/settings.sh index 60dfbfd60f..abb7030617 100644 --- a/etc/config/settings.sh +++ b/etc/config/settings.sh @@ -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 diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index 8f951b6c52..460b965070 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -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::autoMap if (trackStartCell < 0) { trackStartCell = 0; + p.cell() = 0; } vector pos = p.position(); diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H index 2ec24517e3..c295a18e24 100644 --- a/src/lagrangian/basic/Cloud/Cloud.H +++ b/src/lagrangian/basic/Cloud/Cloud.H @@ -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 diff --git a/src/lagrangian/basic/particle/particleI.H b/src/lagrangian/basic/particle/particleI.H index 2f6d975120..e3c9a6e049 100644 --- a/src/lagrangian/basic/particle/particleI.H +++ b/src/lagrangian/basic/particle/particleI.H @@ -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 diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index 5c97c41d5c..d7134f5cd3 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -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::motion(TrackData& td) } +template +void Foam::KinematicCloud::autoMap(const mapPolyMesh& mapper) +{ + typedef typename particle::TrackingData > tdType; + + tdType td(*this); + + Cloud::template autoMap(td, mapper); +} + + template void Foam::KinematicCloud::info() { diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H index 7225347e60..91a261f4df 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H @@ -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 diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index 3de4ae546d..4a83808fa2 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -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::evolve() +template +void Foam::ReactingCloud::autoMap(const mapPolyMesh& mapper) +{ + typedef typename particle::TrackingData > tdType; + + tdType td(*this); + + Cloud::template autoMap(td, mapper); +} + + template void Foam::ReactingCloud::info() { diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H index 7f58d83bd6..a16f1255af 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H @@ -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 diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index 9088b97717..8cab7d3f85 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -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::evolve() } +template +void Foam::ReactingMultiphaseCloud::autoMap +( + const mapPolyMesh& mapper +) +{ + typedef typename particle::TrackingData > + tdType; + + tdType td(*this); + + Cloud::template autoMap(td, mapper); +} + + template void Foam::ReactingMultiphaseCloud::info() { diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H index 5f92be1ea8..bb72273e3f 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H @@ -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 diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index 9530707bb4..1844a6b21e 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -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::evolve() } +template +void Foam::ThermoCloud::autoMap(const mapPolyMesh& mapper) +{ + typedef typename particle::TrackingData > tdType; + + tdType td(*this); + + Cloud::template autoMap(td, mapper); +} + + template void Foam::ThermoCloud::info() { diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H index c3c552472f..4acd251621 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H @@ -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(); diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H index 572be515a6..9e19beae34 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H @@ -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); diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C new file mode 100644 index 0000000000..f1b19bde59 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#include "ParticleTrap.H" +#include "fvcGrad.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::ParticleTrap::ParticleTrap +( + const dictionary& dict, + CloudType& owner +) +: + CloudFunctionObject(dict, owner, typeName), + alphaName_ + ( + this->coeffDict().template lookupOrDefault("alphaName", "alpha") + ), + alphaPtr_(NULL), + gradAlphaPtr_(NULL), + threshold_(readScalar(this->coeffDict().lookup("threshold"))) +{} + + +template +Foam::ParticleTrap::ParticleTrap +( + const ParticleTrap& pt +) +: + CloudFunctionObject(pt), + alphaName_(pt.alphaName_), + alphaPtr_(pt.alphaPtr_), + gradAlphaPtr_(NULL), + threshold_(pt.threshold_) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::ParticleTrap::~ParticleTrap() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::ParticleTrap::preEvolve() +{ + if (alphaPtr_ == NULL) + { + const fvMesh& mesh = this->owner().mesh(); + const volScalarField& alpha = + mesh.lookupObject(alphaName_); + + alphaPtr_ = α + } + + if (gradAlphaPtr_.valid()) + { + gradAlphaPtr_() == fvc::grad(*alphaPtr_); + } + else + { + gradAlphaPtr_.reset(new volVectorField(fvc::grad(*alphaPtr_))); + } +} + + +template +void Foam::ParticleTrap::postEvolve() +{ + gradAlphaPtr_.clear(); +} + + +template +void Foam::ParticleTrap::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; + } + } +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.H new file mode 100644 index 0000000000..39321af3c0 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.H @@ -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 . + +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 ParticleTrap +: + public CloudFunctionObject +{ + // 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 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& pe); + + //- Construct and return a clone + virtual autoPtr > clone() const + { + return autoPtr > + ( + new ParticleTrap(*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 + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C index 9701431dc4..0939a2e3be 100644 --- a/src/meshTools/sets/cellSources/pointToCell/pointToCell.C +++ b/src/meshTools/sets/cellSources/pointToCell/pointToCell.C @@ -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 any\n\n" - " Select all cells with any point in the pointSet\n\n" + "\n Usage: pointToCell any|edge\n\n" + " Select all cells with any point ('any') or any edge ('edge')" + " in the pointSet\n\n" ); -const Foam::NamedEnum +const Foam::NamedEnum 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); + } + } + } + } + } } diff --git a/src/meshTools/sets/cellSources/pointToCell/pointToCell.H b/src/meshTools/sets/cellSources/pointToCell/pointToCell.H index 2e8a507640..96f02f18bf 100644 --- a/src/meshTools/sets/cellSources/pointToCell/pointToCell.H +++ b/src/meshTools/sets/cellSources/pointToCell/pointToCell.H @@ -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 pointActionNames_; + static const NamedEnum pointActionNames_; //- Name of set to use word setName_; diff --git a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C index 81e13e4fc4..7d66aaefe2 100644 --- a/src/meshTools/sets/faceSources/pointToFace/pointToFace.C +++ b/src/meshTools/sets/faceSources/pointToFace/pointToFace.C @@ -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 any|all\n\n" + "\n Usage: pointToFace 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 +const Foam::NamedEnum 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; + } + } + } + } } diff --git a/src/meshTools/sets/faceSources/pointToFace/pointToFace.H b/src/meshTools/sets/faceSources/pointToFace/pointToFace.H index 482626f33f..e31bc65086 100644 --- a/src/meshTools/sets/faceSources/pointToFace/pointToFace.H +++ b/src/meshTools/sets/faceSources/pointToFace/pointToFace.H @@ -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 pointActionNames_; + static const NamedEnum pointActionNames_; //- Name of set to use word setName_; diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C index b2b03af70d..5a9e4b1d1e 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -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(fieldSet_[fieldI]); - calcMinMaxFields(fieldSet_[fieldI]); - calcMinMaxFields(fieldSet_[fieldI]); - calcMinMaxFields(fieldSet_[fieldI]); - calcMinMaxFields(fieldSet_[fieldI]); + calcMinMaxFields(fieldSet_[fieldI], mdCmpt); + calcMinMaxFields(fieldSet_[fieldI], mode_); + calcMinMaxFields(fieldSet_[fieldI], mode_); + calcMinMaxFields(fieldSet_[fieldI], mode_); + calcMinMaxFields(fieldSet_[fieldI], mode_); } - } -} - -template<> -void Foam::fieldMinMax::calcMinMaxFields -( - const word& fieldName -) -{ - if (obr_.foundObject(fieldName)) - { - const volScalarField& field = - obr_.lookupObject(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; } } } + // ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H index 8971a5b1d4..3cccb9668d 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMax.H @@ -163,7 +163,11 @@ public: //- Calculate the field min/max template - 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(const word& fieldName); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C index 5f74bcc28a..c2e9674329 100644 --- a/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldMinMax/fieldMinMaxTemplates.C @@ -27,81 +27,140 @@ License #include "volFields.H" #include "dictionary.H" #include "Time.H" +#include "ListOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName) +void Foam::fieldMinMax::calcMinMaxFields +( + const word& fieldName, + const modeType& mode +) { typedef GeometricField fieldType; if (obr_.foundObject(fieldName)) { + const label procI = Pstream::myProcNo(); + const fieldType& field = obr_.lookupObject(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 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 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 minVs(Pstream::nProcs()); + labelList minIs(Pstream::nProcs()); + List 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 maxVs(Pstream::nProcs()); + labelList maxIs(Pstream::nProcs()); + List 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); } } } diff --git a/src/postProcessing/functionObjects/field/fieldValues/controlDict b/src/postProcessing/functionObjects/field/fieldValues/controlDict index 24b3ddbad4..ff5007f18d 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/controlDict +++ b/src/postProcessing/functionObjects/field/fieldValues/controlDict @@ -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 ... diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 97f244c60b..6ce7b3350d 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -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::sourceTypeNames_; -const Foam::NamedEnum +const Foam::NamedEnum Foam::fieldValues::faceSource::operationTypeNames_; @@ -313,6 +315,35 @@ void Foam::fieldValues::faceSource::writeFileHeader() } +template<> +Foam::vector Foam::fieldValues::faceSource::processValues +( + const Field& 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 diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index b7a2924035..fd95788894 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -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 operationTypeNames_; + static const NamedEnum operationTypeNames_; private: @@ -194,7 +202,6 @@ protected: autoPtr 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 + Type processSameTypeValues + ( + const Field& values, + const vectorField& Sf, + const scalarField& weightField + ) const; + + //- Apply the 'operation' to the values. Wrapper around + // processSameTypeValues. See also template specialisation below. template Type processValues ( const Field& 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& values, + const vectorField& Sf, + const scalarField& weightField +) const; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fieldValues diff --git a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index 79c031818f..892593d036 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -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::fieldValues::faceSource::getFieldValues } else if (obr_.foundObject(fieldName)) { + const vf& fld = obr_.lookupObject(fieldName); + if (surfacePtr_.valid()) { - return surfacePtr_().sample(obr_.lookupObject(fieldName)); + if (surfacePtr_().interpolate()) + { + const interpolationCellPoint interp(fld); + tmp > tintFld(surfacePtr_().interpolate(interp)); + const Field& intFld = tintFld(); + + // Average + const faceList& faces = surfacePtr_().faces(); + tmp > tavg + ( + new Field(faces.size(), pTraits::zero) + ); + Field& 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(fieldName), true); + return filterField(fld, true); } } @@ -94,12 +126,11 @@ Foam::tmp > Foam::fieldValues::faceSource::getFieldValues template -Type Foam::fieldValues::faceSource::processValues +Type Foam::fieldValues::faceSource::processSameTypeValues ( const Field& values, - const scalarField& magSf, + const vectorField& Sf, const scalarField& weightField - ) const { Type result = pTraits::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::nComponents; @@ -169,6 +206,19 @@ Type Foam::fieldValues::faceSource::processValues } +template +Type Foam::fieldValues::faceSource::processValues +( + const Field& values, + const vectorField& Sf, + const scalarField& weightField +) const +{ + return processSameTypeValues(values, Sf, weightField); +} + + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -186,22 +236,22 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName) weightField = getFieldValues(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_) { diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index c632fc6222..f6e23536e0 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -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 diff --git a/src/postProcessing/functionObjects/utilities/Make/options b/src/postProcessing/functionObjects/utilities/Make/options index 623013bc21..9acdda40ef 100644 --- a/src/postProcessing/functionObjects/utilities/Make/options +++ b/src/postProcessing/functionObjects/utilities/Make/options @@ -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 diff --git a/src/postProcessing/functionObjects/utilities/yPlusLES/IOyPlusLES.H b/src/postProcessing/functionObjects/utilities/yPlusLES/IOyPlusLES.H new file mode 100644 index 0000000000..55c541ab8f --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/IOyPlusLES.H @@ -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 . + +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 IOyPlusLES; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C new file mode 100644 index 0000000000..c93f42c3e8 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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("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(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("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(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(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("log", false); + phiName_ = dict.lookupOrDefault("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(phiName_); + + const volVectorField& U = obr_.lookupObject(UName_); + + const fvMesh& mesh = refCast(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(); + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H new file mode 100644 index 0000000000..5ab936ab7e --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H @@ -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 . + +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 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 + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.C b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.C new file mode 100644 index 0000000000..77ea1c21a3 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#include "yPlusLESFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(yPlusLESFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + yPlusLESFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.H b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.H new file mode 100644 index 0000000000..35a19abb69 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.H @@ -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 . + +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 yPlusLESFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/IOyPlusRAS.H b/src/postProcessing/functionObjects/utilities/yPlusRAS/IOyPlusRAS.H new file mode 100644 index 0000000000..959d3fbf4a --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/IOyPlusRAS.H @@ -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 . + +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 IOyPlusRAS; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C new file mode 100644 index 0000000000..81bb1df7ec --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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("RASProperties"); + + const volScalarField nut(model.nut()); + const volScalarField::GeometricBoundaryField& nutPatches = + nut.boundaryField(); + + bool foundPatch = false; + forAll(nutPatches, patchI) + { + if (isA(nutPatches[patchI])) + { + foundPatch = true; + + const wallFunctionPatchField& nutPw = + dynamic_cast(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("RASProperties"); + + const volScalarField mut(model.mut()); + const volScalarField::GeometricBoundaryField& mutPatches = + mut.boundaryField(); + + bool foundPatch = false; + forAll(mutPatches, patchI) + { + if (isA(mutPatches[patchI])) + { + foundPatch = true; + + const wallFunctionPatchField& mutPw = + dynamic_cast(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(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("log", false); + phiName_ = dict.lookupOrDefault("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(phiName_); + + const fvMesh& mesh = refCast(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(); + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H new file mode 100644 index 0000000000..2be6293424 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H @@ -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 . + +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 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 + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.C b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.C new file mode 100644 index 0000000000..77ffceeb84 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#include "yPlusRASFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(yPlusRASFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + yPlusRASFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.H b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.H new file mode 100644 index 0000000000..99d34c6517 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.H @@ -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 . + +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 yPlusRASFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //