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) 2011 OpenFOAM Foundation
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"
27 #include "surfaceFields.H"
28 #include "volFields.H"
29 #include "SVD.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Polynomial>
36 (
37  const fvMesh& mesh,
38  const extendedUpwindCellToFaceStencil& stencil,
39  const bool linearCorrection,
40  const scalar linearLimitFactor,
41  const scalar centralWeight
42 )
43 :
44  FitData
45  <
49  >
50  (
51  mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
52  ),
53  owncoeffs_(mesh.nFaces()),
54  neicoeffs_(mesh.nFaces())
55 {
56  if (debug)
57  {
58  Info<< "Contructing UpwindFitData<Polynomial>" << endl;
59  }
60 
61  calcFit();
62 
63  if (debug)
64  {
65  Info<< "UpwindFitData<Polynomial>::UpwindFitData() :"
66  << "Finished constructing polynomialFit data"
67  << 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::GeometricBoundaryField& 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  <
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  <
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  <
190  Polynomial
191  >::calcFit
192  (
193  neicoeffs_[facei], stencilPoints[facei], pw[i], facei
194  );
195  facei++;
196  }
197  }
198  }
199 }
200 
201 
202 // ************************************************************************* //
volFields.H
Foam::FitData
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:54
w
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
SVD.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
surfaceFields.H
Foam::surfaceFields.
Foam::UpwindFitData::calcFit
void calcFit()
Calculate the fit for the all the mesh faces.
Definition: UpwindFitData.C:75
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:36
Foam::extendedUpwindCellToFaceStencil
Creates upwind stencil by shifting a centred stencil to upwind and downwind faces and optionally remo...
Definition: extendedUpwindCellToFaceStencil.H:59
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:59
extendedUpwindCellToFaceStencil.H
Foam::Info
messageStream Info
UpwindFitData.H
Foam::UpwindFitData
Data for the quadratic fit correction interpolation scheme to be used with upwind biased stencil.
Definition: UpwindFitData.H:54
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::Polynomial
Polynomial templated on size (order):
Definition: Polynomial.H:63
Foam::fvsPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvsPatchField.H:278
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:59
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::fvPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:155
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::fvsPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvsPatchField.H:308
Foam::GeometricField::GeometricBoundaryField
Definition: GeometricField.H:105