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  <
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  <
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  <
114  Polynomial
115  >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
116  facei++;
117  }
118  }
119  }
120 }
121 
122 
123 // ************************************************************************* //
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::extendedCentredCellToFaceStencil
Definition: extendedCentredCellToFaceStencil.H:49
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.
syncTools.H
Foam::CentredFitData
Data for the quadratic fit correction interpolation scheme.
Definition: CentredFitData.H:51
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
CentredFitData.H
Foam::Info
messageStream Info
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
extendedCentredCellToFaceStencil.H
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
Foam::CentredFitData::calcFit
void calcFit()
Calculate the fit for the all the mesh faces.
Definition: CentredFitData.C:74
Foam::CentredFitData::CentredFitData
CentredFitData(const fvMesh &mesh, const extendedCentredCellToFaceStencil &stencil, const scalar linearLimitFactor, const scalar centralWeight)
Construct from components.
Definition: CentredFitData.C:37