Loading...
Searching...
No Matches
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 (
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 auto& owner = mesh.owner();
60 const auto& 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
70 scalar at = triPointRef
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 {
87 at = triPointRef
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
132 scalar at = triPointRef
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 {
149 at = triPointRef
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 }
175 return tsfCorr;
176}
177
178
179namespace Foam
180{
182}
183
184// ************************************************************************* //
constexpr scalar pi(M_PI)
Graphite solid properties.
Definition C.H:49
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
Generic GeometricField class.
static FOAM_NO_DANGLING_REFERENCE const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
A face is a list of labels corresponding to mesh vertices.
Definition face.H:71
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
label start() const noexcept
The patch start within the polyMesh face list.
Definition fvPatch.H:226
virtual const labelUList & faceCells() const
Return faceCells.
Definition fvPatch.C:107
virtual bool coupled() const
True if the patch field is coupled.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Face-point interpolation scheme class derived from linear and returns linear weighting factors but al...
Definition pointLinear.H:56
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:32
const fvMesh & mesh() const
Return mesh reference.
A class for managing temporary objects.
Definition tmp.H:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
mesh interpolate(rAU)
dynamicFvMesh & mesh
const pointField & points
Namespace for OpenFOAM.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition linear.H:120
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
Definition point.H:37
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
triangle< point, const point & > triPointRef
A triangle using referred points.
Definition triangleFwd.H:46
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
labelList f(nPoints)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
#define makeSurfaceInterpolationScheme(SS)