volSurfaceMapping.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) 2016-2017 Wikki Ltd
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 "volSurfaceMapping.H"
29 
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
36 ) const
37 {
38  // Grab labels for all faces in faMesh
39  const labelList& faceLabels = mesh_.faceLabels();
40 
41  tmp<Field<Type>> tresult
42  (
43  new Field<Type>(faceLabels.size(), Zero)
44  );
45  Field<Type>& result = tresult.ref();
46 
47  // Get reference to volume mesh
48  const polyMesh& pMesh = mesh_();
49  const polyBoundaryMesh& bm = pMesh.boundaryMesh();
50 
51  label patchID, faceID;
52 
53  // Grab droplet cloud source by identifying patch and face
54  forAll(faceLabels, i)
55  {
56  // Escape if face is beyond active faces, eg belongs to a face zone
57  if (faceLabels[i] < pMesh.nFaces())
58  {
59  patchID = bm.whichPatch(faceLabels[i]);
60  faceID = bm[patchID].whichFace(faceLabels[i]);
61 
62  result[i] = df[patchID][faceID];
63  }
64  }
65 
66  return tresult;
67 }
68 
69 
70 template<class Type>
72 (
75 ) const
76 {
77  // Grab labels for all faces in faMesh
78  const labelList& faceLabels = mesh_.faceLabels();
79 
80  // Get reference to volume mesh
81  const polyMesh& pMesh = mesh_();
82  const polyBoundaryMesh& bm = pMesh.boundaryMesh();
83 
84  label patchID, faceID;
85 
86  const Field<Type>& afi = af.internalField();
87 
88  forAll(faceLabels, i)
89  {
90  // Escape if face is beyond active faces, eg belongs to a face zone
91  if (faceLabels[i] < pMesh.nFaces())
92  {
93  patchID = bm.whichPatch(faceLabels[i]);
94  faceID = bm[patchID].whichFace(faceLabels[i]);
95 
96  bf[patchID][faceID] = afi[i];
97  }
98  }
99 }
100 
101 
102 template<class Type>
104 (
107 ) const
108 {
109  mapToVolume(taf(), bf);
110 
111  taf.clear();
112 }
113 
114 
115 // ************************************************************************* //
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::primitiveMesh::nFaces
label nFaces() const
Number of mesh faces.
Definition: primitiveMeshI.H:90
Foam::volSurfaceMapping::mapToSurface
tmp< Field< Type > > mapToSurface(const typename GeometricField< Type, fvPatchField, volMesh >::Boundary &df) const
Map droplet cloud sources to surface.
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::GeometricField::internalField
const Internal & internalField() const
Return a const-reference to the dimensioned internal field.
Definition: GeometricFieldI.H:43
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
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:62
Foam::Field
Generic templated field type.
Definition: Field.H:63
patchID
label patchID
Definition: boundaryProcessorFaPatchPoints.H:5
Foam::polyBoundaryMesh::whichPatch
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Definition: polyBoundaryMesh.C:805
Foam::volSurfaceMapping::mapToVolume
void mapToVolume(const GeometricField< Type, faPatchField, areaMesh > &af, typename GeometricField< Type, fvPatchField, volMesh >::Boundary &bf) const
Map surface field to volume boundary field.
Definition: volSurfaceMapping.C:72
volSurfaceMapping.H
mapToVolume
vsm mapToVolume(Cs, Cvf.boundaryFieldRef())
Foam::List< label >
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53