The distributions have been extended in various ways to permit usage in a greater variety of situations... The distributions now have write methods which allow a distribution to be written into a field file for restart, therby permitting their usage in boundary conditions and similar. Their read methods now also support dimension-checked unit conversions for all their parameters. An additional selector has been added that allows a distribution to be re-constructed with a different sample size exponent. The distributions now own their random generator, thereby simplifying their usage and preventing the need for a (potentially dangling) reference member. This makes sense now as the random generators do not rely on global state; individual sub-models can and should own their own random generator and manage its initialisation and restart. This principle should be extended to other parts of the code in future.
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
IOdictionary pdfDictionary
|
|
(
|
|
IOobject
|
|
(
|
|
"pdfDict",
|
|
runTime.constant(),
|
|
runTime,
|
|
IOobject::MUST_READ_IF_MODIFIED,
|
|
IOobject::NO_WRITE
|
|
)
|
|
);
|
|
|
|
const label nIntervals(pdfDictionary.lookup<label>("nIntervals"));
|
|
|
|
const label nSamples(pdfDictionary.lookup<label>("nSamples"));
|
|
|
|
const bool writeData(readBool(pdfDictionary.lookup("writeData")));
|
|
|
|
const fileName pdfPath =
|
|
runTime.globalPath()
|
|
/functionObjects::writeFile::outputPrefix
|
|
/args.executable()
|
|
/runTime.name();
|
|
|
|
mkDir(pdfPath);
|
|
|
|
autoPtr<distribution> p(distribution::New(unitAny, pdfDictionary, 0, 0));
|
|
|
|
const scalar xMin = p->min();
|
|
const scalar xMax = p->max();
|
|
|
|
autoPtr<OFstream> filePtr(nullptr);
|
|
|
|
if (writeData)
|
|
{
|
|
fileName fName = pdfPath/(p->type() + ".data");
|
|
Info<< "Writing " << p->type() << " data samples to file:" << nl
|
|
<< fName << nl << endl;
|
|
|
|
filePtr.reset(new OFstream(fName));
|
|
}
|
|
|
|
scalarField samples(nIntervals, 0);
|