mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/hunt2/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -151,18 +151,20 @@ public:
|
|||||||
const IOobject& fieldIoObject
|
const IOobject& fieldIoObject
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Reconstruct and write all volume fields
|
//- Reconstruct and write all/selected volume fields
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void reconstructFvVolumeFields
|
void reconstructFvVolumeFields
|
||||||
(
|
(
|
||||||
const IOobjectList& objects
|
const IOobjectList& objects,
|
||||||
|
const HashSet<word>& selectedFields
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Reconstruct and write all volume fields
|
//- Reconstruct and write all/selected volume fields
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void reconstructFvSurfaceFields
|
void reconstructFvSurfaceFields
|
||||||
(
|
(
|
||||||
const IOobjectList& objects
|
const IOobjectList& objects,
|
||||||
|
const HashSet<word>& selectedFields
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -131,7 +131,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
|
|||||||
forAll(cp, faceI)
|
forAll(cp, faceI)
|
||||||
{
|
{
|
||||||
// Subtract one to take into account offsets for
|
// Subtract one to take into account offsets for
|
||||||
// face direction.
|
// face direction.
|
||||||
reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
|
reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
|
|||||||
forAll(cp, faceI)
|
forAll(cp, faceI)
|
||||||
{
|
{
|
||||||
// Subtract one to take into account offsets for
|
// Subtract one to take into account offsets for
|
||||||
// face direction.
|
// face direction.
|
||||||
label curF = cp[faceI] - 1;
|
label curF = cp[faceI] - 1;
|
||||||
|
|
||||||
// Is the face on the boundary?
|
// Is the face on the boundary?
|
||||||
@ -282,7 +282,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
|
|||||||
|
|
||||||
// It is necessary to create a copy of the addressing array to
|
// It is necessary to create a copy of the addressing array to
|
||||||
// take care of the face direction offset trick.
|
// take care of the face direction offset trick.
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
labelList curAddr(faceProcAddressing_[procI]);
|
labelList curAddr(faceProcAddressing_[procI]);
|
||||||
|
|
||||||
@ -342,7 +342,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
|
|||||||
forAll(cp, faceI)
|
forAll(cp, faceI)
|
||||||
{
|
{
|
||||||
// Subtract one to take into account offsets for
|
// Subtract one to take into account offsets for
|
||||||
// face direction.
|
// face direction.
|
||||||
reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
|
reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,11 +452,12 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Reconstruct and write all volume fields
|
// Reconstruct and write all/selected volume fields
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::fvFieldReconstructor::reconstructFvVolumeFields
|
void Foam::fvFieldReconstructor::reconstructFvVolumeFields
|
||||||
(
|
(
|
||||||
const IOobjectList& objects
|
const IOobjectList& objects,
|
||||||
|
const HashSet<word>& selectedFields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word& fieldClassName =
|
const word& fieldClassName =
|
||||||
@ -468,27 +469,29 @@ void Foam::fvFieldReconstructor::reconstructFvVolumeFields
|
|||||||
{
|
{
|
||||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||||
|
|
||||||
for
|
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||||
(
|
|
||||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
|
||||||
fieldIter != fields.end();
|
|
||||||
++fieldIter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
Info<< " " << fieldIter()->name() << endl;
|
if
|
||||||
|
(
|
||||||
|
!selectedFields.size()
|
||||||
|
|| selectedFields.found(fieldIter()->name())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< " " << fieldIter()->name() << endl;
|
||||||
|
|
||||||
reconstructFvVolumeField<Type>(*fieldIter())().write();
|
reconstructFvVolumeField<Type>(*fieldIter())().write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconstruct and write all surface fields
|
// Reconstruct and write all/selected surface fields
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
|
void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
|
||||||
(
|
(
|
||||||
const IOobjectList& objects
|
const IOobjectList& objects,
|
||||||
|
const HashSet<word>& selectedFields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const word& fieldClassName =
|
const word& fieldClassName =
|
||||||
@ -500,18 +503,19 @@ void Foam::fvFieldReconstructor::reconstructFvSurfaceFields
|
|||||||
{
|
{
|
||||||
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
|
||||||
|
|
||||||
for
|
forAllConstIter(IOobjectList, fields, fieldIter)
|
||||||
(
|
|
||||||
IOobjectList::const_iterator fieldIter = fields.begin();
|
|
||||||
fieldIter != fields.end();
|
|
||||||
++fieldIter
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
Info<< " " << fieldIter()->name() << endl;
|
if
|
||||||
|
(
|
||||||
|
!selectedFields.size()
|
||||||
|
|| selectedFields.found(fieldIter()->name())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< " " << fieldIter()->name() << endl;
|
||||||
|
|
||||||
reconstructFvSurfaceField<Type>(*fieldIter())().write();
|
reconstructFvSurfaceField<Type>(*fieldIter())().write();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,9 +48,17 @@ int main(int argc, char *argv[])
|
|||||||
argList::noParallel();
|
argList::noParallel();
|
||||||
timeSelector::addOptions();
|
timeSelector::addOptions();
|
||||||
# include "addRegionOption.H"
|
# include "addRegionOption.H"
|
||||||
|
argList::validOptions.insert("fields", "\"(list of fields)\"");
|
||||||
|
|
||||||
# include "setRootCase.H"
|
# include "setRootCase.H"
|
||||||
# include "createTime.H"
|
# include "createTime.H"
|
||||||
|
|
||||||
|
HashSet<word> selectedFields;
|
||||||
|
if (args.options().found("fields"))
|
||||||
|
{
|
||||||
|
IStringStream(args.options()["fields"])() >> selectedFields;
|
||||||
|
}
|
||||||
|
|
||||||
// determine the processor count directly
|
// determine the processor count directly
|
||||||
label nProcs = 0;
|
label nProcs = 0;
|
||||||
while (dir(args.path()/(word("processor") + name(nProcs))))
|
while (dir(args.path()/(word("processor") + name(nProcs))))
|
||||||
@ -184,13 +192,37 @@ int main(int argc, char *argv[])
|
|||||||
procMeshes.boundaryProcAddressing()
|
procMeshes.boundaryProcAddressing()
|
||||||
);
|
);
|
||||||
|
|
||||||
fvReconstructor.reconstructFvVolumeFields<scalar>(objects);
|
fvReconstructor.reconstructFvVolumeFields<scalar>
|
||||||
fvReconstructor.reconstructFvVolumeFields<vector>(objects);
|
(
|
||||||
fvReconstructor.reconstructFvVolumeFields<sphericalTensor>(objects);
|
objects,
|
||||||
fvReconstructor.reconstructFvVolumeFields<symmTensor>(objects);
|
selectedFields
|
||||||
fvReconstructor.reconstructFvVolumeFields<tensor>(objects);
|
);
|
||||||
|
fvReconstructor.reconstructFvVolumeFields<vector>
|
||||||
|
(
|
||||||
|
objects,
|
||||||
|
selectedFields
|
||||||
|
);
|
||||||
|
fvReconstructor.reconstructFvVolumeFields<sphericalTensor>
|
||||||
|
(
|
||||||
|
objects,
|
||||||
|
selectedFields
|
||||||
|
);
|
||||||
|
fvReconstructor.reconstructFvVolumeFields<symmTensor>
|
||||||
|
(
|
||||||
|
objects,
|
||||||
|
selectedFields
|
||||||
|
);
|
||||||
|
fvReconstructor.reconstructFvVolumeFields<tensor>
|
||||||
|
(
|
||||||
|
objects,
|
||||||
|
selectedFields
|
||||||
|
);
|
||||||
|
|
||||||
fvReconstructor.reconstructFvSurfaceFields<scalar>(objects);
|
fvReconstructor.reconstructFvSurfaceFields<scalar>
|
||||||
|
(
|
||||||
|
objects,
|
||||||
|
selectedFields
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -139,7 +139,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
|
|||||||
|
|
||||||
IOobject LESPropertiesHeader
|
IOobject LESPropertiesHeader
|
||||||
(
|
(
|
||||||
"RASProperties",
|
"LESProperties",
|
||||||
runTime.constant(),
|
runTime.constant(),
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
|
|||||||
@ -34,7 +34,7 @@ Description
|
|||||||
#define ODE_H
|
#define ODE_H
|
||||||
|
|
||||||
#include "scalarField.H"
|
#include "scalarField.H"
|
||||||
#include "Matrix.H"
|
#include "scalarMatrices.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ public:
|
|||||||
const scalar x,
|
const scalar x,
|
||||||
const scalarField& y,
|
const scalarField& y,
|
||||||
scalarField& dfdx,
|
scalarField& dfdx,
|
||||||
Matrix<scalar>& dfdy
|
scalarSquareMatrix& dfdy
|
||||||
) const = 0;
|
) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "KRR4.H"
|
#include "KRR4.H"
|
||||||
#include "simpleMatrix.H"
|
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
@ -36,11 +35,11 @@ namespace Foam
|
|||||||
{
|
{
|
||||||
addToRunTimeSelectionTable(ODESolver, KRR4, ODE);
|
addToRunTimeSelectionTable(ODESolver, KRR4, ODE);
|
||||||
|
|
||||||
const scalar
|
const scalar
|
||||||
KRR4::safety = 0.9, KRR4::grow = 1.5, KRR4::pgrow = -0.25,
|
KRR4::safety = 0.9, KRR4::grow = 1.5, KRR4::pgrow = -0.25,
|
||||||
KRR4::shrink = 0.5, KRR4::pshrink = (-1.0/3.0), KRR4::errcon = 0.1296;
|
KRR4::shrink = 0.5, KRR4::pshrink = (-1.0/3.0), KRR4::errcon = 0.1296;
|
||||||
|
|
||||||
const scalar
|
const scalar
|
||||||
KRR4::gamma = 1.0/2.0,
|
KRR4::gamma = 1.0/2.0,
|
||||||
KRR4::a21 = 2.0, KRR4::a31 = 48.0/25.0, KRR4::a32 = 6.0/25.0,
|
KRR4::a21 = 2.0, KRR4::a31 = 48.0/25.0, KRR4::a32 = 6.0/25.0,
|
||||||
KRR4::c21 = -8.0, KRR4::c31 = 372.0/25.0, KRR4::c32 = 12.0/5.0,
|
KRR4::c21 = -8.0, KRR4::c31 = 372.0/25.0, KRR4::c32 = 12.0/5.0,
|
||||||
@ -81,8 +80,8 @@ void Foam::KRR4::solve
|
|||||||
const ODE& ode,
|
const ODE& ode,
|
||||||
scalar& x,
|
scalar& x,
|
||||||
scalarField& y,
|
scalarField& y,
|
||||||
scalarField& dydx,
|
scalarField& dydx,
|
||||||
const scalar eps,
|
const scalar eps,
|
||||||
const scalarField& yScale,
|
const scalarField& yScale,
|
||||||
const scalar hTry,
|
const scalar hTry,
|
||||||
scalar& hDid,
|
scalar& hDid,
|
||||||
@ -109,14 +108,14 @@ void Foam::KRR4::solve
|
|||||||
a_[i][i] += 1.0/(gamma*h);
|
a_[i][i] += 1.0/(gamma*h);
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUDecompose(a_, pivotIndices_);
|
LUDecompose(a_, pivotIndices_);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
g1_[i] = dydxTemp_[i] + h*c1X*dfdx_[i];
|
g1_[i] = dydxTemp_[i] + h*c1X*dfdx_[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g1_);
|
LUBacksubstitute(a_, pivotIndices_, g1_);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
@ -131,7 +130,7 @@ void Foam::KRR4::solve
|
|||||||
g2_[i] = dydx_[i] + h*c2X*dfdx_[i] + c21*g1_[i]/h;
|
g2_[i] = dydx_[i] + h*c2X*dfdx_[i] + c21*g1_[i]/h;
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g2_);
|
LUBacksubstitute(a_, pivotIndices_, g2_);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
@ -146,7 +145,7 @@ void Foam::KRR4::solve
|
|||||||
g3_[i] = dydx[i] + h*c3X*dfdx_[i] + (c31*g1_[i] + c32*g2_[i])/h;
|
g3_[i] = dydx[i] + h*c3X*dfdx_[i] + (c31*g1_[i] + c32*g2_[i])/h;
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g3_);
|
LUBacksubstitute(a_, pivotIndices_, g3_);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
@ -154,7 +153,7 @@ void Foam::KRR4::solve
|
|||||||
+ (c41*g1_[i] + c42*g2_[i] + c43*g3_[i])/h;
|
+ (c41*g1_[i] + c42*g2_[i] + c43*g3_[i])/h;
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUBacksubstitute(a_, pivotIndices_, g4_);
|
LUBacksubstitute(a_, pivotIndices_, g4_);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -62,15 +62,15 @@ class KRR4
|
|||||||
mutable scalarField g4_;
|
mutable scalarField g4_;
|
||||||
mutable scalarField yErr_;
|
mutable scalarField yErr_;
|
||||||
mutable scalarField dfdx_;
|
mutable scalarField dfdx_;
|
||||||
mutable Matrix<scalar> dfdy_;
|
mutable scalarSquareMatrix dfdy_;
|
||||||
mutable Matrix<scalar> a_;
|
mutable scalarSquareMatrix a_;
|
||||||
mutable labelList pivotIndices_;
|
mutable labelList pivotIndices_;
|
||||||
|
|
||||||
static const int maxtry = 40;
|
static const int maxtry = 40;
|
||||||
|
|
||||||
static const scalar safety, grow, pgrow, shrink, pshrink, errcon;
|
static const scalar safety, grow, pgrow, shrink, pshrink, errcon;
|
||||||
|
|
||||||
static const scalar
|
static const scalar
|
||||||
gamma,
|
gamma,
|
||||||
a21, a31, a32,
|
a21, a31, a32,
|
||||||
c21, c31, c32, c41, c42, c43,
|
c21, c31, c32, c41, c42, c43,
|
||||||
|
|||||||
@ -60,8 +60,8 @@ class SIBS
|
|||||||
static const scalar safe1, safe2, redMax, redMin, scaleMX;
|
static const scalar safe1, safe2, redMax, redMin, scaleMX;
|
||||||
|
|
||||||
mutable scalarField a_;
|
mutable scalarField a_;
|
||||||
mutable Matrix<scalar> alpha_;
|
mutable scalarSquareMatrix alpha_;
|
||||||
mutable Matrix<scalar> d_p_;
|
mutable scalarSquareMatrix d_p_;
|
||||||
mutable scalarField x_p_;
|
mutable scalarField x_p_;
|
||||||
mutable scalarField err_;
|
mutable scalarField err_;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class SIBS
|
|||||||
mutable scalarField ySeq_;
|
mutable scalarField ySeq_;
|
||||||
mutable scalarField yErr_;
|
mutable scalarField yErr_;
|
||||||
mutable scalarField dfdx_;
|
mutable scalarField dfdx_;
|
||||||
mutable Matrix<scalar> dfdy_;
|
mutable scalarSquareMatrix dfdy_;
|
||||||
|
|
||||||
mutable label first_, kMax_, kOpt_;
|
mutable label first_, kMax_, kOpt_;
|
||||||
mutable scalar epsOld_, xNew_;
|
mutable scalar epsOld_, xNew_;
|
||||||
@ -82,7 +82,7 @@ void SIMPR
|
|||||||
const scalarField& y,
|
const scalarField& y,
|
||||||
const scalarField& dydx,
|
const scalarField& dydx,
|
||||||
const scalarField& dfdx,
|
const scalarField& dfdx,
|
||||||
const Matrix<scalar>& dfdy,
|
const scalarSquareMatrix& dfdy,
|
||||||
const scalar deltaX,
|
const scalar deltaX,
|
||||||
const label nSteps,
|
const label nSteps,
|
||||||
scalarField& yEnd
|
scalarField& yEnd
|
||||||
@ -97,7 +97,7 @@ void polyExtrapolate
|
|||||||
scalarField& yz,
|
scalarField& yz,
|
||||||
scalarField& dy,
|
scalarField& dy,
|
||||||
scalarField& x_p,
|
scalarField& x_p,
|
||||||
Matrix<scalar>& d_p
|
scalarSquareMatrix& d_p
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,6 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "SIBS.H"
|
#include "SIBS.H"
|
||||||
#include "simpleMatrix.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ void Foam::SIBS::SIMPR
|
|||||||
const scalarField& y,
|
const scalarField& y,
|
||||||
const scalarField& dydx,
|
const scalarField& dydx,
|
||||||
const scalarField& dfdx,
|
const scalarField& dfdx,
|
||||||
const Matrix<scalar>& dfdy,
|
const scalarSquareMatrix& dfdy,
|
||||||
const scalar deltaX,
|
const scalar deltaX,
|
||||||
const label nSteps,
|
const label nSteps,
|
||||||
scalarField& yEnd
|
scalarField& yEnd
|
||||||
@ -44,7 +43,7 @@ void Foam::SIBS::SIMPR
|
|||||||
{
|
{
|
||||||
scalar h = deltaX/nSteps;
|
scalar h = deltaX/nSteps;
|
||||||
|
|
||||||
Matrix<scalar> a(n_, n_);
|
scalarSquareMatrix a(n_);
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
for (register label j=0; j<n_; j++)
|
for (register label j=0; j<n_; j++)
|
||||||
@ -55,14 +54,14 @@ void Foam::SIBS::SIMPR
|
|||||||
}
|
}
|
||||||
|
|
||||||
labelList pivotIndices(n_);
|
labelList pivotIndices(n_);
|
||||||
simpleMatrix<scalar>::LUDecompose(a, pivotIndices);
|
LUDecompose(a, pivotIndices);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
yEnd[i] = h*(dydx[i] + h*dfdx[i]);
|
yEnd[i] = h*(dydx[i] + h*dfdx[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUBacksubstitute(a, pivotIndices, yEnd);
|
LUBacksubstitute(a, pivotIndices, yEnd);
|
||||||
|
|
||||||
scalarField del(yEnd);
|
scalarField del(yEnd);
|
||||||
scalarField ytemp(n_);
|
scalarField ytemp(n_);
|
||||||
@ -83,7 +82,7 @@ void Foam::SIBS::SIMPR
|
|||||||
yEnd[i] = h*yEnd[i] - del[i];
|
yEnd[i] = h*yEnd[i] - del[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUBacksubstitute(a, pivotIndices, yEnd);
|
LUBacksubstitute(a, pivotIndices, yEnd);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
@ -99,7 +98,7 @@ void Foam::SIBS::SIMPR
|
|||||||
yEnd[i] = h*yEnd[i] - del[i];
|
yEnd[i] = h*yEnd[i] - del[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleMatrix<scalar>::LUBacksubstitute(a, pivotIndices, yEnd);
|
LUBacksubstitute(a, pivotIndices, yEnd);
|
||||||
|
|
||||||
for (register label i=0; i<n_; i++)
|
for (register label i=0; i<n_; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -36,7 +36,7 @@ void Foam::SIBS::polyExtrapolate
|
|||||||
scalarField& yz,
|
scalarField& yz,
|
||||||
scalarField& dy,
|
scalarField& dy,
|
||||||
scalarField& x,
|
scalarField& x,
|
||||||
Matrix<scalar>& d
|
scalarSquareMatrix& d
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
label n = yz.size();
|
label n = yz.size();
|
||||||
|
|||||||
@ -177,9 +177,9 @@ dimensionedTypes/dimensionedTensor/dimensionedTensor.C
|
|||||||
|
|
||||||
matrices/solution/solution.C
|
matrices/solution/solution.C
|
||||||
|
|
||||||
scalarMatrix = matrices/scalarMatrix
|
scalarMatrices = matrices/scalarMatrices
|
||||||
$(scalarMatrix)/scalarMatrix.C
|
$(scalarMatrices)/scalarMatrices.C
|
||||||
$(scalarMatrix)/SVD/SVD.C
|
$(scalarMatrices)/SVD/SVD.C
|
||||||
|
|
||||||
LUscalarMatrix = matrices/LUscalarMatrix
|
LUscalarMatrix = matrices/LUscalarMatrix
|
||||||
$(LUscalarMatrix)/LUscalarMatrix.C
|
$(LUscalarMatrix)/LUscalarMatrix.C
|
||||||
|
|||||||
@ -22,8 +22,6 @@ License
|
|||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "Pstream.H"
|
#include "Pstream.H"
|
||||||
|
|||||||
@ -29,7 +29,8 @@ License
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::DiagonalMatrix<Type>::DiagonalMatrix(const Matrix<Type>& a)
|
template<class Form>
|
||||||
|
Foam::DiagonalMatrix<Type>::DiagonalMatrix(const Matrix<Form, Type>& a)
|
||||||
:
|
:
|
||||||
List<Type>(min(a.n(), a.m()))
|
List<Type>(min(a.n(), a.m()))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -46,7 +46,7 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Class Forward declaration * * * * * * * * * * * //
|
// * * * * * * * * * * * * Class Forward declaration * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type> class Matrix;
|
template<class Form, class Type> class Matrix;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class DiagonalMatrix Declaration
|
Class DiagonalMatrix Declaration
|
||||||
@ -62,7 +62,8 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from diagonal component of a Matrix
|
//- Construct from diagonal component of a Matrix
|
||||||
DiagonalMatrix<Type>(const Matrix<Type>&);
|
template<class Form>
|
||||||
|
DiagonalMatrix<Type>(const Matrix<Form, Type>&);
|
||||||
|
|
||||||
//- Construct empty from size
|
//- Construct empty from size
|
||||||
DiagonalMatrix<Type>(const label size);
|
DiagonalMatrix<Type>(const label size);
|
||||||
|
|||||||
@ -31,9 +31,9 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::LUscalarMatrix::LUscalarMatrix(const Matrix<scalar>& matrix)
|
Foam::LUscalarMatrix::LUscalarMatrix(const scalarSquareMatrix& matrix)
|
||||||
:
|
:
|
||||||
scalarMatrix(matrix),
|
scalarSquareMatrix(matrix),
|
||||||
pivotIndices_(n())
|
pivotIndices_(n())
|
||||||
{
|
{
|
||||||
LUDecompose(*this, pivotIndices_);
|
LUDecompose(*this, pivotIndices_);
|
||||||
@ -101,7 +101,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
nCells += lduMatrices[i].size();
|
nCells += lduMatrices[i].size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix<scalar> m(nCells, nCells, 0.0);
|
scalarSquareMatrix m(nCells, nCells, 0.0);
|
||||||
transfer(m);
|
transfer(m);
|
||||||
convert(lduMatrices);
|
convert(lduMatrices);
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ Foam::LUscalarMatrix::LUscalarMatrix
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
label nCells = ldum.lduAddr().size();
|
label nCells = ldum.lduAddr().size();
|
||||||
Matrix<scalar> m(nCells, nCells, 0.0);
|
scalarSquareMatrix m(nCells, nCells, 0.0);
|
||||||
transfer(m);
|
transfer(m);
|
||||||
convert(ldum, interfaceCoeffs, interfaces);
|
convert(ldum, interfaceCoeffs, interfaces);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ SourceFiles
|
|||||||
#ifndef LUscalarMatrix_H
|
#ifndef LUscalarMatrix_H
|
||||||
#define LUscalarMatrix_H
|
#define LUscalarMatrix_H
|
||||||
|
|
||||||
#include "scalarMatrix.H"
|
#include "scalarMatrices.H"
|
||||||
#include "labelList.H"
|
#include "labelList.H"
|
||||||
#include "FieldField.H"
|
#include "FieldField.H"
|
||||||
#include "lduInterfaceFieldPtrsList.H"
|
#include "lduInterfaceFieldPtrsList.H"
|
||||||
@ -55,7 +55,7 @@ class procLduMatrix;
|
|||||||
|
|
||||||
class LUscalarMatrix
|
class LUscalarMatrix
|
||||||
:
|
:
|
||||||
public scalarMatrix
|
public scalarSquareMatrix
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ class LUscalarMatrix
|
|||||||
void convert(const PtrList<procLduMatrix>& lduMatrices);
|
void convert(const PtrList<procLduMatrix>& lduMatrices);
|
||||||
|
|
||||||
|
|
||||||
//- Print the ratio of the mag-sum of the off-diagonal coefficients
|
//- Print the ratio of the mag-sum of the off-diagonal coefficients
|
||||||
// to the mag-diagonal
|
// to the mag-diagonal
|
||||||
void printDiagonalDominance() const;
|
void printDiagonalDominance() const;
|
||||||
|
|
||||||
@ -87,8 +87,8 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from Matrix<scalar> and perform LU decomposition
|
//- Construct from scalarSquareMatrix and perform LU decomposition
|
||||||
LUscalarMatrix(const Matrix<scalar>&);
|
LUscalarMatrix(const scalarSquareMatrix&);
|
||||||
|
|
||||||
//- Construct from lduMatrix and perform LU decomposition
|
//- Construct from lduMatrix and perform LU decomposition
|
||||||
LUscalarMatrix
|
LUscalarMatrix
|
||||||
|
|||||||
@ -28,8 +28,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
void Foam::Matrix<Type>::allocate()
|
void Foam::Matrix<Form, Type>::allocate()
|
||||||
{
|
{
|
||||||
if (n_ && m_)
|
if (n_ && m_)
|
||||||
{
|
{
|
||||||
@ -46,8 +46,8 @@ void Foam::Matrix<Type>::allocate()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type>::~Matrix()
|
Foam::Matrix<Form, Type>::~Matrix()
|
||||||
{
|
{
|
||||||
if (v_)
|
if (v_)
|
||||||
{
|
{
|
||||||
@ -59,16 +59,16 @@ Foam::Matrix<Type>::~Matrix()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
const Foam::Matrix<Type>& Foam::Matrix<Type>::null()
|
const Foam::Matrix<Form, Type>& Foam::Matrix<Form, Type>::null()
|
||||||
{
|
{
|
||||||
Matrix<Type>* nullPtr = reinterpret_cast<Matrix<Type>*>(NULL);
|
Matrix<Form, Type>* nullPtr = reinterpret_cast<Matrix<Form, Type>*>(NULL);
|
||||||
return *nullPtr;
|
return *nullPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type>::Matrix(const label n, const label m)
|
Foam::Matrix<Form, Type>::Matrix(const label n, const label m)
|
||||||
:
|
:
|
||||||
n_(n),
|
n_(n),
|
||||||
m_(m),
|
m_(m),
|
||||||
@ -76,7 +76,7 @@ Foam::Matrix<Type>::Matrix(const label n, const label m)
|
|||||||
{
|
{
|
||||||
if (n_ < 0 || m_ < 0)
|
if (n_ < 0 || m_ < 0)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Matrix<Type>::Matrix(const label n, const label m)")
|
FatalErrorIn("Matrix<Form, Type>::Matrix(const label n, const label m)")
|
||||||
<< "bad n, m " << n_ << ", " << m_
|
<< "bad n, m " << n_ << ", " << m_
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -85,8 +85,8 @@ Foam::Matrix<Type>::Matrix(const label n, const label m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type>::Matrix(const label n, const label m, const Type& a)
|
Foam::Matrix<Form, Type>::Matrix(const label n, const label m, const Type& a)
|
||||||
:
|
:
|
||||||
n_(n),
|
n_(n),
|
||||||
m_(m),
|
m_(m),
|
||||||
@ -96,7 +96,7 @@ Foam::Matrix<Type>::Matrix(const label n, const label m, const Type& a)
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Matrix<Type>::Matrix(const label n, const label m, const T&)"
|
"Matrix<Form, Type>::Matrix(const label n, const label m, const T&)"
|
||||||
) << "bad n, m " << n_ << ", " << m_
|
) << "bad n, m " << n_ << ", " << m_
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -117,8 +117,8 @@ Foam::Matrix<Type>::Matrix(const label n, const label m, const Type& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type>::Matrix(const Matrix<Type>& a)
|
Foam::Matrix<Form, Type>::Matrix(const Matrix<Form, Type>& a)
|
||||||
:
|
:
|
||||||
n_(a.n_),
|
n_(a.n_),
|
||||||
m_(a.m_),
|
m_(a.m_),
|
||||||
@ -139,8 +139,8 @@ Foam::Matrix<Type>::Matrix(const Matrix<Type>& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
void Foam::Matrix<Type>::clear()
|
void Foam::Matrix<Form, Type>::clear()
|
||||||
{
|
{
|
||||||
if (v_)
|
if (v_)
|
||||||
{
|
{
|
||||||
@ -153,8 +153,8 @@ void Foam::Matrix<Type>::clear()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
void Foam::Matrix<Type>::transfer(Matrix<Type>& a)
|
void Foam::Matrix<Form, Type>::transfer(Matrix<Form, Type>& a)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
@ -169,13 +169,11 @@ void Foam::Matrix<Type>::transfer(Matrix<Type>& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
template<class Form, class Type>
|
||||||
|
Form Foam::Matrix<Form, Type>::T() const
|
||||||
template<class Type>
|
|
||||||
Foam::Matrix<Type> Foam::Matrix<Type>::T() const
|
|
||||||
{
|
{
|
||||||
const Matrix<Type>& A = *this;
|
const Matrix<Form, Type>& A = *this;
|
||||||
Matrix<Type> At(m(), n());
|
Form At(m(), n());
|
||||||
|
|
||||||
for (register label i=0; i<n(); i++)
|
for (register label i=0; i<n(); i++)
|
||||||
{
|
{
|
||||||
@ -189,8 +187,10 @@ Foam::Matrix<Type> Foam::Matrix<Type>::T() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
void Foam::Matrix<Type>::operator=(const Type& t)
|
|
||||||
|
template<class Form, class Type>
|
||||||
|
void Foam::Matrix<Form, Type>::operator=(const Type& t)
|
||||||
{
|
{
|
||||||
if (v_)
|
if (v_)
|
||||||
{
|
{
|
||||||
@ -206,12 +206,12 @@ void Foam::Matrix<Type>::operator=(const Type& t)
|
|||||||
|
|
||||||
|
|
||||||
// Assignment operator. Takes linear time.
|
// Assignment operator. Takes linear time.
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
void Foam::Matrix<Type>::operator=(const Matrix<Type>& a)
|
void Foam::Matrix<Form, Type>::operator=(const Matrix<Form, Type>& a)
|
||||||
{
|
{
|
||||||
if (this == &a)
|
if (this == &a)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Matrix<Type>::operator=(const Matrix<Type>&)")
|
FatalErrorIn("Matrix<Form, Type>::operator=(const Matrix<Form, Type>&)")
|
||||||
<< "attempted assignment to self"
|
<< "attempted assignment to self"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -240,8 +240,8 @@ void Foam::Matrix<Type>::operator=(const Matrix<Type>& a)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
const Type& Foam::max(const Matrix<Type>& a)
|
const Type& Foam::max(const Matrix<Form, Type>& a)
|
||||||
{
|
{
|
||||||
label nm = a.n_*a.m_;
|
label nm = a.n_*a.m_;
|
||||||
|
|
||||||
@ -262,7 +262,7 @@ const Type& Foam::max(const Matrix<Type>& a)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorIn("max(const Matrix<Type>&)")
|
FatalErrorIn("max(const Matrix<Form, Type>&)")
|
||||||
<< "matrix is empty"
|
<< "matrix is empty"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
|
|
||||||
@ -272,8 +272,8 @@ const Type& Foam::max(const Matrix<Type>& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
const Type& Foam::min(const Matrix<Type>& a)
|
const Type& Foam::min(const Matrix<Form, Type>& a)
|
||||||
{
|
{
|
||||||
label nm = a.n_*a.m_;
|
label nm = a.n_*a.m_;
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ const Type& Foam::min(const Matrix<Type>& a)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorIn("min(const Matrix<Type>&)")
|
FatalErrorIn("min(const Matrix<Form, Type>&)")
|
||||||
<< "matrix is empty"
|
<< "matrix is empty"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
|
|
||||||
@ -306,10 +306,10 @@ const Type& Foam::min(const Matrix<Type>& a)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type> Foam::operator-(const Matrix<Type>& a)
|
Form Foam::operator-(const Matrix<Form, Type>& a)
|
||||||
{
|
{
|
||||||
Matrix<Type> na(a.n_, a.m_);
|
Form na(a.n_, a.m_);
|
||||||
|
|
||||||
if (a.n_ && a.m_)
|
if (a.n_ && a.m_)
|
||||||
{
|
{
|
||||||
@ -327,14 +327,14 @@ Foam::Matrix<Type> Foam::operator-(const Matrix<Type>& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type> Foam::operator+(const Matrix<Type>& a, const Matrix<Type>& b)
|
Form Foam::operator+(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
|
||||||
{
|
{
|
||||||
if (a.n_ != b.n_)
|
if (a.n_ != b.n_)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Matrix<Type>::operator+(const Matrix<Type>&, const Matrix<Type>&)"
|
"Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
|
||||||
) << "attempted add matrices with different number of rows: "
|
) << "attempted add matrices with different number of rows: "
|
||||||
<< a.n_ << ", " << b.n_
|
<< a.n_ << ", " << b.n_
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -344,13 +344,13 @@ Foam::Matrix<Type> Foam::operator+(const Matrix<Type>& a, const Matrix<Type>& b)
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Matrix<Type>::operator+(const Matrix<Type>&, const Matrix<Type>&)"
|
"Matrix<Form, Type>::operator+(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
|
||||||
) << "attempted add matrices with different number of columns: "
|
) << "attempted add matrices with different number of columns: "
|
||||||
<< a.m_ << ", " << b.m_
|
<< a.m_ << ", " << b.m_
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix<Type> ab(a.n_, a.m_);
|
Form ab(a.n_, a.m_);
|
||||||
|
|
||||||
Type* abv = ab.v_[0];
|
Type* abv = ab.v_[0];
|
||||||
const Type* av = a.v_[0];
|
const Type* av = a.v_[0];
|
||||||
@ -366,14 +366,14 @@ Foam::Matrix<Type> Foam::operator+(const Matrix<Type>& a, const Matrix<Type>& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type> Foam::operator-(const Matrix<Type>& a, const Matrix<Type>& b)
|
Form Foam::operator-(const Matrix<Form, Type>& a, const Matrix<Form, Type>& b)
|
||||||
{
|
{
|
||||||
if (a.n_ != b.n_)
|
if (a.n_ != b.n_)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Matrix<Type>::operator-(const Matrix<Type>&, const Matrix<Type>&)"
|
"Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
|
||||||
) << "attempted add matrices with different number of rows: "
|
) << "attempted add matrices with different number of rows: "
|
||||||
<< a.n_ << ", " << b.n_
|
<< a.n_ << ", " << b.n_
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -383,13 +383,13 @@ Foam::Matrix<Type> Foam::operator-(const Matrix<Type>& a, const Matrix<Type>& b)
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"Matrix<Type>::operator-(const Matrix<Type>&, const Matrix<Type>&)"
|
"Matrix<Form, Type>::operator-(const Matrix<Form, Type>&, const Matrix<Form, Type>&)"
|
||||||
) << "attempted add matrices with different number of columns: "
|
) << "attempted add matrices with different number of columns: "
|
||||||
<< a.m_ << ", " << b.m_
|
<< a.m_ << ", " << b.m_
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix<Type> ab(a.n_, a.m_);
|
Form ab(a.n_, a.m_);
|
||||||
|
|
||||||
Type* abv = ab.v_[0];
|
Type* abv = ab.v_[0];
|
||||||
const Type* av = a.v_[0];
|
const Type* av = a.v_[0];
|
||||||
@ -405,17 +405,17 @@ Foam::Matrix<Type> Foam::operator-(const Matrix<Type>& a, const Matrix<Type>& b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type> Foam::operator*(const scalar s, const Matrix<Type>& a)
|
Form Foam::operator*(const scalar s, const Matrix<Form, Type>& a)
|
||||||
{
|
{
|
||||||
Matrix<Type> sa(a.n_, a.m_);
|
Form sa(a.n_, a.m_);
|
||||||
|
|
||||||
if (a.n_ && a.m_)
|
if (a.n_ && a.m_)
|
||||||
{
|
{
|
||||||
Type* sav = sa.v_[0];
|
Type* sav = sa.v_[0];
|
||||||
const Type* av = a.v_[0];
|
const Type* av = a.v_[0];
|
||||||
|
|
||||||
label nm = a.n_*a.m_;;
|
label nm = a.n_*a.m_;
|
||||||
for (register label i=0; i<nm; i++)
|
for (register label i=0; i<nm; i++)
|
||||||
{
|
{
|
||||||
sav[i] = s*av[i];
|
sav[i] = s*av[i];
|
||||||
|
|||||||
@ -51,37 +51,26 @@ namespace Foam
|
|||||||
|
|
||||||
// Forward declaration of friend functions and operators
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
template<class Type> class Matrix;
|
template<class Form, class Type> class Matrix;
|
||||||
|
|
||||||
template<class Type> const Type& max(const Matrix<Type>&);
|
template<class Form, class Type> Istream& operator>>
|
||||||
template<class Type> const Type& min(const Matrix<Type>&);
|
|
||||||
|
|
||||||
template<class Type> Matrix<Type> operator-(const Matrix<Type>&);
|
|
||||||
template<class Type> Matrix<Type> operator+
|
|
||||||
(
|
(
|
||||||
const Matrix<Type>&,
|
Istream&,
|
||||||
const Matrix<Type>&
|
Matrix<Form, Type>&
|
||||||
);
|
|
||||||
template<class Type> Matrix<Type> operator-
|
|
||||||
(
|
|
||||||
const Matrix<Type>&,
|
|
||||||
const Matrix<Type>&
|
|
||||||
);
|
|
||||||
template<class Type> Matrix<Type> operator*
|
|
||||||
(
|
|
||||||
const scalar,
|
|
||||||
const Matrix<Type>&
|
|
||||||
);
|
);
|
||||||
|
|
||||||
template<class Type> Istream& operator>>(Istream&, Matrix<Type>&);
|
template<class Form, class Type> Ostream& operator<<
|
||||||
template<class Type> Ostream& operator<<(Ostream&, const Matrix<Type>&);
|
(
|
||||||
|
Ostream&,
|
||||||
|
const Matrix<Form, Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class Matrix Declaration
|
Class Matrix Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
class Matrix
|
class Matrix
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
@ -112,13 +101,13 @@ public:
|
|||||||
Matrix(const label n, const label m, const Type&);
|
Matrix(const label n, const label m, const Type&);
|
||||||
|
|
||||||
//- Copy constructor.
|
//- Copy constructor.
|
||||||
Matrix(const Matrix<Type>&);
|
Matrix(const Matrix<Form, Type>&);
|
||||||
|
|
||||||
//- Construct from Istream.
|
//- Construct from Istream.
|
||||||
Matrix(Istream&);
|
Matrix(Istream&);
|
||||||
|
|
||||||
//- Clone
|
//- Clone
|
||||||
inline autoPtr<Matrix<Type> > clone() const;
|
inline autoPtr<Matrix<Form, Type> > clone() const;
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@ -129,7 +118,7 @@ public:
|
|||||||
// Member functions
|
// Member functions
|
||||||
|
|
||||||
//- Return a null Matrix
|
//- Return a null Matrix
|
||||||
static const Matrix<Type>& null();
|
static const Matrix<Form, Type>& null();
|
||||||
|
|
||||||
|
|
||||||
// Access
|
// Access
|
||||||
@ -160,7 +149,11 @@ public:
|
|||||||
|
|
||||||
//- Transfer the contents of the argument Matrix into this Matrix
|
//- Transfer the contents of the argument Matrix into this Matrix
|
||||||
// and annull the argument Matrix.
|
// and annull the argument Matrix.
|
||||||
void transfer(Matrix<Type>&);
|
void transfer(Matrix<Form, Type>&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Return the transpose of the matrix
|
||||||
|
Form T() const;
|
||||||
|
|
||||||
|
|
||||||
// Member operators
|
// Member operators
|
||||||
@ -171,52 +164,49 @@ public:
|
|||||||
//- Return subscript-checked element of constant Matrix.
|
//- Return subscript-checked element of constant Matrix.
|
||||||
inline const Type* operator[](const label) const;
|
inline const Type* operator[](const label) const;
|
||||||
|
|
||||||
//- Return the transpose of the matrix
|
|
||||||
Matrix<Type> T() const;
|
|
||||||
|
|
||||||
//- Assignment operator. Takes linear time.
|
//- Assignment operator. Takes linear time.
|
||||||
void operator=(const Matrix<Type>&);
|
void operator=(const Matrix<Form, Type>&);
|
||||||
|
|
||||||
//- Assignment of all entries to the given value
|
//- Assignment of all entries to the given value
|
||||||
void operator=(const Type&);
|
void operator=(const Type&);
|
||||||
|
|
||||||
|
|
||||||
// Friend functions
|
|
||||||
|
|
||||||
friend const Type& max<Type>(const Matrix<Type>&);
|
|
||||||
friend const Type& min<Type>(const Matrix<Type>&);
|
|
||||||
|
|
||||||
|
|
||||||
// Friend operators
|
|
||||||
|
|
||||||
friend Matrix<Type> operator-<Type>(const Matrix<Type>&);
|
|
||||||
friend Matrix<Type> operator+<Type>
|
|
||||||
(
|
|
||||||
const Matrix<Type>&,
|
|
||||||
const Matrix<Type>&
|
|
||||||
);
|
|
||||||
friend Matrix<Type> operator-<Type>
|
|
||||||
(
|
|
||||||
const Matrix<Type>&,
|
|
||||||
const Matrix<Type>&
|
|
||||||
);
|
|
||||||
friend Matrix<Type> operator*<Type>
|
|
||||||
(
|
|
||||||
const scalar,
|
|
||||||
const Matrix<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// IOstream operators
|
// IOstream operators
|
||||||
|
|
||||||
//- Read Matrix from Istream, discarding contents of existing Matrix.
|
//- Read Matrix from Istream, discarding contents of existing Matrix.
|
||||||
friend Istream& operator>> <Type>(Istream&, Matrix<Type>&);
|
friend Istream& operator>> <Form, Type>(Istream&, Matrix<Form, Type>&);
|
||||||
|
|
||||||
// Write Matrix to Ostream.
|
// Write Matrix to Ostream.
|
||||||
friend Ostream& operator<< <Type>(Ostream&, const Matrix<Type>&);
|
friend Ostream& operator<< <Form, Type>(Ostream&, const Matrix<Form, Type>&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Global functions and operators
|
||||||
|
|
||||||
|
template<class Form, class Type> const Type& max(const Matrix<Form, Type>&);
|
||||||
|
template<class Form, class Type> const Type& min(const Matrix<Form, Type>&);
|
||||||
|
|
||||||
|
template<class Form, class Type> Form operator-(const Matrix<Form, Type>&);
|
||||||
|
|
||||||
|
template<class Form, class Type> Form operator+
|
||||||
|
(
|
||||||
|
const Matrix<Form, Type>&,
|
||||||
|
const Matrix<Form, Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Form, class Type> Form operator-
|
||||||
|
(
|
||||||
|
const Matrix<Form, Type>&,
|
||||||
|
const Matrix<Form, Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Form, class Type> Form operator*
|
||||||
|
(
|
||||||
|
const scalar,
|
||||||
|
const Matrix<Form, Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -26,8 +26,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline Foam::Matrix<Type>::Matrix()
|
inline Foam::Matrix<Form, Type>::Matrix()
|
||||||
:
|
:
|
||||||
n_(0),
|
n_(0),
|
||||||
m_(0),
|
m_(0),
|
||||||
@ -35,67 +35,67 @@ inline Foam::Matrix<Type>::Matrix()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline Foam::autoPtr<Foam::Matrix<Type> > Foam::Matrix<Type>::clone() const
|
inline Foam::autoPtr<Foam::Matrix<Form, Type> > Foam::Matrix<Form, Type>::clone() const
|
||||||
{
|
{
|
||||||
return autoPtr<Matrix<Type> >(new Matrix<Type>(*this));
|
return autoPtr<Matrix<Form, Type> >(new Matrix<Form, Type>(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
//- Return the number of rows
|
//- Return the number of rows
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline Foam::label Foam::Matrix<Type>::n() const
|
inline Foam::label Foam::Matrix<Form, Type>::n() const
|
||||||
{
|
{
|
||||||
return n_;
|
return n_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline Foam::label Foam::Matrix<Type>::m() const
|
inline Foam::label Foam::Matrix<Form, Type>::m() const
|
||||||
{
|
{
|
||||||
return m_;
|
return m_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline Foam::label Foam::Matrix<Type>::size() const
|
inline Foam::label Foam::Matrix<Form, Type>::size() const
|
||||||
{
|
{
|
||||||
return n_*m_;
|
return n_*m_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline void Foam::Matrix<Type>::checki(const label i) const
|
inline void Foam::Matrix<Form, Type>::checki(const label i) const
|
||||||
{
|
{
|
||||||
if (!n_)
|
if (!n_)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Matrix<Type>::checki(const label)")
|
FatalErrorIn("Matrix<Form, Type>::checki(const label)")
|
||||||
<< "attempt to access element from zero sized row"
|
<< "attempt to access element from zero sized row"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
else if (i<0 || i>=n_)
|
else if (i<0 || i>=n_)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Matrix<Type>::checki(const label)")
|
FatalErrorIn("Matrix<Form, Type>::checki(const label)")
|
||||||
<< "index " << i << " out of range 0 ... " << n_-1
|
<< "index " << i << " out of range 0 ... " << n_-1
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline void Foam::Matrix<Type>::checkj(const label j) const
|
inline void Foam::Matrix<Form, Type>::checkj(const label j) const
|
||||||
{
|
{
|
||||||
if (!m_)
|
if (!m_)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Matrix<Type>::checkj(const label)")
|
FatalErrorIn("Matrix<Form, Type>::checkj(const label)")
|
||||||
<< "attempt to access element from zero sized column"
|
<< "attempt to access element from zero sized column"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
else if (j<0 || j>=m_)
|
else if (j<0 || j>=m_)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Matrix<Type>::checkj(const label)")
|
FatalErrorIn("Matrix<Form, Type>::checkj(const label)")
|
||||||
<< "index " << j << " out of range 0 ... " << m_-1
|
<< "index " << j << " out of range 0 ... " << m_-1
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
@ -104,8 +104,8 @@ inline void Foam::Matrix<Type>::checkj(const label j) const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline Type* Foam::Matrix<Type>::operator[](const label i)
|
inline Type* Foam::Matrix<Form, Type>::operator[](const label i)
|
||||||
{
|
{
|
||||||
# ifdef FULLDEBUG
|
# ifdef FULLDEBUG
|
||||||
checki(i);
|
checki(i);
|
||||||
@ -114,8 +114,8 @@ inline Type* Foam::Matrix<Type>::operator[](const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
inline const Type* Foam::Matrix<Type>::operator[](const label i) const
|
inline const Type* Foam::Matrix<Form, Type>::operator[](const label i) const
|
||||||
{
|
{
|
||||||
# ifdef FULLDEBUG
|
# ifdef FULLDEBUG
|
||||||
checki(i);
|
checki(i);
|
||||||
|
|||||||
@ -32,8 +32,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Matrix<Type>::Matrix(Istream& is)
|
Foam::Matrix<Form, Type>::Matrix(Istream& is)
|
||||||
:
|
:
|
||||||
n_(0),
|
n_(0),
|
||||||
m_(0),
|
m_(0),
|
||||||
@ -43,17 +43,17 @@ Foam::Matrix<Type>::Matrix(Istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, Matrix<Type>& M)
|
Foam::Istream& Foam::operator>>(Istream& is, Matrix<Form, Type>& M)
|
||||||
{
|
{
|
||||||
// Anull matrix
|
// Anull matrix
|
||||||
M.clear();
|
M.clear();
|
||||||
|
|
||||||
is.fatalCheck("operator>>(Istream&, Matrix<Type>&)");
|
is.fatalCheck("operator>>(Istream&, Matrix<Form, Type>&)");
|
||||||
|
|
||||||
token firstToken(is);
|
token firstToken(is);
|
||||||
|
|
||||||
is.fatalCheck("operator>>(Istream&, Matrix<Type>&) : reading first token");
|
is.fatalCheck("operator>>(Istream&, Matrix<Form, Type>&) : reading first token");
|
||||||
|
|
||||||
if (firstToken.isLabel())
|
if (firstToken.isLabel())
|
||||||
{
|
{
|
||||||
@ -88,7 +88,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<Type>& M)
|
|||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
"operator>>(Istream&, Matrix<Type>&) : "
|
"operator>>(Istream&, Matrix<Form, Type>&) : "
|
||||||
"reading entry"
|
"reading entry"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<Type>& M)
|
|||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
"operator>>(Istream&, Matrix<Type>&) : "
|
"operator>>(Istream&, Matrix<Form, Type>&) : "
|
||||||
"reading the single entry"
|
"reading the single entry"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<Type>& M)
|
|||||||
|
|
||||||
is.fatalCheck
|
is.fatalCheck
|
||||||
(
|
(
|
||||||
"operator>>(Istream&, Matrix<Type>&) : "
|
"operator>>(Istream&, Matrix<Form, Type>&) : "
|
||||||
"reading the binary block"
|
"reading the binary block"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<Type>& M)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalIOErrorIn("operator>>(Istream&, Matrix<Type>&)", is)
|
FatalIOErrorIn("operator>>(Istream&, Matrix<Form, Type>&)", is)
|
||||||
<< "incorrect first token, expected <int>, found "
|
<< "incorrect first token, expected <int>, found "
|
||||||
<< firstToken.info()
|
<< firstToken.info()
|
||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
@ -146,8 +146,8 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix<Type>& M)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Form, class Type>
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Type>& M)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
|
||||||
{
|
{
|
||||||
label nm = M.n_*M.m_;
|
label nm = M.n_*M.m_;
|
||||||
|
|
||||||
|
|||||||
92
src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H
Normal file
92
src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrix.H
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::RectangularMatrix
|
||||||
|
|
||||||
|
Description
|
||||||
|
A templated 2D rectangular matrix of objects of \<T\>, where the n x n matrix
|
||||||
|
dimension is known and used for subscript bounds checking, etc.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
RectangularMatrixI.H
|
||||||
|
RectangularMatrix.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef RectangularMatrix_H
|
||||||
|
#define RectangularMatrix_H
|
||||||
|
|
||||||
|
#include "Matrix.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class Matrix Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class RectangularMatrix
|
||||||
|
:
|
||||||
|
public Matrix<RectangularMatrix<Type>, Type>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Null constructor.
|
||||||
|
inline RectangularMatrix();
|
||||||
|
|
||||||
|
//- Construct given number of rows and columns,
|
||||||
|
inline RectangularMatrix(const label m, const label n);
|
||||||
|
|
||||||
|
//- Construct with given number of rows and columns
|
||||||
|
// and value for all elements.
|
||||||
|
inline RectangularMatrix(const label m, const label n, const Type&);
|
||||||
|
|
||||||
|
//- Construct from Istream.
|
||||||
|
inline RectangularMatrix(Istream&);
|
||||||
|
|
||||||
|
//- Clone
|
||||||
|
inline autoPtr<RectangularMatrix<Type> > clone() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
# include "RectangularMatrixI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
70
src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H
Normal file
70
src/OpenFOAM/matrices/RectangularMatrix/RectangularMatrixI.H
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::RectangularMatrix<Type>::RectangularMatrix()
|
||||||
|
:
|
||||||
|
Matrix<RectangularMatrix<Type>, Type>()
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::RectangularMatrix<Type>::RectangularMatrix
|
||||||
|
(
|
||||||
|
const label m,
|
||||||
|
const label n
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Matrix<RectangularMatrix<Type>, Type>(m, n)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::RectangularMatrix<Type>::RectangularMatrix
|
||||||
|
(
|
||||||
|
const label m,
|
||||||
|
const label n,
|
||||||
|
const Type& t
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Matrix<RectangularMatrix<Type>, Type>(m, n, t)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::RectangularMatrix<Type>::RectangularMatrix(Istream& is)
|
||||||
|
:
|
||||||
|
Matrix<RectangularMatrix<Type>, Type>(is)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::autoPtr<Foam::RectangularMatrix<Type> >
|
||||||
|
Foam::RectangularMatrix<Type>::clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<RectangularMatrix<Type> >(new RectangularMatrix<Type>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
97
src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H
Normal file
97
src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::SquareMatrix
|
||||||
|
|
||||||
|
Description
|
||||||
|
A templated 2D square matrix of objects of \<T\>, where the n x n matrix
|
||||||
|
dimension is known and used for subscript bounds checking, etc.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
SquareMatrixI.H
|
||||||
|
SquareMatrix.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef SquareMatrix_H
|
||||||
|
#define SquareMatrix_H
|
||||||
|
|
||||||
|
#include "Matrix.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class Matrix Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
class SquareMatrix
|
||||||
|
:
|
||||||
|
public Matrix<SquareMatrix<Type>, Type>
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Null constructor.
|
||||||
|
inline SquareMatrix();
|
||||||
|
|
||||||
|
//- Construct given number of rows/columns.
|
||||||
|
inline SquareMatrix(const label n);
|
||||||
|
|
||||||
|
//- Construct given number of rows and columns,
|
||||||
|
// It checks that m == n.
|
||||||
|
inline SquareMatrix(const label m, const label n);
|
||||||
|
|
||||||
|
//- Construct with given number of rows and rows
|
||||||
|
// and value for all elements.
|
||||||
|
// It checks that m == n.
|
||||||
|
inline SquareMatrix(const label m, const label n, const Type&);
|
||||||
|
|
||||||
|
//- Construct from Istream.
|
||||||
|
inline SquareMatrix(Istream&);
|
||||||
|
|
||||||
|
//- Clone
|
||||||
|
inline autoPtr<SquareMatrix<Type> > clone() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
# include "SquareMatrixI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
89
src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H
Normal file
89
src/OpenFOAM/matrices/SquareMatrix/SquareMatrixI.H
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::SquareMatrix<Type>::SquareMatrix()
|
||||||
|
:
|
||||||
|
Matrix<SquareMatrix<Type>, Type>()
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::SquareMatrix<Type>::SquareMatrix(const label n)
|
||||||
|
:
|
||||||
|
Matrix<SquareMatrix<Type>, Type>(n, n)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::SquareMatrix<Type>::SquareMatrix(const label m, const label n)
|
||||||
|
:
|
||||||
|
Matrix<SquareMatrix<Type>, Type>(m, n)
|
||||||
|
{
|
||||||
|
if (m != n)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"SquareMatrix<Type>::SquareMatrix(const label m, const label n)"
|
||||||
|
) << "m != n for constructing a square matrix" << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::SquareMatrix<Type>::SquareMatrix
|
||||||
|
(
|
||||||
|
const label m,
|
||||||
|
const label n,
|
||||||
|
const Type& t
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Matrix<SquareMatrix<Type>, Type>(m, n, t)
|
||||||
|
{
|
||||||
|
if (m != n)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"SquareMatrix<Type>::SquareMatrix"
|
||||||
|
"(const label m, const label n, const Type&)"
|
||||||
|
) << "m != n for constructing a square matrix" << exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::SquareMatrix<Type>::SquareMatrix(Istream& is)
|
||||||
|
:
|
||||||
|
Matrix<SquareMatrix<Type>, Type>(is)
|
||||||
|
{}
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
inline Foam::autoPtr<Foam::SquareMatrix<Type> >
|
||||||
|
Foam::SquareMatrix<Type>::clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<SquareMatrix<Type> >(new SquareMatrix<Type>(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -26,12 +26,12 @@ License
|
|||||||
|
|
||||||
#include "SVD.H"
|
#include "SVD.H"
|
||||||
#include "scalarList.H"
|
#include "scalarList.H"
|
||||||
#include "scalarMatrix.H"
|
#include "scalarMatrices.H"
|
||||||
#include "ListOps.H"
|
#include "ListOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::SVD::SVD(const Matrix<scalar>& A, const scalar minCondition)
|
Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
|
||||||
:
|
:
|
||||||
U_(A),
|
U_(A),
|
||||||
V_(A.m(), A.m()),
|
V_(A.m(), A.m()),
|
||||||
@ -294,8 +294,11 @@ Foam::SVD::SVD(const Matrix<scalar>& A, const scalar minCondition)
|
|||||||
}
|
}
|
||||||
if (its == 34)
|
if (its == 34)
|
||||||
{
|
{
|
||||||
WarningIn("SVD::SVD(Matrix<scalar>& A)")
|
WarningIn
|
||||||
<< "no convergence in 35 SVD iterations"
|
(
|
||||||
|
"SVD::SVD"
|
||||||
|
"(scalarRectangularMatrix& A, const scalar minCondition)"
|
||||||
|
) << "no convergence in 35 SVD iterations"
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,7 +378,7 @@ Foam::SVD::SVD(const Matrix<scalar>& A, const scalar minCondition)
|
|||||||
multiply(VSinvUt_, V_, inv(S_), U_.T());
|
multiply(VSinvUt_, V_, inv(S_), U_.T());
|
||||||
|
|
||||||
// test SVD
|
// test SVD
|
||||||
/*Matrix<scalar> SVDA(A.n(), A.m());
|
/*scalarRectangularMatrix SVDA(A.n(), A.m());
|
||||||
multiply(SVDA, U_, S_, transpose(V_));
|
multiply(SVDA, U_, S_, transpose(V_));
|
||||||
scalar maxDiff = 0;
|
scalar maxDiff = 0;
|
||||||
scalar diff = 0;
|
scalar diff = 0;
|
||||||
@ -23,12 +23,13 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Class
|
Class
|
||||||
SVD
|
Foam::SVD
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Singular value decomposition of a rectangular matrix.
|
Singular value decomposition of a rectangular matrix.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
|
SVDI.H
|
||||||
SVD.C
|
SVD.C
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -36,8 +37,7 @@ SourceFiles
|
|||||||
#ifndef SVD_H
|
#ifndef SVD_H
|
||||||
#define SVD_H
|
#define SVD_H
|
||||||
|
|
||||||
#include "DiagonalMatrix.H"
|
#include "scalarMatrices.H"
|
||||||
#include "Matrix.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -56,16 +56,16 @@ class SVD
|
|||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Rectangular matrix with the same dimensions as the input
|
//- Rectangular matrix with the same dimensions as the input
|
||||||
Matrix<scalar> U_;
|
scalarRectangularMatrix U_;
|
||||||
|
|
||||||
//- square matrix V
|
//- square matrix V
|
||||||
Matrix<scalar> V_;
|
scalarRectangularMatrix V_;
|
||||||
|
|
||||||
//- The singular values
|
//- The singular values
|
||||||
DiagonalMatrix<scalar> S_;
|
DiagonalMatrix<scalar> S_;
|
||||||
|
|
||||||
//- The matrix product V S^(-1) U^T
|
//- The matrix product V S^(-1) U^T
|
||||||
Matrix<scalar> VSinvUt_;
|
scalarRectangularMatrix VSinvUt_;
|
||||||
|
|
||||||
//- The number of zero singular values
|
//- The number of zero singular values
|
||||||
label nZeros_;
|
label nZeros_;
|
||||||
@ -88,22 +88,22 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from a rectangular Matrix
|
//- Construct from a rectangular Matrix
|
||||||
SVD(const Matrix<scalar>& A, const scalar minCondition = 0);
|
SVD(const scalarRectangularMatrix& A, const scalar minCondition = 0);
|
||||||
|
|
||||||
|
|
||||||
// Access functions
|
// Access functions
|
||||||
|
|
||||||
//- Return U
|
//- Return U
|
||||||
inline const Matrix<scalar>& U() const;
|
inline const scalarRectangularMatrix& U() const;
|
||||||
|
|
||||||
//- Return the square matrix V
|
//- Return the square matrix V
|
||||||
inline const Matrix<scalar>& V() const;
|
inline const scalarRectangularMatrix& V() const;
|
||||||
|
|
||||||
//- Return the singular values
|
//- Return the singular values
|
||||||
inline const DiagonalMatrix<scalar>& S() const;
|
inline const scalarDiagonalMatrix& S() const;
|
||||||
|
|
||||||
//- Return VSinvUt (the pseudo inverse)
|
//- Return VSinvUt (the pseudo inverse)
|
||||||
inline const Matrix<scalar>& VSinvUt() const;
|
inline const scalarRectangularMatrix& VSinvUt() const;
|
||||||
|
|
||||||
//- Return the number of zero singular values
|
//- Return the number of zero singular values
|
||||||
inline label nZeros() const;
|
inline label nZeros() const;
|
||||||
@ -35,22 +35,22 @@ inline const T Foam::SVD::sign(const T& a, const T& b)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
inline const Foam::Matrix<Foam::scalar>& Foam::SVD::U() const
|
inline const Foam::scalarRectangularMatrix& Foam::SVD::U() const
|
||||||
{
|
{
|
||||||
return U_;
|
return U_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Foam::Matrix<Foam::scalar>& Foam::SVD::V() const
|
inline const Foam::scalarRectangularMatrix& Foam::SVD::V() const
|
||||||
{
|
{
|
||||||
return V_;
|
return V_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Foam::DiagonalMatrix<Foam::scalar>& Foam::SVD::S() const
|
inline const Foam::scalarDiagonalMatrix& Foam::SVD::S() const
|
||||||
{
|
{
|
||||||
return S_;
|
return S_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const Foam::Matrix<Foam::scalar>& Foam::SVD::VSinvUt() const
|
inline const Foam::scalarRectangularMatrix& Foam::SVD::VSinvUt() const
|
||||||
{
|
{
|
||||||
return VSinvUt_;
|
return VSinvUt_;
|
||||||
}
|
}
|
||||||
@ -24,39 +24,14 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "scalarMatrix.H"
|
#include "scalarMatrices.H"
|
||||||
#include "SVD.H"
|
#include "SVD.H"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::scalarMatrix::scalarMatrix()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::scalarMatrix::scalarMatrix(const label mSize)
|
|
||||||
:
|
|
||||||
Matrix<scalar>(mSize, mSize, 0.0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::scalarMatrix::scalarMatrix(const Matrix<scalar>& matrix)
|
|
||||||
:
|
|
||||||
Matrix<scalar>(matrix)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::scalarMatrix::scalarMatrix(Istream& is)
|
|
||||||
:
|
|
||||||
Matrix<scalar>(is)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::scalarMatrix::LUDecompose
|
void Foam::LUDecompose
|
||||||
(
|
(
|
||||||
Matrix<scalar>& matrix,
|
scalarSquareMatrix& matrix,
|
||||||
labelList& pivotIndices
|
labelList& pivotIndices
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -81,8 +56,8 @@ void Foam::scalarMatrix::LUDecompose
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"scalarMatrix::LUdecompose"
|
"LUdecompose"
|
||||||
"(Matrix<scalar>& matrix, labelList& rowIndices)"
|
"(scalarSquareMatrix& matrix, labelList& rowIndices)"
|
||||||
) << "Singular matrix" << exit(FatalError);
|
) << "Singular matrix" << exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,9 +139,9 @@ void Foam::scalarMatrix::LUDecompose
|
|||||||
|
|
||||||
void Foam::multiply
|
void Foam::multiply
|
||||||
(
|
(
|
||||||
Matrix<scalar>& ans, // value changed in return
|
scalarRectangularMatrix& ans, // value changed in return
|
||||||
const Matrix<scalar>& A,
|
const scalarRectangularMatrix& A,
|
||||||
const Matrix<scalar>& B
|
const scalarRectangularMatrix& B
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (A.m() != B.n())
|
if (A.m() != B.n())
|
||||||
@ -174,15 +149,15 @@ void Foam::multiply
|
|||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"multiply("
|
"multiply("
|
||||||
"Matrix<scalar>& answer "
|
"scalarRectangularMatrix& answer "
|
||||||
"const Matrix<scalar>& A, "
|
"const scalarRectangularMatrix& A, "
|
||||||
"const Matrix<scalar>& B)"
|
"const scalarRectangularMatrix& B)"
|
||||||
) << "A and B must have identical inner dimensions but A.m = "
|
) << "A and B must have identical inner dimensions but A.m = "
|
||||||
<< A.m() << " and B.n = " << B.n()
|
<< A.m() << " and B.n = " << B.n()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
ans = Matrix<scalar>(A.n(), B.m(), scalar(0));
|
ans = scalarRectangularMatrix(A.n(), B.m(), scalar(0));
|
||||||
|
|
||||||
for(register label i = 0; i < A.n(); i++)
|
for(register label i = 0; i < A.n(); i++)
|
||||||
{
|
{
|
||||||
@ -199,10 +174,10 @@ void Foam::multiply
|
|||||||
|
|
||||||
void Foam::multiply
|
void Foam::multiply
|
||||||
(
|
(
|
||||||
Matrix<scalar>& ans, // value changed in return
|
scalarRectangularMatrix& ans, // value changed in return
|
||||||
const Matrix<scalar>& A,
|
const scalarRectangularMatrix& A,
|
||||||
const Matrix<scalar>& B,
|
const scalarRectangularMatrix& B,
|
||||||
const Matrix<scalar>& C
|
const scalarRectangularMatrix& C
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (A.m() != B.n())
|
if (A.m() != B.n())
|
||||||
@ -210,10 +185,10 @@ void Foam::multiply
|
|||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"multiply("
|
"multiply("
|
||||||
"const Matrix<scalar>& A, "
|
"const scalarRectangularMatrix& A, "
|
||||||
"const Matrix<scalar>& B, "
|
"const scalarRectangularMatrix& B, "
|
||||||
"const Matrix<scalar>& C, "
|
"const scalarRectangularMatrix& C, "
|
||||||
"Matrix<scalar>& answer)"
|
"scalarRectangularMatrix& answer)"
|
||||||
) << "A and B must have identical inner dimensions but A.m = "
|
) << "A and B must have identical inner dimensions but A.m = "
|
||||||
<< A.m() << " and B.n = " << B.n()
|
<< A.m() << " and B.n = " << B.n()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -224,16 +199,16 @@ void Foam::multiply
|
|||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"multiply("
|
"multiply("
|
||||||
"const Matrix<scalar>& A, "
|
"const scalarRectangularMatrix& A, "
|
||||||
"const Matrix<scalar>& B, "
|
"const scalarRectangularMatrix& B, "
|
||||||
"const Matrix<scalar>& C, "
|
"const scalarRectangularMatrix& C, "
|
||||||
"Matrix<scalar>& answer)"
|
"scalarRectangularMatrix& answer)"
|
||||||
) << "B and C must have identical inner dimensions but B.m = "
|
) << "B and C must have identical inner dimensions but B.m = "
|
||||||
<< B.m() << " and C.n = " << C.n()
|
<< B.m() << " and C.n = " << C.n()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
ans = Matrix<scalar>(A.n(), C.m(), scalar(0));
|
ans = scalarRectangularMatrix(A.n(), C.m(), scalar(0));
|
||||||
|
|
||||||
for(register label i = 0; i < A.n(); i++)
|
for(register label i = 0; i < A.n(); i++)
|
||||||
{
|
{
|
||||||
@ -255,10 +230,10 @@ void Foam::multiply
|
|||||||
|
|
||||||
void Foam::multiply
|
void Foam::multiply
|
||||||
(
|
(
|
||||||
Matrix<scalar>& ans, // value changed in return
|
scalarRectangularMatrix& ans, // value changed in return
|
||||||
const Matrix<scalar>& A,
|
const scalarRectangularMatrix& A,
|
||||||
const DiagonalMatrix<scalar>& B,
|
const DiagonalMatrix<scalar>& B,
|
||||||
const Matrix<scalar>& C
|
const scalarRectangularMatrix& C
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (A.m() != B.size())
|
if (A.m() != B.size())
|
||||||
@ -266,10 +241,10 @@ void Foam::multiply
|
|||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"multiply("
|
"multiply("
|
||||||
"const Matrix<scalar>& A, "
|
"const scalarRectangularMatrix& A, "
|
||||||
"const DiagonalMatrix<scalar>& B, "
|
"const DiagonalMatrix<scalar>& B, "
|
||||||
"const Matrix<scalar>& C, "
|
"const scalarRectangularMatrix& C, "
|
||||||
"Matrix<scalar>& answer)"
|
"scalarRectangularMatrix& answer)"
|
||||||
) << "A and B must have identical inner dimensions but A.m = "
|
) << "A and B must have identical inner dimensions but A.m = "
|
||||||
<< A.m() << " and B.n = " << B.size()
|
<< A.m() << " and B.n = " << B.size()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
@ -280,16 +255,16 @@ void Foam::multiply
|
|||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"multiply("
|
"multiply("
|
||||||
"const Matrix<scalar>& A, "
|
"const scalarRectangularMatrix& A, "
|
||||||
"const DiagonalMatrix<scalar>& B, "
|
"const DiagonalMatrix<scalar>& B, "
|
||||||
"const Matrix<scalar>& C, "
|
"const scalarRectangularMatrix& C, "
|
||||||
"Matrix<scalar>& answer)"
|
"scalarRectangularMatrix& answer)"
|
||||||
) << "B and C must have identical inner dimensions but B.m = "
|
) << "B and C must have identical inner dimensions but B.m = "
|
||||||
<< B.size() << " and C.n = " << C.n()
|
<< B.size() << " and C.n = " << C.n()
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
ans = Matrix<scalar>(A.n(), C.m(), scalar(0));
|
ans = scalarRectangularMatrix(A.n(), C.m(), scalar(0));
|
||||||
|
|
||||||
for(register label i = 0; i < A.n(); i++)
|
for(register label i = 0; i < A.n(); i++)
|
||||||
{
|
{
|
||||||
@ -304,9 +279,9 @@ void Foam::multiply
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Matrix<Foam::scalar> Foam::SVDinv
|
Foam::RectangularMatrix<Foam::scalar> Foam::SVDinv
|
||||||
(
|
(
|
||||||
const Matrix<scalar>& A,
|
const scalarRectangularMatrix& A,
|
||||||
scalar minCondition
|
scalar minCondition
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
137
src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.H
Normal file
137
src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.H
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
scalarMatrices
|
||||||
|
|
||||||
|
Description
|
||||||
|
Scalar matrices
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
scalarMatrices.C
|
||||||
|
scalarMatricesTemplates.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef scalarMatrices_H
|
||||||
|
#define scalarMatrices_H
|
||||||
|
|
||||||
|
#include "RectangularMatrix.H"
|
||||||
|
#include "SquareMatrix.H"
|
||||||
|
#include "DiagonalMatrix.H"
|
||||||
|
#include "scalarField.H"
|
||||||
|
#include "labelList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef RectangularMatrix<scalar> scalarRectangularMatrix;
|
||||||
|
typedef SquareMatrix<scalar> scalarSquareMatrix;
|
||||||
|
typedef DiagonalMatrix<scalar> scalarDiagonalMatrix;
|
||||||
|
|
||||||
|
//- Solve the matrix using Gaussian elimination with pivoting,
|
||||||
|
// returning the solution in the source
|
||||||
|
template<class Type>
|
||||||
|
void solve(scalarSquareMatrix& matrix, Field<Type>& source);
|
||||||
|
|
||||||
|
//- Solve the matrix using Gaussian elimination with pivoting
|
||||||
|
// and return the solution
|
||||||
|
template<class Type>
|
||||||
|
void solve
|
||||||
|
(
|
||||||
|
Field<Type>& psi,
|
||||||
|
const scalarSquareMatrix& matrix,
|
||||||
|
const Field<Type>& source
|
||||||
|
);
|
||||||
|
|
||||||
|
//- LU decompose the matrix with pivoting
|
||||||
|
void LUDecompose
|
||||||
|
(
|
||||||
|
scalarSquareMatrix& matrix,
|
||||||
|
labelList& pivotIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
//- LU back-substitution with given source, returning the solution
|
||||||
|
// in the source
|
||||||
|
template<class Type>
|
||||||
|
void LUBacksubstitute
|
||||||
|
(
|
||||||
|
const scalarSquareMatrix& luMmatrix,
|
||||||
|
const labelList& pivotIndices,
|
||||||
|
Field<Type>& source
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Solve the matrix using LU decomposition with pivoting
|
||||||
|
// returning the LU form of the matrix and the solution in the source
|
||||||
|
template<class Type>
|
||||||
|
void LUsolve(scalarSquareMatrix& matrix, Field<Type>& source);
|
||||||
|
|
||||||
|
void multiply
|
||||||
|
(
|
||||||
|
scalarRectangularMatrix& answer, // value changed in return
|
||||||
|
const scalarRectangularMatrix& A,
|
||||||
|
const scalarRectangularMatrix& B
|
||||||
|
);
|
||||||
|
|
||||||
|
void multiply
|
||||||
|
(
|
||||||
|
scalarRectangularMatrix& answer, // value changed in return
|
||||||
|
const scalarRectangularMatrix& A,
|
||||||
|
const scalarRectangularMatrix& B,
|
||||||
|
const scalarRectangularMatrix& C
|
||||||
|
);
|
||||||
|
|
||||||
|
void multiply
|
||||||
|
(
|
||||||
|
scalarRectangularMatrix& answer, // value changed in return
|
||||||
|
const scalarRectangularMatrix& A,
|
||||||
|
const DiagonalMatrix<scalar>& B,
|
||||||
|
const scalarRectangularMatrix& C
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return the inverse of matrix A using SVD
|
||||||
|
scalarRectangularMatrix SVDinv
|
||||||
|
(
|
||||||
|
const scalarRectangularMatrix& A,
|
||||||
|
scalar minCondition = 0
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "scalarMatricesTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -24,15 +24,15 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "scalarMatrix.H"
|
#include "scalarMatrices.H"
|
||||||
#include "Swap.H"
|
#include "Swap.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::scalarMatrix::solve
|
void Foam::solve
|
||||||
(
|
(
|
||||||
Matrix<scalar>& tmpMatrix,
|
scalarSquareMatrix& tmpMatrix,
|
||||||
Field<Type>& sourceSol
|
Field<Type>& sourceSol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ void Foam::scalarMatrix::solve
|
|||||||
// Check that the system of equations isn't singular
|
// Check that the system of equations isn't singular
|
||||||
if (mag(tmpMatrix[i][i]) < 1e-20)
|
if (mag(tmpMatrix[i][i]) < 1e-20)
|
||||||
{
|
{
|
||||||
FatalErrorIn("scalarMatrix::solve()")
|
FatalErrorIn("solve(scalarSquareMatrix&, Field<Type>& sourceSol)")
|
||||||
<< "Singular Matrix"
|
<< "Singular Matrix"
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
@ -102,18 +102,23 @@ void Foam::scalarMatrix::solve
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::scalarMatrix::solve(Field<Type>& psi, const Field<Type>& source) const
|
void Foam::solve
|
||||||
|
(
|
||||||
|
Field<Type>& psi,
|
||||||
|
const scalarSquareMatrix& matrix,
|
||||||
|
const Field<Type>& source
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Matrix<scalar> tmpMatrix = *this;
|
scalarSquareMatrix tmpMatrix = matrix;
|
||||||
psi = source;
|
psi = source;
|
||||||
solve(tmpMatrix, psi);
|
solve(tmpMatrix, psi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::scalarMatrix::LUBacksubstitute
|
void Foam::LUBacksubstitute
|
||||||
(
|
(
|
||||||
const Matrix<scalar>& luMatrix,
|
const scalarSquareMatrix& luMatrix,
|
||||||
const labelList& pivotIndices,
|
const labelList& pivotIndices,
|
||||||
Field<Type>& sourceSol
|
Field<Type>& sourceSol
|
||||||
)
|
)
|
||||||
@ -160,9 +165,9 @@ void Foam::scalarMatrix::LUBacksubstitute
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::scalarMatrix::LUsolve
|
void Foam::LUsolve
|
||||||
(
|
(
|
||||||
Matrix<scalar>& matrix,
|
scalarSquareMatrix& matrix,
|
||||||
Field<Type>& sourceSol
|
Field<Type>& sourceSol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -1,155 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
|
||||||
\\/ M anipulation |
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
License
|
|
||||||
This file is part of OpenFOAM.
|
|
||||||
|
|
||||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
|
||||||
under the terms of the GNU General Public License as published by the
|
|
||||||
Free Software Foundation; either version 2 of the License, or (at your
|
|
||||||
option) any later version.
|
|
||||||
|
|
||||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
|
|
||||||
Class
|
|
||||||
Foam::scalarMatrix
|
|
||||||
|
|
||||||
Description
|
|
||||||
Foam::scalarMatrix
|
|
||||||
|
|
||||||
SourceFiles
|
|
||||||
scalarMatrix.C
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#ifndef scalarMatrix_H
|
|
||||||
#define scalarMatrix_H
|
|
||||||
|
|
||||||
#include "Matrix.H"
|
|
||||||
#include "DiagonalMatrix.H"
|
|
||||||
#include "scalarField.H"
|
|
||||||
#include "labelList.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
Class scalarMatrix Declaration
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
class scalarMatrix
|
|
||||||
:
|
|
||||||
public Matrix<scalar>
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
// Constructors
|
|
||||||
|
|
||||||
//- Construct null
|
|
||||||
scalarMatrix();
|
|
||||||
|
|
||||||
//- Construct given size
|
|
||||||
scalarMatrix(const label);
|
|
||||||
|
|
||||||
//- Construct from Matrix<scalar>
|
|
||||||
scalarMatrix(const Matrix<scalar>&);
|
|
||||||
|
|
||||||
//- Construct from Istream
|
|
||||||
scalarMatrix(Istream&);
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
|
||||||
|
|
||||||
//- Solve the matrix using Gaussian elimination with pivoting,
|
|
||||||
// returning the solution in the source
|
|
||||||
template<class Type>
|
|
||||||
static void solve(Matrix<scalar>& matrix, Field<Type>& source);
|
|
||||||
|
|
||||||
//- Solve the matrix using Gaussian elimination with pivoting
|
|
||||||
// and return the solution
|
|
||||||
template<class Type>
|
|
||||||
void solve(Field<Type>& psi, const Field<Type>& source) const;
|
|
||||||
|
|
||||||
|
|
||||||
//- LU decompose the matrix with pivoting
|
|
||||||
static void LUDecompose
|
|
||||||
(
|
|
||||||
Matrix<scalar>& matrix,
|
|
||||||
labelList& pivotIndices
|
|
||||||
);
|
|
||||||
|
|
||||||
//- LU back-substitution with given source, returning the solution
|
|
||||||
// in the source
|
|
||||||
template<class Type>
|
|
||||||
static void LUBacksubstitute
|
|
||||||
(
|
|
||||||
const Matrix<scalar>& luMmatrix,
|
|
||||||
const labelList& pivotIndices,
|
|
||||||
Field<Type>& source
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Solve the matrix using LU decomposition with pivoting
|
|
||||||
// returning the LU form of the matrix and the solution in the source
|
|
||||||
template<class Type>
|
|
||||||
static void LUsolve(Matrix<scalar>& matrix, Field<Type>& source);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// Global functions
|
|
||||||
|
|
||||||
void multiply
|
|
||||||
(
|
|
||||||
Matrix<scalar>& answer, // value changed in return
|
|
||||||
const Matrix<scalar>& A,
|
|
||||||
const Matrix<scalar>& B
|
|
||||||
);
|
|
||||||
|
|
||||||
void multiply
|
|
||||||
(
|
|
||||||
Matrix<scalar>& answer, // value changed in return
|
|
||||||
const Matrix<scalar>& A,
|
|
||||||
const Matrix<scalar>& B,
|
|
||||||
const Matrix<scalar>& C
|
|
||||||
);
|
|
||||||
|
|
||||||
void multiply
|
|
||||||
(
|
|
||||||
Matrix<scalar>& answer, // value changed in return
|
|
||||||
const Matrix<scalar>& A,
|
|
||||||
const DiagonalMatrix<scalar>& B,
|
|
||||||
const Matrix<scalar>& C
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Return the inverse of matrix A using SVD
|
|
||||||
Matrix<scalar> SVDinv(const Matrix<scalar>& A, scalar minCondition = 0);
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
} // End namespace Foam
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#ifdef NoRepository
|
|
||||||
# include "scalarMatrixTemplates.C"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
@ -31,7 +31,7 @@ License
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::simpleMatrix<Type>::simpleMatrix(const label mSize)
|
Foam::simpleMatrix<Type>::simpleMatrix(const label mSize)
|
||||||
:
|
:
|
||||||
scalarMatrix(mSize),
|
scalarSquareMatrix(mSize),
|
||||||
source_(mSize, pTraits<Type>::zero)
|
source_(mSize, pTraits<Type>::zero)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -39,11 +39,11 @@ Foam::simpleMatrix<Type>::simpleMatrix(const label mSize)
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::simpleMatrix<Type>::simpleMatrix
|
Foam::simpleMatrix<Type>::simpleMatrix
|
||||||
(
|
(
|
||||||
const scalarMatrix& matrix,
|
const scalarSquareMatrix& matrix,
|
||||||
const Field<Type>& source
|
const Field<Type>& source
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
scalarMatrix(matrix),
|
scalarSquareMatrix(matrix),
|
||||||
source_(source)
|
source_(source)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ Foam::simpleMatrix<Type>::simpleMatrix
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::simpleMatrix<Type>::simpleMatrix(Istream& is)
|
Foam::simpleMatrix<Type>::simpleMatrix(Istream& is)
|
||||||
:
|
:
|
||||||
scalarMatrix(is),
|
scalarSquareMatrix(is),
|
||||||
source_(is)
|
source_(is)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -61,10 +61,10 @@ Foam::simpleMatrix<Type>::simpleMatrix(Istream& is)
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::Field<Type> Foam::simpleMatrix<Type>::solve() const
|
Foam::Field<Type> Foam::simpleMatrix<Type>::solve() const
|
||||||
{
|
{
|
||||||
scalarMatrix tmpMatrix = *this;
|
scalarSquareMatrix tmpMatrix = *this;
|
||||||
Field<Type> sourceSol = source_;
|
Field<Type> sourceSol = source_;
|
||||||
|
|
||||||
scalarMatrix::solve(tmpMatrix, sourceSol);
|
Foam::solve(tmpMatrix, sourceSol);
|
||||||
|
|
||||||
return sourceSol;
|
return sourceSol;
|
||||||
}
|
}
|
||||||
@ -73,10 +73,10 @@ Foam::Field<Type> Foam::simpleMatrix<Type>::solve() const
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::Field<Type> Foam::simpleMatrix<Type>::LUsolve() const
|
Foam::Field<Type> Foam::simpleMatrix<Type>::LUsolve() const
|
||||||
{
|
{
|
||||||
scalarMatrix luMatrix = *this;
|
scalarSquareMatrix luMatrix = *this;
|
||||||
Field<Type> sourceSol = source_;
|
Field<Type> sourceSol = source_;
|
||||||
|
|
||||||
scalarMatrix::LUsolve(luMatrix, sourceSol);
|
Foam::LUsolve(luMatrix, sourceSol);
|
||||||
|
|
||||||
return sourceSol;
|
return sourceSol;
|
||||||
}
|
}
|
||||||
@ -108,7 +108,7 @@ void Foam::simpleMatrix<Type>::operator=(const simpleMatrix<Type>& m)
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
scalarMatrix::operator=(m);
|
scalarSquareMatrix::operator=(m);
|
||||||
source_ = m.source_;
|
source_ = m.source_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +124,8 @@ Foam::simpleMatrix<Type> Foam::operator+
|
|||||||
{
|
{
|
||||||
return simpleMatrix<Type>
|
return simpleMatrix<Type>
|
||||||
(
|
(
|
||||||
static_cast<const scalarMatrix&>(m1)
|
static_cast<const scalarSquareMatrix&>(m1)
|
||||||
+ static_cast<const scalarMatrix&>(m2),
|
+ static_cast<const scalarSquareMatrix&>(m2),
|
||||||
m1.source_ + m2.source_
|
m1.source_ + m2.source_
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -140,8 +140,8 @@ Foam::simpleMatrix<Type> Foam::operator-
|
|||||||
{
|
{
|
||||||
return simpleMatrix<Type>
|
return simpleMatrix<Type>
|
||||||
(
|
(
|
||||||
static_cast<const scalarMatrix&>(m1)
|
static_cast<const scalarSquareMatrix&>(m1)
|
||||||
- static_cast<const scalarMatrix&>(m2),
|
- static_cast<const scalarSquareMatrix&>(m2),
|
||||||
m1.source_ - m2.source_
|
m1.source_ - m2.source_
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ Foam::simpleMatrix<Type> Foam::operator*(const scalar s, const simpleMatrix<Type
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const simpleMatrix<Type>& m)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const simpleMatrix<Type>& m)
|
||||||
{
|
{
|
||||||
os << static_cast<const scalarMatrix&>(m) << nl << m.source_;
|
os << static_cast<const scalarSquareMatrix&>(m) << nl << m.source_;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ SourceFiles
|
|||||||
#ifndef simpleMatrix_H
|
#ifndef simpleMatrix_H
|
||||||
#define simpleMatrix_H
|
#define simpleMatrix_H
|
||||||
|
|
||||||
#include "scalarMatrix.H"
|
#include "scalarMatrices.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -48,27 +48,6 @@ namespace Foam
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
class simpleMatrix;
|
class simpleMatrix;
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
simpleMatrix<Type> operator+
|
|
||||||
(
|
|
||||||
const simpleMatrix<Type>&,
|
|
||||||
const simpleMatrix<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
simpleMatrix<Type> operator-
|
|
||||||
(
|
|
||||||
const simpleMatrix<Type>&,
|
|
||||||
const simpleMatrix<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
simpleMatrix<Type> operator*
|
|
||||||
(
|
|
||||||
const scalar,
|
|
||||||
const simpleMatrix<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Ostream& operator<<
|
Ostream& operator<<
|
||||||
(
|
(
|
||||||
@ -84,7 +63,7 @@ Ostream& operator<<
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
class simpleMatrix
|
class simpleMatrix
|
||||||
:
|
:
|
||||||
public scalarMatrix
|
public scalarSquareMatrix
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
@ -99,7 +78,7 @@ public:
|
|||||||
simpleMatrix(const label);
|
simpleMatrix(const label);
|
||||||
|
|
||||||
//- Construct from components
|
//- Construct from components
|
||||||
simpleMatrix(const scalarMatrix&, const Field<Type>&);
|
simpleMatrix(const scalarSquareMatrix&, const Field<Type>&);
|
||||||
|
|
||||||
//- Construct from Istream
|
//- Construct from Istream
|
||||||
simpleMatrix(Istream&);
|
simpleMatrix(Istream&);
|
||||||
@ -137,27 +116,6 @@ public:
|
|||||||
void operator=(const simpleMatrix<Type>&);
|
void operator=(const simpleMatrix<Type>&);
|
||||||
|
|
||||||
|
|
||||||
// Friend Operators
|
|
||||||
|
|
||||||
friend simpleMatrix<Type> operator+ <Type>
|
|
||||||
(
|
|
||||||
const simpleMatrix<Type>&,
|
|
||||||
const simpleMatrix<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
friend simpleMatrix<Type> operator- <Type>
|
|
||||||
(
|
|
||||||
const simpleMatrix<Type>&,
|
|
||||||
const simpleMatrix<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
friend simpleMatrix<Type> operator* <Type>
|
|
||||||
(
|
|
||||||
const scalar,
|
|
||||||
const simpleMatrix<Type>&
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operator
|
// Ostream Operator
|
||||||
|
|
||||||
friend Ostream& operator<< <Type>
|
friend Ostream& operator<< <Type>
|
||||||
@ -168,6 +126,30 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Global operators
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
simpleMatrix<Type> operator+
|
||||||
|
(
|
||||||
|
const simpleMatrix<Type>&,
|
||||||
|
const simpleMatrix<Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
simpleMatrix<Type> operator-
|
||||||
|
(
|
||||||
|
const simpleMatrix<Type>&,
|
||||||
|
const simpleMatrix<Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
simpleMatrix<Type> operator*
|
||||||
|
(
|
||||||
|
const scalar,
|
||||||
|
const simpleMatrix<Type>&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|||||||
@ -49,11 +49,11 @@ Foam::quadraticFitData::quadraticFitData
|
|||||||
:
|
:
|
||||||
MeshObject<fvMesh, quadraticFitData>(mesh),
|
MeshObject<fvMesh, quadraticFitData>(mesh),
|
||||||
centralWeight_(cWeight),
|
centralWeight_(cWeight),
|
||||||
#ifdef SPHERICAL_GEOMETRY
|
# ifdef SPHERICAL_GEOMETRY
|
||||||
dim_(2),
|
dim_(2),
|
||||||
#else
|
# else
|
||||||
dim_(mesh.nGeometricD()),
|
dim_(mesh.nGeometricD()),
|
||||||
#endif
|
# endif
|
||||||
minSize_
|
minSize_
|
||||||
(
|
(
|
||||||
dim_ == 1 ? 3 :
|
dim_ == 1 ? 3 :
|
||||||
@ -204,7 +204,7 @@ Foam::label Foam::quadraticFitData::calcFit
|
|||||||
scalar scale = 0;
|
scalar scale = 0;
|
||||||
|
|
||||||
// calculate the matrix of the polynomial components
|
// calculate the matrix of the polynomial components
|
||||||
Matrix<scalar> B(C.size(), minSize_, scalar(0));
|
scalarRectangularMatrix B(C.size(), minSize_, scalar(0));
|
||||||
|
|
||||||
for(label ip = 0; ip < C.size(); ip++)
|
for(label ip = 0; ip < C.size(); ip++)
|
||||||
{
|
{
|
||||||
@ -212,11 +212,11 @@ Foam::label Foam::quadraticFitData::calcFit
|
|||||||
|
|
||||||
scalar px = (p - p0)&idir;
|
scalar px = (p - p0)&idir;
|
||||||
scalar py = (p - p0)&jdir;
|
scalar py = (p - p0)&jdir;
|
||||||
#ifndef SPHERICAL_GEOMETRY
|
# ifndef SPHERICAL_GEOMETRY
|
||||||
scalar pz = (p - p0)&kdir;
|
scalar pz = (p - p0)&kdir;
|
||||||
#else
|
# else
|
||||||
scalar pz = mag(p) - mag(p0);
|
scalar pz = mag(p) - mag(p0);
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
if (ip == 0)
|
if (ip == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -114,7 +114,7 @@ Foam::scalarField Foam::chemistryModel::omega
|
|||||||
forAll(reactions_, i)
|
forAll(reactions_, i)
|
||||||
{
|
{
|
||||||
const reaction& R = reactions_[i];
|
const reaction& R = reactions_[i];
|
||||||
|
|
||||||
scalar omegai = omega
|
scalar omegai = omega
|
||||||
(
|
(
|
||||||
R, c, T, p, pf, cf, lRef, pr, cr, rRef
|
R, c, T, p, pf, cf, lRef, pr, cr, rRef
|
||||||
@ -164,13 +164,13 @@ Foam::scalar Foam::chemistryModel::omega
|
|||||||
|
|
||||||
pf = 1.0;
|
pf = 1.0;
|
||||||
pr = 1.0;
|
pr = 1.0;
|
||||||
|
|
||||||
label Nl = R.lhs().size();
|
label Nl = R.lhs().size();
|
||||||
label Nr = R.rhs().size();
|
label Nr = R.rhs().size();
|
||||||
|
|
||||||
label slRef = 0;
|
label slRef = 0;
|
||||||
lRef = R.lhs()[slRef].index;
|
lRef = R.lhs()[slRef].index;
|
||||||
|
|
||||||
pf = kf;
|
pf = kf;
|
||||||
for(label s=1; s<Nl; s++)
|
for(label s=1; s<Nl; s++)
|
||||||
{
|
{
|
||||||
@ -212,7 +212,7 @@ Foam::scalar Foam::chemistryModel::omega
|
|||||||
|
|
||||||
label srRef = 0;
|
label srRef = 0;
|
||||||
rRef = R.rhs()[srRef].index;
|
rRef = R.rhs()[srRef].index;
|
||||||
|
|
||||||
// find the matrix element and element position for the rhs
|
// find the matrix element and element position for the rhs
|
||||||
pr = kr;
|
pr = kr;
|
||||||
for(label s=1; s<Nr; s++)
|
for(label s=1; s<Nr; s++)
|
||||||
@ -250,7 +250,7 @@ Foam::scalar Foam::chemistryModel::omega
|
|||||||
{
|
{
|
||||||
pr *= pow(cr, exp-1.0);
|
pr *= pow(cr, exp-1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return pf*cf - pr*cr;
|
return pf*cf - pr*cr;
|
||||||
@ -313,12 +313,12 @@ void Foam::chemistryModel::jacobian
|
|||||||
const scalar t,
|
const scalar t,
|
||||||
const scalarField& c,
|
const scalarField& c,
|
||||||
scalarField& dcdt,
|
scalarField& dcdt,
|
||||||
Matrix<scalar>& dfdc
|
scalarSquareMatrix& dfdc
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
scalar T = c[Ns_];
|
scalar T = c[Ns_];
|
||||||
scalar p = c[Ns_ + 1];
|
scalar p = c[Ns_ + 1];
|
||||||
|
|
||||||
scalarField c2(Ns(), 0.0);
|
scalarField c2(Ns(), 0.0);
|
||||||
for(label i=0; i<Ns(); i++)
|
for(label i=0; i<Ns(); i++)
|
||||||
{
|
{
|
||||||
@ -470,23 +470,23 @@ Foam::tmp<Foam::volScalarField> Foam::chemistryModel::tc() const
|
|||||||
scalar pi = thermo_.p()[celli];
|
scalar pi = thermo_.p()[celli];
|
||||||
scalarField c(Ns_);
|
scalarField c(Ns_);
|
||||||
scalar cSum = 0.0;
|
scalar cSum = 0.0;
|
||||||
|
|
||||||
for(label i=0; i<Ns_; i++)
|
for(label i=0; i<Ns_; i++)
|
||||||
{
|
{
|
||||||
scalar Yi = Y_[i][celli];
|
scalar Yi = Y_[i][celli];
|
||||||
c[i] = rhoi*Yi/specieThermo_[i].W();
|
c[i] = rhoi*Yi/specieThermo_[i].W();
|
||||||
cSum += c[i];
|
cSum += c[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(reactions_, i)
|
forAll(reactions_, i)
|
||||||
{
|
{
|
||||||
const reaction& R = reactions_[i];
|
const reaction& R = reactions_[i];
|
||||||
|
|
||||||
omega
|
omega
|
||||||
(
|
(
|
||||||
R, c, Ti, pi, pf, cf, lRef, pr, cr, rRef
|
R, c, Ti, pi, pf, cf, lRef, pr, cr, rRef
|
||||||
);
|
);
|
||||||
|
|
||||||
forAll(R.rhs(), s)
|
forAll(R.rhs(), s)
|
||||||
{
|
{
|
||||||
scalar sr = R.rhs()[s].stoichCoeff;
|
scalar sr = R.rhs()[s].stoichCoeff;
|
||||||
@ -544,22 +544,22 @@ void Foam::chemistryModel::calculate()
|
|||||||
{
|
{
|
||||||
RR_[i][celli] = 0.0;
|
RR_[i][celli] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar rhoi = rho_[celli];
|
scalar rhoi = rho_[celli];
|
||||||
scalar Ti = thermo_.T()[celli];
|
scalar Ti = thermo_.T()[celli];
|
||||||
scalar pi = thermo_.p()[celli];
|
scalar pi = thermo_.p()[celli];
|
||||||
|
|
||||||
scalarField c(Ns_);
|
scalarField c(Ns_);
|
||||||
scalarField dcdt(nEqns(), 0.0);
|
scalarField dcdt(nEqns(), 0.0);
|
||||||
|
|
||||||
for(label i=0; i<Ns_; i++)
|
for(label i=0; i<Ns_; i++)
|
||||||
{
|
{
|
||||||
scalar Yi = Y_[i][celli];
|
scalar Yi = Y_[i][celli];
|
||||||
c[i] = rhoi*Yi/specieThermo_[i].W();
|
c[i] = rhoi*Yi/specieThermo_[i].W();
|
||||||
}
|
}
|
||||||
|
|
||||||
dcdt = omega(c, Ti, pi);
|
dcdt = omega(c, Ti, pi);
|
||||||
|
|
||||||
for(label i=0; i<Ns_; i++)
|
for(label i=0; i<Ns_; i++)
|
||||||
{
|
{
|
||||||
RR_[i][celli] = dcdt[i]*specieThermo_[i].W();
|
RR_[i][celli] = dcdt[i]*specieThermo_[i].W();
|
||||||
@ -624,7 +624,7 @@ Foam::scalar Foam::chemistryModel::solve(const scalar t0, const scalar deltaT)
|
|||||||
for(label i=0; i<Ns_; i++)
|
for(label i=0; i<Ns_; i++)
|
||||||
{
|
{
|
||||||
mixture += (c[i]/cTot)*specieThermo_[i];
|
mixture += (c[i]/cTot)*specieThermo_[i];
|
||||||
}
|
}
|
||||||
Ti = mixture.TH(hi, Ti);
|
Ti = mixture.TH(hi, Ti);
|
||||||
|
|
||||||
timeLeft -= dt;
|
timeLeft -= dt;
|
||||||
@ -639,7 +639,7 @@ Foam::scalar Foam::chemistryModel::solve(const scalar t0, const scalar deltaT)
|
|||||||
for(label i=0; i<Ns_; i++)
|
for(label i=0; i<Ns_; i++)
|
||||||
{
|
{
|
||||||
WTot += c[i]*specieThermo_[i].W();
|
WTot += c[i]*specieThermo_[i].W();
|
||||||
}
|
}
|
||||||
WTot /= cTot;
|
WTot /= cTot;
|
||||||
|
|
||||||
for(label i=0; i<Ns_; i++)
|
for(label i=0; i<Ns_; i++)
|
||||||
|
|||||||
@ -39,7 +39,6 @@ SourceFiles
|
|||||||
|
|
||||||
#include "hCombustionThermo.H"
|
#include "hCombustionThermo.H"
|
||||||
#include "reactingMixture.H"
|
#include "reactingMixture.H"
|
||||||
#include "Matrix.H"
|
|
||||||
#include "ODE.H"
|
#include "ODE.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -251,7 +250,7 @@ public:
|
|||||||
const scalar t,
|
const scalar t,
|
||||||
const scalarField& c,
|
const scalarField& c,
|
||||||
scalarField& dcdt,
|
scalarField& dcdt,
|
||||||
Matrix<scalar>& dfdc
|
scalarSquareMatrix& dfdc
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Calculates the reaction rates
|
//- Calculates the reaction rates
|
||||||
|
|||||||
@ -204,11 +204,20 @@ LRR::LRR
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
autoCreateMut("mut", mesh_)
|
autoCreateMut("mut", mesh_)
|
||||||
|
),
|
||||||
|
alphat_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alphat",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
autoCreateAlphat("alphat", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
|
||||||
mut_.correctBoundaryConditions();
|
|
||||||
|
|
||||||
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -221,6 +230,12 @@ LRR::LRR
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
alphat_ == mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,8 +325,13 @@ void LRR::correct()
|
|||||||
if (!turbulence_)
|
if (!turbulence_)
|
||||||
{
|
{
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,9 +419,13 @@ void LRR::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
|
mut_ == rho_*Cmu_*sqr(k_)/epsilon_;
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
|
||||||
// Correct wall shear stresses
|
// Correct wall shear stresses
|
||||||
|
|
||||||
|
|||||||
@ -97,6 +97,7 @@ class LRR
|
|||||||
volScalarField k_;
|
volScalarField k_;
|
||||||
volScalarField epsilon_;
|
volScalarField epsilon_;
|
||||||
volScalarField mut_;
|
volScalarField mut_;
|
||||||
|
volScalarField alphat_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -152,7 +153,7 @@ public:
|
|||||||
{
|
{
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
(
|
(
|
||||||
new volScalarField("alphaEff", alphah_*mut_ + alpha())
|
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -226,11 +226,20 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
autoCreateMut("mut", mesh_)
|
autoCreateMut("mut", mesh_)
|
||||||
|
),
|
||||||
|
alphat_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alphat",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
autoCreateAlphat("alphat", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
|
||||||
mut_.correctBoundaryConditions();
|
|
||||||
|
|
||||||
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
@ -243,6 +252,12 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
alphat_ == mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,8 +350,13 @@ void LaunderGibsonRSTM::correct()
|
|||||||
if (!turbulence_)
|
if (!turbulence_)
|
||||||
{
|
{
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,9 +458,12 @@ void LaunderGibsonRSTM::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate turbulent viscosity
|
// Re-calculate turbulent viscosity
|
||||||
mut_ = Cmu_*rho_*sqr(k_)/epsilon_;
|
mut_ == Cmu_*rho_*sqr(k_)/epsilon_;
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
// Correct wall shear stresses
|
// Correct wall shear stresses
|
||||||
|
|
||||||
|
|||||||
@ -104,6 +104,7 @@ class LaunderGibsonRSTM
|
|||||||
volScalarField k_;
|
volScalarField k_;
|
||||||
volScalarField epsilon_;
|
volScalarField epsilon_;
|
||||||
volScalarField mut_;
|
volScalarField mut_;
|
||||||
|
volScalarField alphat_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -161,7 +162,7 @@ public:
|
|||||||
{
|
{
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
(
|
(
|
||||||
new volScalarField("alphaEff", alphah_*mut_ + alpha())
|
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,9 @@ kOmegaSST/kOmegaSST.C
|
|||||||
/* Wall functions */
|
/* Wall functions */
|
||||||
wallFunctions = derivedFvPatchFields/wallFunctions
|
wallFunctions = derivedFvPatchFields/wallFunctions
|
||||||
|
|
||||||
|
alphatWallFunctions = $(wallFunctions)/alphatWallFunctions
|
||||||
|
$(alphatWallFunctions)/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
|
||||||
|
|
||||||
mutWallFunctions = $(wallFunctions)/mutWallFunctions
|
mutWallFunctions = $(wallFunctions)/mutWallFunctions
|
||||||
$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C
|
$(mutWallFunctions)/mutWallFunction/mutWallFunctionFvPatchScalarField.C
|
||||||
$(mutWallFunctions)/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C
|
$(mutWallFunctions)/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C
|
||||||
|
|||||||
@ -47,7 +47,8 @@ void RASModel::printCoeffs()
|
|||||||
{
|
{
|
||||||
if (printCoeffs_)
|
if (printCoeffs_)
|
||||||
{
|
{
|
||||||
Info<< type() << "Coeffs" << coeffDict_ << endl;
|
Info<< type() << "Coeffs" << coeffDict_ << nl
|
||||||
|
<< "wallFunctionCoeffs" << wallFunctionDict_ << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +116,15 @@ RASModel::RASModel
|
|||||||
0.09
|
0.09
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
Prt_
|
||||||
|
(
|
||||||
|
dimensioned<scalar>::lookupOrAddToDict
|
||||||
|
(
|
||||||
|
"Prt",
|
||||||
|
wallFunctionDict_,
|
||||||
|
0.85
|
||||||
|
)
|
||||||
|
),
|
||||||
|
|
||||||
yPlusLam_(yPlusLam(kappa_.value(), E_.value())),
|
yPlusLam_(yPlusLam(kappa_.value(), E_.value())),
|
||||||
|
|
||||||
@ -148,11 +158,9 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
|
|||||||
tmp<scalarField> tYp(new scalarField(curPatch.size()));
|
tmp<scalarField> tYp(new scalarField(curPatch.size()));
|
||||||
scalarField& Yp = tYp();
|
scalarField& Yp = tYp();
|
||||||
|
|
||||||
if (typeid(curPatch) == typeid(wallFvPatch))
|
if (isType<wallFvPatch>(curPatch))
|
||||||
{
|
{
|
||||||
scalar Cmu(readScalar(coeffDict_.lookup("Cmu")));
|
Yp = pow(Cmu_.value(), 0.25)
|
||||||
|
|
||||||
Yp = pow(Cmu, 0.25)
|
|
||||||
*y_[patchNo]
|
*y_[patchNo]
|
||||||
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
|
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
|
||||||
/(
|
/(
|
||||||
@ -165,8 +173,8 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
|
|||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"tmp<scalarField> RASModel::yPlus(const label patchNo) const"
|
"tmp<scalarField> RASModel::yPlus(const label patchNo) const"
|
||||||
) << "Patch " << patchNo << " is not a wall. Returning blank field"
|
) << "Patch " << patchNo << " is not a wall. Returning null field"
|
||||||
<< endl;
|
<< nl << endl;
|
||||||
|
|
||||||
Yp.setSize(0);
|
Yp.setSize(0);
|
||||||
}
|
}
|
||||||
@ -191,8 +199,11 @@ bool RASModel::read()
|
|||||||
lookup("turbulence") >> turbulence_;
|
lookup("turbulence") >> turbulence_;
|
||||||
coeffDict_ = subDict(type() + "Coeffs");
|
coeffDict_ = subDict(type() + "Coeffs");
|
||||||
|
|
||||||
kappa_.readIfPresent(subDict("wallFunctionCoeffs"));
|
wallFunctionDict_ = subDict("wallFunctionCoeffs");
|
||||||
E_.readIfPresent(subDict("wallFunctionCoeffs"));
|
kappa_.readIfPresent(wallFunctionDict_);
|
||||||
|
E_.readIfPresent(wallFunctionDict_);
|
||||||
|
Cmu_.readIfPresent(wallFunctionDict_);
|
||||||
|
Prt_.readIfPresent(wallFunctionDict_);
|
||||||
|
|
||||||
yPlusLam_ = yPlusLam(kappa_.value(), E_.value());
|
yPlusLam_ = yPlusLam(kappa_.value(), E_.value());
|
||||||
|
|
||||||
|
|||||||
@ -95,6 +95,7 @@ protected:
|
|||||||
dimensionedScalar kappa_;
|
dimensionedScalar kappa_;
|
||||||
dimensionedScalar E_;
|
dimensionedScalar E_;
|
||||||
dimensionedScalar Cmu_;
|
dimensionedScalar Cmu_;
|
||||||
|
dimensionedScalar Prt_;
|
||||||
|
|
||||||
scalar yPlusLam_;
|
scalar yPlusLam_;
|
||||||
|
|
||||||
@ -244,6 +245,12 @@ public:
|
|||||||
return Cmu_;
|
return Cmu_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- Return turbulent Prandtl number for use in wall-functions
|
||||||
|
dimensionedScalar Prt() const
|
||||||
|
{
|
||||||
|
return Prt_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Return the near wall distances
|
//- Return the near wall distances
|
||||||
const nearWallDist& y() const
|
const nearWallDist& y() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -174,11 +174,26 @@ RNGkEpsilon::RNGkEpsilon
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
autoCreateMut("mut", mesh_)
|
autoCreateMut("mut", mesh_)
|
||||||
|
),
|
||||||
|
alphat_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alphat",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
autoCreateAlphat("alphat", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
alphat_ == mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,8 +278,13 @@ void RNGkEpsilon::correct()
|
|||||||
if (!turbulence_)
|
if (!turbulence_)
|
||||||
{
|
{
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,8 +350,12 @@ void RNGkEpsilon::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
|
mut_ == rho_*Cmu_*sqr(k_)/epsilon_;
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -87,6 +87,7 @@ class RNGkEpsilon
|
|||||||
volScalarField k_;
|
volScalarField k_;
|
||||||
volScalarField epsilon_;
|
volScalarField epsilon_;
|
||||||
volScalarField mut_;
|
volScalarField mut_;
|
||||||
|
volScalarField alphat_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -142,7 +143,7 @@ public:
|
|||||||
{
|
{
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
(
|
(
|
||||||
new volScalarField("alphaEff", alphah_*mut_ + alpha())
|
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ License
|
|||||||
#include "backwardsCompatibilityWallFunctions.H"
|
#include "backwardsCompatibilityWallFunctions.H"
|
||||||
|
|
||||||
#include "calculatedFvPatchField.H"
|
#include "calculatedFvPatchField.H"
|
||||||
|
#include "alphatWallFunctionFvPatchScalarField.H"
|
||||||
#include "mutWallFunctionFvPatchScalarField.H"
|
#include "mutWallFunctionFvPatchScalarField.H"
|
||||||
#include "epsilonWallFunctionFvPatchScalarField.H"
|
#include "epsilonWallFunctionFvPatchScalarField.H"
|
||||||
#include "kQRWallFunctionFvPatchField.H"
|
#include "kQRWallFunctionFvPatchField.H"
|
||||||
@ -41,6 +42,76 @@ namespace compressible
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
tmp<volScalarField> autoCreateAlphat
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const fvMesh& mesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
IOobject alphatHeader
|
||||||
|
(
|
||||||
|
fieldName,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
if (alphatHeader.headerOk())
|
||||||
|
{
|
||||||
|
return tmp<volScalarField>(new volScalarField(alphatHeader, mesh));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "--> Upgrading " << fieldName << " to employ run-time "
|
||||||
|
<< "selectable wall functions" << endl;
|
||||||
|
|
||||||
|
const fvBoundaryMesh& bm = mesh.boundary();
|
||||||
|
|
||||||
|
wordList alphatBoundaryTypes(bm.size());
|
||||||
|
|
||||||
|
forAll(bm, patchI)
|
||||||
|
{
|
||||||
|
if (isType<wallFvPatch>(bm[patchI]))
|
||||||
|
{
|
||||||
|
alphatBoundaryTypes[patchI] =
|
||||||
|
RASModels::alphatWallFunctionFvPatchScalarField::typeName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alphatBoundaryTypes[patchI] =
|
||||||
|
calculatedFvPatchField<scalar>::typeName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp<volScalarField> alphat
|
||||||
|
(
|
||||||
|
new volScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
fieldName,
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
dimensionedScalar("zero", dimDensity*dimArea/dimTime, 0.0),
|
||||||
|
alphatBoundaryTypes
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< " Writing updated " << fieldName << endl;
|
||||||
|
alphat().write();
|
||||||
|
|
||||||
|
return alphat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
tmp<volScalarField> autoCreateMut
|
tmp<volScalarField> autoCreateMut
|
||||||
(
|
(
|
||||||
const word& fieldName,
|
const word& fieldName,
|
||||||
|
|||||||
@ -53,6 +53,13 @@ namespace compressible
|
|||||||
const fvMesh& mesh
|
const fvMesh& mesh
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- alphat
|
||||||
|
tmp<volScalarField> autoCreateAlphat
|
||||||
|
(
|
||||||
|
const word& fieldName,
|
||||||
|
const fvMesh& mesh
|
||||||
|
);
|
||||||
|
|
||||||
//- epsilon
|
//- epsilon
|
||||||
tmp<volScalarField> autoCreateEpsilon
|
tmp<volScalarField> autoCreateEpsilon
|
||||||
(
|
(
|
||||||
|
|||||||
@ -0,0 +1,132 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "alphatWallFunctionFvPatchScalarField.H"
|
||||||
|
#include "RASModel.H"
|
||||||
|
#include "fvPatchFieldMapper.H"
|
||||||
|
#include "volFields.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace compressible
|
||||||
|
{
|
||||||
|
namespace RASModels
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
alphatWallFunctionFvPatchScalarField::
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchScalarField(p, iF)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
alphatWallFunctionFvPatchScalarField::
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const alphatWallFunctionFvPatchScalarField& ptf,
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF,
|
||||||
|
const fvPatchFieldMapper& mapper
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
alphatWallFunctionFvPatchScalarField::
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch& p,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchScalarField(p, iF, dict)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
alphatWallFunctionFvPatchScalarField::
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const alphatWallFunctionFvPatchScalarField& awfpsf
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchScalarField(awfpsf)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
alphatWallFunctionFvPatchScalarField::
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const alphatWallFunctionFvPatchScalarField& awfpsf,
|
||||||
|
const DimensionedField<scalar, volMesh>& iF
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fixedValueFvPatchScalarField(awfpsf, iF)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void alphatWallFunctionFvPatchScalarField::updateCoeffs()
|
||||||
|
{
|
||||||
|
const RASModel& ras = db().lookupObject<RASModel>("RASProperties");
|
||||||
|
const scalar Prt = ras.Prt().value();
|
||||||
|
|
||||||
|
const scalarField& mutw =
|
||||||
|
patch().lookupPatchField<volScalarField, scalar>("mut");
|
||||||
|
|
||||||
|
operator==(mutw/Prt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void alphatWallFunctionFvPatchScalarField::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
fvPatchField<scalar>::write(os);
|
||||||
|
writeEntry("value", os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
makePatchTypeField(fvPatchScalarField, alphatWallFunctionFvPatchScalarField);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace RASModels
|
||||||
|
} // End namespace compressible
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,155 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by the
|
||||||
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::compressible::RASModels::alphatWallFunctionFvPatchScalarField
|
||||||
|
|
||||||
|
Description
|
||||||
|
Boundary condition for turbulent thermal diffusivity when using wall
|
||||||
|
functions
|
||||||
|
- replicates OpenFOAM v1.5 (and earlier) behaviour
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
alphatWallFunctionFvPatchScalarField.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef alphatWallFunctionFvPatchScalarField_H
|
||||||
|
#define alphatWallFunctionFvPatchScalarField_H
|
||||||
|
|
||||||
|
#include "fixedValueFvPatchFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace compressible
|
||||||
|
{
|
||||||
|
namespace RASModels
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class alphatWallFunctionFvPatchScalarField Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class alphatWallFunctionFvPatchScalarField
|
||||||
|
:
|
||||||
|
public fixedValueFvPatchScalarField
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("alphatWallFunction");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from patch and internal field
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<scalar, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct from patch, internal field and dictionary
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<scalar, volMesh>&,
|
||||||
|
const dictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct by mapping given
|
||||||
|
// alphatWallFunctionFvPatchScalarField
|
||||||
|
// onto a new patch
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const alphatWallFunctionFvPatchScalarField&,
|
||||||
|
const fvPatch&,
|
||||||
|
const DimensionedField<scalar, volMesh>&,
|
||||||
|
const fvPatchFieldMapper&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct as copy
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const alphatWallFunctionFvPatchScalarField&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual tmp<fvPatchScalarField> clone() const
|
||||||
|
{
|
||||||
|
return tmp<fvPatchScalarField>
|
||||||
|
(
|
||||||
|
new alphatWallFunctionFvPatchScalarField(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Construct as copy setting internal field reference
|
||||||
|
alphatWallFunctionFvPatchScalarField
|
||||||
|
(
|
||||||
|
const alphatWallFunctionFvPatchScalarField&,
|
||||||
|
const DimensionedField<scalar, volMesh>&
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone setting internal field reference
|
||||||
|
virtual tmp<fvPatchScalarField> clone
|
||||||
|
(
|
||||||
|
const DimensionedField<scalar, volMesh>& iF
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return tmp<fvPatchScalarField>
|
||||||
|
(
|
||||||
|
new alphatWallFunctionFvPatchScalarField(*this, iF)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
|
||||||
|
// Evaluation functions
|
||||||
|
|
||||||
|
//- Update the coefficients associated with the patch field
|
||||||
|
virtual void updateCoeffs();
|
||||||
|
|
||||||
|
|
||||||
|
// I-O
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
void write(Ostream&) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace RASModels
|
||||||
|
} // End namespace compressible
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -155,11 +155,26 @@ kEpsilon::kEpsilon
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
autoCreateMut("mut", mesh_)
|
autoCreateMut("mut", mesh_)
|
||||||
|
),
|
||||||
|
alphat_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alphat",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
autoCreateAlphat("alphat", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
mut_ = Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
mut_ == Cmu_*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
alphat_ == mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +258,13 @@ void kEpsilon::correct()
|
|||||||
if (!turbulence_)
|
if (!turbulence_)
|
||||||
{
|
{
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
mut_ == rho_*Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,8 +323,12 @@ void kEpsilon::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rho_*Cmu_*sqr(k_)/epsilon_;
|
mut_ == rho_*Cmu_*sqr(k_)/epsilon_;
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,6 @@ class kEpsilon
|
|||||||
|
|
||||||
// Model coefficients
|
// Model coefficients
|
||||||
|
|
||||||
// dimensionedScalar Cmu;
|
|
||||||
dimensionedScalar Cmu_;
|
dimensionedScalar Cmu_;
|
||||||
dimensionedScalar C1_;
|
dimensionedScalar C1_;
|
||||||
dimensionedScalar C2_;
|
dimensionedScalar C2_;
|
||||||
@ -88,6 +87,7 @@ class kEpsilon
|
|||||||
volScalarField k_;
|
volScalarField k_;
|
||||||
volScalarField epsilon_;
|
volScalarField epsilon_;
|
||||||
volScalarField mut_;
|
volScalarField mut_;
|
||||||
|
volScalarField alphat_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -144,7 +144,7 @@ public:
|
|||||||
{
|
{
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
(
|
(
|
||||||
new volScalarField("alphaEff", alphah_*mut_ + alpha())
|
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -258,11 +258,26 @@ kOmegaSST::kOmegaSST
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
autoCreateMut("mut", mesh_)
|
autoCreateMut("mut", mesh_)
|
||||||
|
),
|
||||||
|
alphat_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alphat",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
autoCreateAlphat("alphat", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
mut_ = a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_)))));
|
mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_)))));
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
alphat_ == mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,11 +366,15 @@ void kOmegaSST::correct()
|
|||||||
if (!turbulence_)
|
if (!turbulence_)
|
||||||
{
|
{
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ =
|
mut_ ==
|
||||||
a1_*rho_*k_
|
a1_*rho_*k_
|
||||||
/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_)))));
|
/max(a1_*omega_, F2()*sqrt(magSqr(symm(fvc::grad(U_)))));
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,8 +449,12 @@ void kOmegaSST::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(S2));
|
mut_ == a1_*rho_*k_/max(a1_*omega_, F2()*sqrt(S2));
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -134,6 +134,7 @@ class kOmegaSST
|
|||||||
volScalarField k_;
|
volScalarField k_;
|
||||||
volScalarField omega_;
|
volScalarField omega_;
|
||||||
volScalarField mut_;
|
volScalarField mut_;
|
||||||
|
volScalarField alphat_;
|
||||||
|
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
@ -238,7 +239,7 @@ public:
|
|||||||
{
|
{
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
(
|
(
|
||||||
new volScalarField("alphaEff", alphah_*mut_ + alpha())
|
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -187,14 +187,29 @@ realizableKE::realizableKE
|
|||||||
IOobject::AUTO_WRITE
|
IOobject::AUTO_WRITE
|
||||||
),
|
),
|
||||||
autoCreateMut("mut", mesh_)
|
autoCreateMut("mut", mesh_)
|
||||||
|
),
|
||||||
|
alphat_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alphat",
|
||||||
|
runTime_.timeName(),
|
||||||
|
mesh_,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
autoCreateAlphat("alphat", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bound(k_, k0_);
|
bound(k_, k0_);
|
||||||
bound(epsilon_, epsilon0_);
|
bound(epsilon_, epsilon0_);
|
||||||
|
|
||||||
mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
alphat_ == mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,8 +291,13 @@ void realizableKE::correct()
|
|||||||
if (!turbulence_)
|
if (!turbulence_)
|
||||||
{
|
{
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
|
mut_ == rCmu(fvc::grad(U_))*rho_*sqr(k_)/epsilon_;
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,8 +362,12 @@ void realizableKE::correct()
|
|||||||
bound(k_, k0_);
|
bound(k_, k0_);
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
mut_ = rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
|
mut_ == rCmu(gradU, S2, magS)*rho_*sqr(k_)/epsilon_;
|
||||||
mut_.correctBoundaryConditions();
|
mut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
// Re-calculate thermal diffusivity
|
||||||
|
alphat_ = mut_/Prt_;
|
||||||
|
alphat_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -91,6 +91,7 @@ class realizableKE
|
|||||||
volScalarField k_;
|
volScalarField k_;
|
||||||
volScalarField epsilon_;
|
volScalarField epsilon_;
|
||||||
volScalarField mut_;
|
volScalarField mut_;
|
||||||
|
volScalarField alphat_;
|
||||||
|
|
||||||
tmp<volScalarField> rCmu
|
tmp<volScalarField> rCmu
|
||||||
(
|
(
|
||||||
@ -157,7 +158,7 @@ public:
|
|||||||
{
|
{
|
||||||
return tmp<volScalarField>
|
return tmp<volScalarField>
|
||||||
(
|
(
|
||||||
new volScalarField("alphaEff", alphah_*mut_ + alpha())
|
new volScalarField("alphaEff", alphah_*alphat_ + alpha())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -187,7 +187,7 @@ LRR::LRR
|
|||||||
autoCreateNut("nut", mesh_)
|
autoCreateNut("nut", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
||||||
@ -381,7 +381,7 @@ void LRR::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
nut_ = Cmu_*sqr(k_)/epsilon_;
|
nut_ == Cmu_*sqr(k_)/epsilon_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -216,7 +216,7 @@ LaunderGibsonRSTM::LaunderGibsonRSTM
|
|||||||
autoCreateNut("nut", mesh_)
|
autoCreateNut("nut", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
|
||||||
@ -422,7 +422,7 @@ void LaunderGibsonRSTM::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate turbulent viscosity
|
// Re-calculate turbulent viscosity
|
||||||
nut_ = Cmu_*sqr(k_)/epsilon_;
|
nut_ == Cmu_*sqr(k_)/epsilon_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -228,7 +228,7 @@ LienCubicKE::LienCubicKE
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_) + C5viscosity_;
|
nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_) + C5viscosity_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
@ -385,7 +385,7 @@ void LienCubicKE::correct()
|
|||||||
- 2.0*pow(Cmu_, 3.0)*pow(k_, 4.0)/pow(epsilon_, 3.0)
|
- 2.0*pow(Cmu_, 3.0)*pow(k_, 4.0)/pow(epsilon_, 3.0)
|
||||||
*(magSqr(gradU_ + gradU_.T()) - magSqr(gradU_ - gradU_.T()));
|
*(magSqr(gradU_ + gradU_.T()) - magSqr(gradU_ - gradU_.T()));
|
||||||
|
|
||||||
nut_ = Cmu_*sqr(k_)/epsilon_ + C5viscosity_;
|
nut_ == Cmu_*sqr(k_)/epsilon_ + C5viscosity_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
nonlinearStress_ = symm
|
nonlinearStress_ = symm
|
||||||
|
|||||||
@ -45,7 +45,8 @@ void RASModel::printCoeffs()
|
|||||||
{
|
{
|
||||||
if (printCoeffs_)
|
if (printCoeffs_)
|
||||||
{
|
{
|
||||||
Info<< type() << "Coeffs" << coeffDict_ << endl;;
|
Info<< type() << "Coeffs" << coeffDict_ << nl
|
||||||
|
<< "wallFunctionCoeffs" << wallFunctionDict_ << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,9 +149,10 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
|
|||||||
tmp<scalarField> tYp(new scalarField(curPatch.size()));
|
tmp<scalarField> tYp(new scalarField(curPatch.size()));
|
||||||
scalarField& Yp = tYp();
|
scalarField& Yp = tYp();
|
||||||
|
|
||||||
if (typeid(curPatch) == typeid(wallFvPatch))
|
if (isType<wallFvPatch>(curPatch))
|
||||||
{
|
{
|
||||||
Yp = pow(Cmu_.value(), 0.25)*y_[patchNo]
|
Yp = pow(Cmu_.value(), 0.25)
|
||||||
|
*y_[patchNo]
|
||||||
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
|
*sqrt(k()().boundaryField()[patchNo].patchInternalField())
|
||||||
/nu().boundaryField()[patchNo];
|
/nu().boundaryField()[patchNo];
|
||||||
}
|
}
|
||||||
@ -158,9 +160,8 @@ tmp<scalarField> RASModel::yPlus(const label patchNo) const
|
|||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
"tmp<scalarField> RASModel::yPlus(const label patchNo)"
|
"tmp<scalarField> RASModel::yPlus(const label patchNo) const"
|
||||||
) << "const : " << nl
|
) << "Patch " << patchNo << " is not a wall. Returning null field"
|
||||||
<< "Patch " << patchNo << " is not a wall. Returning zero field"
|
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|
||||||
Yp.setSize(0);
|
Yp.setSize(0);
|
||||||
@ -185,8 +186,8 @@ bool RASModel::read()
|
|||||||
{
|
{
|
||||||
lookup("turbulence") >> turbulence_;
|
lookup("turbulence") >> turbulence_;
|
||||||
coeffDict_ = subDict(type() + "Coeffs");
|
coeffDict_ = subDict(type() + "Coeffs");
|
||||||
wallFunctionDict_ = subDict("wallFunctionCoeffs");
|
|
||||||
|
|
||||||
|
wallFunctionDict_ = subDict("wallFunctionCoeffs");
|
||||||
kappa_.readIfPresent(wallFunctionDict_);
|
kappa_.readIfPresent(wallFunctionDict_);
|
||||||
E_.readIfPresent(wallFunctionDict_);
|
E_.readIfPresent(wallFunctionDict_);
|
||||||
Cmu_.readIfPresent(wallFunctionDict_);
|
Cmu_.readIfPresent(wallFunctionDict_);
|
||||||
|
|||||||
@ -156,7 +156,7 @@ RNGkEpsilon::RNGkEpsilon
|
|||||||
autoCreateNut("nut", mesh_)
|
autoCreateNut("nut", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
@ -297,7 +297,7 @@ void RNGkEpsilon::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
nut_ = Cmu_*sqr(k_)/epsilon_;
|
nut_ == Cmu_*sqr(k_)/epsilon_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -160,7 +160,7 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs()
|
|||||||
|
|
||||||
scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
|
scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI];
|
||||||
|
|
||||||
omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceCellI]);
|
omega[faceCellI] = sqrt(k[faceCellI])/(Cmu25*kappa*y[faceI]);
|
||||||
|
|
||||||
if (yPlus > yPlusLam)
|
if (yPlus > yPlusLam)
|
||||||
{
|
{
|
||||||
@ -168,7 +168,7 @@ void omegaWallFunctionFvPatchScalarField::updateCoeffs()
|
|||||||
(nutw[faceI] + nuw[faceI])
|
(nutw[faceI] + nuw[faceI])
|
||||||
*magGradUw[faceI]
|
*magGradUw[faceI]
|
||||||
*Cmu25*sqrt(k[faceCellI])
|
*Cmu25*sqrt(k[faceCellI])
|
||||||
/(kappa*y[faceCellI]);
|
/(kappa*y[faceI]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -130,7 +130,7 @@ kEpsilon::kEpsilon
|
|||||||
autoCreateNut("nut", mesh_)
|
autoCreateNut("nut", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nut_ = Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
nut_ == Cmu_*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
@ -267,7 +267,7 @@ void kEpsilon::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
nut_ = Cmu_*sqr(k_)/epsilon_;
|
nut_ == Cmu_*sqr(k_)/epsilon_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -141,7 +141,7 @@ kOmega::kOmega
|
|||||||
autoCreateNut("nut", mesh_)
|
autoCreateNut("nut", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nut_ = k_/(omega_ + omegaSmall_);
|
nut_ == k_/(omega_ + omegaSmall_);
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
@ -273,7 +273,7 @@ void kOmega::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
nut_ = k_/omega_;
|
nut_ == k_/omega_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -250,7 +250,7 @@ kOmegaSST::kOmegaSST
|
|||||||
autoCreateNut("nut", mesh_)
|
autoCreateNut("nut", mesh_)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
nut_ =
|
nut_ ==
|
||||||
a1_*k_
|
a1_*k_
|
||||||
/max
|
/max
|
||||||
(
|
(
|
||||||
@ -411,7 +411,7 @@ void kOmegaSST::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
nut_ = a1_*k_/max(a1_*omega_, F2()*sqrt(S2));
|
nut_ == a1_*k_/max(a1_*omega_, F2()*sqrt(S2));
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -182,7 +182,7 @@ realizableKE::realizableKE
|
|||||||
bound(k_, k0_);
|
bound(k_, k0_);
|
||||||
bound(epsilon_, epsilon0_);
|
bound(epsilon_, epsilon0_);
|
||||||
|
|
||||||
nut_ = rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_);
|
nut_ == rCmu(fvc::grad(U_))*sqr(k_)/(epsilon_ + epsilonSmall_);
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
|
|
||||||
printCoeffs();
|
printCoeffs();
|
||||||
@ -326,7 +326,7 @@ void realizableKE::correct()
|
|||||||
|
|
||||||
|
|
||||||
// Re-calculate viscosity
|
// Re-calculate viscosity
|
||||||
nut_ = rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
|
nut_ == rCmu(gradU, S2, magS)*sqr(k_)/epsilon_;
|
||||||
nut_.correctBoundaryConditions();
|
nut_.correctBoundaryConditions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user