Loading...
Searching...
No Matches
faceCorrectedSnGrad.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) 2021 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 "faceCorrectedSnGrad.H"
31#include "triangle.H"
32
33// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
34
35template<class Type>
38(
40) const
41{
42 const fvMesh& mesh = this->mesh();
43
45 (
47 );
48
49 // construct GeometricField<Type, fvsPatchField, surfaceMesh>
51 (
53 (
55 (
56 "snGradCorr("+vf.name()+')',
57 vf.instance(),
58 mesh,
61 ),
62 mesh,
63 vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions()
64 )
65 );
66
67 Field<Type>& sfCorr = tsfCorr.ref().primitiveFieldRef();
68
69 const pointField& points = mesh.points();
70 const faceList& faces = mesh.faces();
71 const vectorField& Sf = mesh.Sf();
72 const vectorField& C = mesh.C();
73 const scalarField& magSf = mesh.magSf();
74 const auto& owner = mesh.owner();
75 const auto& neighbour = mesh.neighbour();
76
77 forAll(sfCorr, facei)
78 {
80 (
82 );
83
84 const face& fi = faces[facei];
85
86 const vector nf(Sf[facei]/magSf[facei]);
87
88 for (label pi = 0; pi < fi.size(); ++pi)
89 {
90 // Next point index
91 const label pj = fi.fcIndex(pi);
92
93 // Edge normal in plane of face
94 const vector edgen(nf^(points[fi[pj]] - points[fi[pi]]));
95
96 // Edge centre field value
97 const Type pvfe(0.5*(pvf[fi[pj]] + pvf[fi[pi]]));
98
99 // Integrate face gradient
100 fgrad += edgen*pvfe;
101 }
102
103 // Finalize face-gradient by dividing by face area
104 fgrad /= magSf[facei];
105
106 // Calculate correction vector
107 vector dCorr(C[neighbour[facei]] - C[owner[facei]]);
108 dCorr /= (nf & dCorr);
109
110 sfCorr[facei] = dCorr&fgrad;
111 }
112
113 tsfCorr.ref().boundaryFieldRef() = Zero;
115 return tsfCorr;
116}
117
118
119template<class Type>
122(
124) const
125{
126 const fvMesh& mesh = this->mesh();
127
128 // construct GeometricField<Type, fvsPatchField, surfaceMesh>
130 (
132 (
134 (
135 "snGradCorr("+vf.name()+')',
136 vf.instance(),
137 mesh,
140 ),
141 mesh,
142 vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions()
143 )
144 );
146
147 for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; ++cmpt)
148 {
149 ssf.replace
150 (
151 cmpt,
153 .fullGradCorrection(vf.component(cmpt))
154 );
155 }
156
157 return tssf;
158}
159
160
161// ************************************************************************* //
constexpr scalar pi(M_PI)
Graphite solid properties.
Definition C.H:49
const dimensionSet & dimensions() const noexcept
Return dimensions.
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.
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
const fileName & instance() const noexcept
Read access to instance path component.
Definition IOobjectI.H:289
static FOAM_NO_DANGLING_REFERENCE const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
label fcIndex(const label i) const noexcept
The forward circular index. The next index in the list which returns to the first at the end of the l...
Definition UListI.H:99
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
Surface gradient scheme with full explicit non-orthogonal correction.
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > correction(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the explicit correction to the faceCorrectedSnGrad for the given field using the gradients of ...
faceCorrectedSnGrad(const fvMesh &mesh)
Construct from mesh.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > fullGradCorrection(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the explicit correction to the faceCorrectedSnGrad for the given field using the gradient of t...
const fvMesh & mesh() const
Return const reference to mesh.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition products.H:118
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
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
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
uint8_t direction
Definition direction.H:49
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
vectorField pointField
pointField is a vectorField.
Vector< scalar > vector
Definition vector.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299