From 4bf0ae136c6698c038b6c25e4d51a6a31bd963e0 Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Tue, 21 Jul 2009 16:51:21 +0100 Subject: [PATCH] empty handling --- .../isoSurface/isoSurfaceTemplates.C | 6 ++- .../sampledCuttingPlane/sampledCuttingPlane.C | 53 ++++++++++++++++--- 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C b/src/sampling/sampledSurface/isoSurface/isoSurfaceTemplates.C index bddf6fedf21..1a7a68ad4c9 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 85dbeca5959..2bcf3784b6e 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(); + } } } } -- GitLab