All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
domainDecompositionTemplates.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) 2014-2020 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 "cyclicPolyPatch.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class BinaryOp>
31 void Foam::domainDecomposition::processInterCyclics
32 (
33  const polyBoundaryMesh& patches,
34  List<DynamicList<DynamicList<label>>>& interPatchFaces,
35  List<Map<label>>& procNbrToInterPatch,
36  List<labelListList>& subPatchIDs,
37  List<labelListList>& subPatchStarts,
38  bool owner,
39  BinaryOp bop
40 ) const
41 {
42  // Processor boundaries from split cyclics
43  forAll(patches, patchi)
44  {
45  if (isA<cyclicPolyPatch>(patches[patchi]))
46  {
47  const cyclicPolyPatch& pp = refCast<const cyclicPolyPatch>
48  (
49  patches[patchi]
50  );
51 
52  if (pp.owner() != owner)
53  {
54  continue;
55  }
56 
57  // cyclic: check opposite side on this processor
58  const labelUList& patchFaceCells = pp.faceCells();
59  const labelUList& nbrPatchFaceCells =
60  pp.nbrPatch().faceCells();
61 
62  // Store old sizes. Used to detect which inter-proc patches
63  // have been added to.
64  labelListList oldInterfaceSizes(nProcs_);
65  forAll(oldInterfaceSizes, proci)
66  {
67  labelList& curOldSizes = oldInterfaceSizes[proci];
68 
69  curOldSizes.setSize(interPatchFaces[proci].size());
70  forAll(curOldSizes, interI)
71  {
72  curOldSizes[interI] =
73  interPatchFaces[proci][interI].size();
74  }
75  }
76 
77  // Add faces with different owner and neighbour processors
78  forAll(patchFaceCells, facei)
79  {
80  const label ownerProc = cellToProc_[patchFaceCells[facei]];
81  const label nbrProc = cellToProc_[nbrPatchFaceCells[facei]];
82  if (bop(ownerProc, nbrProc))
83  {
84  // inter - processor patch face found.
85  addInterProcFace
86  (
87  pp.start()+facei,
88  ownerProc,
89  nbrProc,
90  procNbrToInterPatch,
91  interPatchFaces
92  );
93  }
94  }
95 
96  // 1. Check if any faces added to existing interfaces
97  forAll(oldInterfaceSizes, proci)
98  {
99  const labelList& curOldSizes = oldInterfaceSizes[proci];
100 
101  forAll(curOldSizes, interI)
102  {
103  label oldSz = curOldSizes[interI];
104  if (interPatchFaces[proci][interI].size() > oldSz)
105  {
106  // Added faces to this interface. Add an entry
107  append(subPatchIDs[proci][interI], patchi);
108  append(subPatchStarts[proci][interI], oldSz);
109  }
110  }
111  }
112 
113  // 2. Any new interfaces
114  forAll(subPatchIDs, proci)
115  {
116  label nIntfcs = interPatchFaces[proci].size();
117  subPatchIDs[proci].setSize(nIntfcs, labelList(1, patchi));
118  subPatchStarts[proci].setSize(nIntfcs, labelList(1, label(0)));
119  }
120  }
121  }
122 }
123 
124 
125 // ************************************************************************* //
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
UList< label > labelUList
Definition: UList.H:65
List< label > labelList
A List of labels.
Definition: labelList.H:56
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:278
void setSize(const label)
Reset size of List.
Definition: List.C:281
label patchi