62 const dictionary& topDict,
63 const dictionary& setDict
67 setDict.readIfPresent<word>(
"setFormat", writerType);
78 Foam::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);
120 const coordSet&
s = gatheredSets_[seti];
133 for (label probei = 0; probei <
nPoints; ++probei)
135 os <<
' ' <<
setw(width) << probei;
148 void Foam::sampledSets::gatherAllSets()
151 for (
auto&
writer : writers_)
156 const PtrList<sampledSet>& localSets = *
this;
158 gatheredSets_.clear();
159 gatheredSets_.resize(localSets.size());
160 gatheredSorting_.resize_nocopy(localSets.size());
161 globalIndices_.resize_nocopy(localSets.size());
165 const coordSet& coords = localSets[seti];
167 globalIndices_[seti].reset(globalIndex::gatherOnly{}, coords.size());
168 gatheredSets_.set(seti, coords.gatherSort(gatheredSorting_[seti]));
176 HashTable<wordHashSet> selected;
178 IOobjectList objects(0);
183 objects = IOobjectList(mesh_, mesh_.time().timeName());
185 allFields = objects.names();
186 selected = objects.classes(fieldSelection_);
191 allFields = mesh_.names();
192 selected = mesh_.classes(fieldSelection_);
200 DynamicList<label> missed(fieldSelection_.size());
203 forAll(fieldSelection_, i)
207 fieldSelection_[i].isLiteral()
215 if (missed.size() && (request != ACTION_NONE))
220 << (loadFromFiles_ ?
"field file" :
"registered field")
222 << UIndirectList<wordRe>(fieldSelection_, missed) <<
endl;
229 selectedFieldNames_.clear();
234 #define doLocalCode(InputType) \ 236 const auto iter = selected.find(InputType::typeName); \ 239 selectedFieldNames_.append(iter.val().sortedToc()); \ 256 const label nFields = selectedFieldNames_.size();
263 if (!selectedFieldNames_.found(iter.key()))
266 <<
"close probe stream: " 267 << iter()->name() <<
endl;
269 probeFilePtrs_.remove(iter);
273 else if ((request & ACTION_WRITE) != 0)
277 coordSetWriter&
writer = writers_[seti];
287 void Foam::sampledSets::initDict(
const dictionary&
dict,
const bool initial)
297 if (eptr && eptr->isDict())
299 PtrList<sampledSet> sampSets(eptr->dict().size());
300 if (initial && !writeAsProbes_)
302 writers_.resize(sampSets.size());
307 for (
const entry& dEntry : eptr->dict())
309 if (!dEntry.isDict())
314 const dictionary& subDict = dEntry.
dict();
316 autoPtr<sampledSet> sampSet =
331 sampSets.set(seti, sampSet);
334 if (initial && !writeAsProbes_)
339 newWriter(writeFormat_, dict_, subDict)
343 writers_[seti].useTimeDir(
true);
344 writers_[seti].verbose(verbose_);
349 sampSets.resize(seti);
350 if (initial && !writeAsProbes_)
352 writers_.resize(seti);
354 static_cast<PtrList<sampledSet>&
>(*this).transfer(sampSets);
361 DynamicList<dictionary> capture;
363 PtrList<sampledSet>
input 366 sampledSet::iNewCapture(mesh_, searchEngine_, capture)
369 PtrList<sampledSet> sampSets(
input.size());
370 if (initial && !writeAsProbes_)
372 writers_.resize(sampSets.size());
379 const dictionary& subDict = capture[inputi];
381 autoPtr<sampledSet> sampSet =
input.release(inputi);
389 sampSets.set(seti, sampSet);
392 if (initial && !writeAsProbes_)
397 newWriter(writeFormat_, dict_, subDict)
401 writers_[seti].useTimeDir(
true);
402 writers_[seti].verbose(verbose_);
407 sampSets.resize(seti);
408 if (initial && !writeAsProbes_)
410 writers_.resize(seti);
413 static_cast<PtrList<sampledSet>&
>(*this).transfer(sampSets);
418 needsCorrect_ =
false;
424 Foam::sampledSets::sampledSets
434 loadFromFiles_(false),
437 needsCorrect_(false),
438 writeAsProbes_(false),
444 searchEngine_(mesh_),
445 samplePointScheme_(),
447 selectedFieldNames_(),
460 Foam::sampledSets::sampledSets
465 const bool loadFromFiles
468 functionObjects::fvMeshFunctionObject(
name, obr,
dict),
471 loadFromFiles_(loadFromFiles),
474 needsCorrect_(false),
475 writeAsProbes_(false),
481 searchEngine_(mesh_),
482 samplePointScheme_(),
484 selectedFieldNames_(),
519 fieldSelection_.clear();
520 selectedFieldNames_.clear();
522 gatheredSets_.clear();
523 gatheredSorting_.clear();
524 globalIndices_.clear();
540 writeAsProbes_ = (
"probes" == writeFormat_);
544 probeFilePtrs_.clear();
547 initDict(
dict,
true);
553 dict_.readEntry(
"fields", fieldSelection_);
554 fieldSelection_.uniq();
559 Info<<
"Sampled set as probes ensemble:" <<
nl;
563 const sampledSet&
s = (*this)[seti];
564 Info<<
" " <<
s.name();
570 Info<<
"Sampled set:" <<
nl;
574 const sampledSet&
s = (*this)[seti];
576 Info<<
" " <<
s.name() <<
" -> " 577 << writers_[seti].type() <<
nl;
587 <<
"sample sets:" <<
nl <<
'(' <<
nl;
592 :
static_cast<const PtrList<sampledSet>&
>(*
this)
602 (void) preCheckFields(ACTION_NONE);
613 bool Foam::sampledSets::performAction(
unsigned request)
620 else if (needsCorrect_)
622 searchEngine_.correct();
623 initDict(dict_,
false);
633 IOobjectList objects = preCheckFields(request);
635 const label nFields = selectedFieldNames_.size();
648 const coordSet&
s = gatheredSets_[seti];
650 if ((request & ACTION_WRITE) != 0)
652 coordSetWriter&
writer = writers_[seti];
676 writer.beginTime(mesh_.time());
683 performAction<VolumeField<scalar>>(objects, request);
684 performAction<VolumeField<vector>>(objects, request);
685 performAction<VolumeField<sphericalTensor>>(objects, request);
686 performAction<VolumeField<symmTensor>>(objects, request);
687 performAction<VolumeField<tensor>>(objects, request);
698 if ((request & ACTION_WRITE) != 0)
705 writers_[seti].endTime();
718 return performAction(ACTION_ALL & ~ACTION_WRITE);
727 return performAction(ACTION_ALL);
733 needsCorrect_ =
true;
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
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...
static autoPtr< sampledSet > New(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const dictionary &dict)
Return a reference to the selected sampledSet.
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
Same as found_if.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
Output to file stream, using an OSstream.
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.
static unsigned int defaultPrecision() noexcept
Return the default precision.
virtual bool read(const dictionary &)
Read the sampledSets.
Abstract base-class for Time/database function objects.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
GeometricField< sphericalTensor, fvPatchField, volMesh > volSphericalTensorField
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Macros for easy insertion into run-time selection tables.
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
static word suffix(const word &fldName, const word &fileExt=word::null)
Name suffix based on fieldName (underscore separator)
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 autoPtr< coordSetWriter > New(const word &writeFormat)
Return a reference to the selected writer.
Foam::word regionName(Foam::polyMesh::defaultRegion)
vectorField pointField
pointField is a vectorField.
#define doLocalCode(InputType)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
A class for handling words, derived from Foam::string.
static Istream & input(Istream &is, IntRange< T > &range)
#define forAllIters(container, iter)
Iterate across all elements in the container object.
void correct()
Correct for mesh changes.
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
bool verbose(const bool on) noexcept
Enable/disable verbose output.
static dictionary formatOptions(const dictionary &dict, const word &formatName, const word &entryName="formatOptions")
Same as fileFormats::getFormatOptions.
#define DebugInfo
Report an information message using Foam::Info.
virtual bool execute()
Execute, currently does nothing.
Istream and Ostream manipulators taking arguments.
int debug
Static debugging option.
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/chef2/andy/OpenFOAM/release/v2212/OpenFOAM-v2212/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0));alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
OBJstream os(runTime.globalPath()/outputName)
virtual bool open(const fileName &file, bool parallel=UPstream::parRun())
Open file for writing (creates parent directory).
defineTypeNameAndDebug(combustionModel, 0)
static bool clean(std::string &str)
Cleanup filename string, possibly applies other transformations such as changing the path separator e...
virtual const fileName & name() const
Read/write access to the name of the stream.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
List< word > wordList
A List of words.
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
virtual bool write()
Sample and write.
const polyMesh & mesh() const
Return polyMesh.
static bool master(const label communicator=worldComm)
Am I the master rank.
static word outputPrefix
Directory prefix.
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)
Omanip< int > setw(const int i)
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.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
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))
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.