oversetGAMGInterface.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) 2021-2023 OpenCFD Ltd.
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 "oversetGAMGInterface.H"
30 
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(oversetGAMGInterface, 0);
38  (
39  GAMGInterface,
40  oversetGAMGInterface,
41  lduInterface
42  );
44  (
45  GAMGInterface,
46  oversetGAMGInterface,
47  Istream
48  );
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 Foam::oversetGAMGInterface::oversetGAMGInterface
55 (
56  const label index,
57  const lduInterfacePtrsList& coarseInterfaces,
58  const lduInterface& fineInterface,
59  const labelField& localRestrictAddressing,
60  const labelField& neighbourRestrictAddressing,
61  const label fineLevelIndex,
62  const label coarseComm
63 )
64 :
66  (
67  index,
68  coarseInterfaces
69  )
70 {
71  // Problem:
72  // - we only want the oversetGAMGInterfaceField
73  // - but this needs a oversetGAMGInterface of at least size 1
74  // (since faceRestrictAddressing cannot have -1 or so in it - it
75  // can only have >= 0 i.e. we cannot agglomerate into nothing)
76  // - note that the end result is not used - the (current) corresponding
77  // oversetGAMGInterfaceField has dummy updateInterfaceMatrix.
78 
79  // Construct face agglomeration from cell agglomeration. Code same as
80  // in e.g. cyclicAMIGAMGInterface.
81  {
82  // From coarse face to cell
83  DynamicList<label> dynFaceCells(localRestrictAddressing.size());
84 
85  // From face to coarse face
86  DynamicList<label> dynFaceRestrictAddressing
87  (
88  localRestrictAddressing.size()
89  );
90 
91  Map<label> masterToCoarseFace(localRestrictAddressing.size());
92 
93  for (const label curMaster : localRestrictAddressing)
94  {
95  const auto iter = masterToCoarseFace.cfind(curMaster);
96 
97  if (iter.good())
98  {
99  // Already have coarse face
100  dynFaceRestrictAddressing.append(iter.val());
101  }
102  else
103  {
104  // New coarse face
105  const label coarseI = dynFaceCells.size();
106 
107  dynFaceRestrictAddressing.append(coarseI);
108  dynFaceCells.append(curMaster);
109  masterToCoarseFace.insert(curMaster, coarseI);
110  }
111  }
112 
113  faceCells_.transfer(dynFaceCells);
114  faceRestrictAddressing_.transfer(dynFaceRestrictAddressing);
115  }
116 }
117 
118 
119 Foam::oversetGAMGInterface::oversetGAMGInterface
120 (
121  const label index,
122  const lduInterfacePtrsList& coarseInterfaces,
123  Istream& is
124 )
125 :
126  GAMGInterface(index, coarseInterfaces, is)
127 {}
128 
129 
130 Foam::oversetGAMGInterface::oversetGAMGInterface
131 (
132  const label index,
133  const lduInterfacePtrsList& coarseInterfaces,
134  const lduInterface& fineInterface,
135  const labelList& interfaceMap,
136  const labelUList& faceCells,
137  const labelUList& faceRestrictAddresssing,
138  const labelUList& faceOffsets,
139  const lduInterfacePtrsList& allInterfaces
140 )
141 :
143  (
144  index,
145  coarseInterfaces,
146  faceCells,
147  faceRestrictAddresssing
148  )
149 {}
150 
151 
152 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
153 
155 (
156  const Pstream::commsTypes commsType,
157  const labelUList& iF
158 ) const
159 {
160  return tmp<labelField>::New(iF);
161 }
162 
163 
165 {
167 }
168 
169 
170 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
commsTypes
Communications types.
Definition: UPstream.H:72
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition: List.C:326
labelList faceRestrictAddressing_
Face restrict addressing.
Definition: GAMGInterface.H:76
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
Macros for easy insertion into run-time selection tables.
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
Definition: HashTableI.H:113
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &iF) const
Transfer and return internal field adjacent to the interface.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
Abstract base class for GAMG agglomerated interfaces.
Definition: GAMGInterface.H:50
virtual void write(Ostream &) const =0
Write to stream.
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches...
Definition: lduInterface.H:53
labelList faceCells_
Face-cell addressing.
Definition: GAMGInterface.H:71
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual void write(Ostream &) const
Write to stream.
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)