55 Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1
e-10;
60 void Foam::sampledSurfaces::storeRegistrySurface
62 const sampledSurface&
s 65 s.storeRegistrySurface
76 HashTable<wordHashSet> selected;
83 objects = IOobjectList(obr_, obr_.time().timeName());
85 allFields = objects.names();
86 selected = objects.classes(fieldSelection_);
91 allFields = obr_.names();
92 selected = obr_.classes(fieldSelection_);
99 DynamicList<label> missed(fieldSelection_.size());
102 forAll(fieldSelection_, i)
115 << (loadFromFiles_ ?
"field file" :
"registered field")
117 << UIndirectList<wordRe>(fieldSelection_, missed) <<
endl;
122 label nVolumeFields = 0;
123 label nSurfaceFields = 0;
127 const word& clsName = iter.key();
128 const label
n = iter.val().size();
145 const sampledSurface&
s = (*this)[surfi];
146 surfaceWriter& outWriter = writers_[surfi];
151 + (
s.withSurfaceFields() ? nSurfaceFields : 0)
155 !
s.isPointData() &&
s.hasFaceIds() && !outWriter.usesFaceIds()
168 const dictionary& topDict,
169 const dictionary& surfDict
173 surfDict.readIfPresent<word>(
"surfaceFormat", writerType);
186 Foam::sampledSurfaces::sampledSurfaces
195 loadFromFiles_(false),
209 Foam::sampledSurfaces::sampledSurfaces
214 const bool loadFromFiles
217 functionObjects::fvMeshFunctionObject(
name, obr,
dict),
219 loadFromFiles_(loadFromFiles),
251 fieldSelection_.clear();
265 const word writerType =
271 if (eptr && eptr->isDict())
275 actions_.
resize(surfs.size(), ACTION_WRITE);
276 writers_.resize(surfs.size());
282 if (!dEntry.isDict())
289 autoPtr<sampledSurface> surf =
297 if (!surf || !surf->enabled())
303 surfs.set(surfi, surf);
306 if (surfDict.getOrDefault(
"store", dfltStore))
308 actions_[surfi] |= ACTION_STORE;
315 newWriter(writerType,
dict, surfDict)
318 writers_[surfi].isPointData(surfs[surfi].isPointData());
321 writers_[surfi].useTimeDir(
true);
322 writers_[surfi].verbose(verbose_);
328 actions_.resize(surfi);
329 writers_.resize(surfi);
330 surfaces().transfer(surfs);
337 DynamicList<dictionary> capture;
339 PtrList<sampledSurface>
input 342 sampledSurface::iNewCapture(mesh_, capture)
345 PtrList<sampledSurface> surfs(
input.size());
347 actions_.resize(surfs.size(), ACTION_WRITE);
348 writers_.resize(surfs.size());
356 autoPtr<sampledSurface> surf =
input.release(inputi);
358 if (!surf || !surf->enabled())
364 surfs.set(surfi, surf);
367 if (surfDict.getOrDefault(
"store", dfltStore))
369 actions_[surfi] |= ACTION_STORE;
376 newWriter(writerType,
dict, surfDict)
379 writers_[surfi].isPointData(surfs[surfi].isPointData());
382 writers_[surfi].useTimeDir(
true);
383 writers_[surfi].verbose(verbose_);
389 actions_.resize(surfi);
390 writers_.resize(surfi);
391 surfaces().transfer(surfs);
395 const auto& surfs = surfaces();
399 hasFaces_.resize_nocopy(surfs.size());
405 fieldSelection_.uniq();
409 const sampledSurface&
s = (*this)[surfi];
413 Info<<
"Sampled surface:" <<
nl;
416 Info<<
" " <<
s.name() <<
" -> " << writers_[surfi].type();
417 if (actions_[surfi] & ACTION_STORE)
419 Info<<
", store on registry (" 432 Pout<<
"sample fields:" << fieldSelection_ <<
nl 433 <<
"sample surfaces:" <<
nl <<
'(' <<
nl;
435 for (
const sampledSurface&
s : surfaces())
449 bool Foam::sampledSurfaces::performAction(
unsigned request)
456 sampledSurface&
s = (*this)[surfi];
458 if (request & actions_[surfi])
462 writers_[surfi].expire();
463 hasFaces_[surfi] =
false;
466 if (!hasFaces_[surfi])
471 ok = ok || hasFaces_[surfi];
477 if ((request & actions_[surfi]) & ACTION_STORE)
479 storeRegistrySurface(
s);
495 IOobjectList objects = preCheckFields();
501 const sampledSurface&
s = (*this)[surfi];
503 if (((request & actions_[surfi]) & ACTION_WRITE) && hasFaces_[surfi])
505 surfaceWriter& outWriter = writers_[surfi];
507 if (outWriter.needsUpdate())
509 outWriter.setSurface(
s);
512 outWriter.open(outputPath_/
s.name());
514 outWriter.beginTime(obr_.time());
517 if (!
s.isPointData() &&
s.hasFaceIds() && !outWriter.usesFaceIds())
521 Field<label> ids(
s.faceIds());
537 writeSurface(outWriter, ids,
"Ids");
544 performAction<volScalarField>(objects, request);
545 performAction<volVectorField>(objects, request);
546 performAction<volSphericalTensorField>(objects, request);
547 performAction<volSymmTensorField>(objects, request);
548 performAction<volTensorField>(objects, request);
556 [](
const sampledSurface&
s) {
return s.withSurfaceFields(); }
560 performAction<surfaceScalarField>(objects, request);
561 performAction<surfaceVectorField>(objects, request);
562 performAction<surfaceSphericalTensorField>(objects, request);
563 performAction<surfaceSymmTensorField>(objects, request);
564 performAction<surfaceTensorField>(objects, request);
571 if (((request & actions_[surfi]) & ACTION_WRITE) && hasFaces_[surfi])
576 if (!writers_[surfi].wroteData())
578 writers_[surfi].write();
581 writers_[surfi].endTime();
593 return performAction(ACTION_ALL & ~ACTION_WRITE);
602 return performAction(ACTION_ALL);
608 if (&mpm.
mesh() == &mesh_)
636 bool Foam::sampledSurfaces::needsUpdate()
const 638 for (
const sampledSurface&
s : surfaces())
650 bool Foam::sampledSurfaces::expire(
const bool force)
653 const scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
655 bool changed =
false;
659 sampledSurface&
s = (*this)[surfi];
661 if (
s.invariant() && !force)
671 writers_[surfi].expire();
672 writers_[surfi].mergeDim(mergeDim);
673 hasFaces_[surfi] =
false;
681 bool Foam::sampledSurfaces::update()
688 bool changed =
false;
692 sampledSurface&
s = (*this)[surfi];
697 writers_[surfi].expire();
714 scalar old(mergeTol_);
virtual bool write()
Sample and write.
const polyMesh & mesh() const noexcept
Return polyMesh.
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, otherwise Fatal.
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.
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 expressions::valueTypeCode::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.
bool verbose(bool on) noexcept
Enable/disable verbose output.
List< word > wordList
List of word.
#define WarningInFunction
Report a warning using Foam::Warning.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
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...
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
static autoPtr< surfaceWriter > New(const word &writeType)
Select construct a surfaceWriter.
forAllConstIters(mixture.phases(), phase)
A keyword and a list of tokens is an 'entry'.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh - expires the surfaces.