MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / updateLabels

Function updateLabels

src/meshTools/sets/topoSets/topoSet.C:137–180  ·  view source on GitHub ↗

Update stored cell numbers using map. Do in two passes to prevent allocation if nothing changed.

Source from the content-addressed store, hash-verified

135// Update stored cell numbers using map.
136// Do in two passes to prevent allocation if nothing changed.
137void Foam::topoSet::updateLabels(const labelList& map)
138{
139 // Iterate over map to see if anything changed
140 bool changed = false;
141
142 forAllConstIter(labelHashSet, *this, iter)
143 {
144 if ((iter.key() < 0) || (iter.key() > map.size()))
145 {
146 FatalErrorInFunction
147 << "Illegal content " << iter.key() << " of set:" << name()
148 << " of type " << type() << endl
149 << "Value should be between 0 and " << map.size()-1
150 << abort(FatalError);
151 }
152
153 const label newCelli = map[iter.key()];
154
155 if (newCelli != iter.key())
156 {
157 changed = true;
158
159 break;
160 }
161 }
162
163 // Relabel (use second Map to prevent overlapping)
164 if (changed)
165 {
166 labelHashSet newSet(2*size());
167
168 forAllConstIter(labelHashSet, *this, iter)
169 {
170 const label newCelli = map[iter.key()];
171
172 if (newCelli >= 0)
173 {
174 newSet.insert(newCelli);
175 }
176 }
177
178 transfer(newSet);
179 }
180}
181
182
183void Foam::topoSet::check(const label maxLabel)

Callers 2

updateMeshFunction · 0.70
updateMeshFunction · 0.70

Calls 8

forAllConstIterFunction · 0.50
nameFunction · 0.50
typeEnum · 0.50
abortFunction · 0.50
transferFunction · 0.50
keyMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected