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-2023 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 proci,
33  const label procPatchi
34 ) const
35 {
36  const fvPatch& procPatch = procMeshes_[proci].boundary()[procPatchi];
37 
38  if (procPatchi < completeMesh_.boundary().size())
39  {
40  return procPatchi;
41  }
42  else if (isA<processorCyclicFvPatch>(procPatch))
43  {
44  return
45  refCast<const processorCyclicFvPatch>(procPatch)
46  .referPatchIndex();
47  }
48  else
49  {
50  return -1;
51  }
52 }
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
58 (
59  const labelUList& addressing
60 )
61 :
62  labelList(mag(addressing) - 1),
63  forwardFieldMapper(static_cast<const labelList&>(*this))
64 {}
65 
66 
68 (
69  const fvMesh& completeMesh,
70  const PtrList<fvMesh>& procMeshes,
71  const labelListList& faceProcAddressing,
72  const labelListList& cellProcAddressing,
73  const PtrList<surfaceLabelField::Boundary>& faceProcAddressingBf
74 )
75 :
76  completeMesh_(completeMesh),
77  procMeshes_(procMeshes),
78  faceProcAddressing_(faceProcAddressing),
79  cellProcAddressing_(cellProcAddressing),
80  faceProcAddressingBf_(faceProcAddressingBf),
81  patchFieldDecomposers_(procMeshes_.size())
82 {
83  forAll(procMeshes_, proci)
84  {
85  patchFieldDecomposers_.set
86  (
87  proci,
88  new PtrList<patchFieldDecomposer>
89  (
90  procMeshes_[proci].boundary().size()
91  )
92  );
93 
94  forAll(procMeshes_[proci].boundary(), procPatchi)
95  {
96  const label completePatchi = completePatchID(proci, procPatchi);
97 
98  if (completePatchi >= 0)
99  {
100  patchFieldDecomposers_[proci].set
101  (
102  procPatchi,
103  new patchFieldDecomposer
104  (
105  faceProcAddressingBf[proci][completePatchi]
106  )
107  );
108  }
109  }
110  }
111 }
112 
113 
114 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
115 
117 {}
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
122 bool Foam::fvFieldDecomposer::decomposes(const IOobjectList& objects)
123 {
124  bool result = false;
125 
126  #define DO_FV_FIELDS_TYPE(Type, nullArg) \
127  result = result \
128  || !objects.lookupClass(VolField<Type>::Internal::typeName).empty() \
129  || !objects.lookupClass(VolField<Type>::typeName).empty() \
130  || !objects.lookupClass(SurfaceField<Type>::typeName).empty();
131  FOR_ALL_FIELD_TYPES(DO_FV_FIELDS_TYPE)
132  #undef DO_FV_FIELDS_TYPE
133 
134  return result;
135 }
136 
137 
138 // ************************************************************************* //
#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.
static bool decomposes(const IOobjectList &objects)
Return whether anything in the object list gets decomposed.
fvFieldDecomposer(const fvMesh &completeMesh, const PtrList< fvMesh > &procMeshes, const labelListList &faceProcAddressing, const labelListList &cellProcAddressing, const PtrList< surfaceLabelField::Boundary > &faceProcAddressingBf)
Construct from components.
~fvFieldDecomposer()
Destructor.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:857
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
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
dimensioned< scalar > mag(const dimensioned< Type > &)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
UList< label > labelUList
Definition: UList.H:65
faceListList boundary(nPatches)
objects