From c85daee12c213ea451a2ce9fc19a06445b8023b3 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 4 Oct 2017 15:23:06 +0100 Subject: [PATCH] paraFoam: Added support for wildcards in etc/paraFoam::defaultFields Specifying default fields for complex and multi-phase cases is simplified and generalized by using wildcards to select sets of related field names, e.g. defaultFields (p p_rgh U "U\..*" T "T\..*" "alpha\..*"); selects the velocity, temperature and phase-fraction fields of all phases in addition to the pressure fields. --- .../PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C | 4 +- .../vtkPVFoam/vtkPVFoamUpdateInfoFields.H | 49 ++++++++++++++----- etc/paraFoam | 2 +- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C index ba94d02696..2f1c0add6d 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfo.C @@ -451,12 +451,12 @@ void Foam::vtkPVFoam::updateInfoPatches if (!reader_->GetShowGroupsOnly()) { - wordReList defaultPatchTypes + const wordReList defaultPatchTypes ( configDict_.lookupOrDefault ( "defaultPatchTypes", - wordReList{"patch", "wall"} + wordReList(wordList({"patch", "wall"})) ) ); diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfoFields.H b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfoFields.H index 4490957da4..5081c71033 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfoFields.H +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoamUpdateInfoFields.H @@ -45,19 +45,51 @@ void Foam::vtkPVFoam::updateInfoFields << endl; } + // Use the db directly since this might be called without a mesh, + // but the region must get added back in + word regionPrefix; + if (meshRegion_ != polyMesh::defaultRegion) + { + regionPrefix = meshRegion_; + } + + const instantList times = dbPtr_().times(); + stringList enabledEntries; if (select->GetNumberOfArrays() == 0 && !meshPtr_) { - wordList defaultFields + const wordReList defaultFieldRes ( - configDict_.lookupOrDefault("defaultFields", wordList{"p", "U"}) + configDict_.lookupOrDefault + ( + "defaultFields", + wordReList(wordList{"p", "U"}) + ) + ); + + wordHashSet objectNameSet; + forAll(times, timei) + { + // Search for list of objects for this time and mesh region + IOobjectList objects(dbPtr_(), times[timei].name(), regionPrefix); + + forAllConstIter(IOobjectList, objects, iter) + { + objectNameSet.insert(iter.key()); + } + } + + const wordList objectNames(objectNameSet.toc()); + const labelList defaultFields + ( + findStrings(defaultFieldRes, objectNames) ); enabledEntries.setSize(defaultFields.size()); forAll(defaultFields, i) { - enabledEntries[i] = defaultFields[i]; + enabledEntries[i] = objectNames[defaultFields[i]]; } } else @@ -68,15 +100,6 @@ void Foam::vtkPVFoam::updateInfoFields select->RemoveAllArrays(); - // use the db directly since this might be called without a mesh, - // but the region must get added back in - word regionPrefix; - if (meshRegion_ != polyMesh::defaultRegion) - { - regionPrefix = meshRegion_; - } - - instantList times = dbPtr_().times(); forAll(times, timei) { // Search for list of objects for this time and mesh region @@ -110,7 +133,7 @@ void Foam::vtkPVFoam::updateInfoFields ); } - // restore the enabled selections + // Restore the enabled selections setSelectedArrayEntries(select, enabledEntries); if (debug) diff --git a/etc/paraFoam b/etc/paraFoam index a80a98f620..a7d58c7d62 100644 --- a/etc/paraFoam +++ b/etc/paraFoam @@ -15,7 +15,7 @@ FoamFile // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -defaultFields (U p p_rgh T alpha.water alpha.air); +defaultFields (p p_rgh U "U\..*" T "T\..*" "alpha\..*"); defaultPatchTypes (patch wall);