mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: distributionModel: consolidate min/max of distributions
BUG: distributionModel: disallow any distribution where input min is equal to input max ENH: distributionModel: ensure execution of check() at ctor level
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,8 +49,6 @@ Foam::distributionModels::RosinRammler::RosinRammler
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
minValue_(distributionModelDict_.get<scalar>("minValue")),
|
||||
maxValue_(distributionModelDict_.get<scalar>("maxValue")),
|
||||
d_(distributionModelDict_.get<scalar>("d")),
|
||||
n_(distributionModelDict_.get<scalar>("n"))
|
||||
{
|
||||
@ -60,8 +59,6 @@ Foam::distributionModels::RosinRammler::RosinRammler
|
||||
Foam::distributionModels::RosinRammler::RosinRammler(const RosinRammler& p)
|
||||
:
|
||||
distributionModel(p),
|
||||
minValue_(p.minValue_),
|
||||
maxValue_(p.maxValue_),
|
||||
d_(p.d_),
|
||||
n_(p.n_)
|
||||
{}
|
||||
@ -84,18 +81,6 @@ Foam::scalar Foam::distributionModels::RosinRammler::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::RosinRammler::minValue() const
|
||||
{
|
||||
return minValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::RosinRammler::maxValue() const
|
||||
{
|
||||
return maxValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::RosinRammler::meanValue() const
|
||||
{
|
||||
return d_;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -62,12 +63,6 @@ class RosinRammler
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Distribution minimum
|
||||
scalar minValue_;
|
||||
|
||||
//- Distribution maximum
|
||||
scalar maxValue_;
|
||||
|
||||
// Model coefficients
|
||||
|
||||
//- Scale parameter
|
||||
@ -107,12 +102,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -90,14 +90,10 @@ Foam::distributionModels::binned::binned
|
||||
xy_(distributionModelDict_.lookup("distribution")),
|
||||
meanValue_(0)
|
||||
{
|
||||
if (maxValue() < minValue())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Maximum value is smaller than the minimum value:"
|
||||
<< " maxValue = " << maxValue()
|
||||
<< ", minValue = " << minValue()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
minValue_ = xy_[0][0];
|
||||
maxValue_ = xy_[xy_.size()-1][0];
|
||||
|
||||
check();
|
||||
|
||||
initialise();
|
||||
}
|
||||
@ -114,16 +110,16 @@ Foam::distributionModels::binned::binned
|
||||
xy_(),
|
||||
meanValue_(0)
|
||||
{
|
||||
scalar minValue = GREAT;
|
||||
scalar maxValue = -GREAT;
|
||||
minValue_ = GREAT;
|
||||
maxValue_ = -GREAT;
|
||||
forAll(sampleData, i)
|
||||
{
|
||||
minValue = min(minValue, sampleData[i]);
|
||||
maxValue = max(maxValue, sampleData[i]);
|
||||
minValue_ = min(minValue_, sampleData[i]);
|
||||
maxValue_ = max(maxValue_, sampleData[i]);
|
||||
}
|
||||
|
||||
const label bin0 = floor(minValue/binWidth);
|
||||
const label bin1 = ceil(maxValue/binWidth);
|
||||
const label bin0 = floor(minValue_/binWidth);
|
||||
const label bin1 = ceil(maxValue_/binWidth);
|
||||
const label nBin = bin1 - bin0;
|
||||
|
||||
if (nBin == 0)
|
||||
@ -201,18 +197,6 @@ Foam::scalar Foam::distributionModels::binned::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::binned::minValue() const
|
||||
{
|
||||
return xy_.first()[0];
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::binned::maxValue() const
|
||||
{
|
||||
return xy_.last()[0];
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::binned::meanValue() const
|
||||
{
|
||||
return meanValue_;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -127,12 +127,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -43,19 +44,31 @@ void Foam::distributionModel::check() const
|
||||
if (minValue() < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << "distribution: Minimum value must be greater than "
|
||||
<< "zero." << nl << "Supplied minValue = " << minValue()
|
||||
<< type() << "Distribution: "
|
||||
<< "Minimum value must be greater than zero." << nl
|
||||
<< "Supplied minValue = " << minValue()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (maxValue() < minValue())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< type() << "distribution: Maximum value is smaller than the "
|
||||
<< "minimum value:" << nl << " maxValue = " << maxValue()
|
||||
<< type() << "Distribution: "
|
||||
<< "Maximum value cannot be smaller than minimum value" << nl
|
||||
<< " maxValue = " << maxValue()
|
||||
<< ", minValue = " << minValue()
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (maxValue() == minValue())
|
||||
{
|
||||
WarningInFunction
|
||||
<< type() << "Distribution: "
|
||||
<< "Maximum and minimum values are equal to each other" << nl
|
||||
<< " maxValue = " << maxValue()
|
||||
<< ", minValue = " << minValue()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -69,7 +82,9 @@ Foam::distributionModel::distributionModel
|
||||
)
|
||||
:
|
||||
distributionModelDict_(dict),
|
||||
rndGen_(rndGen)
|
||||
rndGen_(rndGen),
|
||||
minValue_(distributionModelDict_.getOrDefault<scalar>("minValue", GREAT)),
|
||||
maxValue_(distributionModelDict_.getOrDefault<scalar>("maxValue", -GREAT))
|
||||
{}
|
||||
|
||||
|
||||
@ -79,7 +94,9 @@ Foam::distributionModel::distributionModel
|
||||
)
|
||||
:
|
||||
distributionModelDict_(p.distributionModelDict_),
|
||||
rndGen_(p.rndGen_)
|
||||
rndGen_(p.rndGen_),
|
||||
minValue_(p.minValue_),
|
||||
maxValue_(p.maxValue_)
|
||||
{}
|
||||
|
||||
|
||||
@ -89,4 +106,18 @@ Foam::distributionModel::~distributionModel()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::distributionModel::minValue() const
|
||||
{
|
||||
return minValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModel::maxValue() const
|
||||
{
|
||||
return maxValue_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -81,6 +82,12 @@ protected:
|
||||
//- Reference to the random number generator
|
||||
Random& rndGen_;
|
||||
|
||||
//- Minimum of the distribution
|
||||
scalar minValue_;
|
||||
|
||||
//- Maximum of the distribution
|
||||
scalar maxValue_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
@ -142,11 +149,11 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const = 0;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const = 0;
|
||||
//- Return the minimum of the distribution
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const = 0;
|
||||
//- Return the maximum of the distribution
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar meanValue() const = 0;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,8 +49,6 @@ Foam::distributionModels::exponential::exponential
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
minValue_(distributionModelDict_.get<scalar>("minValue")),
|
||||
maxValue_(distributionModelDict_.get<scalar>("maxValue")),
|
||||
lambda_(distributionModelDict_.get<scalar>("lambda"))
|
||||
{
|
||||
check();
|
||||
@ -59,8 +58,6 @@ Foam::distributionModels::exponential::exponential
|
||||
Foam::distributionModels::exponential::exponential(const exponential& p)
|
||||
:
|
||||
distributionModel(p),
|
||||
minValue_(p.minValue_),
|
||||
maxValue_(p.maxValue_),
|
||||
lambda_(p.lambda_)
|
||||
{}
|
||||
|
||||
@ -81,18 +78,6 @@ Foam::scalar Foam::distributionModels::exponential::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::exponential::minValue() const
|
||||
{
|
||||
return minValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::exponential::maxValue() const
|
||||
{
|
||||
return maxValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::exponential::meanValue() const
|
||||
{
|
||||
return 1.0/lambda_;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -56,13 +57,6 @@ class exponential
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Distribution minimum
|
||||
scalar minValue_;
|
||||
|
||||
//- Distribution maximum
|
||||
scalar maxValue_;
|
||||
|
||||
|
||||
// Model coefficients
|
||||
|
||||
scalar lambda_;
|
||||
@ -98,12 +92,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -89,6 +89,9 @@ Foam::distributionModels::general::general
|
||||
meanValue_(0.0),
|
||||
integral_()
|
||||
{
|
||||
minValue_ = xy_[0][0];
|
||||
maxValue_ = xy_[nEntries_-1][0];
|
||||
|
||||
check();
|
||||
|
||||
initialise();
|
||||
@ -107,16 +110,16 @@ Foam::distributionModels::general::general
|
||||
meanValue_(0.0),
|
||||
integral_()
|
||||
{
|
||||
scalar minValue = GREAT;
|
||||
scalar maxValue = -GREAT;
|
||||
minValue_ = GREAT;
|
||||
maxValue_ = -GREAT;
|
||||
forAll(sampleData, i)
|
||||
{
|
||||
minValue = min(minValue, sampleData[i]);
|
||||
maxValue = max(maxValue, sampleData[i]);
|
||||
minValue_ = min(minValue_, sampleData[i]);
|
||||
maxValue_ = max(maxValue_, sampleData[i]);
|
||||
}
|
||||
|
||||
label bin0 = floor(minValue/binWidth);
|
||||
label bin1 = ceil(maxValue/binWidth);
|
||||
label bin0 = floor(minValue_/binWidth);
|
||||
label bin1 = ceil(maxValue_/binWidth);
|
||||
label nEntries = bin1 - bin0;
|
||||
|
||||
if (nEntries == 0)
|
||||
@ -211,18 +214,6 @@ Foam::scalar Foam::distributionModels::general::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::general::minValue() const
|
||||
{
|
||||
return xy_.first()[0];
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::general::maxValue() const
|
||||
{
|
||||
return xy_.last()[0];
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::general::meanValue() const
|
||||
{
|
||||
return meanValue_;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2016 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -134,12 +134,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
|
||||
|
||||
@ -50,8 +50,6 @@ Foam::distributionModels::massRosinRammler::massRosinRammler
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
minValue_(distributionModelDict_.get<scalar>("minValue")),
|
||||
maxValue_(distributionModelDict_.get<scalar>("maxValue")),
|
||||
d_(distributionModelDict_.get<scalar>("d")),
|
||||
n_(distributionModelDict_.get<scalar>("n"))
|
||||
{
|
||||
@ -65,8 +63,6 @@ Foam::distributionModels::massRosinRammler::massRosinRammler
|
||||
)
|
||||
:
|
||||
distributionModel(p),
|
||||
minValue_(p.minValue_),
|
||||
maxValue_(p.maxValue_),
|
||||
d_(p.d_),
|
||||
n_(p.n_)
|
||||
{}
|
||||
@ -97,18 +93,6 @@ Foam::scalar Foam::distributionModels::massRosinRammler::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::massRosinRammler::minValue() const
|
||||
{
|
||||
return minValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::massRosinRammler::maxValue() const
|
||||
{
|
||||
return maxValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::massRosinRammler::meanValue() const
|
||||
{
|
||||
return d_;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -72,12 +73,6 @@ class massRosinRammler
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Distribution minimum
|
||||
scalar minValue_;
|
||||
|
||||
//- Distribution maximum
|
||||
scalar maxValue_;
|
||||
|
||||
//- Characteristic droplet size
|
||||
scalar d_;
|
||||
|
||||
@ -116,12 +111,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
};
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,8 +49,6 @@ Foam::distributionModels::multiNormal::multiNormal
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
minValue_(distributionModelDict_.get<scalar>("minValue")),
|
||||
maxValue_(distributionModelDict_.get<scalar>("maxValue")),
|
||||
range_(maxValue_ - minValue_),
|
||||
expectation_(distributionModelDict_.lookup("expectation")),
|
||||
variance_(distributionModelDict_.lookup("variance")),
|
||||
@ -86,8 +85,6 @@ Foam::distributionModels::multiNormal::multiNormal
|
||||
Foam::distributionModels::multiNormal::multiNormal(const multiNormal& p)
|
||||
:
|
||||
distributionModel(p),
|
||||
minValue_(p.minValue_),
|
||||
maxValue_(p.maxValue_),
|
||||
range_(p.range_),
|
||||
expectation_(p.expectation_),
|
||||
variance_(p.variance_),
|
||||
@ -135,18 +132,6 @@ Foam::scalar Foam::distributionModels::multiNormal::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::multiNormal::minValue() const
|
||||
{
|
||||
return minValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::multiNormal::maxValue() const
|
||||
{
|
||||
return maxValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::multiNormal::meanValue() const
|
||||
{
|
||||
scalar mean = 0.0;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -61,12 +62,6 @@ class multiNormal
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Distribution minimum
|
||||
scalar minValue_;
|
||||
|
||||
//- Distribution maximum
|
||||
scalar maxValue_;
|
||||
|
||||
//- Distribution range
|
||||
scalar range_;
|
||||
|
||||
@ -108,12 +103,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
};
|
||||
|
||||
@ -50,35 +50,17 @@ Foam::distributionModels::normal::normal
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
minValue_(distributionModelDict_.get<scalar>("minValue")),
|
||||
maxValue_(distributionModelDict_.get<scalar>("maxValue")),
|
||||
expectation_(distributionModelDict_.get<scalar>("expectation")),
|
||||
variance_(distributionModelDict_.get<scalar>("variance")),
|
||||
a_(0.147)
|
||||
{
|
||||
if (minValue_ < 0)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Minimum value must be greater than zero. "
|
||||
<< "Supplied minValue = " << minValue_
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (maxValue_ < minValue_)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Maximum value is smaller than the minimum value:"
|
||||
<< " maxValue = " << maxValue_ << ", minValue = " << minValue_
|
||||
<< abort(FatalError);
|
||||
}
|
||||
check();
|
||||
}
|
||||
|
||||
|
||||
Foam::distributionModels::normal::normal(const normal& p)
|
||||
:
|
||||
distributionModel(p),
|
||||
minValue_(p.minValue_),
|
||||
maxValue_(p.maxValue_),
|
||||
expectation_(p.expectation_),
|
||||
variance_(p.variance_),
|
||||
a_(p.a_)
|
||||
@ -111,18 +93,6 @@ Foam::scalar Foam::distributionModels::normal::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::normal::minValue() const
|
||||
{
|
||||
return minValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::normal::maxValue() const
|
||||
{
|
||||
return maxValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::normal::meanValue() const
|
||||
{
|
||||
return expectation_;
|
||||
|
||||
@ -63,13 +63,6 @@ class normal
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Distribution minimum
|
||||
scalar minValue_;
|
||||
|
||||
//- Distribution maximum
|
||||
scalar maxValue_;
|
||||
|
||||
|
||||
// Model coefficients
|
||||
|
||||
scalar expectation_;
|
||||
@ -108,12 +101,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
};
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -47,9 +48,7 @@ Foam::distributionModels::uniform::uniform
|
||||
Random& rndGen
|
||||
)
|
||||
:
|
||||
distributionModel(typeName, dict, rndGen),
|
||||
minValue_(distributionModelDict_.get<scalar>("minValue")),
|
||||
maxValue_(distributionModelDict_.get<scalar>("maxValue"))
|
||||
distributionModel(typeName, dict, rndGen)
|
||||
{
|
||||
check();
|
||||
}
|
||||
@ -57,9 +56,7 @@ Foam::distributionModels::uniform::uniform
|
||||
|
||||
Foam::distributionModels::uniform::uniform(const uniform& p)
|
||||
:
|
||||
distributionModel(p),
|
||||
minValue_(p.minValue_),
|
||||
maxValue_(p.maxValue_)
|
||||
distributionModel(p)
|
||||
{}
|
||||
|
||||
|
||||
@ -77,18 +74,6 @@ Foam::scalar Foam::distributionModels::uniform::sample() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::uniform::minValue() const
|
||||
{
|
||||
return minValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::uniform::maxValue() const
|
||||
{
|
||||
return maxValue_;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::distributionModels::uniform::meanValue() const
|
||||
{
|
||||
return 0.5*(minValue_ + maxValue_);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,15 +55,6 @@ class uniform
|
||||
:
|
||||
public distributionModel
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Distribution minimum
|
||||
scalar minValue_;
|
||||
|
||||
//- Distribution maximum
|
||||
scalar maxValue_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -93,12 +85,6 @@ public:
|
||||
//- Sample the distributionModel
|
||||
virtual scalar sample() const;
|
||||
|
||||
//- Return the minimum value
|
||||
virtual scalar minValue() const;
|
||||
|
||||
//- Return the maximum value
|
||||
virtual scalar maxValue() const;
|
||||
|
||||
//- Return the mean value
|
||||
virtual scalar meanValue() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user