UpwindFitData.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-------------------------------------------------------------------------------
11License
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 "UpwindFitData.H"
30#include "surfaceFields.H"
31#include "volFields.H"
32#include "SVD.H"
34
35// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36
37template<class Polynomial>
39(
40 const fvMesh& mesh,
42 const bool linearCorrection,
43 const scalar linearLimitFactor,
44 const scalar centralWeight
45)
46:
48 <
52 >
53 (
54 mesh, stencil, linearCorrection, linearLimitFactor, centralWeight
55 ),
56 owncoeffs_(mesh.nFaces()),
57 neicoeffs_(mesh.nFaces())
58{
59 DebugInFunction << "Constructing UpwindFitData<Polynomial>" << nl;
60
61 calcFit();
62
63 DebugInfo << " Finished constructing polynomialFit data" << nl;
64}
65
66
67// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68
69template<class Polynomial>
71{
72 const fvMesh& mesh = this->mesh();
73
74 const surfaceScalarField& w = mesh.surfaceInterpolation::weights();
76
77 // Owner stencil weights
78 // ~~~~~~~~~~~~~~~~~~~~~
79
80 // Get the cell/face centres in stencil order.
81 List<List<point>> stencilPoints(mesh.nFaces());
82 this->stencil().collectData
83 (
84 this->stencil().ownMap(),
85 this->stencil().ownStencil(),
86 mesh.C(),
87 stencilPoints
88 );
89
90 // find the fit coefficients for every owner
91
92 //Pout<< "-- Owner --" << endl;
93 for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
94 {
96 <
100 >::calcFit(owncoeffs_[facei], stencilPoints[facei], w[facei], facei);
101
102 //Pout<< " facei:" << facei
103 // << " at:" << mesh.faceCentres()[facei] << endl;
104 //forAll(owncoeffs_[facei], i)
105 //{
106 // Pout<< " point:" << stencilPoints[facei][i]
107 // << "\tweight:" << owncoeffs_[facei][i]
108 // << endl;
109 //}
110 }
111
112 forAll(bw, patchi)
113 {
114 const fvsPatchScalarField& pw = bw[patchi];
115
116 if (pw.coupled())
117 {
118 label facei = pw.patch().start();
119
120 forAll(pw, i)
121 {
122 FitData
123 <
124 UpwindFitData<Polynomial>,
125 extendedUpwindCellToFaceStencil,
126 Polynomial
127 >::calcFit
128 (
129 owncoeffs_[facei], stencilPoints[facei], pw[i], facei
130 );
131 facei++;
132 }
133 }
134 }
135
136
137 // Neighbour stencil weights
138 // ~~~~~~~~~~~~~~~~~~~~~~~~~
139
140 // Note:reuse stencilPoints since is major storage
141 this->stencil().collectData
142 (
143 this->stencil().neiMap(),
144 this->stencil().neiStencil(),
145 mesh.C(),
146 stencilPoints
147 );
148
149 // find the fit coefficients for every neighbour
150
151 //Pout<< "-- Neighbour --" << endl;
152 for (label facei = 0; facei < mesh.nInternalFaces(); facei++)
153 {
154 FitData
155 <
156 UpwindFitData<Polynomial>,
157 extendedUpwindCellToFaceStencil,
158 Polynomial
159 >::calcFit(neicoeffs_[facei], stencilPoints[facei], w[facei], facei);
160
161 //Pout<< " facei:" << facei
162 // << " at:" << mesh.faceCentres()[facei] << endl;
163 //forAll(neicoeffs_[facei], i)
164 //{
165 // Pout<< " point:" << stencilPoints[facei][i]
166 // << "\tweight:" << neicoeffs_[facei][i]
167 // << endl;
168 //}
169 }
170
171 forAll(bw, patchi)
172 {
173 const fvsPatchScalarField& pw = bw[patchi];
174
175 if (pw.coupled())
176 {
177 label facei = pw.patch().start();
178
179 forAll(pw, i)
180 {
181 FitData
182 <
183 UpwindFitData<Polynomial>,
184 extendedUpwindCellToFaceStencil,
185 Polynomial
186 >::calcFit
187 (
188 neicoeffs_[facei], stencilPoints[facei], pw[i], facei
189 );
190 facei++;
191 }
192 }
193 }
194}
195
196
197// ************************************************************************* //
Data for the upwinded and centred polynomial fit interpolation schemes. The linearCorrection_ determi...
Definition: FitData.H:60
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: List.H:77
Polynomial templated on size (order):
Definition: Polynomial.H:78
Data for the quadratic fit correction interpolation scheme to be used with upwind biased stencil.
Definition: UpwindFitData.H:65
Creates upwind stencil by shifting a centred stencil to upwind and downwind faces and optionally remo...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const volVectorField & C() const
Return cell centres as volVectorField.
label nInternalFaces() const noexcept
Number of internal faces.
label nFaces() const noexcept
Number of mesh faces.
dynamicFvMesh & mesh
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
#define DebugInfo
Report an information message using Foam::Info.
#define DebugInFunction
Report an information message using Foam::Info.
fvsPatchField< scalar > fvsPatchScalarField
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
Foam::surfaceFields.