OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

CentredFitData.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "CentredFitData.H"
00028 #include "surfaceFields.H"
00029 #include "volFields.H"
00030 #include "SVD.H"
00031 #include "syncTools.H"
00032 #include "extendedCentredCellToFaceStencil.H"
00033 
00034 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
00035 
00036 template<class Polynomial>
00037 Foam::CentredFitData<Polynomial>::CentredFitData
00038 (
00039     const fvMesh& mesh,
00040     const extendedCentredCellToFaceStencil& stencil,
00041     const scalar linearLimitFactor,
00042     const scalar centralWeight
00043 )
00044 :
00045     FitData
00046     <
00047         CentredFitData<Polynomial>,
00048         extendedCentredCellToFaceStencil,
00049         Polynomial
00050     >
00051     (
00052         mesh, stencil, true, linearLimitFactor, centralWeight
00053     ),
00054     coeffs_(mesh.nFaces())
00055 {
00056     if (debug)
00057     {
00058         Info<< "Contructing CentredFitData<Polynomial>" << endl;
00059     }
00060 
00061     calcFit();
00062 
00063     if (debug)
00064     {
00065         Info<< "CentredFitData<Polynomial>::CentredFitData() :"
00066             << "Finished constructing polynomialFit data"
00067             << endl;
00068     }
00069 }
00070 
00071 
00072 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00073 
00074 template<class Polynomial>
00075 void Foam::CentredFitData<Polynomial>::calcFit()
00076 {
00077     const fvMesh& mesh = this->mesh();
00078 
00079     // Get the cell/face centres in stencil order.
00080     // Centred face stencils no good for triangles or tets.
00081     // Need bigger stencils
00082     List<List<point> > stencilPoints(mesh.nFaces());
00083     this->stencil().collectData(mesh.C(), stencilPoints);
00084 
00085     // find the fit coefficients for every face in the mesh
00086 
00087     const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
00088 
00089     for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
00090     {
00091         FitData
00092         <
00093             CentredFitData<Polynomial>,
00094             extendedCentredCellToFaceStencil,
00095             Polynomial
00096         >::calcFit(coeffs_[facei], stencilPoints[facei], w[facei], facei);
00097     }
00098 
00099     const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
00100 
00101     forAll(bw, patchi)
00102     {
00103         const fvsPatchScalarField& pw = bw[patchi];
00104 
00105         if (pw.coupled())
00106         {
00107             label facei = pw.patch().patch().start();
00108 
00109             forAll(pw, i)
00110             {
00111                 FitData
00112                 <
00113                     CentredFitData<Polynomial>,
00114                     extendedCentredCellToFaceStencil,
00115                     Polynomial
00116                 >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
00117                 facei++;
00118             }
00119         }
00120     }
00121 }
00122 
00123 
00124 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd