FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "CentredFitData.H"
00027 #include <finiteVolume/surfaceFields.H>
00028 #include <finiteVolume/volFields.H>
00029 #include <OpenFOAM/SVD.H>
00030 #include <OpenFOAM/syncTools.H>
00031 #include <finiteVolume/extendedCentredCellToFaceStencil.H>
00032 
00033 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
00034 
00035 template<class Polynomial>
00036 Foam::CentredFitData<Polynomial>::CentredFitData
00037 (
00038     const fvMesh& mesh,
00039     const extendedCentredCellToFaceStencil& stencil,
00040     const scalar linearLimitFactor,
00041     const scalar centralWeight
00042 )
00043 :
00044     FitData
00045     <
00046         CentredFitData<Polynomial>,
00047         extendedCentredCellToFaceStencil,
00048         Polynomial
00049     >
00050     (
00051         mesh, stencil, true, linearLimitFactor, centralWeight
00052     ),
00053     coeffs_(mesh.nFaces())
00054 {
00055     if (debug)
00056     {
00057         Info<< "Contructing CentredFitData<Polynomial>" << endl;
00058     }
00059 
00060     calcFit();
00061 
00062     if (debug)
00063     {
00064         Info<< "CentredFitData<Polynomial>::CentredFitData() :"
00065             << "Finished constructing polynomialFit data"
00066             << endl;
00067     }
00068 }
00069 
00070 
00071 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00072 
00073 template<class Polynomial>
00074 void Foam::CentredFitData<Polynomial>::calcFit()
00075 {
00076     const fvMesh& mesh = this->mesh();
00077 
00078     // Get the cell/face centres in stencil order.
00079     // Centred face stencils no good for triangles or tets.
00080     // Need bigger stencils
00081     List<List<point> > stencilPoints(mesh.nFaces());
00082     this->stencil().collectData(mesh.C(), stencilPoints);
00083 
00084     // find the fit coefficients for every face in the mesh
00085 
00086     const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
00087 
00088     for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
00089     {
00090         FitData
00091         <
00092             CentredFitData<Polynomial>,
00093             extendedCentredCellToFaceStencil,
00094             Polynomial
00095         >::calcFit(coeffs_[facei], stencilPoints[facei], w[facei], facei);
00096     }
00097 
00098     const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
00099 
00100     forAll(bw, patchi)
00101     {
00102         const fvsPatchScalarField& pw = bw[patchi];
00103 
00104         if (pw.coupled())
00105         {
00106             label facei = pw.patch().patch().start();
00107 
00108             forAll(pw, i)
00109             {
00110                 FitData
00111                 <
00112                     CentredFitData<Polynomial>,
00113                     extendedCentredCellToFaceStencil,
00114                     Polynomial
00115                 >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
00116                 facei++;
00117             }
00118         }
00119     }
00120 }
00121 
00122 
00123 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines