From e0eb0c03a95c9c6dfcfea576aeebbab95499f508 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 27 Sep 2011 14:44:33 +0100 Subject: [PATCH 1/7] ENH: Added reverseDistribute helper to mappedPatchBase --- .../mappedPolyPatch/mappedPatchBase.H | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H index 34c7fa5479..79c5d6d8ad 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H @@ -339,6 +339,26 @@ public: } + //- Wrapper around map/interpolate data distribution + template + void reverseDistribute(List& lst) const + { + switch (mode_) + { + case NEARESTPATCHFACEAMI: + { + lst = AMI().interpolateToTarget(Field(lst.xfer())); + break; + } + default: + { + label cSize = patch_.size(); + map().reverseDistribute(cSize, lst); + } + } + } + + //- Return reference to the parallel distribution map const mapDistribute& map() const { From e13a06be66d8a5782dffc05bbdb8e0f183d01923 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 27 Sep 2011 14:51:28 +0100 Subject: [PATCH 2/7] BUG: Film diameter initialised to 0 instead of -1 - broke with AMI functionality --- .../kinematicSingleLayer/kinematicSingleLayer.C | 2 +- .../injectionModel/drippingInjection/drippingInjection.C | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 461fbd10ae..a448083f99 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -827,7 +827,7 @@ void kinematicSingleLayer::preEvolveRegion() // availableMass_ = mass(); availableMass_ = netMass(); cloudMassTrans_ == dimensionedScalar("zero", dimMass, 0.0); - cloudDiameterTrans_ == dimensionedScalar("zero", dimLength, -1.0); + cloudDiameterTrans_ == dimensionedScalar("zero", dimLength, 0.0); } diff --git a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/drippingInjection/drippingInjection.C b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/drippingInjection/drippingInjection.C index 076e6abb23..e271674b10 100644 --- a/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/drippingInjection/drippingInjection.C +++ b/src/regionModels/surfaceFilmModels/submodels/kinematic/injectionModel/drippingInjection/drippingInjection.C @@ -139,7 +139,7 @@ void drippingInjection::correct { // Mass below minimum threshold - cannot be injected massToInject[cellI] = 0.0; - diameterToInject[cellI] = -1.0; + diameterToInject[cellI] = 0.0; } } } From e26ce06560f1e8c7c0acc52aad7650de24ab7dab Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 27 Sep 2011 14:52:01 +0100 Subject: [PATCH 3/7] ENH: Tidied surface film mapping functionality --- .../mappedField/mappedFieldFvPatchField.C | 1 - .../SurfaceFilmModel/SurfaceFilmModel.C | 51 ++++++------ .../SurfaceFilmModel/SurfaceFilmModel.H | 1 - .../ThermoSurfaceFilm/ThermoSurfaceFilm.C | 6 +- .../ThermoSurfaceFilm/ThermoSurfaceFilm.H | 1 - ...ysisTemperatureCoupledFvPatchScalarField.C | 10 +-- ...rolysisVelocityCoupledFvPatchVectorField.C | 10 +-- .../regionModel/regionModel/regionModel.C | 24 +----- .../regionModel/regionModel/regionModel.H | 31 +++++-- .../regionModel/regionModel/regionModelI.H | 7 -- .../regionModel/regionModelTemplates.C | 80 +++++++++++++++++++ ...alphatFilmWallFunctionFvPatchScalarField.C | 4 +- .../mutkFilmWallFunctionFvPatchScalarField.C | 4 +- .../thermoSingleLayer/thermoSingleLayer.C | 9 +-- 14 files changed, 148 insertions(+), 91 deletions(-) create mode 100644 src/regionModels/regionModel/regionModel/regionModelTemplates.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C index 19aeaa4a5a..ae597b4bfc 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/mappedFieldFvPatchField.C @@ -227,7 +227,6 @@ void mappedFieldFvPatchField::updateCoeffs() const fieldType& nbrField = sampleField(); - const mapDistribute& distMap = mappedPatchBase::map(); newValues = nbrField.boundaryField()[nbrPatchID]; this->distribute(newValues); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C index 36dca28f6a..d080a624a2 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.C @@ -114,8 +114,8 @@ bool Foam::SurfaceFilmModel::transferParcel "bool Foam::SurfaceFilmModel::transferParcel" "(" "parcelType&, " - "const label, " - "const bool&" + "const polyPatch&, " + "bool&" ")" ); @@ -156,11 +156,9 @@ void Foam::SurfaceFilmModel::inject(TrackData& td) const label filmPatchI = filmPatches[i]; const label primaryPatchI = primaryPatches[i]; - const mappedPatchBase& mapPatch = filmModel.mappedPatches()[filmPatchI]; - const labelList& injectorCellsPatch = pbm[primaryPatchI].faceCells(); - cacheFilmFields(filmPatchI, primaryPatchI, mapPatch, filmModel); + cacheFilmFields(filmPatchI, primaryPatchI, filmModel); const vectorField& Cf = mesh.C().boundaryField()[primaryPatchI]; const vectorField& Sf = mesh.Sf().boundaryField()[primaryPatchI]; @@ -172,13 +170,11 @@ void Foam::SurfaceFilmModel::inject(TrackData& td) { const label cellI = injectorCellsPatch[j]; - // The position is at the cell centre, which could be - // in any tet of the decomposed cell, so arbitrarily - // choose the first face of the cell as the tetFace - // and the first point on the face after the base - // point as the tetPt. The tracking will - // pick the cell consistent with the motion in the - // first tracking step. + // The position could bein any tet of the decomposed cell, + // so arbitrarily choose the first face of the cell as the + // tetFace and the first point on the face after the base + // point as the tetPt. The tracking will pick the cell + // consistent with the motion in the first tracking step. const label tetFaceI = this->owner().mesh().cells()[cellI][0]; const label tetPtI = 1; @@ -208,14 +204,22 @@ void Foam::SurfaceFilmModel::inject(TrackData& td) setParcelProperties(*pPtr, j); - // Check new parcel properties -// td.cloud().checkParcelProperties(*pPtr, 0.0, true); - td.cloud().checkParcelProperties(*pPtr, 0.0, false); + if (pPtr->nParticle() > 0.001) + { + // Check new parcel properties + // td.cloud().checkParcelProperties(*pPtr, 0.0, true); + td.cloud().checkParcelProperties(*pPtr, 0.0, false); - // Add the new parcel to the cloud - td.cloud().addParticle(pPtr); + // Add the new parcel to the cloud + td.cloud().addParticle(pPtr); - nParcelsInjected_++; + nParcelsInjected_++; + } + else + { + // TODO: cache mass and re-distribute? + delete pPtr; + } } } } @@ -227,26 +231,25 @@ void Foam::SurfaceFilmModel::cacheFilmFields ( const label filmPatchI, const label primaryPatchI, - const mappedPatchBase& mapPatch, const regionModels::surfaceFilmModels::surfaceFilmModel& filmModel ) { massParcelPatch_ = filmModel.cloudMassTrans().boundaryField()[filmPatchI]; - mapPatch.distribute(massParcelPatch_); + filmModel.toPrimary(filmPatchI, massParcelPatch_); diameterParcelPatch_ = filmModel.cloudDiameterTrans().boundaryField()[filmPatchI]; - mapPatch.distribute(diameterParcelPatch_); + filmModel.toPrimary(filmPatchI, diameterParcelPatch_); UFilmPatch_ = filmModel.Us().boundaryField()[filmPatchI]; - mapPatch.distribute(UFilmPatch_); + filmModel.toPrimary(filmPatchI, UFilmPatch_); rhoFilmPatch_ = filmModel.rho().boundaryField()[filmPatchI]; - mapPatch.distribute(rhoFilmPatch_); + filmModel.toPrimary(filmPatchI, rhoFilmPatch_); deltaFilmPatch_[primaryPatchI] = filmModel.delta().boundaryField()[filmPatchI]; - mapPatch.distribute(deltaFilmPatch_[primaryPatchI]); + filmModel.toPrimary(filmPatchI, deltaFilmPatch_[primaryPatchI]); } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.H b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.H index ae35db7ec5..967e748f56 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/SurfaceFilmModel/SurfaceFilmModel/SurfaceFilmModel.H @@ -116,7 +116,6 @@ protected: ( const label filmPatchI, const label primaryPatchI, - const mappedPatchBase& mapPatch, const regionModels::surfaceFilmModels::surfaceFilmModel& filmModel ); diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C b/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C index c6f4b4054a..6a6c60db39 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.C @@ -643,7 +643,6 @@ void Foam::ThermoSurfaceFilm::cacheFilmFields ( const label filmPatchI, const label primaryPatchI, - const mappedPatchBase& mapPatch, const regionModels::surfaceFilmModels::surfaceFilmModel& filmModel ) { @@ -651,15 +650,14 @@ void Foam::ThermoSurfaceFilm::cacheFilmFields ( filmPatchI, primaryPatchI, - mapPatch, filmModel ); TFilmPatch_ = filmModel.Ts().boundaryField()[filmPatchI]; - mapPatch.distribute(TFilmPatch_); + filmModel.toPrimary(filmPatchI, TFilmPatch_); CpFilmPatch_ = filmModel.Cp().boundaryField()[filmPatchI]; - mapPatch.distribute(CpFilmPatch_); + filmModel.toPrimary(filmPatchI, CpFilmPatch_); } diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.H b/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.H index 66bd139568..bddbfcc66e 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.H +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/SurfaceFilmModel/ThermoSurfaceFilm/ThermoSurfaceFilm.H @@ -227,7 +227,6 @@ protected: ( const label filmPatchI, const label primaryPatchI, - const mappedPatchBase& distMap, const regionModels::surfaceFilmModels::surfaceFilmModel& filmModel ); diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C index 8351d49d2d..b0f8d1629a 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C @@ -151,13 +151,11 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() const label filmPatchI = filmModel.regionPatchID(patchI); - const mappedPatchBase& filmMap = filmModel.mappedPatches()[filmPatchI]; - scalarField deltaFilm = filmModel.delta().boundaryField()[filmPatchI]; - filmMap.distribute(deltaFilm); + filmModel.toPrimary(filmPatchI, deltaFilm); scalarField TFilm = filmModel.Ts().boundaryField()[filmPatchI]; - filmMap.distribute(TFilm); + filmModel.toPrimary(filmPatchI, TFilm); // Retrieve pyrolysis model @@ -166,10 +164,8 @@ void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() const label pyrPatchI = pyrModel.regionPatchID(patchI); - const mappedPatchBase& pyrMap = pyrModel.mappedPatches()[pyrPatchI]; - scalarField TPyr = pyrModel.T().boundaryField()[pyrPatchI]; - pyrMap.distribute(TPyr); + pyrModel.toPrimary(pyrPatchI, TPyr); forAll(deltaFilm, i) diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C index a516534fa8..29b3e34586 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C @@ -154,13 +154,11 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() const label filmPatchI = filmModel.regionPatchID(patchI); - const mappedPatchBase& filmMap = filmModel.mappedPatches()[filmPatchI]; - scalarField deltaFilm = filmModel.delta().boundaryField()[filmPatchI]; - filmMap.distribute(deltaFilm); + filmModel.toPrimary(filmPatchI, deltaFilm); vectorField UFilm = filmModel.Us().boundaryField()[filmPatchI]; - filmMap.distribute(UFilm); + filmModel.toPrimary(filmPatchI, UFilm); // Retrieve pyrolysis model @@ -172,10 +170,8 @@ void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() const label pyrPatchI = pyrModel.regionPatchID(patchI); - const mappedPatchBase& pyrMap = pyrModel.mappedPatches()[pyrPatchI]; - scalarField phiPyr = pyrModel.phiGas().boundaryField()[pyrPatchI]; - pyrMap.distribute(phiPyr); + pyrModel.toPrimary(pyrPatchI, phiPyr); const surfaceScalarField& phi = diff --git a/src/regionModels/regionModel/regionModel/regionModel.C b/src/regionModels/regionModel/regionModel/regionModel.C index 1d74a9c646..f7f630147e 100644 --- a/src/regionModels/regionModel/regionModel/regionModel.C +++ b/src/regionModels/regionModel/regionModel/regionModel.C @@ -93,8 +93,6 @@ void Foam::regionModels::regionModel::initialise() DynamicList