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-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"
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  extrapolatedCalculatedFvPatchScalarField::typeName
76  )
77  );
78  scalarField& rf = treconField.ref();
79 
80  forAll(owner, facei)
81  {
82  label own = owner[facei];
83  label nei = neighbour[facei];
84 
85  rf[own] += (Sf[facei] & (Cf[facei] - C[own]))*ssf[facei]/magSf[facei];
86  rf[nei] -= (Sf[facei] & (Cf[facei] - C[nei]))*ssf[facei]/magSf[facei];
87  }
88 
89  const surfaceScalarField::Boundary& bsf = ssf.boundaryField();
90 
91  forAll(bsf, patchi)
92  {
93  const fvsPatchScalarField& psf = bsf[patchi];
94 
95  const labelUList& pOwner = mesh.boundary()[patchi].faceCells();
96  const vectorField& pCf = Cf.boundaryField()[patchi];
97  const vectorField& pSf = Sf.boundaryField()[patchi];
98  const scalarField& pMagSf = magSf.boundaryField()[patchi];
99 
100  forAll(pOwner, pFacei)
101  {
102  label own = pOwner[pFacei];
103  rf[own] +=
104  (pSf[pFacei] & (pCf[pFacei] - C[own]))
105  *psf[pFacei]/pMagSf[pFacei];
106  }
107  }
108 
109  rf /= mesh.V();
110 
111  treconField.ref().correctBoundaryConditions();
112 
113  return treconField;
114 }
115 
116 
118 {
120  (
121  fvc::reconstructMag(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 // ************************************************************************* //
Foam::surfaceFields.
Graphite solid properties.
Definition: C.H:57
#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
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
Reconstruct volField from a face flux field.
Generic GeometricField class.
const volVectorField & C() const
Return cell centres as volVectorField.
tmp< volScalarField > reconstructMag(const surfaceScalarField &)
void clear() const
If object pointer points to valid object:
Definition: tmpI.H:230
dynamicFvMesh & mesh
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:288
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
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
const dimensionSet & dimensions() const
Return dimensions.
label patchi
const Mesh & mesh() const
Return mesh.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:282
A class for managing temporary objects.
Definition: PtrList.H:54
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
const fileName & instance() const
Definition: IOobject.H:337
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:545
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
const word & name() const
Return name.
Definition: IOobject.H:260
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Namespace for OpenFOAM.