Fix tutorials: typo in tutorials/viscoelastic/viscoelasticFluidFoam/S-MDCPP/constant...
[OpenFOAM-1.6-ext.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / CentredFitScheme / CentredFitData.C
blob73824535c453ef723d7ab49fdf20812708e59294
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "CentredFitData.H"
28 #include "surfaceFields.H"
29 #include "volFields.H"
30 #include "SVD.H"
31 #include "syncTools.H"
32 #include "extendedCentredCellToFaceStencil.H"
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 template<class Polynomial>
37 Foam::CentredFitData<Polynomial>::CentredFitData
39     const fvMesh& mesh,
40     const extendedCentredCellToFaceStencil& stencil,
41     const scalar linearLimitFactor,
42     const scalar centralWeight
45     FitData
46     <
47         CentredFitData<Polynomial>,
48         extendedCentredCellToFaceStencil,
49         Polynomial
50     >
51     (
52         mesh, stencil, true, linearLimitFactor, centralWeight
53     ),
54     coeffs_(mesh.nFaces())
56     if (debug)
57     {
58         Info<< "Contructing CentredFitData<Polynomial>" << endl;
59     }
61     calcFit();
63     if (debug)
64     {
65         Info<< "CentredFitData<Polynomial>::CentredFitData() :"
66             << "Finished constructing polynomialFit data"
67             << endl;
68     }
72 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
74 template<class Polynomial>
75 void Foam::CentredFitData<Polynomial>::calcFit()
77     const fvMesh& mesh = this->mesh();
79     // Get the cell/face centres in stencil order.
80     // Centred face stencils no good for triangles or tets.
81     // Need bigger stencils
82     List<List<point> > stencilPoints(mesh.nFaces());
83     this->stencil().collectData(mesh.C(), stencilPoints);
85     // find the fit coefficients for every face in the mesh
87     const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
89     for(label facei = 0; facei < mesh.nInternalFaces(); facei++)
90     {
91         FitData
92         <
93             CentredFitData<Polynomial>,
94             extendedCentredCellToFaceStencil,
95             Polynomial
96         >::calcFit(coeffs_[facei], stencilPoints[facei], w[facei], facei);
97     }
99     const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
101     forAll(bw, patchi)
102     {
103         const fvsPatchScalarField& pw = bw[patchi];
105         if (pw.coupled())
106         {
107             label facei = pw.patch().patch().start();
109             forAll(pw, i)
110             {
111                 FitData
112                 <
113                     CentredFitData<Polynomial>,
114                     extendedCentredCellToFaceStencil,
115                     Polynomial
116                 >::calcFit(coeffs_[facei], stencilPoints[facei], pw[i], facei);
117                 facei++;
118             }
119         }
120     }
124 // ************************************************************************* //