famSup.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 -------------------------------------------------------------------------------
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 "areaFields.H"
29 #include "edgeFields.H"
30 #include "faMatrix.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace fam
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 template<class Type>
45 tmp<faMatrix<Type>>
46 Su
47 (
50 )
51 {
52  const faMesh& mesh = vf.mesh();
53 
54  tmp<faMatrix<Type>> tfam
55  (
56  new faMatrix<Type>
57  (
58  vf,
59  dimArea*su.dimensions()
60  )
61  );
62  faMatrix<Type>& fam = tfam.ref();
63 
64  fam.source() -= mesh.S()*su.internalField();
65 
66  return tfam;
67 }
68 
69 template<class Type>
71 Su
72 (
75 )
76 {
77  tmp<faMatrix<Type>> tfam = fam::Su(tsu(), vf);
78  tsu.clear();
79  return tfam;
80 }
81 
82 
83 template<class Type>
85 Sp
86 (
87  const areaScalarField& sp,
89 )
90 {
91  const faMesh& mesh = vf.mesh();
92 
93  tmp<faMatrix<Type>> tfam
94  (
95  new faMatrix<Type>
96  (
97  vf,
98  dimArea*sp.dimensions()*vf.dimensions()
99  )
100  );
101  faMatrix<Type>& fam = tfam.ref();
102 
103  fam.diag() += mesh.S()*sp.internalField();
104 
105  return tfam;
106 }
107 
108 template<class Type>
110 Sp
111 (
112  const tmp<areaScalarField>& tsp,
114 )
115 {
116  tmp<faMatrix<Type>> tfam = fam::Sp(tsp(), vf);
117  tsp.clear();
118  return tfam;
119 }
120 
121 
122 template<class Type>
124 Sp
125 (
126  const dimensionedScalar& sp,
128 )
129 {
130  const faMesh& mesh = vf.mesh();
131 
132  tmp<faMatrix<Type>> tfam
133  (
134  new faMatrix<Type>
135  (
136  vf,
137  dimArea*sp.dimensions()*vf.dimensions()
138  )
139  );
140  faMatrix<Type>& fam = tfam.ref();
141 
142  fam.diag() += mesh.S()*sp.value();
143 
144  return tfam;
145 }
146 
147 
148 template<class Type>
150 SuSp
151 (
152  const areaScalarField& sp,
154 )
155 {
156  const faMesh& mesh = vf.mesh();
157 
158  tmp<faMatrix<Type>> tfam
159  (
160  new faMatrix<Type>
161  (
162  vf,
163  dimArea*sp.dimensions()*vf.dimensions()
164  )
165  );
166  faMatrix<Type>& fam = tfam.ref();
167 
168  fam.diag() +=
169  mesh.S()*max
170  (
171  sp.internalField(),
172  dimensionedScalar("0", sp.dimensions(), Zero)
173  );
174 
175  fam.source() -=
176  mesh.S()*min
177  (
178  sp.internalField(),
179  dimensionedScalar("0", sp.dimensions(), Zero)
180  )
181  *vf.internalField();
182 
183  return tfam;
184 }
185 
186 template<class Type>
188 SuSp
189 (
190  const tmp<areaScalarField>& tsp,
192 )
193 {
194  tmp<faMatrix<Type>> tfam = fam::SuSp(tsp(), vf);
195  tsp.clear();
196  return tfam;
197 }
198 
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 } // End namespace fam
203 
204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205 
206 } // End namespace Foam
207 
208 // ************************************************************************* //
Foam::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatricesFwd.H:43
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:287
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::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::GeometricField::internalField
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
Definition: GeometricFieldI.H:43
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::fam::SuSp
tmp< faMatrix< Type > > SuSp(const areaScalarField &sp, const GeometricField< Type, faPatchField, areaMesh > &vf)
Definition: famSup.C:151
Foam::fam::Sp
tmp< faMatrix< Type > > Sp(const areaScalarField &sp, const GeometricField< Type, faPatchField, areaMesh > &vf)
Definition: famSup.C:86
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
edgeFields.H
faMatrix.H
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
areaFields.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
fam
Calculate the matrix for the second temporal derivative.
Foam::dimensioned::dimensions
const dimensionSet & dimensions() const
Return const reference to dimensions.
Definition: dimensionedType.C:420
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::fam::Su
tmp< faMatrix< Type > > Su(const GeometricField< Type, faPatchField, areaMesh > &su, const GeometricField< Type, faPatchField, areaMesh > &vf)
Definition: famSup.C:47