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

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