55Foam::scalar Foam::sampledSurfaces::mergeTol_ = 1
e-10;
60void Foam::sampledSurfaces::storeRegistrySurface
62 const sampledSurface&
s
65 s.storeRegistrySurface
73Foam::IOobjectList Foam::sampledSurfaces::preCheckFields()
85 allFields = objects.names();
86 selected = objects.classes(fieldSelection_);
91 allFields = obr_.names();
92 selected = obr_.classes(fieldSelection_);
102 forAll(fieldSelection_, i)
115 << (loadFromFiles_ ?
"field file" :
"registered field")
122 label nVolumeFields = 0;
123 label nSurfaceFields = 0;
127 const word& clsName = iter.key();
128 const label
n = iter.val().size();
151 + (
s.withSurfaceFields() ? nSurfaceFields : 0)
155 !
s.isPointData() &&
s.hasFaceIds() && !outWriter.usesFaceIds()
165Foam::autoPtr<Foam::surfaceWriter> Foam::sampledSurfaces::newWriter
173 surfDict.readIfPresent<
word>(
"surfaceFormat", writerType);
186Foam::sampledSurfaces::sampledSurfaces
195 loadFromFiles_(false),
209Foam::sampledSurfaces::sampledSurfaces
214 const bool loadFromFiles
219 loadFromFiles_(loadFromFiles),
245 fvMeshFunctionObject::read(
dict);
251 fieldSelection_.clear();
253 verbose_ =
dict.getOrDefault(
"verbose",
false);
254 onExecute_ =
dict.getOrDefault(
"sampleOnExecute",
false);
257 dict.getOrDefault<
word>(
"sampleScheme",
"cell");
260 dict.getOrDefault<
word>(
"interpolationScheme",
"cellPoint");
265 const word writerType =
269 const bool dfltStore =
dict.getOrDefault(
"store",
false);
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);
347 actions_.resize(surfs.size(), ACTION_WRITE);
348 writers_.resize(surfs.size());
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();
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;
449bool Foam::sampledSurfaces::performAction(
unsigned request)
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);
503 if (((request & actions_[surfi]) & ACTION_WRITE) && hasFaces_[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())
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);
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_)
636bool Foam::sampledSurfaces::needsUpdate()
const
650bool Foam::sampledSurfaces::expire(
const bool force)
653 const scalar mergeDim = mergeTol_ * mesh_.bounds().mag();
655 bool changed =
false;
661 if (
s.invariant() && !force)
672 writers_[surfi].mergeDim(mergeDim);
673 hasFaces_[surfi] =
false;
681bool Foam::sampledSurfaces::update()
688 bool changed =
false;
697 writers_[surfi].expire();
714 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.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
A HashTable similar to std::unordered_map.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
static void mapCombineReduce(Container &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::mapReduce with an in-place cop.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
autoPtr< T > release(const label i)
Release ownership of the pointer at the given position.
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
constexpr PtrList() noexcept
void resize(const label newLen)
Adjust size of PtrList.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A List with indirect addressing. Like IndirectList but does not store addressing.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
label size() const noexcept
The number of entries in the list.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
T * release() noexcept
Release ownership and return the pointer.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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,...
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...
A keyword and a list of tokens is an 'entry'.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary, otherwise Fatal.
static bool clean(std::string &str)
Cleanup filename string, possibly applies other transformations such as changing the path separator e...
Abstract base-class for Time/database function objects.
static word outputPrefix
Directory prefix.
const fvMesh & mesh_
Reference to the fvMesh.
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
virtual const objectRegistry & obr() const
The region or sub-region registry being used.
const Time & time_
Reference to the time database.
objectRegistry & storedObjects()
Write access to the output objects ("functionObjectObjects") registered on Time.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const noexcept
Return polyMesh.
Registry of regIOobjects.
Mesh consisting of general polyhedral cells.
readUpdateState
Enumeration defining the state of the mesh after a read update.
PtrList read-construction helper that captures dictionaries used during creation.
An abstract class for surfaces with sampling.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &mesh, const dictionary &dict)
Return a reference to the selected surface.
virtual bool expire()=0
Mark the surface as needing an update.
Set of surfaces to sample.
virtual void movePoints(const polyMesh &mesh)
Update for mesh point-motion - expires the surfaces.
virtual bool read(const dictionary &dict)
Read the sampledSurfaces dictionary.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh - expires the surfaces.
static scalar mergeTol() noexcept
Get merge tolerance.
bool verbose(bool on) noexcept
Enable/disable verbose output.
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
virtual bool execute()
Sample and store if the sampleOnExecute is enabled.
virtual bool write()
Sample and write.
Base class for surface writers.
virtual void open(const fileName &outputPath)
Open for output on specified path, using existing surface.
static autoPtr< surfaceWriter > New(const word &writeType)
Select construct a surfaceWriter.
label nFields() const noexcept
The number of expected output fields.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#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.
Namespace for handling debugging switches.
bool is_volume(const word &clsName)
Test if the class name appears to be a volume field.
bool is_surface(const word &clsName)
Test if the class name appears to be a surface field.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
List< word > wordList
List of word.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
bool read(const char *buf, int32_t &val)
Same as readInt32.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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.
Combine HashSet operation. Equivalent to 'a |= b'.