mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
MRG: merged develop line back into integration branch
This commit is contained in:
@ -178,7 +178,7 @@ bool Foam::functionObjects::ddt2::execute()
|
||||
{
|
||||
results_.clear();
|
||||
|
||||
wordHashSet candidates = subsetStrings(selectFields_, mesh_.names());
|
||||
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names()));
|
||||
DynamicList<word> missing(selectFields_.size());
|
||||
DynamicList<word> ignored(selectFields_.size());
|
||||
|
||||
|
||||
@ -71,7 +71,6 @@ SourceFiles
|
||||
#include "surfaceFieldsFwd.H"
|
||||
#include "vectorList.H"
|
||||
#include "globalIndex.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "eulerianParticle.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "injectedParticleCloud.H"
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -45,23 +45,31 @@ void Foam::functionObjects::histogram::writeGraph
|
||||
(
|
||||
const coordSet& coords,
|
||||
const word& fieldName,
|
||||
const scalarField& values
|
||||
const scalarField& normalizedValues,
|
||||
const scalarField& absoluteValues
|
||||
) const
|
||||
{
|
||||
const wordList fieldNames(1, fieldName);
|
||||
|
||||
fileName outputPath = baseTimeDir();
|
||||
mkDir(outputPath);
|
||||
OFstream graphFile
|
||||
(
|
||||
outputPath/formatterPtr_().getFileName(coords, fieldNames)
|
||||
outputPath
|
||||
/formatterPtr_().getFileName
|
||||
(
|
||||
coords,
|
||||
wordList(1, fieldName)
|
||||
)
|
||||
);
|
||||
|
||||
Log << " Writing histogram of " << fieldName
|
||||
<< " to " << graphFile.name() << endl;
|
||||
|
||||
List<const scalarField*> yPtrs(1);
|
||||
yPtrs[0] = &values;
|
||||
wordList fieldNames(2);
|
||||
fieldNames[0] = fieldName;
|
||||
fieldNames[1] = fieldName + "Count";
|
||||
List<const scalarField*> yPtrs(2);
|
||||
yPtrs[0] = &normalizedValues;
|
||||
yPtrs[1] = &absoluteValues;
|
||||
formatterPtr_().write(coords, fieldNames, yPtrs, graphFile);
|
||||
}
|
||||
|
||||
@ -76,7 +84,9 @@ Foam::functionObjects::histogram::histogram
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(obr_, name)
|
||||
writeFile(obr_, name),
|
||||
max_(-GREAT),
|
||||
min_(GREAT)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -96,8 +106,9 @@ bool Foam::functionObjects::histogram::read(const dictionary& dict)
|
||||
writeFile::read(dict);
|
||||
|
||||
dict.lookup("field") >> fieldName_;
|
||||
dict.lookup("max") >> max_;
|
||||
min_ = dict.lookupOrDefault<scalar>("min", 0);
|
||||
|
||||
max_ = dict.lookupOrDefault<scalar>("max", -GREAT);
|
||||
min_ = dict.lookupOrDefault<scalar>("min", GREAT);
|
||||
dict.lookup("nBins") >> nBins_;
|
||||
|
||||
word format(dict.lookup("setFormat"));
|
||||
@ -149,38 +160,63 @@ bool Foam::functionObjects::histogram::write()
|
||||
: obr_.lookupObject<volScalarField>(fieldName_)
|
||||
);
|
||||
|
||||
|
||||
scalar histMax = max_;
|
||||
scalar histMin = min_;
|
||||
|
||||
if (max_ == -GREAT)
|
||||
{
|
||||
// Determine current min and max
|
||||
histMax = max(field).value();
|
||||
|
||||
if (min_ == GREAT)
|
||||
{
|
||||
histMin = min(field).value();
|
||||
}
|
||||
Log << " Determined histogram bounds from field"
|
||||
<< " min/max(" << fieldName_ << ") = "
|
||||
<< histMin << ' ' << histMax << endl;
|
||||
}
|
||||
else if (min_ == GREAT)
|
||||
{
|
||||
histMin = 0;
|
||||
}
|
||||
|
||||
// Calculate the mid-points of bins for the graph axis
|
||||
pointField xBin(nBins_);
|
||||
const scalar delta = (max_- min_)/nBins_;
|
||||
const scalar delta = (histMax- histMin)/nBins_;
|
||||
|
||||
scalar x = min_ + 0.5*delta;
|
||||
scalar x = histMin + 0.5*delta;
|
||||
forAll(xBin, i)
|
||||
{
|
||||
xBin[i] = point(x, 0, 0);
|
||||
x += delta;
|
||||
}
|
||||
|
||||
scalarField data(nBins_, 0);
|
||||
scalarField dataNormalized(nBins_, 0);
|
||||
labelField dataCount(nBins_, 0);
|
||||
const scalarField& V = mesh_.V();
|
||||
|
||||
forAll(field, celli)
|
||||
{
|
||||
const label bini = (field[celli] - min_)/delta;
|
||||
const label bini = (field[celli] - histMin)/delta;
|
||||
if (bini >= 0 && bini < nBins_)
|
||||
{
|
||||
data[bini] += V[celli];
|
||||
dataNormalized[bini] += V[celli];
|
||||
dataCount[bini]++;
|
||||
}
|
||||
}
|
||||
|
||||
Pstream::listCombineGather(data, plusEqOp<scalar>());
|
||||
Pstream::listCombineGather(dataNormalized, plusEqOp<scalar>());
|
||||
Pstream::listCombineGather(dataCount, plusEqOp<label>());
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
const scalar sumData = sum(data);
|
||||
const scalar sumData = sum(dataNormalized);
|
||||
|
||||
if (sumData > SMALL)
|
||||
{
|
||||
data /= sumData;
|
||||
dataNormalized /= sumData;
|
||||
|
||||
const coordSet coords
|
||||
(
|
||||
@ -190,7 +226,15 @@ bool Foam::functionObjects::histogram::write()
|
||||
mag(xBin)
|
||||
);
|
||||
|
||||
writeGraph(coords, fieldName_, data);
|
||||
|
||||
// Convert count field from labelField to scalarField
|
||||
scalarField count(dataCount.size());
|
||||
forAll(count, i)
|
||||
{
|
||||
count[i] = 1.0*dataCount[i];
|
||||
}
|
||||
|
||||
writeGraph(coords, fieldName_, dataNormalized, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -53,7 +53,7 @@ Usage
|
||||
type | type name: histogram | yes |
|
||||
field | Field to analyse | yes |
|
||||
nBins | Number of bins for the histogram | yes|
|
||||
max | Maximum value sampled | yes |
|
||||
max | Maximum value sampled | no | field max
|
||||
min | minimum value sampled | no | 0
|
||||
setFormat | Output format | yes |
|
||||
\endtable
|
||||
@ -115,7 +115,8 @@ class histogram
|
||||
(
|
||||
const coordSet& coords,
|
||||
const word& valueName,
|
||||
const scalarField& values
|
||||
const scalarField& normalizedValues,
|
||||
const scalarField& absoluteValues
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
|
||||
@ -61,7 +61,7 @@ Foam::functionObjects::particleDistribution::particleDistribution
|
||||
cloudName_("unknown-cloudName"),
|
||||
nameVsBinWidth_(),
|
||||
tagFieldName_("none"),
|
||||
rndGen_(1234, -1),
|
||||
rndGen_(),
|
||||
writerPtr_(nullptr)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
@ -73,7 +73,7 @@ SourceFiles
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "scalarField.H"
|
||||
#include "cachedRandom.H"
|
||||
#include "Random.H"
|
||||
#include "Tuple2.H"
|
||||
#include "writer.H"
|
||||
|
||||
@ -107,7 +107,7 @@ protected:
|
||||
word tagFieldName_;
|
||||
|
||||
//- Random number generator - used by distribution models
|
||||
cachedRandom rndGen_;
|
||||
Random rndGen_;
|
||||
|
||||
//- Writer
|
||||
autoPtr<writer<scalar>> writerPtr_;
|
||||
|
||||
@ -47,7 +47,7 @@ bool Foam::functionObjects::randomise::calcRandomised()
|
||||
forAll(field, celli)
|
||||
{
|
||||
Type rndPert;
|
||||
rand.randomise(rndPert);
|
||||
rand.randomise01(rndPert);
|
||||
rndPert = 2.0*rndPert - pTraits<Type>::one;
|
||||
rndPert /= mag(rndPert);
|
||||
rfield[celli] += magPerturbation_*rndPert;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -50,9 +50,15 @@ Foam::functionObjects::readFields::readFields
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_()
|
||||
fieldSet_(),
|
||||
readOnStart_(true)
|
||||
{
|
||||
read(dict);
|
||||
|
||||
if (readOnStart_)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,6 +75,7 @@ bool Foam::functionObjects::readFields::read(const dictionary& dict)
|
||||
fvMeshFunctionObject::read(dict);
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
dict.readIfPresent("readOnStart", readOnStart_);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,6 +48,7 @@ Usage
|
||||
Property | Description | Required | Default value
|
||||
type | type name: readFields | yes |
|
||||
fields | list of fields to read | no |
|
||||
readOnStart | flag to start reading on start-up | no | yes
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
@ -88,6 +89,9 @@ protected:
|
||||
//- Fields to load
|
||||
wordList fieldSet_;
|
||||
|
||||
//- Flag to read on construction
|
||||
bool readOnStart_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ bool Foam::functionObjects::zeroGradient::execute()
|
||||
{
|
||||
results_.clear();
|
||||
|
||||
wordHashSet candidates = subsetStrings(selectFields_, mesh_.names());
|
||||
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names()));
|
||||
DynamicList<word> missing(selectFields_.size());
|
||||
DynamicList<word> ignored(selectFields_.size());
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@ include_directories(
|
||||
|
||||
link_directories(
|
||||
$ENV{FOAM_LIBBIN}
|
||||
$ENV{FOAM_EXT_LIBBIN}
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
|
||||
@ -131,6 +131,21 @@ void Foam::functionObjects::runTimePostPro::scene::readColours
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimePostPro::scene::setActorVisibility
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
const bool visible
|
||||
) const
|
||||
{
|
||||
vtkActorCollection *actors = renderer->GetActors();
|
||||
for (int i = 0; i < actors->GetNumberOfItems(); ++i)
|
||||
{
|
||||
vtkActor *actor = vtkActor::SafeDownCast(actors->GetItemAsObject(i));
|
||||
actor->SetVisibility(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::runTimePostPro::scene::initialise
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
@ -239,9 +254,13 @@ void Foam::functionObjects::runTimePostPro::scene::setCamera
|
||||
// to be done once on initialisation
|
||||
if (!clipBox_.empty())
|
||||
{
|
||||
// Call ResetCamera() to fit clip box in view
|
||||
setActorVisibility(renderer, false);
|
||||
clipBoxActor_->VisibilityOn();
|
||||
|
||||
// Call ResetCamera() to fit clip box in view
|
||||
renderer->ResetCamera();
|
||||
|
||||
setActorVisibility(renderer, true);
|
||||
clipBoxActor_->VisibilityOff();
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -105,6 +105,13 @@ class scene
|
||||
//- Read colour properties
|
||||
void readColours(const dictionary& dict);
|
||||
|
||||
//- Set visibility of all actors on/off
|
||||
void setActorVisibility
|
||||
(
|
||||
vtkRenderer* renderer,
|
||||
const bool visible
|
||||
) const;
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
scene(const scene&);
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ bool Foam::functionObjects::ensightWrite::write()
|
||||
ensCase().setTime(t.value(), t.timeIndex());
|
||||
}
|
||||
|
||||
wordHashSet candidates = subsetStrings(selectFields_, mesh_.names());
|
||||
wordHashSet candidates(subsetStrings(selectFields_, mesh_.names()));
|
||||
DynamicList<word> missing(selectFields_.size());
|
||||
DynamicList<word> ignored(selectFields_.size());
|
||||
|
||||
|
||||
@ -48,11 +48,10 @@ namespace functionObjects
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::timeActivatedFileUpdate::updateFile
|
||||
(
|
||||
const bool checkFiles
|
||||
)
|
||||
void Foam::functionObjects::timeActivatedFileUpdate::updateFile()
|
||||
{
|
||||
modified_ = false;
|
||||
|
||||
label i = lastIndex_;
|
||||
while
|
||||
(
|
||||
@ -68,19 +67,15 @@ void Foam::functionObjects::timeActivatedFileUpdate::updateFile
|
||||
Log << nl << type() << ": copying file" << nl << timeVsFile_[i].second()
|
||||
<< nl << "to:" << nl << fileToUpdate_ << nl << endl;
|
||||
|
||||
fileName destFile(fileToUpdate_ + Foam::name(pid()));
|
||||
cp(timeVsFile_[i].second(), destFile);
|
||||
mv(destFile, fileToUpdate_);
|
||||
lastIndex_ = i;
|
||||
|
||||
if (checkFiles)
|
||||
if (Pstream::master() || time_.distributed())
|
||||
{
|
||||
// Do an early check to avoid an additional iteration before
|
||||
// any changes are picked up (see Time::run : does readModified
|
||||
// before executing FOs). Note we have to protect the read
|
||||
// constructor of *this from triggering this behaviour.
|
||||
const_cast<Time&>(time_).Time::readModifiedObjects();
|
||||
// Slaves do not copy if running non-distributed
|
||||
fileName destFile(fileToUpdate_ + Foam::name(pid()));
|
||||
cp(timeVsFile_[i].second(), destFile);
|
||||
mv(destFile, fileToUpdate_);
|
||||
}
|
||||
lastIndex_ = i;
|
||||
modified_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +93,8 @@ Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate
|
||||
time_(runTime),
|
||||
fileToUpdate_("unknown-fileToUpdate"),
|
||||
timeVsFile_(),
|
||||
lastIndex_(-1)
|
||||
lastIndex_(-1),
|
||||
modified_(false)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -142,8 +138,8 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
|
||||
<< timeVsFile_[i].second() << endl;
|
||||
}
|
||||
|
||||
// Copy starting files. Avoid recursion by not checking for modified files.
|
||||
updateFile(false);
|
||||
// Copy starting files
|
||||
updateFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -151,7 +147,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
|
||||
|
||||
bool Foam::functionObjects::timeActivatedFileUpdate::execute()
|
||||
{
|
||||
updateFile(true);
|
||||
updateFile();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -163,4 +159,10 @@ bool Foam::functionObjects::timeActivatedFileUpdate::write()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::timeActivatedFileUpdate::filesModified() const
|
||||
{
|
||||
return modified_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -106,11 +106,14 @@ class timeActivatedFileUpdate
|
||||
//- Index of last file copied
|
||||
label lastIndex_;
|
||||
|
||||
//- Has anything been copied?
|
||||
bool modified_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Update file
|
||||
void updateFile(const bool checkFiles);
|
||||
void updateFile();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
timeActivatedFileUpdate(const timeActivatedFileUpdate&);
|
||||
@ -150,6 +153,9 @@ public:
|
||||
|
||||
//- Do nothing
|
||||
virtual bool write();
|
||||
|
||||
//- Did any file get changed during execution?
|
||||
virtual bool filesModified() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user