ENH: Added finiteArea support to foamToVTK

This commit is contained in:
Andrew Heather
2017-11-21 16:33:33 +00:00
committed by Andrew Heather
parent a14eb71160
commit c2ff8ea99e
14 changed files with 316 additions and 88 deletions

View File

@ -1,8 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/finiteArea/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lfiniteArea \
-lmeshTools

View File

@ -40,6 +40,7 @@ SourceFiles
#include "OFstream.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "areaFields.H"
#include "indirectPrimitivePatch.H"
#include "foamVtkOutputOptions.H"
@ -152,6 +153,13 @@ public:
const GeometricField<Type, fvsPatchField, surfaceMesh>& field
);
//- Write surface field
template<class Type>
void write
(
const GeometricField<Type, faPatchField, areaMesh>& field
);
// Write fields (collectively)
@ -164,6 +172,16 @@ public:
const GeometricField<Type, fvsPatchField, surfaceMesh>
>& sflds
);
//- Write surface fields
template<class Type>
void write
(
const UPtrList
<
const GeometricField<Type, faPatchField, areaMesh>
>& sflds
);
};

View File

@ -74,8 +74,7 @@ void Foam::vtk::surfaceMeshWriter::write
}
else
{
format().openDataArray<float, nCmpt>(field.name())
.closeTag();
format().openDataArray<float, nCmpt>(field.name()).closeTag();
}
format().writeSize(payLoad);
@ -90,6 +89,36 @@ void Foam::vtk::surfaceMeshWriter::write
}
template<class Type>
void Foam::vtk::surfaceMeshWriter::write
(
const GeometricField<Type, faPatchField, areaMesh>& field
)
{
const int nCmpt(pTraits<Type>::nComponents);
const uint64_t payLoad(pp_.size() * nCmpt * sizeof(float));
if (legacy_)
{
legacy::floatField(os(), field.name(), nCmpt, pp_.size());
}
else
{
format().openDataArray<float, nCmpt>(field.name()).closeTag();
}
format().writeSize(payLoad);
vtk::writeList(format(), field.primitiveField());
format().flush();
if (!legacy_)
{
format().endDataArray();
}
}
template<class Type>
void Foam::vtk::surfaceMeshWriter::write
(
@ -106,4 +135,20 @@ void Foam::vtk::surfaceMeshWriter::write
}
template<class Type>
void Foam::vtk::surfaceMeshWriter::write
(
const UPtrList
<
const GeometricField<Type, faPatchField, areaMesh>
>& sflds
)
{
for (const auto& field : sflds)
{
write(field);
}
}
// ************************************************************************* //