addCellZones.H
Go to the documentation of this file.
1 // Set any cellZones
2 // Note cell labelling unaffected by previous mergePatchPairs
3 
4 {
5  const label nZones = blocks.numZonedBlocks();
6  if (nZones)
7  {
8  Info<< nl << "Adding cell zones" << endl;
9 
10  // Map from zoneName to cellZone index
11  HashTable<label> zoneMap(nZones);
12 
13  // Cells per zone.
14  List<DynamicList<label>> zoneCells(nZones);
15 
16  // Running cell counter
17  label celli = 0;
18 
19  // Largest zone so far
20  label freeZoneI = 0;
21 
22  for (const block& b : blocks)
23  {
24  const word& zoneName = b.zoneName();
25  const label nCellsInBlock = b.cells().size();
26 
27  if (zoneName.size())
28  {
29  const auto iter = zoneMap.cfind(zoneName);
30 
31  label zonei;
32 
33  if (iter.found())
34  {
35  zonei = *iter;
36  }
37  else
38  {
39  zonei = freeZoneI++;
40 
41  Info<< " " << zonei << '\t' << zoneName << endl;
42 
43  zoneMap.insert(zoneName, zonei);
44  }
45 
46 
47  // Fill with cell ids
48 
49  zoneCells[zonei].reserve
50  (
51  zoneCells[zonei].size() + nCellsInBlock
52  );
53 
54  const label endOfFill = celli + nCellsInBlock;
55 
56  for (; celli < endOfFill; ++celli)
57  {
58  zoneCells[zonei].append(celli);
59  }
60  }
61  else
62  {
63  celli += nCellsInBlock;
64  }
65  }
66 
67  List<cellZone*> cz(zoneMap.size());
68  forAllConstIters(zoneMap, iter)
69  {
70  const word& zoneName = iter.key();
71  const label zonei = iter.val();
72 
73  cz[zonei] = new cellZone
74  (
75  zoneName,
76  zoneCells[zonei].shrink(),
77  zonei,
78  mesh.cellZones()
79  );
80  }
81 
82  mesh.pointZones().resize(0);
83  mesh.faceZones().resize(0);
84  mesh.cellZones().resize(0);
85  mesh.addZones(List<pointZone*>(), List<faceZone*>(), cz);
86  }
87 }
nZones
label nZones
Definition: interpolatedFaces.H:24
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::nl
constexpr char nl
Definition: Ostream.H:385
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28