diff --git a/src/finiteVolume/finiteVolume/fvm/fvmSup.C b/src/finiteVolume/finiteVolume/fvm/fvmSup.C index 9ac65928dcbbe237f5c0eae2acc2b2cc9713aae4..dcf4d0fca1fd5907ab98d61082f325983c3cbeab 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmSup.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmSup.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,6 +54,7 @@ Foam::fvm::Su return tfvm; } + template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Su @@ -67,6 +68,7 @@ Foam::fvm::Su return tfvm; } + template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Su @@ -80,6 +82,7 @@ Foam::fvm::Su return tfvm; } + template<class Type> Foam::zeroField Foam::fvm::Su @@ -117,6 +120,7 @@ Foam::fvm::Sp return tfvm; } + template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Sp @@ -130,6 +134,7 @@ Foam::fvm::Sp return tfvm; } + template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Sp @@ -169,6 +174,7 @@ Foam::fvm::Sp return tfvm; } + template<class Type> Foam::zeroField Foam::fvm::Sp @@ -209,6 +215,7 @@ Foam::fvm::SuSp return tfvm; } + template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::SuSp @@ -222,6 +229,7 @@ Foam::fvm::SuSp return tfvm; } + template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::SuSp @@ -235,6 +243,7 @@ Foam::fvm::SuSp return tfvm; } + template<class Type> Foam::zeroField Foam::fvm::SuSp diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C index 757c3a8aa694ea642a152c44a9a9d64c08bfa80f..cbdf299df7ce4f1fdc19c03ecdde00e379e5db41 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C @@ -52,7 +52,47 @@ void Foam::FacePostProcessing<CloudType>::applyToFace faceI = j; return; } - } + } + } +} + + +template<class CloudType> +void Foam::FacePostProcessing<CloudType>::makeLogFile +( + const word& zoneName, + const label zoneI, + const label nFaces, + const scalar totArea +) +{ + // Create the output file if not already created + if (log_) + { + if (debug) + { + Info<< "Creating output file." << endl; + } + + if (Pstream::master()) + { + // Create directory if does not exist + mkDir(outputDir_); + + // Open new file at start up + outputFilePtr_.set + ( + zoneI, + new OFstream(outputDir_/(type() + '_' + zoneName + ".dat")) + ); + + outputFilePtr_[zoneI] + << "# Source : " << type() << nl + << "# Face zone : " << zoneName << nl + << "# Faces : " << nFaces << nl + << "# Area : " << totArea << nl + << "# Time" << tab << "mass" << tab << "massFlux" << endl; + } } } @@ -61,8 +101,9 @@ template<class CloudType> void Foam::FacePostProcessing<CloudType>::write() { const fvMesh& mesh = this->owner().mesh(); - const faceZoneMesh& fzm = this->owner().mesh().faceZones(); - const scalar dt = this->owner().time().deltaTValue(); + const Time& time = mesh.time(); + const faceZoneMesh& fzm = mesh.faceZones(); + const scalar dt = time.deltaTValue(); totalTime_ += dt; @@ -80,8 +121,11 @@ void Foam::FacePostProcessing<CloudType>::write() Info<< "particleFaceFlux output:" << nl; List<scalarField> zoneMassTotal(mass_.size()); - forAll(zoneMassTotal, zoneI) + List<scalarField> zoneMassFlux(massFlux_.size()); + forAll(faceZoneIDs_, zoneI) { + const word& zoneName = fzm[faceZoneIDs_[zoneI]].name(); + scalarListList allProcMass(Pstream::nProcs()); allProcMass[procI] = massTotal_[zoneI]; Pstream::gatherList(allProcMass); @@ -90,15 +134,8 @@ void Foam::FacePostProcessing<CloudType>::write() ( allProcMass, accessOp<scalarList>() ); + const scalar sumMassTotal = sum(zoneMassTotal[zoneI]); - const word& zoneName = fzm[faceZoneIDs_[zoneI]].name(); - Info<< " " << zoneName << " total mass = " - << sum(zoneMassTotal[zoneI]) << nl; - } - - List<scalarField> zoneMassFlux(massFlux_.size()); - forAll(zoneMassFlux, zoneI) - { scalarListList allProcMassFlux(Pstream::nProcs()); allProcMassFlux[procI] = massFlux_[zoneI]; Pstream::gatherList(allProcMassFlux); @@ -107,10 +144,19 @@ void Foam::FacePostProcessing<CloudType>::write() ( allProcMassFlux, accessOp<scalarList>() ); + const scalar sumMassFlux = sum(zoneMassFlux[zoneI]); - const word& zoneName = fzm[faceZoneIDs_[zoneI]].name(); - Info<< " " << zoneName << " average mass flux = " - << sum(zoneMassFlux[zoneI]) << nl; + Info<< " " << zoneName + << ": total mass = " << sumMassTotal + << "; average mass flux = " << sumMassFlux + << nl; + + if (outputFilePtr_.set(zoneI)) + { + OFstream& os = outputFilePtr_[zoneI]; + os << time.timeName() << token::TAB << sumMassTotal << token::TAB + << sumMassFlux<< endl; + } } Info<< endl; @@ -125,14 +171,12 @@ void Foam::FacePostProcessing<CloudType>::write() // Put in undecomposed case (Note: gives problems for // distributed data running) outputDir = - outputDir/".."/"postProcessing"/cloud::prefix/ - this->owner().name()/mesh.time().timeName(); + outputDir/".."/"postProcessing"/cloud::prefix/time.timeName(); } else { outputDir = - outputDir/"postProcessing"/cloud::prefix/ - this->owner().name()/mesh.time().timeName(); + outputDir/"postProcessing"/cloud::prefix/time.timeName(); } forAll(faceZoneIDs_, zoneI) @@ -247,15 +291,36 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing totalTime_(0.0), mass_(), massTotal_(), - massFlux_() + massFlux_(), + log_(this->coeffDict().lookup("log")), + outputFilePtr_(), + outputDir_(owner.mesh().time().path()) { wordList faceZoneNames(this->coeffDict().lookup("faceZones")); mass_.setSize(faceZoneNames.size()); massTotal_.setSize(faceZoneNames.size()); massFlux_.setSize(faceZoneNames.size()); + outputFilePtr_.setSize(faceZoneNames.size()); + + if (Pstream::parRun()) + { + // Put in undecomposed case (Note: gives problems for + // distributed data running) + outputDir_ = + outputDir_/".."/"postProcessing"/cloud::prefix/ + owner.name()/owner.mesh().time().timeName(); + } + else + { + outputDir_ = + outputDir_/"postProcessing"/cloud::prefix/ + owner.name()/owner.mesh().time().timeName(); + } + DynamicList<label> zoneIDs; const faceZoneMesh& fzm = owner.mesh().faceZones(); + const surfaceScalarField& magSf = owner.mesh().magSf(); forAll(faceZoneNames, i) { const word& zoneName = faceZoneNames[i]; @@ -269,6 +334,15 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing massTotal_[i].setSize(nFaces, 0.0); massFlux_[i].setSize(nFaces, 0.0); Info<< " " << zoneName << " faces: " << nFaces; + + scalar totArea = 0.0; + forAll(fz, j) + { + totArea += magSf[fz[j]]; + } + totArea = returnReduce(totArea, sumOp<scalar>()); + + makeLogFile(zoneName, i, nFaces, totArea); } } @@ -291,7 +365,10 @@ Foam::FacePostProcessing<CloudType>::FacePostProcessing totalTime_(pff.totalTime_), mass_(pff.mass_), massTotal_(pff.massTotal_), - massFlux_(pff.massFlux_) + massFlux_(pff.massFlux_), + log_(pff.log_), + outputFilePtr_(), + outputDir_(pff.outputDir_) {} diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H index 85a80b1a4ade6ed985f2f1a04bcbb21842251a73..3782306777f230dfd61716939cbb466b39f04381 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.H @@ -85,9 +85,27 @@ class FacePostProcessing //- Mass flux storage List<scalarField> massFlux_; + //- Flag to indicate whether data should be written to file + Switch log_; + + //- Output file pointer per zone + PtrList<OFstream> outputFilePtr_; + + //- Output directory + fileName outputDir_; + // Private Member Functions + //- Helper function to create log files + void makeLogFile + ( + const word& zoneName, + const label zoneI, + const label nFaces, + const scalar totArea + ); + //- Return index into storage lists if valid zone and face void applyToFace ( diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C index 3096c829d0d46132b7f96bdf679928b22df9b4b1..812296e6f5b1bb161dc732388d2d105ae56a6323 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,12 +92,14 @@ Foam::PairSpringSliderDashpot<CloudType>::PairSpringSliderDashpot alpha_(readScalar(this->coeffDict().lookup("alpha"))), b_(readScalar(this->coeffDict().lookup("b"))), mu_(readScalar(this->coeffDict().lookup("mu"))), + cohesionEnergyDensity_ + ( + readScalar(this->coeffDict().lookup("cohesionEnergyDensity")) + ), + cohesion_(false), collisionResolutionSteps_ ( - readScalar - ( - this->coeffDict().lookup("collisionResolutionSteps") - ) + readScalar(this->coeffDict().lookup("collisionResolutionSteps")) ), volumeFactor_(1.0), useEquivalentSize_(Switch(this->coeffDict().lookup("useEquivalentSize"))) @@ -116,6 +118,8 @@ Foam::PairSpringSliderDashpot<CloudType>::PairSpringSliderDashpot scalar G = E/(2.0*(1.0 + nu)); Gstar_ = G/(2.0*(2.0 - nu)); + + cohesion_ = (mag(cohesionEnergyDensity_) > VSMALL); } @@ -183,13 +187,15 @@ void Foam::PairSpringSliderDashpot<CloudType>::evaluatePair dBEff *= cbrt(pB.nParticle()*volumeFactor_); } - scalar normalOverlapMag = 0.5*(dAEff + dBEff) - mag(r_AB); + scalar r_AB_mag = mag(r_AB); + + scalar normalOverlapMag = 0.5*(dAEff + dBEff) - r_AB_mag; if (normalOverlapMag > 0) { //Particles in collision - vector rHat_AB = r_AB/(mag(r_AB) + VSMALL); + vector rHat_AB = r_AB/(r_AB_mag + VSMALL); vector U_AB = pA.U() - pB.U(); @@ -208,6 +214,15 @@ void Foam::PairSpringSliderDashpot<CloudType>::evaluatePair rHat_AB *(kN*pow(normalOverlapMag, b_) - etaN*(U_AB & rHat_AB)); + // Cohesion force + if (cohesion_) + { + fN_AB += + -cohesionEnergyDensity_ + *overlapArea(dAEff/2.0, dBEff/2.0, r_AB_mag) + *rHat_AB; + } + pA.f() += fN_AB; pB.f() += -fN_AB; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.H index d2c9071ae386d8d6cdbeab7b9e62a7bdd2b470de..e53f80babfc2527753023b3f2999376b2103b044 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairModel/PairSpringSliderDashpot/PairSpringSliderDashpot.H @@ -34,6 +34,7 @@ Description #include "PairModel.H" #include "CollisionRecordList.H" +#include "mathematicalConstants.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,6 +68,12 @@ class PairSpringSliderDashpot //- Coefficient of friction in for tangential sliding scalar mu_; + //- Cohesion energy density [J/m^3] + scalar cohesionEnergyDensity_; + + // Switch cohesion on and off + bool cohesion_; + //- The number of steps over which to resolve the minimum // harmonic approximation of the collision period scalar collisionResolutionSteps_; @@ -129,6 +136,23 @@ public: return volumeFactor_; } + // Return the area of overlap between two spheres of radii rA and rB, + // centres separated by a distance rAB. Assumes rAB < (rA + rB). + inline scalar overlapArea(scalar rA, scalar rB, scalar rAB) const + { + // From: + // http://mathworld.wolfram.com/Sphere-SphereIntersection.html + return + mathematical::pi/4.0 + /sqr(rAB) + *( + (-rAB + rA - rB) + *(-rAB - rA + rB) + *(-rAB + rA + rB) + *( rAB + rA + rA) + ); + } + //- Whether the PairModel has a timestep limit that will // require subCycling virtual bool controlsTimestep() const; diff --git a/src/turbulenceModels/compressible/turbulenceModel/Make/files b/src/turbulenceModels/compressible/turbulenceModel/Make/files index 8bd26ec944e639545dffdd4e8bc81a6e3830784d..4a2f2106c3b18a54e78bdaff2dc25bf158b7aed5 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/Make/files +++ b/src/turbulenceModels/compressible/turbulenceModel/Make/files @@ -6,6 +6,6 @@ derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C derivedFvPatchFields/turbulentTemperatureCoupledBaffle/turbulentTemperatureCoupledBaffleFvPatchScalarField.C derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C derivedFvPatchFields/turbulentTemperatureCoupledBaffle/regionProperties.C - +derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarFields.C LIB = $(FOAM_LIBBIN)/libcompressibleTurbulenceModel diff --git a/src/turbulenceModels/compressible/turbulenceModel/Make/options b/src/turbulenceModels/compressible/turbulenceModel/Make/options index 4f1694a48e6d5ee9fda733ec7c9c619ead89bb22..c9e7b7b0eea0c57469dae6d062cab9edbee7b746 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/Make/options +++ b/src/turbulenceModels/compressible/turbulenceModel/Make/options @@ -4,12 +4,14 @@ EXE_INC = \ -I$(LIB_SRC)/turbulenceModels \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude + -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solid/lnInclude LIB_LIBS = \ -lbasicSolidThermo \ -lbasicThermophysicalModels \ -lspecie \ -lfiniteVolume \ - -lmeshTools + -lmeshTools \ + -lsolid diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..ee926c706e489da8a063f18944c12ebc45d62857 --- /dev/null +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarField.C @@ -0,0 +1,378 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "volFields.H" +#include "surfaceFields.H" +#include "directMappedPatchBase.H" +#include "turbulenceModel.H" +#include "mapDistribute.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class solidType> +temperatureThermoBaffle1DFvPatchScalarField<solidType>:: +temperatureThermoBaffle1DFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(p, iF), + TName_("T"), + baffleActivated_(true), + thickness_(p.size()), + Qs_(p.size()), + solid_(NULL) +{} + + +template<class solidType> +temperatureThermoBaffle1DFvPatchScalarField<solidType>:: +temperatureThermoBaffle1DFvPatchScalarField +( + const temperatureThermoBaffle1DFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + TName_(ptf.TName_), + baffleActivated_(ptf.baffleActivated_), + thickness_(ptf.thickness_), + Qs_(ptf.Qs_), + solid_(ptf.solid_) +{} + + +template<class solidType> +temperatureThermoBaffle1DFvPatchScalarField<solidType>:: +temperatureThermoBaffle1DFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + TName_("T"), + baffleActivated_(readBool(dict.lookup("baffleActivated"))), + thickness_(scalarField("thickness", dict, p.size())), + Qs_(scalarField("Qs", dict, p.size())), + solid_(new solidThermoData(dict)) +{ + if (!isA<directMappedPatchBase>(this->patch().patch())) + { + FatalErrorIn + ( + "temperatureThermoBaffle1DFvPatchScalarField::" + "temperatureThermoBaffle1DFvPatchScalarField\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField<scalar, volMesh>& iF,\n" + " const dictionary& dict\n" + ")\n" + ) << "\n patch type '" << patch().type() + << "' not type '" << directMappedPatchBase::typeName << "'" + << "\n for patch " << patch().name() + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } + + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + if (dict.found("refValue") && baffleActivated_) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + } + else + { + // Start from user entered data. Assume zeroGradient. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 0.0; + } + +} + + +template<class solidType> +temperatureThermoBaffle1DFvPatchScalarField<solidType>:: +temperatureThermoBaffle1DFvPatchScalarField +( + const temperatureThermoBaffle1DFvPatchScalarField& ptf +) +: + mixedFvPatchScalarField(ptf), + TName_(ptf.TName_), + baffleActivated_(ptf.baffleActivated_), + thickness_(ptf.thickness_), + Qs_(ptf.Qs_), + solid_(ptf.solid_) +{} + + +template<class solidType> +temperatureThermoBaffle1DFvPatchScalarField<solidType>:: +temperatureThermoBaffle1DFvPatchScalarField +( + const temperatureThermoBaffle1DFvPatchScalarField& ptf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(ptf, iF), + TName_(ptf.TName_), + baffleActivated_(ptf.baffleActivated_), + thickness_(ptf.thickness_), + Qs_(ptf.Qs_), + solid_(ptf.solid_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class solidType> +void temperatureThermoBaffle1DFvPatchScalarField<solidType>::autoMap +( + const fvPatchFieldMapper& m +) +{ + mixedFvPatchScalarField::autoMap(m); +} + +template<class solidType> +void temperatureThermoBaffle1DFvPatchScalarField<solidType>::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); +} + + +template<class solidType> +void temperatureThermoBaffle1DFvPatchScalarField<solidType>::updateCoeffs() +{ + if (updated()) + { + return; + } + + + const directMappedPatchBase& mpp = refCast<const directMappedPatchBase> + ( + patch().patch() + ); + + const label patchI = patch().index(); + + const label nbrPatchI = mpp.samplePolyPatch().index(); + + if (baffleActivated_) + { + + const fvPatch& nbrPatch = + patch().boundaryMesh()[mpp.samplePolyPatch().index()]; + + const compressible::turbulenceModel& model = + db().template lookupObject<compressible::turbulenceModel> + ( + "turbulenceModel" + ); + + + // local properties + const scalarField alphaw = model.alphaEff()().boundaryField()[patchI]; + + const fvPatchScalarField& hw = + model.thermo().h().boundaryField()[patchI]; + + const scalarField qDot(alphaw*hw.snGrad()); + + const scalarField& Tp = + patch().template lookupPatchField<volScalarField, scalar>(TName_); + + tmp<scalarField> Ti = patchInternalField(); + + const scalarField Cpw(model.thermo().Cp(Ti, patchI)); + + scalarField myh = patch().deltaCoeffs()*alphaw*Cpw; + + scalarField alphawCp(alphaw*Cpw); + + + // nbr properties + scalarField nbrAlphaw = + model.alphaEff()().boundaryField()[nbrPatchI]; + mpp.map().distribute(nbrAlphaw); + + const fvPatchScalarField& nbrHw = + model.thermo().h().boundaryField()[nbrPatchI]; + + scalarField nbrQDot + ( + model.alphaEff()().boundaryField()[nbrPatchI]*nbrHw.snGrad() + ); + mpp.map().distribute(nbrQDot); + + scalarField nbrTp = + nbrPatch.template lookupPatchField<volScalarField, scalar>(TName_); + mpp.map().distribute(nbrTp); + + const temperatureThermoBaffle1DFvPatchScalarField& nbrField = + refCast<const temperatureThermoBaffle1DFvPatchScalarField> + ( + nbrPatch.template lookupPatchField<volScalarField, scalar> + ( + TName_ + ) + ); + + scalarField nbrTi(nbrField.patchInternalField()); + mpp.map().distribute(nbrTi); + + const scalarField nbrCpw = model.thermo().Cp + ( + nbrField.patchInternalField(), + nbrPatchI + ); + + scalarField nbrh = + nbrPatch.deltaCoeffs()*nbrCpw + *model.alphaEff()().boundaryField()[nbrPatchI]; + + mpp.map().distribute(nbrh); + + + // heat source + const scalarField Q(Qs_/thickness_); + + tmp<scalarField> tKDeltaw(new scalarField(patch().size())); + scalarField KDeltaw = tKDeltaw(); + + // Create fields for solid properties + forAll(KDeltaw, i) + { + KDeltaw[i] = solid_().K((Tp[i] + nbrTp[i])/2.0)/thickness_[i]; + } + + const scalarField q = + (Ti() - nbrTi)/(1.0/KDeltaw + 1.0/nbrh + 1.0/myh); + + forAll(qDot, i) + { + if (Qs_[i] == 0) + { + this->refValue()[i] = Ti()[i] - q[i]/myh[i]; + this->refGrad()[i] = 0.0; + this->valueFraction()[i] = 1.0; + } + else + { + if (q[i] > 0) + { + this->refValue()[i] = + nbrTp[i] + - Q[i]*thickness_[i]/(2*KDeltaw[i]); + + this->refGrad()[i] = 0.0; + this->valueFraction()[i] = + 1.0 + / + ( + 1.0 + + patch().deltaCoeffs()[i]*alphawCp[i]/KDeltaw[i] + ); + } + else if (q[i] < 0) + { + this->refValue()[i] = 0.0; + this->refGrad()[i] = + (-nbrQDot[i] + Q[i]*thickness_[i])/alphawCp[i]; + this->valueFraction()[i] = 0.0; + } + else + { + scalar Qt = Q[i]*thickness_[i]; + this->refValue()[i] = 0.0; + this->refGrad()[i] = Qt/2/alphawCp[i]; + this->valueFraction()[i] = 0.0; + } + } + } + + if (debug) + { + scalar Q = gSum(patch().magSf()*qDot); + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " <- " + << nbrPatch.name() << ':' + << this->dimensionedInternalField().name() << " :" + << " heat[W]:" << Q + << " walltemperature " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } + } + + mixedFvPatchScalarField::updateCoeffs(); +} + +template <class solidType> +void temperatureThermoBaffle1DFvPatchScalarField<solidType>:: +write(Ostream& os) const +{ + mixedFvPatchScalarField::write(os); + os.writeKeyword("TName") + << TName_ << token::END_STATEMENT << nl; + thickness_.writeEntry("thickness", os); + os.writeKeyword("baffleActivated") + << baffleActivated_ << token::END_STATEMENT << nl; + Qs_.writeEntry("Qs", os); + solid_().write(os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarField.H b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..5c7c998c6a43d01d09cfa60a192a891ae83063f4 --- /dev/null +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarField.H @@ -0,0 +1,249 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::temperatureThermoBaffle1DFvPatchScalarField + +Description + Bounday which solves the 1D steady state heat transfer equation + through a baffle. + +SourceFiles + temperatureThermoBaffle1DFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef temperatureThermoBaffle1DFvPatchScalarField_H +#define temperatureThermoBaffle1DFvPatchScalarField_H + +#include "mixedFvPatchFields.H" +#include "autoPtr.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class temperatureThermoBaffle1DFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +template<class solidType> +class temperatureThermoBaffle1DFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + class solidThermoData + { + // Solid thermo + autoPtr<solidType> solidPtr_; + + // Solid dictionaries + dictionary transportDict_; + dictionary radiationDict_; + dictionary thermoDict_; + dictionary densityDict_; + + + public: + + // Constructor from components + solidThermoData(const dictionary& dict) + : + solidPtr_(new solidType(dict)), + transportDict_(dict.subDict("transportProperties")), + radiationDict_(dict.subDict("radiativeProperties")), + thermoDict_(dict.subDict("thermoProperties")), + densityDict_(dict.subDict("densityProperties")) + {} + + + // Null constructor + solidThermoData() + : + solidPtr_(), + transportDict_(), + radiationDict_(), + thermoDict_(), + densityDict_() + {} + + + // Destructor + virtual ~solidThermoData() + {} + + + // Member Functions + + void write(Ostream& os) const + { + os.writeKeyword("transportProperties"); + os << transportDict_ << nl; + os.writeKeyword("radiativeProperties"); + os << radiationDict_ << nl; + os.writeKeyword("thermoProperties"); + os << thermoDict_ << nl; + os.writeKeyword("densityProperties"); + os << densityDict_ << nl; + } + + + scalar K(const scalar T) const + { + return solidPtr_().K(T); + } + }; + + + //- Name of the temperature field + word TName_; + + //- Baffle is activated + bool baffleActivated_; + + //- Baffle thickness [m] + scalarField thickness_; + + //- Superficial heat source [W/m2] + scalarField Qs_; + + //- Solid thermo + autoPtr<solidThermoData> solid_; + + +public: + + //- Runtime type information + TypeName("compressible::temperatureThermoBaffle1D"); + + + // Constructors + + //- Construct from patch and internal field + temperatureThermoBaffle1DFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + temperatureThermoBaffle1DFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // temperatureThermoBaffle1DFvPatchScalarField onto a new patch + temperatureThermoBaffle1DFvPatchScalarField + ( + const temperatureThermoBaffle1DFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + temperatureThermoBaffle1DFvPatchScalarField + ( + const temperatureThermoBaffle1DFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new temperatureThermoBaffle1DFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + temperatureThermoBaffle1DFvPatchScalarField + ( + const temperatureThermoBaffle1DFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new temperatureThermoBaffle1DFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "temperatureThermoBaffle1DFvPatchScalarField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarFields.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarFields.C new file mode 100644 index 0000000000000000000000000000000000000000..b7c97a968d862c7632acdab87feedf710ef5f393 --- /dev/null +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarFields.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "temperatureThermoBaffle1DFvPatchScalarFields.H" +#include "addToRunTimeSelectionTable.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTemplateTypeNameAndDebugWithName +( + constSolid_temperatureThermoBaffle1DFvPatchScalarField, + "compressible::temperatureThermoBaffle1D<constSolidThermoPhysics>", + 0 +); + +addToPatchFieldRunTimeSelection +( + fvPatchScalarField, + constSolid_temperatureThermoBaffle1DFvPatchScalarField +); + +defineTemplateTypeNameAndDebugWithName +( + expoSolid_temperatureThermoBaffle1DFvPatchScalarField, + "compressible::temperatureThermoBaffle1D<expoSolidThermoPhysics>", + 0 +); + +addToPatchFieldRunTimeSelection +( + fvPatchScalarField, + expoSolid_temperatureThermoBaffle1DFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam +// ************************************************************************* // diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarFields.H b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarFields.H new file mode 100644 index 0000000000000000000000000000000000000000..11f9e068b8e4cbd23869bf6ab603f0e33128bee8 --- /dev/null +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/temperatureThermoBaffle1D/temperatureThermoBaffle1DFvPatchScalarFields.H @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef temperatureThermoBaffle1DFvPatchScalarFields_H +#define temperatureThermoBaffle1DFvPatchScalarFields_H + +#include "temperatureThermoBaffle1DFvPatchScalarField.H" +#include "solidThermoPhysicsTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + typedef temperatureThermoBaffle1DFvPatchScalarField + < + constSolidThermoPhysics + >constSolid_temperatureThermoBaffle1DFvPatchScalarField; + + typedef temperatureThermoBaffle1DFvPatchScalarField + < + expoSolidThermoPhysics + >expoSolid_temperatureThermoBaffle1DFvPatchScalarField; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties index 253b33246017170df7c1a76f26302f0986d6bad7..7422e40c4404239739ae9f0e11a19ade0b78adca 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties @@ -82,6 +82,7 @@ subModels pairCollisionCoeffs { + // Maximum possible particle diameter expected at any time maxInteractionDistance 0.006; writeReferredParticleCloud no; @@ -94,6 +95,7 @@ subModels alpha 0.12; b 1.5; mu 0.52; + cohesionEnergyDensity 0; collisionResolutionSteps 12; }; diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties index 93315fbd6307c26b1551ca1564e8b288071179be..36448f7b3072cd013d7d88f700374341ec2868ac 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties @@ -91,6 +91,7 @@ subModels pairCollisionCoeffs { + // Maximum possible particle diameter expected at any time maxInteractionDistance 0.006; writeReferredParticleCloud no; @@ -103,6 +104,7 @@ subModels alpha 0.12; b 1.5; mu 0.52; + cohesionEnergyDensity 0; collisionResolutionSteps 12; };