From 29d67c32406f6db8d2c449ba63259f1ad1774588 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 7 Nov 2008 18:14:06 +0000 Subject: [PATCH] averaging in isoSurfaces --- .../postProcessing/sampling/sample/sampleDict | 20 ++-- .../isoSurface/sampledIsoSurface.C | 93 +++++++++++-------- .../isoSurface/sampledIsoSurface.H | 3 + 3 files changed, 65 insertions(+), 51 deletions(-) diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index b3e489a176..57385a9555 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -40,7 +40,7 @@ surfaceFormat vtk; // 1] vertex values determined from neighbouring cell-centre values // 2] face values determined using the current face interpolation scheme // for the field (linear, gamma, etc.) -interpolationScheme cellPointFace; +interpolationScheme cellPoint; // Fields to sample. fields @@ -155,21 +155,21 @@ surfaces // Optional: whether to leave as faces (=default) or triangulate } -/* not yet (re)implemented -- constantIso { - name iso; - field rho; - value 0.5; + name isoSurface; + isoField rho; + isoValue 0.5; + interpolate false } - someIso + interpolatedIso { - type iso; - field rho; - value 0.5; + name isoSurface; + isoField rho; + isoValue 0.5; interpolate true; + //regularise false; //optional: do not simplify } - */ ); diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index d068b51120..2780d37f25 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -105,55 +105,65 @@ void Foam::sampledIsoSurface::createGeometry() const volPointInterpolation::New(fvm).interpolate(cellFld) ); - //- Direct from cell field and point field. Gives bad continuity. - const isoSurface iso - ( - fvm, - cellFld.internalField(), - pointFld().internalField(), - isoVal_, - regularise_ - ); + if (average_) + { + //- From point field and interpolated cell. + scalarField cellAvg(fvm.nCells(), scalar(0.0)); + labelField nPointCells(fvm.nCells(), 0); + { + for (label pointI = 0; pointI < fvm.nPoints(); pointI++) + { + const labelList& pCells = fvm.pointCells(pointI); - ////- From point field and interpolated cell. - //scalarField cellAvg(fvm.nCells(), scalar(0.0)); - //labelField nPointCells(fvm.nCells(), 0); - //{ - // for (label pointI = 0; pointI < fvm.nPoints(); pointI++) - // { - // const labelList& pCells = fvm.pointCells(pointI); - // - // forAll(pCells, i) - // { - // label cellI = pCells[i]; - // - // cellAvg[cellI] += pointFld().internalField()[pointI]; - // nPointCells[cellI]++; - // } - // } - //} - //forAll(cellAvg, cellI) - //{ - // cellAvg[cellI] /= nPointCells[cellI]; - //} - // - //const isoSurface iso - //( - // fvm, - // cellAvg, - // pointFld().internalField(), - // isoVal_, - // regularise_ - //); + forAll(pCells, i) + { + label cellI = pCells[i]; + cellAvg[cellI] += pointFld().internalField()[pointI]; + nPointCells[cellI]++; + } + } + } + forAll(cellAvg, cellI) + { + cellAvg[cellI] /= nPointCells[cellI]; + } + + const isoSurface iso + ( + fvm, + cellAvg, + pointFld().internalField(), + isoVal_, + regularise_ + ); + + const_cast(*this).triSurface::operator=(iso); + meshCells_ = iso.meshCells(); + } + else + { + //- Direct from cell field and point field. Gives bad continuity. + const isoSurface iso + ( + fvm, + cellFld.internalField(), + pointFld().internalField(), + isoVal_, + regularise_ + ); + + const_cast(*this).triSurface::operator=(iso); + meshCells_ = iso.meshCells(); + } - const_cast(*this).triSurface::operator=(iso); - meshCells_ = iso.meshCells(); if (debug) { Pout<< "sampledIsoSurface::createGeometry() : constructed iso:" << nl + << " regularise : " << regularise_ << nl + << " average : " << average_ << nl << " isoField : " << isoField_ << nl << " isoValue : " << isoVal_ << nl << " points : " << points().size() << nl @@ -177,6 +187,7 @@ Foam::sampledIsoSurface::sampledIsoSurface isoField_(dict.lookup("isoField")), isoVal_(readScalar(dict.lookup("isoValue"))), regularise_(dict.lookupOrDefault("regularise", true)), + average_(dict.lookupOrDefault("average", true)), zoneName_(word::null), facesPtr_(NULL), storedTimeIndex_(-1), diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H index e4213dbbde..02b62f151f 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H @@ -66,6 +66,9 @@ class sampledIsoSurface //- Whether to coarse const Switch regularise_; + //- Whether to recalculate cell values as average of point values + const Switch average_; + //- zone name (if restricted to zones) word zoneName_;