55 Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1
e-10;
62 const sampledSurface&
s 65 return s.getRegistrySurface
75 const sampledSurface&
s 78 return s.storeRegistrySurface
86 bool Foam::sampledSurfaces::removeRegistrySurface
88 const sampledSurface&
s 91 return s.removeRegistrySurface
102 HashTable<wordHashSet> selected;
104 IOobjectList objects(0);
109 objects = IOobjectList(obr_, obr_.time().timeName());
111 allFields = objects.names();
112 selected = objects.classes(fieldSelection_);
117 allFields = obr_.names();
118 selected = obr_.classes(fieldSelection_);
125 DynamicList<label> missed(fieldSelection_.size());
128 forAll(fieldSelection_, i)
141 << (loadFromFiles_ ?
"field file" :
"registered field")
143 << UIndirectList<wordRe>(fieldSelection_, missed) <<
endl;
148 label nVolumeFields = 0;
149 label nSurfaceFields = 0;
153 const word& clsName = iter.key();
154 const label
n = iter.val().size();
171 const sampledSurface&
s = (*this)[surfi];
172 surfaceWriter& outWriter = writers_[surfi];
177 + (
s.withSurfaceFields() ? nSurfaceFields : 0)
181 !
s.isPointData() &&
s.hasFaceIds() && !outWriter.usesFaceIds()
194 const dictionary& topDict,
195 const dictionary& surfDict
199 surfDict.readIfPresent<word>(
"surfaceFormat", writerType);
212 Foam::sampledSurfaces::sampledSurfaces
221 loadFromFiles_(false),
241 Foam::sampledSurfaces::sampledSurfaces
246 const bool loadFromFiles
249 functionObjects::fvMeshFunctionObject(
name, obr,
dict),
251 loadFromFiles_(loadFromFiles),
289 fieldSelection_.clear();
303 const word writerType =
309 if (eptr && eptr->isDict())
313 actions_.
resize(surfs.size(), ACTION_WRITE);
314 writers_.resize(surfs.size());
315 nFaces_.resize(surfs.size(),
Zero);
321 if (!dEntry.isDict())
326 const dictionary& surfDict = dEntry.dict();
328 autoPtr<sampledSurface> surf =
336 if (!surf || !surf->enabled())
342 surfs.set(surfi, surf);
345 if (surfDict.getOrDefault(
"store", dfltStore))
347 actions_[surfi] |= ACTION_STORE;
354 newWriter(writerType,
dict, surfDict)
357 writers_[surfi].isPointData(surfs[surfi].isPointData());
360 writers_[surfi].useTimeDir(
true);
361 writers_[surfi].verbose(verbose_);
367 actions_.resize(surfi);
368 writers_.resize(surfi);
369 surfaces().transfer(surfs);
376 DynamicList<dictionary> capture;
378 PtrList<sampledSurface>
input 381 sampledSurface::iNewCapture(mesh_, capture)
384 PtrList<sampledSurface> surfs(
input.size());
386 actions_.resize(surfs.size(), ACTION_WRITE);
387 writers_.resize(surfs.size());
388 nFaces_.resize(surfs.size(),
Zero);
394 const dictionary& surfDict = capture[inputi];
396 autoPtr<sampledSurface> surf =
input.release(inputi);
398 if (!surf || !surf->enabled())
404 surfs.set(surfi, surf);
407 if (surfDict.getOrDefault(
"store", dfltStore))
409 actions_[surfi] |= ACTION_STORE;
416 newWriter(writerType,
dict, surfDict)
419 writers_[surfi].isPointData(surfs[surfi].isPointData());
422 writers_[surfi].useTimeDir(
true);
423 writers_[surfi].verbose(verbose_);
429 actions_.resize(surfi);
430 writers_.resize(surfi);
431 surfaces().transfer(surfs);
435 const auto& surfs = surfaces();
441 nFaces_.resize(surfs.size(),
Zero);
444 fieldSelection_.uniq();
448 const sampledSurface&
s = (*this)[surfi];
452 Info<<
"Sampled surface:" <<
nl;
455 Info<<
" " <<
s.name() <<
" -> " << writers_[surfi].type();
456 if (actions_[surfi] & ACTION_STORE)
458 Info<<
", store on registry (" 471 Pout<<
"sample fields:" << fieldSelection_ <<
nl 472 <<
"sample surfaces:" <<
nl <<
'(' <<
nl;
474 for (
const sampledSurface&
s : surfaces())
488 bool Foam::sampledSurfaces::performAction(
unsigned request)
495 sampledSurface&
s = (*this)[surfi];
497 if (request & actions_[surfi])
501 writers_[surfi].expire();
504 nFaces_[surfi] =
returnReduce(
s.faces().size(), sumOp<label>());
506 ok = ok || nFaces_[surfi];
513 if ((request & actions_[surfi]) & ACTION_STORE)
515 storeRegistrySurface(
s);
531 IOobjectList objects = preCheckFields();
537 const sampledSurface&
s = (*this)[surfi];
539 if (((request & actions_[surfi]) & ACTION_WRITE) && nFaces_[surfi])
541 surfaceWriter& outWriter = writers_[surfi];
543 if (outWriter.needsUpdate())
545 outWriter.setSurface(
s);
548 outWriter.open(outputPath_/
s.name());
550 outWriter.beginTime(obr_.time());
553 if (!
s.isPointData() &&
s.hasFaceIds() && !outWriter.usesFaceIds())
557 Field<label> ids(
s.faceIds());
573 writeSurface(outWriter, ids,
"Ids");
580 performAction<volScalarField>(objects, request);
581 performAction<volVectorField>(objects, request);
582 performAction<volSphericalTensorField>(objects, request);
583 performAction<volSymmTensorField>(objects, request);
584 performAction<volTensorField>(objects, request);
592 [] (
const sampledSurface&
s) {
return s.withSurfaceFields(); }
596 performAction<surfaceScalarField>(objects, request);
597 performAction<surfaceVectorField>(objects, request);
598 performAction<surfaceSphericalTensorField>(objects, request);
599 performAction<surfaceSymmTensorField>(objects, request);
600 performAction<surfaceTensorField>(objects, request);
607 if (((request & actions_[surfi]) & ACTION_WRITE) && nFaces_[surfi])
612 if (!writers_[surfi].wroteData())
614 writers_[surfi].write();
617 writers_[surfi].endTime();
629 return performAction(ACTION_ALL & ~ACTION_WRITE);
638 return performAction(ACTION_ALL);
644 if (&mpm.
mesh() == &mesh_)
672 bool Foam::sampledSurfaces::needsUpdate()
const 674 for (
const sampledSurface&
s : surfaces())
686 bool Foam::sampledSurfaces::expire(
const bool force)
689 const scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
695 sampledSurface&
s = (*this)[surfi];
697 if (
s.invariant() && !force)
707 writers_[surfi].expire();
708 writers_[surfi].mergeDim(mergeDim);
717 bool Foam::sampledSurfaces::update()
728 sampledSurface&
s = (*this)[surfi];
733 writers_[surfi].expire();
751 const scalar old(mergeTol_);
A surface mesh consisting of general polygon faces and capable of holding fields. ...
virtual bool write()
Sample and write.
objectRegistry & storedObjects()
Write access to the output objects ("functionObjectObjects") registered on Time.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
An abstract class for surfaces with sampling.
virtual void movePoints(const polyMesh &mesh)
Update for mesh point-motion - expires the surfaces.
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Abstract base-class for Time/database function objects.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected surface.
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.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Macros for easy insertion into run-time selection tables.
const word & name() const noexcept
Return the name of this functionObject.
static scalar mergeTol() noexcept
Get merge tolerance.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
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.
virtual bool read(const dictionary &dict)
Read the sampledSurfaces dictionary.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
static Istream & input(Istream &is, IntRange< T > &range)
static const word null
An empty word.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
const wordList volume
Standard volume field types (scalar, vector, tensor, etc)
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
static bool clean(std::string &str)
Cleanup filename string, possibly applies other transformations such as changing the path separator e...
virtual bool execute()
Sample and store if the sampleOnExecute is enabled.
void resize(const label newLen)
Adjust size of PtrList.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
List< word > wordList
A List of words.
#define WarningInFunction
Report a warning using Foam::Warning.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
bool verbose(const bool on) noexcept
Enable/disable verbose output.
const polyMesh & mesh() const
Return polyMesh.
static bool master(const label communicator=worldComm)
Am I the master rank.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
messageStream Info
Information stream (stdout output on master, null elsewhere)
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...
readUpdateState
Enumeration defining the state of the mesh after a read update.
Registry of regIOobjects.
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;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static void mapCombineReduce(Container &values, const CombineOp &cop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) applying cop to inplace combine map values from different processo...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
forAllConstIters(mixture.phases(), phase)
A keyword and a list of tokens is an 'entry'.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh - expires the surfaces.
static constexpr const zero Zero
Global zero (0)