Go to the documentation of this file.
39 { outputState::CLOSED,
"closed" },
40 { outputState::OPENED,
"opened" },
41 { outputState::DECLARED,
"declared" },
42 { outputState::FIELD_DATA,
"FieldData" },
43 { outputState::PIECE,
"Piece" },
44 { outputState::CELL_DATA,
"CellData" },
56 if (
isState(outputState::OPENED))
64 <<
") - should be (" <<
stateNames[outputState::DECLARED] <<
')'
85 state_ = outputState::DECLARED;
107 <<
"Bad writer state (" << stateNames[state_]
115 if (legacy() && !nFields)
return false;
146 <<
"Bad writer state (" << stateNames[state_]
154 if (legacy() && !nFields)
return false;
166 format().beginPointData();
180 if (isState(outputState::DECLARED))
182 if (format_ && !legacy())
184 format().endTag(contentType_).endVTKFile();
186 state_ = outputState::OPENED;
191 if (isState(outputState::CLOSED) || isState(outputState::OPENED))
197 <<
"Bad writer state (" << stateNames[state_]
198 <<
") - should be (" << stateNames[outputState::CLOSED]
199 <<
") or (" << stateNames[outputState::OPENED]
215 contentType_(contentType),
218 state_(outputState::CLOSED),
242 if (notState(outputState::CLOSED))
245 <<
"Bad writer state (" << stateNames[state_]
246 <<
") - should be (" << stateNames[outputState::CLOSED] <<
')'
255 nCellData_ = nPointData_ = 0;
270 if (!outputFile_.hasExt(ext()))
273 outputFile_.ext(ext());
289 mkDir(outputFile_.path());
291 os_.open(outputFile_);
293 format_ = opts_.newFormatter(os_);
296 state_ = outputState::OPENED;
311 state_ = outputState::CLOSED;
313 nCellData_ = nPointData_ = 0;
319 if (isState(outputState::DECLARED))
324 if (notState(outputState::OPENED))
327 <<
"Bad writer state (" << stateNames[state_]
328 <<
") - should be (" << stateNames[outputState::OPENED] <<
')'
331 state_ = outputState::DECLARED;
347 format().xmlComment(title);
350 format().beginVTKFile(contentType_);
361 if (legacy() && !nFields)
return false;
363 if (isState(outputState::OPENED))
367 if (notState(outputState::DECLARED))
370 <<
"Bad writer state (" << stateNames[state_]
371 <<
") - should be (" << stateNames[outputState::DECLARED] <<
')'
384 format().beginFieldData();
399 state_ = outputState::DECLARED;
401 if (format_ && !legacy())
419 if (format_ && !legacy())
437 if (format_ && !legacy())
449 if (isState(outputState::OPENED) || isState(outputState::DECLARED))
456 <<
"Bad writer state (" << stateNames[state_]
462 if (!format_)
return;
470 format().writeTimeValue(timeValue);
Encapsulated combinations of output format options. This is primarily useful when defining the output...
bool enter_Piece()
Trigger change state to Piece. Resets nCellData_, nPointData_.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
void close()
End the file contents and close the file after writing.
A class for handling file names.
const word fileExtension
Legacy file extension ("vtk")
bool enter_CellData(label nEntries, label nFields)
Trigger change state to CellData.
const Foam::Enum< fileTag > fileExtension
File extension (without ".") for some vtk XML file content types.
bool endCellData()
Explicitly end CellData output and switch to PIECE state.
void writeTimeValue(scalar timeValue)
Write "TimeValue" FieldData (name as per Catalyst output)
static bool & parRun()
Is this a parallel run?
bool beginFieldData(label nFields=0)
Begin FieldData output section for specified number of fields.
bool notState(outputState test) const
True if the output state does not correspond to the test state.
void beginPointData(vtk::formatter &fmt, label nPoints, label nFields)
Emit legacy POINT_DATA nPoints, FIELD FieldData nFields.
virtual bool beginFile(std::string title="")
Write file header (non-collective)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void beginFieldData(vtk::formatter &fmt, label nFields)
Emit legacy FIELD FieldData nFields.
static const Enum< outputState > stateNames
Names for the output state (for messages, not for file output).
label nPointData_
The number of PointData written for the Piece thus far.
outputState state_
The output state.
bool open(const fileName &file, bool parallel=Pstream::parRun())
Open file for writing (creates parent directory).
word format(conversionProperties.get< word >("format"))
fileWriter(const fileWriter &)=delete
No copy construct.
void writeTimeValue(vtk::formatter &fmt, scalar timeValue)
Emit "TimeValue" for a FIELD entry (name as per Catalyst output)
bool enter_PointData(label nEntries, label nFields)
Trigger change state to PointData.
bool removeExt()
Remove extension, returning true if string changed.
virtual ~fileWriter()
Destructor.
bool endPiece()
Explicitly end Piece output and switch to DECLARED state.
void fileHeader(std::ostream &os, const std::string &title, bool binary)
Emit header for legacy file.
bool endPointData()
Explicitly end PointData output and switch to PIECE state.
fileTag
Some common XML tags for vtk files.
const Foam::Enum< fileTag > fileTagNames
Strings corresponding to the vtk XML tags.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void beginCellData(vtk::formatter &fmt, label nCells, label nFields)
Emit legacy CELL_DATA nCells, FIELD FieldData nFields.
static bool master(const label communicator=0)
Am I the master process.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool exit_File()
Emit file footer (end data, end piece, end file)
label nCellData_
The number of CellData written for the Piece thus far.
outputState
Internal tracking of the output state.
bool endFieldData()
Explicitly end FieldData output and switch to DECLARED state.
bool isState(outputState test) const
True if the output state corresponds to the test state.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
#define WarningInFunction
Report a warning using Foam::Warning.