mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
115
src/randomProcesses/Kmesh/Kmesh.C
Normal file
115
src/randomProcesses/Kmesh/Kmesh.C
Normal file
@ -0,0 +1,115 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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 "Kmesh.H"
|
||||
#include "polyMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
|
||||
// from fvMesh
|
||||
Kmesh::Kmesh(const fvMesh& mesh)
|
||||
:
|
||||
vectorField(mesh.V().size()),
|
||||
NN(vector::dim)
|
||||
{
|
||||
const scalar pi = mathematicalConstant::pi;
|
||||
const scalar twoPi = 2.0*pi;
|
||||
|
||||
boundBox box = mesh.bounds();
|
||||
L = box.max() - box.min();
|
||||
|
||||
vector cornerCellCentre = ::Foam::max(mesh.C().internalField());
|
||||
vector cellL = 2*(box.max() - cornerCellCentre);
|
||||
|
||||
vector rdeltaByL;
|
||||
label nTot = 1;
|
||||
|
||||
label i;
|
||||
forAll(NN, i)
|
||||
{
|
||||
NN[i] = label(L[i]/cellL[i] + 0.5);
|
||||
nTot *= NN[i];
|
||||
|
||||
if (NN[i] > 1)
|
||||
{
|
||||
L[i] -= cellL[i];
|
||||
}
|
||||
|
||||
rdeltaByL[i] = NN[i]/(L[i]*L[i]);
|
||||
}
|
||||
|
||||
if (nTot != mesh.nCells())
|
||||
{
|
||||
FatalErrorIn("Kmesh::Kmesh(const fvMesh& mesh)")
|
||||
<< "calculated number of cells is incorrect"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
for (i=0; i<NN[0]; i++)
|
||||
{
|
||||
scalar k1 = (i - NN[0]/2)*twoPi/L[0];
|
||||
|
||||
for (label j=0; j<NN[1]; j++)
|
||||
{
|
||||
scalar k2 = (j - NN[1]/2)*twoPi/L[1];
|
||||
|
||||
for (label k=0; k<NN[2]; k++)
|
||||
{
|
||||
scalar k3 = (k - NN[2]/2)*twoPi/L[2];
|
||||
|
||||
(*this)[rep(i, j, k, NN)] = vector(k1, k2, k3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Kmax = mag((*this)[rep(NN[0]-1, NN[1]-1, NN[2]-1, NN)]);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
104
src/randomProcesses/Kmesh/Kmesh.H
Normal file
104
src/randomProcesses/Kmesh/Kmesh.H
Normal file
@ -0,0 +1,104 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 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::Kmesh
|
||||
|
||||
Description
|
||||
Calculate the wavenumber vector field corresponding to the
|
||||
space vector field of a finite volume mesh;
|
||||
|
||||
SourceFiles
|
||||
Kmesh.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Kmesh_H
|
||||
#define Kmesh_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Kmesh Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class Kmesh
|
||||
:
|
||||
public vectorField
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
//- Dimensions of box
|
||||
vector L;
|
||||
|
||||
//- Multi-dimensional addressing array
|
||||
labelList NN;
|
||||
|
||||
//- Maximum wavenumber
|
||||
scalar Kmax;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from fvMesh
|
||||
Kmesh(const fvMesh&);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const vector& sizeOfBox() const
|
||||
{
|
||||
return L;
|
||||
}
|
||||
|
||||
const labelList& nn() const
|
||||
{
|
||||
return NN;
|
||||
}
|
||||
|
||||
scalar max() const
|
||||
{
|
||||
return Kmax;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user