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