mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: add namespace qualifiers to interpolationWeights
This commit is contained in:
committed by
Andrew Heather
parent
e6a2083281
commit
29e6c81af8
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
@ -33,9 +33,9 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(interpolationWeights, 0);
|
||||
defineRunTimeSelectionTable(interpolationWeights, word);
|
||||
}
|
||||
defineTypeNameAndDebug(interpolationWeights, 0);
|
||||
defineRunTimeSelectionTable(interpolationWeights, word);
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -77,10 +77,4 @@ Foam::autoPtr<Foam::interpolationWeights> Foam::interpolationWeights::New
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::interpolationWeights::~interpolationWeights()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
@ -57,10 +57,14 @@ class objectRegistry;
|
||||
|
||||
class interpolationWeights
|
||||
{
|
||||
protected:
|
||||
|
||||
private:
|
||||
// Protected Data
|
||||
|
||||
// Private Member Functions
|
||||
const scalarField& samples_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- No copy construct
|
||||
interpolationWeights(const interpolationWeights&) = delete;
|
||||
@ -68,9 +72,6 @@ private:
|
||||
//- No copy assignment
|
||||
void operator=(const interpolationWeights&) = delete;
|
||||
|
||||
protected:
|
||||
|
||||
const scalarField& samples_;
|
||||
|
||||
public:
|
||||
|
||||
@ -95,7 +96,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
interpolationWeights(const scalarField& samples);
|
||||
explicit interpolationWeights(const scalarField& samples);
|
||||
|
||||
|
||||
// Selectors
|
||||
@ -109,7 +110,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~interpolationWeights();
|
||||
virtual ~interpolationWeights() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
@ -26,15 +26,7 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolationWeights.H"
|
||||
#include "ListOps.H"
|
||||
#include "IOobject.H"
|
||||
#include "HashSet.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
#include "products.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -56,24 +48,19 @@ Foam::interpolationWeights::weightedSum
|
||||
typename ListType2::value_type
|
||||
>::type returnType;
|
||||
|
||||
if (f1.size())
|
||||
const label len = f1.size();
|
||||
if (len)
|
||||
{
|
||||
returnType SumProd = f1[0]*f2[0];
|
||||
for (label i = 1; i < f1.size(); ++i)
|
||||
for (label i = 1; i < len; ++i)
|
||||
{
|
||||
SumProd += f1[i]*f2[i];
|
||||
}
|
||||
return SumProd;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Zero;
|
||||
}
|
||||
|
||||
return Zero;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
@ -30,25 +30,23 @@ License
|
||||
#include "ListOps.H"
|
||||
#include "Pair.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(linearInterpolationWeights, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
interpolationWeights,
|
||||
linearInterpolationWeights,
|
||||
word
|
||||
);
|
||||
defineTypeNameAndDebug(linearInterpolationWeights, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
interpolationWeights,
|
||||
linearInterpolationWeights,
|
||||
word
|
||||
);
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
|
||||
Foam::Pair<Foam::scalar> Foam::linearInterpolationWeights::integrationWeights
|
||||
(
|
||||
const label i,
|
||||
const scalar t
|
||||
@ -56,7 +54,7 @@ Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
|
||||
{
|
||||
// t is in range samples_[i] .. samples_[i+1]
|
||||
|
||||
scalar s = (t-samples_[i])/(samples_[i+1]-samples_[i]);
|
||||
const scalar s = (t-samples_[i])/(samples_[i+1]-samples_[i]);
|
||||
|
||||
if (s < -SMALL || s > 1+SMALL)
|
||||
{
|
||||
@ -66,7 +64,7 @@ Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
scalar d = samples_[i+1]-t;
|
||||
const scalar d = samples_[i+1]-t;
|
||||
|
||||
return Pair<scalar>(d*0.5*(1-s), d*0.5*(1+s));
|
||||
}
|
||||
@ -74,7 +72,7 @@ Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
linearInterpolationWeights::linearInterpolationWeights
|
||||
Foam::linearInterpolationWeights::linearInterpolationWeights
|
||||
(
|
||||
const scalarField& samples
|
||||
)
|
||||
@ -86,7 +84,7 @@ linearInterpolationWeights::linearInterpolationWeights
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool linearInterpolationWeights::valueWeights
|
||||
bool Foam::linearInterpolationWeights::valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
labelList& indices,
|
||||
@ -153,7 +151,7 @@ bool linearInterpolationWeights::valueWeights
|
||||
}
|
||||
|
||||
|
||||
bool linearInterpolationWeights::integrationWeights
|
||||
bool Foam::linearInterpolationWeights::integrationWeights
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2,
|
||||
@ -172,9 +170,10 @@ bool linearInterpolationWeights::integrationWeights
|
||||
// Currently no fancy logic on cached index like in value
|
||||
|
||||
//- Find lower or equal index
|
||||
label i1 = findLower(samples_, t1, 0, lessEqOp<scalar>());
|
||||
const label i1 = findLower(samples_, t1, 0, lessEqOp<scalar>());
|
||||
|
||||
//- Find lower index
|
||||
label i2 = findLower(samples_, t2);
|
||||
const label i2 = findLower(samples_, t2);
|
||||
|
||||
// For now just fail if any outside table
|
||||
if (i1 == -1 || i2 == samples_.size()-1)
|
||||
@ -185,7 +184,7 @@ bool linearInterpolationWeights::integrationWeights
|
||||
<< " t1:" << t1 << " t2:" << t2 << exit(FatalError);
|
||||
}
|
||||
|
||||
label nIndices = i2-i1+2;
|
||||
const label nIndices = i2-i1+2;
|
||||
|
||||
|
||||
// Determine if indices already correct
|
||||
@ -218,7 +217,7 @@ bool linearInterpolationWeights::integrationWeights
|
||||
// Sum from i1+1 to i2+1
|
||||
for (label i = i1+1; i <= i2; i++)
|
||||
{
|
||||
scalar d = samples_[i+1]-samples_[i];
|
||||
const scalar d = samples_[i+1]-samples_[i];
|
||||
indices[i-i1] = i;
|
||||
weights[i-i1] += 0.5*d;
|
||||
indices[i+1-i1] = i+1;
|
||||
@ -227,19 +226,19 @@ bool linearInterpolationWeights::integrationWeights
|
||||
|
||||
// Add from i1 to t1
|
||||
{
|
||||
Pair<scalar> i1Tot1 = integrationWeights(i1, t1);
|
||||
const Pair<scalar> i1Tot1 = integrationWeights(i1, t1);
|
||||
indices[0] = i1;
|
||||
weights[0] += i1Tot1.first();
|
||||
indices[1] = i1+1;
|
||||
weights[0] += i1Tot1.first();
|
||||
weights[1] += i1Tot1.second();
|
||||
}
|
||||
|
||||
// Subtract from t2 to i2+1
|
||||
{
|
||||
Pair<scalar> wghts = integrationWeights(i2, t2);
|
||||
const Pair<scalar> wghts = integrationWeights(i2, t2);
|
||||
indices[i2-i1] = i2;
|
||||
weights[i2-i1] += -wghts.first();
|
||||
indices[i2-i1+1] = i2+1;
|
||||
weights[i2-i1] += -wghts.first();
|
||||
weights[i2-i1+1] += -wghts.second();
|
||||
}
|
||||
|
||||
@ -247,8 +246,4 @@ bool linearInterpolationWeights::integrationWeights
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2012 OpenFOAM Foundation
|
||||
@ -51,47 +51,39 @@ class linearInterpolationWeights
|
||||
:
|
||||
public interpolationWeights
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- Cached index in samples from previous invocation
|
||||
mutable label index_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Get weights of i and i+1 to calculate integration from t to
|
||||
// samples_[i+1]
|
||||
Pair<scalar> integrationWeights
|
||||
(
|
||||
const label i,
|
||||
const scalar t
|
||||
) const;
|
||||
//- samples_[i+1]
|
||||
Pair<scalar> integrationWeights(const label i, const scalar t) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("linear");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
linearInterpolationWeights
|
||||
(
|
||||
const scalarField& samples
|
||||
);
|
||||
explicit linearInterpolationWeights(const scalarField& samples);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~linearInterpolationWeights()
|
||||
{}
|
||||
virtual ~linearInterpolationWeights() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate weights and indices to calculate t from samples.
|
||||
// Returns true if indices changed.
|
||||
// \return true if indices changed.
|
||||
virtual bool valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
@ -100,7 +92,8 @@ public:
|
||||
) const;
|
||||
|
||||
//- Calculate weights and indices to calculate integrand of t1..t2
|
||||
// from samples. Returns true if indices changed.
|
||||
//- from samples.
|
||||
// \return true if indices changed.
|
||||
virtual bool integrationWeights
|
||||
(
|
||||
const scalar t1,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
@ -30,25 +30,23 @@ License
|
||||
#include "ListOps.H"
|
||||
#include "linearInterpolationWeights.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(splineInterpolationWeights, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
interpolationWeights,
|
||||
splineInterpolationWeights,
|
||||
word
|
||||
);
|
||||
defineTypeNameAndDebug(splineInterpolationWeights, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
interpolationWeights,
|
||||
splineInterpolationWeights,
|
||||
word
|
||||
);
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
splineInterpolationWeights::splineInterpolationWeights
|
||||
Foam::splineInterpolationWeights::splineInterpolationWeights
|
||||
(
|
||||
const scalarField& samples,
|
||||
const bool checkEqualDistance
|
||||
@ -80,7 +78,7 @@ splineInterpolationWeights::splineInterpolationWeights
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool splineInterpolationWeights::valueWeights
|
||||
bool Foam::splineInterpolationWeights::valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
labelList& indices,
|
||||
@ -220,8 +218,4 @@ bool splineInterpolationWeights::valueWeights
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||
@ -52,24 +52,23 @@ class splineInterpolationWeights
|
||||
:
|
||||
public interpolationWeights
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- Cached index in samples from previous invocation
|
||||
mutable label index_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("spline");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components. By default make sure samples are
|
||||
// equidistant.
|
||||
splineInterpolationWeights
|
||||
explicit splineInterpolationWeights
|
||||
(
|
||||
const scalarField& samples,
|
||||
const bool checkEqualDistance = true
|
||||
@ -77,14 +76,13 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~splineInterpolationWeights()
|
||||
{}
|
||||
virtual ~splineInterpolationWeights() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate weights and indices to calculate t from samples.
|
||||
// Returns true if indices changed.
|
||||
// \return true if indices changed.
|
||||
virtual bool valueWeights
|
||||
(
|
||||
const scalar t,
|
||||
@ -93,7 +91,8 @@ public:
|
||||
) const;
|
||||
|
||||
//- Calculate weights and indices to calculate integrand of t1..t2
|
||||
// from samples. Returns true if indices changed.
|
||||
//- from samples.
|
||||
// \return true if indices changed.
|
||||
virtual bool integrationWeights
|
||||
(
|
||||
const scalar t1,
|
||||
|
||||
Reference in New Issue
Block a user