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 | Copyright (C) 2013 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 "AMIInterpolation.H"
29 #include "Map.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(cyclicACMIGAMGInterface, 0);
37  (
38  GAMGInterface,
39  cyclicACMIGAMGInterface,
40  lduInterface
41  );
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
48 (
49  const label index,
50  const lduInterfacePtrsList& coarseInterfaces,
51  const lduInterface& fineInterface,
52  const labelField& localRestrictAddressing,
53  const labelField& neighbourRestrictAddressing,
54  const label fineLevelIndex,
55  const label coarseComm
56 )
57 :
59  (
60  index,
61  coarseInterfaces
62  ),
63  fineCyclicACMIInterface_
64  (
65  refCast<const cyclicACMILduInterface>(fineInterface)
66  )
67 {
68  // Construct face agglomeration from cell agglomeration
69  {
70  // From coarse face to cell
71  DynamicList<label> dynFaceCells(localRestrictAddressing.size());
72 
73  // From face to coarse face
74  DynamicList<label> dynFaceRestrictAddressing
75  (
76  localRestrictAddressing.size()
77  );
78 
79  Map<label> masterToCoarseFace(localRestrictAddressing.size());
80 
81  forAll(localRestrictAddressing, ffi)
82  {
83  label curMaster = localRestrictAddressing[ffi];
84 
85  Map<label>::const_iterator fnd = masterToCoarseFace.find
86  (
87  curMaster
88  );
89 
90  if (fnd == masterToCoarseFace.end())
91  {
92  // New coarse face
93  label coarseI = dynFaceCells.size();
94  dynFaceRestrictAddressing.append(coarseI);
95  dynFaceCells.append(curMaster);
96  masterToCoarseFace.insert(curMaster, coarseI);
97  }
98  else
99  {
100  // Already have coarse face
101  dynFaceRestrictAddressing.append(fnd());
102  }
103  }
104 
105  faceCells_.transfer(dynFaceCells);
106  faceRestrictAddressing_.transfer(dynFaceRestrictAddressing);
107  }
108 
109 
110  // On the owner side construct the AMI
111 
112  if (fineCyclicACMIInterface_.owner())
113  {
114  // Construct the neighbour side agglomeration (as the neighbour would
115  // do it so it the exact loop above using neighbourRestrictAddressing
116  // instead of localRestrictAddressing)
117 
118  labelList nbrFaceRestrictAddressing;
119  {
120  // From face to coarse face
121  DynamicList<label> dynNbrFaceRestrictAddressing
122  (
123  neighbourRestrictAddressing.size()
124  );
125 
126  Map<label> masterToCoarseFace(neighbourRestrictAddressing.size());
127 
128  forAll(neighbourRestrictAddressing, ffi)
129  {
130  label curMaster = neighbourRestrictAddressing[ffi];
131 
132  Map<label>::const_iterator fnd = masterToCoarseFace.find
133  (
134  curMaster
135  );
136 
137  if (fnd == masterToCoarseFace.end())
138  {
139  // New coarse face
140  label coarseI = masterToCoarseFace.size();
141  dynNbrFaceRestrictAddressing.append(coarseI);
142  masterToCoarseFace.insert(curMaster, coarseI);
143  }
144  else
145  {
146  // Already have coarse face
147  dynNbrFaceRestrictAddressing.append(fnd());
148  }
149  }
150 
151  nbrFaceRestrictAddressing.transfer(dynNbrFaceRestrictAddressing);
152  }
153 
154  amiPtr_.reset
155  (
157  (
158  fineCyclicACMIInterface_.AMI(),
159  faceRestrictAddressing_,
160  nbrFaceRestrictAddressing
161  )
162  );
163  }
164 }
165 
166 
167 // * * * * * * * * * * * * * * * * Desstructor * * * * * * * * * * * * * * * //
168 
170 {}
171 
172 
173 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
174 
177 (
178  const Pstream::commsTypes,
179  const labelUList& iF
180 ) const
181 {
182  const cyclicACMIGAMGInterface& nbr =
183  dynamic_cast<const cyclicACMIGAMGInterface&>(neighbPatch());
184  const labelUList& nbrFaceCells = nbr.faceCells();
185 
186  tmp<labelField> tpnf(new labelField(nbrFaceCells.size()));
187  labelField& pnf = tpnf();
188 
189  forAll(pnf, facei)
190  {
191  pnf[facei] = iF[nbrFaceCells[facei]];
192  }
193 
194  return tpnf;
195 }
196 
197 
198 // ************************************************************************* //
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Definition: List.C:390
Field< label > labelField
Specialisation of Field<T> for label.
Definition: labelField.H:49
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Namespace for OpenFOAM.
virtual const labelUList & faceCells() const
Return faceCell addressing.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
commsTypes
Types of communications.
Definition: UPstream.H:64
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
#define forAll(list, i)
Definition: UList.H:421
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
Macros for easy insertion into run-time selection tables.
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const
Transfer and return internal field adjacent to the interface.
GAMG agglomerated cyclic ACMI interface.
virtual ~cyclicACMIGAMGInterface()
Destructor.
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
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Definition: HashTable.H:106
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:51
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:139
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
A class for managing temporary objects.
Definition: PtrList.H:118
defineTypeNameAndDebug(combustionModel, 0)