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-2025 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 fileName& meshPath,
42  const wordList& regionNames
43 )
44 {
46 
47  forAll(result, regioni)
48  {
49  result.set
50  (
51  regioni,
52  new domainDecomposition
53  (
54  runTimes,
55  meshPath,
56  regionNames[regioni],
57  *this
58  )
59  );
60  }
61 
62  return result;
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
67 
69 (
70  const processorRunTimes& runTimes,
71  const fileName& meshPath,
72  const wordList& regionNames
73 )
74 :
76  runTimes_(runTimes)
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  bool decomposed = false;
91 
92  forAll(*this, regioni)
93  {
94  if (this->operator[](regioni)().readDecompose(false))
95  {
96  decomposed = true;
97 
98  if (regioni != size() - 1)
99  {
100  Info<< endl;
101  }
102  }
103  }
104 
105  forAll(*this, regioni)
106  {
107  this->operator[](regioni)().postReadDecompose();
108  }
109 
110  forAll(*this, regioni)
111  {
112  this->operator[](regioni)().unconformReadDecompose();
113  }
114 
115  forAll(*this, regioni)
116  {
117  this->operator[](regioni)().writeReadDecompose(decomposed, doSets);
118  }
119 
120  return decomposed;
121 }
122 
123 
125 {
126  bool reconstructed = false;
127 
128  forAll(*this, regioni)
129  {
130  if (this->operator[](regioni)().readReconstruct(false))
131  {
132  reconstructed = true;
133 
134  if (regioni != size() - 1)
135  {
136  Info<< endl;
137  }
138  }
139  }
140 
141  forAll(*this, regioni)
142  {
143  this->operator[](regioni)().postReadReconstruct();
144  }
145 
146  forAll(*this, regioni)
147  {
148  this->operator[](regioni)().unconformReadReconstruct();
149  }
150 
151  forAll(*this, regioni)
152  {
153  this->operator[](regioni)().writeReadReconstruct(reconstructed, doSets);
154  }
155 
156  return reconstructed;
157 }
158 
159 
162 {
164 
165  forAll(*this, regioni)
166  {
167  const fvMesh::readUpdateState regionStat =
168  this->operator[](regioni)().readUpdateDecompose(false);
169 
170  if (regioni != size() - 1 && regionStat >= fvMesh::TOPO_CHANGE)
171  {
172  Info<< endl;
173  }
174 
175  stat = stat > regionStat ? stat : regionStat;
176  }
177 
178  forAll(*this, regioni)
179  {
180  this->operator[](regioni)().postReadUpdateDecompose(stat);
181  }
182 
183  forAll(*this, regioni)
184  {
185  this->operator[](regioni)().unconformReadUpdateDecompose(stat);
186  }
187 
188  return stat;
189 }
190 
191 
194 {
196 
197  forAll(*this, regioni)
198  {
199  const fvMesh::readUpdateState regionStat =
200  this->operator[](regioni)().readUpdateReconstruct(false);
201 
202  if (regioni != size() - 1 && regionStat >= fvMesh::TOPO_CHANGE)
203  {
204  Info<< endl;
205  }
206 
207  stat = stat > regionStat ? stat : regionStat;
208  }
209 
210  forAll(*this, regioni)
211  {
212  this->operator[](regioni)().postReadUpdateReconstruct(stat);
213  }
214 
215  forAll(*this, regioni)
216  {
217  this->operator[](regioni)().unconformReadUpdateReconstruct(stat);
218  }
219 
220  return stat;
221 }
222 
223 
225 {
226  forAll(*this, regioni)
227  {
228  this->operator[](regioni)().writeComplete(doSets);
229  }
230 }
231 
232 
233 void Foam::multiDomainDecomposition::writeProcs(const bool doSets) const
234 {
235  forAll(*this, regioni)
236  {
237  this->operator[](regioni)().writeProcs(doSets);
238  }
239 }
240 
241 
242 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
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.
A class for handling file names.
Definition: fileName.H:82
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: fvMesh.H:105
@ TOPO_CHANGE
Definition: fvMesh.H:109
virtual ~multiDomainDecomposition()
Destructor.
void writeProcs(const bool doSets) const
Write the decomposed meshes and associated data.
multiDomainDecomposition(const processorRunTimes &procRunTimes, const fileName &meshPath, const wordList &regionNames)
Construct from processor run times and region names.
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:258
messageStream Info
defineTypeNameAndDebug(combustionModel, 0)
word meshPath
Definition: setMeshPath.H:1
const Foam::wordList regionNames(args.optionFound("allRegions") ? runTime .controlDict().subDict("regionSolvers").toc() :wordList(1, args.optionFound("region") ? args.optionRead< word >("region") :polyMesh::defaultRegion))