Merge branch 'master' of ssh://homedm/home/dm2/henry/OpenFOAM/OpenFOAM-dev/

This commit is contained in:
Henry
2012-10-08 09:32:59 +01:00
2 changed files with 53 additions and 42 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -30,34 +30,27 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam inline Foam::label Foam::Kmesh::index
(
const label i,
const label j,
const label k,
const labelList& nn
)
{ {
//! \cond fileScope return (k + j*nn[2] + i*nn[1]*nn[2]);
inline label rep }
(
const label i,
const label j,
const label k,
const labelList& nn
)
{
return (k + j*nn[2] + i*nn[1]*nn[2]);
}
//! \endcond
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// from fvMesh
Foam::Kmesh::Kmesh(const fvMesh& mesh) Foam::Kmesh::Kmesh(const fvMesh& mesh)
: :
vectorField(mesh.V().size()), vectorField(mesh.V().size()),
NN(vector::dim) nn_(vector::dim)
{ {
boundBox box = mesh.bounds(); boundBox box = mesh.bounds();
L = box.span(); l_ = box.span();
vector cornerCellCentre = ::Foam::max(mesh.C().internalField()); vector cornerCellCentre = ::Foam::max(mesh.C().internalField());
vector cellL = 2*(box.max() - cornerCellCentre); vector cellL = 2*(box.max() - cornerCellCentre);
@ -65,18 +58,17 @@ Foam::Kmesh::Kmesh(const fvMesh& mesh)
vector rdeltaByL; vector rdeltaByL;
label nTot = 1; label nTot = 1;
label i; forAll(nn_, i)
forAll(NN, i)
{ {
NN[i] = label(L[i]/cellL[i] + 0.5); nn_[i] = label(l_[i]/cellL[i] + 0.5);
nTot *= NN[i]; nTot *= nn_[i];
if (NN[i] > 1) if (nn_[i] > 1)
{ {
L[i] -= cellL[i]; l_[i] -= cellL[i];
} }
rdeltaByL[i] = NN[i]/(L[i]*L[i]); rdeltaByL[i] = nn_[i]/(l_[i]*l_[i]);
} }
if (nTot != mesh.nCells()) if (nTot != mesh.nCells())
@ -86,24 +78,31 @@ Foam::Kmesh::Kmesh(const fvMesh& mesh)
<< abort(FatalError); << abort(FatalError);
} }
for (i=0; i<NN[0]; i++) for (label i=0; i<nn_[0]; i++)
{ {
scalar k1 = (i - NN[0]/2)*constant::mathematical::twoPi/L[0]; scalar k1 = (i - nn_[0]/2)*constant::mathematical::twoPi/l_[0];
for (label j=0; j<NN[1]; j++) for (label j=0; j<nn_[1]; j++)
{ {
scalar k2 = (j - NN[1]/2)*constant::mathematical::twoPi/L[1]; scalar k2 = (j - nn_[1]/2)*constant::mathematical::twoPi/l_[1];
for (label k=0; k<NN[2]; k++) for (label k=0; k<nn_[2]; k++)
{ {
scalar k3 = (k - NN[2]/2)*constant::mathematical::twoPi/L[2]; scalar k3 = (k - nn_[2]/2)*constant::mathematical::twoPi/l_[2];
(*this)[rep(i, j, k, NN)] = vector(k1, k2, k3); (*this)[index(i, j, k, nn_)] = vector(k1, k2, k3);
} }
} }
} }
Kmax = mag((*this)[rep(NN[0]-1, NN[1]-1, NN[2]-1, NN)]); kmax_ = mag
(
Foam::max
(
cmptMag((*this)[index(nn_[0]-1, nn_[1]-1, nn_[2]-1, nn_)]),
cmptMag((*this)[index(0, 0, 0, nn_)])
)
);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,17 +51,29 @@ class Kmesh
: :
public vectorField public vectorField
{ {
// Private data // Private data
//- Dimensions of box //- Dimensions of box
vector L; vector l_;
//- Multi-dimensional addressing array //- Multi-dimensional addressing array
labelList NN; labelList nn_;
//- Maximum wavenumber //- Maximum wavenumber
scalar Kmax; scalar kmax_;
// Private functions
//- Return the linear index from the i-j-k indices
static inline label index
(
const label i,
const label j,
const label k,
const labelList& nn
);
public: public:
@ -77,17 +89,17 @@ public:
const vector& sizeOfBox() const const vector& sizeOfBox() const
{ {
return L; return l_;
} }
const labelList& nn() const const labelList& nn() const
{ {
return NN; return nn_;
} }
scalar max() const scalar max() const
{ {
return Kmax; return kmax_;
} }
}; };