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 | Copyright (C) 2013 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"
28 #include "volFields.H"
29 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace fvc
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
45 {
46  const fvMesh& mesh = ssf.mesh();
47 
48  const labelUList& owner = mesh.owner();
49  const labelUList& neighbour = mesh.neighbour();
50 
51  const volVectorField& C = mesh.C();
52  const surfaceVectorField& Cf = mesh.Cf();
53  const surfaceVectorField& Sf = mesh.Sf();
54  const surfaceScalarField& magSf = mesh.magSf();
55 
56  tmp<volScalarField> treconField
57  (
58  new volScalarField
59  (
60  IOobject
61  (
62  "reconstruct("+ssf.name()+')',
63  ssf.instance(),
64  mesh,
67  ),
68  mesh,
70  (
71  "0",
72  ssf.dimensions()/dimArea,
73  scalar(0)
74  ),
75  zeroGradientFvPatchScalarField::typeName
76  )
77  );
78 
79  scalarField& rf = treconField();
80 
81  forAll(owner, facei)
82  {
83  label own = owner[facei];
84  label nei = neighbour[facei];
85 
86  rf[own] += (Sf[facei] & (Cf[facei] - C[own]))*ssf[facei]/magSf[facei];
87  rf[nei] -= (Sf[facei] & (Cf[facei] - C[nei]))*ssf[facei]/magSf[facei];
88  }
89 
91 
92  forAll(bsf, patchi)
93  {
94  const fvsPatchScalarField& psf = bsf[patchi];
95 
96  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
97  const vectorField& pCf = Cf.boundaryField()[patchi];
98  const vectorField& pSf = Sf.boundaryField()[patchi];
99  const scalarField& pMagSf = magSf.boundaryField()[patchi];
100 
101  forAll(pOwner, pFacei)
102  {
103  label own = pOwner[pFacei];
104  rf[own] +=
105  (pSf[pFacei] & (pCf[pFacei] - C[own]))
106  *psf[pFacei]/pMagSf[pFacei];
107  }
108  }
109 
110  rf /= mesh.V();
111 
112  treconField().correctBoundaryConditions();
113 
114  return treconField;
115 }
116 
117 
119 {
121  (
122  fvc::reconstructMag(tssf())
123  );
124  tssf.clear();
125  return tvf;
126 }
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace fvc
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 } // End namespace Foam
136 
137 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
surfaceFields.H
Foam::surfaceFields.
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
patchi
label patchi
Definition: getPatchFieldScalar.H:1
fvcReconstruct.H
Reconstruct volField from a face flux field.
Foam::fvc::reconstructMag
tmp< volScalarField > reconstructMag(const surfaceScalarField &)
Definition: fvcReconstructMag.C:44
Foam::C
Graphite solid properties.
Definition: C.H:57
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::tmp::clear
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:172
zeroGradientFvPatchFields.H
Foam::GeometricField::GeometricBoundaryField
Definition: GeometricField.H:105