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) 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 "CentredFitData.H"
27 #include "surfaceFields.H"
28 #include "volFields.H"
29 #include "SVD.H"
30 #include "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  <
46  CentredFitData<Polynomial>,
47  extendedCentredCellToFaceStencil,
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().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 // ************************************************************************* //
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:54
virtual bool coupled() const
Return true if this patch field is coupled.
Polynomial templated on size (order):
Definition: Polynomial.H:63
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::surfaceFields.
label nFaces() const
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
const fvPatch & patch() const
Return patch.
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
messageStream Info
dynamicFvMesh & mesh
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const volVectorField & C() const
Return cell centres as volVectorField.
#define forAll(list, i)
Definition: UList.H:421
label patchi
label nInternalFaces() const
CentredFitData(const fvMesh &mesh, const extendedCentredCellToFaceStencil &stencil, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Data for the quadratic fit correction interpolation scheme.
label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:155
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65