From a32a915d2e5d7f16fce5a9cce3c1c4c9145470ef Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Thu, 15 Dec 2016 19:07:05 +0100 Subject: [PATCH] BUG: polyMesh removeFiles side-effect for blockMesh viewer (issue #346) - polyMesh constructor from cell shapes invoked 'removeFiles'. This may or may not be what the caller wants or expects. With the ParaView blockMesh viewer, this behaviour causes deletion of all mesh data (points, faces, etc) when the viewer is refreshed. Triggered even when just building the blockMesh topology. - only a few places that construct a polyMesh from cell shapes (mostly mesh conversion utilities). Ensure that the file removal (if any) occurs in the application and *not* as a side-effect of calling the polyMesh constructor. -- blockMesh (application) - The placement of the removeFiles seems to also remove freshly generated sets (Bug or feature to remove sets?) +-----------------------+---------------+------------------+ | Application | Constructor | removeFiles | | | (patch info) | new / existing | +-----------------------+---------------+------------------+ | blockMesh | dictionary | existing | | ansysToFoam | names | new | | cfx4ToFoam | dictionary | new | | fluentMeshToFoam | names | new | | gambitToFoam | dictionary | new | | gmshToFoam | names | new | | ideasUnvToFoam | names | new | | kivaToFoam | dictionary | new | | mshToFoam | names | new | | netgenNeutralToFoam | names | new | | plot3dToFoam | names | new | | tetgenToFoam | names | new | | vtkUnstructuredToFoam | names | new | +-----------------------+---------------+------------------+ --- .../mesh/conversion/ansysToFoam/ansysToFoam.L | 1 + .../utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C | 1 + .../conversion/fluentMeshToFoam/fluentMeshToFoam.L | 3 +++ .../mesh/conversion/gambitToFoam/gambitToFoam.L | 1 + .../utilities/mesh/conversion/gmshToFoam/gmshToFoam.C | 3 +++ .../mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C | 10 +++++----- .../mesh/conversion/kivaToFoam/readKivaGrid.H | 1 + .../utilities/mesh/conversion/mshToFoam/mshToFoam.C | 2 +- .../netgenNeutralToFoam/netgenNeutralToFoam.C | 5 ++--- .../mesh/conversion/plot3dToFoam/plot3dToFoam.C | 1 + .../mesh/conversion/tetgenToFoam/tetgenToFoam.C | 4 ++-- .../vtkUnstructuredToFoam/vtkUnstructuredToFoam.C | 2 +- src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C | 6 ------ 13 files changed, 22 insertions(+), 18 deletions(-) diff --git a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L index 5c4c321850d..3268db21081 100644 --- a/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L +++ b/applications/utilities/mesh/conversion/ansysToFoam/ansysToFoam.L @@ -702,6 +702,7 @@ int main(int argc, char *argv[]) IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); Info<< "Writing polyMesh" << endl; + pShapeMesh.removeFiles(); pShapeMesh.write(); Info<< nl << "end" << endl; diff --git a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C index 45477dd4fba..ee5b4f073b8 100644 --- a/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C +++ b/applications/utilities/mesh/conversion/cfx4ToFoam/cfx4ToFoam.C @@ -753,6 +753,7 @@ int main(int argc, char *argv[]) IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); Info<< "Writing polyMesh" << endl; + pShapeMesh.removeFiles(); pShapeMesh.write(); Info<< "End\n" << endl; diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L index 5a0ebc94aa2..fbb98236c85 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L @@ -1177,6 +1177,9 @@ int main(int argc, char *argv[]) patchPhysicalTypes ); + // Remove files now, to ensure all mesh files written are consistent. + pShapeMesh.removeFiles(); + //dont write mesh yet, otherwise preservePatchTypes will be broken //and zones wont be written //checkmesh done after patch addition as well diff --git a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L index f9ce3c3423f..ff3ae5737ed 100644 --- a/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L +++ b/applications/utilities/mesh/conversion/gambitToFoam/gambitToFoam.L @@ -865,6 +865,7 @@ int main(int argc, char *argv[]) IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); Info<< "Writing polyMesh" << endl; + pShapeMesh.removeFiles(); pShapeMesh.write(); Info<< "\nEnd\n" << endl; diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index a1d4f55668a..f6c84fbb1a1 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -942,6 +942,9 @@ int main(int argc, char *argv[]) boundaryPatchPhysicalTypes ); + // Remove files now, to ensure all mesh files written are consistent. + mesh.removeFiles(); + repatchPolyTopoChanger repatcher(mesh); // Now use the patchFaces to patch up the outside faces of the mesh. diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 6c3c2451e02..e4c9fb7bf9f 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -1158,8 +1158,6 @@ int main(int argc, char *argv[]) Info<< endl; - - // Construct mesh polyMesh mesh ( @@ -1179,8 +1177,10 @@ int main(int argc, char *argv[]) wordList(0) // boundaryPatchPhysicalTypes ); + // Remove files now, to ensure all mesh files written are consistent. + mesh.removeFiles(); - if (faceZones.size() > 0 || cellZones.size() > 0) + if (faceZones.size() || cellZones.size()) { Info << "Adding cell and face zones" << endl; @@ -1188,7 +1188,7 @@ int main(int argc, char *argv[]) List<faceZone*> fZones(faceZones.size()); List<cellZone*> cZones(cellZones.size()); - if (cellZones.size() > 0) + if (cellZones.size()) { forAll(cellZones.toc(), cnt) { @@ -1205,7 +1205,7 @@ int main(int argc, char *argv[]) ); } } - if (faceZones.size() > 0) + if (faceZones.size()) { const labelList& own = mesh.faceOwner(); const labelList& nei = mesh.faceNeighbour(); diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H index 994f0c57a77..d291b831396 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H +++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H @@ -575,6 +575,7 @@ polyMesh pShapeMesh ); Info << "Writing polyMesh" << endl; +pShapeMesh.removeFiles(); pShapeMesh.write(); fileName czPath diff --git a/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C b/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C index 28e99a7a1d6..2bc7e4fd7e5 100644 --- a/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C +++ b/applications/utilities/mesh/conversion/mshToFoam/mshToFoam.C @@ -156,9 +156,9 @@ int main(int argc, char *argv[]) Info<< "Writing mesh ..." << endl; + mesh.removeFiles(); mesh.write(); - Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C index d953cc9782a..c7f8d86a200 100644 --- a/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C +++ b/applications/utilities/mesh/conversion/netgenNeutralToFoam/netgenNeutralToFoam.C @@ -313,11 +313,10 @@ int main(int argc, char *argv[]) patchPhysicalTypes ); - Info<< "Writing mesh to " << runTime.constant() << endl << endl; - + Info<< "Writing mesh ..." << endl; + mesh.removeFiles(); mesh.write(); - Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C index ac629373671..1a24ab8623d 100644 --- a/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C +++ b/applications/utilities/mesh/conversion/plot3dToFoam/plot3dToFoam.C @@ -262,6 +262,7 @@ int main(int argc, char *argv[]) IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); Info<< "Writing polyMesh" << endl; + pShapeMesh.removeFiles(); pShapeMesh.write(); Info<< "End\n" << endl; diff --git a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C index 39d8ff5a769..b7b80d576c1 100644 --- a/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C +++ b/applications/utilities/mesh/conversion/tetgenToFoam/tetgenToFoam.C @@ -342,7 +342,6 @@ int main(int argc, char *argv[]) const polyMesh& mesh = meshPtr; - if (readFaceFile) { label nPatches = 0; @@ -474,7 +473,7 @@ int main(int argc, char *argv[]) boundaryPatch.setSize(facei); - // Print region to patch mapping + // Print region to patch mapping Info<< "Regions:" << endl; forAllConstIter(Map<label>, regionToPatch, iter) @@ -548,6 +547,7 @@ int main(int argc, char *argv[]) Info<< "Writing mesh to " << runTime.constant() << endl << endl; + meshPtr().removeFiles(); meshPtr().write(); Info<< "End\n" << endl; diff --git a/applications/utilities/mesh/conversion/vtkUnstructuredToFoam/vtkUnstructuredToFoam.C b/applications/utilities/mesh/conversion/vtkUnstructuredToFoam/vtkUnstructuredToFoam.C index 507d8575e7b..a338b390b5f 100644 --- a/applications/utilities/mesh/conversion/vtkUnstructuredToFoam/vtkUnstructuredToFoam.C +++ b/applications/utilities/mesh/conversion/vtkUnstructuredToFoam/vtkUnstructuredToFoam.C @@ -80,9 +80,9 @@ int main(int argc, char *argv[]) Info<< "Writing mesh ..." << endl; + mesh.removeFiles(); mesh.write(); - Info<< "End\n" << endl; return 0; diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index f7a6b8d2d34..ee160048be8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -530,9 +530,6 @@ Foam::polyMesh::polyMesh Info<<"Constructing polyMesh from cell and boundary shapes." << endl; } - // Remove all of the old mesh files if they exist - removeFiles(instance()); - // Calculate faces and cells labelList patchSizes; labelList patchStarts; @@ -814,9 +811,6 @@ Foam::polyMesh::polyMesh Info<<"Constructing polyMesh from cell and boundary shapes." << endl; } - // Remove all of the old mesh files if they exist - removeFiles(instance()); - // Calculate faces and cells labelList patchSizes; labelList patchStarts; -- GitLab