diff --git a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C index e9a32b05d0..6f48d62c76 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/directMappedFixedValue/directMappedFixedValueFvPatchField.C @@ -26,7 +26,7 @@ License #include "directMappedFixedValueFvPatchField.H" #include "directMappedFvPatch.H" -#include "fvBoundaryMesh.H" +#include "volFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -164,6 +164,38 @@ void directMappedFixedValueFvPatchField::updateCoeffs() Field newValues(this->size()); + Field sendValues(this->size()); + + switch(mpp.mode()) + { + case directMappedPolyPatch::NEARESTCELL: + { + sendValues = this->internalField(); + break; + } + case directMappedPolyPatch::NEARESTPATCHFACE: + { + const label patchID = + this->patch().patch().boundaryMesh().findPatchID + ( + mpp.samplePatch() + ); + typedef GeometricField fieldType; + const word& fieldName = this->dimensionedInternalField().name(); + const fieldType& sendField = + this->db().objectRegistry::lookupObject(fieldName); + sendValues = sendField.boundaryField()[patchID]; + break; + } + default: + { + FatalErrorIn + ( + "directMappedFixedValueFvPatchField::updateCoeffs()" + )<< "patch can only be used in NEARESTCELL or NEARESTPATCHFACE " + << "mode" << nl << abort(FatalError); + } + } forAll(schedule, i) { @@ -174,11 +206,7 @@ void directMappedFixedValueFvPatchField::updateCoeffs() if (Pstream::myProcNo() == sendProc) { OPstream toProc(Pstream::blocking, recvProc); - toProc<< IndirectList - ( - this->internalField(), - sendLabels[recvProc] - )(); + toProc<< IndirectList(sendValues, sendLabels[recvProc])(); } else { @@ -201,12 +229,8 @@ void directMappedFixedValueFvPatchField::updateCoeffs() // Do data from myself { - IndirectList fromFld - ( - this->internalField(), - sendLabels[Pstream::myProcNo()] - ); - + IndirectList fromFld(sendValues, sendLabels[Pstream::myProcNo()]); + // Destination faces const labelList& faceLabels = receiveFaceLabels[Pstream::myProcNo()]; @@ -220,7 +244,7 @@ void directMappedFixedValueFvPatchField::updateCoeffs() if (setAverage_) { - Type averagePsi = + Type averagePsi = gSum(this->patch().magSf()*newValues) /gSum(this->patch().magSf()); diff --git a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H index 144994d09a..152b727a5b 100644 --- a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H +++ b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H @@ -271,7 +271,19 @@ public: // Member functions - //- Offset vector (from patch faces to internal cells) + //- What to sample + const sampleMode& mode() const + { + return mode_; + } + + //- Patch (only if NEARESTBOUNDARY) + const word& samplePatch() const + { + return samplePatch_; + } + + //- Offset vector (from patch faces to destination mesh objects) const vector& offset() const { return offset_; @@ -290,11 +302,18 @@ public: //- Cells/faces to sample per processor const labelListList& sendLabels() const { - Pout<< "Asking for sendLabels." << endl; + if (debug) + { + Pout<< "Asking for sendLabels." << endl; + } + if (!sendLabelsPtr_.valid()) { - Pout<< "Calculating mapping." << endl; - calcMapping(); + if (debug) + { + Pout<< "Calculating mapping." << endl; + calcMapping(); + } } return sendLabelsPtr_(); } @@ -302,11 +321,18 @@ public: //- Patch faces to receive per processor const labelListList& receiveFaceLabels() const { - Pout<< "Asking for receiveFaceLabels." << endl; + if (debug) + { + Pout<< "Asking for receiveFaceLabels." << endl; + } + if (!receiveFaceLabelsPtr_.valid()) { - Pout<< "Calculating mapping." << endl; - calcMapping(); + if (debug) + { + Pout<< "Calculating mapping." << endl; + calcMapping(); + } } return receiveFaceLabelsPtr_(); }