foamToVTK: Use UPtrList rather than PtrList

This commit is contained in:
Henry Weller
2016-05-06 14:11:38 +01:00
parent 6ba5b46d0f
commit a50015a423
12 changed files with 52 additions and 50 deletions

View File

@ -164,7 +164,7 @@ Note
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class GeoField> 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()) if (flds.size())
{ {
@ -396,6 +396,7 @@ int main(int argc, char *argv[])
// VTK/ directory in the case // VTK/ directory in the case
fileName fvPath(runTime.path()/"VTK"); fileName fvPath(runTime.path()/"VTK");
// Directory of mesh (region0 gets filtered out) // Directory of mesh (region0 gets filtered out)
fileName regionPrefix = ""; fileName regionPrefix = "";
@ -556,11 +557,11 @@ int main(int argc, char *argv[])
// Construct the vol fields (on the original mesh if subsetted) // Construct the vol fields (on the original mesh if subsetted)
PtrList<volScalarField> vsf; PtrList<const volScalarField> vsf;
PtrList<volVectorField> vvf; PtrList<const volVectorField> vvf;
PtrList<volSphericalTensorField> vSpheretf; PtrList<const volSphericalTensorField> vSpheretf;
PtrList<volSymmTensorField> vSymmtf; PtrList<const volSymmTensorField> vSymmtf;
PtrList<volTensorField> vtf; PtrList<const volTensorField> vtf;
if (!specifiedFields || selectedFields.size()) if (!specifiedFields || selectedFields.size())
{ {
@ -612,11 +613,11 @@ int main(int argc, char *argv[])
<< " (\"-noPointValues\" (at your option)\n"; << " (\"-noPointValues\" (at your option)\n";
} }
PtrList<pointScalarField> psf; PtrList<const pointScalarField> psf;
PtrList<pointVectorField> pvf; PtrList<const pointVectorField> pvf;
PtrList<pointSphericalTensorField> pSpheretf; PtrList<const pointSphericalTensorField> pSpheretf;
PtrList<pointSymmTensorField> pSymmtf; PtrList<const pointSymmTensorField> pSymmtf;
PtrList<pointTensorField> ptf; PtrList<const pointTensorField> ptf;
if (!noPointValues && !(specifiedFields && selectedFields.empty())) if (!noPointValues && !(specifiedFields && selectedFields.empty()))
{ {
@ -747,7 +748,7 @@ int main(int argc, char *argv[])
if (args.optionFound("surfaceFields")) if (args.optionFound("surfaceFields"))
{ {
PtrList<surfaceScalarField> ssf; PtrList<const surfaceScalarField> ssf;
readFields readFields
( (
vMesh, vMesh,
@ -758,7 +759,7 @@ int main(int argc, char *argv[])
); );
print(" surfScalarFields :", Info, ssf); print(" surfScalarFields :", Info, ssf);
PtrList<surfaceVectorField> svf; PtrList<const surfaceVectorField> svf;
readFields readFields
( (
vMesh, vMesh,
@ -780,8 +781,9 @@ int main(int argc, char *argv[])
forAll(ssf, i) forAll(ssf, i)
{ {
svf.set(sz+i, ssf[i]*n); surfaceVectorField* ssfiPtr = (ssf[i]*n).ptr();
svf[sz+i].rename(ssf[i].name()); ssfiPtr->rename(ssf[i].name());
svf.set(sz+i, ssfiPtr);
} }
ssf.clear(); ssf.clear();
@ -990,7 +992,7 @@ int main(int argc, char *argv[])
if (doFaceZones) if (doFaceZones)
{ {
PtrList<surfaceScalarField> ssf; PtrList<const surfaceScalarField> ssf;
readFields readFields
( (
vMesh, vMesh,
@ -1001,7 +1003,7 @@ int main(int argc, char *argv[])
); );
print(" surfScalarFields :", Info, ssf); print(" surfScalarFields :", Info, ssf);
PtrList<surfaceVectorField> svf; PtrList<const surfaceVectorField> svf;
readFields readFields
( (
vMesh, vMesh,

View File

@ -91,7 +91,7 @@ public:
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
void write void write
( (
const PtrList<GeometricField<Type, PatchField, GeoMesh>>& const UPtrList<const GeometricField<Type, PatchField, GeoMesh>>&
); );
//- Interpolate and write volFields //- Interpolate and write volFields
@ -99,7 +99,7 @@ public:
void write void write
( (
const volPointInterpolation&, const volPointInterpolation&,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
); );
}; };

View File

@ -31,7 +31,7 @@ License
template<class Type, template<class> class PatchField, class GeoMesh> template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::internalWriter::write void Foam::internalWriter::write
( (
const PtrList<GeometricField<Type, PatchField, GeoMesh>>& flds const UPtrList<const GeometricField<Type, PatchField, GeoMesh>>& flds
) )
{ {
forAll(flds, i) forAll(flds, i)
@ -45,7 +45,7 @@ template<class Type>
void Foam::internalWriter::write void Foam::internalWriter::write
( (
const volPointInterpolation& pInterp, const volPointInterpolation& pInterp,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& flds const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
) )
{ {
forAll(flds, i) forAll(flds, i)

View File

@ -114,14 +114,17 @@ public:
template<class Type> template<class Type>
void write void write
( (
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
); );
//- Write pointFields //- Write pointFields
template<class Type> template<class Type>
void write void write
( (
const PtrList<GeometricField<Type, pointPatchField, pointMesh>>& const UPtrList
<
const GeometricField<Type, pointPatchField, pointMesh>
>&
); );
//- Interpolate and write volFields //- Interpolate and write volFields
@ -129,7 +132,7 @@ public:
void write void write
( (
const PrimitivePatchInterpolation<primitivePatch>&, const PrimitivePatchInterpolation<primitivePatch>&,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>&
); );
}; };

View File

@ -31,14 +31,14 @@ License
template<class Type> template<class Type>
void Foam::patchWriter::write void Foam::patchWriter::write
( (
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& flds const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
) )
{ {
forAll(flds, fieldi) forAll(flds, fieldi)
{ {
const GeometricField<Type, fvPatchField, volMesh>& fld = 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; << nFaces_ << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_); DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nFaces_);
@ -66,7 +66,7 @@ void Foam::patchWriter::write
template<class Type> template<class Type>
void Foam::patchWriter::write void Foam::patchWriter::write
( (
const PtrList<GeometricField<Type, pointPatchField, pointMesh>>& flds const UPtrList<const GeometricField<Type, pointPatchField, pointMesh>>& flds
) )
{ {
forAll(flds, fieldi) forAll(flds, fieldi)
@ -74,7 +74,7 @@ void Foam::patchWriter::write
const GeometricField<Type, pointPatchField, pointMesh>& fld = const GeometricField<Type, pointPatchField, pointMesh>& fld =
flds[fieldi]; flds[fieldi];
os_ << fld.name() << ' ' << pTraits<Type>::nComponents << ' ' os_ << fld.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
<< nPoints_ << " float" << std::endl; << nPoints_ << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_); DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);
@ -96,14 +96,14 @@ template<class Type>
void Foam::patchWriter::write void Foam::patchWriter::write
( (
const PrimitivePatchInterpolation<primitivePatch>& pInter, const PrimitivePatchInterpolation<primitivePatch>& pInter,
const PtrList<GeometricField<Type, fvPatchField, volMesh>>& flds const UPtrList<const GeometricField<Type, fvPatchField, volMesh>>& flds
) )
{ {
forAll(flds, fieldi) forAll(flds, fieldi)
{ {
const GeometricField<Type, fvPatchField, volMesh>& fld = 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; << nPoints_ << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_); DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nPoints_);

View File

@ -40,7 +40,7 @@ void readFields
const typename GeoField::Mesh& mesh, const typename GeoField::Mesh& mesh,
const IOobjectList& objects, const IOobjectList& objects,
const HashSet<word>& selectedFields, const HashSet<word>& selectedFields,
PtrList<GeoField>& fields PtrList<const GeoField>& fields
) )
{ {
// Search list of objects for volScalarFields // Search list of objects for volScalarFields
@ -64,7 +64,7 @@ void readFields
*iter(), *iter(),
mesh mesh
) )
) ).ptr()
); );
nFields++; nFields++;
} }

View File

@ -52,7 +52,7 @@ void readFields
const typename GeoField::Mesh& mesh, const typename GeoField::Mesh& mesh,
const IOobjectList& objects, const IOobjectList& objects,
const HashSet<word>& selectedFields, const HashSet<word>& selectedFields,
PtrList<GeoField>& fields PtrList<const GeoField>& fields
); );
} // End namespace Foam } // End namespace Foam

View File

@ -99,7 +99,10 @@ public:
template<class Type> template<class Type>
void write void write
( (
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& const UPtrList
<
const GeometricField<Type, fvsPatchField, surfaceMesh>
>&
); );
}; };

View File

@ -63,7 +63,10 @@ Foam::tmp<Field<Type>> Foam::surfaceMeshWriter::getFaceField
template<class Type> template<class Type>
void Foam::surfaceMeshWriter::write void Foam::surfaceMeshWriter::write
( (
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds const UPtrList
<
const GeometricField<Type, fvsPatchField, surfaceMesh>
>& sflds
) )
{ {
forAll(sflds, fieldi) forAll(sflds, fieldi)

View File

@ -74,7 +74,7 @@ void Foam::writeFuns::write
label nValues = mesh.nCells() + superCells.size(); label nValues = mesh.nCells() + superCells.size();
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' ' os << vvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
<< nValues << " float" << std::endl; << nValues << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues); DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nValues);
@ -106,7 +106,7 @@ void Foam::writeFuns::write
const labelList& addPointCellLabels = topo.addPointCellLabels(); const labelList& addPointCellLabels = topo.addPointCellLabels();
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size(); const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
os << pvf.name() << ' ' << pTraits<Type>::nComponents << ' ' os << pvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
<< nTotPoints << " float" << std::endl; << nTotPoints << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints); DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);
@ -139,7 +139,7 @@ void Foam::writeFuns::write
const labelList& addPointCellLabels = topo.addPointCellLabels(); const labelList& addPointCellLabels = topo.addPointCellLabels();
const label nTotPoints = mesh.nPoints() + addPointCellLabels.size(); const label nTotPoints = mesh.nPoints() + addPointCellLabels.size();
os << vvf.name() << ' ' << pTraits<Type>::nComponents << ' ' os << vvf.name() << ' ' << int(pTraits<Type>::nComponents) << ' '
<< nTotPoints << " float" << std::endl; << nTotPoints << " float" << std::endl;
DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints); DynamicList<floatScalar> fField(pTraits<Type>::nComponents*nTotPoints);

View File

@ -30,19 +30,14 @@ License
#include "emptyFvsPatchFields.H" #include "emptyFvsPatchFields.H"
#include "fvsPatchFields.H" #include "fvsPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void writeSurfFields void Foam::writeSurfFields
( (
const bool binary, const bool binary,
const vtkMesh& vMesh, const vtkMesh& vMesh,
const fileName& fileName, const fileName& fileName,
const PtrList<surfaceVectorField>& surfVectorFields const UPtrList<const surfaceVectorField>& surfVectorFields
) )
{ {
const fvMesh& mesh = vMesh.mesh(); const fvMesh& mesh = vMesh.mesh();
@ -117,8 +112,4 @@ void writeSurfFields
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -50,7 +50,7 @@ void writeSurfFields
const bool binary, const bool binary,
const vtkMesh& vMesh, const vtkMesh& vMesh,
const fileName& fileName, const fileName& fileName,
const PtrList<surfaceVectorField>& surfVectorFields const UPtrList<const surfaceVectorField>& surfVectorFields
); );
} // End namespace Foam } // End namespace Foam