mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: refactor vtk::internalWriter, vtk::patchWriter
- new vtk::internalMeshWriter, vtk::patchMeshWriter intermediate classes without finiteVolume dependencies. Enables direct use with a polyMesh. Makes vtk::internalWriter, vtk::patchWriter header/template only.
This commit is contained in:
@ -16,8 +16,6 @@ starcd/STARCDMeshWriter.C
|
|||||||
|
|
||||||
polyDualMesh/polyDualMesh.C
|
polyDualMesh/polyDualMesh.C
|
||||||
|
|
||||||
vtk/output/foamVtkInternalWriter.H
|
|
||||||
vtk/output/foamVtkPatchWriter.H
|
|
||||||
vtk/output/foamVtkSurfaceFieldWriter.C
|
vtk/output/foamVtkSurfaceFieldWriter.C
|
||||||
|
|
||||||
LIB = $(FOAM_LIBBIN)/libconversion
|
LIB = $(FOAM_LIBBIN)/libconversion
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -40,8 +40,10 @@ Note
|
|||||||
In the future, the duplicate points at processor connections
|
In the future, the duplicate points at processor connections
|
||||||
may be addressed using ghost points.
|
may be addressed using ghost points.
|
||||||
|
|
||||||
|
See Also
|
||||||
|
Foam::vtk::internalMeshWriter
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkInternalWriter.C
|
|
||||||
foamVtkInternalWriterTemplates.C
|
foamVtkInternalWriterTemplates.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -49,8 +51,7 @@ SourceFiles
|
|||||||
#ifndef foamVtkInternalWriter_H
|
#ifndef foamVtkInternalWriter_H
|
||||||
#define foamVtkInternalWriter_H
|
#define foamVtkInternalWriter_H
|
||||||
|
|
||||||
#include "foamVtkFileWriter.H"
|
#include "foamVtkInternalMeshWriter.H"
|
||||||
#include "foamVtuCells.H"
|
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "pointFields.H"
|
#include "pointFields.H"
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class volPointInterpolation;
|
class volPointInterpolation;
|
||||||
|
|
||||||
namespace vtk
|
namespace vtk
|
||||||
@ -71,44 +72,10 @@ namespace vtk
|
|||||||
|
|
||||||
class internalWriter
|
class internalWriter
|
||||||
:
|
:
|
||||||
public vtk::fileWriter
|
public vtk::internalMeshWriter
|
||||||
{
|
{
|
||||||
// Private Member Data
|
|
||||||
|
|
||||||
//- Reference to the OpenFOAM mesh (or subset)
|
|
||||||
const fvMesh& mesh_;
|
|
||||||
|
|
||||||
//- The volume cells (internalMesh)
|
|
||||||
const vtuCells& vtuCells_;
|
|
||||||
|
|
||||||
//- The number of field points for the current Piece
|
|
||||||
label numberOfPoints_;
|
|
||||||
|
|
||||||
//- The number of field cells for the current Piece
|
|
||||||
label numberOfCells_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Begin piece
|
|
||||||
void beginPiece();
|
|
||||||
|
|
||||||
//- Write mesh points
|
|
||||||
void writePoints();
|
|
||||||
|
|
||||||
//- Write cells (connectivity and type), legacy format
|
|
||||||
// \param pointOffset processor-local point offset
|
|
||||||
void writeCellsLegacy(const label pointOffset);
|
|
||||||
|
|
||||||
//- Write cells connectivity
|
|
||||||
// \param pointOffset processor-local point offset
|
|
||||||
void writeCellsConnectivity(const label pointOffset);
|
|
||||||
|
|
||||||
//- Write cells face streams
|
|
||||||
// \param pointOffset processor-local point offset
|
|
||||||
void writeCellsFaces(const label pointOffset);
|
|
||||||
|
|
||||||
|
|
||||||
//- No copy construct
|
//- No copy construct
|
||||||
internalWriter(const internalWriter&) = delete;
|
internalWriter(const internalWriter&) = delete;
|
||||||
|
|
||||||
@ -118,43 +85,46 @@ class internalWriter
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Debug information
|
|
||||||
static int debug;
|
|
||||||
|
|
||||||
//- File extension for given output type
|
|
||||||
// constexpr static vtk::fileTag content = vtk::fileTag::UNSTRUCTURED_GRID;
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components (default format INLINE_BASE64),
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
internalWriter
|
internalWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const vtk::vtuCells& cells,
|
const vtk::vtuCells& cells,
|
||||||
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
|
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
|
||||||
);
|
)
|
||||||
|
:
|
||||||
|
vtk::internalMeshWriter(mesh, cells, opts)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Construct from components (default format INLINE_BASE64),
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
// The file name is with/without an extension.
|
// The file name is with/without an extension.
|
||||||
internalWriter
|
internalWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const vtk::vtuCells& cells,
|
const vtk::vtuCells& cells,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel = Pstream::parRun()
|
bool parallel = Pstream::parRun()
|
||||||
);
|
)
|
||||||
|
:
|
||||||
|
vtk::internalMeshWriter(mesh, cells, file, parallel)
|
||||||
|
{}
|
||||||
|
|
||||||
//- Construct from components (default format INLINE_BASE64),
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
// The file name is with/without an extension.
|
// The file name is with/without an extension.
|
||||||
internalWriter
|
internalWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const vtk::vtuCells& cells,
|
const vtk::vtuCells& cells,
|
||||||
const vtk::outputOptions opts,
|
const vtk::outputOptions opts,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel = Pstream::parRun()
|
bool parallel = Pstream::parRun()
|
||||||
);
|
)
|
||||||
|
:
|
||||||
|
vtk::internalMeshWriter(mesh, cells, opts, file, parallel)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -163,63 +133,8 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- File extension for current format type.
|
|
||||||
using vtk::fileWriter::ext;
|
|
||||||
|
|
||||||
//- File extension for given output type
|
|
||||||
inline static word ext(vtk::outputOptions opts)
|
|
||||||
{
|
|
||||||
return opts.ext(vtk::fileTag::UNSTRUCTURED_GRID);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//- Write file header (non-collective)
|
|
||||||
// \note Expected calling states: (OPENED)
|
|
||||||
virtual bool beginFile(std::string title = "");
|
|
||||||
|
|
||||||
//- Write mesh topology.
|
|
||||||
// Also writes the file header if not previously written.
|
|
||||||
// \note Must be called prior to writing CellData or PointData
|
|
||||||
virtual bool writeGeometry();
|
|
||||||
|
|
||||||
//- Begin CellData output section for specified number of fields.
|
|
||||||
// Must be called prior to writing any cell data fields.
|
|
||||||
// \param nFields is for legacy format only.
|
|
||||||
// When nFields=0, this a no-op for legacy format.
|
|
||||||
// \note Expected calling states: (PIECE | POINT_DATA).
|
|
||||||
//
|
|
||||||
// \return True if the state changed
|
|
||||||
virtual bool beginCellData(label nFields = 0);
|
|
||||||
|
|
||||||
//- Begin PointData for specified number of fields.
|
|
||||||
// Must be called prior to writing any point data fields.
|
|
||||||
// \param nFields is for legacy format only.
|
|
||||||
// When nFields=0, this a no-op for legacy format.
|
|
||||||
// \note Expected calling states: (PIECE | CELL_DATA).
|
|
||||||
//
|
|
||||||
// \return True if the state changed
|
|
||||||
virtual bool beginPointData(label nFields = 0);
|
|
||||||
|
|
||||||
|
|
||||||
//- Write cell ids as CellData.
|
|
||||||
// Must be called within the CELL_DATA state.
|
|
||||||
void writeCellIDs();
|
|
||||||
|
|
||||||
//- Write processor ids as CellData. This is no-op in serial.
|
|
||||||
// Must be called within the CELL_DATA state.
|
|
||||||
bool writeProcIDs();
|
|
||||||
|
|
||||||
//- Write point ids as PointData.
|
|
||||||
// Must be called within the POINT_DATA state.
|
|
||||||
void writePointIDs();
|
|
||||||
|
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
//- Write a uniform field of Cell or Point values
|
|
||||||
template<class Type>
|
|
||||||
void writeUniform(const word& fieldName, const Type& val);
|
|
||||||
|
|
||||||
//- Write point field
|
//- Write point field
|
||||||
// Interpolate to originating cell centre for decomposed cells.
|
// Interpolate to originating cell centre for decomposed cells.
|
||||||
template<class Type, template<class> class PatchField>
|
template<class Type, template<class> class PatchField>
|
||||||
@ -228,7 +143,7 @@ public:
|
|||||||
const GeometricField<Type, PatchField, pointMesh>& field
|
const GeometricField<Type, PatchField, pointMesh>& field
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Write the internal field
|
//- Write the internal field (CellData)
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void write
|
void write
|
||||||
(
|
(
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -32,33 +32,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::vtk::internalWriter::writeUniform
|
|
||||||
(
|
|
||||||
const word& fieldName,
|
|
||||||
const Type& val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (isState(outputState::CELL_DATA))
|
|
||||||
{
|
|
||||||
++nCellData_;
|
|
||||||
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfCells_);
|
|
||||||
}
|
|
||||||
else if (isState(outputState::POINT_DATA))
|
|
||||||
{
|
|
||||||
++nPointData_;
|
|
||||||
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WarningInFunction
|
|
||||||
<< "Ignore bad writer state (" << stateNames[state_]
|
|
||||||
<< ") for field " << fieldName << nl << endl
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField>
|
template<class Type, template<class> class PatchField>
|
||||||
void Foam::vtk::internalWriter::write
|
void Foam::vtk::internalWriter::write
|
||||||
(
|
(
|
||||||
@ -135,53 +108,7 @@ void Foam::vtk::internalWriter::write
|
|||||||
const DimensionedField<Type, volMesh>& field
|
const DimensionedField<Type, volMesh>& field
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (isState(outputState::CELL_DATA))
|
writeCellData(field.name(), field.field());
|
||||||
{
|
|
||||||
++nCellData_;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Bad writer state (" << stateNames[state_]
|
|
||||||
<< ") - should be (" << stateNames[outputState::CELL_DATA]
|
|
||||||
<< ") for field " << field.name() << nl << endl
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
const direction nCmpt(pTraits<Type>::nComponents);
|
|
||||||
|
|
||||||
const labelList& cellMap = vtuCells_.cellMap();
|
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
if (legacy())
|
|
||||||
{
|
|
||||||
legacy::floatField<nCmpt>(format(), field.name(), numberOfCells_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const uint64_t payLoad =
|
|
||||||
vtk::sizeofData<float, nCmpt>(numberOfCells_);
|
|
||||||
|
|
||||||
format().beginDataArray<float, nCmpt>(field.name());
|
|
||||||
format().writeSize(payLoad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parallel_)
|
|
||||||
{
|
|
||||||
vtk::writeListParallel(format_.ref(), field, cellMap);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
vtk::writeList(format(), field, cellMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (format_)
|
|
||||||
{
|
|
||||||
format().flush();
|
|
||||||
format().endDataArray();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -191,7 +118,7 @@ void Foam::vtk::internalWriter::write
|
|||||||
const GeometricField<Type, PatchField, volMesh>& field
|
const GeometricField<Type, PatchField, volMesh>& field
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
write(field.internalField());
|
writeCellData(field.name(), field.primitiveField());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -221,7 +148,7 @@ void Foam::vtk::internalWriter::write
|
|||||||
|
|
||||||
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
||||||
tmp<PointFieldType> tfield = pInterp.interpolate(vfield);
|
tmp<PointFieldType> tfield = pInterp.interpolate(vfield);
|
||||||
const PointFieldType& pfield = tfield();
|
const auto& pfield = tfield();
|
||||||
|
|
||||||
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
||||||
|
|
||||||
@ -290,7 +217,7 @@ void Foam::vtk::internalWriter::write
|
|||||||
|
|
||||||
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
// Use tmp intermediate. Compiler sometimes weird otherwise.
|
||||||
tmp<PointFieldType> tfield = pInterp.interpolate(vfield);
|
tmp<PointFieldType> tfield = pInterp.interpolate(vfield);
|
||||||
const PointFieldType& pfield = tfield();
|
const auto& pfield = tfield();
|
||||||
|
|
||||||
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
const labelList& addPointCellLabels = vtuCells_.addPointCellLabels();
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -39,8 +39,10 @@ Note
|
|||||||
In the future, the duplicate points at processor connections
|
In the future, the duplicate points at processor connections
|
||||||
may be addressed using ghost points.
|
may be addressed using ghost points.
|
||||||
|
|
||||||
|
See Also
|
||||||
|
Foam::vtk::patchMeshWriter
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
foamVtkPatchWriter.C
|
|
||||||
foamVtkPatchWriterTemplates.C
|
foamVtkPatchWriterTemplates.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -48,7 +50,7 @@ SourceFiles
|
|||||||
#ifndef foamVtkPatchWriter_H
|
#ifndef foamVtkPatchWriter_H
|
||||||
#define foamVtkPatchWriter_H
|
#define foamVtkPatchWriter_H
|
||||||
|
|
||||||
#include "foamVtkFileWriter.H"
|
#include "foamVtkPatchMeshWriter.H"
|
||||||
#include "volFields.H"
|
#include "volFields.H"
|
||||||
#include "pointFields.H"
|
#include "pointFields.H"
|
||||||
#include "PrimitivePatchInterpolation.H"
|
#include "PrimitivePatchInterpolation.H"
|
||||||
@ -66,53 +68,16 @@ namespace vtk
|
|||||||
|
|
||||||
class patchWriter
|
class patchWriter
|
||||||
:
|
:
|
||||||
public vtk::fileWriter
|
public vtk::patchMeshWriter
|
||||||
{
|
{
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
//- Reference to the OpenFOAM mesh (or subset)
|
|
||||||
const fvMesh& mesh_;
|
|
||||||
|
|
||||||
//- The selected patch ids
|
|
||||||
labelList patchIDs_;
|
|
||||||
|
|
||||||
//- Use internal field value instead of patch value
|
//- Use internal field value instead of patch value
|
||||||
bool useNearCellValue_;
|
bool useNearCellValue_;
|
||||||
|
|
||||||
//- The number of field points for the current Piece
|
|
||||||
label numberOfPoints_;
|
|
||||||
|
|
||||||
//- The number of field cells (faces) for the current Piece
|
|
||||||
label numberOfCells_;
|
|
||||||
|
|
||||||
//- Local number of points
|
|
||||||
label nLocalPoints_;
|
|
||||||
|
|
||||||
//- Local number of faces
|
|
||||||
label nLocalFaces_;
|
|
||||||
|
|
||||||
//- Local face vertices (connectivity) count. Sum of face sizes.
|
|
||||||
label nLocalVerts_;
|
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Determine sizes (nLocalPoints_, nLocalFaces_, nLocalVerts_),
|
|
||||||
//- and begin piece.
|
|
||||||
void beginPiece();
|
|
||||||
|
|
||||||
//- Write patch points
|
|
||||||
void writePoints();
|
|
||||||
|
|
||||||
//- Write patch faces, legacy format
|
|
||||||
// \param pointOffset processor-local point offset
|
|
||||||
void writePolysLegacy(const label pointOffset);
|
|
||||||
|
|
||||||
//- Write patch faces
|
|
||||||
// \param pointOffset processor-local point offset
|
|
||||||
void writePolys(const label pointOffset);
|
|
||||||
|
|
||||||
|
|
||||||
//- No copy construct
|
//- No copy construct
|
||||||
patchWriter(const patchWriter&) = delete;
|
patchWriter(const patchWriter&) = delete;
|
||||||
|
|
||||||
@ -125,50 +90,68 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from components (default format INLINE_BASE64)
|
//- Construct from components (default format INLINE_BASE64)
|
||||||
|
//
|
||||||
// \param useNearCellValue to use cell instead of patch values
|
// \param useNearCellValue to use cell instead of patch values
|
||||||
patchWriter
|
patchWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& patchIDs,
|
const labelList& patchIDs,
|
||||||
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64,
|
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64,
|
||||||
const bool useNearCellValue = false
|
const bool useNearCellValue = false
|
||||||
);
|
)
|
||||||
|
:
|
||||||
|
vtk::patchMeshWriter(mesh, patchIDs, opts),
|
||||||
|
useNearCellValue_(useNearCellValue)
|
||||||
|
{}
|
||||||
|
|
||||||
//- Construct from components (default format INLINE_BASE64),
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
//- and open the file for writing.
|
//- and open the file for writing.
|
||||||
// The file name is with/without an extension.
|
// The file name is with/without an extension.
|
||||||
patchWriter
|
patchWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& patchIDs,
|
const labelList& patchIDs,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel = Pstream::parRun()
|
bool parallel = Pstream::parRun()
|
||||||
);
|
)
|
||||||
|
:
|
||||||
|
vtk::patchMeshWriter(mesh, patchIDs, file, parallel),
|
||||||
|
useNearCellValue_(false)
|
||||||
|
{}
|
||||||
|
|
||||||
//- Construct from components (default format INLINE_BASE64),
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
//- Construct from components and open the file for writing.
|
//- and open the file for writing.
|
||||||
// The file name is with/without an extension.
|
// The file name is with/without an extension.
|
||||||
patchWriter
|
patchWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& patchIDs,
|
const labelList& patchIDs,
|
||||||
const vtk::outputOptions opts,
|
const vtk::outputOptions opts,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel = Pstream::parRun()
|
bool parallel = Pstream::parRun()
|
||||||
);
|
)
|
||||||
|
:
|
||||||
|
vtk::patchMeshWriter(mesh, patchIDs, opts, file, parallel),
|
||||||
|
useNearCellValue_(false)
|
||||||
|
{}
|
||||||
|
|
||||||
//- Construct from components and open the file for writing.
|
//- Construct from components and open the file for writing.
|
||||||
// The file name is with/without an extension.
|
// The file name is with/without an extension.
|
||||||
|
//
|
||||||
// \param useNearCellValue to use cell instead of patch values
|
// \param useNearCellValue to use cell instead of patch values
|
||||||
patchWriter
|
patchWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& patchIDs,
|
const labelList& patchIDs,
|
||||||
const vtk::outputOptions opts,
|
const vtk::outputOptions opts,
|
||||||
const bool useNearCellValue,
|
const bool useNearCellValue,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel = Pstream::parRun()
|
bool parallel = Pstream::parRun()
|
||||||
);
|
)
|
||||||
|
:
|
||||||
|
vtk::patchMeshWriter(mesh, patchIDs, opts, file, parallel),
|
||||||
|
useNearCellValue_(useNearCellValue)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
@ -177,68 +160,8 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- File extension for current format type.
|
|
||||||
using vtk::fileWriter::ext;
|
|
||||||
|
|
||||||
//- File extension for given output type
|
|
||||||
inline static word ext(vtk::outputOptions opts)
|
|
||||||
{
|
|
||||||
return opts.ext(vtk::fileTag::POLY_DATA);
|
|
||||||
}
|
|
||||||
|
|
||||||
//- The patch IDs
|
|
||||||
inline const labelList& patchIDs() const
|
|
||||||
{
|
|
||||||
return patchIDs_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Write file header (non-collective)
|
|
||||||
// \note Expected calling states: (OPENED).
|
|
||||||
virtual bool beginFile(std::string title = "");
|
|
||||||
|
|
||||||
//- Write patch topology
|
|
||||||
// Also writes the file header if not previously written.
|
|
||||||
// \note Must be called prior to writing CellData or PointData
|
|
||||||
virtual bool writeGeometry();
|
|
||||||
|
|
||||||
//- Begin CellData output section for specified number of fields.
|
|
||||||
// Must be called prior to writing any cell data fields.
|
|
||||||
// \param nFields is for legacy format only.
|
|
||||||
// When nFields=0, this a no-op for legacy format.
|
|
||||||
// \note Expected calling states: (PIECE | POINT_DATA).
|
|
||||||
//
|
|
||||||
// \return True if the state changed
|
|
||||||
virtual bool beginCellData(label nFields = 0);
|
|
||||||
|
|
||||||
//- Begin PointData for specified number of fields.
|
|
||||||
// Must be called prior to writing any point data fields.
|
|
||||||
// \param nFields is for legacy format only.
|
|
||||||
// When nFields=0, this a no-op for legacy format.
|
|
||||||
// \note Expected calling states: (PIECE | CELL_DATA).
|
|
||||||
//
|
|
||||||
// \return True if the state changed
|
|
||||||
virtual bool beginPointData(label nFields = 0);
|
|
||||||
|
|
||||||
|
|
||||||
//- Write patch ids as CellData.
|
|
||||||
// Must be called within the CELL_DATA state.
|
|
||||||
void writePatchIDs();
|
|
||||||
|
|
||||||
//- Write processor ids as CellData. This is no-op in serial.
|
|
||||||
// Must be called within the CELL_DATA state.
|
|
||||||
bool writeProcIDs();
|
|
||||||
|
|
||||||
//- Write processor neighbour ids as CellData. This is no-op in serial.
|
|
||||||
// Must be called within the CELL_DATA state.
|
|
||||||
bool writeNeighIDs();
|
|
||||||
|
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
//- Write a uniform field of Cell (Face) or Point values
|
|
||||||
template<class Type>
|
|
||||||
void writeUniform(const word& fieldName, const Type& val);
|
|
||||||
|
|
||||||
//- Write point field
|
//- Write point field
|
||||||
template<class Type, template<class> class PatchField>
|
template<class Type, template<class> class PatchField>
|
||||||
void write
|
void write
|
||||||
@ -282,7 +205,6 @@ public:
|
|||||||
#include "foamVtkPatchWriterTemplates.C"
|
#include "foamVtkPatchWriterTemplates.C"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -30,33 +30,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::vtk::patchWriter::writeUniform
|
|
||||||
(
|
|
||||||
const word& fieldName,
|
|
||||||
const Type& val
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (isState(outputState::CELL_DATA))
|
|
||||||
{
|
|
||||||
++nCellData_;
|
|
||||||
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfCells_);
|
|
||||||
}
|
|
||||||
else if (isState(outputState::POINT_DATA))
|
|
||||||
{
|
|
||||||
++nPointData_;
|
|
||||||
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfPoints_);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WarningInFunction
|
|
||||||
<< "Ignore bad writer state (" << stateNames[state_]
|
|
||||||
<< ") for field " << fieldName << nl << endl
|
|
||||||
<< exit(FatalError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField>
|
template<class Type, template<class> class PatchField>
|
||||||
void Foam::vtk::patchWriter::write
|
void Foam::vtk::patchWriter::write
|
||||||
(
|
(
|
||||||
|
|||||||
@ -302,6 +302,8 @@ PatchFunction1/CodedField/makeCodedFields.C
|
|||||||
meshStructure/meshStructure.C
|
meshStructure/meshStructure.C
|
||||||
|
|
||||||
output/foamVtkIndPatchWriter.C
|
output/foamVtkIndPatchWriter.C
|
||||||
|
output/foamVtkInternalMeshWriter.C
|
||||||
|
output/foamVtkPatchMeshWriter.C
|
||||||
output/foamVtkWriteTopoSet.C
|
output/foamVtkWriteTopoSet.C
|
||||||
output/foamVtkWriteFaceSet.C
|
output/foamVtkWriteFaceSet.C
|
||||||
output/foamVtkWritePointSet.C
|
output/foamVtkWritePointSet.C
|
||||||
|
|||||||
@ -118,7 +118,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from patch (default output INLINE_BASE64)
|
//- Construct from patch (default output INLINE_BASE64)
|
||||||
indirectPatchWriter
|
explicit indirectPatchWriter
|
||||||
(
|
(
|
||||||
const indirectPrimitivePatch& pp,
|
const indirectPrimitivePatch& pp,
|
||||||
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
|
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,17 +25,18 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "foamVtkInternalWriter.H"
|
#include "foamVtkInternalMeshWriter.H"
|
||||||
#include "globalIndex.H"
|
#include "globalIndex.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
int Foam::vtk::internalWriter::debug = 0;
|
int Foam::vtk::internalMeshWriter::debug = 0;
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::vtk::internalWriter::beginPiece()
|
void Foam::vtk::internalMeshWriter::beginPiece()
|
||||||
{
|
{
|
||||||
// Basic sizes
|
// Basic sizes
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ void Foam::vtk::internalWriter::beginPiece()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::internalWriter::writePoints()
|
void Foam::vtk::internalMeshWriter::writePoints()
|
||||||
{
|
{
|
||||||
if (format_)
|
if (format_)
|
||||||
{
|
{
|
||||||
@ -125,7 +126,7 @@ void Foam::vtk::internalWriter::writePoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::internalWriter::writeCellsLegacy(const label pointOffset)
|
void Foam::vtk::internalMeshWriter::writeCellsLegacy(const label pointOffset)
|
||||||
{
|
{
|
||||||
const List<uint8_t>& cellTypes = vtuCells_.cellTypes();
|
const List<uint8_t>& cellTypes = vtuCells_.cellTypes();
|
||||||
const labelList& vertLabels = vtuCells_.vertLabels();
|
const labelList& vertLabels = vtuCells_.vertLabels();
|
||||||
@ -205,7 +206,7 @@ void Foam::vtk::internalWriter::writeCellsLegacy(const label pointOffset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::internalWriter::writeCellsConnectivity(const label pointOffset)
|
void Foam::vtk::internalMeshWriter::writeCellsConnectivity(const label pointOffset)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// 'connectivity'
|
// 'connectivity'
|
||||||
@ -343,7 +344,7 @@ void Foam::vtk::internalWriter::writeCellsConnectivity(const label pointOffset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::internalWriter::writeCellsFaces(const label pointOffset)
|
void Foam::vtk::internalMeshWriter::writeCellsFaces(const label pointOffset)
|
||||||
{
|
{
|
||||||
label nFaceLabels = vtuCells_.faceLabels().size();
|
label nFaceLabels = vtuCells_.faceLabels().size();
|
||||||
|
|
||||||
@ -476,9 +477,9 @@ void Foam::vtk::internalWriter::writeCellsFaces(const label pointOffset)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::vtk::internalWriter::internalWriter
|
Foam::vtk::internalMeshWriter::internalMeshWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const vtk::vtuCells& cells,
|
const vtk::vtuCells& cells,
|
||||||
const vtk::outputOptions opts
|
const vtk::outputOptions opts
|
||||||
)
|
)
|
||||||
@ -494,30 +495,30 @@ Foam::vtk::internalWriter::internalWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::vtk::internalWriter::internalWriter
|
Foam::vtk::internalMeshWriter::internalMeshWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const vtk::vtuCells& cells,
|
const vtk::vtuCells& cells,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel
|
bool parallel
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
internalWriter(mesh, cells)
|
internalMeshWriter(mesh, cells)
|
||||||
{
|
{
|
||||||
open(file, parallel);
|
open(file, parallel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::vtk::internalWriter::internalWriter
|
Foam::vtk::internalMeshWriter::internalMeshWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const vtk::vtuCells& cells,
|
const vtk::vtuCells& cells,
|
||||||
const vtk::outputOptions opts,
|
const vtk::outputOptions opts,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel
|
bool parallel
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
internalWriter(mesh, cells, opts)
|
internalMeshWriter(mesh, cells, opts)
|
||||||
{
|
{
|
||||||
open(file, parallel);
|
open(file, parallel);
|
||||||
}
|
}
|
||||||
@ -525,7 +526,7 @@ Foam::vtk::internalWriter::internalWriter
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::vtk::internalWriter::beginFile(std::string title)
|
bool Foam::vtk::internalMeshWriter::beginFile(std::string title)
|
||||||
{
|
{
|
||||||
if (title.size())
|
if (title.size())
|
||||||
{
|
{
|
||||||
@ -563,7 +564,7 @@ bool Foam::vtk::internalWriter::beginFile(std::string title)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::internalWriter::writeGeometry()
|
bool Foam::vtk::internalMeshWriter::writeGeometry()
|
||||||
{
|
{
|
||||||
enter_Piece();
|
enter_Piece();
|
||||||
|
|
||||||
@ -600,19 +601,19 @@ bool Foam::vtk::internalWriter::writeGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::internalWriter::beginCellData(label nFields)
|
bool Foam::vtk::internalMeshWriter::beginCellData(label nFields)
|
||||||
{
|
{
|
||||||
return enter_CellData(numberOfCells_, nFields);
|
return enter_CellData(numberOfCells_, nFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::internalWriter::beginPointData(label nFields)
|
bool Foam::vtk::internalMeshWriter::beginPointData(label nFields)
|
||||||
{
|
{
|
||||||
return enter_PointData(numberOfPoints_, nFields);
|
return enter_PointData(numberOfPoints_, nFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::internalWriter::writeCellIDs()
|
void Foam::vtk::internalMeshWriter::writeCellIDs()
|
||||||
{
|
{
|
||||||
if (isState(outputState::CELL_DATA))
|
if (isState(outputState::CELL_DATA))
|
||||||
{
|
{
|
||||||
@ -665,7 +666,7 @@ void Foam::vtk::internalWriter::writeCellIDs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::internalWriter::writeProcIDs()
|
bool Foam::vtk::internalMeshWriter::writeProcIDs()
|
||||||
{
|
{
|
||||||
if (!parallel_)
|
if (!parallel_)
|
||||||
{
|
{
|
||||||
@ -727,7 +728,7 @@ bool Foam::vtk::internalWriter::writeProcIDs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::internalWriter::writePointIDs()
|
void Foam::vtk::internalMeshWriter::writePointIDs()
|
||||||
{
|
{
|
||||||
if (isState(outputState::POINT_DATA))
|
if (isState(outputState::POINT_DATA))
|
||||||
{
|
{
|
||||||
246
src/meshTools/output/foamVtkInternalMeshWriter.H
Normal file
246
src/meshTools/output/foamVtkInternalMeshWriter.H
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::vtk::internalMeshWriter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Write an OpenFOAM volume (internal) geometry and internal fields
|
||||||
|
as a vtu file or a legacy vtk file.
|
||||||
|
|
||||||
|
The file output states are managed by the Foam::vtk::fileWriter class.
|
||||||
|
FieldData (eg, TimeValue) must appear before any geometry pieces.
|
||||||
|
|
||||||
|
Note
|
||||||
|
Parallel output is combined into a single Piece without point merging,
|
||||||
|
which is similar to using multi-piece data sets, but allows more
|
||||||
|
convenient creation as a streaming process.
|
||||||
|
In the future, the duplicate points at processor connections
|
||||||
|
may be addressed using ghost points.
|
||||||
|
|
||||||
|
See Also
|
||||||
|
Foam::vtk::internalWriter
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkInternalMeshWriter.C
|
||||||
|
foamVtkInternalMeshWriterTemplates.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkInternalMeshWriter_H
|
||||||
|
#define foamVtkInternalMeshWriter_H
|
||||||
|
|
||||||
|
#include "foamVtkFileWriter.H"
|
||||||
|
#include "foamVtuCells.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace vtk
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class vtk::internalMeshWriter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class internalMeshWriter
|
||||||
|
:
|
||||||
|
public vtk::fileWriter
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
|
//- Reference to the OpenFOAM mesh (or subset)
|
||||||
|
const polyMesh& mesh_;
|
||||||
|
|
||||||
|
//- The volume cells (internalMesh)
|
||||||
|
const vtuCells& vtuCells_;
|
||||||
|
|
||||||
|
//- The number of field points for the current Piece
|
||||||
|
label numberOfPoints_;
|
||||||
|
|
||||||
|
//- The number of field cells for the current Piece
|
||||||
|
label numberOfCells_;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Begin piece
|
||||||
|
void beginPiece();
|
||||||
|
|
||||||
|
//- Write mesh points
|
||||||
|
void writePoints();
|
||||||
|
|
||||||
|
//- Write cells (connectivity and type), legacy format
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writeCellsLegacy(const label pointOffset);
|
||||||
|
|
||||||
|
//- Write cells connectivity
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writeCellsConnectivity(const label pointOffset);
|
||||||
|
|
||||||
|
//- Write cells face streams
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writeCellsFaces(const label pointOffset);
|
||||||
|
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
internalMeshWriter(const internalMeshWriter&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const internalMeshWriter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Debug information
|
||||||
|
static int debug;
|
||||||
|
|
||||||
|
//- File extension for given output type
|
||||||
|
// constexpr static vtk::fileTag content = vtk::fileTag::UNSTRUCTURED_GRID;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
|
internalMeshWriter
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vtk::vtuCells& cells,
|
||||||
|
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
|
// The file name is with/without an extension.
|
||||||
|
internalMeshWriter
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vtk::vtuCells& cells,
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel = Pstream::parRun()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
|
// The file name is with/without an extension.
|
||||||
|
internalMeshWriter
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const vtk::vtuCells& cells,
|
||||||
|
const vtk::outputOptions opts,
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel = Pstream::parRun()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~internalMeshWriter() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- File extension for current format type.
|
||||||
|
using vtk::fileWriter::ext;
|
||||||
|
|
||||||
|
//- File extension for given output type
|
||||||
|
inline static word ext(vtk::outputOptions opts)
|
||||||
|
{
|
||||||
|
return opts.ext(vtk::fileTag::UNSTRUCTURED_GRID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Write file header (non-collective)
|
||||||
|
// \note Expected calling states: (OPENED)
|
||||||
|
virtual bool beginFile(std::string title = "");
|
||||||
|
|
||||||
|
//- Write mesh topology.
|
||||||
|
// Also writes the file header if not previously written.
|
||||||
|
// \note Must be called prior to writing CellData or PointData
|
||||||
|
virtual bool writeGeometry();
|
||||||
|
|
||||||
|
//- Begin CellData output section for specified number of fields.
|
||||||
|
// Must be called prior to writing any cell data fields.
|
||||||
|
// \param nFields is for legacy format only.
|
||||||
|
// When nFields=0, this a no-op for legacy format.
|
||||||
|
// \note Expected calling states: (PIECE | POINT_DATA).
|
||||||
|
//
|
||||||
|
// \return True if the state changed
|
||||||
|
virtual bool beginCellData(label nFields = 0);
|
||||||
|
|
||||||
|
//- Begin PointData for specified number of fields.
|
||||||
|
// Must be called prior to writing any point data fields.
|
||||||
|
// \param nFields is for legacy format only.
|
||||||
|
// When nFields=0, this a no-op for legacy format.
|
||||||
|
// \note Expected calling states: (PIECE | CELL_DATA).
|
||||||
|
//
|
||||||
|
// \return True if the state changed
|
||||||
|
virtual bool beginPointData(label nFields = 0);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write cell ids as CellData.
|
||||||
|
// Must be called within the CELL_DATA state.
|
||||||
|
void writeCellIDs();
|
||||||
|
|
||||||
|
//- Write processor ids as CellData. This is no-op in serial.
|
||||||
|
// Must be called within the CELL_DATA state.
|
||||||
|
bool writeProcIDs();
|
||||||
|
|
||||||
|
//- Write point ids as PointData.
|
||||||
|
// Must be called within the POINT_DATA state.
|
||||||
|
void writePointIDs();
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- Write a uniform field of Cell or Point values
|
||||||
|
template<class Type>
|
||||||
|
void writeUniform(const word& fieldName, const Type& val);
|
||||||
|
|
||||||
|
//- Write primitive field of CellData
|
||||||
|
template<class Type>
|
||||||
|
void writeCellData(const word& fieldName, const UList<Type>& field);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace vtk
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamVtkInternalMeshWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
117
src/meshTools/output/foamVtkInternalMeshWriterTemplates.C
Normal file
117
src/meshTools/output/foamVtkInternalMeshWriterTemplates.C
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "foamVtkInternalMeshWriter.H"
|
||||||
|
#include "foamVtkOutput.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtk::internalMeshWriter::writeUniform
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const Type& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (isState(outputState::CELL_DATA))
|
||||||
|
{
|
||||||
|
++nCellData_;
|
||||||
|
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfCells_);
|
||||||
|
}
|
||||||
|
else if (isState(outputState::POINT_DATA))
|
||||||
|
{
|
||||||
|
++nPointData_;
|
||||||
|
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfPoints_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Ignore bad writer state (" << stateNames[state_]
|
||||||
|
<< ") for field " << fieldName << nl << endl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtk::internalMeshWriter::writeCellData
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const UList<Type>& field
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (isState(outputState::CELL_DATA))
|
||||||
|
{
|
||||||
|
++nCellData_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Bad writer state (" << stateNames[state_]
|
||||||
|
<< ") - should be (" << stateNames[outputState::CELL_DATA]
|
||||||
|
<< ") for field " << fieldName << nl << endl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
const direction nCmpt(pTraits<Type>::nComponents);
|
||||||
|
|
||||||
|
const labelList& cellMap = vtuCells_.cellMap();
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
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_)
|
||||||
|
{
|
||||||
|
vtk::writeListParallel(format_.ref(), field, cellMap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vtk::writeList(format(), field, cellMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format_)
|
||||||
|
{
|
||||||
|
format().flush();
|
||||||
|
format().endDataArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016-2019 OpenCFD Ltd.
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -25,13 +25,15 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "foamVtkPatchWriter.H"
|
#include "foamVtkPatchMeshWriter.H"
|
||||||
#include "foamVtkOutput.H"
|
#include "foamVtkOutput.H"
|
||||||
#include "globalIndex.H"
|
#include "globalIndex.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "processorPolyPatch.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::vtk::patchWriter::beginPiece()
|
void Foam::vtk::patchMeshWriter::beginPiece()
|
||||||
{
|
{
|
||||||
// Basic sizes
|
// Basic sizes
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
@ -78,7 +80,7 @@ void Foam::vtk::patchWriter::beginPiece()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::patchWriter::writePoints()
|
void Foam::vtk::patchMeshWriter::writePoints()
|
||||||
{
|
{
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
@ -173,7 +175,7 @@ void Foam::vtk::patchWriter::writePoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::patchWriter::writePolysLegacy(const label pointOffset)
|
void Foam::vtk::patchMeshWriter::writePolysLegacy(const label pointOffset)
|
||||||
{
|
{
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
@ -244,7 +246,7 @@ void Foam::vtk::patchWriter::writePolysLegacy(const label pointOffset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::patchWriter::writePolys(const label pointOffset)
|
void Foam::vtk::patchMeshWriter::writePolys(const label pointOffset)
|
||||||
{
|
{
|
||||||
if (format_)
|
if (format_)
|
||||||
{
|
{
|
||||||
@ -387,18 +389,16 @@ void Foam::vtk::patchWriter::writePolys(const label pointOffset)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::vtk::patchWriter::patchWriter
|
Foam::vtk::patchMeshWriter::patchMeshWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& patchIDs,
|
const labelList& patchIDs,
|
||||||
const vtk::outputOptions opts,
|
const vtk::outputOptions opts
|
||||||
const bool useNearCellValue
|
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
vtk::fileWriter(vtk::fileTag::POLY_DATA, opts),
|
vtk::fileWriter(vtk::fileTag::POLY_DATA, opts),
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
patchIDs_(patchIDs),
|
patchIDs_(patchIDs),
|
||||||
useNearCellValue_(useNearCellValue),
|
|
||||||
numberOfPoints_(0),
|
numberOfPoints_(0),
|
||||||
numberOfCells_(0),
|
numberOfCells_(0),
|
||||||
nLocalPoints_(0),
|
nLocalPoints_(0),
|
||||||
@ -410,46 +410,30 @@ Foam::vtk::patchWriter::patchWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::vtk::patchWriter::patchWriter
|
Foam::vtk::patchMeshWriter::patchMeshWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& patchIDs,
|
const labelList& patchIDs,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel
|
bool parallel
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
patchWriter(mesh, patchIDs)
|
patchMeshWriter(mesh, patchIDs)
|
||||||
{
|
{
|
||||||
open(file, parallel);
|
open(file, parallel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::vtk::patchWriter::patchWriter
|
Foam::vtk::patchMeshWriter::patchMeshWriter
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& patchIDs,
|
const labelList& patchIDs,
|
||||||
const vtk::outputOptions opts,
|
const vtk::outputOptions opts,
|
||||||
const fileName& file,
|
const fileName& file,
|
||||||
bool parallel
|
bool parallel
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
patchWriter(mesh, patchIDs, opts)
|
patchMeshWriter(mesh, patchIDs, opts)
|
||||||
{
|
|
||||||
open(file, parallel);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::vtk::patchWriter::patchWriter
|
|
||||||
(
|
|
||||||
const fvMesh& mesh,
|
|
||||||
const labelList& patchIDs,
|
|
||||||
const vtk::outputOptions opts,
|
|
||||||
const bool useNearCellValue,
|
|
||||||
const fileName& file,
|
|
||||||
bool parallel
|
|
||||||
)
|
|
||||||
:
|
|
||||||
patchWriter(mesh, patchIDs, opts, useNearCellValue)
|
|
||||||
{
|
{
|
||||||
open(file, parallel);
|
open(file, parallel);
|
||||||
}
|
}
|
||||||
@ -457,7 +441,7 @@ Foam::vtk::patchWriter::patchWriter
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
bool Foam::vtk::patchWriter::beginFile(std::string title)
|
bool Foam::vtk::patchMeshWriter::beginFile(std::string title)
|
||||||
{
|
{
|
||||||
if (title.size())
|
if (title.size())
|
||||||
{
|
{
|
||||||
@ -507,7 +491,7 @@ bool Foam::vtk::patchWriter::beginFile(std::string title)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::patchWriter::writeGeometry()
|
bool Foam::vtk::patchMeshWriter::writeGeometry()
|
||||||
{
|
{
|
||||||
enter_Piece();
|
enter_Piece();
|
||||||
|
|
||||||
@ -533,19 +517,19 @@ bool Foam::vtk::patchWriter::writeGeometry()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::patchWriter::beginCellData(label nFields)
|
bool Foam::vtk::patchMeshWriter::beginCellData(label nFields)
|
||||||
{
|
{
|
||||||
return enter_CellData(numberOfCells_, nFields);
|
return enter_CellData(numberOfCells_, nFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::patchWriter::beginPointData(label nFields)
|
bool Foam::vtk::patchMeshWriter::beginPointData(label nFields)
|
||||||
{
|
{
|
||||||
return enter_PointData(numberOfPoints_, nFields);
|
return enter_PointData(numberOfPoints_, nFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::vtk::patchWriter::writePatchIDs()
|
void Foam::vtk::patchMeshWriter::writePatchIDs()
|
||||||
{
|
{
|
||||||
if (isState(outputState::CELL_DATA))
|
if (isState(outputState::CELL_DATA))
|
||||||
{
|
{
|
||||||
@ -656,7 +640,7 @@ void Foam::vtk::patchWriter::writePatchIDs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::patchWriter::writeProcIDs()
|
bool Foam::vtk::patchMeshWriter::writeProcIDs()
|
||||||
{
|
{
|
||||||
// This is different than for internalWriter.
|
// This is different than for internalWriter.
|
||||||
// Here we allow procIDs whenever running in parallel, even if the
|
// Here we allow procIDs whenever running in parallel, even if the
|
||||||
@ -740,7 +724,7 @@ bool Foam::vtk::patchWriter::writeProcIDs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::vtk::patchWriter::writeNeighIDs()
|
bool Foam::vtk::patchMeshWriter::writeNeighIDs()
|
||||||
{
|
{
|
||||||
if (!Pstream::parRun())
|
if (!Pstream::parRun())
|
||||||
{
|
{
|
||||||
246
src/meshTools/output/foamVtkPatchMeshWriter.H
Normal file
246
src/meshTools/output/foamVtkPatchMeshWriter.H
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::vtk::patchMeshWriter
|
||||||
|
|
||||||
|
Description
|
||||||
|
Write OpenFOAM patches and patch fields in VTP or legacy vtk format.
|
||||||
|
|
||||||
|
The file output states are managed by the Foam::vtk::fileWriter class.
|
||||||
|
FieldData (eg, TimeValue) must appear before any geometry pieces.
|
||||||
|
|
||||||
|
Note
|
||||||
|
Parallel output is combined into a single Piece without point merging,
|
||||||
|
which is similar to using multi-piece data sets, but allows more
|
||||||
|
convenient creation as a streaming process.
|
||||||
|
In the future, the duplicate points at processor connections
|
||||||
|
may be addressed using ghost points.
|
||||||
|
|
||||||
|
See Also
|
||||||
|
Foam::vtk::patchWriter
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
foamVtkPatchMeshWriter.C
|
||||||
|
foamVtkPatchMeshWriterTemplates.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef foamVtkPatchMeshWriter_H
|
||||||
|
#define foamVtkPatchMeshWriter_H
|
||||||
|
|
||||||
|
#include "foamVtkFileWriter.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace vtk
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class vtk::patchMeshWriter Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class patchMeshWriter
|
||||||
|
:
|
||||||
|
public vtk::fileWriter
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Data
|
||||||
|
|
||||||
|
//- Reference to the OpenFOAM mesh (or subset)
|
||||||
|
const polyMesh& mesh_;
|
||||||
|
|
||||||
|
//- The selected patch ids
|
||||||
|
labelList patchIDs_;
|
||||||
|
|
||||||
|
//- The number of field points for the current Piece
|
||||||
|
label numberOfPoints_;
|
||||||
|
|
||||||
|
//- The number of field cells (faces) for the current Piece
|
||||||
|
label numberOfCells_;
|
||||||
|
|
||||||
|
//- Local number of points
|
||||||
|
label nLocalPoints_;
|
||||||
|
|
||||||
|
//- Local number of faces
|
||||||
|
label nLocalFaces_;
|
||||||
|
|
||||||
|
//- Local face vertices (connectivity) count. Sum of face sizes.
|
||||||
|
label nLocalVerts_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Determine sizes (nLocalPoints_, nLocalFaces_, nLocalVerts_),
|
||||||
|
//- and begin piece.
|
||||||
|
void beginPiece();
|
||||||
|
|
||||||
|
//- Write patch points
|
||||||
|
void writePoints();
|
||||||
|
|
||||||
|
//- Write patch faces, legacy format
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writePolysLegacy(const label pointOffset);
|
||||||
|
|
||||||
|
//- Write patch faces
|
||||||
|
// \param pointOffset processor-local point offset
|
||||||
|
void writePolys(const label pointOffset);
|
||||||
|
|
||||||
|
|
||||||
|
//- No copy construct
|
||||||
|
patchMeshWriter(const patchMeshWriter&) = delete;
|
||||||
|
|
||||||
|
//- No copy assignment
|
||||||
|
void operator=(const patchMeshWriter&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64)
|
||||||
|
// \param useNearCellValue to use cell instead of patch values
|
||||||
|
patchMeshWriter
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const labelList& patchIDs,
|
||||||
|
const vtk::outputOptions opts = vtk::formatType::INLINE_BASE64
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
|
//- and open the file for writing.
|
||||||
|
// The file name is with/without an extension.
|
||||||
|
patchMeshWriter
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const labelList& patchIDs,
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel = Pstream::parRun()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from components (default format INLINE_BASE64),
|
||||||
|
//- Construct from components and open the file for writing.
|
||||||
|
// The file name is with/without an extension.
|
||||||
|
patchMeshWriter
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const labelList& patchIDs,
|
||||||
|
const vtk::outputOptions opts,
|
||||||
|
const fileName& file,
|
||||||
|
bool parallel = Pstream::parRun()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~patchMeshWriter() = default;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- File extension for current format type.
|
||||||
|
using vtk::fileWriter::ext;
|
||||||
|
|
||||||
|
//- File extension for given output type
|
||||||
|
inline static word ext(vtk::outputOptions opts)
|
||||||
|
{
|
||||||
|
return opts.ext(vtk::fileTag::POLY_DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- The patch IDs
|
||||||
|
inline const labelList& patchIDs() const
|
||||||
|
{
|
||||||
|
return patchIDs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Write file header (non-collective)
|
||||||
|
// \note Expected calling states: (OPENED).
|
||||||
|
virtual bool beginFile(std::string title = "");
|
||||||
|
|
||||||
|
//- Write patch topology
|
||||||
|
// Also writes the file header if not previously written.
|
||||||
|
// \note Must be called prior to writing CellData or PointData
|
||||||
|
virtual bool writeGeometry();
|
||||||
|
|
||||||
|
//- Begin CellData output section for specified number of fields.
|
||||||
|
// Must be called prior to writing any cell data fields.
|
||||||
|
// \param nFields is for legacy format only.
|
||||||
|
// When nFields=0, this a no-op for legacy format.
|
||||||
|
// \note Expected calling states: (PIECE | POINT_DATA).
|
||||||
|
//
|
||||||
|
// \return True if the state changed
|
||||||
|
virtual bool beginCellData(label nFields = 0);
|
||||||
|
|
||||||
|
//- Begin PointData for specified number of fields.
|
||||||
|
// Must be called prior to writing any point data fields.
|
||||||
|
// \param nFields is for legacy format only.
|
||||||
|
// When nFields=0, this a no-op for legacy format.
|
||||||
|
// \note Expected calling states: (PIECE | CELL_DATA).
|
||||||
|
//
|
||||||
|
// \return True if the state changed
|
||||||
|
virtual bool beginPointData(label nFields = 0);
|
||||||
|
|
||||||
|
|
||||||
|
//- Write patch ids as CellData.
|
||||||
|
// Must be called within the CELL_DATA state.
|
||||||
|
void writePatchIDs();
|
||||||
|
|
||||||
|
//- Write processor ids as CellData. This is no-op in serial.
|
||||||
|
// Must be called within the CELL_DATA state.
|
||||||
|
bool writeProcIDs();
|
||||||
|
|
||||||
|
//- Write processor neighbour ids as CellData. This is no-op in serial.
|
||||||
|
// Must be called within the CELL_DATA state.
|
||||||
|
bool writeNeighIDs();
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- Write a uniform field of Cell (Face) or Point values
|
||||||
|
template<class Type>
|
||||||
|
void writeUniform(const word& fieldName, const Type& val);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace vtk
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "foamVtkPatchMeshWriterTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
60
src/meshTools/output/foamVtkPatchMeshWriterTemplates.C
Normal file
60
src/meshTools/output/foamVtkPatchMeshWriterTemplates.C
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "foamVtkPatchMeshWriter.H"
|
||||||
|
#include "foamVtkOutput.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::vtk::patchMeshWriter::writeUniform
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const Type& val
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (isState(outputState::CELL_DATA))
|
||||||
|
{
|
||||||
|
++nCellData_;
|
||||||
|
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfCells_);
|
||||||
|
}
|
||||||
|
else if (isState(outputState::POINT_DATA))
|
||||||
|
{
|
||||||
|
++nPointData_;
|
||||||
|
vtk::fileWriter::writeUniform<Type>(fieldName, val, numberOfPoints_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningInFunction
|
||||||
|
<< "Ignore bad writer state (" << stateNames[state_]
|
||||||
|
<< ") for field " << fieldName << nl << endl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -49,7 +49,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declarations
|
// Forward Declarations
|
||||||
class polyMesh;
|
class polyMesh;
|
||||||
class topoSet;
|
class topoSet;
|
||||||
class faceSet;
|
class faceSet;
|
||||||
|
|||||||
Reference in New Issue
Block a user