leastSquaresFaGrad.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-------------------------------------------------------------------------------
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 "leastSquaresFaGrad.H"
30#include "gaussFaGrad.H"
31#include "faMesh.H"
32#include "areaFaMesh.H"
33#include "edgeFaMesh.H"
34#include "GeometricField.H"
36
37// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38
39namespace Foam
40{
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace fa
45{
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49template<class Type>
50tmp
51<
52 GeometricField
53 <
54 typename outerProduct<vector, Type>::type, faPatchField, areaMesh
55 >
56>
58(
60) const
61{
62 typedef typename outerProduct<vector, Type>::type GradType;
63
64 const faMesh& mesh = vsf.mesh();
65
67 (
69 (
71 (
72 "grad(" + vsf.name() + ')',
73 vsf.instance(),
74 vsf.db(),
77 ),
78 mesh,
81 )
82 );
84
85 // Get reference to least square vectors
87
88 const edgeVectorField& ownLs = lsv.pVectors();
89 const edgeVectorField& neiLs = lsv.nVectors();
90
91 const labelUList& own = mesh.owner();
92 const labelUList& nei = mesh.neighbour();
93
94 forAll(own, edgei)
95 {
96 label ownEdgeI = own[edgei];
97 label neiEdgeI = nei[edgei];
98
99 Type deltaVsf = vsf[neiEdgeI] - vsf[ownEdgeI];
100
101 lsGrad[ownEdgeI] += ownLs[edgei]*deltaVsf;
102 lsGrad[neiEdgeI] -= neiLs[edgei]*deltaVsf;
103 }
104
105 // Boundary edges
106 forAll(vsf.boundaryField(), patchi)
107 {
108 const faePatchVectorField& patchOwnLs = ownLs.boundaryField()[patchi];
109
110 const labelUList& edgeFaces =
111 lsGrad.boundaryField()[patchi].patch().edgeFaces();
112
113 if (vsf.boundaryField()[patchi].coupled())
114 {
115 Field<Type> neiVsf
116 (
117 vsf.boundaryField()[patchi].patchNeighbourField()
118 );
119
120 forAll(neiVsf, patchEdgeI)
121 {
122 lsGrad[edgeFaces[patchEdgeI]] +=
123 patchOwnLs[patchEdgeI]
124 *(neiVsf[patchEdgeI] - vsf[edgeFaces[patchEdgeI]]);
125 }
126 }
127 else
128 {
129 const faPatchField<Type>& patchVsf = vsf.boundaryField()[patchi];
130
131 forAll(patchVsf, patchEdgeI)
132 {
133 lsGrad[edgeFaces[patchEdgeI]] +=
134 patchOwnLs[patchEdgeI]
135 *(patchVsf[patchEdgeI] - vsf[edgeFaces[patchEdgeI]]);
136 }
137 }
138 }
139
140 // Remove component of gradient normal to surface (area)
142
144
145 return tlsGrad;
146}
147
148
149// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150
151} // End namespace fa
152
153// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154
155} // End namespace Foam
156
157// ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
Generic templated field type.
Definition: Field.H:82
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:500
const fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:196
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Generic dimensioned Type class.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: faePatchField.H:83
Computes the gradient of an input field.
Definition: grad.H:157
Least-squares gradient scheme vectors for the Finite Area method.
const edgeVectorField & pVectors() const
Return reference to owner least square vectors.
const edgeVectorField & nVectors() const
Return reference to neighbour least square vectors.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition: products.H:114
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
type
Volume classification types.
Definition: volumeType.H:66
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
dynamicFvMesh & mesh
Namespace for OpenFOAM.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333