diff --git a/src/lagrangian/distributionModels/RosinRammler/RosinRammler.C b/src/lagrangian/distributionModels/RosinRammler/RosinRammler.C index 24ffc4d895..f30a2c66e1 100644 --- a/src/lagrangian/distributionModels/RosinRammler/RosinRammler.C +++ b/src/lagrangian/distributionModels/RosinRammler/RosinRammler.C @@ -84,12 +84,6 @@ Foam::distributionModels::RosinRammler::RosinRammler(const RosinRammler& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::RosinRammler::~RosinRammler() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::RosinRammler::sample() const diff --git a/src/lagrangian/distributionModels/RosinRammler/RosinRammler.H b/src/lagrangian/distributionModels/RosinRammler/RosinRammler.H index bf69d38d96..d648fed8c5 100644 --- a/src/lagrangian/distributionModels/RosinRammler/RosinRammler.H +++ b/src/lagrangian/distributionModels/RosinRammler/RosinRammler.H @@ -83,7 +83,7 @@ public: //- Construct from components RosinRammler(const dictionary& dict, Random& rndGen); - //- Construct copy + //- Copy construct RosinRammler(const RosinRammler& p); //- Construct and return a clone @@ -92,17 +92,20 @@ public: return autoPtr(new RosinRammler(*this)); } + //- No copy assignment + void operator=(const RosinRammler&) = delete; + //- Destructor - virtual ~RosinRammler(); + virtual ~RosinRammler() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the theoretical mean of the distribution virtual scalar meanValue() const; }; diff --git a/src/lagrangian/distributionModels/binned/binned.C b/src/lagrangian/distributionModels/binned/binned.C index f740cdd30c..36d7370387 100644 --- a/src/lagrangian/distributionModels/binned/binned.C +++ b/src/lagrangian/distributionModels/binned/binned.C @@ -32,11 +32,11 @@ License namespace Foam { - namespace distributionModels - { - defineTypeNameAndDebug(binned, 0); - addToRunTimeSelectionTable(distributionModel, binned, dictionary); - } +namespace distributionModels +{ + defineTypeNameAndDebug(binned, 0); + addToRunTimeSelectionTable(distributionModel, binned, dictionary); +} } @@ -183,27 +183,21 @@ Foam::distributionModels::binned::binned(const binned& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::binned::~binned() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::binned::sample() const { - scalar y = rndGen_.sample01(); + const scalar u = rndGen_.sample01(); for (label i = 0; i < xy_.size() - 1; ++i) { - if (xy_[i][1] > y) + if (xy_[i][1] > u) { return xy_[i][0]; } } - return xy_.last()[0]; + return maxValue_; } diff --git a/src/lagrangian/distributionModels/binned/binned.H b/src/lagrangian/distributionModels/binned/binned.H index 83277e8c65..cca73c2491 100644 --- a/src/lagrangian/distributionModels/binned/binned.H +++ b/src/lagrangian/distributionModels/binned/binned.H @@ -70,18 +70,18 @@ class binned : public distributionModel { - // Private data + typedef VectorSpace, scalar, 2> pair; - typedef VectorSpace, scalar, 2> pair; + // Private Data - // List of (bin probability) + // List of (bin probability) pairs List xy_; - //- Distribution mean value + //- Mean of the distribution scalar meanValue_; - // Private member functions + // Private Member Functions //- Initialise the distribution parameters void initialise(); @@ -101,6 +101,7 @@ public: binned(const dictionary& dict, Random& rndGen); //- Construct from components + // Allows negative entries binned ( const UList& sampleData, @@ -108,7 +109,7 @@ public: Random& rndGen ); - //- Construct copy + //- Copy construct binned(const binned& p); //- Construct and return a clone @@ -117,17 +118,20 @@ public: return autoPtr(new binned(*this)); } + //- No copy assignment + void operator=(const binned&) = delete; + //- Destructor - virtual ~binned(); + virtual ~binned() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the arithmetic mean of the distribution data virtual scalar meanValue() const; //- Write data to stream diff --git a/src/lagrangian/distributionModels/distributionModel/distributionModel.C b/src/lagrangian/distributionModels/distributionModel/distributionModel.C index e3b72fb9b4..93d13e802a 100644 --- a/src/lagrangian/distributionModels/distributionModel/distributionModel.C +++ b/src/lagrangian/distributionModels/distributionModel/distributionModel.C @@ -100,12 +100,6 @@ Foam::distributionModel::distributionModel {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModel::~distributionModel() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModel::minValue() const diff --git a/src/lagrangian/distributionModels/distributionModel/distributionModel.H b/src/lagrangian/distributionModels/distributionModel/distributionModel.H index c827e08a80..1841df1f49 100644 --- a/src/lagrangian/distributionModels/distributionModel/distributionModel.H +++ b/src/lagrangian/distributionModels/distributionModel/distributionModel.H @@ -71,10 +71,9 @@ namespace Foam class distributionModel { - protected: - // Protected data + // Protected Data //- Coefficients dictionary const dictionary distributionModelDict_; @@ -125,7 +124,7 @@ public: Random& rndGen ); - //- Construct copy + //- Copy construct distributionModel(const distributionModel& p); //- Construct and return a clone @@ -141,12 +140,12 @@ public: //- Destructor - virtual ~distributionModel(); + virtual ~distributionModel() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const = 0; //- Return the minimum of the distribution @@ -155,7 +154,8 @@ public: //- Return the maximum of the distribution virtual scalar maxValue() const; - //- Return the maximum value + //- Return the theoretical mean of the distribution, or + //- the arithmetic mean of the distribution data virtual scalar meanValue() const = 0; }; diff --git a/src/lagrangian/distributionModels/exponential/exponential.C b/src/lagrangian/distributionModels/exponential/exponential.C index 8479f48d16..96d3df2c15 100644 --- a/src/lagrangian/distributionModels/exponential/exponential.C +++ b/src/lagrangian/distributionModels/exponential/exponential.C @@ -70,25 +70,20 @@ Foam::distributionModels::exponential::exponential(const exponential& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::exponential::~exponential() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::exponential::sample() const { - scalar y = rndGen_.sample01(); - scalar K = exp(-lambda_*maxValue_) - exp(-lambda_*minValue_); - return -(1.0/lambda_)*log(exp(-lambda_*minValue_) + y*K); + const scalar u = rndGen_.sample01(); + const scalar qMin = exp(-lambda_*minValue_); + const scalar qMax = exp(-lambda_*maxValue_); + return -(scalar(1)/lambda_)*log(qMin + u*(qMax - qMin)); } Foam::scalar Foam::distributionModels::exponential::meanValue() const { - return 1.0/lambda_; + return scalar(1)/lambda_; } diff --git a/src/lagrangian/distributionModels/exponential/exponential.H b/src/lagrangian/distributionModels/exponential/exponential.H index cba36e9672..253c94ae93 100644 --- a/src/lagrangian/distributionModels/exponential/exponential.H +++ b/src/lagrangian/distributionModels/exponential/exponential.H @@ -55,11 +55,10 @@ class exponential : public distributionModel { - // Private data + // Private Data - // Model coefficients - - scalar lambda_; + //- Rate parameter + scalar lambda_; public: @@ -73,7 +72,7 @@ public: //- Construct from components exponential(const dictionary& dict, Random& rndGen); - //- Construct copy + //- Copy construct exponential(const exponential& p); //- Construct and return a clone @@ -82,17 +81,20 @@ public: return autoPtr(new exponential(*this)); } + //- No copy assignment + void operator=(const exponential&) = delete; + //- Destructor - virtual ~exponential(); + virtual ~exponential() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the theoretical mean of the distribution virtual scalar meanValue() const; }; diff --git a/src/lagrangian/distributionModels/fixedValue/fixedValue.C b/src/lagrangian/distributionModels/fixedValue/fixedValue.C index 5e620be98d..9cc2f8dbb3 100644 --- a/src/lagrangian/distributionModels/fixedValue/fixedValue.C +++ b/src/lagrangian/distributionModels/fixedValue/fixedValue.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -67,12 +68,6 @@ Foam::distributionModels::fixedValue::fixedValue(const fixedValue& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::fixedValue::~fixedValue() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::fixedValue::fixedValue::sample() const diff --git a/src/lagrangian/distributionModels/fixedValue/fixedValue.H b/src/lagrangian/distributionModels/fixedValue/fixedValue.H index 9b07b2670e..2ca64157b1 100644 --- a/src/lagrangian/distributionModels/fixedValue/fixedValue.H +++ b/src/lagrangian/distributionModels/fixedValue/fixedValue.H @@ -53,9 +53,9 @@ class fixedValue : public distributionModel { - // Private data + // Private Data - //- Fixed value + //- Fixed value for size scalar value_; @@ -70,7 +70,7 @@ public: //- Construct from components fixedValue(const dictionary& dict, Random& rndGen); - //- Construct copy + //- Copy construct fixedValue(const fixedValue& p); //- Construct and return a clone @@ -79,23 +79,26 @@ public: return autoPtr(new fixedValue(*this)); } + //- No copy assignment + void operator=(const fixedValue&) = delete; + //- Destructor - virtual ~fixedValue(); + virtual ~fixedValue() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the minimum value + //- Return the minimum of the distribution virtual scalar minValue() const; - //- Return the maximum value + //- Return the maximum of the distribution virtual scalar maxValue() const; - //- Return the mean value + //- Return the theoretical mean of the distribution virtual scalar meanValue() const; }; diff --git a/src/lagrangian/distributionModels/general/general.C b/src/lagrangian/distributionModels/general/general.C index de3a04c25e..e37eabd2de 100644 --- a/src/lagrangian/distributionModels/general/general.C +++ b/src/lagrangian/distributionModels/general/general.C @@ -162,55 +162,45 @@ Foam::distributionModels::general::general(const general& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::general::~general() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::general::sample() const { - scalar y = rndGen_.sample01(); + const scalar u = rndGen_.sample01(); - // Find the interval where y is in the table + // Find the interval where u is in the table label n = 1; - while (integral_[n] <= y) + while (integral_[n] <= u) { n++; } - scalar k = (xy_[n][1] - xy_[n-1][1])/(xy_[n][0] - xy_[n-1][0]); - scalar d = xy_[n-1][1] - k*xy_[n-1][0]; + const scalar k = (xy_[n][1] - xy_[n-1][1])/(xy_[n][0] - xy_[n-1][0]); + const scalar d = xy_[n-1][1] - k*xy_[n-1][0]; - scalar alpha = y + xy_[n-1][0]*(0.5*k*xy_[n-1][0] + d) - integral_[n-1]; - scalar x = 0.0; + const scalar alpha = + u + xy_[n-1][0]*(0.5*k*xy_[n-1][0] + d) - integral_[n-1]; // If k is small it is a linear equation, otherwise it is of second order if (mag(k) > SMALL) { - scalar p = 2.0*d/k; - scalar q = -2.0*alpha/k; - scalar sqrtEr = sqrt(0.25*p*p - q); + const scalar p = 2.0*d/k; + const scalar q = -2.0*alpha/k; + const scalar sqrtEr = sqrt(0.25*p*p - q); - scalar x1 = -0.5*p + sqrtEr; - scalar x2 = -0.5*p - sqrtEr; + const scalar x1 = -0.5*p + sqrtEr; + const scalar x2 = -0.5*p - sqrtEr; if ((x1 >= xy_[n-1][0]) && (x1 <= xy_[n][0])) { - x = x1; + return x1; } else { - x = x2; + return x2; } } - else - { - x = alpha/d; - } - return x; + return alpha/d; } @@ -269,11 +259,11 @@ void Foam::distributionModels::general::readDict(const dictionary& dict) Foam::tmp> Foam::distributionModels::general::x() const { - tmp> tx(new Field(xy_.size())); - scalarField& xi = tx.ref(); + auto tx = tmp::New(xy_.size()); + auto& x = tx.ref(); forAll(xy_, i) { - xi[i] = xy_[i][0]; + x[i] = xy_[i][0]; } return tx; @@ -283,11 +273,11 @@ Foam::distributionModels::general::x() const Foam::tmp> Foam::distributionModels::general::y() const { - tmp> ty(new Field(xy_.size())); - scalarField& yi = ty.ref(); + auto ty = tmp::New(xy_.size()); + auto& y = ty.ref(); forAll(xy_, i) { - yi[i] = xy_[i][1]; + y[i] = xy_[i][1]; } return ty; diff --git a/src/lagrangian/distributionModels/general/general.H b/src/lagrangian/distributionModels/general/general.H index 3c15263787..7501b1a8b3 100644 --- a/src/lagrangian/distributionModels/general/general.H +++ b/src/lagrangian/distributionModels/general/general.H @@ -65,26 +65,29 @@ namespace distributionModels { /*---------------------------------------------------------------------------*\ - Class general Declaration + Class general Declaration \*---------------------------------------------------------------------------*/ class general : public distributionModel { - // Private data + typedef VectorSpace, scalar, 2> pair; - typedef VectorSpace, scalar, 2> pair; + // Private Data - // List of (bin probability) + //- List of (x, y=f(x)) pairs List xy_; + //- Mean of the distribution scalar meanValue_; + //- Values of cumulative distribution function List integral_; - // Private member functions + + // Private Member Functions //- Initialise the distribution parameters void initialise(); @@ -102,6 +105,7 @@ public: general(const dictionary& dict, Random& rndGen); //- Construct from components + // Allows negative entries general ( const UList& sampleData, @@ -109,7 +113,7 @@ public: Random& rndGen ); - //- Construct copy + //- Copy construct general(const general& p); //- Construct and return a clone @@ -118,23 +122,26 @@ public: return autoPtr(new general(*this)); } + //- No copy assignment + void operator=(const general&) = delete; + //- Destructor - virtual ~general(); + virtual ~general() = default; // Member Functions //- Bin boundaries - virtual tmp> x() const; + virtual tmp x() const; //- Probabilities - virtual tmp> y() const; + virtual tmp y() const; - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the arithmetic mean of the distribution data virtual scalar meanValue() const; //- Write data to stream diff --git a/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.C b/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.C index 48a8092333..a2a0dff8b5 100644 --- a/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.C +++ b/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.C @@ -77,12 +77,6 @@ Foam::distributionModels::massRosinRammler::massRosinRammler {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::massRosinRammler::~massRosinRammler() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::massRosinRammler::sample() const diff --git a/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.H b/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.H index bfcb4dc45f..0df4d00027 100644 --- a/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.H +++ b/src/lagrangian/distributionModels/massRosinRammler/massRosinRammler.H @@ -71,13 +71,12 @@ class massRosinRammler : public distributionModel { - // Private data + // Private Data - //- Characteristic droplet size + //- Scale parameter scalar d_; - //- Empirical dimensionless constant to specify the distribution width, - // sometimes referred to as the dispersion coefficient + //- Shape parameter scalar n_; @@ -92,7 +91,7 @@ public: //- Construct from components massRosinRammler(const dictionary& dict, Random& rndGen); - //- Construct copy + //- Copy construct massRosinRammler(const massRosinRammler& p); //- Construct and return a clone @@ -101,17 +100,20 @@ public: return autoPtr(new massRosinRammler(*this)); } + //- No copy assignment + void operator=(const massRosinRammler&) = delete; + //- Destructor - virtual ~massRosinRammler(); + virtual ~massRosinRammler() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the theoretical mean of the distribution virtual scalar meanValue() const; }; diff --git a/src/lagrangian/distributionModels/multiNormal/multiNormal.C b/src/lagrangian/distributionModels/multiNormal/multiNormal.C index 7879a34ac9..bb5b9ee3f2 100644 --- a/src/lagrangian/distributionModels/multiNormal/multiNormal.C +++ b/src/lagrangian/distributionModels/multiNormal/multiNormal.C @@ -92,12 +92,6 @@ Foam::distributionModels::multiNormal::multiNormal(const multiNormal& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::multiNormal::~multiNormal() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::multiNormal::sample() const diff --git a/src/lagrangian/distributionModels/multiNormal/multiNormal.H b/src/lagrangian/distributionModels/multiNormal/multiNormal.H index 8387ecdde5..9db7445fba 100644 --- a/src/lagrangian/distributionModels/multiNormal/multiNormal.H +++ b/src/lagrangian/distributionModels/multiNormal/multiNormal.H @@ -60,7 +60,7 @@ class multiNormal : public distributionModel { - // Private data + // Private Data //- Distribution range scalar range_; @@ -84,7 +84,7 @@ public: //- Construct from components multiNormal(const dictionary& dict, Random& rndGen); - //- Construct copy + //- Copy construct multiNormal(const multiNormal& p); //- Construct and return a clone @@ -93,17 +93,20 @@ public: return autoPtr(new multiNormal(*this)); } + //- No copy assignment + void operator=(const multiNormal&) = delete; + //- Destructor - virtual ~multiNormal(); + virtual ~multiNormal() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the theoretical mean of the distribution virtual scalar meanValue() const; }; diff --git a/src/lagrangian/distributionModels/normal/normal.C b/src/lagrangian/distributionModels/normal/normal.C index 9081093488..141b63d53b 100644 --- a/src/lagrangian/distributionModels/normal/normal.C +++ b/src/lagrangian/distributionModels/normal/normal.C @@ -75,12 +75,6 @@ Foam::distributionModels::normal::normal(const normal& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::normal::~normal() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::normal::sample() const diff --git a/src/lagrangian/distributionModels/normal/normal.H b/src/lagrangian/distributionModels/normal/normal.H index f1d2c21def..5d692e5903 100644 --- a/src/lagrangian/distributionModels/normal/normal.H +++ b/src/lagrangian/distributionModels/normal/normal.H @@ -82,7 +82,7 @@ public: //- Construct from components normal(const dictionary& dict, Random& rndGen); - //- Construct copy + //- Copy construct normal(const normal& p); //- Construct and return a clone @@ -91,17 +91,20 @@ public: return autoPtr(new normal(*this)); } + //- No copy assignment + void operator=(const normal&) = delete; + //- Destructor - virtual ~normal(); + virtual ~normal() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the theoretical mean of the distribution virtual scalar meanValue() const; }; diff --git a/src/lagrangian/distributionModels/uniform/uniform.C b/src/lagrangian/distributionModels/uniform/uniform.C index 0ea5332f0d..690ac67dd4 100644 --- a/src/lagrangian/distributionModels/uniform/uniform.C +++ b/src/lagrangian/distributionModels/uniform/uniform.C @@ -60,12 +60,6 @@ Foam::distributionModels::uniform::uniform(const uniform& p) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::distributionModels::uniform::~uniform() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::scalar Foam::distributionModels::uniform::sample() const diff --git a/src/lagrangian/distributionModels/uniform/uniform.H b/src/lagrangian/distributionModels/uniform/uniform.H index 1e11b4408f..d1a85367e9 100644 --- a/src/lagrangian/distributionModels/uniform/uniform.H +++ b/src/lagrangian/distributionModels/uniform/uniform.H @@ -66,7 +66,7 @@ public: //- Construct from components uniform(const dictionary& dict, Random& rndGen); - //- Construct copy + //- Copy construct uniform(const uniform& p); //- Construct and return a clone @@ -75,17 +75,20 @@ public: return autoPtr(new uniform(*this)); } + //- No copy assignment + void operator=(const uniform&) = delete; + //- Destructor - virtual ~uniform(); + virtual ~uniform() = default; // Member Functions - //- Sample the distributionModel + //- Sample the distribution virtual scalar sample() const; - //- Return the mean value + //- Return the theoretical mean of the distribution virtual scalar meanValue() const; };