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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "CentredFitData.H"
30 #include "surfaceFields.H"
31 #include "volFields.H"
32 #include "SVD.H"
33 #include "syncTools.H"
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
38 template<class Polynomial>
40 (
41  const fvMesh& mesh,
42  const extendedCentredCellToFaceStencil& stencil,
43  const scalar linearLimitFactor,
44  const scalar centralWeight
45 )
46 :
47  FitData
48  <
52  >
53  (
54  mesh, stencil, true, linearLimitFactor, centralWeight
55  ),
56  coeffs_(mesh.nFaces())
57 {
58  DebugInFunction << "Constructing CentredFitData<Polynomial>" << nl;
59 
60  calcFit();
61 
62  DebugInfo << "Finished constructing polynomialFit data" << endl;
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
68 template<class Polynomial>
70 {
71  const fvMesh& mesh = this->mesh();
72 
73  // Get the cell/face centres in stencil order.
74  // Centred face stencils no good for triangles or tets.
75  // Need bigger stencils
76  List<List<point>> stencilPoints(mesh.nFaces());
77  this->stencil().collectData(mesh.C(), stencilPoints);
78 
79  // find the fit coefficients for every face in the mesh
80 
81  const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
82 
83  for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
84  {
85  FitData
86  <
90  >::calcFit(coeffs_[facei], stencilPoints[facei], w[facei], facei);
91  }
92 
93  const surfaceScalarField::Boundary& bw = w.boundaryField();
94 
95  forAll(bw, patchi)
96  {
97  const fvsPatchScalarField& pw = bw[patchi];
98 
99  if (pw.coupled())
100  {
101  label facei = pw.patch().start();
102 
103  forAll(pw, i)
104  {
105  FitData
106  <
107  CentredFitData<Polynomial>,
108  extendedCentredCellToFaceStencil,
109  Polynomial
110  >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
111  facei++;
112  }
113  }
114  }
115 }
116 
117 
118 // ************************************************************************* //
volFields.H
Foam::FitData
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:57
SVD.H
Foam::extendedCentredCellToFaceStencil
Definition: extendedCentredCellToFaceStencil.H:51
Foam::fvsPatchScalarField
fvsPatchField< scalar > fvsPatchScalarField
Definition: fvsPatchFieldsFwd.H:45
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
surfaceFields.H
Foam::surfaceFields.
syncTools.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::CentredFitData
Data for the quadratic fit correction interpolation scheme.
Definition: CentredFitData.H:54
CentredFitData.H
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
extendedCentredCellToFaceStencil.H
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam::Polynomial
Polynomial templated on size (order):
Definition: Polynomial.H:68
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
Foam::CentredFitData::CentredFitData
CentredFitData(const fvMesh &mesh, const extendedCentredCellToFaceStencil &stencil, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Definition: CentredFitData.C:40
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62