fvcSimpleReconstruct.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fvcReconstruct.H"
27 #include "fvMesh.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace fvc
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 template<class Type>
43 tmp
44 <
45  GeometricField
46  <
47  typename outerProduct<vector,Type>::type, fvPatchField, volMesh
48  >
49 >
51 (
52  const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
53 )
54 {
55  typedef typename outerProduct<vector, Type>::type GradType;
56 
57  const fvMesh& mesh = ssf.mesh();
58 
59  const labelUList& owner = mesh.owner();
60  const labelUList& neighbour = mesh.neighbour();
61 
62  const volVectorField& C = mesh.C();
63  const surfaceVectorField& Cf = mesh.Cf();
64 
65  tmp<GeometricField<GradType, fvPatchField, volMesh>> treconField
66  (
68  (
69  "reconstruct("+ssf.name()+')',
70  mesh,
71  dimensioned<GradType>
72  (
73  "0",
74  ssf.dimensions()/dimArea,
75  Zero
76  ),
78  )
79  );
80 
81  Field<GradType>& rf = treconField();
82 
83  forAll(owner, facei)
84  {
85  label own = owner[facei];
86  label nei = neighbour[facei];
87 
88  rf[own] += (Cf[facei] - C[own])*ssf[facei];
89  rf[nei] -= (Cf[facei] - C[nei])*ssf[facei];
90  }
91 
92  const typename GeometricField<Type, fvsPatchField, surfaceMesh>::
93  Boundary& bsf = ssf.boundaryField();
94 
95  forAll(bsf, patchi)
96  {
97  const fvsPatchField<Type>& psf = bsf[patchi];
98 
99  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
100  const vectorField& pCf = Cf.boundaryField()[patchi];
101 
102  forAll(pOwner, pFacei)
103  {
104  label own = pOwner[pFacei];
105  rf[own] += (pCf[pFacei] - C[own])*psf[pFacei];
106  }
107  }
108 
109  rf /= mesh.V();
110 
111  treconField().correctBoundaryConditions();
112 
113  return treconField;
114 }
115 
116 
117 template<class Type>
118 tmp
119 <
120  GeometricField
121  <
122  typename outerProduct<vector, Type>::type, fvPatchField, volMesh
123  >
124 >
126 (
127  const tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>& tssf
128 )
129 {
130  typedef typename outerProduct<vector, Type>::type GradType;
131  tmp<GeometricField<GradType, fvPatchField, volMesh>> tvf
132  (
133  fvc::reconstruct(tssf())
134  );
135  tssf.clear();
136  return tvf;
137 }
138 
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 } // End namespace fvc
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace Foam
147 
148 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static const char *const typeName
Definition: Field.H:105
Reconstruct volField from a face flux field.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
UList< label > labelUList
Definition: UList.H:65
dynamicFvMesh & mesh
static const zero Zero
Definition: zero.H:97
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
label patchi
Field< vector > vectorField
Specialisation of Field<T> for vector.
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Namespace for OpenFOAM.