cyclicACMIGAMGInterface.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "AMIInterpolation.H"
32 #include "Map.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(cyclicACMIGAMGInterface, 0);
40  (
41  GAMGInterface,
42  cyclicACMIGAMGInterface,
43  lduInterface
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
51 (
52  const label index,
53  const lduInterfacePtrsList& coarseInterfaces,
54  const lduInterface& fineInterface,
55  const labelField& localRestrictAddressing,
56  const labelField& neighbourRestrictAddressing,
57  const label fineLevelIndex,
58  const label coarseComm
59 )
60 :
62  (
63  index,
64  coarseInterfaces
65  ),
66  fineCyclicACMIInterface_
67  (
68  refCast<const cyclicACMILduInterface>(fineInterface)
69  )
70 {
71  // Construct face agglomeration from cell agglomeration
72  {
73  // From coarse face to cell
74  DynamicList<label> dynFaceCells(localRestrictAddressing.size());
75 
76  // From face to coarse face
77  DynamicList<label> dynFaceRestrictAddressing
78  (
79  localRestrictAddressing.size()
80  );
81 
82  Map<label> masterToCoarseFace(localRestrictAddressing.size());
83 
84  for (const label curMaster : localRestrictAddressing)
85  {
86  const auto iter = masterToCoarseFace.cfind(curMaster);
87 
88  if (iter.found())
89  {
90  // Already have coarse face
91  dynFaceRestrictAddressing.append(iter.val());
92  }
93  else
94  {
95  // New coarse face
96  const label coarseI = dynFaceCells.size();
97  dynFaceRestrictAddressing.append(coarseI);
98  dynFaceCells.append(curMaster);
99  masterToCoarseFace.insert(curMaster, coarseI);
100  }
101  }
102 
103  faceCells_.transfer(dynFaceCells);
104  faceRestrictAddressing_.transfer(dynFaceRestrictAddressing);
105  }
106 
107 
108  // On the owner side construct the AMI
109 
110  if (fineCyclicACMIInterface_.owner())
111  {
112  // Construct the neighbour side agglomeration (as the neighbour would
113  // do it so it the exact loop above using neighbourRestrictAddressing
114  // instead of localRestrictAddressing)
115 
116  labelList nbrFaceRestrictAddressing;
117  {
118  // From face to coarse face
119  DynamicList<label> dynNbrFaceRestrictAddressing
120  (
121  neighbourRestrictAddressing.size()
122  );
123 
124  Map<label> masterToCoarseFace(neighbourRestrictAddressing.size());
125 
126  for (const label curMaster : neighbourRestrictAddressing)
127  {
128  const auto iter = masterToCoarseFace.cfind(curMaster);
129 
130  if (iter.found())
131  {
132  // Already have coarse face
133  dynNbrFaceRestrictAddressing.append(iter.val());
134  }
135  else
136  {
137  // New coarse face
138  const label coarseI = masterToCoarseFace.size();
139  dynNbrFaceRestrictAddressing.append(coarseI);
140  masterToCoarseFace.insert(curMaster, coarseI);
141  }
142  }
143 
144  nbrFaceRestrictAddressing.transfer(dynNbrFaceRestrictAddressing);
145  }
146 
147  amiPtr_.reset
148  (
150  (
151  fineCyclicACMIInterface_.AMI(),
152  faceRestrictAddressing_,
153  nbrFaceRestrictAddressing
154  )
155  );
156  }
157 }
158 
159 
160 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
161 
163 {}
164 
165 
166 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
167 
170 (
171  const Pstream::commsTypes commsType,
172  const labelUList& iF
173 ) const
174 {
175  const cyclicACMIGAMGInterface& nbr =
176  dynamic_cast<const cyclicACMIGAMGInterface&>(neighbPatch());
177  const labelUList& nbrFaceCells = nbr.faceCells();
178 
179  auto tpnf = tmp<labelField>::New(nbrFaceCells.size());
180  labelField& pnf = tpnf.ref();
181 
182  forAll(pnf, facei)
183  {
184  pnf[facei] = iF[nbrFaceCells[facei]];
185  }
186 
187  return tpnf;
188 }
189 
190 
191 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::DynamicList< label >
Foam::cyclicACMIGAMGInterface
GAMG agglomerated cyclic ACMI interface.
Definition: cyclicACMIGAMGInterface.H:51
Foam::lduInterface
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:54
Foam::Map< label >
AMIInterpolation.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Map.H
Foam::cyclicACMIGAMGInterface::internalFieldTransfer
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const
Transfer and return internal field adjacent to the interface.
Definition: cyclicACMIGAMGInterface.C:170
Foam::Field< label >
Foam::GAMGInterface::faceCells
virtual const labelUList & faceCells() const
Return faceCell addressing.
Definition: GAMGInterface.H:221
Foam::GAMGInterface
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:54
Foam::List::transfer
void transfer(List< T > &list)
Definition: List.C:456
Foam::UPtrList< const lduInterface >
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
cyclicACMIGAMGInterface.H
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::cyclicACMIGAMGInterface::~cyclicACMIGAMGInterface
virtual ~cyclicACMIGAMGInterface()
Destructor.
Definition: cyclicACMIGAMGInterface.C:162
Foam::List< label >
Foam::AMIInterpolation
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
Definition: AMIInterpolation.H:79
Foam::UList< label >
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)