From 4245909efb9b2c394c82227ae156d16184c1273f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 3 Feb 2021 15:05:36 +0100 Subject: [PATCH 1/6] BUG: typo in etc/colourTables --- etc/colourTables | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/colourTables b/etc/colourTables index 0ffe648f9a..a388aaae0a 100644 --- a/etc/colourTables +++ b/etc/colourTables @@ -44,7 +44,7 @@ coldAndHot fire { // ParaView: Black-Body Radiation - interpolate rbg; + interpolate rgb; table ( @@ -70,7 +70,7 @@ rainbow greyscale { // ParaView: grayscale - interpolate rbg; + interpolate rgb; table ( @@ -82,7 +82,7 @@ greyscale xray { // ParaView: "X ray" - interpolate rbg; + interpolate rgb; table ( From 77c31a7bef284cb7a2e6afdcc77de1a169a82884 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 10 Feb 2021 13:03:50 +0100 Subject: [PATCH 2/6] BUG: inconsistent surfaceFieldValue writing (fixes #1999) - setup writer outside the data loop to ensure that the number of output fields is correct (VTK format). - ignore 'interpolate' on sampled surfaces to ensure proper face sampling, never allow point sampling BUG: incorrect debug-switch for sampledIsoSurface --- .../surfaceFieldValue/surfaceFieldValue.C | 22 +---- .../surfaceFieldValueTemplates.C | 84 ++++++++++++------- .../isoSurface/sampledIsoSurface.H | 4 +- 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 23c52913b6..6b1684577b 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -1034,16 +1034,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::read mesh_, dict.subDict("sampledSurfaceDict") ); - - if (sampledPtr_->interpolate()) - { - // Should probably ignore interpolate entirely, - // but the oldest isoSurface algorithm requires it! - WarningInFunction - << type() << ' ' << name() << ": " - << "sampledSurface with interpolate = true " - << "is likely incorrect" << nl << nl; - } } Info<< type() << ' ' << name() << ':' << nl @@ -1061,15 +1051,6 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::read if (usesWeight()) { - if (stSampled == regionType_) - { - FatalIOErrorInFunction(dict) - << "Cannot use weighted operation '" - << operationTypeNames_[operation_] - << "' for sampledSurface" - << exit(FatalIOError); - } - // Can have "weightFields" or "weightField" bool missing = true; @@ -1140,6 +1121,9 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::read ) ); + // Propagate field counts (per surface) + surfaceWriterPtr_->nFields() = fields_.size(); + if (debug) { surfaceWriterPtr_->verbose(true); diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C index 20effe990b..9db9386e64 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValueTemplates.C @@ -96,18 +96,13 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::getFieldValues if (sampledPtr_) { - if (sampledPtr_->interpolate()) - { - const interpolationCellPoint interp(fld); + // Could be runtime selectable + // auto sampler = interpolation::New(sampleFaceScheme_, fld); - return sampledPtr_->interpolate(interp); - } - else - { - const interpolationCell interp(fld); + // const interpolationCellPoint interp(fld); + const interpolationCell interp(fld); - return sampledPtr_->sample(interp); - } + return sampledPtr_->sample(interp); } else { @@ -324,6 +319,30 @@ Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll { label nProcessed = 0; + // If using the surface writer, the points/faces parameters have already + // been merged on the master and the writeValues routine will also gather + // all data onto the master before calling the writer. + // Thus only call the writer on master! + + // Begin writer time step + if (Pstream::master() && surfaceWriterPtr_ && surfaceWriterPtr_->enabled()) + { + auto& writer = *surfaceWriterPtr_; + + writer.open + ( + points, + faces, + ( + outputDir() + / regionTypeNames_[regionType_] + ("_" + regionName_) + ), + false // serial - already merged + ); + + writer.beginTime(time_); + } + for (const word& fieldName : fields_) { if @@ -349,6 +368,23 @@ Foam::label Foam::functionObjects::fieldValues::surfaceFieldValue::writeAll } } + // Finish writer time step + if (Pstream::master() && surfaceWriterPtr_ && surfaceWriterPtr_->enabled()) + { + auto& writer = *surfaceWriterPtr_; + + // Write geometry if no fields were written so that we still + // can have something to look at. + + if (!writer.wroteData()) + { + writer.write(); + } + + writer.endTime(); + writer.clear(); + } + return nProcessed; } @@ -377,29 +413,13 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues if (Pstream::master()) { - surfaceWriterPtr_->open - ( - points, - faces, - ( - outputDir() - / regionTypeNames_[regionType_] + ("_" + regionName_) - ), - false // serial - already merged - ); + fileName outputName = + surfaceWriterPtr_->write(fieldName, allValues); - // Point data? Should probably disallow - if (sampledPtr_) - { - surfaceWriterPtr_->isPointData() = - sampledPtr_->interpolate(); - } - - surfaceWriterPtr_->nFields() = 1; // Needed for VTK legacy - - surfaceWriterPtr_->write(fieldName, allValues); - - surfaceWriterPtr_->clear(); + // Case-local file name with "" to make relocatable + dictionary propsDict; + propsDict.add("file", time_.relativePath(outputName, true)); + this->setProperty(fieldName, propsDict); } } diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H index b78aa1dcbb..41c42189c2 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -215,7 +215,7 @@ protected: public: //- Runtime type information - TypeName("samplediIsoSurfacePoint"); + TypeName("sampledIsoSurface"); // Constructors From 9913dfb31aa6a3147d203b5c32fc44ad8f73ca6c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 10 Feb 2021 13:19:27 +0100 Subject: [PATCH 3/6] CONFIG: bump patch level --- META-INFO/api-info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/META-INFO/api-info b/META-INFO/api-info index 7695e780f5..04d551248b 100644 --- a/META-INFO/api-info +++ b/META-INFO/api-info @@ -1,2 +1,2 @@ api=2012 -patch=0 +patch=210210 From 0ee7a23504df99ef623af02d85e49ec5c4237132 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 15 Feb 2021 12:02:42 +0100 Subject: [PATCH 4/6] CONFIG: ensure PV_PLUGIN_PATH is also in the library path --- bin/paraFoam | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/paraFoam b/bin/paraFoam index 33c5216071..cde84ad314 100755 --- a/bin/paraFoam +++ b/bin/paraFoam @@ -7,7 +7,7 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 2011-2016 OpenFOAM Foundation -# Copyright (C) 2016-2020 OpenCFD Ltd. +# Copyright (C) 2016-2021 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -140,8 +140,8 @@ do esac else echo "Ignore bad/invalid plugin-path: $pluginPath" 1>&2 - unset pluginPath fi + unset pluginPath ;; -block*) # Silently accepts -blockMesh @@ -238,8 +238,11 @@ then ;; esac - if [ -n "$pluginError" ] + if [ -z "$pluginError" ] then + # Ensure plugin is also in the lib-path + LD_LIBRARY_PATH="${PV_PLUGIN_PATH}:$LD_LIBRARY_PATH" + else cat<< NO_PLUGIN 1>&2 $pluginError See '${0##*/} -help-build' for more information From ae8ccd7b94af21945c74f802becbf96d9fe1ce1a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 15 Feb 2021 13:07:53 +0100 Subject: [PATCH 5/6] BUG: foamToEnsight cellZones missing mesh coverage (closes #2002) --- src/fileFormats/ensight/mesh/ensightMesh.C | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fileFormats/ensight/mesh/ensightMesh.C b/src/fileFormats/ensight/mesh/ensightMesh.C index 65c5e5bbd9..9faae73675 100644 --- a/src/fileFormats/ensight/mesh/ensightMesh.C +++ b/src/fileFormats/ensight/mesh/ensightMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -199,6 +199,9 @@ void Foam::ensightMesh::correct() if (returnReduce(!zn.empty(), orOp())) { + // Ensure full mesh coverage + cellSelection.resize(mesh_.nCells()); + cellSelection.set(zn); ensightCells& part = cellZoneParts_(zoneId); @@ -267,6 +270,7 @@ void Foam::ensightMesh::correct() if (returnReduce(!cellSelection.empty(), orOp())) { + // Ensure full mesh coverage excludeFace.resize(mesh_.nFaces()); const labelList& owner = mesh_.faceOwner(); @@ -288,6 +292,7 @@ void Foam::ensightMesh::correct() if (fzoneIds.size()) { + // Ensure full mesh coverage excludeFace.resize(mesh_.nFaces()); for (const polyPatch& p : mesh_.boundaryMesh()) From a334aaae7869c955659e46c75a301b336d6d8011 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Mon, 15 Feb 2021 12:51:35 +0000 Subject: [PATCH 6/6] ENH: noiseModel gainX - protect against very small input frequencies --- .../noise/noiseModels/noiseModel/noiseModel.C | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C index 82cd1e9c4f..efc36e3346 100644 --- a/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C +++ b/src/randomProcesses/noise/noiseModels/noiseModel/noiseModel.C @@ -434,6 +434,11 @@ Foam::scalar Foam::noiseModel::RAf(const scalar f) const Foam::scalar Foam::noiseModel::gainA(const scalar f) const { + if (f < SMALL) + { + return 0; + } + return 20*log10(RAf(f)) - 20*log10(RAf(1000)); } @@ -456,6 +461,11 @@ Foam::scalar Foam::noiseModel::RBf(const scalar f) const Foam::scalar Foam::noiseModel::gainB(const scalar f) const { + if (f < SMALL) + { + return 0; + } + return 20*log10(RBf(f)) - 20*log10(RBf(1000)); } @@ -473,6 +483,11 @@ Foam::scalar Foam::noiseModel::RCf(const scalar f) const Foam::scalar Foam::noiseModel::gainC(const scalar f) const { + if (f < SMALL) + { + return 0; + } + return 20*log10(RCf(f)) - 20*log10(RCf(1000)); } @@ -492,6 +507,11 @@ Foam::scalar Foam::noiseModel::RDf(const scalar f) const Foam::scalar Foam::noiseModel::gainD(const scalar f) const { + if (f < SMALL) + { + return 0; + } + return 20*log10(RDf(f)); }