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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "UpwindFitData.H"
29 #include "surfaceFields.H"
30 #include "volFields.H"
31 #include "SVD.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Polynomial>
38 (
39  const fvMesh& mesh,
40  const extendedUpwindCellToFaceStencil& stencil,
41  const bool linearCorrection,
42  const scalar linearLimitFactor,
43  const scalar centralWeight
44 )
45 :
46  FitData
47  <
51  >
52  (
53  mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
54  ),
55  owncoeffs_(mesh.nFaces()),
56  neicoeffs_(mesh.nFaces())
57 {
58  if (debug)
59  {
60  InfoInFunction << "Contructing UpwindFitData<Polynomial>" << endl;
61  }
62 
63  calcFit();
64 
65  if (debug)
66  {
67  Info<< " Finished constructing polynomialFit data" << endl;
68  }
69 }
70 
71 
72 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 
74 template<class Polynomial>
76 {
77  const fvMesh& mesh = this->mesh();
78 
79  const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
80  const surfaceScalarField::Boundary& bw = w.boundaryField();
81 
82  // Owner stencil weights
83  // ~~~~~~~~~~~~~~~~~~~~~
84 
85  // Get the cell/face centres in stencil order.
86  List<List<point>> stencilPoints(mesh.nFaces());
87  this->stencil().collectData
88  (
89  this->stencil().ownMap(),
90  this->stencil().ownStencil(),
91  mesh.C(),
92  stencilPoints
93  );
94 
95  // find the fit coefficients for every owner
96 
97  //Pout<< "-- Owner --" << endl;
98  for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
99  {
100  FitData
101  <
104  Polynomial
105  >::calcFit(owncoeffs_[facei], stencilPoints[facei], w[facei], facei);
106 
107  //Pout<< " facei:" << facei
108  // << " at:" << mesh.faceCentres()[facei] << endl;
109  //forAll(owncoeffs_[facei], i)
110  //{
111  // Pout<< " point:" << stencilPoints[facei][i]
112  // << "\tweight:" << owncoeffs_[facei][i]
113  // << endl;
114  //}
115  }
116 
117  forAll(bw, patchi)
118  {
119  const fvsPatchScalarField& pw = bw[patchi];
120 
121  if (pw.coupled())
122  {
123  label facei = pw.patch().start();
124 
125  forAll(pw, i)
126  {
127  FitData
128  <
129  UpwindFitData<Polynomial>,
130  extendedUpwindCellToFaceStencil,
131  Polynomial
132  >::calcFit
133  (
134  owncoeffs_[facei], stencilPoints[facei], pw[i], facei
135  );
136  facei++;
137  }
138  }
139  }
140 
141 
142  // Neighbour stencil weights
143  // ~~~~~~~~~~~~~~~~~~~~~~~~~
144 
145  // Note:reuse stencilPoints since is major storage
146  this->stencil().collectData
147  (
148  this->stencil().neiMap(),
149  this->stencil().neiStencil(),
150  mesh.C(),
151  stencilPoints
152  );
153 
154  // find the fit coefficients for every neighbour
155 
156  //Pout<< "-- Neighbour --" << endl;
157  for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
158  {
159  FitData
160  <
161  UpwindFitData<Polynomial>,
162  extendedUpwindCellToFaceStencil,
163  Polynomial
164  >::calcFit(neicoeffs_[facei], stencilPoints[facei], w[facei], facei);
165 
166  //Pout<< " facei:" << facei
167  // << " at:" << mesh.faceCentres()[facei] << endl;
168  //forAll(neicoeffs_[facei], i)
169  //{
170  // Pout<< " point:" << stencilPoints[facei][i]
171  // << "\tweight:" << neicoeffs_[facei][i]
172  // << endl;
173  //}
174  }
175 
176  forAll(bw, patchi)
177  {
178  const fvsPatchScalarField& pw = bw[patchi];
179 
180  if (pw.coupled())
181  {
182  label facei = pw.patch().start();
183 
184  forAll(pw, i)
185  {
186  FitData
187  <
188  UpwindFitData<Polynomial>,
189  extendedUpwindCellToFaceStencil,
190  Polynomial
191  >::calcFit
192  (
193  neicoeffs_[facei], stencilPoints[facei], pw[i], facei
194  );
195  facei++;
196  }
197  }
198  }
199 }
200 
201 
202 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
volFields.H
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:316
Foam::FitData
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:57
SVD.H
Foam::fvsPatchScalarField
fvsPatchField< scalar > fvsPatchScalarField
Definition: fvsPatchFieldsFwd.H:45
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
surfaceFields.H
Foam::surfaceFields.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::UpwindFitData::UpwindFitData
UpwindFitData(const fvMesh &mesh, const extendedUpwindCellToFaceStencil &stencil, const bool linearCorrection, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Definition: UpwindFitData.C:38
Foam::extendedUpwindCellToFaceStencil
Creates upwind stencil by shifting a centred stencil to upwind and downwind faces and optionally remo...
Definition: extendedUpwindCellToFaceStencil.H:61
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
extendedUpwindCellToFaceStencil.H
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
UpwindFitData.H
Foam::UpwindFitData
Data for the quadratic fit correction interpolation scheme to be used with upwind biased stencil.
Definition: UpwindFitData.H:57
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam::Polynomial
Polynomial templated on size (order):
Definition: Polynomial.H:67
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62