fvFieldDecomposer.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 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 "fvFieldDecomposer.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 Foam::label Foam::fvFieldDecomposer::completePatchID
31 (
32  const label procPatchi
33 ) const
34 {
35  const fvPatch& procPatch = procMesh_.boundary()[procPatchi];
36 
37  if (procPatchi < completeMesh_.boundary().size())
38  {
39  return procPatchi;
40  }
41  else if (isA<processorCyclicFvPatch>(procPatch))
42  {
43  return refCast<const processorCyclicFvPatch>(procPatch).referPatchID();
44  }
45  else
46  {
47  return -1;
48  }
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const labelUList& addressing
57 )
58 :
59  labelList(mag(addressing) - 1),
60  directFvPatchFieldMapper(static_cast<const labelList&>(*this))
61 {}
62 
63 
65 (
66  const fvMesh& completeMesh,
67  const fvMesh& procMesh,
68  const labelList& faceAddressing,
69  const labelList& cellAddressing,
70  const surfaceLabelField::Boundary& faceAddressingBf
71 )
72 :
73  completeMesh_(completeMesh),
74  procMesh_(procMesh),
75  faceAddressing_(faceAddressing),
76  cellAddressing_(cellAddressing),
77  faceAddressingBf_(faceAddressingBf),
78  patchFieldDecomposers_(procMesh_.boundary().size())
79 {
80  forAll(procMesh_.boundary(), procPatchi)
81  {
82  const label completePatchi = completePatchID(procPatchi);
83 
84  // If there is a corresponding complete patch then create a patch mapper
85  if (completePatchi >= 0)
86  {
87  patchFieldDecomposers_.set
88  (
89  procPatchi,
90  new patchFieldDecomposer
91  (
92  faceAddressingBf[completePatchi]
93  )
94  );
95  }
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
101 
103 {}
104 
105 
106 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
patchFieldDecomposer(const labelUList &addressing)
Construct given addressing.
fvFieldDecomposer(const fvMesh &completeMesh, const fvMesh &procMesh, const labelList &faceAddressing, const labelList &cellAddressing, const surfaceLabelField::Boundary &faceAddressingBf)
Construct from components.
~fvFieldDecomposer()
Destructor.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:893
List< label > labelList
A List of labels.
Definition: labelList.H:56
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
dimensioned< scalar > mag(const dimensioned< Type > &)
UList< label > labelUList
Definition: UList.H:65
faceListList boundary(nPatches)