multiDomainDecomposition.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) 2023-2024 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 
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 namespace Foam
31 {
33 }
34 
35 
36 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
37 
38 Foam::PtrList<Foam::domainDecomposition> Foam::multiDomainDecomposition::init
39 (
40  const processorRunTimes& runTimes,
41  const wordList& regionNames
42 )
43 {
45 
46  forAll(result, regioni)
47  {
48  result.set
49  (
50  regioni,
51  new domainDecomposition(runTimes, regionNames[regioni], *this)
52  );
53  }
54 
55  return result;
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
62 (
63  const processorRunTimes& runTimes,
64  const wordList& regionNames
65 )
66 :
68  runTimes_(runTimes)
69 {}
70 
71 
72 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
73 
75 {}
76 
77 
78 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
79 
81 {
82  bool decomposed = false;
83 
84  forAll(*this, regioni)
85  {
86  if (this->operator[](regioni)().readDecompose())
87  {
88  decomposed = true;
89 
90  if (regioni != size() - 1)
91  {
92  Info<< endl;
93  }
94  }
95  }
96 
97  forAll(*this, regioni)
98  {
99  this->operator[](regioni)().postReadDecompose();
100  }
101 
102  forAll(*this, regioni)
103  {
104  this->operator[](regioni)().unconformReadDecompose();
105  }
106 
107  forAll(*this, regioni)
108  {
109  this->operator[](regioni)().writeReadDecompose(decomposed, doSets);
110  }
111 
112  return decomposed;
113 }
114 
115 
117 {
118  bool reconstructed = false;
119 
120  forAll(*this, regioni)
121  {
122  if (this->operator[](regioni)().readReconstruct())
123  {
124  reconstructed = true;
125 
126  if (regioni != size() - 1)
127  {
128  Info<< endl;
129  }
130  }
131  }
132 
133  forAll(*this, regioni)
134  {
135  this->operator[](regioni)().postReadReconstruct();
136  }
137 
138  forAll(*this, regioni)
139  {
140  this->operator[](regioni)().unconformReadReconstruct();
141  }
142 
143  forAll(*this, regioni)
144  {
145  this->operator[](regioni)().writeReadReconstruct(reconstructed, doSets);
146  }
147 
148  return reconstructed;
149 }
150 
151 
154 {
156 
157  forAll(*this, regioni)
158  {
159  const fvMesh::readUpdateState regionStat =
160  this->operator[](regioni)().readUpdateDecompose();
161 
162  if (regioni != size() - 1 && regionStat >= fvMesh::TOPO_CHANGE)
163  {
164  Info<< endl;
165  }
166 
167  stat = stat > regionStat ? stat : regionStat;
168  }
169 
170  forAll(*this, regioni)
171  {
172  this->operator[](regioni)().postReadUpdateDecompose(stat);
173  }
174 
175  forAll(*this, regioni)
176  {
177  this->operator[](regioni)().unconformReadUpdateDecompose(stat);
178  }
179 
180  return stat;
181 }
182 
183 
186 {
188 
189  forAll(*this, regioni)
190  {
191  const fvMesh::readUpdateState regionStat =
192  this->operator[](regioni)().readUpdateReconstruct();
193 
194  if (regioni != size() - 1 && regionStat >= fvMesh::TOPO_CHANGE)
195  {
196  Info<< endl;
197  }
198 
199  stat = stat > regionStat ? stat : regionStat;
200  }
201 
202  forAll(*this, regioni)
203  {
204  this->operator[](regioni)().postReadUpdateReconstruct(stat);
205  }
206 
207  forAll(*this, regioni)
208  {
209  this->operator[](regioni)().unconformReadUpdateReconstruct(stat);
210  }
211 
212  return stat;
213 }
214 
215 
217 {
218  forAll(*this, regioni)
219  {
220  this->operator[](regioni)().writeComplete(doSets);
221  }
222 }
223 
224 
225 void Foam::multiDomainDecomposition::writeProcs(const bool doSets) const
226 {
227  forAll(*this, regioni)
228  {
229  this->operator[](regioni)().writeProcs(doSets);
230  }
231 }
232 
233 
234 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
Automatic domain decomposition class for finite-volume meshes.
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: fvMesh.H:108
@ TOPO_CHANGE
Definition: fvMesh.H:112
virtual ~multiDomainDecomposition()
Destructor.
multiDomainDecomposition(const processorRunTimes &procRunTimes, const wordList &regionNames)
Construct from processor run times and region names.
void writeProcs(const bool doSets) const
Write the decomposed meshes and associated data.
bool readDecompose(const bool doSets)
Read in the complete mesh. Read the processor meshes if they are.
void writeComplete(const bool doSets) const
Write the decomposed meshes and associated data.
bool readReconstruct(const bool doSets)
Read in the processor meshes. Read the complete mesh if it is.
fvMesh::readUpdateState readUpdateReconstruct()
Read-update for reconstruction.
fvMesh::readUpdateState readUpdateDecompose()
Read-update for decomposition.
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
messageStream Info
defineTypeNameAndDebug(combustionModel, 0)
const Foam::wordList regionNames(args.optionFound("allRegions") ? runTime .controlDict().subDict("regionSolvers").toc() :wordList(1, args.optionFound("region") ? args.optionRead< word >("region") :polyMesh::defaultRegion))