From e5d9fd13c206d34f810be2be0dcb1fee33b1d8b2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 9 Nov 2016 23:33:24 +0100 Subject: [PATCH] ENH: relocate meshSubsetHelper into dynamicMesh for re-use - reuse for foamToTecplot360 and foamToVTK. - remove dependency on vtkMesh where possible. --- .../dataConversion/foamToEnsight/Make/files | 2 - .../foamToEnsight/foamToEnsight.C | 2 +- .../foamToTecplot360/Make/files | 1 - .../foamToTecplot360/foamToTecplot360.C | 102 +++++----- .../foamToTecplot360/readFields.C | 31 ++- .../foamToTecplot360/readFields.H | 10 +- .../dataConversion/foamToTecplot360/vtkMesh.C | 83 -------- .../dataConversion/foamToTecplot360/vtkMesh.H | 178 ------------------ .../dataConversion/foamToVTK/foamToVTK.C | 17 +- .../foamToVTK/foamToVTK/Make/files | 1 - .../foamToVTK/foamToVTK/internalWriter.H | 2 - .../foamToVTK/foamToVTK/lagrangianWriter.C | 10 +- .../foamToVTK/foamToVTK/lagrangianWriter.H | 9 +- .../foamToVTK/lagrangianWriterTemplates.C | 4 +- .../foamToVTK/foamToVTK/patchWriter.C | 11 +- .../foamToVTK/foamToVTK/patchWriter.H | 10 +- .../foamToVTK/foamToVTK/readFields.C | 21 +-- .../foamToVTK/foamToVTK/readFields.H | 6 +- .../foamToVTK/foamToVTK/surfaceMeshWriter.H | 3 - .../foamToVTK/surfaceMeshWriterTemplates.C | 3 +- .../foamToVTK/foamToVTK/vtkMesh.C | 82 -------- .../foamToVTK/foamToVTK/vtkMesh.H | 86 +++------ .../foamToVTK/foamToVTK/writeFaceSet.C | 8 +- .../foamToVTK/foamToVTK/writeFaceSet.H | 6 +- .../foamToVTK/foamToVTK/writePointSet.C | 4 +- .../foamToVTK/foamToVTK/writePointSet.H | 6 +- .../foamToVTK/foamToVTK/writeSurfFields.C | 6 +- .../foamToVTK/foamToVTK/writeSurfFields.H | 4 +- src/dynamicMesh/Make/files | 1 + .../meshSubsetHelper}/meshSubsetHelper.C | 29 ++- .../meshSubsetHelper}/meshSubsetHelper.H | 33 +++- .../meshSubsetHelperTemplates.C | 21 +++ 32 files changed, 209 insertions(+), 583 deletions(-) delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.C delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.H delete mode 100644 applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.C rename {applications/utilities/postProcessing/dataConversion/foamToEnsight => src/dynamicMesh/meshSubsetHelper}/meshSubsetHelper.C (88%) rename {applications/utilities/postProcessing/dataConversion/foamToEnsight => src/dynamicMesh/meshSubsetHelper}/meshSubsetHelper.H (86%) rename {applications/utilities/postProcessing/dataConversion/foamToEnsight => src/dynamicMesh/meshSubsetHelper}/meshSubsetHelperTemplates.C (89%) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files index 044aa6ae43..a474a8fcfc 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files @@ -1,6 +1,4 @@ ensightOutputCloud.C -meshSubsetHelper.C - foamToEnsight.C EXE = $(FOAM_APPBIN)/foamToEnsight diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C index 1d0f6c3beb..5080d840eb 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/foamToEnsight.C @@ -291,7 +291,7 @@ int main(int argc, char *argv[]) << mesh.boundaryMesh()[0].name() << ")" << endl; } - meshSubsetHelper myMesh(mesh, cellZoneName); + meshSubsetHelper myMesh(mesh, meshSubsetHelper::ZONE, cellZoneName); // // Open new ensight case file, initialize header etc. diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/files b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/files index 270e84931b..3eb58f1773 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/files @@ -1,5 +1,4 @@ tecplotWriter.C -vtkMesh.C foamToTecplot360.C EXE = $(FOAM_APPBIN)/foamToTecplot360 diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C index 6ec9aff277..5dbe1581ca 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -68,9 +68,6 @@ Usage information as a single argument. The double quotes denote a regular expression. - - \par -useTimeName - use the time index in the VTK file name instead of the time index - \*---------------------------------------------------------------------------*/ #include "pointMesh.H" @@ -86,7 +83,7 @@ Usage #include "stringListOps.H" #include "wordRe.H" -#include "vtkMesh.H" +#include "meshSubsetHelper.H" #include "readFields.H" #include "tecplotWriter.H" @@ -99,7 +96,7 @@ Usage // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -void print(const char* msg, Ostream& os, const PtrList& flds) +void print(const char* msg, Ostream& os, const PtrList& flds) { if (flds.size()) { @@ -140,7 +137,7 @@ labelList getSelectedPatches if ( isType(pp) - || (Pstream::parRun() && isType(pp)) + || (Pstream::parRun() && isType(pp)) ) { Info<< " discarding empty/processor patch " << patchi @@ -161,8 +158,7 @@ labelList getSelectedPatches } - - +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { @@ -170,10 +166,8 @@ int main(int argc, char *argv[]) ( "Tecplot binary file format writer" ); - timeSelector::addOptions(); #include "addRegionOption.H" - argList::addOption ( "fields", @@ -190,7 +184,7 @@ int main(int argc, char *argv[]) ( "faceSet", "name", - "restrict conversion to the specified cellSet" + "restrict conversion to the specified faceSet" ); argList::addBoolOption ( @@ -248,7 +242,8 @@ int main(int argc, char *argv[]) } word cellSetName; - string vtkName; + word faceSetName; + string vtkName = runTime.caseName(); if (args.optionReadIfPresent("cellSet", cellSetName)) { @@ -266,11 +261,7 @@ int main(int argc, char *argv[]) vtkName = vtkName.substr(i); } } - else - { - vtkName = runTime.caseName(); - } - + args.optionReadIfPresent("faceSet", faceSetName); instantList timeDirs = timeSelector::select0(runTime, args); @@ -294,10 +285,11 @@ int main(int argc, char *argv[]) args.optionFound("time") || args.optionFound("latestTime") || cellSetName.size() + || faceSetName.size() || regionName != polyMesh::defaultRegion ) { - Info<< "Keeping old files in " << fvPath << nl << endl; + Info<< "Keeping old tecplot files in " << fvPath << nl << endl; } else { @@ -309,9 +301,8 @@ int main(int argc, char *argv[]) mkDir(fvPath); - - // mesh wrapper; does subsetting and decomposition - vtkMesh vMesh(mesh, cellSetName); + // Mesh wrapper: does subsetting + meshSubsetHelper myMesh(mesh, meshSubsetHelper::SET, cellSetName); forAll(timeDirs, timeI) { @@ -319,13 +310,12 @@ int main(int argc, char *argv[]) Info<< "Time: " << runTime.timeName() << endl; - const word timeDesc = name(timeI); //name(runTime.timeIndex()); + const word timeDesc = name(timeI); // Foam::name(runTime.timeIndex()); // Check for new polyMesh/ and update mesh, fvMeshSubset and cell // decomposition. - polyMesh::readUpdateState meshState = vMesh.readUpdate(); - - const fvMesh& mesh = vMesh.mesh(); + polyMesh::readUpdateState meshState = myMesh.readUpdate(); + const fvMesh& mesh = myMesh.mesh(); INTEGER4 nFaceNodes = 0; forAll(mesh.faces(), facei) @@ -348,24 +338,24 @@ int main(int argc, char *argv[]) // Construct the vol fields (on the original mesh if subsetted) - PtrList vsf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vsf); + PtrList vsf; + readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vsf); print(" volScalarFields :", Info, vsf); - PtrList vvf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vvf); + PtrList vvf; + readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vvf); print(" volVectorFields :", Info, vvf); - PtrList vSpheretf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSpheretf); + PtrList vSpheretf; + readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vSpheretf); print(" volSphericalTensorFields :", Info, vSpheretf); - PtrList vSymmtf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSymmtf); + PtrList vSymmtf; + readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vSymmtf); print(" volSymmTensorFields :", Info, vSymmtf); - PtrList vtf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vtf); + PtrList vtf; + readFields(myMesh, myMesh.baseMesh(), objects, selectedFields, vtf); print(" volTensorFields :", Info, vtf); @@ -379,11 +369,11 @@ int main(int argc, char *argv[]) << " (\"-noPointValues\" (at your option)\n"; } - PtrList psf; - PtrList pvf; - //PtrList pSpheretf; - //PtrList pSymmtf; - //PtrList ptf; + PtrList psf; + PtrList pvf; + //PtrList pSpheretf; + //PtrList pSymmtf; + //PtrList ptf; if (!noPointValues) @@ -418,8 +408,8 @@ int main(int argc, char *argv[]) readFields ( - vMesh, - pointMesh::New(vMesh.baseMesh()), + myMesh, + pointMesh::New(myMesh.baseMesh()), objects, selectedFields, psf @@ -428,8 +418,8 @@ int main(int argc, char *argv[]) readFields ( - vMesh, - pointMesh::New(vMesh.baseMesh()), + myMesh, + pointMesh::New(myMesh.baseMesh()), objects, selectedFields, pvf @@ -438,8 +428,8 @@ int main(int argc, char *argv[]) //readFields //( - // vMesh, - // pointMesh::New(vMesh.baseMesh()), + // myMesh, + // pointMesh::New(myMesh.baseMesh()), // objects, // selectedFields, // pSpheretf @@ -448,8 +438,8 @@ int main(int argc, char *argv[]) // //readFields //( - // vMesh, - // pointMesh::New(vMesh.baseMesh()), + // myMesh, + // pointMesh::New(myMesh.baseMesh()), // objects, // selectedFields, // pSymmtf @@ -458,8 +448,8 @@ int main(int argc, char *argv[]) // //readFields //( - // vMesh, - // pointMesh::New(vMesh.baseMesh()), + // myMesh, + // pointMesh::New(myMesh.baseMesh()), // objects, // selectedFields, // ptf @@ -769,11 +759,10 @@ int main(int argc, char *argv[]) // //--------------------------------------------------------------------- - if (args.optionFound("faceSet")) + if (faceSetName.size()) { // Load the faceSet - const word setName = args["faceSet"]; - labelList faceLabels(faceSet(mesh, setName).toc()); + labelList faceLabels(faceSet(mesh, faceSetName).toc()); // Filename as if patch with same name. mkDir(fvPath/setName); @@ -886,7 +875,6 @@ int main(int argc, char *argv[]) } - //--------------------------------------------------------------------- // // Write patches as multi-zone file @@ -901,7 +889,7 @@ int main(int argc, char *argv[]) fileName patchFileName; - if (vMesh.useSubMesh()) + if (myMesh.useSubMesh()) { patchFileName = fvPath/"boundaryMesh"/cellSetName @@ -1072,7 +1060,7 @@ int main(int argc, char *argv[]) fileName patchFileName; - if (vMesh.useSubMesh()) + if (myMesh.useSubMesh()) { patchFileName = fvPath/"faceZoneMesh"/cellSetName diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.C index c677fe439c..172a83cf23 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.C @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,37 +36,32 @@ namespace Foam template void readFields ( - const vtkMesh& vMesh, + const meshSubsetHelper& helper, const typename GeoField::Mesh& mesh, const IOobjectList& objects, const HashSet& selectedFields, - PtrList& fields + PtrList& fields ) { - // Search list of objects for volScalarFields + // Search list of objects for fields of type GeomField IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); - // Construct the vol scalar fields - label nFields = fields.size(); - fields.setSize(nFields + fieldObjects.size()); + // Construct the fields + fields.setSize(fieldObjects.size()); + label nFields = 0; - forAllIter(IOobjectList, fieldObjects, iter) + forAllConstIter(IOobjectList, fieldObjects, iter) { if (selectedFields.empty() || selectedFields.found(iter()->name())) { fields.set ( - nFields, - vMesh.interpolate + nFields++, + helper.interpolate ( - GeoField - ( - *iter(), - mesh - ) - ) + GeoField(*iter(), mesh) + ).ptr() ); - nFields++; } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.H b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.H index b25c56755c..510bd11d25 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.H @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,7 +34,7 @@ SourceFiles #ifndef readFields_H #define readFields_H -#include "fvMesh.H" +#include "meshSubsetHelper.H" #include "PtrList.H" #include "IOobjectList.H" #include "HashSet.H" @@ -48,11 +48,11 @@ namespace Foam template void readFields ( - const vtkMesh& vMesh, + const meshSubsetHelper&, const typename GeoField::Mesh& mesh, const IOobjectList& objects, const HashSet& selectedFields, - PtrList& fields + PtrList& fields ); } // End namespace Foam diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.C deleted file mode 100644 index 0a58e5d523..0000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.C +++ /dev/null @@ -1,83 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "vtkMesh.H" -#include "fvMeshSubset.H" -#include "Time.H" -#include "cellSet.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components -Foam::vtkMesh::vtkMesh -( - fvMesh& baseMesh, - const word& setName -) -: - baseMesh_(baseMesh), - subsetter_(baseMesh), - setName_(setName) -{ - if (setName.size()) - { - // Read cellSet using whole mesh - cellSet currentSet(baseMesh_, setName_); - - // Set current subset - subsetter_.setLargeCellSubset(currentSet); - } -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate() -{ - polyMesh::readUpdateState meshState = baseMesh_.readUpdate(); - - if (meshState != polyMesh::UNCHANGED) - { - // Note: since fvMeshSubset has no movePoints() functionality - // reconstruct the subset even if only movement. - -// topoPtr_.clear(); - - if (setName_.size()) - { - Info<< "Subsetting mesh based on cellSet " << setName_ << endl; - - // Read cellSet using whole mesh - cellSet currentSet(baseMesh_, setName_); - - subsetter_.setLargeCellSubset(currentSet); - } - } - - return meshState; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.H b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.H deleted file mode 100644 index ec6045b534..0000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.H +++ /dev/null @@ -1,178 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::vtkMesh - -Description - Encapsulation of VTK mesh data. Holds mesh or meshsubset and - polyhedral-cell decomposition on it. - -SourceFiles - vtkMesh.C - -\*---------------------------------------------------------------------------*/ - -#ifndef vtkMesh_H -#define vtkMesh_H - -#include "fvMeshSubset.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// Forward declaration of classes -class Time; - -/*---------------------------------------------------------------------------*\ - Class vtkMesh Declaration -\*---------------------------------------------------------------------------*/ - -class vtkMesh -{ - // Private data - - //- Reference to mesh - fvMesh& baseMesh_; - - //- Subsetting engine + sub-fvMesh - fvMeshSubset subsetter_; - - //- Current cellSet (or empty) - const word setName_; - -// //- Current decomposition of topology -// mutable autoPtr topoPtr_; - - - - // Private Member Functions - - //- Disallow default bitwise copy construct - vtkMesh(const vtkMesh&); - - //- Disallow default bitwise assignment - void operator=(const vtkMesh&); - - -public: - - // Constructors - - //- Construct from components - vtkMesh(fvMesh& baseMesh, const word& setName = ""); - - - // Member Functions - - // Access - - //- Whole mesh - const fvMesh& baseMesh() const - { - return baseMesh_; - } - - const fvMeshSubset& subsetter() const - { - return subsetter_; - } - - //- Check if running subMesh - bool useSubMesh() const - { - return setName_.size(); - } - -// //- topology -// const vtkTopo& topo() const -// { -// if (topoPtr_.empty()) -// { -// topoPtr_.reset(new vtkTopo(mesh())); -// } -// return topoPtr_(); -// } - - //- Access either mesh or submesh - const fvMesh& mesh() const - { - if (useSubMesh()) - { - return subsetter_.subMesh(); - } - else - { - return baseMesh_; - } - } - -// //- Number of field cells -// label nFieldCells() const -// { -// return topo().vertLabels().size(); -// } -// -// //- Number of field points -// label nFieldPoints() const -// { -// return mesh().nPoints() + topo().addPointCellLabels().size(); -// } - - - // Edit - - //- Read mesh - polyMesh::readUpdateState readUpdate(); - - - //- Map volume field (does in fact do very little interpolation; - // just copied from fvMeshSubset) - template - tmp interpolate(const GeoField& fld) const - { - if (useSubMesh()) - { - tmp subFld = subsetter_.interpolate(fld); - subFld.ref().rename(fld.name()); - return subFld; - } - else - { - return fld; - } - } -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 4e42b5afbf..c2a6f3b298 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -410,7 +410,6 @@ int main(int argc, char *argv[]) args.optionReadIfPresent("pointSet", pointSetName); - instantList timeDirs = timeSelector::select0(runTime, args); #include "createNamedMesh.H" @@ -450,7 +449,7 @@ int main(int argc, char *argv[]) mkDir(fvPath); - // Mesh wrapper; does subsetting and decomposition + // Mesh wrapper: does subsetting and decomposition vtkMesh vMesh(mesh, cellSetName); Info<< "VTK mesh topology: " @@ -503,7 +502,7 @@ int main(int argc, char *argv[]) Info<< " FaceSet : " << patchFileName << endl; - writeFaceSet(binary, vMesh, set, patchFileName); + writeFaceSet(binary, vMesh.mesh(), set, patchFileName); continue; } @@ -526,7 +525,7 @@ int main(int argc, char *argv[]) Info<< " pointSet : " << patchFileName << endl; - writePointSet(binary, vMesh, set, patchFileName); + writePointSet(binary, vMesh.mesh(), set, patchFileName); continue; } @@ -849,7 +848,7 @@ int main(int argc, char *argv[]) writeSurfFields ( binary, - vMesh, + vMesh.mesh(), surfFileName, svf ); @@ -892,7 +891,7 @@ int main(int argc, char *argv[]) patchWriter writer ( - vMesh, + vMesh.mesh(), binary, nearCellValue, patchFileName, @@ -970,7 +969,7 @@ int main(int argc, char *argv[]) patchWriter writer ( - vMesh, + vMesh.mesh(), binary, nearCellValue, patchFileName, @@ -1188,7 +1187,7 @@ int main(int argc, char *argv[]) lagrangianWriter writer ( - vMesh, + vMesh.mesh(), binary, lagrFileName, cloudName, @@ -1218,7 +1217,7 @@ int main(int argc, char *argv[]) { lagrangianWriter writer ( - vMesh, + vMesh.mesh(), binary, lagrFileName, cloudName, diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files index 4deaaa68f0..02de5b47e6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/Make/files @@ -6,7 +6,6 @@ writeFuns.C writeFaceSet.C writePointSet.C writeSurfFields.C -vtkMesh.C vtkTopo.C writeVTK/writeVTK.C diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H index b61cfd6377..b1836afb60 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H @@ -41,8 +41,6 @@ SourceFiles #include "pointFields.H" #include "vtkMesh.H" -using namespace Foam; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C index 6c168a2280..6eab8f1646 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,23 +32,21 @@ License Foam::lagrangianWriter::lagrangianWriter ( - const vtkMesh& vMesh, + const fvMesh& mesh, const bool binary, const fileName& fName, const word& cloudName, const bool dummyCloud ) : - vMesh_(vMesh), + mesh_(mesh), binary_(binary), fName_(fName), cloudName_(cloudName), os_(fName.c_str()) { - const fvMesh& mesh = vMesh_.mesh(); - // Write header - writeFuns::writeHeader(os_, binary_, mesh.time().caseName()); + writeFuns::writeHeader(os_, binary_, mesh_.time().caseName()); os_ << "DATASET POLYDATA" << std::endl; if (dummyCloud) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.H index 113bfe43b0..24dd4a3228 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriter.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,9 +40,6 @@ SourceFiles #include "Cloud.H" #include "volFields.H" #include "pointFields.H" -#include "vtkMesh.H" - -using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,7 +54,7 @@ class volPointInterpolation; class lagrangianWriter { - const vtkMesh& vMesh_; + const fvMesh& mesh_; const bool binary_; @@ -77,7 +74,7 @@ public: //- Construct from components lagrangianWriter ( - const vtkMesh&, + const fvMesh&, const bool binary, const fileName&, const word&, diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriterTemplates.C index 8d34517dca..86cec10dc3 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/lagrangianWriterTemplates.C @@ -39,9 +39,9 @@ void Foam::lagrangianWriter::writeIOField(const wordList& objects) IOobject header ( object, - vMesh_.mesh().time().timeName(), + mesh_.time().timeName(), cloud::prefix/cloudName_, - vMesh_.mesh(), + mesh_, IOobject::MUST_READ, IOobject::NO_WRITE, false diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.C index 4a9840c1e2..d099745aa2 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,21 +30,20 @@ License Foam::patchWriter::patchWriter ( - const vtkMesh& vMesh, + const fvMesh& mesh, const bool binary, const bool nearCellValue, const fileName& fName, const labelList& patchIDs ) : - vMesh_(vMesh), + mesh_(mesh), binary_(binary), nearCellValue_(nearCellValue), fName_(fName), patchIDs_(patchIDs), os_(fName.c_str()) { - const fvMesh& mesh = vMesh_.mesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh(); // Write header @@ -115,8 +114,6 @@ Foam::patchWriter::patchWriter void Foam::patchWriter::writePatchIDs() { - const fvMesh& mesh = vMesh_.mesh(); - DynamicList fField(nFaces_); os_ << "patchID 1 " << nFaces_ << " float" << std::endl; @@ -125,7 +122,7 @@ void Foam::patchWriter::writePatchIDs() { label patchi = patchIDs_[i]; - const polyPatch& pp = mesh.boundaryMesh()[patchi]; + const polyPatch& pp = mesh_.boundaryMesh()[patchi]; if (!isA(pp)) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H index e25bbb1122..aab8075da8 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,12 +40,9 @@ SourceFiles #include "OFstream.H" #include "volFields.H" #include "pointFields.H" -#include "vtkMesh.H" #include "indirectPrimitivePatch.H" #include "PrimitivePatchInterpolation.H" -using namespace Foam; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -59,7 +56,8 @@ class volPointInterpolation; class patchWriter { - const vtkMesh& vMesh_; + //- Reference to the OpenFOAM mesh (or subset) + const fvMesh& mesh_; const bool binary_; @@ -82,7 +80,7 @@ public: //- Construct from components patchWriter ( - const vtkMesh&, + const fvMesh&, const bool binary, const bool nearCellValue, const fileName&, diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C index 8d515ab056..172a83cf23 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,37 +36,32 @@ namespace Foam template void readFields ( - const vtkMesh& vMesh, + const meshSubsetHelper& helper, const typename GeoField::Mesh& mesh, const IOobjectList& objects, const HashSet& selectedFields, PtrList& fields ) { - // Search list of objects for volScalarFields + // Search list of objects for fields of type GeomField IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); - // Construct the vol scalar fields + // Construct the fields fields.setSize(fieldObjects.size()); label nFields = 0; - forAllIter(IOobjectList, fieldObjects, iter) + forAllConstIter(IOobjectList, fieldObjects, iter) { if (selectedFields.empty() || selectedFields.found(iter()->name())) { fields.set ( - nFields, - vMesh.interpolate + nFields++, + helper.interpolate ( - GeoField - ( - *iter(), - mesh - ) + GeoField(*iter(), mesh) ).ptr() ); - nFields++; } } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.H index 31b7e2632c..510bd11d25 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,7 +34,7 @@ SourceFiles #ifndef readFields_H #define readFields_H -#include "fvMesh.H" +#include "meshSubsetHelper.H" #include "PtrList.H" #include "IOobjectList.H" #include "HashSet.H" @@ -48,7 +48,7 @@ namespace Foam template void readFields ( - const vtkMesh& vMesh, + const meshSubsetHelper&, const typename GeoField::Mesh& mesh, const IOobjectList& objects, const HashSet& selectedFields, diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H index f06da45c3f..0a5589c26e 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H @@ -40,11 +40,8 @@ SourceFiles #include "OFstream.H" #include "volFields.H" #include "surfaceFields.H" -#include "vtkMesh.H" #include "indirectPrimitivePatch.H" -using namespace Foam; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C index 68fd29d257..92d878f229 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C @@ -29,7 +29,8 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template -Foam::tmp> Foam::surfaceMeshWriter::getFaceField +Foam::tmp> +Foam::surfaceMeshWriter::getFaceField ( const GeometricField& sfld ) const diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.C deleted file mode 100644 index d13a96df3d..0000000000 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.C +++ /dev/null @@ -1,82 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "vtkMesh.H" -#include "fvMeshSubset.H" -#include "Time.H" -#include "cellSet.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::vtkMesh::vtkMesh -( - fvMesh& baseMesh, - const word& setName -) -: - baseMesh_(baseMesh), - subsetter_(baseMesh), - setName_(setName) -{ - if (setName.size()) - { - // Read cellSet using whole mesh - cellSet currentSet(baseMesh_, setName_); - - // Set current subset - subsetter_.setLargeCellSubset(currentSet); - } -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate() -{ - polyMesh::readUpdateState meshState = baseMesh_.readUpdate(); - - if (meshState != polyMesh::UNCHANGED) - { - // Note: since fvMeshSubset has no movePoints() functionality, - // reconstruct the subset even if only movement. - - topoPtr_.clear(); - - if (setName_.size()) - { - Info<< "Subsetting mesh based on cellSet " << setName_ << endl; - - // Read cellSet using whole mesh - cellSet currentSet(baseMesh_, setName_); - - subsetter_.setLargeCellSubset(currentSet); - } - } - - return meshState; -} - - -// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.H index f536ae04fa..f0a80db4ea 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/vtkMesh.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,46 +36,35 @@ SourceFiles #ifndef vtkMesh_H #define vtkMesh_H +#include "meshSubsetHelper.H" #include "vtkTopo.H" -#include "fvMeshSubset.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declaration of classes -class Time; - /*---------------------------------------------------------------------------*\ Class vtkMesh Declaration \*---------------------------------------------------------------------------*/ class vtkMesh +: + public meshSubsetHelper { // Private data - //- Reference to mesh - fvMesh& baseMesh_; - - //- Subsetting engine + sub-fvMesh - fvMeshSubset subsetter_; - - //- Current cellSet (or empty) - const word setName_; - //- Current decomposition of topology mutable autoPtr topoPtr_; - // Private Member Functions //- Disallow default bitwise copy construct - vtkMesh(const vtkMesh&); + vtkMesh(const vtkMesh&) = delete; //- Disallow default bitwise assignment - void operator=(const vtkMesh&); + void operator=(const vtkMesh&) = delete; public: @@ -83,31 +72,17 @@ public: // Constructors //- Construct from components - vtkMesh(fvMesh& baseMesh, const word& setName = ""); + vtkMesh(fvMesh& baseMesh, const word& setName = word::null) + : + meshSubsetHelper(baseMesh, meshSubsetHelper::SET, setName) + {} // Member Functions // Access - //- Whole mesh - const fvMesh& baseMesh() const - { - return baseMesh_; - } - - const fvMeshSubset& subsetter() const - { - return subsetter_; - } - - //- Check if running subMesh - bool useSubMesh() const - { - return setName_.size(); - } - - //- topology + //- Topology const vtkTopo& topo() const { if (topoPtr_.empty()) @@ -117,18 +92,6 @@ public: return topoPtr_(); } - //- Access either mesh or submesh - const fvMesh& mesh() const - { - if (useSubMesh()) - { - return subsetter_.subMesh(); - } - else - { - return baseMesh_; - } - } //- Number of field cells label nFieldCells() const @@ -136,6 +99,7 @@ public: return topo().cellTypes().size(); } + //- Number of field points label nFieldPoints() const { @@ -145,26 +109,20 @@ public: // Edit - //- Read mesh - polyMesh::readUpdateState readUpdate(); - - - //- Map volume field (does in fact do very little interpolation; - // just copied from fvMeshSubset) - template - tmp interpolate(const GeoField& fld) const + //- Read mesh, forcing topo update if necessary + polyMesh::readUpdateState readUpdate() { - if (useSubMesh()) + polyMesh::readUpdateState meshState + = meshSubsetHelper::readUpdate(); + + if (meshState != polyMesh::UNCHANGED) { - tmp subFld = subsetter_.interpolate(fld); - subFld.ref().rename(fld.name()); - return subFld; - } - else - { - return fld; + topoPtr_.clear(); } + + return meshState; } + }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.C index 4ad78d96a0..0556b7aaf2 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,12 +32,12 @@ License void Foam::writeFaceSet ( const bool binary, - const vtkMesh& vMesh, + const fvMesh& mesh, const faceSet& set, const fileName& fileName ) { - const faceList& faces = vMesh.mesh().faces(); + const faceList& faces = mesh.faces(); std::ofstream ostr(fileName.c_str()); @@ -69,7 +69,7 @@ void Foam::writeFaceSet setFaces[setFacei] = faces[iter.key()]; setFacei++; } - primitiveFacePatch fp(setFaces, vMesh.mesh().points()); + primitiveFacePatch fp(setFaces, mesh.points()); // Write points and faces as polygons diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.H index eb7c452031..73ca4f0741 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFaceSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +36,7 @@ SourceFiles #ifndef writeFaceSet_H #define writeFaceSet_H -#include "vtkMesh.H" +#include "fvMesh.H" #include "faceSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,7 +48,7 @@ namespace Foam void writeFaceSet ( const bool binary, - const vtkMesh& vMesh, + const fvMesh&, const faceSet& set, const fileName& fileName ); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.C index 4cafa01f0a..e5fffb5366 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.C @@ -37,7 +37,7 @@ namespace Foam void writePointSet ( const bool binary, - const vtkMesh& vMesh, + const fvMesh& mesh, const pointSet& set, const fileName& fileName ) @@ -68,7 +68,7 @@ void writePointSet writeFuns::insert ( - UIndirectList(vMesh.mesh().points(), set.toc())(), + UIndirectList(mesh.points(), set.toc())(), ptField ); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.H index 32ffd981f6..d1ad15efe6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writePointSet.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -36,7 +36,7 @@ SourceFiles #ifndef writePointSet_H #define writePointSet_H -#include "vtkMesh.H" +#include "fvMesh.H" #include "pointSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,7 +48,7 @@ namespace Foam void writePointSet ( const bool binary, - const vtkMesh& vMesh, + const fvMesh& mesh, const pointSet& set, const fileName& fileName ); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C index 4144a579a5..9dc889adf4 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -35,13 +35,11 @@ License void Foam::writeSurfFields ( const bool binary, - const vtkMesh& vMesh, + const fvMesh& mesh, const fileName& fileName, const UPtrList& surfVectorFields ) { - const fvMesh& mesh = vMesh.mesh(); - std::ofstream str(fileName.c_str()); writeFuns::writeHeader diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H index 798e335fd3..7740e15f78 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H @@ -35,7 +35,7 @@ SourceFiles #ifndef writeSurfFields_H #define writeSurfFields_H -#include "vtkMesh.H" +#include "fvMesh.H" #include "surfaceMesh.H" #include "surfaceFieldsFwd.H" @@ -48,7 +48,7 @@ namespace Foam void writeSurfFields ( const bool binary, - const vtkMesh& vMesh, + const fvMesh&, const fileName& fileName, const UPtrList& surfVectorFields ); diff --git a/src/dynamicMesh/Make/files b/src/dynamicMesh/Make/files index 215d35048d..de8f61296c 100644 --- a/src/dynamicMesh/Make/files +++ b/src/dynamicMesh/Make/files @@ -90,6 +90,7 @@ polyMeshAdder/polyMeshAdder.C fvMeshTools/fvMeshTools.C fvMeshSubset/fvMeshSubset.C +meshSubsetHelper/meshSubsetHelper.C motionSmoother/motionSmoother.C motionSmoother/motionSmootherAlgo.C diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelper.C b/src/dynamicMesh/meshSubsetHelper/meshSubsetHelper.C similarity index 88% rename from applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelper.C rename to src/dynamicMesh/meshSubsetHelper/meshSubsetHelper.C index 05bdc9420b..0f3760654c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelper.C +++ b/src/dynamicMesh/meshSubsetHelper/meshSubsetHelper.C @@ -28,21 +28,34 @@ License #include "cellSet.H" #include "cellZone.H" #include "Time.H" -#include "IOstreams.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::meshSubsetHelper::meshSubsetHelper ( - fvMesh& baseMesh, - const word& name, - const bool isCellSet + fvMesh& baseMesh ) : baseMesh_(baseMesh), subsetter_(baseMesh), - name_(name), - type_(name_.empty() ? 0 : isCellSet ? 1 : 2) + type_(NONE), + name_() +{ + correct(); +} + + +Foam::meshSubsetHelper::meshSubsetHelper +( + fvMesh& baseMesh, + const subsetType type, + const word& name +) +: + baseMesh_(baseMesh), + subsetter_(baseMesh), + type_(name.empty() ? NONE : type), + name_(name) { correct(); } @@ -52,7 +65,7 @@ Foam::meshSubsetHelper::meshSubsetHelper void Foam::meshSubsetHelper::correct(bool verbose) { - if (type_ == 1) + if (type_ == SET) { if (verbose) { @@ -62,7 +75,7 @@ void Foam::meshSubsetHelper::correct(bool verbose) cellSet subset(baseMesh_, name_); subsetter_.setLargeCellSubset(subset); } - else if (type_ == 2) + else if (type_ == ZONE) { if (verbose) { diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelper.H b/src/dynamicMesh/meshSubsetHelper/meshSubsetHelper.H similarity index 86% rename from applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelper.H rename to src/dynamicMesh/meshSubsetHelper/meshSubsetHelper.H index 43112a5a18..891e6d94a6 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelper.H +++ b/src/dynamicMesh/meshSubsetHelper/meshSubsetHelper.H @@ -54,6 +54,17 @@ class Time; class meshSubsetHelper { +public: + + //- Internal book-keeping for subset type + enum subsetType + { + NONE, //::Internal& df + >::Internal& ); @@ -174,6 +188,11 @@ public: >::Internal& ) const; + + //- Map volume field (does in fact do very little interpolation; + // just copied from fvMeshSubset) + template + tmp interpolate(const GeoField& fld) const; }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelperTemplates.C b/src/dynamicMesh/meshSubsetHelper/meshSubsetHelperTemplates.C similarity index 89% rename from applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelperTemplates.C rename to src/dynamicMesh/meshSubsetHelper/meshSubsetHelperTemplates.C index d588118d0f..25a6d1301b 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/meshSubsetHelperTemplates.C +++ b/src/dynamicMesh/meshSubsetHelper/meshSubsetHelperTemplates.C @@ -116,4 +116,25 @@ Foam::meshSubsetHelper::interpolate } +template +Foam::tmp +Foam::meshSubsetHelper::interpolate +( + const GeoField& fld +) const +{ + if (subsetter_.hasSubMesh()) + { + tmp subFld = subsetter_.interpolate(fld); + subFld.ref().checkOut(); + subFld.ref().rename(fld.name()); + return subFld; + } + else + { + return fld; + } +} + + // ************************************************************************* //