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

UpwindFitData.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 "UpwindFitData.H"
00028 #include "surfaceFields.H"
00029 #include "volFields.H"
00030 #include "SVD.H"
00031 #include "syncTools.H"
00032 #include "extendedUpwindCellToFaceStencil.H"
00033 
00034 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
00035 
00036 template<class Polynomial>
00037 Foam::UpwindFitData<Polynomial>::UpwindFitData
00038 (
00039     const fvMesh& mesh,
00040     const extendedUpwindCellToFaceStencil& stencil,
00041     const bool linearCorrection,
00042     const scalar linearLimitFactor,
00043     const scalar centralWeight
00044 )
00045 :
00046     FitData
00047     <
00048         UpwindFitData<Polynomial>,
00049         extendedUpwindCellToFaceStencil,
00050         Polynomial
00051     >
00052     (
00053         mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
00054     ),
00055     owncoeffs_(mesh.nFaces()),
00056     neicoeffs_(mesh.nFaces())
00057 {
00058     if (debug)
00059     {
00060         Info<< "Contructing UpwindFitData<Polynomial>" << endl;
00061     }
00062 
00063     calcFit();
00064 
00065     if (debug)
00066     {
00067         Info<< "UpwindFitData<Polynomial>::UpwindFitData() :"
00068             << "Finished constructing polynomialFit data"
00069             << endl;
00070     }
00071 }
00072 
00073 
00074 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00075 
00076 template<class Polynomial>
00077 void Foam::UpwindFitData<Polynomial>::calcFit()
00078 {
00079     const fvMesh& mesh = this->mesh();
00080 
00081     const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
00082     const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
00083 
00084     // Owner stencil weights
00085     // ~~~~~~~~~~~~~~~~~~~~~
00086 
00087     // Get the cell/face centres in stencil order.
00088     List<List<point> > stencilPoints(mesh.nFaces());
00089     this->stencil().collectData
00090     (
00091         this->stencil().ownMap(),
00092         this->stencil().ownStencil(),
00093         mesh.C(),
00094         stencilPoints
00095     );
00096 
00097     // find the fit coefficients for every owner
00098 
00099     //Pout<< "-- Owner --" << endl;
00100     for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
00101     {
00102         FitData
00103         <
00104             UpwindFitData<Polynomial>,
00105             extendedUpwindCellToFaceStencil,
00106             Polynomial
00107         >::calcFit(owncoeffs_[facei], stencilPoints[facei], w[facei], facei);
00108 
00109         //Pout<< "    facei:" << facei
00110         //    << " at:" << mesh.faceCentres()[facei] << endl;
00111         //forAll(owncoeffs_[facei], i)
00112         //{
00113         //    Pout<< "    point:" << stencilPoints[facei][i]
00114         //        << "\tweight:" << owncoeffs_[facei][i]
00115         //        << endl;
00116         //}
00117     }
00118 
00119     forAll(bw, patchi)
00120     {
00121         const fvsPatchScalarField& pw = bw[patchi];
00122 
00123         if (pw.coupled())
00124         {
00125             label facei = pw.patch().patch().start();
00126 
00127             forAll(pw, i)
00128             {
00129                 FitData
00130                 <
00131                     UpwindFitData<Polynomial>,
00132                     extendedUpwindCellToFaceStencil,
00133                     Polynomial
00134                 >::calcFit
00135                 (
00136                     owncoeffs_[facei], stencilPoints[facei], pw[i], facei
00137                 );
00138                 facei++;
00139             }
00140         }
00141     }
00142 
00143 
00144     // Neighbour stencil weights
00145     // ~~~~~~~~~~~~~~~~~~~~~~~~~
00146 
00147     // Note:reuse stencilPoints since is major storage
00148     this->stencil().collectData
00149     (
00150         this->stencil().neiMap(),
00151         this->stencil().neiStencil(),
00152         mesh.C(),
00153         stencilPoints
00154     );
00155 
00156     // find the fit coefficients for every neighbour
00157 
00158     //Pout<< "-- Neighbour --" << endl;
00159     for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
00160     {
00161         FitData
00162         <
00163             UpwindFitData<Polynomial>,
00164             extendedUpwindCellToFaceStencil,
00165             Polynomial
00166         >::calcFit(neicoeffs_[facei], stencilPoints[facei], w[facei], facei);
00167 
00168         //Pout<< "    facei:" << facei
00169         //    << " at:" << mesh.faceCentres()[facei] << endl;
00170         //forAll(neicoeffs_[facei], i)
00171         //{
00172         //    Pout<< "    point:" << stencilPoints[facei][i]
00173         //        << "\tweight:" << neicoeffs_[facei][i]
00174         //        << endl;
00175         //}
00176     }
00177 
00178     forAll(bw, patchi)
00179     {
00180         const fvsPatchScalarField& pw = bw[patchi];
00181 
00182         if (pw.coupled())
00183         {
00184             label facei = pw.patch().patch().start();
00185 
00186             forAll(pw, i)
00187             {
00188                 FitData
00189                 <
00190                     UpwindFitData<Polynomial>,
00191                     extendedUpwindCellToFaceStencil,
00192                     Polynomial
00193                 >::calcFit
00194                 (
00195                     neicoeffs_[facei], stencilPoints[facei], pw[i], facei
00196                 );
00197                 facei++;
00198             }
00199         }
00200     }
00201 }
00202 
00203 
00204 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd