regionCoupledBaseGAMGInterface.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) 2011-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 "AMIInterpolation.H"
29 #include "Map.H"
30 #include "polyMesh.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 (
36  const label index,
37  const lduInterfacePtrsList& coarseInterfaces,
38  const lduInterface& fineInterface,
39  const labelField& localRestrictAddressing,
40  const labelField& neighbourRestrictAddressing,
41  const label fineLevelIndex,
42  const label coarseComm
43 )
44 :
46  (
47  index,
48  coarseInterfaces
49  ),
50  fineRegionCoupledLduInterface_
51  (
52  refCast<const regionCoupledLduInterface>(fineInterface)
53  )
54 {
55  // Construct face agglomeration from cell agglomeration
56  {
57  // From coarse face to cell
58  DynamicList<label> dynFaceCells(localRestrictAddressing.size());
59 
60  // From face to coarse face
61  DynamicList<label> dynFaceRestrictAddressing
62  (
63  localRestrictAddressing.size()
64  );
65 
66  Map<label> masterToCoarseFace(localRestrictAddressing.size());
67 
68  forAll(localRestrictAddressing, ffi)
69  {
70  label curMaster = localRestrictAddressing[ffi];
71 
72  Map<label>::const_iterator fnd = masterToCoarseFace.find
73  (
74  curMaster
75  );
76 
77  if (fnd == masterToCoarseFace.end())
78  {
79  // New coarse face
80  label coarseI = dynFaceCells.size();
81  dynFaceRestrictAddressing.append(coarseI);
82  dynFaceCells.append(curMaster);
83  masterToCoarseFace.insert(curMaster, coarseI);
84  }
85  else
86  {
87  // Already have coarse face
88  dynFaceRestrictAddressing.append(fnd());
89  }
90  }
91 
92  faceCells_.transfer(dynFaceCells);
93  faceRestrictAddressing_.transfer(dynFaceRestrictAddressing);
94  }
95 
96  /*
97  // On the owner side construct the AMI
98  if (fineRegionCoupledLduInterface_.owner())
99  {
100  const polyMesh& nbrMesh =
101  fineRegionCoupledLduInterface_.nbrMesh();
102 
103  if
104  (
105  nbrMesh.foundObject<GAMGAgglomeration>(GAMGAgglomeration::typeName)
106  )
107  {
108  const GAMGAgglomeration& nbrAgg = nbrMesh.thisDb().lookupObject
109  <
110  GAMGAgglomeration
111  >
112  (
113  GAMGAgglomeration::typeName
114  );
115 
116  label nbrLevel(-1);
117  if (nbrAgg.size() > fineLevelIndex)
118  {
119  nbrLevel = fineLevelIndex;
120  }
121  else
122  {
123  nbrLevel = nbrAgg.size() - 1;
124  }
125 
126  const labelField& nbrRestrictMap =
127  nbrAgg.restrictAddressing(nbrLevel);
128 
129  const labelUList& nbrFaceCells =
130  nbrLduInterface
131  (
132  nbrLevel,
133  nbrPatchID()
134  ).faceCells();
135 
136 
137  const IndirectList<label> nbrPatchRestrictMap
138  (
139  nbrRestrictMap,
140  nbrFaceCells
141  );
142 
143  labelList nbrFaceRestrictAddressing;
144  {
145  // From face to coarse face
146  DynamicList<label> dynNbrFaceRestrictAddressing
147  (
148  nbrPatchRestrictMap.size()
149  );
150 
151  Map<label> masterToCoarseFace(nbrPatchRestrictMap.size());
152 
153  forAll(nbrPatchRestrictMap, ffi)
154  {
155  label curMaster = nbrPatchRestrictMap[ffi];
156 
157  Map<label>::const_iterator fnd = masterToCoarseFace.find
158  (
159  curMaster
160  );
161 
162  if (fnd == masterToCoarseFace.end())
163  {
164  // New coarse face
165  label coarseI = masterToCoarseFace.size();
166  dynNbrFaceRestrictAddressing.append(coarseI);
167  masterToCoarseFace.insert(curMaster, coarseI);
168  }
169  else
170  {
171  // Already have coarse face
172  dynNbrFaceRestrictAddressing.append(fnd());
173  }
174  }
175 
176  nbrFaceRestrictAddressing.transfer
177  (
178  dynNbrFaceRestrictAddressing
179  );
180  }
181 
182  amiPtr_.reset
183  (
184  new AMIInterpolation
185  (
186  fineRegionCoupledLduInterface_.AMI(),
187  faceRestrictAddressing_,
188  nbrFaceRestrictAddressing
189  )
190  );
191  }
192  else
193  {
194  FatalErrorInFunction
195  << " GAMGAgglomeration was not found in the nbr mesh. "
196  << " Check on the cacheAgglomeration flag in fvSolution"
197  << exit(FatalError);
198  }
199  }
200  */
201 
202 }
203 
204 
205 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
206 
208 {}
209 
210 
211 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
212 
215 (
216  const Pstream::commsTypes,
217  const labelUList& iF
218 ) const
219 {
220  /*
221  // const labelUList& nbrFaceCells = nbrPatch().faceCells();
222 
223  const labelUList& nbrFaceCells = nbrLduInterface().faceCells();
224 
225  tmp<labelField> tpnf(new labelField(nbrFaceCells.size()));
226  labelField& pnf = tpnf();
227 
228  forAll(pnf, facei)
229  {
230  pnf[facei] = iF[nbrFaceCells[facei]];
231  }
232  */
233  tmp<labelField> tpnf(new labelField(iF));
234 
235  return tpnf;
236 }
237 
238 
239 // ************************************************************************* //
Field< label > labelField
Specialisation of Field<T> for label.
Definition: labelField.H:49
#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
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
Definition: HashTable.H:112
regionCoupledBaseGAMGInterface(const label index, const lduInterfacePtrsList &coarseInterfaces, const lduInterface &fineInterface, const labelField &restrictAddressing, const labelField &neighbourRestrictAddressing, const label fineLevelIndex, const label coarseComm)
Construct from fine level interface,.
commsTypes
Types of communications.
Definition: UPstream.H:64
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const
Transfer and return internal field adjacent to the interface.
Macros for easy insertion into run-time selection tables.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:142
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
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:51
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
A class for managing temporary objects.
Definition: PtrList.H:53