mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use common internal calls for VTK begin/end DataArray
- reduces common boilerplate, ensures that label fields are more easily handled.
This commit is contained in:
@ -49,25 +49,10 @@ void Foam::vtk::internalWriter::write
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), field.name(), numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(numberOfPoints_);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(field.name());
|
this->beginDataArray<Type>(field.name(), numberOfPoints_);
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -92,11 +77,7 @@ void Foam::vtk::internalWriter::write
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,8 +119,6 @@ void Foam::vtk::internalWriter::write
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
typedef DimensionedField<Type, pointMesh> PointFieldType;
|
typedef DimensionedField<Type, pointMesh> PointFieldType;
|
||||||
|
|
||||||
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
||||||
@ -148,21 +127,8 @@ void Foam::vtk::internalWriter::write
|
|||||||
|
|
||||||
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), vfield.name(), numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(numberOfPoints_);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(vfield.name());
|
this->beginDataArray<Type>(vfield.name(), numberOfPoints_);
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -179,11 +145,7 @@ void Foam::vtk::internalWriter::write
|
|||||||
vtk::writeLists(format(), pfield, vfield, addPointCellLabels);
|
vtk::writeLists(format(), pfield, vfield, addPointCellLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -205,8 +167,6 @@ void Foam::vtk::internalWriter::write
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
typedef GeometricField<Type, pointPatchField, pointMesh> PointFieldType;
|
typedef GeometricField<Type, pointPatchField, pointMesh> PointFieldType;
|
||||||
|
|
||||||
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
||||||
@ -215,21 +175,8 @@ void Foam::vtk::internalWriter::write
|
|||||||
|
|
||||||
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), vfield.name(), numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(numberOfPoints_);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(vfield.name());
|
this->beginDataArray<Type>(vfield.name(), numberOfPoints_);
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -246,11 +193,7 @@ void Foam::vtk::internalWriter::write
|
|||||||
vtk::writeLists(format(), pfield, vfield, addPointCellLabels);
|
vtk::writeLists(format(), pfield, vfield, addPointCellLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -47,7 +47,6 @@ void Foam::vtk::patchWriter::write
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
label nPoints = nLocalPoints_;
|
label nPoints = nLocalPoints_;
|
||||||
|
|
||||||
@ -57,22 +56,7 @@ void Foam::vtk::patchWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->beginDataArray<Type>(field.name(), nPoints);
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), field.name(), nPoints);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(nPoints);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(field.name());
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (parallel_ ? Pstream::master() : true)
|
if (parallel_ ? Pstream::master() : true)
|
||||||
{
|
{
|
||||||
@ -144,11 +128,7 @@ void Foam::vtk::patchWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,8 +149,6 @@ void Foam::vtk::patchWriter::write
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
label nFaces = nLocalFaces_;
|
label nFaces = nLocalFaces_;
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
@ -179,22 +157,7 @@ void Foam::vtk::patchWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->beginDataArray<Type>(field.name(), nFaces);
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), field.name(), nFaces);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(nFaces);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(field.name());
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (parallel_ ? Pstream::master() : true)
|
if (parallel_ ? Pstream::master() : true)
|
||||||
{
|
{
|
||||||
@ -261,11 +224,7 @@ void Foam::vtk::patchWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -287,8 +246,6 @@ void Foam::vtk::patchWriter::write
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
label nPoints = nLocalPoints_;
|
label nPoints = nLocalPoints_;
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
@ -297,22 +254,7 @@ void Foam::vtk::patchWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->beginDataArray<Type>(field.name(), nPoints);
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), field.name(), nPoints);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(nPoints);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(field.name());
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (parallel_ ? Pstream::master() : true)
|
if (parallel_ ? Pstream::master() : true)
|
||||||
{
|
{
|
||||||
@ -396,11 +338,7 @@ void Foam::vtk::patchWriter::write
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -159,29 +159,19 @@ bool Foam::vtk::surfaceFieldWriter::writeGeometry()
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// <Point>
|
// <Point>
|
||||||
if (format_)
|
this->beginPoints(numberOfPoints_);
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float,3>(numberOfPoints_);
|
|
||||||
|
|
||||||
format().tag(vtk::fileTag::POINTS)
|
|
||||||
.beginDataArray<float,3>(vtk::dataArrayAttr::POINTS);
|
|
||||||
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
// Internal faces
|
// Centres for internal faces
|
||||||
vtk::writeListParallel
|
vtk::writeListParallel
|
||||||
(
|
(
|
||||||
format_.ref(),
|
format_.ref(),
|
||||||
SubList<point>(centres, mesh_.nInternalFaces())
|
SubList<point>(centres, mesh_.nInternalFaces())
|
||||||
);
|
);
|
||||||
|
|
||||||
// Boundary faces
|
// Centres for boundary faces
|
||||||
vtk::writeListParallel
|
vtk::writeListParallel
|
||||||
(
|
(
|
||||||
format_.ref(),
|
format_.ref(),
|
||||||
@ -195,15 +185,7 @@ bool Foam::vtk::surfaceFieldWriter::writeGeometry()
|
|||||||
vtk::writeList(format(), centres);
|
vtk::writeList(format(), centres);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endPoints();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
|
|
||||||
// Non-legacy
|
|
||||||
format()
|
|
||||||
.endDataArray()
|
|
||||||
.endTag(vtk::fileTag::POINTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -251,15 +233,7 @@ void Foam::vtk::surfaceFieldWriter::write(const surfaceVectorField& field)
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->beginDataArray<vector>(field.name(), nFaces);
|
||||||
{
|
|
||||||
// Non-legacy
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, 3>(nFaces);
|
|
||||||
|
|
||||||
format().beginDataArray<float, 3>(field.name());
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Internal field
|
// Internal field
|
||||||
@ -289,11 +263,7 @@ void Foam::vtk::surfaceFieldWriter::write(const surfaceVectorField& field)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -190,6 +190,55 @@ bool Foam::vtk::fileWriter::enter_PointData(label nEntries, label nFields)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::fileWriter::endDataArray()
|
||||||
|
{
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
format().endDataArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::fileWriter::beginPoints(const label nPoints)
|
||||||
|
{
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
if (legacy())
|
||||||
|
{
|
||||||
|
legacy::beginPoints(os_, nPoints);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const uint64_t payLoad =
|
||||||
|
vtk::sizeofData<float, 3>(nPoints);
|
||||||
|
|
||||||
|
format()
|
||||||
|
.tag(vtk::fileTag::POINTS)
|
||||||
|
.beginDataArray<float, 3>(vtk::dataArrayAttr::POINTS);
|
||||||
|
|
||||||
|
format().writeSize(payLoad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::vtk::fileWriter::endPoints()
|
||||||
|
{
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
format().endDataArray();
|
||||||
|
|
||||||
|
if (!legacy())
|
||||||
|
{
|
||||||
|
format()
|
||||||
|
.endTag(vtk::fileTag::POINTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::fileWriter::exit_File()
|
bool Foam::vtk::fileWriter::exit_File()
|
||||||
{
|
{
|
||||||
// Finish other output
|
// Finish other output
|
||||||
|
|||||||
@ -134,6 +134,24 @@ protected:
|
|||||||
//- True if the output state does not correspond to the test state.
|
//- True if the output state does not correspond to the test state.
|
||||||
inline bool notState(outputState test) const;
|
inline bool notState(outputState test) const;
|
||||||
|
|
||||||
|
//- Start of a field or DataArray output (legacy or non-legacy).
|
||||||
|
template<class Type>
|
||||||
|
void beginDataArray
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const label nValues
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Flush formatter and end of DataArray output (non-legacy)
|
||||||
|
void endDataArray();
|
||||||
|
|
||||||
|
//- Start of a POINTS DataArray
|
||||||
|
void beginPoints(const label nPoints);
|
||||||
|
|
||||||
|
//- End of a POINTS DataArray
|
||||||
|
void endPoints();
|
||||||
|
|
||||||
|
|
||||||
//- Write uniform field content.
|
//- Write uniform field content.
|
||||||
// No context checking (eg, file-open, CellData, PointData, etc)
|
// No context checking (eg, file-open, CellData, PointData, etc)
|
||||||
template<class Type>
|
template<class Type>
|
||||||
|
|||||||
@ -31,10 +31,9 @@ License
|
|||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::vtk::fileWriter::writeUniform
|
void Foam::vtk::fileWriter::beginDataArray
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
const Type& val,
|
|
||||||
const label nValues
|
const label nValues
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -59,7 +58,8 @@ void Foam::vtk::fileWriter::writeUniform
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const uint64_t payLoad = vtk::sizeofData<label, nCmpt>(nValues);
|
const uint64_t payLoad =
|
||||||
|
vtk::sizeofData<label, nCmpt>(nValues);
|
||||||
|
|
||||||
format().beginDataArray<label, nCmpt>(fieldName);
|
format().beginDataArray<label, nCmpt>(fieldName);
|
||||||
format().writeSize(payLoad);
|
format().writeSize(payLoad);
|
||||||
@ -73,24 +73,33 @@ void Foam::vtk::fileWriter::writeUniform
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const uint64_t payLoad = vtk::sizeofData<float, nCmpt>(nValues);
|
const uint64_t payLoad =
|
||||||
|
vtk::sizeofData<float, nCmpt>(nValues);
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(fieldName);
|
format().beginDataArray<float, nCmpt>(fieldName);
|
||||||
format().writeSize(payLoad);
|
format().writeSize(payLoad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtk::fileWriter::writeUniform
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const Type& val,
|
||||||
|
const label nValues
|
||||||
|
)
|
||||||
|
{
|
||||||
|
this->beginDataArray<Type>(fieldName, nValues);
|
||||||
|
|
||||||
if (format_)
|
if (format_)
|
||||||
{
|
{
|
||||||
vtk::write(format(), val, nValues);
|
vtk::write(format(), val, nValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,17 +110,6 @@ void Foam::vtk::fileWriter::writeBasicField
|
|||||||
const UList<Type>& field
|
const UList<Type>& field
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
static_assert
|
|
||||||
(
|
|
||||||
(
|
|
||||||
std::is_same<label, typename pTraits<Type>::cmptType>::value
|
|
||||||
|| std::is_floating_point<typename pTraits<Type>::cmptType>::value
|
|
||||||
),
|
|
||||||
"Label and Floating-point vector space only"
|
|
||||||
);
|
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
label nValues = field.size();
|
label nValues = field.size();
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
@ -119,38 +117,7 @@ void Foam::vtk::fileWriter::writeBasicField
|
|||||||
reduce(nValues, sumOp<label>());
|
reduce(nValues, sumOp<label>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->beginDataArray<Type>(fieldName, nValues);
|
||||||
{
|
|
||||||
if (std::is_same<label, typename pTraits<Type>::cmptType>::value)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::intField<nCmpt>(format(), fieldName, nValues);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad = vtk::sizeofData<label, nCmpt>(nValues);
|
|
||||||
|
|
||||||
format().beginDataArray<label, nCmpt>(fieldName);
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), fieldName, nValues);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad = vtk::sizeofData<float, nCmpt>(nValues);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(fieldName);
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -161,11 +128,7 @@ void Foam::vtk::fileWriter::writeBasicField
|
|||||||
vtk::writeList(format(), field);
|
vtk::writeList(format(), field);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -77,24 +77,7 @@ void Foam::vtk::polyWriter::writePoints
|
|||||||
const pointField& points
|
const pointField& points
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (format_)
|
this->beginPoints(numberOfPoints_);
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::beginPoints(os_, numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad = vtk::sizeofData<float, 3>(numberOfPoints_);
|
|
||||||
|
|
||||||
format()
|
|
||||||
.tag(vtk::fileTag::POINTS)
|
|
||||||
.beginDataArray<float,3>(vtk::dataArrayAttr::POINTS);
|
|
||||||
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (parallel_ ? Pstream::master() : true)
|
if (parallel_ ? Pstream::master() : true)
|
||||||
{
|
{
|
||||||
@ -103,7 +86,6 @@ void Foam::vtk::polyWriter::writePoints
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
@ -138,17 +120,7 @@ void Foam::vtk::polyWriter::writePoints
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endPoints();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
|
|
||||||
if (!legacy())
|
|
||||||
{
|
|
||||||
format()
|
|
||||||
.endTag(vtk::fileTag::POINTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -100,7 +100,6 @@ Foam::wordList Foam::functionObjects::vtkCloud::writeFields
|
|||||||
{
|
{
|
||||||
// Non-legacy
|
// Non-legacy
|
||||||
format().flush();
|
format().flush();
|
||||||
|
|
||||||
format().endDataArray();
|
format().endDataArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,25 +70,7 @@ void Foam::vtk::internalMeshWriter::beginPiece()
|
|||||||
|
|
||||||
void Foam::vtk::internalMeshWriter::writePoints()
|
void Foam::vtk::internalMeshWriter::writePoints()
|
||||||
{
|
{
|
||||||
if (format_)
|
this->beginPoints(numberOfPoints_);
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::beginPoints(os_, numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float,3>(numberOfPoints_);
|
|
||||||
|
|
||||||
format()
|
|
||||||
.tag(vtk::fileTag::POINTS)
|
|
||||||
.beginDataArray<float,3>(vtk::dataArrayAttr::POINTS);
|
|
||||||
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -112,17 +94,7 @@ void Foam::vtk::internalMeshWriter::writePoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endPoints();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
|
|
||||||
if (!legacy())
|
|
||||||
{
|
|
||||||
format()
|
|
||||||
.endTag(vtk::fileTag::POINTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -629,21 +601,8 @@ void Foam::vtk::internalMeshWriter::writeCellIDs()
|
|||||||
|
|
||||||
const labelList& cellMap = vtuCells_.cellMap();
|
const labelList& cellMap = vtuCells_.cellMap();
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
vtk::legacy::intField<1>(format(), "cellID", numberOfCells_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad = vtk::sizeofData<label>(numberOfCells_);
|
|
||||||
|
|
||||||
format().beginDataArray<label>("cellID");
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
this->beginDataArray<label>("cellID", numberOfCells_);
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -657,11 +616,7 @@ void Foam::vtk::internalMeshWriter::writeCellIDs()
|
|||||||
vtk::writeList(format(), cellMap);
|
vtk::writeList(format(), cellMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -686,40 +641,24 @@ bool Foam::vtk::internalMeshWriter::writeProcIDs()
|
|||||||
|
|
||||||
const globalIndex procMaps(vtuCells_.nFieldCells());
|
const globalIndex procMaps(vtuCells_.nFieldCells());
|
||||||
|
|
||||||
|
this->beginDataArray<label>("procID", procMaps.size());
|
||||||
|
|
||||||
bool good = false;
|
bool good = false;
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
const label nCells = procMaps.size();
|
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
vtk::legacy::intField<1>(format(), "procID", nCells);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<label>(nCells);
|
|
||||||
|
|
||||||
format().beginDataArray<label>("procID");
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Per-processor ids
|
// Per-processor ids
|
||||||
for (const int proci : Pstream::allProcs())
|
for (const int proci : Pstream::allProcs())
|
||||||
{
|
{
|
||||||
vtk::write(format(), label(proci), procMaps.localSize(proci));
|
vtk::write(format(), label(proci), procMaps.localSize(proci));
|
||||||
}
|
}
|
||||||
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
|
|
||||||
good = true;
|
good = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->endDataArray();
|
||||||
|
|
||||||
|
|
||||||
// MPI barrier
|
// MPI barrier
|
||||||
return returnReduce(good, orOp<bool>());
|
return returnReduce(good, orOp<bool>());
|
||||||
}
|
}
|
||||||
@ -738,21 +677,8 @@ void Foam::vtk::internalMeshWriter::writePointIDs()
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
vtk::legacy::intField<1>(format(), "pointID", numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad = vtk::sizeofData<label>(numberOfPoints_);
|
|
||||||
|
|
||||||
format().beginDataArray<label>("pointID");
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
this->beginDataArray<label>("pointID", numberOfPoints_);
|
||||||
|
|
||||||
// Point offset for regular mesh points (without decomposed)
|
// Point offset for regular mesh points (without decomposed)
|
||||||
const label pointOffset =
|
const label pointOffset =
|
||||||
@ -786,11 +712,7 @@ void Foam::vtk::internalMeshWriter::writePointIDs()
|
|||||||
vtk::writeList(format(), pointIds);
|
vtk::writeList(format(), pointIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -78,25 +78,9 @@ void Foam::vtk::internalMeshWriter::writeCellData
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
const labelList& cellMap = vtuCells_.cellMap();
|
const labelList& cellMap = vtuCells_.cellMap();
|
||||||
|
|
||||||
if (format_)
|
this->beginDataArray<Type>(fieldName, numberOfCells_);
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), fieldName, numberOfCells_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(numberOfCells_);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(fieldName);
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parallel_)
|
if (parallel_)
|
||||||
{
|
{
|
||||||
@ -107,11 +91,7 @@ void Foam::vtk::internalMeshWriter::writeCellData
|
|||||||
vtk::writeList(format(), field, cellMap);
|
vtk::writeList(format(), field, cellMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -84,25 +84,7 @@ void Foam::vtk::patchMeshWriter::writePoints()
|
|||||||
{
|
{
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
if (format_)
|
this->beginPoints(numberOfPoints_);
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::beginPoints(os_, numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, 3>(numberOfPoints_);
|
|
||||||
|
|
||||||
format()
|
|
||||||
.tag(vtk::fileTag::POINTS)
|
|
||||||
.beginDataArray<float, 3>(vtk::dataArrayAttr::POINTS);
|
|
||||||
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (parallel_ ? Pstream::master() : true)
|
if (parallel_ ? Pstream::master() : true)
|
||||||
{
|
{
|
||||||
@ -156,17 +138,7 @@ void Foam::vtk::patchMeshWriter::writePoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endPoints();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
|
|
||||||
if (!legacy())
|
|
||||||
{
|
|
||||||
format()
|
|
||||||
.endTag(vtk::fileTag::POINTS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -547,21 +519,8 @@ void Foam::vtk::patchMeshWriter::writePatchIDs()
|
|||||||
reduce(nFaces, sumOp<label>());
|
reduce(nFaces, sumOp<label>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::intField<1>(format(), "patchID", nFaces); // 1 component
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<label>(nFaces);
|
|
||||||
|
|
||||||
format().beginDataArray<label>("patchID");
|
this->beginDataArray<label>("patchID", nFaces);
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parallel_ ? Pstream::master() : true)
|
if (parallel_ ? Pstream::master() : true)
|
||||||
{
|
{
|
||||||
@ -619,11 +578,7 @@ void Foam::vtk::patchMeshWriter::writePatchIDs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -657,21 +612,8 @@ bool Foam::vtk::patchMeshWriter::writeProcIDs()
|
|||||||
reduce(nFaces, sumOp<label>());
|
reduce(nFaces, sumOp<label>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::intField<1>(format(), "procID", nFaces); // 1 component
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<label>(nFaces);
|
|
||||||
|
|
||||||
format().beginDataArray<label>("procID");
|
this->beginDataArray<label>("procID", nFaces);
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool good = false;
|
bool good = false;
|
||||||
|
|
||||||
@ -698,11 +640,7 @@ bool Foam::vtk::patchMeshWriter::writeProcIDs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
// MPI barrier
|
// MPI barrier
|
||||||
return parallel_ ? returnReduce(good, orOp<bool>()) : good;
|
return parallel_ ? returnReduce(good, orOp<bool>()) : good;
|
||||||
@ -737,21 +675,8 @@ bool Foam::vtk::patchMeshWriter::writeNeighIDs()
|
|||||||
reduce(nFaces, sumOp<label>());
|
reduce(nFaces, sumOp<label>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::intField<1>(format(), "neighID", nFaces); // 1 component
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<label>(nFaces);
|
|
||||||
|
|
||||||
format().beginDataArray<label>("neighID");
|
this->beginDataArray<label>("neighID", nFaces);
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool good = false;
|
bool good = false;
|
||||||
|
|
||||||
@ -818,11 +743,7 @@ bool Foam::vtk::patchMeshWriter::writeNeighIDs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format_)
|
this->endDataArray();
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
// MPI barrier
|
// MPI barrier
|
||||||
return parallel_ ? returnReduce(good, orOp<bool>()) : good;
|
return parallel_ ? returnReduce(good, orOp<bool>()) : good;
|
||||||
|
|||||||
Reference in New Issue
Block a user