From 8cff734abce0e0a5e254f238d7dc892aff95e84c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 9 Oct 2018 18:22:40 +0200 Subject: [PATCH] ENH: improvements for ensightWrite function object (issue #926) - align input parameters and some of the behaviour with vtkWrite The output is now postProcessing/ for similar reasoning as mentioned in #866 - better alignment with other function objects, no data collision with foamToEnsight output. - separate controls for internal and boundary meshes - can restrict conversion based on zone names, enclosing volumes, bounding box. --- src/functionObjects/utilities/Make/files | 3 + .../utilities/ensightWrite/ensightWrite.C | 285 ++++++------------ .../utilities/ensightWrite/ensightWrite.H | 148 ++++++--- .../ensightWrite/ensightWriteTemplates.C | 60 ++-- .../ensightWrite/ensightWriteUpdate.C | 235 +++++++++++++++ 5 files changed, 453 insertions(+), 278 deletions(-) create mode 100644 src/functionObjects/utilities/ensightWrite/ensightWriteUpdate.C diff --git a/src/functionObjects/utilities/Make/files b/src/functionObjects/utilities/Make/files index 68074bcbe1..4390ef6bf5 100644 --- a/src/functionObjects/utilities/Make/files +++ b/src/functionObjects/utilities/Make/files @@ -1,7 +1,10 @@ abort/abort.C codedFunctionObject/codedFunctionObject.C + ensightWrite/ensightWrite.C +ensightWrite/ensightWriteUpdate.C + vtkWrite/vtkWrite.C vtkWrite/vtkWriteUpdate.C diff --git a/src/functionObjects/utilities/ensightWrite/ensightWrite.C b/src/functionObjects/utilities/ensightWrite/ensightWrite.C index 06bbd0307d..6840faf713 100644 --- a/src/functionObjects/utilities/ensightWrite/ensightWrite.C +++ b/src/functionObjects/utilities/ensightWrite/ensightWrite.C @@ -47,50 +47,21 @@ namespace functionObjects // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::bitSet Foam::functionObjects::ensightWrite::cellSelection() const +Foam::label Foam::functionObjects::ensightWrite::writeAllVolFields +( + const fvMeshSubset& proxy, + const wordHashSet& acceptField +) { - bitSet cellsToSelect; + label count = 0; - // Could also deal with cellZones here, as required + count += writeVolFields(proxy, acceptField); + count += writeVolFields(proxy, acceptField); + count += writeVolFields(proxy, acceptField); + count += writeVolFields(proxy, acceptField); + count += writeVolFields(proxy, acceptField); - if (bounds_.empty()) - { - return cellsToSelect; - } - - - const auto& cellCentres = static_cast(mesh_).C(); - - const label len = mesh_.nCells(); - - cellsToSelect.resize(len); - - for (label celli=0; celli < len; ++celli) - { - const point& cc = cellCentres[celli]; - - if (bounds_.contains(cc)) - { - cellsToSelect.set(celli); - } - } - - return cellsToSelect; -} - - - -int Foam::functionObjects::ensightWrite::process(const word& fieldName) -{ - int state = 0; - - writeVolField(fieldName, state); - writeVolField(fieldName, state); - writeVolField(fieldName, state); - writeVolField(fieldName, state); - writeVolField(fieldName, state); - - return state; + return count; } @@ -115,19 +86,24 @@ Foam::functionObjects::ensightWrite::ensightWrite ) ), caseOpts_(writeOpts_.format()), - selectFields_(), - dirName_("ensightWrite"), + outputDir_(), consecutive_(false), - bounds_() + meshState_(polyMesh::TOPO_CHANGE), + selectFields_(), + selection_(), + meshSubset_(mesh_), + ensCase_(nullptr), + ensMesh_(nullptr) { - if (postProcess) - { - // Disable for post-process mode. - // Emit as FatalError for the try/catch in the caller. - FatalError - << type() << " disabled in post-process mode" - << exit(FatalError); - } + // May still want this? (OCT-2018) + // if (postProcess) + // { + // // Disable for post-process mode. + // // Emit as FatalError for the try/catch in the caller. + // FatalError + // << type() << " disabled in post-process mode" + // << exit(FatalError); + // } read(dict); } @@ -139,16 +115,29 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); - // Ensure consistency - - meshSubset_.clear(); - ensMesh_.clear(); + readSelection(dict); - // - // writer options - // - writeOpts_.noPatches(dict.lookupOrDefault("noPatches", false)); + // Writer options + + consecutive_ = dict.lookupOrDefault("consecutive", false); + + writeOpts_.useBoundaryMesh(dict.lookupOrDefault("boundary", true)); + writeOpts_.useInternalMesh(dict.lookupOrDefault("internal", true)); + + + // Warn if noPatches keyword (1806) exists and contradicts our settings + // Cannot readily use Compat since the boolean has the opposite value. + if + ( + dict.lookupOrDefault("noPatches", false) + && writeOpts_.useBoundaryMesh() + ) + { + WarningInFunction + << "Use 'boundary' instead of 'noPatches' to enable/disable " + << "conversion of the boundaries" << endl; + } wordRes list; if (dict.readIfPresent("patches", list)) @@ -164,33 +153,35 @@ bool Foam::functionObjects::ensightWrite::read(const dictionary& dict) } - bounds_.clear(); - dict.readIfPresent("bounds", bounds_); - - - // - // case options - // + // Case options caseOpts_.nodeValues(dict.lookupOrDefault("nodeValues", false)); - caseOpts_.width(dict.lookupOrDefault