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 -------------------------------------------------------------------------------
10 License
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"
30 #include "volPointInterpolation.H"
31 #include "triangle.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 template<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 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 
179 namespace Foam
180 {
182 }
183 
184 // ************************************************************************* //
triangle.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::fvPatch::start
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:173
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::triangle
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:59
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::pointLinear
Face-point interpolation scheme class derived from linear and returns linear weighting factors but al...
Definition: pointLinear.H:57
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
volPointInterpolation.H
Foam::triangle::mag
scalar mag() const
Return scalar magnitude.
Definition: triangleI.H:128
Foam::pointLinear::correction
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
Foam::constant::mathematical::pi
constexpr scalar pi(M_PI)
Foam::linearInterpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > linearInterpolate(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: linear.H:112
f
labelList f(nPoints)
Foam::Vector< scalar >
Foam::List< face >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::UList< label >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::makeSurfaceInterpolationScheme
makeSurfaceInterpolationScheme(cellCoBlended)
Foam::fvPatch::faceCells
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:113
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::C
Graphite solid properties.
Definition: C.H:50
Foam::GeometricField< Type, fvPatchField, volMesh >
pointLinear.H
Foam::fvsPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvsPatchField.H:310
Foam::fac::interpolate
static tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &tvf, const edgeScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.