63 const dictionary& setDict
67 setDict.readIfPresent<word>(
"setFormat", writeType);
73 setDict.subOrEmptyDict(
"formatOptions").subOrEmptyDict(writeType)
80Foam::OFstream* Foam::sampledSets::createProbeFile(
const word& fieldName)
84 OFstream* osptr = probeFilePtrs_.lookup(fieldName,
nullptr);
93 mesh_.time().globalPath()
95 /
name()/mesh_.regionName()
97 / mesh_.time().timeName(mesh_.time().startTime().value())
104 probeFilePtrs_.insert
109 osptr = probeFilePtrs_.lookup(fieldName,
nullptr);
122 const coordSet&
s = gatheredSets_[seti];
126 for (
const point&
p : pts)
135 for (label probei = 0; probei <
nPoints; ++probei)
137 os <<
' ' <<
setw(width) << probei;
150void Foam::sampledSets::gatherAllSets()
153 for (
auto&
writer : writers_)
158 const PtrList<sampledSet>& localSets = *
this;
160 gatheredSets_.clear();
161 gatheredSets_.resize(localSets.size());
162 gatheredSorting_.resize_nocopy(localSets.size());
163 globalIndices_.resize_nocopy(localSets.size());
167 const coordSet& coords = localSets[seti];
169 globalIndices_[seti].reset(coords.size(), globalIndex::gatherOnly{});
170 gatheredSets_.set(seti, coords.gatherSort(gatheredSorting_[seti]));
178 HashTable<wordHashSet> selected;
180 IOobjectList objects(0);
185 objects = IOobjectList(mesh_, mesh_.time().timeName());
187 allFields = objects.names();
188 selected = objects.classes(fieldSelection_);
193 allFields = mesh_.names();
194 selected = mesh_.classes(fieldSelection_);
202 DynamicList<label> missed(fieldSelection_.size());
205 forAll(fieldSelection_, i)
209 fieldSelection_[i].isLiteral()
217 if (missed.size() && (request != ACTION_NONE))
222 << (loadFromFiles_ ?
"field file" :
"registered field")
224 << UIndirectList<wordRe>(fieldSelection_, missed) <<
endl;
231 selectedFieldNames_.clear();
236 #define doLocalCode(InputType) \
238 const auto iter = selected.find(InputType::typeName); \
241 selectedFieldNames_.append(iter.val().sortedToc()); \
258 const label nFields = selectedFieldNames_.size();
265 if (!selectedFieldNames_.found(iter.key()))
268 <<
"close probe stream: "
269 << iter()->name() <<
endl;
271 probeFilePtrs_.remove(iter);
275 else if ((request & ACTION_WRITE) != 0)
279 coordSetWriter&
writer = writers_[seti];
289void Foam::sampledSets::initDict(
const dictionary&
dict,
const bool initial)
299 if (eptr && eptr->isDict())
301 PtrList<sampledSet> sampSets(eptr->dict().size());
302 if (initial && !writeAsProbes_)
304 writers_.resize(sampSets.size());
309 for (
const entry& dEntry : eptr->dict())
311 if (!dEntry.isDict())
316 const dictionary& subDict = dEntry.dict();
318 autoPtr<sampledSet> sampSet =
333 sampSets.set(seti, sampSet);
336 if (initial && !writeAsProbes_)
341 newWriter(writeFormat_, writeFormatOptions_, subDict)
345 writers_[seti].useTimeDir(
true);
346 writers_[seti].verbose(verbose_);
351 sampSets.resize(seti);
352 if (initial && !writeAsProbes_)
354 writers_.resize(seti);
356 static_cast<PtrList<sampledSet>&
>(*this).transfer(sampSets);
363 DynamicList<dictionary> capture;
365 PtrList<sampledSet>
input
368 sampledSet::iNewCapture(mesh_, searchEngine_, capture)
371 PtrList<sampledSet> sampSets(
input.size());
372 if (initial && !writeAsProbes_)
374 writers_.resize(sampSets.size());
381 const dictionary& subDict = capture[inputi];
383 autoPtr<sampledSet> sampSet =
input.release(inputi);
391 sampSets.set(seti, sampSet);
394 if (initial && !writeAsProbes_)
399 newWriter(writeFormat_, writeFormatOptions_, subDict)
403 writers_[seti].useTimeDir(
true);
404 writers_[seti].verbose(verbose_);
409 sampSets.resize(seti);
410 if (initial && !writeAsProbes_)
412 writers_.resize(seti);
415 static_cast<PtrList<sampledSet>&
>(*this).transfer(sampSets);
420 needsCorrect_ =
false;
436 loadFromFiles_(false),
439 needsCorrect_(false),
440 writeAsProbes_(false),
446 searchEngine_(mesh_),
447 samplePointScheme_(),
449 writeFormatOptions_(
dict.subOrEmptyDict(
"formatOptions")),
450 selectedFieldNames_(),
468 const bool loadFromFiles
471 functionObjects::fvMeshFunctionObject(
name, obr,
dict),
474 loadFromFiles_(loadFromFiles),
477 needsCorrect_(false),
478 writeAsProbes_(false),
484 searchEngine_(mesh_),
485 samplePointScheme_(),
487 writeFormatOptions_(
dict.subOrEmptyDict(
"formatOptions")),
488 selectedFieldNames_(),
519 fvMeshFunctionObject::read(
dict);
523 fieldSelection_.clear();
524 selectedFieldNames_.clear();
526 gatheredSets_.clear();
527 gatheredSorting_.clear();
528 globalIndices_.clear();
544 writeAsProbes_ = (
"probes" == writeFormat_);
548 probeFilePtrs_.clear();
557 initDict(
dict,
true);
563 dict_.readEntry(
"fields", fieldSelection_);
564 fieldSelection_.uniq();
569 Info<<
"Sampled set as probes ensemble:" <<
nl;
574 Info<<
" " <<
s.name();
580 Info<<
"Sampled set:" <<
nl;
586 Info<<
" " <<
s.name() <<
" -> "
587 << writers_[seti].type() <<
nl;
597 <<
"sample sets:" <<
nl <<
'(' <<
nl;
612 (void) preCheckFields(ACTION_NONE);
623bool Foam::sampledSets::performAction(
unsigned request)
630 else if (needsCorrect_)
632 searchEngine_.correct();
633 initDict(dict_,
false);
643 IOobjectList objects = preCheckFields(request);
645 const label nFields = selectedFieldNames_.size();
658 const coordSet&
s = gatheredSets_[seti];
660 if ((request & ACTION_WRITE) != 0)
662 coordSetWriter&
writer = writers_[seti];
686 writer.beginTime(mesh_.time());
693 performAction<VolumeField<scalar>>(objects, request);
694 performAction<VolumeField<vector>>(objects, request);
695 performAction<VolumeField<sphericalTensor>>(objects, request);
696 performAction<VolumeField<symmTensor>>(objects, request);
697 performAction<VolumeField<tensor>>(objects, request);
708 if ((request & ACTION_WRITE) != 0)
715 writers_[seti].endTime();
728 return performAction(ACTION_ALL & ~ACTION_WRITE);
737 return performAction(ACTION_ALL);
743 needsCorrect_ =
true;
749 if (&mpm.
mesh() == &mesh_)
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::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
List of IOobjects with searching and retrieving facilities.
static unsigned int defaultPrecision() noexcept
Return the default precision.
Output to file stream, using an OSstream.
virtual const fileName & name() const
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 clear()
Clear the PtrList. Delete allocated entries and set size to zero.
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.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static word suffix(const word &fldName, const word &fileExt=word::null)
Name suffix based on fieldName (underscore separator)
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
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.
A keyword and a list of tokens is an 'entry'.
static bool clean(std::string &str)
Abstract base-class for Time/database function objects.
static word outputPrefix
Directory prefix.
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.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
void correct()
Correct for mesh changes.
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Sample and write.
virtual bool read(const dictionary &)
Read the sampledSets.
splitCell * master() const
virtual bool open(const fileName &file, bool parallel=Pstream::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(Foam::polyMesh::defaultRegion)
OBJstream os(runTime.globalPath()/outputName)
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.
List< word > wordList
A List of words.
GeometricField< vector, fvPatchField, volMesh > volVectorField
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
static Istream & input(Istream &is, IntRange< T > &range)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
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
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for 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 forAllIters(container, iter)
Iterate across all elements in the container object.
const dictionary formatOptions(propsDict.subOrEmptyDict("formatOptions", keyType::LITERAL))
#define doLocalCode(GeoField)