foamToVTK: Use UPtrList rather than PtrList

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

View File

@ -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,

View File

@ -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>>&
);
};

View File

@ -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)

View File

@ -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>>&
);
};

View File

@ -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_);

View File

@ -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++;
}

View File

@ -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

View File

@ -99,7 +99,10 @@ public:
template<class Type>
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>
void Foam::surfaceMeshWriter::write
(
const PtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds
const UPtrList
<
const GeometricField<Type, fvsPatchField, surfaceMesh>
>& sflds
)
{
forAll(sflds, fieldi)

View File

@ -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);

View File

@ -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
// ************************************************************************* //

View File

@ -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