diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C b/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C index bddf6fedf21c5a621bb76bddabbb19a02c503fb6..1a7a68ad4c9908a11e893ef5c5e56485c0e32091 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C +++ b/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C @@ -81,7 +81,11 @@ Foam::isoSurface::adaptPatchFields { const polyPatch& pp = patches[patchI]; - if (isA<emptyPolyPatch>(pp)) + if + ( + isA<emptyPolyPatch>(pp) + && pp.size() != sliceFld.boundaryField()[patchI].size() + ) { // Clear old value. Cannot resize it since is a slice. sliceFld.boundaryField().set(patchI, NULL); diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index 85dbeca59590d134b6e7fca455dd391229119de2..2bcf3784b6ec83f34120b70032f71e9bf8b4bb9b 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -37,7 +37,13 @@ License namespace Foam { defineTypeNameAndDebug(sampledCuttingPlane, 0); - addNamedToRunTimeSelectionTable(sampledSurface, sampledCuttingPlane, word, cuttingPlane); + addNamedToRunTimeSelectionTable + ( + sampledSurface, + sampledCuttingPlane, + word, + cuttingPlane + ); } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -118,7 +124,7 @@ void Foam::sampledCuttingPlane::createGeometry() // Internal field { - const pointField& cc = fvm.C(); + const pointField& cc = fvm.cellCentres(); scalarField& fld = cellDistance.internalField(); forAll(cc, i) @@ -130,14 +136,45 @@ void Foam::sampledCuttingPlane::createGeometry() // Patch fields { - forAll(fvm.C().boundaryField(), patchI) + forAll(cellDistance.boundaryField(), patchI) { - const pointField& cc = fvm.C().boundaryField()[patchI]; - fvPatchScalarField& fld = cellDistance.boundaryField()[patchI]; - - forAll(fld, i) + if + ( + isA<emptyFvPatchScalarField> + ( + cellDistance.boundaryField()[patchI] + ) + ) { - fld[i] = (cc[i] - plane_.refPoint()) & plane_.normal(); + cellDistance.boundaryField().set + ( + patchI, + new calculatedFvPatchScalarField + ( + fvm.boundary()[patchI], + cellDistance + ) + ); + + const polyPatch& pp = fvm.boundary()[patchI].patch(); + pointField::subField cc = pp.patchSlice(fvm.faceCentres()); + + fvPatchScalarField& fld = cellDistance.boundaryField()[patchI]; + fld.setSize(pp.size()); + forAll(fld, i) + { + fld[i] = (cc[i] - plane_.refPoint()) & plane_.normal(); + } + } + else + { + const pointField& cc = fvm.C().boundaryField()[patchI]; + fvPatchScalarField& fld = cellDistance.boundaryField()[patchI]; + + forAll(fld, i) + { + fld[i] = (cc[i] - plane_.refPoint()) & plane_.normal(); + } } } }