FreeFOAM The Cross-Platform CFD Toolkit
CentredFitData.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "CentredFitData.H"
28 #include <finiteVolume/volFields.H>
29 #include <OpenFOAM/SVD.H>
30 #include <OpenFOAM/syncTools.H>
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Polynomial>
37 (
38  const fvMesh& mesh,
39  const extendedCentredCellToFaceStencil& stencil,
40  const scalar linearLimitFactor,
41  const scalar centralWeight
42 )
43 :
44  FitData
45  <
49  >
50  (
51  mesh, stencil, true, linearLimitFactor, centralWeight
52  ),
53  coeffs_(mesh.nFaces())
54 {
55  if (debug)
56  {
57  Info<< "Contructing CentredFitData<Polynomial>" << endl;
58  }
59 
60  calcFit();
61 
62  if (debug)
63  {
64  Info<< "CentredFitData<Polynomial>::CentredFitData() :"
65  << "Finished constructing polynomialFit data"
66  << endl;
67  }
68 }
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
73 template<class Polynomial>
75 {
76  const fvMesh& mesh = this->mesh();
77 
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);
83 
84  // find the fit coefficients for every face in the mesh
85 
86  const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
87 
88  for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
89  {
90  FitData
91  <
92  CentredFitData<Polynomial>,
93  extendedCentredCellToFaceStencil,
95  >::calcFit(coeffs_[facei], stencilPoints[facei], w[facei], facei);
96  }
97 
98  const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
99 
100  forAll(bw, patchi)
101  {
102  const fvsPatchScalarField& pw = bw[patchi];
103 
104  if (pw.coupled())
105  {
106  label facei = pw.patch().patch().start();
107 
108  forAll(pw, i)
109  {
110  FitData
111  <
112  CentredFitData<Polynomial>,
113  extendedCentredCellToFaceStencil,
114  Polynomial
115  >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
116  facei++;
117  }
118  }
119  }
120 }
121 
122 
123 // ************************ vim: set sw=4 sts=4 et: ************************ //