1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "channelIndex.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 channelIndex::channelIndex(const fvMesh& m)
44 nx_(readLabel(indexingDict_.lookup("Nx"))),
45 ny_(indexingDict_.lookup("Ny")),
46 nz_(readLabel(indexingDict_.lookup("Nz"))),
49 readBool(indexingDict_.lookup("symmetric"))
54 // initialise the layers
57 for (label j=1; j<ny_.size(); j++)
60 cumNy_[j] = ny_[j]+cumNy_[j-1];
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
67 channelIndex::~channelIndex()
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 scalarField channelIndex::collapse
75 const volScalarField& vsf,
79 scalarField cs(nLayers(), 0.0);
83 // sweep over all cells in this layer
84 for (label i=0; i<nx(); i++)
86 for (label k=0; k<nz(); k++)
88 cs[j] += vsf[operator()(i,j,k)];
92 // and divide by the number of cells in the layer
93 cs[j] /= scalar(nx()*nz());
98 label nlb2 = nLayers()/2;
102 for (label j=0; j<nlb2; j++)
104 cs[j] = 0.5*(cs[j] - cs[nLayers() - j - 1]);
109 for (label j=0; j<nlb2; j++)
111 cs[j] = 0.5*(cs[j] + cs[nLayers() - j - 1]);
122 scalarField channelIndex::y
124 const volVectorField& cellCentres
129 scalarField Y(nLayers()/2);
131 for (label j=0; j<nLayers()/2; j++)
133 Y[j] = cellCentres[operator()(0, j, 0)].y();
140 scalarField Y(nLayers());
142 for (label j=0; j<nLayers(); j++)
144 Y[j] = cellCentres[operator()(0, j, 0)].y();
152 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
154 label channelIndex::operator()
163 // count up `full' layers in the mesh
167 while(Jy >= cumNy_[j])
169 index += nx_*ny_[j]*nz_;
174 index += Jx + nx_*tmpJy + nx_*ny_[j]*Jz;
180 // ************************************************************************* //