fvcSimpleReconstruct.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 | Copyright (C) 2013-2016 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  (
67  new GeometricField<GradType, fvPatchField, volMesh>
68  (
69  IOobject
70  (
71  "reconstruct("+ssf.name()+')',
72  ssf.instance(),
73  mesh,
76  ),
77  mesh,
78  dimensioned<GradType>
79  (
80  "0",
81  ssf.dimensions()/dimArea,
82  Zero
83  ),
85  )
86  );
87 
88  Field<GradType>& rf = treconField();
89 
90  forAll(owner, facei)
91  {
92  label own = owner[facei];
93  label nei = neighbour[facei];
94 
95  rf[own] += (Cf[facei] - C[own])*ssf[facei];
96  rf[nei] -= (Cf[facei] - C[nei])*ssf[facei];
97  }
98 
99  const typename GeometricField<Type, fvsPatchField, surfaceMesh>::
100  Boundary& bsf = ssf.boundaryField();
101 
102  forAll(bsf, patchi)
103  {
104  const fvsPatchField<Type>& psf = bsf[patchi];
105 
106  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
107  const vectorField& pCf = Cf.boundaryField()[patchi];
108 
109  forAll(pOwner, pFacei)
110  {
111  label own = pOwner[pFacei];
112  rf[own] += (pCf[pFacei] - C[own])*psf[pFacei];
113  }
114  }
115 
116  rf /= mesh.V();
117 
118  treconField().correctBoundaryConditions();
119 
120  return treconField;
121 }
122 
123 
124 template<class Type>
125 tmp
126 <
127  GeometricField
128  <
129  typename outerProduct<vector, Type>::type, fvPatchField, volMesh
130  >
131 >
133 (
134  const tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>& tssf
135 )
136 {
137  typedef typename outerProduct<vector, Type>::type GradType;
138  tmp<GeometricField<GradType, fvPatchField, volMesh>> tvf
139  (
140  fvc::reconstruct(tssf())
141  );
142  tssf.clear();
143  return tvf;
144 }
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace fvc
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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:94
Reconstruct volField from a face flux field.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
UList< label > labelUList
Definition: UList.H:64
dynamicFvMesh & mesh
static const zero Zero
Definition: zero.H:91
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.