fvcCellReduce.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 "fvcCellReduce.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 
44 template<class Type, class CombineOp>
45 tmp<GeometricField<Type, fvPatchField, volMesh> > cellReduce
46 (
48  const CombineOp& cop
49 )
50 {
52 
53  const fvMesh& mesh = ssf.mesh();
54 
55  tmp<volFieldType> tresult
56  (
57  new volFieldType
58  (
59  IOobject
60  (
61  "cellReduce(" + ssf.name() + ')',
62  ssf.instance(),
63  mesh,
66  ),
67  mesh,
70  )
71  );
72 
73  volFieldType& result = tresult();
74 
75  const labelUList& own = mesh.owner();
76  const labelUList& nbr = mesh.neighbour();
77 
78  forAll(own, i)
79  {
80  label cellI = own[i];
81  cop(result[cellI], ssf[i]);
82  }
83  forAll(nbr, i)
84  {
85  label cellI = nbr[i];
86  cop(result[cellI], ssf[i]);
87  }
88 
89  result.correctBoundaryConditions();
90 
91  return tresult;
92 }
93 
94 
95 template<class Type, class CombineOp>
97 (
99  const CombineOp& cop
100 )
101 {
103  tvf(cellReduce(cop, tssf));
104 
105  tssf.clear();
106  return tvf;
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 } // End namespace fvc
113 
114 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115 
116 } // End namespace Foam
117 
118 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::surfaceFields.
Construct a volume field from a surface field using a combine operator.
tmp< GeometricField< Type, fvPatchField, volMesh > > cellReduce(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf, const CombineOp &cop)
Definition: fvcCellReduce.C:46
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 fileName & instance() const
Definition: IOobject.H:337
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:282
const Mesh & mesh() const
Return mesh.
dynamicFvMesh & mesh
Namespace for OpenFOAM.
This boundary condition applies a zero-gradient condition from the patch internal field onto the patc...
Generic dimensioned Type class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define forAll(list, i)
Definition: UList.H:421
const dimensionSet & dimensions() const
Return dimensions.
const word & name() const
Return name.
Definition: IOobject.H:260
Generic GeometricField class.
Traits class for primitives.
Definition: pTraits.H:50
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 labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:288
A class for managing temporary objects.
Definition: PtrList.H:118