From 22b85e36e64b5f001926a6547746f295d0cc9599 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Nov 2010 12:20:47 +0000 Subject: [PATCH 1/5] BUG: sampledSurface : clear out underlying storage --- .../sampledSurface/distanceSurface/distanceSurface.C | 6 ++++++ src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C | 6 ++++++ .../sampledSurface/isoSurface/sampledIsoSurfaceCell.C | 6 ++++++ .../sampledCuttingPlane/sampledCuttingPlane.C | 5 +++++ .../thresholdCellFaces/sampledThresholdCellFaces.C | 2 ++ 5 files changed, 25 insertions(+) diff --git a/src/sampling/sampledSurface/distanceSurface/distanceSurface.C b/src/sampling/sampledSurface/distanceSurface/distanceSurface.C index 450384506a..3a6562b897 100644 --- a/src/sampling/sampledSurface/distanceSurface/distanceSurface.C +++ b/src/sampling/sampledSurface/distanceSurface/distanceSurface.C @@ -50,6 +50,9 @@ void Foam::distanceSurface::createGeometry() // Clear any stored topologies facesPtr_.clear(); + // Clear derived data + clearGeom(); + const fvMesh& fvm = static_cast(mesh()); // Distance to cell centres @@ -361,6 +364,9 @@ bool Foam::distanceSurface::expire() // Clear any stored topologies facesPtr_.clear(); + // Clear derived data + clearGeom(); + // already marked as expired if (needsUpdate_) { diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index b70461cef3..46d6f108cc 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -333,6 +333,9 @@ bool Foam::sampledIsoSurface::updateGeometry() const surfPtr_.clear(); facesPtr_.clear(); + // Clear derived data + clearGeom(); + if (subMeshPtr_.valid()) { surfPtr_.reset @@ -471,6 +474,9 @@ bool Foam::sampledIsoSurface::expire() facesPtr_.clear(); subMeshPtr_.clear(); + // Clear derived data + clearGeom(); + // already marked as expired if (prevTimeIndex_ == -1) { diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C index 155e12bbd2..7d1b138f5e 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurfaceCell.C @@ -62,6 +62,9 @@ bool Foam::sampledIsoSurfaceCell::updateGeometry() const // Clear any stored topo facesPtr_.clear(); + // Clear derived data + sampledSurface::clearGeom(); + // Optionally read volScalarField autoPtr readFieldPtr_; @@ -240,6 +243,9 @@ bool Foam::sampledIsoSurfaceCell::expire() { facesPtr_.clear(); + // Clear derived data + sampledSurface::clearGeom(); + // already marked as expired if (prevTimeIndex_ == -1) { diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index bfbb5293f7..3c88d38d6f 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -60,6 +60,8 @@ void Foam::sampledCuttingPlane::createGeometry() pointDistance_.clear(); cellDistancePtr_.clear(); + // Clear derived data + clearGeom(); // Get any subMesh if (zoneID_.index() != -1 && !subMeshPtr_.valid()) @@ -321,6 +323,9 @@ bool Foam::sampledCuttingPlane::expire() // Clear any stored topologies facesPtr_.clear(); + // Clear derived data + clearGeom(); + // already marked as expired if (needsUpdate_) { diff --git a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C index 0d9e1312ab..c8a3291ede 100644 --- a/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C +++ b/src/sampling/sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C @@ -124,6 +124,8 @@ bool Foam::sampledThresholdCellFaces::updateGeometry() const ).MeshedSurface::transfer(surf); meshCells_.transfer(surf.meshCells()); + // clear derived data + sampledSurface::clearGeom(); if (debug) { From ae1e1cc96317d0567c270b686d163f2e7d7919f0 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Nov 2010 13:31:40 +0000 Subject: [PATCH 2/5] BUG: tutorial scripts bashisms --- .../incompressible/MRFSimpleFoam/mixerVessel2D/makeMesh | 2 +- .../reactingParcelFilmFoam/hotBoxes/Allrun-parallel | 8 ++++---- .../lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun.pre | 2 +- .../reactingParcelFilmFoam/multipleBoxes/Allrun-parallel | 8 ++++---- .../reactingParcelFilmFoam/multipleBoxes/Allrun.pre | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/makeMesh b/tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/makeMesh index 91a75f1c48..937900177c 100755 --- a/tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/makeMesh +++ b/tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/makeMesh @@ -2,4 +2,4 @@ set -x m4 < constant/polyMesh/blockMeshDict.m4 > constant/polyMesh/blockMeshDict -blockMesh >& log.blockMesh +blockMesh > log.blockMesh 2>&1 diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun-parallel b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun-parallel index 680b728393..818c810f17 100755 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun-parallel +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun-parallel @@ -7,11 +7,11 @@ cd ${0%/*} || exit 1 # run from this directory ./Allrun.pre -decomposePar -region wallFilmRegion >& log.decomposePar.wallFilmRegion -decomposePar >& log.decomposePar.primaryRegion +decomposePar -region wallFilmRegion > log.decomposePar.wallFilmRegion 2>&1 +decomposePar > log.decomposePar.primaryRegion 2>&1 runParallel reactingParcelFilmFoam 4 -reconstructPar -region wallFilmRegion >& log.reconstructPar.wallFilmRegion -reconstructPar >& log.reconstructPar.primaryRegion +reconstructPar -region wallFilmRegion > log.reconstructPar.wallFilmRegion 2>&1 +reconstructPar > log.reconstructPar.primaryRegion 2>&1 diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun.pre b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun.pre index c2d435dfee..8ea2458c6a 100755 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun.pre +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/Allrun.pre @@ -14,7 +14,7 @@ runApplication subsetMesh c0 -patch wallFilm -overwrite # split the obstacle patches into cube[1-6]_patch[1-6] echo "running patchifyObstacles" -./patchifyObstacles >& log.patchifyObstacles +./patchifyObstacles > log.patchifyObstacles 2>&1 # Create the wall film region via extrusion runApplication extrudeToRegionMesh \ diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun-parallel b/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun-parallel index 53395bfc44..c88abfd1af 100755 --- a/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun-parallel +++ b/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun-parallel @@ -4,11 +4,11 @@ ./Allrun.pre -decomposePar -region wallFilmRegion >& log.decomposePar.wallFilmRegion -decomposePar >& log.decomposePar.primaryRegion +decomposePar -region wallFilmRegion > log.decomposePar.wallFilmRegion 2>&1 +decomposePar > log.decomposePar.primaryRegion 2>&1 runParallel reactingParcelFilmFoam 4 -reconstructPar -region wallFilmRegion >& log.reconstructPar.wallFilmRegion -reconstructPar >& log.reconstructPar.primaryRegion +reconstructPar -region wallFilmRegion > log.reconstructPar.wallFilmRegion 2>&1 +reconstructPar > log.reconstructPar.primaryRegion 2>&1 diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun.pre b/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun.pre index 9df92d95a1..9752b34767 100755 --- a/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun.pre +++ b/tutorials/lagrangian/reactingParcelFilmFoam/multipleBoxes/Allrun.pre @@ -14,7 +14,7 @@ runApplication subsetMesh c0 -patch wallFilm -overwrite # split the obstacle patches into cube[1-6]_patch[1-6] echo "running patchifyObstacles" -./patchifyObstacles >& log.patchifyObstacles +./patchifyObstacles > log.patchifyObstacles 2>&1 # Create the wall film region via extrusion runApplication extrudeToRegionMesh \ From 191cc9a8143d206c84dd8c2694dc2d12eaa15e7d Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Nov 2010 13:32:18 +0000 Subject: [PATCH 3/5] ENH: mapDistribute : optional initial value --- .../mapPolyMesh/mapDistribute/mapDistribute.H | 56 +++++++++++++++++++ .../mapDistribute/mapDistributeTemplates.C | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index e783887685..0df1ce8484 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -319,6 +319,62 @@ public: } } + //- Reverse distribute data using default commsType. + // Since constructSize might be larger than supplied size supply + // a nullValue + template + void reverseDistribute + ( + const label constructSize, + const T& nullValue, + List& fld + ) + const + { + if (Pstream::defaultCommsType == Pstream::nonBlocking) + { + distribute + ( + Pstream::nonBlocking, + List(), + constructSize, + constructMap_, + subMap_, + fld, + eqOp(), + nullValue + ); + } + else if (Pstream::defaultCommsType == Pstream::scheduled) + { + distribute + ( + Pstream::scheduled, + schedule(), + constructSize, + constructMap_, + subMap_, + fld, + eqOp(), + nullValue + ); + } + else + { + distribute + ( + Pstream::blocking, + List(), + constructSize, + constructMap_, + subMap_, + fld, + eqOp(), + nullValue + ); + } + } + //- Do all sends using PstreamBuffers template void send(PstreamBuffers&, const List&) const; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 443dbf502d..ef6c78299e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -446,10 +446,11 @@ void Foam::mapDistribute::distribute const labelList& map = constructMap[Pstream::myProcNo()]; field.setSize(constructSize); + field = nullValue; forAll(map, i) { - field[map[i]] = subField[i]; + cop(field[map[i]], subField[i]); } return; } From 938084438e9993600997ec4c3375a4c0cfcc2d52 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Nov 2010 13:33:27 +0000 Subject: [PATCH 4/5] ENH: directMapped: allow offset specification; allow fieldName specification; allow non-constant interpolation --- .../directMappedFixedValueFvPatchField.C | 137 +++++++++-- .../directMappedFixedValueFvPatchField.H | 33 ++- ...MappedVelocityFluxFixedValueFvPatchField.C | 23 ++ .../directMappedPatchBase.C | 230 ++++++++++++------ .../directMappedPatchBase.H | 69 +++++- 5 files changed, 389 insertions(+), 103 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C index 4dd232091d..0fb5b64b78 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C @@ -26,6 +26,7 @@ License #include "directMappedFixedValueFvPatchField.H" #include "directMappedPatchBase.H" #include "volFields.H" +#include "interpolationCell.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -42,8 +43,10 @@ directMappedFixedValueFvPatchField::directMappedFixedValueFvPatchField ) : fixedValueFvPatchField(p, iF), + fieldName_(iF.name()), setAverage_(false), - average_(pTraits::zero) + average_(pTraits::zero), + interpolationScheme_(interpolationCell::typeName) {} @@ -57,8 +60,10 @@ directMappedFixedValueFvPatchField::directMappedFixedValueFvPatchField ) : fixedValueFvPatchField(ptf, p, iF, mapper), + fieldName_(ptf.fieldName_), setAverage_(ptf.setAverage_), - average_(ptf.average_) + average_(ptf.average_), + interpolationScheme_(ptf.interpolationScheme_) { if (!isA(this->patch().patch())) { @@ -91,8 +96,10 @@ directMappedFixedValueFvPatchField::directMappedFixedValueFvPatchField ) : fixedValueFvPatchField(p, iF, dict), + fieldName_(dict.lookupOrDefault("fieldName", iF.name())), setAverage_(readBool(dict.lookup("setAverage"))), - average_(pTraits(dict.lookup("average"))) + average_(pTraits(dict.lookup("average"))), + interpolationScheme_(interpolationCell::typeName) { if (!isA(this->patch().patch())) { @@ -112,6 +119,15 @@ directMappedFixedValueFvPatchField::directMappedFixedValueFvPatchField << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); } + + const directMappedPatchBase& mpp = refCast + ( + directMappedFixedValueFvPatchField::patch().patch() + ); + if (mpp.mode() == directMappedPatchBase::NEARESTCELL) + { + dict.lookup("interpolationScheme") >> interpolationScheme_; + } } @@ -122,8 +138,10 @@ directMappedFixedValueFvPatchField::directMappedFixedValueFvPatchField ) : fixedValueFvPatchField(ptf), + fieldName_(ptf.fieldName_), setAverage_(ptf.setAverage_), - average_(ptf.average_) + average_(ptf.average_), + interpolationScheme_(ptf.interpolationScheme_) {} @@ -135,13 +153,67 @@ directMappedFixedValueFvPatchField::directMappedFixedValueFvPatchField ) : fixedValueFvPatchField(ptf, iF), + fieldName_(ptf.fieldName_), setAverage_(ptf.setAverage_), - average_(ptf.average_) + average_(ptf.average_), + interpolationScheme_(ptf.interpolationScheme_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +const GeometricField& +directMappedFixedValueFvPatchField::sampleField() const +{ + typedef GeometricField fieldType; + + const directMappedPatchBase& mpp = refCast + ( + directMappedFixedValueFvPatchField::patch().patch() + ); + const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); + + if (mpp.sameRegion()) + { + if (fieldName_ == this->dimensionedInternalField().name()) + { + // Optimisation: bypass field lookup + return + dynamic_cast + ( + this->dimensionedInternalField() + ); + } + else + { + const fvMesh& thisMesh = this->patch().boundaryMesh().mesh(); + return thisMesh.lookupObject(fieldName_); + } + } + else + { + return nbrMesh.lookupObject(fieldName_); + } +} + + +template +const interpolation& +directMappedFixedValueFvPatchField::interpolator() const +{ + if (!interpolator_.valid()) + { + interpolator_ = interpolation::New + ( + interpolationScheme_, + sampleField() + ); + } + return interpolator_(); +} + + template void directMappedFixedValueFvPatchField::updateCoeffs() { @@ -159,11 +231,8 @@ void directMappedFixedValueFvPatchField::updateCoeffs() ); const mapDistribute& distMap = mpp.map(); - // Force recalculation of schedule - (void)distMap.schedule(); - + const fvMesh& thisMesh = this->patch().boundaryMesh().mesh(); const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); - const word& fldName = this->dimensionedInternalField().name(); // Result of obtaining remote values Field newValues; @@ -172,17 +241,37 @@ void directMappedFixedValueFvPatchField::updateCoeffs() { case directMappedPatchBase::NEARESTCELL: { - if (mpp.sameRegion()) + if (interpolationScheme_ != interpolationCell::typeName) { - newValues = this->internalField(); + // Send back sample points to the processor that holds the cell + vectorField samples(mpp.samplePoints()); + distMap.reverseDistribute + ( + (mpp.sameRegion() ? thisMesh.nCells() : nbrMesh.nCells()), + point::max, + samples + ); + + const interpolation& interp = interpolator(); + + newValues.setSize(samples.size(), pTraits::max); + forAll(samples, cellI) + { + if (samples[cellI] != point::max) + { + newValues[cellI] = interp.interpolate + ( + samples[cellI], + cellI + ); + } + } } else { - newValues = nbrMesh.lookupObject - ( - fldName - ).internalField(); + newValues = sampleField(); } + mapDistribute::distribute ( Pstream::defaultCommsType, @@ -213,10 +302,8 @@ void directMappedFixedValueFvPatchField::updateCoeffs() << abort(FatalError); } - const fieldType& nbrField = nbrMesh.lookupObject - ( - fldName - ); + const fieldType& nbrField = sampleField(); + newValues = nbrField.boundaryField()[nbrPatchID]; mapDistribute::distribute ( @@ -234,10 +321,8 @@ void directMappedFixedValueFvPatchField::updateCoeffs() { Field allValues(nbrMesh.nFaces(), pTraits::zero); - const fieldType& nbrField = nbrMesh.lookupObject - ( - fldName - ); + const fieldType& nbrField = sampleField(); + forAll(nbrField.boundaryField(), patchI) { const fvPatchField& pf = @@ -294,7 +379,8 @@ void directMappedFixedValueFvPatchField::updateCoeffs() if (debug) { - Info<< "directMapped on field:" << fldName + Info<< "directMapped on field:" + << this->dimensionedInternalField().name() << " patch:" << this->patch().name() << " avg:" << gAverage(*this) << " min:" << gMin(*this) @@ -310,8 +396,11 @@ template void directMappedFixedValueFvPatchField::write(Ostream& os) const { fvPatchField::write(os); + os.writeKeyword("fieldName") << fieldName_ << token::END_STATEMENT << nl; os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; os.writeKeyword("average") << average_ << token::END_STATEMENT << nl; + os.writeKeyword("interpolationScheme") << interpolationScheme_ + << token::END_STATEMENT << nl; this->writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.H index 8d6038913e..07960cd0e5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.H @@ -33,6 +33,17 @@ Description mode = NEARESTFACE : sample nearest face on any patch. Note: does not warn if nearest actually is on internal face! + For NEARESTCELL you have to provide an 'interpolationScheme' entry + which can be any one of the interpolation schemes (cell, cellPoint, etc.) + In case of interpolation (so scheme != cell) the limitation is that + there is only one value per cell. So e.g. if you have a cell with two + boundary faces and both faces sample into the cell both faces will get + the same value. + + See directMappedPatchBase for options on sampling. + + Optional 'fieldName' entry to supply a different filename + SourceFiles directMappedFixedValueFvPatchField.C @@ -43,6 +54,7 @@ SourceFiles #include "fixedValueFvPatchFields.H" #include "directMappedFvPatch.H" +#include "interpolation.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,12 +72,29 @@ class directMappedFixedValueFvPatchField { // Private data + //- Name of field to sample - defaults to field associated with this + // patchField if not specified + word fieldName_; + //- If true adjust the mapped field to maintain average value average_ - bool setAverage_; + const bool setAverage_; //- Average value the mapped field is adjusted to maintain if // setAverage_ is set true - Type average_; + const Type average_; + + //- Interpolation scheme to use for nearestcell mode + word interpolationScheme_; + + mutable autoPtr > interpolator_; + + // Private Member Functions + + //- Field to sample. Either on my or nbr mesh + const GeometricField& sampleField() const; + + //- Access the interpolation method + const interpolation& interpolator() const; public: diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C index 36821fe72f..8f64aedc7e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedVelocityFluxFixedValue/directMappedVelocityFluxFixedValueFvPatchField.C @@ -112,6 +112,29 @@ directMappedVelocityFluxFixedValueFvPatchField << " in file " << dimensionedInternalField().objectPath() << exit(FatalError); } + + const directMappedPatchBase& mpp = refCast + ( + this->patch().patch() + ); + if (mpp.mode() == directMappedPolyPatch::NEARESTCELL) + { + FatalErrorIn + ( + "directMappedVelocityFluxFixedValueFvPatchField::" + "directMappedVelocityFluxFixedValueFvPatchField" + "(" + "const fvPatch&, " + "const DimensionedField&, " + "const dictionary&" + ")" + ) << "Patch " << p.name() + << " of type '" << p.type() + << "' can not be used in 'nearestCell' mode" + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } } diff --git a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.C b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.C index f3b679154c..957fd0281b 100644 --- a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.C +++ b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.C @@ -54,6 +54,18 @@ namespace Foam directMappedPatchBase::sampleModeNames_; + template<> + const char* NamedEnum::names[] = + { + "uniform", + "nonuniform", + "normal" + }; + + const NamedEnum + directMappedPatchBase::offsetModeNames_; + + //- Private class for finding nearest // - point+local index // - sqr(distance) @@ -100,7 +112,7 @@ void Foam::directMappedPatchBase::collectSamples labelListList globalFaces(Pstream::nProcs()); globalFc[Pstream::myProcNo()] = patch_.faceCentres(); - globalSamples[Pstream::myProcNo()] = globalFc[Pstream::myProcNo()]+offsets_; + globalSamples[Pstream::myProcNo()] = samplePoints(); globalFaces[Pstream::myProcNo()] = identity(patch_.size()); // Distribute to all processors @@ -393,19 +405,34 @@ void Foam::directMappedPatchBase::calcMapping() const << "Mapping already calculated" << exit(FatalError); } - if + // Do a sanity check + // Am I sampling my own patch? This only makes sense for a non-zero + // offset. + bool sampleMyself = ( - gAverage(mag(offsets_)) <= ROOTVSMALL - && mode_ == NEARESTPATCHFACE + mode_ == NEARESTPATCHFACE && sampleRegion_ == patch_.boundaryMesh().mesh().name() && samplePatch_ == patch_.name() - ) + ); + + // Check offset + vectorField d(samplePoints()-patch_.faceCentres()); + if (sampleMyself && gAverage(mag(d)) <= ROOTVSMALL) { - WarningIn("directMappedPatchBase::calcMapping() const") - << "Invalid offset " << offsets_ << endl + WarningIn + ( + "directMappedPatchBase::directMappedPatchBase\n" + "(\n" + " const polyPatch& pp,\n" + " const word& sampleRegion,\n" + " const sampleMode mode,\n" + " const word& samplePatch,\n" + " const vector& offset\n" + ")\n" + ) << "Invalid offset " << d << endl << "Offset is the vector added to the patch face centres to" << " find the patch face supplying the data." << endl - << "Setting it to " << offsets_ + << "Setting it to " << d << " on the same patch, on the same region" << " will find the faces themselves which does not make sense" << " for anything but testing." << endl @@ -413,10 +440,11 @@ void Foam::directMappedPatchBase::calcMapping() const << "sampleRegion_:" << sampleRegion_ << endl << "mode_:" << sampleModeNames_[mode_] << endl << "samplePatch_:" << samplePatch_ << endl - << "offsets_:" << offsets_ << endl; + << "offsetMode_:" << offsetModeNames_[offsetMode_] << endl; } + // Get global list of all samples and the processor and face they come from. pointField samples; labelList patchFaceProcs; @@ -477,40 +505,6 @@ void Foam::directMappedPatchBase::calcMapping() const } - //// Check that actual offset vector (sampleLocations - patchFc) is more or - //// less constant. - //if (Pstream::master()) - //{ - // const scalarField magOffset(mag(sampleLocations - patchFc)); - // const scalar avgOffset(average(magOffset)); - // - // forAll(magOffset, sampleI) - // { - // if - // ( - // mag(magOffset[sampleI]-avgOffset) - // > max(SMALL, 0.001*avgOffset) - // ) - // { - // WarningIn("directMappedPatchBase::calcMapping() const") - // << "The actual cell/face centres picked up using offset " - // << offsets_ << " are not" << endl - // << " on a single plane." - // << " This might give numerical problems." << endl - // << " At patchface " << patchFc[sampleI] - // << " the sampled cell/face " << sampleLocations[sampleI] - // << endl - // << " is not on a plane " << avgOffset - // << " offset from the patch." << endl - // << " You might want to shift your plane offset." - // << " Set the debug flag to get a dump of sampled cells." - // << endl; - // break; - // } - // } - //} - - // Determine schedule. mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs)); @@ -597,9 +591,10 @@ Foam::directMappedPatchBase::directMappedPatchBase sampleRegion_(patch_.boundaryMesh().mesh().name()), mode_(NEARESTPATCHFACE), samplePatch_("none"), - uniformOffset_(true), + offsetMode_(UNIFORM), offset_(vector::zero), offsets_(pp.size(), offset_), + distance_(0), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), mapPtr_(NULL) {} @@ -618,8 +613,10 @@ Foam::directMappedPatchBase::directMappedPatchBase sampleRegion_(sampleRegion), mode_(mode), samplePatch_(samplePatch), - uniformOffset_(false), + offsetMode_(NONUNIFORM), + offset_(vector::zero), offsets_(offsets), + distance_(0), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), mapPtr_(NULL) {} @@ -638,9 +635,10 @@ Foam::directMappedPatchBase::directMappedPatchBase sampleRegion_(sampleRegion), mode_(mode), samplePatch_(samplePatch), - uniformOffset_(true), + offsetMode_(UNIFORM), offset_(offset), - offsets_(pp.size(), offset_), + offsets_(0), + distance_(0), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), mapPtr_(NULL) {} @@ -663,22 +661,62 @@ Foam::directMappedPatchBase::directMappedPatchBase ), mode_(sampleModeNames_.read(dict.lookup("sampleMode"))), samplePatch_(dict.lookup("samplePatch")), - uniformOffset_(dict.found("offset")), - offset_ - ( - uniformOffset_ - ? point(dict.lookup("offset")) - : vector::zero - ), - offsets_ - ( - uniformOffset_ - ? pointField(pp.size(), offset_) - : dict.lookup("offsets") - ), + offsetMode_(UNIFORM), + offset_(vector::zero), + offsets_(0), + distance_(0.0), sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()), mapPtr_(NULL) -{} +{ + if (dict.found("offsetMode")) + { + offsetMode_ = offsetModeNames_.read(dict.lookup("offsetMode")); + + switch(offsetMode_) + { + case UNIFORM: + { + offset_ = point(dict.lookup("offset")); + } + break; + + case NONUNIFORM: + { + offsets_ = pointField(dict.lookup("offsets")); + } + break; + + case NORMAL: + { + distance_ = readScalar(dict.lookup("distance")); + } + break; + } + } + else if (dict.found("offset")) + { + offsetMode_ = UNIFORM; + offset_ = point(dict.lookup("offset")); + } + else if (dict.found("offsets")) + { + offsetMode_ = NONUNIFORM; + offsets_ = pointField(dict.lookup("offsets")); + } + else + { + FatalErrorIn + ( + "directMappedPatchBase::directMappedPatchBase\n" + "(\n" + " const polyPatch& pp,\n" + " const dictionary& dict\n" + ")\n" + ) << "Please supply the offsetMode as one of " + << NamedEnum::words() + << exit(FatalError); + } +} Foam::directMappedPatchBase::directMappedPatchBase @@ -691,9 +729,10 @@ Foam::directMappedPatchBase::directMappedPatchBase sampleRegion_(dmp.sampleRegion_), mode_(dmp.mode_), samplePatch_(dmp.samplePatch_), - uniformOffset_(dmp.uniformOffset_), + offsetMode_(dmp.offsetMode_), offset_(dmp.offset_), offsets_(dmp.offsets_), + distance_(dmp.distance_), sameRegion_(dmp.sameRegion_), mapPtr_(NULL) {} @@ -710,9 +749,10 @@ Foam::directMappedPatchBase::directMappedPatchBase sampleRegion_(dmp.sampleRegion_), mode_(dmp.mode_), samplePatch_(dmp.samplePatch_), - uniformOffset_(dmp.uniformOffset_), + offsetMode_(dmp.offsetMode_), offset_(dmp.offset_), offsets_(dmp.offsets_, mapAddressing), + distance_(dmp.distance_), sameRegion_(dmp.sameRegion_), mapPtr_(NULL) {} @@ -762,6 +802,40 @@ const Foam::polyPatch& Foam::directMappedPatchBase::samplePolyPatch() const } +Foam::tmp Foam::directMappedPatchBase::samplePoints() const +{ + tmp tfld(new pointField(patch_.faceCentres())); + pointField& fld = tfld(); + + switch(offsetMode_) + { + case UNIFORM: + { + fld += offset_; + } + break; + + case NONUNIFORM: + { + fld += offsets_; + } + break; + + case NORMAL: + { + // Get outwards pointing normal + vectorField n(patch_.faceAreas()); + n /= mag(n); + + fld += distance_*n; + } + break; + } + + return tfld; +} + + void Foam::directMappedPatchBase::write(Ostream& os) const { os.writeKeyword("sampleMode") << sampleModeNames_[mode_] @@ -770,13 +844,31 @@ void Foam::directMappedPatchBase::write(Ostream& os) const << token::END_STATEMENT << nl; os.writeKeyword("samplePatch") << samplePatch_ << token::END_STATEMENT << nl; - if (uniformOffset_) + + os.writeKeyword("offsetMode") << offsetModeNames_[offsetMode_] + << token::END_STATEMENT << nl; + + switch(offsetMode_) { - os.writeKeyword("offset") << offset_ << token::END_STATEMENT << nl; - } - else - { - os.writeKeyword("offsets") << offsets_ << token::END_STATEMENT << nl; + case UNIFORM: + { + os.writeKeyword("offset") << offset_ << token::END_STATEMENT << nl; + } + break; + + case NONUNIFORM: + { + os.writeKeyword("offsets") << offsets_ << token::END_STATEMENT + << nl; + } + break; + + case NORMAL: + { + os.writeKeyword("distance") << distance_ << token::END_STATEMENT + << nl; + } + break; } } diff --git a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.H b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.H index 281e24ec6e..96ac05bf7c 100644 --- a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.H +++ b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPatchBase.H @@ -28,6 +28,33 @@ Description Determines a mapping between patch face centres and mesh cell or face centres and processors they're on. + If constructed from dictionary: + // Region to sample (default is region0) + sampleRegion region0; + + // What to sample: + // - nearestCell : sample nearest cell + // - nearestPatchFace : nearest face on selected patch + // - nearestFace : nearest boundary face on any patch + sampleMode nearestCell; + + // If sampleMod is nearestPatchFace : patch to find faces of + samplePatch movingWall; + + // How to supply offset (w.r.t. my patch face centres): + // - uniform : single offset vector + // - nonuniform : per-face offset vector + // - normal : using supplied distance and face normal + offsetMode uniform; + + // According to offsetMode (see above) supply one of + // offset, offsets or distance + offset (1 0 0); + + Note: if offsetMode is 'normal' it uses outwards pointing normals. So + supply a negative distance if sampling inside the domain. + + Note Storage is not optimal. It temporary collects all (patch)face centres on all processors to keep the addressing calculation simple. @@ -71,12 +98,22 @@ public: NEARESTFACE // nearest face }; + //- How to project face centres + enum offsetMode + { + UNIFORM, // single offset vector + NONUNIFORM, // per-face offset vector + NORMAL // use face normal + distance + }; + private: // Private data static const NamedEnum sampleModeNames_; + static const NamedEnum offsetModeNames_; + //- Patch to sample const polyPatch& patch_; @@ -89,14 +126,17 @@ private: //- Patch (only if NEARESTPATCHFACE) const word samplePatch_; - //- For backwards compatibility : reading/writing of uniform offset. - const bool uniformOffset_; + //- How to obtain samples + offsetMode offsetMode_; //- Offset vector (uniform) - const vector offset_; + vector offset_; - //- Offset vector - const vectorField offsets_; + //- Offset vector (nonuniform) + vectorField offsets_; + + //- Offset distance (normal) + scalar distance_; //- Same region const bool sameRegion_; @@ -146,17 +186,17 @@ public: //- Construct from patch directMappedPatchBase(const polyPatch&); - //- Construct from components + //- Construct with offsetMode=non-uniform directMappedPatchBase ( const polyPatch& pp, const word& sampleRegion, const sampleMode sampleMode, const word& samplePatch, - const vectorField& offset + const vectorField& offsets ); - //- Construct from components + //- Construct from offsetMode=uniform directMappedPatchBase ( const polyPatch& pp, @@ -166,6 +206,16 @@ public: const vector& offset ); + ////- Construct from normal and distance + //directMappedPatchBase + //( + // const polyPatch& pp, + // const word& sampleRegion, + // const word& samplePatch, + // const sampleMode sampleMode, + // const vector& offset + //); + //- Construct from dictionary directMappedPatchBase(const polyPatch&, const dictionary&); @@ -241,6 +291,9 @@ public: //- Get the patch on the region const polyPatch& samplePolyPatch() const; + //- Get the sample points + tmp samplePoints() const; + //- Write as a dictionary virtual void write(Ostream&) const; }; From 59695e5a4da4b5dd57fa7918b0ca35b1d3ca1432 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 25 Nov 2010 13:46:42 +0000 Subject: [PATCH 5/5] ENH: directMappedNamedFixedValue : merged functionality into directMapped --- src/surfaceFilmModels/Make/files | 1 - .../directMappedNamedFixedValueFvPatchField.C | 334 ------------------ .../directMappedNamedFixedValueFvPatchField.H | 164 --------- ...directMappedNamedFixedValueFvPatchFields.C | 43 --- ...directMappedNamedFixedValueFvPatchFields.H | 49 --- ...ectMappedNamedFixedValueFvPatchFieldsFwd.H | 50 --- ...ectMappedNamesFixedValueFvPatchFieldsFwd.H | 50 --- .../evaporationTest/0.org/T | 2 +- .../evaporationTest/0.org/U | 2 +- .../evaporationTest/0/T | 2 +- .../evaporationTest/0/U | 2 +- .../reactingParcelFilmFoam/hotBoxes/0.org/T | 2 +- .../reactingParcelFilmFoam/hotBoxes/0.org/U | 2 +- .../reactingParcelFilmFoam/hotBoxes/0/T | 2 +- .../reactingParcelFilmFoam/hotBoxes/0/U | 2 +- .../hotBoxes/system/changeDictionaryDict | 4 +- 16 files changed, 10 insertions(+), 701 deletions(-) delete mode 100644 src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.C delete mode 100644 src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.H delete mode 100644 src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.C delete mode 100644 src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.H delete mode 100644 src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFieldsFwd.H delete mode 100644 src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamesFixedValueFvPatchFieldsFwd.H diff --git a/src/surfaceFilmModels/Make/files b/src/surfaceFilmModels/Make/files index 8b84a94e14..3f2aaef301 100644 --- a/src/surfaceFilmModels/Make/files +++ b/src/surfaceFilmModels/Make/files @@ -26,7 +26,6 @@ submodels/thermo/heatTransferModel/mappedConvectiveHeatTransfer/mappedConvective /* Boundary conditions */ derivedFvPatchFields/directMappedFixedInternalValue/directMappedFixedInternalValueFvPatchFields.C -derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.C derivedFvPatchFields/directMappedFixedPushedInternalValue/directMappedFixedPushedInternalValueFvPatchFields.C derivedFvPatchFields/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField.C derivedFvPatchFields/htcConv/htcConvFvPatchScalarField.C diff --git a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.C b/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.C deleted file mode 100644 index c9e799e08a..0000000000 --- a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.C +++ /dev/null @@ -1,334 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 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 . - -\*---------------------------------------------------------------------------*/ - -#include "directMappedNamedFixedValueFvPatchField.H" -#include "directMappedPatchBase.H" -#include "volFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -directMappedNamedFixedValueFvPatchField:: -directMappedNamedFixedValueFvPatchField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchField(p, iF), - fieldName_(iF.name()), - setAverage_(false), - average_(pTraits::zero) -{} - - -template -directMappedNamedFixedValueFvPatchField:: -directMappedNamedFixedValueFvPatchField -( - const directMappedNamedFixedValueFvPatchField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchField(ptf, p, iF, mapper), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_) -{ - if (!isA(this->patch().patch())) - { - FatalErrorIn - ( - "directMappedNamedFixedValueFvPatchField::" - "directMappedNamedFixedValueFvPatchField\n" - "(" - "const directMappedNamedFixedValueFvPatchField&, " - "const fvPatch&, " - "const Field&, " - "const fvPatchFieldMapper& " - ")" - ) << " patch type '" << p.type() - << "' not type '" << directMappedPatchBase::typeName << "'" - << "\n for patch " << p.name() - << " of field " << this->dimensionedInternalField().name() - << " in file " << this->dimensionedInternalField().objectPath() - << exit(FatalError); - } -} - - -template -directMappedNamedFixedValueFvPatchField:: -directMappedNamedFixedValueFvPatchField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchField(p, iF, dict), - fieldName_(dict.lookupOrDefault("fieldName", iF.name())), - setAverage_(readBool(dict.lookup("setAverage"))), - average_(pTraits(dict.lookup("average"))) -{ - if (!isA(this->patch().patch())) - { - FatalErrorIn - ( - "directMappedNamedFixedValueFvPatchField::" - "directMappedNamedFixedValueFvPatchField" - "(" - "const fvPatch&, " - "const DimensionedField& iF, " - "const dictionary&" - ")" - ) << " patch type '" << p.type() - << "' not type '" << directMappedPatchBase::typeName << "'" - << "\n for patch " << p.name() - << " of field " << fieldName_ - << " in file " << this->dimensionedInternalField().objectPath() - << exit(FatalError); - } - - //// Force calculation of schedule (uses parallel comms) - //const directMappedPatchBase& mpp = refCast - //( - // this->patch().patch() - //); - //(void)mpp.map().schedule(); -} - - -template -directMappedNamedFixedValueFvPatchField:: -directMappedNamedFixedValueFvPatchField -( - const directMappedNamedFixedValueFvPatchField& ptf -) -: - fixedValueFvPatchField(ptf), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_) -{} - - -template -directMappedNamedFixedValueFvPatchField:: -directMappedNamedFixedValueFvPatchField -( - const directMappedNamedFixedValueFvPatchField& ptf, - const DimensionedField& iF -) -: - fixedValueFvPatchField(ptf, iF), - fieldName_(ptf.fieldName_), - setAverage_(ptf.setAverage_), - average_(ptf.average_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void directMappedNamedFixedValueFvPatchField::updateCoeffs() -{ - if (this->updated()) - { - return; - } - - typedef GeometricField fieldType; - - // Get the scheduling information from the directMappedPatchBase - const directMappedPatchBase& mpp = refCast - ( - directMappedNamedFixedValueFvPatchField::patch().patch() - ); - const mapDistribute& distMap = mpp.map(); - - // Force recalculation of schedule - (void)distMap.schedule(); - - const fvMesh& nbrMesh = refCast(mpp.sampleMesh()); - - // Result of obtaining remote values - Field newValues; - - switch (mpp.mode()) - { - case directMappedPatchBase::NEARESTCELL: - { - if (mpp.sameRegion()) - { - newValues = this->internalField(); - } - else - { - newValues = nbrMesh.lookupObject - ( - fieldName_ - ).internalField(); - } - mapDistribute::distribute - ( - Pstream::defaultCommsType, - distMap.schedule(), - distMap.constructSize(), - distMap.subMap(), - distMap.constructMap(), - newValues - ); - - break; - } - case directMappedPatchBase::NEARESTPATCHFACE: - { - const label nbrPatchID = - nbrMesh.boundaryMesh().findPatchID(mpp.samplePatch()); - if (nbrPatchID < 0) - { - FatalErrorIn - ( - "void directMappedNamedFixedValueFvPatchField::" - "updateCoeffs()" - )<< "Unable to find sample patch " << mpp.samplePatch() - << " in region " << mpp.sampleRegion() - << " for patch " << this->patch().name() << nl - << abort(FatalError); - } - - const fieldType& nbrField = - nbrMesh.lookupObject(fieldName_); - newValues = nbrField.boundaryField()[nbrPatchID]; - mapDistribute::distribute - ( - Pstream::defaultCommsType, - distMap.schedule(), - distMap.constructSize(), - distMap.subMap(), - distMap.constructMap(), - newValues - ); - - break; - } - case directMappedPatchBase::NEARESTFACE: - { - Field allValues(nbrMesh.nFaces(), pTraits::zero); - - const fieldType& nbrField = - nbrMesh.lookupObject(fieldName_); - forAll(nbrField.boundaryField(), patchI) - { - const fvPatchField& pf = - nbrField.boundaryField()[patchI]; - label faceStart = pf.patch().patch().start(); - - forAll(pf, faceI) - { - allValues[faceStart++] = pf[faceI]; - } - } - - mapDistribute::distribute - ( - Pstream::defaultCommsType, - distMap.schedule(), - distMap.constructSize(), - distMap.subMap(), - distMap.constructMap(), - allValues - ); - - newValues = this->patch().patchSlice(allValues); - - break; - } - default: - { - FatalErrorIn - ( - "directMappedNamedFixedValueFvPatchField::updateCoeffs()" - )<< "Unknown sampling mode: " << mpp.mode() - << nl << abort(FatalError); - } - } - - if (setAverage_) - { - Type averagePsi = - gSum(this->patch().magSf()*newValues) - /gSum(this->patch().magSf()); - - if (mag(averagePsi)/mag(average_) > 0.5) - { - newValues *= mag(average_)/mag(averagePsi); - } - else - { - newValues += (average_ - averagePsi); - } - } - - this->operator==(newValues); - - if (debug) - { - Info<< "directMapped on field:" << fieldName_ - << " patch:" << this->patch().name() - << " avg:" << gAverage(*this) - << " min:" << gMin(*this) - << " max:" << gMax(*this) - << endl; - } - - fixedValueFvPatchField::updateCoeffs(); -} - - -template -void directMappedNamedFixedValueFvPatchField::write(Ostream& os) const -{ - fvPatchField::write(os); - os.writeKeyword("fieldName") << fieldName_ << token::END_STATEMENT << nl; - os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; - os.writeKeyword("average") << average_ << token::END_STATEMENT << nl; - this->writeEntry("value", os); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.H b/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.H deleted file mode 100644 index 711ed1ec98..0000000000 --- a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchField.H +++ /dev/null @@ -1,164 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 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 . - -Class - Foam::directMappedNamedFixedValueFvPatchField - -Description - Variant of directMappedFixedValueFvPatch where the name of the field to - map is input. - -SourceFiles - directMappedNamedFixedValueFvPatchField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef directMappedNamedFixedValueFvPatchField_H -#define directMappedNamedFixedValueFvPatchField_H - -#include "fixedValueFvPatchField.H" -#include "directMappedFvPatch.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class directMappedNamesFixedValueFvPatchField Declaration -\*---------------------------------------------------------------------------*/ - -template -class directMappedNamedFixedValueFvPatchField -: - public fixedValueFvPatchField -{ - // Private data - - //- Name of field to sample - defaults to field associated with this - // patch if not specified - word fieldName_; - - //- If true adjust the mapped field to maintain average value average_ - bool setAverage_; - - //- Average value the mapped field is adjusted to maintain if - // setAverage_ is set true - Type average_; - - -public: - - //- Runtime type information - TypeName("directMappedNamedFixedValue"); - - - // Constructors - - //- Construct from patch and internal field - directMappedNamedFixedValueFvPatchField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - directMappedNamedFixedValueFvPatchField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given directMappedNamedFixedValueFvPatchField - // onto a new patch - directMappedNamedFixedValueFvPatchField - ( - const directMappedNamedFixedValueFvPatchField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct as copy - directMappedNamedFixedValueFvPatchField - ( - const directMappedNamedFixedValueFvPatchField& - ); - - //- Construct and return a clone - virtual tmp > clone() const - { - return tmp > - ( - new directMappedNamedFixedValueFvPatchField(*this) - ); - } - - //- Construct as copy setting internal field reference - directMappedNamedFixedValueFvPatchField - ( - const directMappedNamedFixedValueFvPatchField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp > clone - ( - const DimensionedField& iF - ) const - { - return tmp > - ( - new directMappedNamedFixedValueFvPatchField(*this, iF) - ); - } - - - // Member functions - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "directMappedNamedFixedValueFvPatchField.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.C b/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.C deleted file mode 100644 index 849cc55825..0000000000 --- a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.C +++ /dev/null @@ -1,43 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 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 . - -\*---------------------------------------------------------------------------*/ - -#include "directMappedNamedFixedValueFvPatchFields.H" -#include "volMesh.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makePatchFields(directMappedNamedFixedValue); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.H b/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.H deleted file mode 100644 index 2f815fb81a..0000000000 --- a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFields.H +++ /dev/null @@ -1,49 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 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 . - -\*---------------------------------------------------------------------------*/ - -#ifndef directMappedNamedFixedValueFvPatchFields_H -#define directMappedNamedFixedValueFvPatchFields_H - -#include "directMappedNamedFixedValueFvPatchField.H" -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makePatchTypeFieldTypedefs(directMappedNamedFixedValue) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFieldsFwd.H b/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFieldsFwd.H deleted file mode 100644 index c7d6e5c11c..0000000000 --- a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamedFixedValueFvPatchFieldsFwd.H +++ /dev/null @@ -1,50 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 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 . - -\*---------------------------------------------------------------------------*/ - -#ifndef directMappedNamedFixedValueFvPatchFieldsFwd_H -#define directMappedNamedFixedValueFvPatchFieldsFwd_H - -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template class directMappedNamedFixedValueFvPatchField; - -makePatchTypeFieldTypedefs(directMappedNamedFixedValue) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamesFixedValueFvPatchFieldsFwd.H b/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamesFixedValueFvPatchFieldsFwd.H deleted file mode 100644 index c7d6e5c11c..0000000000 --- a/src/surfaceFilmModels/derivedFvPatchFields/directMappedNamedFixedValue/directMappedNamesFixedValueFvPatchFieldsFwd.H +++ /dev/null @@ -1,50 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 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 . - -\*---------------------------------------------------------------------------*/ - -#ifndef directMappedNamedFixedValueFvPatchFieldsFwd_H -#define directMappedNamedFixedValueFvPatchFieldsFwd_H - -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template class directMappedNamedFixedValueFvPatchField; - -makePatchTypeFieldTypedefs(directMappedNamedFixedValue) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/T b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/T index f34ddb4387..877f52af23 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/T +++ b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/T @@ -28,7 +28,7 @@ boundaryField } region0_to_wallFilmRegion_wallFilmFaces { - type directMappedNamedFixedValue; + type directMapped; fieldName Tsf; average 300; setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/U b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/U index 4622cf8a48..d3def72f0c 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/U +++ b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0.org/U @@ -28,7 +28,7 @@ boundaryField } region0_to_wallFilmRegion_wallFilmFaces { - type directMappedNamedFixedValue; + type directMapped; fieldName Usf; average ( 0 0 0 ); setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/T b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/T index f34ddb4387..877f52af23 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/T +++ b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/T @@ -28,7 +28,7 @@ boundaryField } region0_to_wallFilmRegion_wallFilmFaces { - type directMappedNamedFixedValue; + type directMapped; fieldName Tsf; average 300; setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/U b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/U index 4622cf8a48..d3def72f0c 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/U +++ b/tutorials/lagrangian/reactingParcelFilmFoam/evaporationTest/0/U @@ -28,7 +28,7 @@ boundaryField } region0_to_wallFilmRegion_wallFilmFaces { - type directMappedNamedFixedValue; + type directMapped; fieldName Usf; average ( 0 0 0 ); setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/T b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/T index 21a4eadb2c..082d4cb3bc 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/T +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/T @@ -29,7 +29,7 @@ boundaryField wallFilm { type zeroGradient; -// type directMappedNamedFixedValue; +// type directMapped; // fieldName Tsf; // average 300; // setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/U b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/U index d114c24c03..9464847840 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/U +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/U @@ -30,7 +30,7 @@ boundaryField { type fixedValue; value uniform (0 0 0); -// type directMappedNamedFixedValue; +// type directMapped; // fieldName Usf; // average (0 0 0); // setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/T b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/T index 21a4eadb2c..082d4cb3bc 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/T +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/T @@ -29,7 +29,7 @@ boundaryField wallFilm { type zeroGradient; -// type directMappedNamedFixedValue; +// type directMapped; // fieldName Tsf; // average 300; // setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/U b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/U index d114c24c03..9464847840 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/U +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0/U @@ -30,7 +30,7 @@ boundaryField { type fixedValue; value uniform (0 0 0); -// type directMappedNamedFixedValue; +// type directMapped; // fieldName Usf; // average (0 0 0); // setAverage no; diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/system/changeDictionaryDict b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/system/changeDictionaryDict index 055c1549d0..e8bc6994f0 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/system/changeDictionaryDict +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/system/changeDictionaryDict @@ -22,7 +22,7 @@ dictionaryReplacement { wallFilm { - type directMappedNamedFixedValue; + type directMapped; fieldName Tsf; average 300; setAverage no; @@ -37,7 +37,7 @@ dictionaryReplacement { wallFilm { - type directMappedNamedFixedValue; + type directMapped; fieldName Usf; average (0 0 0); setAverage no;