Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / finiteVolume / interpolation / surfaceInterpolation / schemes / UpwindFitScheme / UpwindFitData.C
blob1044a4de711cc5f7b038c28e1494fae1b0f36c6f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
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
13     the Free Software Foundation, either version 3 of the License, or
14     (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "UpwindFitData.H"
27 #include "surfaceFields.H"
28 #include "volFields.H"
29 #include "SVD.H"
30 #include "extendedUpwindCellToFaceStencil.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 template<class Polynomial>
35 Foam::UpwindFitData<Polynomial>::UpwindFitData
37     const fvMesh& mesh,
38     const extendedUpwindCellToFaceStencil& stencil,
39     const bool linearCorrection,
40     const scalar linearLimitFactor,
41     const scalar centralWeight
44     FitData
45     <
46         UpwindFitData<Polynomial>,
47         extendedUpwindCellToFaceStencil,
48         Polynomial
49     >
50     (
51         mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
52     ),
53     owncoeffs_(mesh.nFaces()),
54     neicoeffs_(mesh.nFaces())
56     if (debug)
57     {
58         Info<< "Contructing UpwindFitData<Polynomial>" << endl;
59     }
61     calcFit();
63     if (debug)
64     {
65         Info<< "UpwindFitData<Polynomial>::UpwindFitData() :"
66             << "Finished constructing polynomialFit data"
67             << endl;
68     }
72 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
74 template<class Polynomial>
75 void Foam::UpwindFitData<Polynomial>::calcFit()
77     const fvMesh& mesh = this->mesh();
79     const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
80     const surfaceScalarField::GeometricBoundaryField& bw = w.boundaryField();
82     // Owner stencil weights
83     // ~~~~~~~~~~~~~~~~~~~~~
85     // Get the cell/face centres in stencil order.
86     List<List<point> > stencilPoints(mesh.nFaces());
87     this->stencil().collectData
88     (
89         this->stencil().ownMap(),
90         this->stencil().ownStencil(),
91         mesh.C(),
92         stencilPoints
93     );
95     // find the fit coefficients for every owner
97     //Pout<< "-- Owner --" << endl;
98     for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
99     {
100         FitData
101         <
102             UpwindFitData<Polynomial>,
103             extendedUpwindCellToFaceStencil,
104             Polynomial
105         >::calcFit(owncoeffs_[facei], stencilPoints[facei], w[facei], facei);
107         //Pout<< "    facei:" << facei
108         //    << " at:" << mesh.faceCentres()[facei] << endl;
109         //forAll(owncoeffs_[facei], i)
110         //{
111         //    Pout<< "    point:" << stencilPoints[facei][i]
112         //        << "\tweight:" << owncoeffs_[facei][i]
113         //        << endl;
114         //}
115     }
117     forAll(bw, patchi)
118     {
119         const fvsPatchScalarField& pw = bw[patchi];
121         if (pw.coupled())
122         {
123             label facei = pw.patch().start();
125             forAll(pw, i)
126             {
127                 FitData
128                 <
129                     UpwindFitData<Polynomial>,
130                     extendedUpwindCellToFaceStencil,
131                     Polynomial
132                 >::calcFit
133                 (
134                     owncoeffs_[facei], stencilPoints[facei], pw[i], facei
135                 );
136                 facei++;
137             }
138         }
139     }
142     // Neighbour stencil weights
143     // ~~~~~~~~~~~~~~~~~~~~~~~~~
145     // Note:reuse stencilPoints since is major storage
146     this->stencil().collectData
147     (
148         this->stencil().neiMap(),
149         this->stencil().neiStencil(),
150         mesh.C(),
151         stencilPoints
152     );
154     // find the fit coefficients for every neighbour
156     //Pout<< "-- Neighbour --" << endl;
157     for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
158     {
159         FitData
160         <
161             UpwindFitData<Polynomial>,
162             extendedUpwindCellToFaceStencil,
163             Polynomial
164         >::calcFit(neicoeffs_[facei], stencilPoints[facei], w[facei], facei);
166         //Pout<< "    facei:" << facei
167         //    << " at:" << mesh.faceCentres()[facei] << endl;
168         //forAll(neicoeffs_[facei], i)
169         //{
170         //    Pout<< "    point:" << stencilPoints[facei][i]
171         //        << "\tweight:" << neicoeffs_[facei][i]
172         //        << endl;
173         //}
174     }
176     forAll(bw, patchi)
177     {
178         const fvsPatchScalarField& pw = bw[patchi];
180         if (pw.coupled())
181         {
182             label facei = pw.patch().start();
184             forAll(pw, i)
185             {
186                 FitData
187                 <
188                     UpwindFitData<Polynomial>,
189                     extendedUpwindCellToFaceStencil,
190                     Polynomial
191                 >::calcFit
192                 (
193                     neicoeffs_[facei], stencilPoints[facei], pw[i], facei
194                 );
195                 facei++;
196             }
197         }
198     }
202 // ************************************************************************* //