diff --git a/src/sampling/probes/patchProbes.C b/src/sampling/probes/patchProbes.C index e6a240fb41..fd6bec4b90 100644 --- a/src/sampling/probes/patchProbes.C +++ b/src/sampling/probes/patchProbes.C @@ -92,65 +92,60 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) ); - if (elementList_.empty()) + forAll(probeLocations(), probeI) { - elementList_.setSize(probeLocations().size()); + const point sample = probeLocations()[probeI]; - forAll(probeLocations(), probeI) + scalar span = boundaryTree.bb().mag(); + + pointIndexHit info = boundaryTree.findNearest + ( + sample, + Foam::sqr(span) + ); + + if (!info.hit()) { - const point sample = probeLocations()[probeI]; - - scalar span = boundaryTree.bb().mag(); - - pointIndexHit info = boundaryTree.findNearest + info = boundaryTree.findNearest ( sample, - Foam::sqr(span) + Foam::sqr(GREAT) + ); + } + + label faceI = boundaryTree.shapes().faceLabels()[info.index()]; + + const label patchi = bm.whichPatch(faceI); + + if (isA(bm[patchi])) + { + WarningIn + ( + " Foam::patchProbes::findElements(const fvMesh&)" + ) + << " The sample point: " << sample + << " belongs to " << patchi + << " which is an empty patch. This is not permitted. " + << " This sample will not be included " + << endl; + } + else + { + const point& fc = mesh.faceCentres()[faceI]; + + directMappedPatchBase::nearInfo sampleInfo; + + sampleInfo.first() = pointIndexHit + ( + true, + fc, + faceI ); - if (!info.hit()) - { - info = boundaryTree.findNearest - ( - sample, - Foam::sqr(GREAT) - ); - } + sampleInfo.second().first() = magSqr(fc-sample); + sampleInfo.second().second() = Pstream::myProcNo(); - label faceI = boundaryTree.shapes().faceLabels()[info.index()]; - - const label patchi = bm.whichPatch(faceI); - - if (isA(bm[patchi])) - { - WarningIn - ( - " Foam::patchProbes::findElements(const fvMesh&)" - ) - << " The sample point: " << sample - << " belongs to " << patchi - << " which is an empty patch. This is not permitted. " - << " This sample will not be included " - << endl; - } - else - { - const point& fc = mesh.faceCentres()[faceI]; - - directMappedPatchBase::nearInfo sampleInfo; - - sampleInfo.first() = pointIndexHit - ( - true, - fc, - faceI - ); - - sampleInfo.second().first() = magSqr(fc-sample); - sampleInfo.second().second() = Pstream::myProcNo(); - - nearest[probeI]= sampleInfo; - } + nearest[probeI]= sampleInfo; } } } @@ -171,25 +166,21 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) Info<< " " << sampleI << " coord:"<< operator[](sampleI) << " found on processor:" << procI << " in local cell/face:" << localI - << " with cc:" << nearest[sampleI].first().rawPoint() << endl; + << " with fc:" << nearest[sampleI].first().rawPoint() << endl; } } - // Check if all patchProbes have been found. + + // Extract any local faces to sample + elementList_.setSize(nearest.size(), -1); + forAll(nearest, sampleI) { - label localI = -1; if (nearest[sampleI].second().second() == Pstream::myProcNo()) { - localI = nearest[sampleI].first().index(); + // Store the face to sample + elementList_[sampleI] = nearest[sampleI].first().index(); } - - if (elementList_.empty()) - { - elementList_.setSize(probeLocations().size()); - } - - elementList_[sampleI] = localI; } } @@ -206,6 +197,12 @@ Foam::patchProbes::patchProbes : probes(name, obr, dict, loadFromFiles) { + // When constructing probes above it will have called the + // probes::findElements (since the virtual mechanism not yet operating). + // Not easy to workaround (apart from feeding through flag into constructor) + // so clear out any cells found for now. + elementList_.clear(); + read(dict); } @@ -230,6 +227,7 @@ void Foam::patchProbes::write() void Foam::patchProbes::read(const dictionary& dict) { + dict.lookup("patchName") >> patchName_; probes::read(dict); } diff --git a/src/sampling/probes/probes.H b/src/sampling/probes/probes.H index b3a22afe2d..1c2761e349 100644 --- a/src/sampling/probes/probes.H +++ b/src/sampling/probes/probes.H @@ -206,7 +206,7 @@ public: } //- Cells to be probed (obtained from the locations) - const labelList& elemets() const + const labelList& elements() const { return elementList_; } diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C index bb6e27c34b..9068904d50 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C @@ -175,7 +175,9 @@ void Foam::MarshakRadiationFvPatchScalarField::updateCoeffs() const scalarField& gamma = patch().lookupPatchField("gammaRad"); - const scalarField Ep(emissivity()/(2.0*(2.0 - emissivity()))); + const scalarField temissivity = emissivity(); + + const scalarField Ep(temissivity/(2.0*(2.0 - temissivity))); // Set value fraction valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep); diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C index f13bdf2e15..711ac43bd9 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C @@ -176,7 +176,9 @@ void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::updateCoeffs() const scalarField& gamma = patch().lookupPatchField("gammaRad"); - const scalarField Ep(emissivity()/(2.0*(scalar(2.0) - emissivity()))); + const scalarField temissivity = emissivity(); + + const scalarField Ep(temissivity/(2.0*(scalar(2.0) - temissivity))); // Set value fraction valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep); diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C index 4416ce0157..57acb81533 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -194,7 +194,7 @@ updateCoeffs() ray.Qr().boundaryField()[patchI] += Iw*(n & ray.dAve()); - scalarList temissivity = emissivity(); + scalarField temissivity = emissivity(); forAll(Iw, faceI) { diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C index f74930b729..ff0bb83b46 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C @@ -194,7 +194,7 @@ updateCoeffs() dom.blackBody().bLambda(lambdaId).boundaryField()[patchI] ); - scalarList temissivity = emissivity(); + scalarField temissivity = emissivity(); forAll(Iw, faceI) {