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-2022 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<VolField<typename outerProduct<vector, Type>::type>>
45 (
46  const SurfaceField<Type>& ssf
47 )
48 {
49  typedef typename outerProduct<vector, Type>::type GradType;
50 
51  const fvMesh& mesh = ssf.mesh();
52 
53  const labelUList& owner = mesh.owner();
54  const labelUList& neighbour = mesh.neighbour();
55 
56  const volVectorField& C = mesh.C();
57  const surfaceVectorField& Cf = mesh.Cf();
58 
59  tmp<VolField<GradType>> treconField
60  (
62  (
63  "reconstruct("+ssf.name()+')',
64  mesh,
65  dimensioned<GradType>
66  (
67  "0",
68  ssf.dimensions()/dimArea,
69  Zero
70  ),
72  )
73  );
74 
75  Field<GradType>& rf = treconField();
76 
77  forAll(owner, facei)
78  {
79  label own = owner[facei];
80  label nei = neighbour[facei];
81 
82  rf[own] += (Cf[facei] - C[own])*ssf[facei];
83  rf[nei] -= (Cf[facei] - C[nei])*ssf[facei];
84  }
85 
86  const typename SurfaceField<Type>::
87  Boundary& bsf = ssf.boundaryField();
88 
89  forAll(bsf, patchi)
90  {
91  const fvsPatchField<Type>& psf = bsf[patchi];
92 
93  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
94  const vectorField& pCf = Cf.boundaryField()[patchi];
95 
96  forAll(pOwner, pFacei)
97  {
98  label own = pOwner[pFacei];
99  rf[own] += (pCf[pFacei] - C[own])*psf[pFacei];
100  }
101  }
102 
103  rf /= mesh.V();
104 
105  treconField().correctBoundaryConditions();
106 
107  return treconField;
108 }
109 
110 
111 template<class Type>
112 tmp<VolField<typename outerProduct<vector, Type>::type>>
114 (
115  const tmp<SurfaceField<Type>>& tssf
116 )
117 {
118  typedef typename outerProduct<vector, Type>::type GradType;
119  tmp<VolField<GradType>> tvf
120  (
121  fvc::reconstruct(tssf())
122  );
123  tssf.clear();
124  return tvf;
125 }
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace fvc
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace Foam
135 
136 // ************************************************************************* //
static const Foam::dimensionedScalar C("C", Foam::dimTemperature, 234.5)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
static const char *const typeName
Definition: Field.H:105
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:90
Reconstruct volField from a face flux field.
label patchi
tmp< VolField< typename outerProduct< vector, Type >::type > > reconstruct(const SurfaceField< Type > &ssf)
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
VolField< vector > volVectorField
Definition: volFieldsFwd.H:62
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
Field< vector > vectorField
Specialisation of Field<T> for vector.
const dimensionSet dimArea
SurfaceField< vector > surfaceVectorField
UList< label > labelUList
Definition: UList.H:65