FreeFOAM The Cross-Platform CFD Toolkit
UpwindFitData.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 "UpwindFitData.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 extendedUpwindCellToFaceStencil& stencil,
40  const bool linearCorrection,
41  const scalar linearLimitFactor,
42  const scalar centralWeight
43 )
44 :
45  FitData
46  <
50  >
51  (
52  mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
53  ),
54  owncoeffs_(mesh.nFaces()),
55  neicoeffs_(mesh.nFaces())
56 {
57  if (debug)
58  {
59  Info<< "Contructing UpwindFitData<Polynomial>" << endl;
60  }
61 
62  calcFit();
63 
64  if (debug)
65  {
66  Info<< "UpwindFitData<Polynomial>::UpwindFitData() :"
67  << "Finished constructing polynomialFit data"
68  << endl;
69  }
70 }
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
75 template<class Polynomial>
77 {
78  const fvMesh& mesh = this->mesh();
79 
80  const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
81  const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
82 
83  // Owner stencil weights
84  // ~~~~~~~~~~~~~~~~~~~~~
85 
86  // Get the cell/face centres in stencil order.
87  List<List<point> > stencilPoints(mesh.nFaces());
88  this->stencil().collectData
89  (
90  this->stencil().ownMap(),
91  this->stencil().ownStencil(),
92  mesh.C(),
93  stencilPoints
94  );
95 
96  // find the fit coefficients for every owner
97 
98  //Pout<< "-- Owner --" << endl;
99  for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
100  {
101  FitData
102  <
103  UpwindFitData<Polynomial>,
104  extendedUpwindCellToFaceStencil,
105  Polynomial
106  >::calcFit(owncoeffs_[facei], stencilPoints[facei], w[facei], facei);
107 
108  //Pout<< " facei:" << facei
109  // << " at:" << mesh.faceCentres()[facei] << endl;
110  //forAll(owncoeffs_[facei], i)
111  //{
112  // Pout<< " point:" << stencilPoints[facei][i]
113  // << "\tweight:" << owncoeffs_[facei][i]
114  // << endl;
115  //}
116  }
117 
118  forAll(bw, patchi)
119  {
120  const fvsPatchScalarField& pw = bw[patchi];
121 
122  if (pw.coupled())
123  {
124  label facei = pw.patch().patch().start();
125 
126  forAll(pw, i)
127  {
128  FitData
129  <
130  UpwindFitData<Polynomial>,
131  extendedUpwindCellToFaceStencil,
132  Polynomial
133  >::calcFit
134  (
135  owncoeffs_[facei], stencilPoints[facei], pw[i], facei
136  );
137  facei++;
138  }
139  }
140  }
141 
142 
143  // Neighbour stencil weights
144  // ~~~~~~~~~~~~~~~~~~~~~~~~~
145 
146  // Note:reuse stencilPoints since is major storage
147  this->stencil().collectData
148  (
149  this->stencil().neiMap(),
150  this->stencil().neiStencil(),
151  mesh.C(),
152  stencilPoints
153  );
154 
155  // find the fit coefficients for every neighbour
156 
157  //Pout<< "-- Neighbour --" << endl;
158  for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
159  {
160  FitData
161  <
162  UpwindFitData<Polynomial>,
163  extendedUpwindCellToFaceStencil,
164  Polynomial
165  >::calcFit(neicoeffs_[facei], stencilPoints[facei], w[facei], facei);
166 
167  //Pout<< " facei:" << facei
168  // << " at:" << mesh.faceCentres()[facei] << endl;
169  //forAll(neicoeffs_[facei], i)
170  //{
171  // Pout<< " point:" << stencilPoints[facei][i]
172  // << "\tweight:" << neicoeffs_[facei][i]
173  // << endl;
174  //}
175  }
176 
177  forAll(bw, patchi)
178  {
179  const fvsPatchScalarField& pw = bw[patchi];
180 
181  if (pw.coupled())
182  {
183  label facei = pw.patch().patch().start();
184 
185  forAll(pw, i)
186  {
187  FitData
188  <
189  UpwindFitData<Polynomial>,
190  extendedUpwindCellToFaceStencil,
191  Polynomial
192  >::calcFit
193  (
194  neicoeffs_[facei], stencilPoints[facei], pw[i], facei
195  );
196  facei++;
197  }
198  }
199  }
200 }
201 
202 
203 // ************************ vim: set sw=4 sts=4 et: ************************ //