faNVDscheme.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) 2016-2017 Wikki Ltd
9 Copyright (C) 2022 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 "areaFields.H"
30#include "edgeFields.H"
31#include "facGrad.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35namespace Foam
36{
37
39{
40 return phi;
41}
42
43inline tmp<areaScalarField> limiter(const areaVectorField& phi)
44{
45 return magSqr(phi);
46}
47
48inline tmp<areaScalarField> limiter(const areaTensorField& phi)
49{
50 return magSqr(phi);
51}
52
53}
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57template<class Type, class NVDweight>
59(
61) const
62{
63 const faMesh& mesh = this->mesh();
64
65 tmp<edgeScalarField> tWeightingFactors
66 (
67 new edgeScalarField(mesh.edgeInterpolation::weights())
68 );
69 edgeScalarField& weightingFactors = tWeightingFactors.ref();
70
71 scalarField& weights = weightingFactors.primitiveFieldRef();
72
74 const areaScalarField& vf = tvf();
75
76 const areaVectorField gradc(fac::grad(vf));
77
78// edgeVectorField d
79// (
80// mesh.Le()
81// /(mesh.magLe()*mesh.edgeInterpolation::deltaCoeffs())
82// );
83
84// if (!mesh.orthogonal())
85// {
86// d -=
87// mesh.edgeInterpolation::correctionVectors()
88// /mesh.edgeInterpolation::deltaCoeffs();
89// }
90
91 const labelUList& owner = mesh.owner();
92 const labelUList& neighbour = mesh.neighbour();
93 const vectorField& n = mesh.faceAreaNormals().internalField();
94 const vectorField& c = mesh.areaCentres().internalField();
95
96 forAll(weights, edge)
97 {
98 vector d(c[neighbour[edge]] - c[owner[edge]]);
99
100 if (edgeFlux_[edge] > 0)
101 {
102 d.removeCollinear(n[owner[edge]]);
103 }
104 else
105 {
106 d.removeCollinear(n[neighbour[edge]]);
107 }
108 d.normalise();
109 d *= mesh.edgeInterpolation::lPN().internalField()[edge];
110
111 weights[edge] =
112 this->weight
113 (
114 weights[edge],
115 edgeFlux_[edge],
116 vf[owner[edge]],
117 vf[neighbour[edge]],
118 gradc[owner[edge]],
119 gradc[neighbour[edge]],
120 d
121 );
122 }
123
124
125 auto& bWeights = weightingFactors.boundaryFieldRef();
126
127 forAll(bWeights, patchI)
128 {
129 if (bWeights[patchI].coupled())
130 {
131 scalarField& pWeights = bWeights[patchI];
132
133 const scalarField& pEdgeFlux = edgeFlux_.boundaryField()[patchI];
134
135 scalarField pVfP(vf.boundaryField()[patchI].patchInternalField());
136
137 scalarField pVfN(vf.boundaryField()[patchI].patchNeighbourField());
138
139 vectorField pGradcP
140 (
141 gradc.boundaryField()[patchI].patchInternalField()
142 );
143
144 vectorField pGradcN
145 (
146 gradc.boundaryField()[patchI].patchNeighbourField()
147 );
148
149 vectorField CP
150 (
151 mesh.areaCentres().boundaryField()[patchI].patchInternalField()
152 );
153
154 vectorField CN
155 (
156 mesh.areaCentres().boundaryField()[patchI]
157 .patchNeighbourField()
158 );
159
160 vectorField nP
161 (
162 mesh.faceAreaNormals().boundaryField()[patchI]
163 .patchInternalField()
164 );
165
166 vectorField nN
167 (
168 mesh.faceAreaNormals().boundaryField()[patchI]
169 .patchNeighbourField()
170 );
171
172 scalarField pLPN
173 (
174 mesh.edgeInterpolation::lPN().boundaryField()[patchI]
175 );
176
177 forAll(pWeights, edgeI)
178 {
179 vector d(CN[edgeI] - CP[edgeI]);
180
181 if (pEdgeFlux[edgeI] > 0)
182 {
183 d.removeCollinear(nP[edgeI]);
184 }
185 else
186 {
187 d.removeCollinear(nN[edgeI]);
188 }
189 d.normalise();
190 d *= pLPN[edgeI];
191
192 pWeights[edgeI] =
193 this->weight
194 (
195 pWeights[edgeI],
196 pEdgeFlux[edgeI],
197 pVfP[edgeI],
198 pVfN[edgeI],
199 pGradcP[edgeI],
200 pGradcN[edgeI],
201 d
202 );
203 }
204 }
205 }
206
207 return tWeightingFactors;
208}
209
210
211// ************************************************************************* //
label n
surfaceScalarField & phi
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Vector< Cmpt > & normalise(const scalar tol=ROOTVSMALL)
Inplace normalise the vector by its magnitude.
Definition: VectorI.H:123
Vector< Cmpt > & removeCollinear(const Vector< Cmpt > &unitVec)
Definition: VectorI.H:142
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
virtual const scalarListList & weights() const
Return interpolation weights.
Definition: faAreaMapper.C:384
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
dynamicFvMesh & mesh
Calculate the gradient of the given field.
Namespace for OpenFOAM.
GeometricField< tensor, faPatchField, areaMesh > areaTensorField
Definition: areaFieldsFwd.H:83
GeometricField< vector, faPatchField, areaMesh > areaVectorField
Definition: areaFieldsFwd.H:79
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
tmp< areaScalarField > limiter(const areaScalarField &phi)
Definition: faNVDscheme.C:38
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333