From 28c753f52e48fc4157732de257364339522f6d2e Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Fri, 6 May 2016 14:11:38 +0100 Subject: [PATCH] foamToVTK: Use UPtrList rather than PtrList --- .../dataConversion/foamToVTK/foamToVTK.C | 36 ++++++++++--------- .../foamToVTK/foamToVTK/internalWriter.H | 4 +-- .../foamToVTK/internalWriterTemplates.C | 4 +-- .../foamToVTK/foamToVTK/patchWriter.H | 9 +++-- .../foamToVTK/patchWriterTemplates.C | 12 +++---- .../foamToVTK/foamToVTK/readFields.C | 4 +-- .../foamToVTK/foamToVTK/readFields.H | 2 +- .../foamToVTK/foamToVTK/surfaceMeshWriter.H | 5 ++- .../foamToVTK/surfaceMeshWriterTemplates.C | 5 ++- .../foamToVTK/foamToVTK/writeFunsTemplates.C | 6 ++-- .../foamToVTK/foamToVTK/writeSurfFields.C | 13 ++----- .../foamToVTK/foamToVTK/writeSurfFields.H | 2 +- 12 files changed, 52 insertions(+), 50 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index cebe442ca0..3698b2e954 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -164,7 +164,7 @@ Note // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<class GeoField> -void print(const char* msg, Ostream& os, const PtrList<GeoField>& flds) +void print(const char* msg, Ostream& os, const PtrList<const GeoField>& flds) { if (flds.size()) { @@ -396,6 +396,7 @@ int main(int argc, char *argv[]) // VTK/ directory in the case fileName fvPath(runTime.path()/"VTK"); + // Directory of mesh (region0 gets filtered out) fileName regionPrefix = ""; @@ -556,11 +557,11 @@ int main(int argc, char *argv[]) // Construct the vol fields (on the original mesh if subsetted) - PtrList<volScalarField> vsf; - PtrList<volVectorField> vvf; - PtrList<volSphericalTensorField> vSpheretf; - PtrList<volSymmTensorField> vSymmtf; - PtrList<volTensorField> vtf; + PtrList<const volScalarField> vsf; + PtrList<const volVectorField> vvf; + PtrList<const volSphericalTensorField> vSpheretf; + PtrList<const volSymmTensorField> vSymmtf; + PtrList<const volTensorField> vtf; if (!specifiedFields || selectedFields.size()) { @@ -612,11 +613,11 @@ int main(int argc, char *argv[]) << " (\"-noPointValues\" (at your option)\n"; } - PtrList<pointScalarField> psf; - PtrList<pointVectorField> pvf; - PtrList<pointSphericalTensorField> pSpheretf; - PtrList<pointSymmTensorField> pSymmtf; - PtrList<pointTensorField> ptf; + PtrList<const pointScalarField> psf; + PtrList<const pointVectorField> pvf; + PtrList<const pointSphericalTensorField> pSpheretf; + PtrList<const pointSymmTensorField> pSymmtf; + PtrList<const pointTensorField> ptf; if (!noPointValues && !(specifiedFields && selectedFields.empty())) { @@ -747,7 +748,7 @@ int main(int argc, char *argv[]) if (args.optionFound("surfaceFields")) { - PtrList<surfaceScalarField> ssf; + PtrList<const surfaceScalarField> ssf; readFields ( vMesh, @@ -758,7 +759,7 @@ int main(int argc, char *argv[]) ); print(" surfScalarFields :", Info, ssf); - PtrList<surfaceVectorField> svf; + PtrList<const surfaceVectorField> svf; readFields ( vMesh, @@ -780,8 +781,9 @@ int main(int argc, char *argv[]) forAll(ssf, i) { - svf.set(sz+i, ssf[i]*n); - svf[sz+i].rename(ssf[i].name()); + surfaceVectorField* ssfiPtr = (ssf[i]*n).ptr(); + ssfiPtr->rename(ssf[i].name()); + svf.set(sz+i, ssfiPtr); } ssf.clear(); @@ -990,7 +992,7 @@ int main(int argc, char *argv[]) if (doFaceZones) { - PtrList<surfaceScalarField> ssf; + PtrList<const surfaceScalarField> ssf; readFields ( vMesh, @@ -1001,7 +1003,7 @@ int main(int argc, char *argv[]) ); print(" surfScalarFields :", Info, ssf); - PtrList<surfaceVectorField> svf; + PtrList<const surfaceVectorField> svf; readFields ( vMesh, diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H index 4da03b6d73..54ec3168f7 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriter.H @@ -91,7 +91,7 @@ public: template<class Type, template<class> class PatchField, class GeoMesh> void write ( - const PtrList<GeometricField<Type, PatchField, GeoMesh>>& + const UPtrList<const GeometricField<Type, PatchField, GeoMesh>>& ); //- Interpolate and write volFields @@ -99,7 +99,7 @@ public: void write ( const volPointInterpolation&, - const PtrList<GeometricField<Type, fvPatchField, volMesh>>& + const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& ); }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriterTemplates.C index cdc7ad9720..a90eaaa712 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/internalWriterTemplates.C @@ -31,7 +31,7 @@ License template<class Type, template<class> class PatchField, class GeoMesh> void Foam::internalWriter::write ( - const PtrList<GeometricField<Type, PatchField, GeoMesh>>& flds + const UPtrList<const GeometricField<Type, PatchField, GeoMesh>>& flds ) { forAll(flds, i) @@ -45,7 +45,7 @@ template<class Type> void Foam::internalWriter::write ( const volPointInterpolation& pInterp, - const PtrList<GeometricField<Type, fvPatchField, volMesh>>& flds + const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds ) { forAll(flds, i) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H index f0880c9903..e25bbb1122 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriter.H @@ -114,14 +114,17 @@ public: template<class Type> void write ( - const PtrList<GeometricField<Type, fvPatchField, volMesh>>& + const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& ); //- Write pointFields template<class Type> void write ( - const PtrList<GeometricField<Type, pointPatchField, pointMesh>>& + const UPtrList + < + const GeometricField<Type, pointPatchField, pointMesh> + >& ); //- Interpolate and write volFields @@ -129,7 +132,7 @@ public: void write ( const PrimitivePatchInterpolation<primitivePatch>&, - const PtrList<GeometricField<Type, fvPatchField, volMesh>>& + const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& ); }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriterTemplates.C index 192f7ca2c1..e67aa4c835 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/patchWriterTemplates.C @@ -31,14 +31,14 @@ License template<class Type> void Foam::patchWriter::write ( - const PtrList<GeometricField<Type, fvPatchField, volMesh>>& flds + const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds ) { forAll(flds, fieldi) { const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi]; - os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' ' + os_ << fld.name() << ' ' << int(pTraits<Type>::nComponents) << ' ' << nFaces_ << " float" << std::endl; DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_); @@ -66,7 +66,7 @@ void Foam::patchWriter::write template<class Type> void Foam::patchWriter::write ( - const PtrList<GeometricField<Type, pointPatchField, pointMesh>>& flds + const UPtrList<const GeometricField<Type, pointPatchField, pointMesh>>& flds ) { forAll(flds, fieldi) @@ -74,7 +74,7 @@ void Foam::patchWriter::write const GeometricField<Type, pointPatchField, pointMesh>& fld = flds[fieldi]; - os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' ' + os_ << fld.name() << ' ' << int(pTraits<Type>::nComponents) << ' ' << nPoints_ << " float" << std::endl; DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_); @@ -96,14 +96,14 @@ template<class Type> void Foam::patchWriter::write ( const PrimitivePatchInterpolation<primitivePatch>& pInter, - const PtrList<GeometricField<Type, fvPatchField, volMesh>>& flds + const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds ) { forAll(flds, fieldi) { const GeometricField<Type, fvPatchField, volMesh>& fld = flds[fieldi]; - os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' ' + os_ << fld.name() << ' ' << int(pTraits<Type>::nComponents) << ' ' << nPoints_ << " float" << std::endl; DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C index 6c27883787..8d515ab056 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.C @@ -40,7 +40,7 @@ void readFields const typename GeoField::Mesh& mesh, const IOobjectList& objects, const HashSet<word>& selectedFields, - PtrList<GeoField>& fields + PtrList<const GeoField>& fields ) { // Search list of objects for volScalarFields @@ -64,7 +64,7 @@ void readFields *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 118801a309..31b7e2632c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/readFields.H @@ -52,7 +52,7 @@ void readFields const typename GeoField::Mesh& mesh, const IOobjectList& objects, const HashSet<word>& selectedFields, - PtrList<GeoField>& fields + PtrList<const GeoField>& fields ); } // End namespace Foam diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H index 2520badad0..f06da45c3f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriter.H @@ -99,7 +99,10 @@ public: template<class Type> void write ( - const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& + const UPtrList + < + const GeometricField<Type, fvsPatchField, surfaceMesh> + >& ); }; diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C index b36d401ac4..b7e96e3970 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/surfaceMeshWriterTemplates.C @@ -63,7 +63,10 @@ Foam::tmp<Field<Type>> Foam::surfaceMeshWriter::getFaceField template<class Type> void Foam::surfaceMeshWriter::write ( - const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds + const UPtrList + < + const GeometricField<Type, fvsPatchField, surfaceMesh> + >& sflds ) { forAll(sflds, fieldi) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFunsTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFunsTemplates.C index 4dcf09ae2c..137dc10e9a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFunsTemplates.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeFunsTemplates.C @@ -74,7 +74,7 @@ void Foam::writeFuns::write label nValues = mesh.nCells() + superCells.size(); - os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' ' + os << vvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' ' << nValues << " float" << std::endl; DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues); @@ -106,7 +106,7 @@ void Foam::writeFuns::write const labelList& addPointCellLabels = topo.addPointCellLabels(); const label nTotPoints = mesh.nPoints() + addPointCellLabels.size(); - os << pvf.name() << ' ' << pTraits<Type>::nComponents << ' ' + os << pvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' ' << nTotPoints << " float" << std::endl; DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints); @@ -139,7 +139,7 @@ void Foam::writeFuns::write const labelList& addPointCellLabels = topo.addPointCellLabels(); const label nTotPoints = mesh.nPoints() + addPointCellLabels.size(); - os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' ' + os << vvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' ' << nTotPoints << " float" << std::endl; DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C index 62381e65d2..4144a579a5 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.C @@ -30,19 +30,14 @@ License #include "emptyFvsPatchFields.H" #include "fvsPatchFields.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // -void writeSurfFields +void Foam::writeSurfFields ( const bool binary, const vtkMesh& vMesh, const fileName& fileName, - const PtrList<surfaceVectorField>& surfVectorFields + const UPtrList<const surfaceVectorField>& surfVectorFields ) { const fvMesh& mesh = vMesh.mesh(); @@ -117,8 +112,4 @@ void writeSurfFields } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H index 0d1f5ecd4c..798e335fd3 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK/writeSurfFields.H @@ -50,7 +50,7 @@ void writeSurfFields const bool binary, const vtkMesh& vMesh, const fileName& fileName, - const PtrList<surfaceVectorField>& surfVectorFields + const UPtrList<const surfaceVectorField>& surfVectorFields ); } // End namespace Foam -- GitLab