67 setDict.readIfPresent<word>(
"setFormat", writerType);
78Foam::OFstream* Foam::sampledSets::createProbeFile(
const word& fieldName)
82 OFstream* osptr = probeFilePtrs_.lookup(fieldName,
nullptr);
91 mesh_.time().globalPath()
93 /
name()/mesh_.regionName()
95 / mesh_.time().timeName(mesh_.time().startTime().value())
102 probeFilePtrs_.insert
107 osptr = probeFilePtrs_.lookup(fieldName,
nullptr);
133 for (label probei = 0; probei <
nPoints; ++probei)
135 os <<
' ' <<
setw(width) << probei;
148void Foam::sampledSets::gatherAllSets()
151 for (
auto&
writer : writers_)
159 gatheredSorting_.resize_nocopy(localSets.size());
160 globalIndices_.resize_nocopy(localSets.size());
164 const coordSet& coords = localSets[seti];
167 gatheredSets_.
set(seti, coords.gatherSort(gatheredSorting_[seti]));
172Foam::IOobjectList Foam::sampledSets::preCheckFields(
unsigned request)
184 allFields = objects.names();
185 selected = objects.classes(fieldSelection_);
190 allFields = mesh_.names();
191 selected = mesh_.classes(fieldSelection_);
202 forAll(fieldSelection_, i)
206 fieldSelection_[i].isLiteral()
214 if (missed.size() && (request != ACTION_NONE))
219 << (loadFromFiles_ ?
"field file" :
"registered field")
228 selectedFieldNames_.clear();
233 #define doLocalCode(InputType) \
235 const auto iter = selected.find(InputType::typeName); \
238 selectedFieldNames_.append(iter.val().sortedToc()); \
255 const label nFields = selectedFieldNames_.size();
262 if (!selectedFieldNames_.found(iter.key()))
265 <<
"close probe stream: "
266 << iter()->name() <<
endl;
268 probeFilePtrs_.remove(iter);
272 else if ((request & ACTION_WRITE) != 0)
286void Foam::sampledSets::initDict(
const dictionary&
dict,
const bool initial)
296 if (eptr && eptr->isDict())
299 if (initial && !writeAsProbes_)
301 writers_.resize(sampSets.size());
308 if (!dEntry.isDict())
330 sampSets.set(seti, sampSet);
333 if (initial && !writeAsProbes_)
338 newWriter(writeFormat_, dict_, subDict)
342 writers_[seti].useTimeDir(
true);
343 writers_[seti].verbose(verbose_);
348 sampSets.resize(seti);
349 if (initial && !writeAsProbes_)
351 writers_.resize(seti);
369 if (initial && !writeAsProbes_)
371 writers_.resize(sampSets.size());
388 sampSets.set(seti, sampSet);
391 if (initial && !writeAsProbes_)
396 newWriter(writeFormat_, dict_, subDict)
400 writers_[seti].useTimeDir(
true);
401 writers_[seti].verbose(verbose_);
406 sampSets.resize(seti);
407 if (initial && !writeAsProbes_)
409 writers_.resize(seti);
417 needsCorrect_ =
false;
423Foam::sampledSets::sampledSets
433 loadFromFiles_(false),
436 needsCorrect_(false),
437 writeAsProbes_(false),
443 searchEngine_(mesh_),
444 samplePointScheme_(),
446 selectedFieldNames_(),
459Foam::sampledSets::sampledSets
464 const bool loadFromFiles
470 loadFromFiles_(loadFromFiles),
473 needsCorrect_(false),
474 writeAsProbes_(false),
480 searchEngine_(mesh_),
481 samplePointScheme_(),
483 selectedFieldNames_(),
514 fvMeshFunctionObject::read(
dict);
518 fieldSelection_.clear();
519 selectedFieldNames_.clear();
521 gatheredSets_.clear();
522 gatheredSorting_.clear();
523 globalIndices_.clear();
525 verbose_ =
dict.getOrDefault(
"verbose",
false);
526 onExecute_ =
dict.getOrDefault(
"sampleOnExecute",
false);
529 dict.getOrDefault<word>(
"interpolationScheme",
"cellPoint");
535 dict.readEntry(
"setFormat", writeFormat_);
539 writeAsProbes_ = (
"probes" == writeFormat_);
543 probeFilePtrs_.clear();
546 initDict(
dict,
true);
552 dict_.readEntry(
"fields", fieldSelection_);
553 fieldSelection_.uniq();
558 Info<<
"Sampled set as probes ensemble:" <<
nl;
563 Info<<
" " <<
s.name();
569 Info<<
"Sampled set:" <<
nl;
575 Info<<
" " <<
s.name() <<
" -> "
576 << writers_[seti].type() <<
nl;
586 <<
"sample sets:" <<
nl <<
'(' <<
nl;
601 (void) preCheckFields(ACTION_NONE);
612bool Foam::sampledSets::performAction(
unsigned request)
619 else if (needsCorrect_)
621 searchEngine_.correct();
622 initDict(dict_,
false);
634 const label nFields = selectedFieldNames_.size();
649 if ((request & ACTION_WRITE) != 0)
675 writer.beginTime(mesh_.time());
682 performAction<VolumeField<scalar>>(objects, request);
683 performAction<VolumeField<vector>>(objects, request);
684 performAction<VolumeField<sphericalTensor>>(objects, request);
685 performAction<VolumeField<symmTensor>>(objects, request);
686 performAction<VolumeField<tensor>>(objects, request);
697 if ((request & ACTION_WRITE) != 0)
704 writers_[seti].endTime();
717 return performAction(ACTION_ALL & ~ACTION_WRITE);
726 return performAction(ACTION_ALL);
732 needsCorrect_ =
true;
Istream and Ostream manipulators taking arguments.
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.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A HashTable similar to std::unordered_map.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
static unsigned int defaultPrecision() noexcept
Return the default precision.
bool set(const label i, bool val=true)
A bitSet::set() method for a list of bool.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
virtual const fileName & name() const override
Read/write access to the name of the stream.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
void transfer(PtrList< T > &list)
Transfer into this list and annul the argument list.
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
constexpr PtrList() noexcept
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
T * release() noexcept
Release ownership and return the pointer.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Base class for writing coordSet(s) and tracks with fields.
static autoPtr< coordSetWriter > New(const word &writeFormat)
Return a reference to the selected writer.
static word suffix(const word &fldName, const word &fileExt=word::null)
Name suffix based on fieldName (underscore separator).
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
Holds list of sampling positions.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
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.
A class for handling file names.
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.
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.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
static autoPtr< sampledSet > New(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Return a reference to the selected sampledSet.
bool verbose(const bool on) noexcept
Enable/disable verbose output.
void correct()
Correct for mesh changes.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate.
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Sample and write.
virtual bool read(const dictionary &)
Read the sampledSets.
virtual bool open(const fileName &file, bool parallel=UPstream::parRun())
Open file for writing (creates parent directory).
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
OBJstream os(runTime.globalPath()/outputName)
#define doLocalCode(FieldType, Variable)
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 DebugInfo
Report an information message using Foam::Info.
#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.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
List< word > wordList
List of word.
GeometricField< vector, fvPatchField, volMesh > volVectorField
bool read(const char *buf, int32_t &val)
Same as readInt32.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
GeometricField< sphericalTensor, fvPatchField, volMesh > volSphericalTensorField
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
vector point
Point is a vector.
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.
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Dispatch tag: Construct 'one-sided' from local sizes, using gather but no broadcast.