56 wordConstructorTablePtr_->found(writeType)
57 || wordDictConstructorTablePtr_->found(writeType)
66 const word& formatName,
78 const word& formatName,
90 auto* ctorPtr = wordConstructorTable(writeType);
104 <<
"Unknown write type \"" << writeType <<
"\"\n\n" 105 <<
"Valid write types : " 106 <<
flatOutput(wordConstructorTablePtr_->sortedToc()) <<
nl 107 <<
"Valid proxy types : " 119 const word& writeType,
125 auto* ctorPtr = wordDictConstructorTable(writeType);
135 auto* ctorPtr = wordConstructorTable(writeType);
142 return autoPtr<surfaceWriter>
144 new surfaceWriters::proxyWriter(writeType, writeOpts)
149 <<
"Unknown write type \"" << writeType <<
"\"\n\n" 150 <<
"Valid write types : " 151 << wordConstructorTablePtr_->sortedToc() <<
nl 152 <<
"Valid proxy types : " 168 mergeDim_(defaultMergeDim),
170 geometryCentre_(
Zero),
171 geometryTransform_(),
178 commType_(
UPstream::commsTypes::scheduled),
220 Info<<
"Create surfaceWriter (" 221 << (this->
isPointData() ?
"point" :
"face") <<
" data):" 245 currTime_ =
instant(timeValue);
251 currTime_.value() = timeValue;
258 currTime_.value() = 0;
259 currTime_.name().clear();
283 outputPath_ = outputPath;
296 setSurface(surf, parallel);
310 setSurface(
points, faces, parallel);
322 setSurface(surf, parallel_);
335 setSurface(
points, faces, parallel_);
375 surf_.reset(
points, faces);
385 setSurface(surf, parallel_);
395 setSurface(
points, faces, parallel_);
413 const bool changed = upToDate_;
417 adjustedSurf_.clear();
435 const bool value = surf_.faces().empty();
443 const label value = surf_.faces().size();
454 <<
type() <<
" : Attempted to write without a path" <<
nl 462 bool changed =
false;
467 adjustedSurf_.clear();
471 changed = mergedSurf_.merge(surf_, mergeDim_);
506 adjustedSurf_.
clear();
509 if (!adjustedSurf_.good())
511 adjustedSurf_.reset(
surface());
513 tmp<pointField> tpts;
515 if (geometryTransform_.good())
517 if (!geometryTransform_.R().is_identity())
519 if (
magSqr(geometryCentre_) > ROOTVSMALL)
524 geometryTransform_.globalPosition
526 adjustedSurf_.points0() - geometryCentre_
530 tpts.ref() += geometryCentre_;
536 geometryTransform_.globalPosition
538 adjustedSurf_.points0()
542 else if (
magSqr(geometryTransform_.origin()) > ROOTVSMALL)
545 tpts = (adjustedSurf_.points0() + geometryTransform_.origin());
549 adjustedSurf_.movePoints(tpts);
550 adjustedSurf_.scalePoints(geometryScale_);
553 return adjustedSurf_;
572 auto& allFld = tfield.ref();
579 ? mergedSurf_.pointGlobalIndex()
580 : mergedSurf_.faceGlobalIndex()
596 && this->isPointData()
597 && mergedSurf_.pointsMap().size()
601 allFld.resize(mergedSurf_.points().size());
617 const word& fieldName,
623 Info<<
"Writing field " << fieldName;
626 tmp<Field<Type>> tadjusted;
630 if (!std::is_integral<Type>::value)
652 Info<<
" [level " << refLevel <<
']';
658 tadjusted.reset(tfield.ptr());
662 tadjusted.ref() -= refLevel;
674 Info<<
" [scaling " << value <<
']';
680 tadjusted.reset(tfield.ptr());
684 tadjusted.ref() *= value;
691 && geometryTransform_.good()
692 && !geometryTransform_.R().is_identity()
698 tadjusted.reset(tfield.ptr());
704 geometryTransform_.R(),
710 return (tadjusted ? tadjusted : tfield);
714 #define defineSurfaceFieldMethods(ThisClass, Type) \ 715 Foam::tmp<Foam::Field<Type>> \ 716 ThisClass::mergeField(const Field<Type>& fld) const \ 718 return mergeFieldTemplate(fld); \ 721 Foam::tmp<Foam::Field<Type>> \ 722 ThisClass::adjustField \ 724 const word& fieldName, \ 725 const tmp<Field<Type>>& tfield \ 728 return adjustFieldTemplate(fieldName, tfield); \ 738 #undef defineSurfaceFieldMethod 749 const auto& w = *iproxy;
751 os <<
"surfaceWriter:" 752 <<
" upToDate: " << w.upToDate_
753 <<
" PointData: " << w.isPointData_
754 <<
" nFields: " << w.nFields_
755 <<
" time: " << w.currTime_
756 <<
" path: " << w.outputPath_ <<
endl;
const Type & value() const noexcept
Return const reference to value.
label size() const
The global number of faces for the associated surface.
virtual bool expire()
Mark that surface changed and the writer will need an update, and set nFields = 0.
A class for handling file names.
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
surfaceWriter()
Default construct.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
bool equal(const T &a, const T &b)
Compare two values for equality.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool empty() const
The surface to write is empty if the global number of faces is zero.
dictionary fieldLevel_
Field level to remove (on output)
bool readIfPresent(const word &key, const dictionary &dict, EnumType &val, const bool warnOnly=false) const
Find an entry if present, and assign to T val.
void checkOpen() const
Verify that the outputPath_ has been set or FatalError.
virtual void open(const fileName &outputPath)
Open for output on specified path, using existing surface.
constexpr char nl
The newline '\n' character (0x0a)
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
#define defineSurfaceFieldMethods(ThisClass, Type)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const meshedSurf & surface() const
Merge surfaces (if not upToDate) and return merged (parallel) or regular surface (non-parallel) ...
static bool & parRun() noexcept
Test if this a parallel run.
const meshedSurfRef & adjustSurface() const
Merge surfaces (if not upToDate) and return merged (parallel) or regular surface (non-parallel) and a...
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
point geometryCentre_
The centre of rotation (untranslate, translate)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
static int & msgType() noexcept
Message tag of standard messages.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
static bool supportedType(const word &writeType)
True if New is likely to succeed for this writeType.
static bool canWriteType(const word &fileType, bool verbose=false)
Can this file format type be written via MeshedSurfaceProxy?
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
UPstream::commsTypes commType_
Communication type (for field merging)
Macros for easy insertion into run-time selection tables.
virtual void clear()
Reset origin and rotation to an identity coordinateSystem.
virtual ~surfaceWriter()
Destructor. Calls close()
Abstract definition of a meshed surface defined by faces and points.
bool isPointData() const noexcept
Are the field data to be treated as point data?
A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but which does not support any f...
A Cartesian coordinate system.
static scalar defaultMergeDim
The default merge dimension (1e-8)
virtual void clear()
Close any open output, remove association with a surface and expire the writer. The parallel flag rem...
virtual void setSurface(const meshedSurf &surf, bool parallel)
Change association with a surface, expire the writer with defined parallel/serial treatment...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
virtual void endTime()
End a time-step.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
const dimensionedScalar e
Elementary charge.
Implements a meshed surface by referencing another meshed surface or faces/points components...
A class for handling words, derived from Foam::string.
virtual bool needsUpdate() const
Does the writer need an update (eg, lagging behind surface changes)
coordSystem::cartesian geometryTransform_
Local coordinate system transformation.
scalar geometryScale_
Output geometry scaling after rotate/translate.
bool hasSurface() const
Writer is associated with a surface.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
tmp< Field< Type > > mergeFieldTemplate(const Field< Type > &fld) const
Gather (merge) fields with renumbering and shrinking for point data.
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Find and return a sub-dictionary as a copy, otherwise return an empty dictionary. ...
virtual void close()
Finish output, performing any necessary cleanup.
tmp< Field< Type > > adjustFieldTemplate(const word &fieldName, const tmp< Field< Type >> &tfield) const
Apply refLevel and fieldScaling.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dictionary fieldScale_
Field scaling (on output)
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
A helper class for outputting values to Ostream.
virtual bool wroteData() const
Geometry or fields written since the last open?
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool merge() const
Merge surfaces if they are not already upToDate (parallel) or simply mark the surface as being up-to-...
Reading is optional [identical to READ_IF_PRESENT].
Base class for surface writers.
bool verbose_
Additional output verbosity.
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, List< Type > &allFld, const int tag=UPstream::msgType(), const UPstream::commsTypes=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
A class for managing temporary objects.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
label & setComponent(label &val, const direction) noexcept
Non-const access to integer-type (has no components)
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
Tensor of scalars, i.e. Tensor<scalar>.
void unsetTime()
Clear the current time.
Inter-processor communications stream.
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
virtual void beginTime(const Time &t)
Begin a time-step.
void clear()
Invalid by redirecting to null objects.
void setTime(const instant &inst)
Set the current time.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and a sub-dictionary) otherwise return nullptr...
static constexpr const zero Zero
Global zero (0)