1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "CentredFitData.H"
27 #include "surfaceFields.H"
28 #include "volFields.H"
30 #include "syncTools.H"
31 #include "extendedCentredCellToFaceStencil.H"
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 template<class Polynomial>
36 Foam::CentredFitData<Polynomial>::CentredFitData
39 const extendedCentredCellToFaceStencil& stencil,
40 const scalar linearLimitFactor,
41 const scalar centralWeight
46 CentredFitData<Polynomial>,
47 extendedCentredCellToFaceStencil,
51 mesh, stencil, true, linearLimitFactor, centralWeight
53 coeffs_(mesh.nFaces())
57 Info<< "Contructing CentredFitData<Polynomial>" << endl;
64 Info<< "CentredFitData<Polynomial>::CentredFitData() :"
65 << "Finished constructing polynomialFit data"
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 template<class Polynomial>
74 void Foam::CentredFitData<Polynomial>::calcFit()
76 const fvMesh& mesh = this->mesh();
78 // Get the cell/face centres in stencil order.
79 // Centred face stencils no good for triangles or tets.
80 // Need bigger stencils
81 List<List<point> > stencilPoints(mesh.nFaces());
82 this->stencil().collectData(mesh.C(), stencilPoints);
84 // find the fit coefficients for every face in the mesh
86 const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
88 for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
92 CentredFitData<Polynomial>,
93 extendedCentredCellToFaceStencil,
95 >::calcFit(coeffs_[facei], stencilPoints[facei], w[facei], facei);
98 const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
102 const fvsPatchScalarField& pw = bw[patchi];
106 label facei = pw.patch().start();
112 CentredFitData<Polynomial>,
113 extendedCentredCellToFaceStencil,
115 >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
123 // ************************************************************************* //