56 wordConstructorTablePtr_->found(writeType)
57 || wordDictConstructorTablePtr_->found(writeType)
66 const word& formatName,
78 const word& formatName,
91 auto* ctorPtr = wordConstructorTable(writeType);
107 const word& writeType,
113 auto* ctorPtr = wordDictConstructorTable(writeType);
123 auto* ctorPtr = wordConstructorTable(writeType);
147 <<
"Unknown write type \"" << writeType <<
"\"\n\n"
148 <<
"Valid write types : "
149 <<
flatOutput(wordConstructorTablePtr_->sortedToc()) <<
nl
150 <<
"Valid proxy types : "
162 const word& writeType,
166 autoPtr<surfaceWriter>
writer
174 <<
"Unknown write type \"" << writeType <<
"\"\n\n"
175 <<
"Valid write types : "
176 <<
flatOutput(wordConstructorTablePtr_->sortedToc()) <<
nl
177 <<
"Valid proxy types : "
193 mergeDim_(defaultMergeDim),
195 geometryCentre_(
Zero),
196 geometryTransform_(),
203 commType_(
UPstream::commsTypes::scheduled),
248 Info<<
"Create surfaceWriter ("
249 << (this->
isPointData() ?
"point" :
"face") <<
" data):"
453 const bool changed = upToDate_;
457 adjustedSurf_.clear();
475 const bool value =
surf_.faces().empty();
483 const label value =
surf_.faces().size();
494 <<
type() <<
" : Attempted to write without a path" <<
nl
502 bool changed =
false;
507 adjustedSurf_.clear();
511 changed = mergedSurf_.merge(surf_, mergeDim_);
546 adjustedSurf_.clear();
549 if (!adjustedSurf_.good())
551 adjustedSurf_.reset(
surface());
555 if (geometryTransform_.good())
557 if (!geometryTransform_.R().is_identity())
559 if (
magSqr(geometryCentre_) > ROOTVSMALL)
564 geometryTransform_.globalPosition
566 adjustedSurf_.points0() - geometryCentre_
570 tpts.ref() += geometryCentre_;
576 geometryTransform_.globalPosition
578 adjustedSurf_.points0()
582 else if (
magSqr(geometryTransform_.origin()) > ROOTVSMALL)
585 tpts = (adjustedSurf_.points0() + geometryTransform_.origin());
589 adjustedSurf_.movePoints(tpts);
590 adjustedSurf_.scalePoints(geometryScale_);
612 auto& allFld = tfield.ref();
619 ? mergedSurf_.pointGlobalIndex()
620 : mergedSurf_.faceGlobalIndex()
651 && this->isPointData()
652 && mergedSurf_.pointsMap().size()
656 allFld.resize(mergedSurf_.points().size());
681 const word& fieldName,
687 Info<<
"Writing field " << fieldName;
690 tmp<Field<Type>> tadjusted;
694 if constexpr (std::is_integral_v<Type>)
715 refLevel.fill(value);
724 Info<<
" [level " << refLevel <<
']';
730 tadjusted.reset(tfield.ptr());
734 tadjusted.ref() -= refLevel;
746 Info<<
" [scaling " << value <<
']';
752 tadjusted.reset(tfield.ptr());
756 tadjusted.ref() *= value;
764 if (geometryTransform_.good() && !geometryTransform_.R().is_identity())
769 tadjusted.reset(tfield.ptr());
775 geometryTransform_.R(),
781 return (tadjusted ? tadjusted : tfield);
785#define defineSurfaceFieldMethods(ThisClass, Type) \
786 Foam::tmp<Foam::Field<Type>> \
787 ThisClass::mergeField(const Field<Type>& fld) const \
789 return mergeFieldTemplate(fld); \
792 Foam::tmp<Foam::Field<Type>> \
793 ThisClass::adjustField \
795 const word& fieldName, \
796 const tmp<Field<Type>>& tfield \
799 return adjustFieldTemplate(fieldName, tfield); \
809#undef defineSurfaceFieldMethod
820 const auto& w = *iproxy;
822 os <<
"surfaceWriter:"
823 <<
" upToDate: " << w.upToDate_
824 <<
" PointData: " << w.isPointData_
825 <<
" nFields: " << w.nFields_
826 <<
" time: " << w.currTime_
827 <<
" path: " << w.outputPath_ <<
endl;
Macros for easy insertion into run-time selection tables.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
@ LAZY_READ
Reading is optional [identical to READ_IF_PRESENT].
A helper class for outputting values to Ostream.
static bool canWriteType(const word &fileType, bool verbose=false)
Can this file format type be written via MeshedSurfaceProxy?
static wordHashSet writeTypes()
The file format types that can be written via MeshedSurfaceProxy.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
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.
Inter-processor communications stream.
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
static const Enum< commsTypes > commsTypeNames
Enumerated names for the communication types.
static int & msgType() noexcept
Message tag of standard messages.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static bool & parRun() noexcept
Test if this a parallel run.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A Cartesian coordinate system.
virtual void clear()
Reset origin and rotation to an identity coordinateSystem.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
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...
const Type & value() const noexcept
Return const reference to value.
A class for handling file names.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
static void gather(const labelUList &offsets, const label comm, const ProcIDsContainer &procIDs, const UList< Type > &fld, UList< Type > &allFld, const int tag=UPstream::msgType(), UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking)
Collect data in processor order on master (== procIDs[0]).
void mpiGather(const UList< Type > &sendData, OutputContainer &allData, const label comm=UPstream::worldComm, UPstream::commsTypes commsType=UPstream::commsTypes::nonBlocking, const int tag=UPstream::msgType()) const
Use MPI_Gatherv call for contiguous data when possible (in serial: performs a simple copy).
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
@ REGEX
Regular expression.
Implements a meshed surface by referencing another meshed surface or faces/points components.
Abstract definition of a meshed surface defined by faces and points.
A traits class, which is primarily used for primitives and vector-space.
Base class for surface writers.
surfaceWriter()
Default construct.
coordSystem::cartesian geometryTransform_
Local coordinate system transformation.
virtual void open(const fileName &outputPath)
Open for output on specified path, using existing surface.
meshedSurfRef surf_
Reference to surface or surface components.
virtual void endTime()
End a time-step.
scalar geometryScale_
Output geometry scaling after rotate/translate.
bool useTimeDir_
Insert additional time sub-directory in the output path.
bool gatherv_
Prefer MPI gatherv intrinsic (for field merging) [experimental].
static autoPtr< surfaceWriter > New(const word &writeType)
Select construct a surfaceWriter.
bool wroteGeom_
Track if geometry has been written since the last open.
bool isPointData_
Is point vs cell data.
meshedSurfRef adjustedSurf_
The surface after point coordinate transforms and scaling.
const meshedSurf & surface() const
Merge surfaces (if not upToDate) and return merged (parallel) or regular surface (non-parallel).
bool isPointData() const noexcept
Are the field data to be treated as point data?
const word & timeName() const
The current time value/name.
void checkOpen() const
Verify that the outputPath_ has been set or FatalError.
void unsetTime()
Clear the current time.
virtual void beginTime(const Time &t)
Begin a time-step.
label size() const
The global number of faces for the associated surface.
label nFields_
The number of fields.
static scalar defaultMergeDim
The default merge dimension (1e-8).
virtual ~surfaceWriter()
Destructor. Calls close().
virtual void setSurface(const meshedSurf &surf, bool parallel)
Change association with a surface, expire the writer with defined parallel/serial treatment.
static autoPtr< surfaceWriter > TryNew(const word &writeType)
Optional select construct surfaceWriter.
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.
bool upToDate_
The topology/surface is up-to-date?
UPstream::commsTypes commType_
Communication type (for field merging).
dictionary fieldLevel_
Field level to remove (on output).
static bool supportedType(const word &writeType)
True if New is likely to succeed for this writeType.
bool is_open() const noexcept
Test if outputPath has been set.
void setTime(const instant &inst)
Set the current time.
virtual bool merge() const
Merge surfaces if they are not already upToDate (parallel) or simply mark the surface as being up-to-...
mergedSurf mergedSurf_
Surface after merging (parallel).
bool verbose_
Additional output verbosity.
tmp< Field< Type > > adjustFieldTemplate(const word &fieldName, const tmp< Field< Type > > &tfield) const
Apply refLevel and fieldScaling.
dictionary fieldScale_
Field scaling (on output).
virtual bool expire()
Mark that surface changed and the writer will need an update, and set nFields = 0.
virtual bool needsUpdate() const
Does the writer need an update (eg, lagging behind surface changes).
tmp< Field< Type > > mergeFieldTemplate(const Field< Type > &fld) const
Gather (merge) fields with renumbering and shrinking for point data.
instant currTime_
The current time value/name.
bool hasSurface() const
Writer is associated with a surface.
const meshedSurfRef & adjustSurface() const
Merge surfaces (if not upToDate) and return merged (parallel) or regular surface (non-parallel) and a...
virtual void clear()
Close any open output, remove association with a surface and expire the writer. The parallel flag rem...
point geometryCentre_
The centre of rotation (untranslate, translate).
scalar timeValue() const
The current time value/name.
virtual bool wroteData() const
Geometry or fields written since the last open?
fileName outputPath_
The full output directory and file (surface) name.
scalar mergeDim_
Dimension for merging.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
static autoPtr< surfaceWriter > TryNew(const word &writeType)
Optional select construct proxy writer.
A class for managing temporary objects.
void reset(tmp< T > &&other) noexcept
Clear existing and transfer ownership.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
runTimeSource setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex)
const wordList surface
Standard surface field types (scalar, vector, tensor, etc).
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.
bool equal(const T &a, const T &b)
Compare two values for equality.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< face > faceList
List of faces.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr bool is_vectorspace_v
The is_vectorspace value of Type.
void inplaceReorder(const labelUList &oldToNew, ListType &input, const bool prune=false)
Inplace reorder the elements of a list.
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
static constexpr const zero Zero
Global zero (0).
constexpr bool is_rotational_vectorspace_v
The is_rotational_vectorspace value of Type.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
SphericalTensor< scalar > sphericalTensor
SphericalTensor of scalars, i.e. SphericalTensor<scalar>.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
constexpr char nl
The newline '\n' character (0x0a).
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
#define defineSurfaceFieldMethods(ThisClass, Type)