CentredFitData.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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  InfoInFunction << "Constructing CentredFitData<Polynomial>" << endl;
58  }
59 
60  calcFit();
61 
62  if (debug)
63  {
64  Info<< "Finished constructing polynomialFit data" << endl;
65  }
66 }
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
71 template<class Polynomial>
73 {
74  const fvMesh& mesh = this->mesh();
75 
76  // Get the cell/face centres in stencil order.
77  // Centred face stencils no good for triangles or tets.
78  // Need bigger stencils
79  List<List<point>> stencilPoints(mesh.nFaces());
80  this->stencil().collectData(mesh.C(), stencilPoints);
81 
82  // find the fit coefficients for every face in the mesh
83 
84  const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
85 
86  for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
87  {
88  FitData
89  <
90  CentredFitData<Polynomial>,
91  extendedCentredCellToFaceStencil,
93  >::calcFit(coeffs_[facei], stencilPoints[facei], w[facei], facei);
94  }
95 
97 
98  forAll(bw, patchi)
99  {
100  const fvsPatchScalarField& pw = bw[patchi];
101 
102  if (pw.coupled())
103  {
104  label facei = pw.patch().start();
105 
106  forAll(pw, i)
107  {
108  FitData
109  <
110  CentredFitData<Polynomial>,
111  extendedCentredCellToFaceStencil,
112  Polynomial
113  >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
114  facei++;
115  }
116  }
117  }
118 }
119 
120 
121 // ************************************************************************* //
Foam::surfaceFields.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:151
label nInternalFaces() const
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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
label nFaces() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
fvMesh & mesh
CentredFitData(const fvMesh &mesh, const extendedCentredCellToFaceStencil &stencil, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Data for the quadratic fit correction interpolation scheme.
virtual bool coupled() const
Return true if this patch field is coupled.
const fvPatch & patch() const
Return patch.
label patchi
Polynomial templated on size (order):
Definition: Polynomial.H:65
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
messageStream Info
const volVectorField & C() const
Return cell centres.
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:54
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
#define InfoInFunction
Report an information message using Foam::Info.