55Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1
e-10;
62 const sampledSurface&
s
65 return s.getRegistrySurface
75 const sampledSurface&
s
78 return s.storeRegistrySurface
86bool 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()
195 const dictionary& surfDict
199 surfDict.readIfPresent<word>(
"surfaceFormat", writeType);
205 surfDict.subOrEmptyDict(
"formatOptions").subOrEmptyDict(writeType)
223 loadFromFiles_(false),
248 const bool loadFromFiles
251 functionObjects::fvMeshFunctionObject(
name, obr,
dict),
253 loadFromFiles_(loadFromFiles),
285 fvMeshFunctionObject::read(
dict);
291 fieldSelection_.clear();
305 const word writerType =
313 if (eptr && eptr->isDict())
317 actions_.resize(surfs.
size(), ACTION_WRITE);
318 writers_.resize(surfs.
size());
325 if (!dEntry.isDict())
340 if (!surf || !surf->enabled())
346 surfs.
set(surfi, surf);
351 actions_[surfi] |= ACTION_STORE;
361 writers_[surfi].isPointData(surfs[surfi].isPointData());
364 writers_[surfi].useTimeDir(
true);
365 writers_[surfi].verbose(verbose_);
371 actions_.resize(surfi);
372 writers_.resize(surfi);
373 surfaces().transfer(surfs);
390 actions_.resize(surfs.
size(), ACTION_WRITE);
391 writers_.resize(surfs.
size());
402 if (!surf || !surf->enabled())
408 surfs.
set(surfi, surf);
413 actions_[surfi] |= ACTION_STORE;
423 writers_[surfi].isPointData(surfs[surfi].isPointData());
426 writers_[surfi].useTimeDir(
true);
427 writers_[surfi].verbose(verbose_);
433 actions_.resize(surfi);
434 writers_.resize(surfi);
435 surfaces().transfer(surfs);
439 const auto& surfs = surfaces();
445 nFaces_.resize(surfs.size(),
Zero);
448 fieldSelection_.uniq();
456 Info<<
"Sampled surface:" <<
nl;
459 Info<<
" " <<
s.name() <<
" -> " << writers_[surfi].type();
460 if (actions_[surfi] & ACTION_STORE)
462 Info<<
", store on registry ("
475 Pout<<
"sample fields:" << fieldSelection_ <<
nl
476 <<
"sample surfaces:" <<
nl <<
'(' <<
nl;
492bool Foam::sampledSurfaces::performAction(
unsigned request)
501 if (request & actions_[surfi])
505 writers_[surfi].expire();
508 nFaces_[surfi] =
returnReduce(
s.faces().size(), sumOp<label>());
510 ok = ok || nFaces_[surfi];
517 if ((request & actions_[surfi]) & ACTION_STORE)
519 storeRegistrySurface(
s);
535 IOobjectList objects = preCheckFields();
541 const sampledSurface&
s = (*this)[surfi];
543 if (((request & actions_[surfi]) & ACTION_WRITE) && nFaces_[surfi])
545 surfaceWriter& outWriter = writers_[surfi];
547 if (outWriter.needsUpdate())
549 outWriter.setSurface(
s);
552 outWriter.open(outputPath_/
s.name());
554 outWriter.beginTime(obr_.time());
557 if (!
s.isPointData() &&
s.hasFaceIds() && !outWriter.usesFaceIds())
561 Field<label> ids(
s.faceIds());
578 writeSurface(outWriter, ids,
"Ids");
585 performAction<volScalarField>(objects, request);
586 performAction<volVectorField>(objects, request);
587 performAction<volSphericalTensorField>(objects, request);
588 performAction<volSymmTensorField>(objects, request);
589 performAction<volTensorField>(objects, request);
597 [] (
const sampledSurface&
s) {
return s.withSurfaceFields(); }
601 performAction<surfaceScalarField>(objects, request);
602 performAction<surfaceVectorField>(objects, request);
603 performAction<surfaceSphericalTensorField>(objects, request);
604 performAction<surfaceSymmTensorField>(objects, request);
605 performAction<surfaceTensorField>(objects, request);
612 if (((request & actions_[surfi]) & ACTION_WRITE) && nFaces_[surfi])
617 if (!writers_[surfi].wroteData())
619 writers_[surfi].write();
622 writers_[surfi].endTime();
634 return performAction(ACTION_ALL & ~ACTION_WRITE);
643 return performAction(ACTION_ALL);
649 if (&mpm.
mesh() == &mesh_)
677bool Foam::sampledSurfaces::needsUpdate()
const
694 const scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
700 sampledSurface&
s = (*this)[surfi];
702 if (
s.invariant() && !force)
712 writers_[surfi].expire();
713 writers_[surfi].mergeDim(mergeDim);
722bool Foam::sampledSurfaces::update()
733 sampledSurface&
s = (*this)[surfi];
738 writers_[surfi].expire();
741 nFaces_[surfi] =
returnReduce(
s.faces().size(), sumOp<label>());
756 const scalar old(mergeTol_);
Various functions to operate on Lists.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
List of IOobjects with searching and retrieving facilities.
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
static void mapCombineAllGather(const List< commsStruct > &comms, Container &values, const CombineOp &cop, const int tag, const label comm)
After completion all processors have the same data.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
void resize(const label newLen)
Adjust size of PtrList.
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
label size() const noexcept
The number of elements in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
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
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
int verbose() const noexcept
Output verbosity level.
bool expire()
Mark as needing an update.
A keyword and a list of tokens is an 'entry'.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
static bool clean(std::string &str)
Abstract base-class for Time/database function objects.
const word & name() const noexcept
Return the name of this functionObject.
objectRegistry & storedObjects()
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const
Return polyMesh.
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
readUpdateState
Enumeration defining the state of the mesh after a read update.
A surface mesh consisting of general polygon faces and capable of holding fields.
An abstract class for surfaces with sampling.
Set of surfaces to sample.
virtual bool read(const dictionary &dict)
Read the sampledSurfaces dictionary.
static scalar mergeTol() noexcept
Get merge tolerance.
virtual bool execute()
Sample and store if the sampleOnExecute is enabled.
virtual bool write()
Sample and write.
splitCell * master() const
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
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))
#define WarningInFunction
Report a warning using Foam::Warning.
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
const wordList volume
Standard volume field types (scalar, vector, tensor, etc)
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
List< word > wordList
A List of words.
static Istream & input(Istream &is, IntRange< T > &range)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
const dictionary formatOptions(propsDict.subOrEmptyDict("formatOptions", keyType::LITERAL))