fvcReconstructMag.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"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace fvc
42 {
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
47 {
48  const fvMesh& mesh = ssf.mesh();
49 
50  const labelUList& owner = mesh.owner();
51  const labelUList& neighbour = mesh.neighbour();
52 
53  const volVectorField& C = mesh.C();
54  const surfaceVectorField& Cf = mesh.Cf();
55  const surfaceVectorField& Sf = mesh.Sf();
56  const surfaceScalarField& magSf = mesh.magSf();
57 
58  tmp<volScalarField> treconField
59  (
60  new volScalarField
61  (
62  IOobject
63  (
64  "reconstruct("+ssf.name()+')',
65  ssf.instance(),
66  mesh,
69  ),
70  mesh,
71  dimensionedScalar(ssf.dimensions()/dimArea, Zero),
72  extrapolatedCalculatedFvPatchScalarField::typeName
73  )
74  );
75  scalarField& rf = treconField.ref();
76 
77  forAll(owner, facei)
78  {
79  label own = owner[facei];
80  label nei = neighbour[facei];
81 
82  rf[own] += (Sf[facei] & (Cf[facei] - C[own]))*ssf[facei]/magSf[facei];
83  rf[nei] -= (Sf[facei] & (Cf[facei] - C[nei]))*ssf[facei]/magSf[facei];
84  }
85 
86  const surfaceScalarField::Boundary& bsf = ssf.boundaryField();
87 
88  forAll(bsf, patchi)
89  {
90  const fvsPatchScalarField& psf = bsf[patchi];
91 
92  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
93  const vectorField& pCf = Cf.boundaryField()[patchi];
94  const vectorField& pSf = Sf.boundaryField()[patchi];
95  const scalarField& pMagSf = magSf.boundaryField()[patchi];
96 
97  forAll(pOwner, pFacei)
98  {
99  label own = pOwner[pFacei];
100  rf[own] +=
101  (pSf[pFacei] & (pCf[pFacei] - C[own]))
102  *psf[pFacei]/pMagSf[pFacei];
103  }
104  }
105 
106  rf /= mesh.V();
107 
108  treconField.ref().correctBoundaryConditions();
109 
110  return treconField;
111 }
112 
113 
115 {
117  (
118  fvc::reconstructMag(tssf())
119  );
120  tssf.clear();
121  return tvf;
122 }
123 
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 } // End namespace fvc
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace Foam
132 
133 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
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::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
surfaceFields.H
Foam::surfaceFields.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:59
Foam::Field< scalar >
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::UList< label >
fvcReconstruct.H
Reconstruct volField from a face flux field.
Foam::fvc::reconstructMag
tmp< volScalarField > reconstructMag(const surfaceScalarField &)
Definition: fvcReconstructMag.C:46
Foam::C
Graphite solid properties.
Definition: C.H:50
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
extrapolatedCalculatedFvPatchFields.H