pointLinear.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-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "pointLinear.H"
29#include "fvMesh.H"
31#include "triangle.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35template<class Type>
39(
41) const
42{
43 const fvMesh& mesh = this->mesh();
44
46 (
47 volPointInterpolation::New(mesh).interpolate(vf)
48 );
49
52
53 Field<Type>& sfCorr = tsfCorr.ref().primitiveFieldRef();
54
55 const pointField& points = mesh.points();
56 const pointField& C = mesh.C();
57 const faceList& faces = mesh.faces();
58 const scalarField& w = mesh.weights();
59 const labelList& owner = mesh.owner();
60 const labelList& neighbour = mesh.neighbour();
61
62 forAll(sfCorr, facei)
63 {
64 point pi =
65 w[owner[facei]]*C[owner[facei]]
66 + (1.0 - w[owner[facei]])*C[neighbour[facei]];
67
68 const face& f = faces[facei];
69
71 (
72 pi,
73 points[f[0]],
74 points[f[f.size()-1]]
75 ).mag();
76
77 scalar sumAt = at;
78 Type sumPsip = at*(1.0/3.0)*
79 (
80 sfCorr[facei]
81 + pvf[f[0]]
82 + pvf[f[f.size()-1]]
83 );
84
85 for (label pointi=1; pointi<f.size(); pointi++)
86 {
88 (
89 pi,
90 points[f[pointi]],
91 points[f[pointi-1]]
92 ).mag();
93
94 sumAt += at;
95 sumPsip += at*(1.0/3.0)*
96 (
97 sfCorr[facei]
98 + pvf[f[pointi]]
99 + pvf[f[pointi-1]]
100 );
101
102 }
103
104 sfCorr[facei] = sumPsip/sumAt - sfCorr[facei];
105 }
106
107
109 Boundary& bSfCorr = tsfCorr.ref().boundaryFieldRef();
110
111 forAll(bSfCorr, patchi)
112 {
113 fvsPatchField<Type>& pSfCorr = bSfCorr[patchi];
114
115 if (pSfCorr.coupled())
116 {
117 const fvPatch& fvp = mesh.boundary()[patchi];
118 const scalarField& pWghts = mesh.weights().boundaryField()[patchi];
119 const labelUList& pOwner = fvp.faceCells();
120 const vectorField& pNbrC = mesh.C().boundaryField()[patchi];
121
122 forAll(pOwner, facei)
123 {
124 label own = pOwner[facei];
125
126 point pi =
127 pWghts[facei]*C[own]
128 + (1.0 - pWghts[facei])*pNbrC[facei];
129
130 const face& f = faces[facei+fvp.start()];
131
133 (
134 pi,
135 points[f[0]],
136 points[f[f.size()-1]]
137 ).mag();
138
139 scalar sumAt = at;
140 Type sumPsip = at*(1.0/3.0)*
141 (
142 pSfCorr[facei]
143 + pvf[f[0]]
144 + pvf[f[f.size()-1]]
145 );
146
147 for (label pointi=1; pointi<f.size(); pointi++)
148 {
150 (
151 pi,
152 points[f[pointi]],
153 points[f[pointi-1]]
154 ).mag();
155
156 sumAt += at;
157 sumPsip += at*(1.0/3.0)*
158 (
159 pSfCorr[facei]
160 + pvf[f[pointi]]
161 + pvf[f[pointi-1]]
162 );
163
164 }
165
166 pSfCorr[facei] = sumPsip/sumAt - pSfCorr[facei];
167 }
168 }
169 else
170 {
171 pSfCorr = Zero;
172 }
173 }
174
175 return tsfCorr;
176}
177
178
179namespace Foam
180{
182}
183
184// ************************************************************************* //
Graphite solid properties.
Definition: C.H:53
Generic templated field type.
Definition: Field.H:82
Generic GeometricField class.
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:179
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:113
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:79
virtual bool coupled() const
Return true if this patch field is coupled.
Face-point interpolation scheme class derived from linear and returns linear weighting factors but al...
Definition: pointLinear.H:60
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the explicit correction to the face-interpolate.
Definition: pointLinear.C:39
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:80
scalar mag() const
Return scalar magnitude.
Definition: triangleI.H:128
mesh interpolate(rAU)
dynamicFvMesh & mesh
const pointField & points
Namespace for OpenFOAM.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: linear.H:112
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define makeSurfaceInterpolationScheme(SS)