From f85544761995573af898ba36bd34b3ed81fe1351 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Sep 2011 14:39:00 +0100 Subject: [PATCH 1/4] BUG: Updated cone nozzle injector model copy cstr --- .../ConeNozzleInjection/ConeNozzleInjection.C | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C index 80a5bed73f..08e824f35b 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C @@ -220,11 +220,14 @@ Foam::ConeNozzleInjection::ConeNozzleInjection : InjectionModel(im), injectionMethod_(im.injectionMethod_), + flowType_(im.flowType_), outerDiameter_(im.outerDiameter_), innerDiameter_(im.innerDiameter_), duration_(im.duration_), position_(im.position_), injectorCell_(im.injectorCell_), + tetFaceI_(im.tetFaceI_), + tetPtI_(im.tetPtI_), direction_(im.direction_), parcelsPerSecond_(im.parcelsPerSecond_), flowRateProfile_(im.flowRateProfile_().clone().ptr()), @@ -235,9 +238,18 @@ Foam::ConeNozzleInjection::ConeNozzleInjection tanVec2_(im.tanVec1_), normal_(im.normal_), UMag_(im.UMag_), - Cd_(im.Cd_().clone().ptr()), - Pinj_(im.Pinj_().clone().ptr()) -{} + Cd_(NULL), + Pinj_(NULL) +{ + if (im.Cd_.valid()) + { + Cd_.reset(im.Cd_().clone().ptr()); + } + if (im.Pinj_.valid()) + { + Pinj_.reset(im.Pinj_().clone().ptr()); + } +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // From 4614b5cf15c4c18ae760bed15e3e4b75c9ab1f25 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Sep 2011 14:40:13 +0100 Subject: [PATCH 2/4] ENH: Added postMove() hook to particle function objects --- .../KinematicParcel/KinematicParcel.C | 2 ++ .../CloudFunctionObject/CloudFunctionObject.C | 29 +++++++++---------- .../CloudFunctionObject/CloudFunctionObject.H | 8 +++++ .../CloudFunctionObjectList.C | 15 ++++++++++ .../CloudFunctionObjectList.H | 8 +++++ 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index ef36b47058..7007e0167b 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -324,6 +324,8 @@ bool Foam::KinematicParcel::move } p.age() += dt; + + td.cloud().functions().postMove(p, cellI, dt); } return td.keepParticle; diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C index 8ba3dd81b6..02416263cb 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.C @@ -91,6 +91,18 @@ void Foam::CloudFunctionObject::postEvolve() } +template +void Foam::CloudFunctionObject::postMove +( + const typename CloudType::parcelType&, + const label, + const scalar +) +{ + // do nothing +} + + template void Foam::CloudFunctionObject::postPatch ( @@ -98,14 +110,7 @@ void Foam::CloudFunctionObject::postPatch const label ) { - notImplemented - ( - "void Foam::CloudFunctionObject::postPatch" - "(" - "const typename CloudType::parcelType&," - "const label" - ")" - ); + // do nothing } @@ -115,13 +120,7 @@ void Foam::CloudFunctionObject::postFace const typename CloudType::parcelType& ) { - notImplemented - ( - "void Foam::CloudFunctionObject::postFace" - "(" - "const typename CloudType::parcelType&" - ")" - ); + // do nothing } diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H index 607e2a8bd9..0ea373d5cb 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObject/CloudFunctionObject.H @@ -129,6 +129,14 @@ public: //- Post-evolve hook virtual void postEvolve(); + //- Post-move hook + virtual void postMove + ( + const typename CloudType::parcelType& p, + const label cellI, + const scalar dt + ); + //- Post-patch hook virtual void postPatch ( diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C index e9bf670e63..7c9e715c78 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.C @@ -127,6 +127,21 @@ void Foam::CloudFunctionObjectList::postEvolve() } +template +void Foam::CloudFunctionObjectList::postMove +( + const typename CloudType::parcelType& p, + const label cellI, + const scalar dt +) +{ + forAll(*this, i) + { + this->operator[](i).postMove(p, cellI, dt); + } +} + + template void Foam::CloudFunctionObjectList::postPatch ( diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H index bffa812bda..edba8be4a4 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudFunctionObjectList/CloudFunctionObjectList.H @@ -109,6 +109,14 @@ public: //- Post-evolve hook virtual void postEvolve(); + //- Post-move hook + virtual void postMove + ( + const typename CloudType::parcelType& p, + const label cellI, + const scalar dt + ); + //- Post-patch hook virtual void postPatch ( From 13107697e396477a0677893d89a847caa3f0fc03 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Sep 2011 14:40:39 +0100 Subject: [PATCH 3/4] ENH: Added call to reset cloud source terms on construction --- .../spray/clouds/Templates/SprayCloud/SprayCloud.C | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloud.C b/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloud.C index a87007e3e1..67723a6e02 100644 --- a/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloud.C +++ b/src/lagrangian/spray/clouds/Templates/SprayCloud/SprayCloud.C @@ -110,6 +110,11 @@ Foam::SprayCloud::SprayCloud Info << "Average parcel mass: " << averageParcelMass_ << endl; } + + if (this->solution().resetSourcesOnStartup()) + { + CloudType::resetSourceTerms(); + } } From 9f9a64cedc9a0ecc037821661d718ef9057afa17 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Sep 2011 14:41:25 +0100 Subject: [PATCH 4/4] ENH: Added 'voidFraction' cloud function object --- .../include/makeParcelCloudFunctionObjects.H | 4 +- .../VoidFraction/VoidFraction.C | 137 ++++++++++++++++++ .../VoidFraction/VoidFraction.H | 137 ++++++++++++++++++ 3 files changed, 277 insertions(+), 1 deletion(-) create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.H diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H index 0a68bee908..6eadb7fea8 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 "ParticleTracks.H" #include "PatchPostProcessing.H" +#include "VoidFraction.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -40,7 +41,8 @@ License \ makeCloudFunctionObjectType(FacePostProcessing, CloudType); \ makeCloudFunctionObjectType(ParticleTracks, CloudType); \ - makeCloudFunctionObjectType(PatchPostProcessing, CloudType); + makeCloudFunctionObjectType(PatchPostProcessing, CloudType); \ + makeCloudFunctionObjectType(VoidFraction, CloudType); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C new file mode 100644 index 0000000000..855db45c88 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.C @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 "VoidFraction.H" +# +// * * * * * * * * * * * * * Protectd Member Functions * * * * * * * * * * * // + +template +void Foam::VoidFraction::write() +{ + if (thetaPtr_.valid()) + { + thetaPtr_->write(); + } + else + { + FatalErrorIn("void Foam::VoidFraction::write()") + << "thetaPtr not valid" << abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::VoidFraction::VoidFraction +( + const dictionary& dict, + CloudType& owner +) +: + CloudFunctionObject(owner), + thetaPtr_(NULL) +{} + + +template +Foam::VoidFraction::VoidFraction +( + const VoidFraction& vf +) +: + CloudFunctionObject(vf), + thetaPtr_(NULL) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::VoidFraction::~VoidFraction() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::VoidFraction::preEvolve() +{ + if (thetaPtr_.valid()) + { + thetaPtr_->internalField() = 0.0; + } + else + { + const fvMesh& mesh = this->owner().mesh(); + + thetaPtr_.reset + ( + new volScalarField + ( + IOobject + ( + this->owner().name() + "Theta", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimless, 0.0) + ) + ); + } +} + + +template +void Foam::VoidFraction::postEvolve() +{ + volScalarField& theta = thetaPtr_(); + + const fvMesh& mesh = this->owner().mesh(); + + theta.internalField() /= mesh.time().deltaTValue()*mesh.V(); + + CloudFunctionObject::postEvolve(); +} + + +template +void Foam::VoidFraction::postMove +( + const parcelType& p, + const label cellI, + const scalar dt +) +{ + volScalarField& theta = thetaPtr_(); + + theta[cellI] += dt*p.nParticle()*p.volume(); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.H new file mode 100644 index 0000000000..0b15a6f620 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/VoidFraction/VoidFraction.H @@ -0,0 +1,137 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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::VoidFraction + +Description + Creates particle void fraction field on carrier phase + +SourceFiles + VoidFraction.C + +\*---------------------------------------------------------------------------*/ + +#ifndef VoidFraction_H +#define VoidFraction_H + +#include "CloudFunctionObject.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class VoidFraction Declaration +\*---------------------------------------------------------------------------*/ + +template +class VoidFraction +: + public CloudFunctionObject +{ + // Private Data + + // Typedefs + + //- Convenience typedef for parcel type + typedef typename CloudType::parcelType parcelType; + + + //- Void fraction field + autoPtr thetaPtr_; + + +protected: + + // Protected Member Functions + + //- Write post-processing info + virtual void write(); + + +public: + + //- Runtime type information + TypeName("voidFraction"); + + + // Constructors + + //- Construct from dictionary + VoidFraction(const dictionary& dict, CloudType& owner); + + //- Construct copy + VoidFraction(const VoidFraction& vf); + + //- Construct and return a clone + virtual autoPtr > clone() const + { + return autoPtr > + ( + new VoidFraction(*this) + ); + } + + + //- Destructor + virtual ~VoidFraction(); + + + // Member Functions + + // Evaluation + + //- Pre-evolve hook + virtual void preEvolve(); + + //- Post-evolve hook + virtual void postEvolve(); + + //- Post-move hook + virtual void postMove + ( + const parcelType& p, + const label cellI, + const scalar dt + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "VoidFraction.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //