From 5a3ba9bc2b1633da7f57b8c77d5b66282097982a Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Mar 2012 09:33:54 +0000 Subject: [PATCH 01/11] STYLE: minor code formatting change --- src/lagrangian/basic/particle/particleI.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From a12b0221600b197853997d23d9dc75bf48fe8396 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Mar 2012 10:18:25 +0000 Subject: [PATCH 02/11] ENH: partial-fix for mapping lagrangian clouds --- src/lagrangian/basic/Cloud/Cloud.C | 3 ++- src/lagrangian/basic/Cloud/Cloud.H | 2 +- .../Templates/KinematicCloud/KinematicCloud.C | 13 ++++++++++++- .../Templates/KinematicCloud/KinematicCloud.H | 7 +++++++ .../Templates/ReactingCloud/ReactingCloud.C | 13 ++++++++++++- .../Templates/ReactingCloud/ReactingCloud.H | 9 ++++++++- .../ReactingMultiphaseCloud.C | 17 ++++++++++++++++- .../ReactingMultiphaseCloud.H | 9 ++++++++- .../clouds/Templates/ThermoCloud/ThermoCloud.C | 13 ++++++++++++- .../clouds/Templates/ThermoCloud/ThermoCloud.H | 11 +++++++++-- 10 files changed, 87 insertions(+), 10 deletions(-) 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/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(); From 9967a47f6f5b7230a3a8fcc4f5795633c2a32f2b Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Mar 2012 10:37:46 +0000 Subject: [PATCH 03/11] ENH: Added new particleTrap cloud function object --- .../include/makeParcelCloudFunctionObjects.H | 2 + .../ParticleTrap/ParticleTrap.C | 124 +++++++++++++++ .../ParticleTrap/ParticleTrap.H | 147 ++++++++++++++++++ 3 files changed, 273 insertions(+) create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.C create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleTrap/ParticleTrap.H 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 + +// ************************************************************************* // From 656d921b2cec52a57b6a9e093e161567641dbf0a Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Mar 2012 12:42:48 +0000 Subject: [PATCH 04/11] ENH: Added new yPlusRAS function object --- .../functionObjects/utilities/Make/files | 9 +- .../functionObjects/utilities/Make/options | 13 +- .../utilities/yPlusRAS/IOyPlusRAS.H | 49 ++++ .../utilities/yPlusRAS/yPlusRAS.C | 235 ++++++++++++++++++ .../utilities/yPlusRAS/yPlusRAS.H | 158 ++++++++++++ .../yPlusRAS/yPlusRASFunctionObject.C | 42 ++++ .../yPlusRAS/yPlusRASFunctionObject.H | 53 ++++ 7 files changed, 554 insertions(+), 5 deletions(-) create mode 100644 src/postProcessing/functionObjects/utilities/yPlusRAS/IOyPlusRAS.H create mode 100644 src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C create mode 100644 src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H create mode 100644 src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.C create mode 100644 src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRASFunctionObject.H diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index c632fc6222..5737e2f473 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -1,15 +1,18 @@ 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 +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..ecc2c0a411 100644 --- a/src/postProcessing/functionObjects/utilities/Make/options +++ b/src/postProcessing/functionObjects/utilities/Make/options @@ -3,11 +3,20 @@ 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 LIB_LIBS = \ -lfiniteVolume \ -lmeshTools \ -lsampling \ -llagrangian \ - -ldsmc + -ldsmc \ + -lincompressibleTransportModels \ + -lcompressibleRASModels \ + -lincompressibleRASModels \ + -lbasicThermophysicalModels 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..788d9f19ff --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C @@ -0,0 +1,235 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::calcIncompressibleYPlus +( + const fvMesh& mesh, + volScalarField& yPlus +) const +{ + typedef incompressible::RASModels::nutkWallFunctionFvPatchScalarField + wallFunctionPatchField; + + const incompressible::RASModel& model = + mesh.lookupObject("RASProperties"); + + const volScalarField nut(model.nut()); + const volScalarField::GeometricBoundaryField& nutPatches = + nut.boundaryField(); + + Info<< type() << " output:" << nl; + + bool foundNutPatch = false; + forAll(nutPatches, patchi) + { + if (isA(nutPatches[patchi])) + { + foundNutPatch = true; + + const wallFunctionPatchField& nutPw = + dynamic_cast(nutPatches[patchi]); + + yPlus.boundaryField()[patchi] = nutPw.yPlus(); + const scalarField& Yp = yPlus.boundaryField()[patchi]; + + Info<< " patch " << nutPw.patch().name() + << " y+ : min = " << min(Yp) << ", max = " << max(Yp) + << ", average = " << average(Yp) << nl; + } + } + + if (!foundNutPatch) + { + Info<< " no " << wallFunctionPatchField::typeName << " patches" + << endl; + } +} + + +void Foam::yPlusRAS::calcCompressibleYPlus +( + const fvMesh& mesh, + volScalarField& yPlus +) const +{ + typedef compressible::RASModels::mutkWallFunctionFvPatchScalarField + wallFunctionPatchField; + + const compressible::RASModel& model = + mesh.lookupObject("RASProperties"); + + const volScalarField mut(model.mut()); + const volScalarField::GeometricBoundaryField& mutPatches = + mut.boundaryField(); + + Info<< type() << " output:" << nl; + + bool foundMutPatch = false; + forAll(mutPatches, patchi) + { + if (isA(mutPatches[patchi])) + { + foundMutPatch = true; + + const wallFunctionPatchField& mutPw = + dynamic_cast(mutPatches[patchi]); + + yPlus.boundaryField()[patchi] = mutPw.yPlus(); + const scalarField& Yp = yPlus.boundaryField()[patchi]; + + Info<< " patch " << mutPw.patch().name() + << " y+ : min = " << min(Yp) << ", max = " << max(Yp) + << ", average = " << average(Yp) << nl; + } + } + + if (!foundMutPatch) + { + 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), + phiName_("phi") +{ + // 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; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::yPlusRAS::~yPlusRAS() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::yPlusRAS::read(const dictionary& dict) +{ + if (active_) + { + 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 (phi.dimensions() == dimMass/dimTime) + { + calcCompressibleYPlus(mesh, yPlusRAS); + } + else + { + calcIncompressibleYPlus(mesh, yPlusRAS); + } + + 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..5b8a0031cc --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +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 "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class yPlusRAS Declaration +\*---------------------------------------------------------------------------*/ + +class yPlusRAS +{ + // Private data + + //- Name of this set of yPlusRAS objects + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- Name of mass/volume flux field (optional, default = phi) + word phiName_; + + + // Private Member Functions + + //- Calculate incompressible form of y+ + void calcIncompressibleYPlus + ( + const fvMesh& mesh, + volScalarField& yPlus + ) const; + + //- Calculate compressible form of y+ + void calcCompressibleYPlus + ( + const fvMesh& mesh, + volScalarField& yPlus + ) const; + + //- 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 + +// ************************************************************************* // From ce7a93a8476f6c6f4ae5e48177d4178183e05958 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Mar 2012 13:25:12 +0000 Subject: [PATCH 05/11] ENH: Added new yPlusLES function object --- .../functionObjects/utilities/Make/files | 3 + .../functionObjects/utilities/Make/options | 5 +- .../utilities/yPlusLES/IOyPlusLES.H | 49 ++++ .../utilities/yPlusLES/yPlusLES.C | 248 ++++++++++++++++++ .../utilities/yPlusLES/yPlusLES.H | 163 ++++++++++++ .../yPlusLES/yPlusLESFunctionObject.C | 42 +++ .../yPlusLES/yPlusLESFunctionObject.H | 53 ++++ .../utilities/yPlusRAS/yPlusRAS.C | 12 +- .../utilities/yPlusRAS/yPlusRAS.H | 2 +- 9 files changed, 569 insertions(+), 8 deletions(-) create mode 100644 src/postProcessing/functionObjects/utilities/yPlusLES/IOyPlusLES.H create mode 100644 src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C create mode 100644 src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H create mode 100644 src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.C create mode 100644 src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLESFunctionObject.H diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 5737e2f473..f6e23536e0 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -12,6 +12,9 @@ staticPressure/staticPressureFunctionObject.C timeActivatedFileUpdate/timeActivatedFileUpdate.C timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C +yPlusLES/yPlusLES.C +yPlusLES/yPlusLESFunctionObject.C + yPlusRAS/yPlusRAS.C yPlusRAS/yPlusRASFunctionObject.C diff --git a/src/postProcessing/functionObjects/utilities/Make/options b/src/postProcessing/functionObjects/utilities/Make/options index ecc2c0a411..9acdda40ef 100644 --- a/src/postProcessing/functionObjects/utilities/Make/options +++ b/src/postProcessing/functionObjects/utilities/Make/options @@ -8,7 +8,8 @@ EXE_INC = \ -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)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude LIB_LIBS = \ -lfiniteVolume \ @@ -19,4 +20,6 @@ LIB_LIBS = \ -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..59436ba7da --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::calcIncompressibleYPlus +( + const fvMesh& mesh, + const volVectorField& U, + volScalarField& yPlus +) const +{ + 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()); + + 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 + ( + nuEff.boundaryField()[patchI] + *mag(U.boundaryField()[patchI].snGrad()) + ) + /nuLam.boundaryField()[patchI]; + + const scalarField& Yp = yPlus.boundaryField()[patchI]; + + Info<< " patch " << currPatch.name() + << " y+ : min = " << min(Yp) << ", max = " << max(Yp) + << ", average = " << average(Yp) << nl; + } + } + + if (!foundPatch) + { + Info<< " no " << wallFvPatch::typeName << " patches" << endl; + } +} + + +void Foam::yPlusLES::calcCompressibleYPlus +( + const fvMesh& mesh, + const volVectorField& U, + volScalarField& yPlus +) const +{ + 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]; + + Info<< " patch " << currPatch.name() + << " y+ : min = " << min(Yp) << ", max = " << max(Yp) + << ", average = " << average(Yp) << nl; + } + } + + if (!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), + phiName_("phi"), + UName_("U") +{ + // 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; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::yPlusLES::~yPlusLES() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::yPlusLES::read(const dictionary& dict) +{ + if (active_) + { + 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 (phi.dimensions() == dimMass/dimTime) + { + calcCompressibleYPlus(mesh, U, yPlusLES); + } + else + { + calcIncompressibleYPlus(mesh, U, yPlusLES); + } + + 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..48b9a1186a --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class yPlusLES Declaration +\*---------------------------------------------------------------------------*/ + +class yPlusLES +{ + // Private data + + //- Name of this set of yPlusLES objects + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- Name of mass/volume flux field (optional, default = phi) + word phiName_; + + //- Name of velocity field + word UName_; + + + // Private Member Functions + + //- Calculate incompressible form of y+ + void calcIncompressibleYPlus + ( + const fvMesh& mesh, + const volVectorField& U, + volScalarField& yPlus + ) const; + + //- Calculate compressible form of y+ + void calcCompressibleYPlus + ( + const fvMesh& mesh, + const volVectorField& U, + volScalarField& yPlus + ) const; + + //- 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/yPlusRAS.C b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C index 788d9f19ff..188c79bba5 100644 --- a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C @@ -59,12 +59,12 @@ void Foam::yPlusRAS::calcIncompressibleYPlus Info<< type() << " output:" << nl; - bool foundNutPatch = false; + bool foundPatch = false; forAll(nutPatches, patchi) { if (isA(nutPatches[patchi])) { - foundNutPatch = true; + foundPatch = true; const wallFunctionPatchField& nutPw = dynamic_cast(nutPatches[patchi]); @@ -78,7 +78,7 @@ void Foam::yPlusRAS::calcIncompressibleYPlus } } - if (!foundNutPatch) + if (!foundPatch) { Info<< " no " << wallFunctionPatchField::typeName << " patches" << endl; @@ -104,12 +104,12 @@ void Foam::yPlusRAS::calcCompressibleYPlus Info<< type() << " output:" << nl; - bool foundMutPatch = false; + bool foundPatch = false; forAll(mutPatches, patchi) { if (isA(mutPatches[patchi])) { - foundMutPatch = true; + foundPatch = true; const wallFunctionPatchField& mutPw = dynamic_cast(mutPatches[patchi]); @@ -123,7 +123,7 @@ void Foam::yPlusRAS::calcCompressibleYPlus } } - if (!foundMutPatch) + if (!foundPatch) { Info<< " no " << wallFunctionPatchField::typeName << " patches" << endl; diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H index 5b8a0031cc..040e6f86bb 100644 --- a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H @@ -52,7 +52,7 @@ class dictionary; class mapPolyMesh; /*---------------------------------------------------------------------------*\ - Class yPlusRAS Declaration + Class yPlusRAS Declaration \*---------------------------------------------------------------------------*/ class yPlusRAS From c440f4fbb9c0c7a81610ab76d664aff5b8d037f4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 20 Mar 2012 14:12:51 +0000 Subject: [PATCH 06/11] ENH: topoSet: added pointToCell/Face with edge option --- .../mesh/manipulation/topoSet/topoSetDict | 2 ++ .../cellSources/pointToCell/pointToCell.C | 34 +++++++++++++++---- .../cellSources/pointToCell/pointToCell.H | 7 ++-- .../faceSources/pointToFace/pointToFace.C | 29 +++++++++++++--- .../faceSources/pointToFace/pointToFace.H | 7 ++-- 5 files changed, 62 insertions(+), 17 deletions(-) diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 5b8a4b73bb..2bbe8ec55a 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -86,6 +86,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 +199,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/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_; From 04c715a19b6c4bece2984e1db0bb5d2d8e2871e1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 20 Mar 2012 14:14:49 +0000 Subject: [PATCH 07/11] ENH: faceSource: add area-normal integration or averaging --- .../field/fieldValues/controlDict | 15 ++-- .../field/fieldValues/faceSource/faceSource.C | 37 +++++++++- .../field/fieldValues/faceSource/faceSource.H | 45 +++++++++-- .../faceSource/faceSourceTemplates.C | 74 ++++++++++++++++--- 4 files changed, 139 insertions(+), 32 deletions(-) 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_) { From b78e8b6e51e76c40475a6900a6c9d24d04a7c00d Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Mar 2012 16:14:13 +0000 Subject: [PATCH 08/11] ENH: Created log output for yPlusRAS/LES function objects --- .../utilities/yPlusLES/yPlusLES.C | 116 +++++++++++++-- .../utilities/yPlusLES/yPlusLES.H | 17 ++- .../utilities/yPlusRAS/yPlusRAS.C | 136 ++++++++++++++---- .../utilities/yPlusRAS/yPlusRAS.H | 25 ++-- 4 files changed, 239 insertions(+), 55 deletions(-) diff --git a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C index 59436ba7da..c93f42c3e8 100644 --- a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C @@ -39,12 +39,57 @@ 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 +) { const incompressible::LESModel& model = mesh.lookupObject("LESProperties"); @@ -56,8 +101,6 @@ void Foam::yPlusLES::calcIncompressibleYPlus const volScalarField nuLam(model.nu()); - Info<< type() << " output:" << nl; - bool foundPatch = false; forAll(patches, patchI) { @@ -77,13 +120,28 @@ void Foam::yPlusLES::calcIncompressibleYPlus const scalarField& Yp = yPlus.boundaryField()[patchI]; - Info<< " patch " << currPatch.name() - << " y+ : min = " << min(Yp) << ", max = " << max(Yp) - << ", average = " << average(Yp) << nl; + 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 (!foundPatch) + if (log_ && !foundPatch) { Info<< " no " << wallFvPatch::typeName << " patches" << endl; } @@ -95,7 +153,7 @@ void Foam::yPlusLES::calcCompressibleYPlus const fvMesh& mesh, const volVectorField& U, volScalarField& yPlus -) const +) { const compressible::LESModel& model = mesh.lookupObject("LESProperties"); @@ -128,13 +186,28 @@ void Foam::yPlusLES::calcCompressibleYPlus const scalarField& Yp = yPlus.boundaryField()[patchI]; - Info<< " patch " << currPatch.name() - << " y+ : min = " << min(Yp) << ", max = " << max(Yp) - << ", average = " << average(Yp) << nl; - } + 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 (!foundPatch) + if (log_ && !foundPatch) { Info<< " no " << wallFvPatch::typeName << " patches" << endl; } @@ -154,8 +227,10 @@ Foam::yPlusLES::yPlusLES name_(name), obr_(obr), active_(true), + log_(false), phiName_("phi"), - UName_("U") + UName_("U"), + outputFilePtr_(NULL) { // Check if the available mesh is an fvMesh, otherwise deactivate if (!isA(obr_)) @@ -173,6 +248,8 @@ Foam::yPlusLES::yPlusLES ) << "No fvMesh available, deactivating." << nl << endl; } + + makeFile(); } @@ -188,6 +265,7 @@ void Foam::yPlusLES::read(const dictionary& dict) { if (active_) { + log_ = dict.lookupOrDefault("log", false); phiName_ = dict.lookupOrDefault("phiName", "phi"); } } @@ -229,6 +307,11 @@ void Foam::yPlusLES::write() dimensionedScalar("0", dimless, 0.0) ); + if (log_) + { + Info<< type() << " output:" << nl; + } + if (phi.dimensions() == dimMass/dimTime) { calcCompressibleYPlus(mesh, U, yPlusLES); @@ -238,7 +321,10 @@ void Foam::yPlusLES::write() calcIncompressibleYPlus(mesh, U, yPlusLES); } - Info<< endl; + if (log_) + { + Info<< endl; + } yPlusLES.write(); } diff --git a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H index 48b9a1186a..5ab936ab7e 100644 --- a/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H +++ b/src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H @@ -39,7 +39,8 @@ SourceFiles #include "volFieldsFwd.H" #include "pointFieldFwd.H" -#include "fvMesh.H" +#include "Switch.H" +#include "OFstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,6 +51,7 @@ namespace Foam class objectRegistry; class dictionary; class mapPolyMesh; +class fvMesh; /*---------------------------------------------------------------------------*\ Class yPlusLES Declaration @@ -67,22 +69,31 @@ class yPlusLES //- 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 - ) const; + ); //- Calculate compressible form of y+ void calcCompressibleYPlus @@ -90,7 +101,7 @@ class yPlusLES const fvMesh& mesh, const volVectorField& U, volScalarField& yPlus - ) const; + ); //- Disallow default bitwise copy construct yPlusLES(const yPlusLES&); diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C index 188c79bba5..81bb1df7ec 100644 --- a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.C @@ -41,11 +41,56 @@ 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 -) const +) { typedef incompressible::RASModels::nutkWallFunctionFvPatchScalarField wallFunctionPatchField; @@ -57,28 +102,41 @@ void Foam::yPlusRAS::calcIncompressibleYPlus const volScalarField::GeometricBoundaryField& nutPatches = nut.boundaryField(); - Info<< type() << " output:" << nl; - bool foundPatch = false; - forAll(nutPatches, patchi) + forAll(nutPatches, patchI) { - if (isA(nutPatches[patchi])) + if (isA(nutPatches[patchI])) { foundPatch = true; const wallFunctionPatchField& nutPw = - dynamic_cast(nutPatches[patchi]); + dynamic_cast(nutPatches[patchI]); - yPlus.boundaryField()[patchi] = nutPw.yPlus(); - const scalarField& Yp = yPlus.boundaryField()[patchi]; + yPlus.boundaryField()[patchI] = nutPw.yPlus(); + const scalarField& Yp = yPlus.boundaryField()[patchI]; - Info<< " patch " << nutPw.patch().name() - << " y+ : min = " << min(Yp) << ", max = " << max(Yp) - << ", average = " << average(Yp) << nl; + 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 (!foundPatch) + if (log_ && !foundPatch) { Info<< " no " << wallFunctionPatchField::typeName << " patches" << endl; @@ -90,7 +148,7 @@ void Foam::yPlusRAS::calcCompressibleYPlus ( const fvMesh& mesh, volScalarField& yPlus -) const +) { typedef compressible::RASModels::mutkWallFunctionFvPatchScalarField wallFunctionPatchField; @@ -102,28 +160,41 @@ void Foam::yPlusRAS::calcCompressibleYPlus const volScalarField::GeometricBoundaryField& mutPatches = mut.boundaryField(); - Info<< type() << " output:" << nl; - bool foundPatch = false; - forAll(mutPatches, patchi) + forAll(mutPatches, patchI) { - if (isA(mutPatches[patchi])) + if (isA(mutPatches[patchI])) { foundPatch = true; const wallFunctionPatchField& mutPw = - dynamic_cast(mutPatches[patchi]); + dynamic_cast(mutPatches[patchI]); - yPlus.boundaryField()[patchi] = mutPw.yPlus(); - const scalarField& Yp = yPlus.boundaryField()[patchi]; + yPlus.boundaryField()[patchI] = mutPw.yPlus(); + const scalarField& Yp = yPlus.boundaryField()[patchI]; - Info<< " patch " << mutPw.patch().name() - << " y+ : min = " << min(Yp) << ", max = " << max(Yp) - << ", average = " << average(Yp) << nl; + 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 (!foundPatch) + if (log_ && !foundPatch) { Info<< " no " << wallFunctionPatchField::typeName << " patches" << endl; @@ -144,7 +215,9 @@ Foam::yPlusRAS::yPlusRAS name_(name), obr_(obr), active_(true), - phiName_("phi") + log_(false), + phiName_("phi"), + outputFilePtr_(NULL) { // Check if the available mesh is an fvMesh, otherwise deactivate if (!isA(obr_)) @@ -162,6 +235,8 @@ Foam::yPlusRAS::yPlusRAS ) << "No fvMesh available, deactivating." << nl << endl; } + + makeFile(); } @@ -177,6 +252,7 @@ void Foam::yPlusRAS::read(const dictionary& dict) { if (active_) { + log_ = dict.lookupOrDefault("log", false); phiName_ = dict.lookupOrDefault("phiName", "phi"); } } @@ -216,6 +292,11 @@ void Foam::yPlusRAS::write() dimensionedScalar("0", dimless, 0.0) ); + if (log_) + { + Info<< type() << " output:" << nl; + } + if (phi.dimensions() == dimMass/dimTime) { calcCompressibleYPlus(mesh, yPlusRAS); @@ -225,7 +306,10 @@ void Foam::yPlusRAS::write() calcIncompressibleYPlus(mesh, yPlusRAS); } - Info<< endl; + if (log_) + { + Info<< endl; + } yPlusRAS.write(); } diff --git a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H index 040e6f86bb..2be6293424 100644 --- a/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H +++ b/src/postProcessing/functionObjects/utilities/yPlusRAS/yPlusRAS.H @@ -39,7 +39,8 @@ SourceFiles #include "volFieldsFwd.H" #include "pointFieldFwd.H" -#include "fvMesh.H" +#include "Switch.H" +#include "OFstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,6 +51,7 @@ namespace Foam class objectRegistry; class dictionary; class mapPolyMesh; +class fvMesh; /*---------------------------------------------------------------------------*\ Class yPlusRAS Declaration @@ -67,25 +69,26 @@ class yPlusRAS //- 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 - ) const; + void calcIncompressibleYPlus(const fvMesh& mesh, volScalarField& yPlus); //- Calculate compressible form of y+ - void calcCompressibleYPlus - ( - const fvMesh& mesh, - volScalarField& yPlus - ) const; + void calcCompressibleYPlus(const fvMesh& mesh, volScalarField& yPlus); //- Disallow default bitwise copy construct yPlusRAS(const yPlusRAS&); From 6ac73b7d5810e2925ebe362d180c8984f4ebc5aa Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 20 Mar 2012 17:27:09 +0000 Subject: [PATCH 09/11] STYLE:topoSetDict: make consistent with code --- applications/utilities/mesh/manipulation/topoSet/topoSetDict | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 2bbe8ec55a..4c2180f21d 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -85,7 +85,6 @@ 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 // } // From d1a4239478316739bcae14c35263a30538bd02f2 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 21 Mar 2012 09:17:47 +0000 Subject: [PATCH 10/11] ENH: Added position output to fieldMinMax function object --- .../field/fieldMinMax/fieldMinMax.C | 53 +++----- .../field/fieldMinMax/fieldMinMax.H | 11 +- .../field/fieldMinMax/fieldMinMaxTemplates.C | 117 +++++++++++++----- 3 files changed, 109 insertions(+), 72 deletions(-) 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); } } } From c407d396c133e0316aae80ae2210b0b4831449fc Mon Sep 17 00:00:00 2001 From: laurence Date: Wed, 21 Mar 2012 11:07:41 +0000 Subject: [PATCH 11/11] COMP: Update CGAL version to 4.0 --- etc/config/settings.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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