diff --git a/src/lagrangian/coalCombustion/Make/options b/src/lagrangian/coalCombustion/Make/options index 04b133ba05..87e1d6a710 100644 --- a/src/lagrangian/coalCombustion/Make/options +++ b/src/lagrangian/coalCombustion/Make/options @@ -18,6 +18,7 @@ EXE_INC = \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ -I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude @@ -43,6 +44,7 @@ LIB_LIBS = \ -lincompressibleTransportModels \ -lregionModels \ -lsurfaceFilmModels \ + -ldynamicMesh \ -ldynamicFvMesh \ -lfiniteVolume \ -lmeshTools diff --git a/src/lagrangian/intermediate/Make/files b/src/lagrangian/intermediate/Make/files index 9cadf55117..3abb93961e 100644 --- a/src/lagrangian/intermediate/Make/files +++ b/src/lagrangian/intermediate/Make/files @@ -1,3 +1,5 @@ +submodels/CloudFunctionObjects/CloudToVTK/vtkTools.C + PARCELS=parcels BASEPARCELS=$(PARCELS)/baseClasses DERIVEDPARCELS=$(PARCELS)/derived diff --git a/src/lagrangian/intermediate/Make/options b/src/lagrangian/intermediate/Make/options index a5a3b3c8eb..dc893c1148 100644 --- a/src/lagrangian/intermediate/Make/options +++ b/src/lagrangian/intermediate/Make/options @@ -14,6 +14,7 @@ EXE_INC = \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ -I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ @@ -35,6 +36,7 @@ LIB_LIBS = \ -lincompressibleTransportModels \ -lregionModels \ -lsurfaceFilmModels \ + -ldynamicMesh \ -ldynamicFvMesh \ -lsampling \ -lfiniteVolume \ diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C index 8a0001f842..975ab88366 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,11 +28,7 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::cloudSolution::cloudSolution -( - const fvMesh& mesh, - const dictionary& dict -) +Foam::cloudSolution::cloudSolution(const fvMesh& mesh, const dictionary& dict) : mesh_(mesh), dict_(dict), @@ -42,6 +38,7 @@ Foam::cloudSolution::cloudSolution maxCo_(0.3), iter_(1), trackTime_(0.0), + deltaTMax_(GREAT), coupled_(false), cellValueSourceCorrection_(false), maxTrackTime_(0.0), @@ -52,13 +49,25 @@ Foam::cloudSolution::cloudSolution { read(); } + else + { + // see if existing source terms should be reset + const dictionary sourceTerms(dict_.subOrEmptyDict("sourceTerms")); + sourceTerms.readIfPresent("resetOnStartup", resetSourcesOnStartup_); + + if (resetSourcesOnStartup_) + { + Info<< "Cloud source terms will be reset" << endl; + } + else + { + Info<< "Cloud source terms will be held constant" << endl; + } + } } -Foam::cloudSolution::cloudSolution -( - const cloudSolution& cs -) +Foam::cloudSolution::cloudSolution(const cloudSolution& cs) : mesh_(cs.mesh_), dict_(cs.dict_), @@ -68,6 +77,7 @@ Foam::cloudSolution::cloudSolution maxCo_(cs.maxCo_), iter_(cs.iter_), trackTime_(cs.trackTime_), + deltaTMax_(cs.deltaTMax_), coupled_(cs.coupled_), cellValueSourceCorrection_(cs.cellValueSourceCorrection_), maxTrackTime_(cs.maxTrackTime_), @@ -76,10 +86,7 @@ Foam::cloudSolution::cloudSolution {} -Foam::cloudSolution::cloudSolution -( - const fvMesh& mesh -) +Foam::cloudSolution::cloudSolution(const fvMesh& mesh) : mesh_(mesh), dict_(dictionary::null), @@ -89,6 +96,7 @@ Foam::cloudSolution::cloudSolution maxCo_(GREAT), iter_(0), trackTime_(0.0), + deltaTMax_(GREAT), coupled_(false), cellValueSourceCorrection_(false), maxTrackTime_(0.0), @@ -111,6 +119,7 @@ void Foam::cloudSolution::read() dict_.lookup("coupled") >> coupled_; dict_.lookup("cellValueSourceCorrection") >> cellValueSourceCorrection_; dict_.readIfPresent("maxCo", maxCo_); + dict_.readIfPresent("deltaTMax", deltaTMax_); if (steadyState()) { @@ -229,4 +238,23 @@ bool Foam::cloudSolution::output() const } +Foam::scalar Foam::cloudSolution::deltaTMax(const scalar trackTime) const +{ + if (transient_) + { + return min(deltaTMax_, maxCo_*trackTime); + } + else + { + return min(deltaTMax_, trackTime); + } +} + + +Foam::scalar Foam::cloudSolution::deltaLMax(const scalar lRef) const +{ + return maxCo_*lRef; +} + + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.H index e155abc375..01e5c88025 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.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-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,6 +80,9 @@ class cloudSolution //- Particle track time scalar trackTime_; + //- Maximum integration time step (optional) + scalar deltaTMax_; + // Run-time options @@ -171,6 +174,9 @@ public: //- Return the particle track time inline scalar trackTime() const; + //- Return the maximum integation time step + inline scalar deltaTMax() const; + //- Return const access to the coupled flag inline const Switch coupled() const; @@ -207,6 +213,12 @@ public: //- Returns true if writing this step bool output() const; + + //- Return the maximum integration time + scalar deltaTMax(const scalar trackTime) const; + + //- Return the maximum integration length + scalar deltaLMax(const scalar lRef) const; }; diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolutionI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolutionI.H index 6280b97837..27b0b38fde 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolutionI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolutionI.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-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -101,6 +101,12 @@ inline Foam::scalar Foam::cloudSolution::trackTime() const } +inline Foam::scalar Foam::cloudSolution::deltaTMax() const +{ + return deltaTMax_; +} + + inline Foam::Switch& Foam::cloudSolution::coupled() { return coupled_; diff --git a/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C b/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C index 8c7c2cbb55..49d60b1c6a 100644 --- a/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/MPPICCloud/MPPICCloud.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,25 +80,25 @@ Foam::MPPICCloud::MPPICCloud dampingModel_(NULL), isotropyModel_(NULL) { - if (this->solution().steadyState()) - { - FatalErrorIn - ( - "Foam::MPPICCloud::MPPICCloud" - "(" - "const word&, " - "const volScalarField&, " - "const volVectorField&, " - "const volScalarField&, " - "const dimensionedVector&, " - "bool" - ")" - ) << "MPPIC modelling not available for steady state calculations" - << exit(FatalError); - } - if (this->solution().active()) { + if (this->solution().steadyState()) + { + FatalErrorIn + ( + "Foam::MPPICCloud::MPPICCloud" + "(" + "const word&, " + "const volScalarField&, " + "const volVectorField&, " + "const volScalarField&, " + "const dimensionedVector&, " + "bool" + ")" + ) << "MPPIC modelling not available for steady state calculations" + << exit(FatalError); + } + setModels(); if (readFields) diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index 69666fedde..24c9cc1b9d 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-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -51,10 +51,7 @@ void Foam::ThermoCloud::setModels() ).ptr() ); - if (this->solution().coupled()) - { - this->subModelProperties().lookup("radiation") >> radiation_; - } + this->subModelProperties().lookup("radiation") >> radiation_; if (radiation_) { diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C index 36f146d77a..b765d4d285 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,6 +69,8 @@ bool Foam::CollidingParcel::move typename TrackData::cloudType::parcelType& p = static_cast(*this); + td.keepParticle = true; + switch (td.part()) { case TrackData::tpVelocityHalfStep: diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index f34f4b2f28..6a96921be3 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,6 +27,7 @@ License #include "forceSuSp.H" #include "IntegrationScheme.H" #include "meshTools.H" +#include "cloudSolution.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -271,15 +272,11 @@ bool Foam::KinematicParcel::move const polyMesh& mesh = td.cloud().pMesh(); const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); + const cloudSolution& solution = td.cloud().solution(); const scalarField& cellLengthScale = td.cloud().cellLengthScale(); - const scalar maxCo = td.cloud().solution().maxCo(); scalar tEnd = (1.0 - p.stepFraction())*trackTime; - scalar dtMax = trackTime; - if (td.cloud().solution().transient()) - { - dtMax *= maxCo; - } + scalar dtMax = solution.deltaTMax(trackTime); bool tracking = true; label nTrackingStalled = 0; @@ -301,7 +298,8 @@ bool Foam::KinematicParcel::move if (p.active() && tracking && (magU > ROOTVSMALL)) { const scalar d = dt*magU; - const scalar dCorr = min(d, maxCo*cellLengthScale[cellI]); + const scalar deltaLMax = solution.deltaLMax(cellLengthScale[cellI]); + const scalar dCorr = min(d, deltaLMax); dt *= dCorr/d *p.trackToFace(p.position() + dCorr*U_/magU, td); @@ -309,7 +307,7 @@ bool Foam::KinematicParcel::move tEnd -= dt; - scalar newStepFraction = 1.0 - tEnd/trackTime; + const scalar newStepFraction = 1.0 - tEnd/trackTime; if (tracking) { @@ -335,7 +333,7 @@ bool Foam::KinematicParcel::move p.stepFraction() = newStepFraction; bool calcParcel = true; - if (!tracking && td.cloud().solution().steadyState()) + if (!tracking && solution.steadyState()) { calcParcel = false; } @@ -346,7 +344,7 @@ bool Foam::KinematicParcel::move // Update cell based properties p.setCellValues(td, dt, cellI); - if (td.cloud().solution().cellValueSourceCorrection()) + if (solution.cellValueSourceCorrection()) { p.cellValueSourceCorrection(td, dt, cellI); } @@ -466,6 +464,8 @@ void Foam::KinematicParcel::hitPatch ) { td.keepParticle = false; + + td.cloud().patchInteraction().addToEscapedParcels(nParticle_*mass()); } diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C index 289127b18b..2f050e26ae 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C @@ -121,7 +121,13 @@ Foam::scalar Foam::ReactingMultiphaseParcel::updateMassFractions YMix[GAS] = massGas/massNew; YMix[LIQ] = massLiquid/massNew; - YMix[SLD] = 1.0 - YMix[GAS] - YMix[LIQ]; + YMix[SLD] = massSolid/massNew; + + scalar Ytotal = sum(YMix); + + YMix[GAS] /= Ytotal; + YMix[LIQ] /= Ytotal; + YMix[SLD] /= Ytotal; return massNew; } diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C index 4198420d38..ae5f386411 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C @@ -80,6 +80,9 @@ void Foam::ThermoParcel::cellValueSourceCorrection this->Uc_ += td.cloud().UTrans()[cellI]/this->massCell(cellI); const scalar CpMean = td.CpInterp().psi()[cellI]; + + tetIndices tetIs = this->currentTetIndices(); + Tc_ = td.TInterp().interpolate(this->position(), tetIs); Tc_ += td.cloud().hsTrans()[cellI]/(CpMean*this->massCell(cellI)); if (Tc_ < td.cloud().constProps().TMin()) diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H index 783878f480..a181ae19b1 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,6 +28,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "CloudToVTK.H" #include "FacePostProcessing.H" #include "ParticleCollector.H" #include "ParticleErosion.H" @@ -42,6 +43,7 @@ License \ makeCloudFunctionObject(CloudType); \ \ + makeCloudFunctionObjectType(CloudToVTK, CloudType); \ makeCloudFunctionObjectType(FacePostProcessing, CloudType); \ makeCloudFunctionObjectType(ParticleCollector, CloudType); \ makeCloudFunctionObjectType(ParticleErosion, CloudType); \ diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudToVTK/CloudToVTK.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudToVTK/CloudToVTK.C new file mode 100644 index 0000000000..240154edf3 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/CloudToVTK/CloudToVTK.C @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "CloudToVTK.H" +#include "vtkTools.H" +#include "floatScalar.H" + +// * * * * * * * * * * * * * Protectd Member Functions * * * * * * * * * * * // + +template +void Foam::CloudToVTK::writeData +( + std::ostream& vtkOs, + const bool binary, + const List& data +) const +{ + const label procI = Pstream::myProcNo(); + + List > allProcData(Pstream::nProcs()); + allProcData[procI] = data; + Pstream::gatherList(allProcData); + List allData = + ListListOps::combine > + ( + allProcData, + accessOp >() + ); + + vtkTools::write(vtkOs, binary, allData); +} + + +template +template +void Foam::CloudToVTK::writeFieldData +( + std::ostream& vtkOs, + const bool binary, + const List& data, + const word& title, + const label nParcels +) const +{ + vtkOs + << title << ' ' << pTraits::nComponents << ' ' + << nParcels << " float" << std::endl; + writeData(vtkOs, binary, data); +} + + +template +void Foam::CloudToVTK::write() +{ + label nParcels = this->owner().size(); + DynamicList position(3*nParcels); + DynamicList U(3*nParcels); + DynamicList d(nParcels); + DynamicList age(nParcels); + DynamicList rho(nParcels); + + forAllConstIter(typename CloudType, this->owner(), iter) + { + vtkTools::insert(iter().position(), position); + vtkTools::insert(iter().U(), U); + vtkTools::insert(iter().d(), d); + vtkTools::insert(iter().age(), age); + vtkTools::insert(iter().rho(), rho); + } + + reduce(nParcels, sumOp