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 "UpwindFitData.H"
27 #include "surfaceFields.H"
28 #include "volFields.H"
30 #include "extendedUpwindCellToFaceStencil.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 template<class Polynomial>
35 Foam::UpwindFitData<Polynomial>::UpwindFitData
38 const extendedUpwindCellToFaceStencil& stencil,
39 const bool linearCorrection,
40 const scalar linearLimitFactor,
41 const scalar centralWeight
46 UpwindFitData<Polynomial>,
47 extendedUpwindCellToFaceStencil,
51 mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
53 owncoeffs_(mesh.nFaces()),
54 neicoeffs_(mesh.nFaces())
58 Info<< "Contructing UpwindFitData<Polynomial>" << endl;
65 Info<< "UpwindFitData<Polynomial>::UpwindFitData() :"
66 << "Finished constructing polynomialFit data"
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 template<class Polynomial>
75 void Foam::UpwindFitData<Polynomial>::calcFit()
77 const fvMesh& mesh = this->mesh();
79 const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
80 const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
82 // Owner stencil weights
83 // ~~~~~~~~~~~~~~~~~~~~~
85 // Get the cell/face centres in stencil order.
86 List<List<point> > stencilPoints(mesh.nFaces());
87 this->stencil().collectData
89 this->stencil().ownMap(),
90 this->stencil().ownStencil(),
95 // find the fit coefficients for every owner
97 //Pout<< "-- Owner --" << endl;
98 for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
102 UpwindFitData<Polynomial>,
103 extendedUpwindCellToFaceStencil,
105 >::calcFit(owncoeffs_[facei], stencilPoints[facei], w[facei], facei);
107 //Pout<< " facei:" << facei
108 // << " at:" << mesh.faceCentres()[facei] << endl;
109 //forAll(owncoeffs_[facei], i)
111 // Pout<< " point:" << stencilPoints[facei][i]
112 // << "\tweight:" << owncoeffs_[facei][i]
119 const fvsPatchScalarField& pw = bw[patchi];
123 label facei = pw.patch().start();
129 UpwindFitData<Polynomial>,
130 extendedUpwindCellToFaceStencil,
134 owncoeffs_[facei], stencilPoints[facei], pw[i], facei
142 // Neighbour stencil weights
143 // ~~~~~~~~~~~~~~~~~~~~~~~~~
145 // Note:reuse stencilPoints since is major storage
146 this->stencil().collectData
148 this->stencil().neiMap(),
149 this->stencil().neiStencil(),
154 // find the fit coefficients for every neighbour
156 //Pout<< "-- Neighbour --" << endl;
157 for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
161 UpwindFitData<Polynomial>,
162 extendedUpwindCellToFaceStencil,
164 >::calcFit(neicoeffs_[facei], stencilPoints[facei], w[facei], facei);
166 //Pout<< " facei:" << facei
167 // << " at:" << mesh.faceCentres()[facei] << endl;
168 //forAll(neicoeffs_[facei], i)
170 // Pout<< " point:" << stencilPoints[facei][i]
171 // << "\tweight:" << neicoeffs_[facei][i]
178 const fvsPatchScalarField& pw = bw[patchi];
182 label facei = pw.patch().start();
188 UpwindFitData<Polynomial>,
189 extendedUpwindCellToFaceStencil,
193 neicoeffs_[facei], stencilPoints[facei], pw[i], facei
202 // ************************************************************************* //