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 | Copyright (C) 2014 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>
32 (
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
44  {
45  if (isA<cyclicPolyPatch>(patches[patchi]))
46  {
47  const cyclicPolyPatch& pp = refCast<const cyclicPolyPatch>
48  (
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.neighbPatch().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 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
cyclicPolyPatch.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::cyclicPolyPatch
Cyclic plane patch.
Definition: cyclicPolyPatch.H:63
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::cyclicPolyPatch::neighbPatch
const cyclicPolyPatch & neighbPatch() const
Definition: cyclicPolyPatch.H:328
Foam::Map< label >
Foam::domainDecomposition::processInterCyclics
void processInterCyclics(const polyBoundaryMesh &patches, List< DynamicList< DynamicList< label > > > &interPatchFaces, List< Map< label > > &procNbrToInterPatch, List< labelListList > &subPatchIDs, List< labelListList > &subPatchStarts, bool owner, BinaryOp bop) const
Generate sub patch info for processor cyclics.
Definition: domainDecompositionTemplates.C:32
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:59
Foam::cyclicPolyPatch::owner
virtual bool owner() const
Does this side own the patch ?
Definition: cyclicPolyPatch.H:318
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:340
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
patchi
label patchi
Definition: getPatchFieldScalar.H:1
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.