67 fmtType_(static_cast<unsigned>(
vtk::formatType::INLINE_BASE64)),
68 precision_(
IOstream::defaultPrecision()),
80 fmtType_(static_cast<unsigned>(opts.fmt())),
81 precision_(opts.precision()),
93 fmtType_(static_cast<unsigned>(
vtk::formatType::INLINE_BASE64)),
96 options.getOrDefault(
"precision",
IOstream::defaultPrecision())
98 writeNormal_(options.getOrDefault(
"normal", false)),
115 fmtType_ =
static_cast<unsigned>(opts.fmt());
129 open(surf, outputPath, parallel);
203 if (useTimeDir() && !
timeName().empty())
206 outputFile = outputPath_.
path() /
timeName() / outputPath_.name();
212 Info<<
"Writing geometry to " << outputFile <<
endl;
216 const meshedSurfRef& surf = adjustSurface();
222 new vtk::surfaceWriter
235 writer_->setTime(currTime_);
236 writer_->writeTimeValue();
241 writer_->beginFile(outputPath_.stem());
244 writer_->writeGeometry();
251 Field<vector> normals(fcs.size());
254 normals[facei] = fcs[facei].areaNormal(
pts);
259 if (!this->isPointData())
262 nCellData += nFields_;
265 writer_->beginCellData(nCellData);
266 writer_->write(
"area-normal", normals);
280 const word& fieldName,
290 tmp<Field<Type>> tfield = adjustField(fieldName, mergeField(localValues));
294 Info<<
" to " << outputFile <<
endl;
300 if (!nFields_ && writer_->legacy())
306 <<
"Using VTK legacy format, but did not define nFields!"
308 <<
"Assuming nFields=1 (may be incorrect) and continuing..."
310 <<
" Field " << fieldName <<
" to " << outputFile <<
nl;
316 if (this->isPointData())
318 writer_->beginPointData(nFields_);
322 writer_->beginCellData(nFields_);
325 writer_->write(fieldName, tfield());
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
@ ASCII
"ascii" (normal default)
static streamFormat formatEnum(const word &fmtName, const streamFormat deflt=streamFormat::ASCII)
Lookup streamFormat enum corresponding to the string (ascii | binary).
An IOstream is an abstract base class for all input/output systems; be they streams,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
bool wroteGeom_
Track if geometry has been written since the last open.
label nFields_
The number of fields.
bool verbose_
Additional output verbosity.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
A class for handling file names.
word ext() const
Return file name extension (part after last .).
static std::string path(const std::string &str)
Return directory path name (part before last /).
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Implements a meshed surface by referencing another meshed surface or faces/points components.
virtual const pointField & points() const
The points used for the surface.
virtual const faceList & faces() const
The faces used for the surface.
Abstract definition of a meshed surface defined by faces and points.
Base class for surface writers.
surfaceWriter()
Default construct.
virtual void open(const fileName &outputPath)
Open for output on specified path, using existing surface.
virtual void endTime()
End a time-step.
bool wroteGeom_
Track if geometry has been written since the last open.
bool useTimeDir() const noexcept
Should a time directory be spliced into the output path?
bool isPointData() const noexcept
Are the field data to be treated as point data?
void checkOpen() const
Verify that the outputPath_ has been set or FatalError.
virtual void beginTime(const Time &t)
Begin a time-step.
label nFields_
The number of fields.
virtual void close()
Finish output, performing any necessary cleanup.
bool parallel_
Writing in parallel (via master).
bool empty() const
The surface to write is empty if the global number of faces is zero.
virtual bool merge() const
Merge surfaces if they are not already upToDate (parallel) or simply mark the surface as being up-to-...
bool verbose_
Additional output verbosity.
virtual bool needsUpdate() const
Does the writer need an update (eg, lagging behind surface changes).
instant currTime_
The current time value/name.
const meshedSurfRef & adjustSurface() const
Merge surfaces (if not upToDate) and return merged (parallel) or regular surface (non-parallel) and a...
bool hasTime() const
True if there is a known time.
fileName outputPath_
The full output directory and file (surface) name.
A surfaceWriter for VTK legacy (.vtk) or XML (.vtp) format.
virtual void endTime()
End time step. Clears existing backend.
virtual void beginTime(const Time &t)
Begin time step. Clears existing backend.
virtual void close()
Finish output, clears backend.
vtkWriter()
Default construct.
virtual ~vtkWriter()
Destructor. Calls close().
virtual fileName write()
Write surface geometry to file.
A class for managing temporary objects.
word ext() const
File extension for current format type.
Encapsulated combinations of output format options. This is primarily useful when defining the output...
bool legacy() const noexcept
True if writer uses legacy file format.
vtk::formatType fmt() const noexcept
The output format type.
bool ascii() const noexcept
True if output format is ASCII.
Write faces/points (optionally with fields) as a vtp file or a legacy vtk file.
A class for handling words, derived from Foam::string.
#define defineTypeName(Type)
Define the typeName.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for surface writers.
Namespace for handling VTK output. Contains classes and functions for writing VTK file content.
formatType
The output format type for file contents.
@ INLINE_BASE64
XML inline base64, base64Formatter.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
Convenience macros for instantiating surfaceWriter methods.
#define defineSurfaceWriterWriteFields(ThisClass)