From 07ddd52d6a26976d2931f555d4f0ccff0c23937c Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Sep 2012 17:09:53 +0100 Subject: [PATCH 01/10] ENH: patchGroups: disable patch display --- .../PV3FoamReader/PV3FoamReader_SM.xml | 19 ++++- .../PV3FoamReader/pqPV3FoamReaderPanel.cxx | 50 ++++++++++++- .../PV3FoamReader/pqPV3FoamReaderPanel.h | 6 +- .../PV3FoamReader/vtkPV3FoamReader.cxx | 16 +++- .../PV3FoamReader/vtkPV3FoamReader.h | 8 +- .../PV3FoamReader/vtkPV3Foam/Make/files | 1 - .../PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H | 13 +++- .../PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C | 44 +++++++++-- ...3FoamMeshPatch.C => vtkPV3FoamTemplates.C} | 13 +++- .../vtkPV3Foam/vtkPV3FoamUpdateInfo.C | 73 +++++++++++-------- 10 files changed, 189 insertions(+), 54 deletions(-) rename applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/{vtkPV3FoamMeshPatch.C => vtkPV3FoamTemplates.C} (87%) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml index 10873c3734..a798530ce8 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml @@ -107,7 +107,6 @@ Use vtkPolyhedron instead of decomposing polyhedra. - !!Actually uses vtkConvexPointSet until this is properly supported in VTK!! @@ -154,6 +153,20 @@ + + + + + Show groups only + + + - This property contains a list of the mesh parts (patches, sets, zones). + This property contains a list of the mesh parts + (patches, groups, sets, zones). @@ -281,6 +295,7 @@ + diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx index 66327dc6f5..babdd460c9 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -109,7 +109,7 @@ pqPV3FoamReaderPanel::pqPV3FoamReaderPanel QFrame* hline1 = new QFrame(this); hline1->setFrameStyle(QFrame::HLine | QFrame::Sunken); - form->addWidget(hline1, 1, 0, 1, 2); + form->addWidget(hline1, 1, 0, 1, 3); // checkbox for caching mesh if ((prop = this->proxy()->GetProperty("UiCacheMesh")) != 0) @@ -166,6 +166,34 @@ pqPV3FoamReaderPanel::pqPV3FoamReaderPanel } + // checkbox for Groups Only + if ((prop = this->proxy()->GetProperty("UiShowGroupsOnly")) != 0) + { + // immediate update on the Server Manager side + prop->SetImmediateUpdate(true); + + ShowGroupsOnly_ = new QCheckBox("Groups Only"); + ShowGroupsOnly_->setChecked + ( + vtkSMIntVectorProperty::SafeDownCast(prop)->GetElement(0) + ); + ShowGroupsOnly_->setToolTip + ( + "Show patchGroups only." + ); + + // row/col 2, 2 + form->addWidget(ShowGroupsOnly_, 2, 2, Qt::AlignLeft); + connect + ( + ShowGroupsOnly_, + SIGNAL(stateChanged(int)), + this, + SLOT(ShowGroupsOnlyToggled()) + ); + } + + // checkbox for include sets if ((prop = this->proxy()->GetProperty("UiIncludeSets")) != 0) { @@ -278,7 +306,7 @@ pqPV3FoamReaderPanel::pqPV3FoamReaderPanel QFrame* hline2 = new QFrame(this); hline2->setFrameStyle(QFrame::HLine | QFrame::Sunken); - form->addWidget(hline2, 5, 0, 1, 2); + form->addWidget(hline2, 5, 0, 1, 3); } @@ -336,6 +364,22 @@ void pqPV3FoamReaderPanel::ShowPatchNamesToggled() } +void pqPV3FoamReaderPanel::ShowGroupsOnlyToggled() +{ + vtkSMProperty* prop; + + vtkSMIntVectorProperty::SafeDownCast + ( + this->proxy()->GetProperty("UiShowGroupsOnly") + )->SetElement(0, ShowGroupsOnly_->isChecked()); + + if ((prop = this->proxy()->GetProperty("PartArrayStatus")) != 0) + { + this->proxy()->UpdatePropertyInformation(prop); + } +} + + void pqPV3FoamReaderPanel::IncludeSetsToggled() { vtkSMProperty* prop; diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h index f7b057ecc7..c4594c257e 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -71,6 +71,9 @@ class pqPV3FoamReaderPanel //- Show Patch Names checkbox QCheckBox* ShowPatchNames_; + //- Show Groups Only checkbox + QCheckBox* ShowGroupsOnly_; + //- IncludeSets checkbox QCheckBox* IncludeSets_; @@ -90,6 +93,7 @@ protected slots: void ZeroTimeToggled(); void RefreshPressed(); void ShowPatchNamesToggled(); + void ShowGroupsOnlyToggled(); void IncludeSetsToggled(); void IncludeZonesToggled(); void InterpolateVolFieldsToggled(); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index a2671ddb9d..27c3f63fe5 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,6 +85,7 @@ vtkPV3FoamReader::vtkPV3FoamReader() IncludeSets = 0; IncludeZones = 0; ShowPatchNames = 0; + ShowGroupsOnly = 0; InterpolateVolFields = 1; UpdateGUI = 0; @@ -463,6 +464,19 @@ void vtkPV3FoamReader::SetShowPatchNames(int val) } +void vtkPV3FoamReader::SetShowGroupsOnly(int val) +{ + if (ShowGroupsOnly != val) + { + ShowGroupsOnly = val; + if (foamData_) + { + foamData_->updateInfo(); + } + } +} + + void vtkPV3FoamReader::updatePatchNamesView(const bool show) { pqApplicationCore* appCore = pqApplicationCore::instance(); diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h index da31ba6231..aa4bec44b6 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -121,6 +121,11 @@ public: virtual void SetShowPatchNames(int); vtkGetMacro(ShowPatchNames, int); + // Description: + // OpenFOAM display patchGroups + virtual void SetShowGroupsOnly(int); + vtkGetMacro(ShowGroupsOnly, int); + // Description: // OpenFOAM volField interpolation vtkSetMacro(InterpolateVolFields, int); @@ -231,6 +236,7 @@ private: int IncludeSets; int IncludeZones; int ShowPatchNames; + int ShowGroupsOnly; int InterpolateVolFields; //- Dummy variable/switch to invoke a reader update diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/files b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/files index e71b857bb2..685ea2e8a0 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/files +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/files @@ -2,7 +2,6 @@ vtkPV3Foam.C vtkPV3FoamFields.C vtkPV3FoamMesh.C vtkPV3FoamMeshLagrangian.C -vtkPV3FoamMeshPatch.C vtkPV3FoamMeshSet.C vtkPV3FoamMeshVolume.C vtkPV3FoamMeshZone.C diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H index b4d031b7ec..397dc7ecc2 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,7 +33,7 @@ SourceFiles vtkPV3FoamFields.C vtkPV3FoamMesh.C vtkPV3FoamMeshLagrangian.C - vtkPV3FoamMeshPatch.C + vtkPV3FoamTemplates.C vtkPV3FoamMeshSet.C vtkPV3FoamMeshVolume.C vtkPV3FoamMeshZone.C @@ -443,7 +443,8 @@ class vtkPV3Foam ); //- Add patch mesh - vtkPolyData* patchVTKMesh(const polyPatch&); + template + vtkPolyData* patchVTKMesh(const word& name, const PatchType&); //- Add face zone mesh vtkPolyData* faceZoneVTKMesh @@ -736,6 +737,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository +# include "vtkPV3FoamTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C index c77216d858..b229da9479 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,7 @@ License #include "pointSet.H" #include "fvMeshSubset.H" #include "vtkPV3FoamReader.h" +#include "uindirectPrimitivePatch.H" // VTK includes #include "vtkDataArraySelection.h" @@ -171,21 +172,50 @@ void Foam::vtkPV3Foam::convertMeshPatches for (int partId = range.start(); partId < range.end(); ++partId) { - const word patchName = getPartName(partId); - const label patchId = patches.findPatchID(patchName); - - if (!partStatus_[partId] || patchId < 0) + if (!partStatus_[partId]) { continue; } + const word patchName = getPartName(partId); + + labelHashSet patchIds(patches.patchSet(List(1, patchName))); + if (debug) { - Info<< "Creating VTK mesh for patch[" << patchId <<"] " + Info<< "Creating VTK mesh for patches [" << patchIds <<"] " << patchName << endl; } - vtkPolyData* vtkmesh = patchVTKMesh(patches[patchId]); + vtkPolyData* vtkmesh = NULL; + if (patchIds.size() == 1) + { + vtkmesh = patchVTKMesh(patchName, patches[patchIds.begin().key()]); + } + else + { + // Patch group. Collect patch faces. + label sz = 0; + forAllConstIter(labelHashSet, patchIds, iter) + { + sz += patches[iter.key()].size(); + } + labelList meshFaceLabels(sz); + sz = 0; + forAllConstIter(labelHashSet, patchIds, iter) + { + const polyPatch& pp = patches[iter.key()]; + forAll(pp, i) + { + meshFaceLabels[sz++] = pp.start()+i; + } + } + UIndirectList fcs(mesh.faces(), meshFaceLabels); + uindirectPrimitivePatch pp(fcs, mesh.points()); + + vtkmesh = patchVTKMesh(patchName, pp); + } + if (vtkmesh) { diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamTemplates.C similarity index 87% rename from applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamTemplates.C index 29f64dc5af..605fb463ef 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,13 +37,18 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh(const polyPatch& p) +template +vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh +( + const word& name, + const PatchType& p +) { vtkPolyData* vtkmesh = vtkPolyData::New(); if (debug) { - Info<< " Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl; + Info<< " Foam::vtkPV3Foam::patchVTKMesh - " << name << endl; printMemory(); } @@ -83,7 +88,7 @@ vtkPolyData* Foam::vtkPV3Foam::patchVTKMesh(const polyPatch& p) if (debug) { - Info<< " Foam::vtkPV3Foam::patchVTKMesh - " << p.name() << endl; + Info<< " Foam::vtkPV3Foam::patchVTKMesh - " << name << endl; printMemory(); } diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C index 642e5dbaae..ac66e9279e 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -241,7 +241,6 @@ void Foam::vtkPV3Foam::updateInfoPatches { const polyBoundaryMesh& patches = meshPtr_->boundaryMesh(); const HashTable& groups = patches.groupPatchIDs(); - const wordList allPatchNames = patches.names(); // Add patch groups @@ -273,13 +272,16 @@ void Foam::vtkPV3Foam::updateInfoPatches if (enabledEntriesSet.found(vtkGrpName)) { - forAll(patchIDs, i) + //enabledEntriesSet.erase(vtkGrpName); + if (!reader_->GetShowGroupsOnly()) { - const polyPatch& pp = patches[patchIDs[i]]; - string vtkPatchName = pp.name() + " - patch"; - enabledEntriesSet.insert(vtkPatchName); + forAll(patchIDs, i) + { + const polyPatch& pp = patches[patchIDs[i]]; + string vtkPatchName = pp.name() + " - patch"; + enabledEntriesSet.insert(vtkPatchName); + } } - enabledEntriesSet.erase(vtkGrpName); } } } @@ -288,19 +290,22 @@ void Foam::vtkPV3Foam::updateInfoPatches // Add patches // ~~~~~~~~~~~ - forAll(patches, patchI) + if (!reader_->GetShowGroupsOnly()) { - const polyPatch& pp = patches[patchI]; - - if (pp.size()) + forAll(patches, patchI) { - // Add patch to GUI list - arraySelection->AddArray - ( - (pp.name() + " - patch").c_str() - ); + const polyPatch& pp = patches[patchI]; - ++nPatches; + if (pp.size()) + { + // Add patch to GUI list + arraySelection->AddArray + ( + (pp.name() + " - patch").c_str() + ); + + ++nPatches; + } } } } @@ -356,6 +361,7 @@ void Foam::vtkPV3Foam::updateInfoPatches wordList groupNames; patchDict.readIfPresent("inGroups", groupNames); + forAll(groupNames, groupI) { HashTable::iterator iter = groups.find @@ -394,20 +400,22 @@ void Foam::vtkPV3Foam::updateInfoPatches if (nFaces) { string vtkGrpName = groupName + " - group"; - arraySelection->AddArray(vtkGrpName.c_str()); ++nPatches; if (enabledEntriesSet.found(vtkGrpName)) { - forAll(patchIDs, i) + //enabledEntriesSet.erase(vtkGrpName); + if (!reader_->GetShowGroupsOnly()) { - string vtkPatchName = - names[patchIDs[i]] + " - patch"; - enabledEntriesSet.insert(vtkPatchName); + forAll(patchIDs, i) + { + string vtkPatchName = + names[patchIDs[i]] + " - patch"; + enabledEntriesSet.insert(vtkPatchName); + } } - enabledEntriesSet.erase(vtkGrpName); } } } @@ -416,17 +424,20 @@ void Foam::vtkPV3Foam::updateInfoPatches // Add (non-zero) patches to the list of mesh parts // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - forAll(names, patchI) + if (!reader_->GetShowGroupsOnly()) { - // Valid patch if nFace > 0 - add patch to GUI list - if (sizes[patchI]) + forAll(names, patchI) { - arraySelection->AddArray - ( - (names[patchI] + " - patch").c_str() - ); + // Valid patch if nFace > 0 - add patch to GUI list + if (sizes[patchI]) + { + arraySelection->AddArray + ( + (names[patchI] + " - patch").c_str() + ); - ++nPatches; + ++nPatches; + } } } } From 19ef4cdd9e1c42a577b0705c63f5b94ab407ed33 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Sep 2012 17:42:59 +0100 Subject: [PATCH 02/10] ENH: controlDict: typo --- etc/controlDict | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/controlDict b/etc/controlDict index caf1e22933..f1451c59d7 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -989,7 +989,7 @@ DimensionSets // Set of units used for printing. Can be any basic or derived // but not scaled (only supported for dimensionedScalar, etc) - printUnits (kg m s K mol A Cd); + writeUnits (kg m s K mol A Cd); } } From f145cc8fa4340e94e1071e83f24d2617c40968e6 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Sep 2012 09:50:37 +0100 Subject: [PATCH 03/10] BUG: paraFoam: keeping patchGroups thus doubling geometry --- .../vtkPV3Foam/vtkPV3FoamUpdateInfo.C | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C index ac66e9279e..fe7cdae8a9 100644 --- a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C @@ -272,14 +272,17 @@ void Foam::vtkPV3Foam::updateInfoPatches if (enabledEntriesSet.found(vtkGrpName)) { - //enabledEntriesSet.erase(vtkGrpName); if (!reader_->GetShowGroupsOnly()) { + enabledEntriesSet.erase(vtkGrpName); forAll(patchIDs, i) { const polyPatch& pp = patches[patchIDs[i]]; - string vtkPatchName = pp.name() + " - patch"; - enabledEntriesSet.insert(vtkPatchName); + if (pp.size()) + { + string vtkPatchName = pp.name() + " - patch"; + enabledEntriesSet.insert(vtkPatchName); + } } } } @@ -406,14 +409,17 @@ void Foam::vtkPV3Foam::updateInfoPatches if (enabledEntriesSet.found(vtkGrpName)) { - //enabledEntriesSet.erase(vtkGrpName); if (!reader_->GetShowGroupsOnly()) { + enabledEntriesSet.erase(vtkGrpName); forAll(patchIDs, i) { - string vtkPatchName = - names[patchIDs[i]] + " - patch"; - enabledEntriesSet.insert(vtkPatchName); + if (sizes[patchIDs[i]]) + { + string vtkPatchName = + names[patchIDs[i]] + " - patch"; + enabledEntriesSet.insert(vtkPatchName); + } } } } From 2cd4c27a4f402c34f9dc09f13053572c84ad5ee0 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Sep 2012 11:34:23 +0100 Subject: [PATCH 04/10] ENH: codedMixed: corrected comment --- .../derived/codedMixed/codedMixedFvPatchField.H | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H index 2b7c97478e..cc08ba319d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,12 +33,18 @@ Description movingWall { type codedMixed; - value uniform 0; + + refValue uniform (0 0 0); + refGradient uniform (0 0 0); + valueFraction uniform 1; + redirectType rampedMixed; // name of generated bc code #{ - this->refValue() = min(10, 0.1*this->db().time().value()); + this->refValue() = + vector(1, 0, 0) + *min(10, 0.1*this->db().time().value()); this->refGrad() = vector::zero; this->valueFraction() = 1.0; #}; From 3d8a083c407c9e789a1f554e35d81d35b375d8d4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Sep 2012 11:35:18 +0100 Subject: [PATCH 05/10] STYLE: codedMixed: changed className to be consistent with function --- .../dynamicCode/mixedFvPatchFieldTemplate.C | 38 +++++++++---------- .../dynamicCode/mixedFvPatchFieldTemplate.H | 28 +++++++------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C index ded11e8929..ab2f100f3e 100644 --- a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,18 +73,18 @@ extern "C" makeRemovablePatchTypeField ( fvPatch${FieldType}, - ${typeName}FixedValueFvPatch${FieldType} + ${typeName}MixedValueFvPatch${FieldType} ); -const char* const ${typeName}FixedValueFvPatch${FieldType}::SHA1sum = +const char* const ${typeName}MixedValueFvPatch${FieldType}::SHA1sum = "${SHA1sum}"; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -${typeName}FixedValueFvPatch${FieldType}:: -${typeName}FixedValueFvPatch${FieldType} +${typeName}MixedValueFvPatch${FieldType}:: +${typeName}MixedValueFvPatch${FieldType} ( const fvPatch& p, const DimensionedField<${TemplateType}, volMesh>& iF @@ -100,10 +100,10 @@ ${typeName}FixedValueFvPatch${FieldType} } -${typeName}FixedValueFvPatch${FieldType}:: -${typeName}FixedValueFvPatch${FieldType} +${typeName}MixedValueFvPatch${FieldType}:: +${typeName}MixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatch${FieldType}& ptf, + const ${typeName}MixedValueFvPatch${FieldType}& ptf, const fvPatch& p, const DimensionedField<${TemplateType}, volMesh>& iF, const fvPatchFieldMapper& mapper @@ -119,8 +119,8 @@ ${typeName}FixedValueFvPatch${FieldType} } -${typeName}FixedValueFvPatch${FieldType}:: -${typeName}FixedValueFvPatch${FieldType} +${typeName}MixedValueFvPatch${FieldType}:: +${typeName}MixedValueFvPatch${FieldType} ( const fvPatch& p, const DimensionedField<${TemplateType}, volMesh>& iF, @@ -137,10 +137,10 @@ ${typeName}FixedValueFvPatch${FieldType} } -${typeName}FixedValueFvPatch${FieldType}:: -${typeName}FixedValueFvPatch${FieldType} +${typeName}MixedValueFvPatch${FieldType}:: +${typeName}MixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatch${FieldType}& ptf + const ${typeName}MixedValueFvPatch${FieldType}& ptf ) : mixedFvPatchField<${TemplateType}>(ptf) @@ -153,10 +153,10 @@ ${typeName}FixedValueFvPatch${FieldType} } -${typeName}FixedValueFvPatch${FieldType}:: -${typeName}FixedValueFvPatch${FieldType} +${typeName}MixedValueFvPatch${FieldType}:: +${typeName}MixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatch${FieldType}& ptf, + const ${typeName}MixedValueFvPatch${FieldType}& ptf, const DimensionedField<${TemplateType}, volMesh>& iF ) : @@ -172,8 +172,8 @@ ${typeName}FixedValueFvPatch${FieldType} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -${typeName}FixedValueFvPatch${FieldType}:: -~${typeName}FixedValueFvPatch${FieldType}() +${typeName}MixedValueFvPatch${FieldType}:: +~${typeName}MixedValueFvPatch${FieldType}() { if (${verbose:-false}) { @@ -184,7 +184,7 @@ ${typeName}FixedValueFvPatch${FieldType}:: // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs() +void ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs() { if (this->updated()) { diff --git a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H index 7c0b654618..06e1c9887c 100644 --- a/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H +++ b/etc/codeTemplates/dynamicCode/mixedFvPatchFieldTemplate.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,10 +43,10 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - A templated FixedValueFvPatch + A templated MixedValueFvPatchField \*---------------------------------------------------------------------------*/ -class ${typeName}FixedValueFvPatch${FieldType} +class ${typeName}MixedValueFvPatch${FieldType} : public mixedFvPatchField<${TemplateType}> { @@ -62,14 +62,14 @@ public: // Constructors //- Construct from patch and internal field - ${typeName}FixedValueFvPatch${FieldType} + ${typeName}MixedValueFvPatch${FieldType} ( const fvPatch&, const DimensionedField<${TemplateType}, volMesh>& ); //- Construct from patch, internal field and dictionary - ${typeName}FixedValueFvPatch${FieldType} + ${typeName}MixedValueFvPatch${FieldType} ( const fvPatch&, const DimensionedField<${TemplateType}, volMesh>&, @@ -77,18 +77,18 @@ public: ); //- Construct by mapping a copy onto a new patch - ${typeName}FixedValueFvPatch${FieldType} + ${typeName}MixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatch${FieldType}&, + const ${typeName}MixedValueFvPatch${FieldType}&, const fvPatch&, const DimensionedField<${TemplateType}, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy - ${typeName}FixedValueFvPatch${FieldType} + ${typeName}MixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatch${FieldType}& + const ${typeName}MixedValueFvPatch${FieldType}& ); //- Construct and return a clone @@ -96,14 +96,14 @@ public: { return tmp< fvPatch${FieldType} > ( - new ${typeName}FixedValueFvPatch${FieldType}(*this) + new ${typeName}MixedValueFvPatch${FieldType}(*this) ); } //- Construct as copy setting internal field reference - ${typeName}FixedValueFvPatch${FieldType} + ${typeName}MixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatch${FieldType}&, + const ${typeName}MixedValueFvPatch${FieldType}&, const DimensionedField<${TemplateType}, volMesh>& ); @@ -115,13 +115,13 @@ public: { return tmp< fvPatch${FieldType} > ( - new ${typeName}FixedValueFvPatch${FieldType}(*this, iF) + new ${typeName}MixedValueFvPatch${FieldType}(*this, iF) ); } //- Destructor - virtual ~${typeName}FixedValueFvPatch${FieldType}(); + virtual ~${typeName}MixedValueFvPatch${FieldType}(); // Member functions From 4023418a6b98474576befcac5cdf7545b8e2ef41 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Sep 2012 14:14:05 +0100 Subject: [PATCH 06/10] ENH: codeStream: sha1 calculation cached --- .../dictionary/functionEntries/codeStream/codeStream.C | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index de0b87d9ea..cfe9de3273 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,11 +104,8 @@ Foam::functionEntries::codeStream::getFunction // codeName: codeStream + _ // codeDir : _ - dynamicCode dynCode - ( - "codeStream" + context.sha1().str(true), - context.sha1().str(true) - ); + std::string sha1Str(context.sha1().str(true)); + dynamicCode dynCode("codeStream" + sha1Str, sha1Str); // Load library if not already loaded // Version information is encoded in the libPath (encoded with the SHA1) From 0fc430a57ba72e6ab311767cc1a8ef7aa5fc741c Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Sep 2012 14:14:29 +0100 Subject: [PATCH 07/10] STYLE: codedBase: indenting --- src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H index 391c5267c0..a6bce15a25 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,7 +104,7 @@ protected: virtual void prepare ( dynamicCode&, - const dynamicCodeContext & + const dynamicCodeContext& ) const = 0; // Return a description (type + name) for the output From e29c0b1266592bf83f446d62bbf67320124920b9 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 26 Sep 2012 12:07:07 +0100 Subject: [PATCH 08/10] ENH: regionProperties: added comment --- .../regionModel/regionProperties/regionProperties.H | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/regionModels/regionModel/regionProperties/regionProperties.H b/src/regionModels/regionModel/regionProperties/regionProperties.H index 796b0f6405..09ebbf66d5 100644 --- a/src/regionModels/regionModel/regionProperties/regionProperties.H +++ b/src/regionModels/regionModel/regionProperties/regionProperties.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,11 @@ Class regionProperties Description - Simple class to hold region information for coupled region simulations + Simple class to hold region information for coupled region simulations. + + Gives per physics ('fluid', 'solid') the names of the regions. There + is no assumption on this level that one region should only have one + set of physics. SourceFiles regionProperties.C From da17674f0fd7d66df10914082ddb41c88820fcef Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 26 Sep 2012 12:08:43 +0100 Subject: [PATCH 09/10] ENH: decomposePar,reconsturctPar: added -allRegions option --- .../decomposePar/Make/options | 6 +- .../decomposePar/decomposePar.C | 1795 +++++++++-------- .../reconstructPar/Make/options | 6 +- .../reconstructPar/reconstructPar.C | 819 ++++---- .../multiRegionHeater/Allrun | 15 +- .../multiRegionLiquidHeater/Allrun | 10 +- .../snappyMultiRegionHeater/Allrun | 15 +- .../multiRegionHeater/Allrun | 10 +- .../multiRegionHeaterRadiation/Allrun | 10 +- 9 files changed, 1399 insertions(+), 1287 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index 7194eb1bce..5d5d67f989 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -3,7 +3,8 @@ EXE_INC = \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude EXE_LIBS = \ -lfiniteVolume \ @@ -11,4 +12,5 @@ EXE_LIBS = \ -lgenericPatchFields \ -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp \ -llagrangian \ - -lmeshTools + -lmeshTools \ + -lregionModels diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 26d3813004..257c31df53 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -39,6 +39,10 @@ Usage \param -region regionName \n Decompose named region. Does not check for existence of processor*. + \param -allRegions \n + Decompose all regions in regionProperties. Does not check for + existence of processor*. + \param -copyUniform \n Copy any \a uniform directories too. @@ -82,6 +86,7 @@ Usage #include "tensorIOField.H" #include "tensorFieldIOField.H" #include "pointFields.H" +#include "regionProperties.H" #include "readFields.H" #include "dimFieldDecomposer.H" @@ -101,6 +106,11 @@ int main(int argc, char *argv[]) argList::noParallel(); #include "addRegionOption.H" argList::addBoolOption + ( + "allRegions", + "operate on all regions in regionProperties" + ); + argList::addBoolOption ( "cellDist", "write cell distribution as a labelList - for use with 'manual' " @@ -132,15 +142,7 @@ int main(int argc, char *argv[]) #include "setRootCase.H" - word regionName = fvMesh::defaultRegion; - word regionDir = word::null; - - if (args.optionReadIfPresent("region", regionName)) - { - regionDir = regionName; - Info<< "Decomposing mesh " << regionName << nl << endl; - } - + bool allRegions = args.optionFound("allRegions"); bool writeCellDist = args.optionFound("cellDist"); bool copyUniform = args.optionFound("copyUniform"); bool decomposeFieldsOnly = args.optionFound("fields"); @@ -152,756 +154,659 @@ int main(int argc, char *argv[]) // Allow override of time instantList times = timeSelector::selectIfPresent(runTime, args); - // determine the existing processor count directly - label nProcs = 0; - while - ( - isDir - ( - runTime.path() - / (word("processor") + name(nProcs)) - / runTime.constant() - / regionDir - / polyMesh::meshSubDir - ) - ) + + wordList regionNames; + wordList regionDirs; + if (allRegions) { - ++nProcs; - } - - // get requested numberOfSubdomains - const label nDomains = readLabel - ( - IOdictionary - ( - IOobject - ( - "decomposeParDict", - runTime.time().system(), - regionDir, // use region if non-standard - runTime, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ).lookup("numberOfSubdomains") - ); - - if (decomposeFieldsOnly) - { - // Sanity check on previously decomposed case - if (nProcs != nDomains) + Info<< "Decomposing all regions in regionProperties" << nl << endl; + regionProperties rp(runTime); + forAllConstIter(HashTable, rp, iter) { - FatalErrorIn(args.executable()) - << "Specified -fields, but the case was decomposed with " - << nProcs << " domains" - << nl - << "instead of " << nDomains - << " domains as specified in decomposeParDict" - << nl - << exit(FatalError); - } - } - else if (nProcs) - { - bool procDirsProblem = true; - - if (ifRequiredDecomposition && nProcs == nDomains) - { - // we can reuse the decomposition - decomposeFieldsOnly = true; - procDirsProblem = false; - forceOverwrite = false; - - Info<< "Using existing processor directories" << nl; - } - - if (forceOverwrite) - { - Info<< "Removing " << nProcs - << " existing processor directories" << endl; - - // remove existing processor dirs - // reverse order to avoid gaps if someone interrupts the process - for (label procI = nProcs-1; procI >= 0; --procI) + const wordList& regions = iter(); + forAll(regions, i) { - fileName procDir - ( - runTime.path()/(word("processor") + name(procI)) - ); - - rmDir(procDir); - } - - procDirsProblem = false; - } - - if (procDirsProblem) - { - FatalErrorIn(args.executable()) - << "Case is already decomposed with " << nProcs - << " domains, use the -force option or manually" << nl - << "remove processor directories before decomposing. e.g.," - << nl - << " rm -rf " << runTime.path().c_str() << "/processor*" - << nl - << exit(FatalError); - } - } - - Info<< "Create mesh" << endl; - domainDecomposition mesh - ( - IOobject - ( - regionName, - runTime.timeName(), - runTime - ) - ); - - // Decompose the mesh - if (!decomposeFieldsOnly) - { - mesh.decomposeMesh(); - - mesh.writeDecomposition(); - - if (writeCellDist) - { - const labelList& procIds = mesh.cellToProc(); - - // Write the decomposition as labelList for use with 'manual' - // decomposition method. - labelIOList cellDecomposition - ( - IOobject - ( - "cellDecomposition", - mesh.facesInstance(), - mesh, - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - procIds - ); - cellDecomposition.write(); - - Info<< nl << "Wrote decomposition to " - << cellDecomposition.objectPath() - << " for use in manual decomposition." << endl; - - // Write as volScalarField for postprocessing. - volScalarField cellDist - ( - IOobject - ( - "cellDist", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar("cellDist", dimless, 0), - zeroGradientFvPatchScalarField::typeName - ); - - forAll(procIds, celli) - { - cellDist[celli] = procIds[celli]; - } - - cellDist.write(); - - Info<< nl << "Wrote decomposition as volScalarField to " - << cellDist.name() << " for use in postprocessing." - << endl; - } - } - - - - // Caches - // ~~~~~~ - // Cached processor meshes and maps. These are only preserved if running - // with multiple times. - PtrList