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_.resize_null(localSets.size());
159 gatheredSorting_.resize_nocopy(localSets.size());
160 globalIndices_.resize_nocopy(localSets.size());
164 const coordSet& coords = localSets[seti];
166 globalIndices_[seti].reset(globalIndex::gatherOnly{}, coords.size());
167 gatheredSets_.set(seti, coords.gatherSort(gatheredSorting_[seti]));
175 HashTable<wordHashSet> selected;
177 IOobjectList objects;
182 objects = IOobjectList(mesh_, mesh_.time().timeName());
184 allFields = objects.names();
185 selected = objects.classes(fieldSelection_);
190 allFields = mesh_.names();
191 selected = mesh_.classes(fieldSelection_);
199 DynamicList<label> missed(fieldSelection_.size());
202 forAll(fieldSelection_, i)
206 fieldSelection_[i].isLiteral()
214 if (missed.size() && (request != ACTION_NONE))
219 << (loadFromFiles_ ?
"field file" :
"registered field")
221 << UIndirectList<wordRe>(fieldSelection_, missed) <<
endl;
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)
276 coordSetWriter&
writer = writers_[seti];
286 void Foam::sampledSets::initDict(
const dictionary&
dict,
const bool initial)
296 if (eptr && eptr->isDict())
298 PtrList<sampledSet> sampSets(eptr->dict().size());
299 if (initial && !writeAsProbes_)
301 writers_.resize(sampSets.size());
306 for (
const entry& dEntry : eptr->dict())
308 if (!dEntry.isDict())
315 autoPtr<sampledSet> sampSet =
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);
353 static_cast<PtrList<sampledSet>&
>(*this).transfer(sampSets);
360 DynamicList<dictionary> capture;
362 PtrList<sampledSet>
input 365 sampledSet::iNewCapture(mesh_, searchEngine_, capture)
368 PtrList<sampledSet> sampSets(
input.size());
369 if (initial && !writeAsProbes_)
371 writers_.resize(sampSets.size());
380 autoPtr<sampledSet> sampSet =
input.release(inputi);
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);
412 static_cast<PtrList<sampledSet>&
>(*this).transfer(sampSets);
417 needsCorrect_ =
false;
423 Foam::sampledSets::sampledSets
433 loadFromFiles_(false),
436 needsCorrect_(false),
437 writeAsProbes_(false),
443 searchEngine_(mesh_),
444 samplePointScheme_(),
446 selectedFieldNames_(),
459 Foam::sampledSets::sampledSets
464 const bool loadFromFiles
467 functionObjects::fvMeshFunctionObject(
name, obr,
dict),
470 loadFromFiles_(loadFromFiles),
473 needsCorrect_(false),
474 writeAsProbes_(false),
480 searchEngine_(mesh_),
481 samplePointScheme_(),
483 selectedFieldNames_(),
518 fieldSelection_.clear();
519 selectedFieldNames_.clear();
521 gatheredSets_.clear();
522 gatheredSorting_.clear();
523 globalIndices_.clear();
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;
562 const sampledSet&
s = (*this)[seti];
563 Info<<
" " <<
s.name();
569 Info<<
"Sampled set:" <<
nl;
573 const sampledSet&
s = (*this)[seti];
575 Info<<
" " <<
s.name() <<
" -> " 576 << writers_[seti].type() <<
nl;
586 <<
"sample sets:" <<
nl <<
'(' <<
nl;
591 :
static_cast<const PtrList<sampledSet>&
>(*
this)
601 (void) preCheckFields(ACTION_NONE);
612 bool Foam::sampledSets::performAction(
unsigned request)
619 else if (needsCorrect_)
621 searchEngine_.correct();
622 initDict(dict_,
false);
632 IOobjectList objects = preCheckFields(request);
634 const label nFields = selectedFieldNames_.size();
647 const coordSet&
s = gatheredSets_[seti];
649 if ((request & ACTION_WRITE) != 0)
651 coordSetWriter&
writer = writers_[seti];
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;
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
const polyMesh & mesh() const noexcept
Return polyMesh.
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.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/"finiteArea-edgesCentres"))
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.
virtual const fileName & name() const override
Read/write access to the name of the stream.
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 as an OSstream, normally using std::ofstream for the actual output...
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
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 expressions::valueTypeCode::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.
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/v2406/OpenFOAM-v2406/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=clamp((rho - rholSat)/(rhovSat - rholSat), zero_one{});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...
List< word > wordList
List of word.
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.
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
virtual bool write()
Sample and write.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
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.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.