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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2016 OpenFOAM Foundation
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 "fvcReconstruct.H"
29 #include "fvMesh.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace fvc
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 template<class Type>
45 tmp
46 <
47  GeometricField
48  <
49  typename outerProduct<vector,Type>::type, fvPatchField, volMesh
50  >
51 >
53 (
54  const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf
55 )
56 {
57  typedef typename outerProduct<vector, Type>::type GradType;
58 
59  const fvMesh& mesh = ssf.mesh();
60 
61  const labelUList& owner = mesh.owner();
62  const labelUList& neighbour = mesh.neighbour();
63 
64  const volVectorField& C = mesh.C();
65  const surfaceVectorField& Cf = mesh.Cf();
66 
67  tmp<GeometricField<GradType, fvPatchField, volMesh>> treconField
68  (
69  new GeometricField<GradType, fvPatchField, volMesh>
70  (
71  IOobject
72  (
73  "reconstruct("+ssf.name()+')',
74  ssf.instance(),
75  mesh,
78  ),
79  mesh,
80  dimensioned<GradType>(ssf.dimensions()/dimArea, Zero),
81  extrapolatedCalculatedFvPatchField<GradType>::typeName
82  )
83  );
84 
85  Field<GradType>& rf = treconField();
86 
87  forAll(owner, facei)
88  {
89  label own = owner[facei];
90  label nei = neighbour[facei];
91 
92  rf[own] += (Cf[facei] - C[own])*ssf[facei];
93  rf[nei] -= (Cf[facei] - C[nei])*ssf[facei];
94  }
95 
96  const typename GeometricField<Type, fvsPatchField, surfaceMesh>::
97  Boundary& bsf = ssf.boundaryField();
98 
99  forAll(bsf, patchi)
100  {
101  const fvsPatchField<Type>& psf = bsf[patchi];
102 
103  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
104  const vectorField& pCf = Cf.boundaryField()[patchi];
105 
106  forAll(pOwner, pFacei)
107  {
108  label own = pOwner[pFacei];
109  rf[own] += (pCf[pFacei] - C[own])*psf[pFacei];
110  }
111  }
112 
113  rf /= mesh.V();
114 
115  treconField().correctBoundaryConditions();
116 
117  return treconField;
118 }
119 
120 
121 template<class Type>
122 tmp
123 <
124  GeometricField
125  <
126  typename outerProduct<vector, Type>::type, fvPatchField, volMesh
127  >
128 >
130 (
131  const tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>& tssf
132 )
133 {
134  typedef typename outerProduct<vector, Type>::type GradType;
135  tmp<GeometricField<GradType, fvPatchField, volMesh>> tvf
136  (
137  fvc::reconstruct(tssf())
138  );
139  tssf.clear();
140  return tvf;
141 }
142 
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 } // End namespace fvc
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::fvc::reconstruct
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> reconstruct(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcReconstruct.C:56
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
C
volScalarField & C
Definition: readThermalProperties.H:102
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
fvcReconstruct.H
Reconstruct volField from a face flux field.
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:85
Foam::surfaceVectorField
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
Definition: surfaceFieldsFwd.H:59
Foam::IOobject::NO_READ
Definition: IOobject.H:188
extrapolatedCalculatedFvPatchFields.H