mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Tidying up and comments
This commit is contained in:
@ -45,17 +45,6 @@ Foam::Distribution<Type>::Distribution(const Type& binWidth)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// template<class Type>
|
|
||||||
// Foam::Distribution<Type>::Distribution
|
|
||||||
// (
|
|
||||||
// const cmptType& binWidth
|
|
||||||
// )
|
|
||||||
// :
|
|
||||||
// List< Map<scalar> >(pTraits<Type>::nComponents),
|
|
||||||
// binWidth_(binWidth*pTraits<Type>::one)
|
|
||||||
// {}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::Distribution<Type>::Distribution(const Distribution<Type>& d)
|
Foam::Distribution<Type>::Distribution(const Distribution<Type>& d)
|
||||||
:
|
:
|
||||||
@ -71,10 +60,6 @@ Foam::Distribution<Type>::~Distribution()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -133,8 +118,6 @@ inline Type Foam::Distribution<Type>::median()
|
|||||||
{
|
{
|
||||||
List< Pair<scalar> >& normDist = normDistribution[cmpt];
|
List< Pair<scalar> >& normDist = normDistribution[cmpt];
|
||||||
|
|
||||||
scalar cumulative = 0.0;
|
|
||||||
|
|
||||||
if (normDist.size())
|
if (normDist.size())
|
||||||
{
|
{
|
||||||
if (normDist.size() == 1)
|
if (normDist.size() == 1)
|
||||||
@ -164,6 +147,8 @@ inline Type Foam::Distribution<Type>::median()
|
|||||||
{
|
{
|
||||||
label lastNonZeroIndex = 0;
|
label lastNonZeroIndex = 0;
|
||||||
|
|
||||||
|
scalar cumulative = 0.0;
|
||||||
|
|
||||||
forAll(normDist,nD)
|
forAll(normDist,nD)
|
||||||
{
|
{
|
||||||
if
|
if
|
||||||
@ -188,7 +173,7 @@ inline Type Foam::Distribution<Type>::median()
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (normDist[nD].second() > 0.0)
|
else if (mag(normDist[nD].second()) > VSMALL)
|
||||||
{
|
{
|
||||||
cumulative +=
|
cumulative +=
|
||||||
normDist[nD].second()*component(binWidth_, cmpt);
|
normDist[nD].second()*component(binWidth_, cmpt);
|
||||||
@ -232,17 +217,6 @@ void Foam::Distribution<Type>::add
|
|||||||
{
|
{
|
||||||
cmptDistribution[n] += component(weight, cmpt);
|
cmptDistribution[n] += component(weight, cmpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (cmptDistribution[n] < 0)
|
|
||||||
// {
|
|
||||||
// FatalErrorIn("Distribution::add(const scalar valueToAdd)")
|
|
||||||
// << "Accumulated Distribution value has become negative: "
|
|
||||||
// << "bin = " << (0.5 + scalar(n))*component(binWidth_, cmpt)
|
|
||||||
// << ", value = " << cmptDistribution[n]
|
|
||||||
// << ". This is most likely to be because too many samples "
|
|
||||||
// << "have been added to a bin and the weight has 'rolled round'"
|
|
||||||
// << abort(FatalError);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,9 +81,6 @@ public:
|
|||||||
//- Construct from separate binWidth for each component
|
//- Construct from separate binWidth for each component
|
||||||
Distribution(const Type& binWidth);
|
Distribution(const Type& binWidth);
|
||||||
|
|
||||||
//- Construct from single binWidth for each component
|
|
||||||
// Distribution(const cmptType& binWidth);
|
|
||||||
|
|
||||||
//- Construct as copy
|
//- Construct as copy
|
||||||
Distribution(const Distribution& d);
|
Distribution(const Distribution& d);
|
||||||
|
|
||||||
@ -93,6 +90,8 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- Sum the total weight added to the component in the
|
||||||
|
// argument
|
||||||
scalar totalWeight(direction cmpt) const;
|
scalar totalWeight(direction cmpt) const;
|
||||||
|
|
||||||
Type mean() const;
|
Type mean() const;
|
||||||
@ -102,28 +101,31 @@ public:
|
|||||||
// variable where the cumulative Distribution = 0.5.
|
// variable where the cumulative Distribution = 0.5.
|
||||||
Type median();
|
Type median();
|
||||||
|
|
||||||
|
//- Add a value to the distribution, optionally specifying a weight
|
||||||
void add
|
void add
|
||||||
(
|
(
|
||||||
const Type& valueToAdd,
|
const Type& valueToAdd,
|
||||||
const Type& weight = pTraits<Type>::one
|
const Type& weight = pTraits<Type>::one
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Add the missing keys to the Maps to fill any gaps
|
||||||
void insertMissingKeys();
|
void insertMissingKeys();
|
||||||
|
|
||||||
|
//- Return the normalised distribution and bins
|
||||||
List< List<Pair<scalar> > > normalised();
|
List< List<Pair<scalar> > > normalised();
|
||||||
|
|
||||||
// List<Pair<scalar> > normalisedMinusMean();
|
//- Return the distribution of the total bin weights
|
||||||
|
|
||||||
// List<Pair<scalar> > normalisedShifted(scalar shift Value);
|
|
||||||
|
|
||||||
List< List < Pair<scalar> > > raw();
|
List< List < Pair<scalar> > > raw();
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
|
//- Return the bin width
|
||||||
inline const Type& binWidth() const;
|
inline const Type& binWidth() const;
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
|
//- Write the distribution to file. Produces a separate file
|
||||||
|
// for each component.
|
||||||
void write
|
void write
|
||||||
(
|
(
|
||||||
const fileName& filePrefix,
|
const fileName& filePrefix,
|
||||||
|
|||||||
Reference in New Issue
Block a user