51 const Foam::scalar Foam::layerAdditionRemoval::addDelta_ = 0.3;
52 const Foam::scalar Foam::layerAdditionRemoval::removeDelta_ = 0.1;
57 void Foam::layerAdditionRemoval::checkDefinition()
63 "void Foam::layerAdditionRemoval::checkDefinition()"
64 ) <<
"Master face zone named " << faceZoneID_.
name()
65 <<
" cannot be found."
71 minLayerThickness_ < VSMALL
72 || maxLayerThickness_ < minLayerThickness_
77 "void Foam::layerAdditionRemoval::checkDefinition()"
78 ) <<
"Incorrect layer thickness definition."
86 "void Foam::layerAdditionRemoval::checkDefinition()"
87 ) <<
"Face extrusion zone contains no faces. "
88 <<
" Please check your mesh definition."
94 Pout<<
"Cell layer addition/removal object " <<
name() <<
" :" <<
nl
95 <<
" faceZoneID: " << faceZoneID_ <<
endl;
99 Foam::scalar Foam::layerAdditionRemoval::readOldThickness
101 const dictionary& dict
104 return dict.lookupOrDefault(
"oldLayerThickness", -1.0);
108 void Foam::layerAdditionRemoval::clearAddressing()
const
119 Foam::layerAdditionRemoval::layerAdditionRemoval
124 const word& zoneName,
125 const scalar minThickness,
126 const scalar maxThickness
131 minLayerThickness_(minThickness),
132 maxLayerThickness_(maxThickness),
133 oldLayerThickness_(-1.0),
134 pointsPairingPtr_(NULL),
135 facesPairingPtr_(NULL),
144 Foam::layerAdditionRemoval::layerAdditionRemoval
156 oldLayerThickness_(readOldThickness(dict)),
157 pointsPairingPtr_(NULL),
158 facesPairingPtr_(NULL),
179 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
192 const faceZone& fz = topoChanger().mesh().faceZones()[faceZoneID_.index()];
195 const scalarField& V = topoChanger().mesh().cellVolumes();
196 const vectorField& S = topoChanger().mesh().faceAreas();
198 if (
min(V) < -VSMALL)
200 FatalErrorIn(
"bool layerAdditionRemoval::changeTopology() const")
201 <<
"negative cell volume. Error in mesh motion before "
202 <<
"topological change.\n V: " << V
207 scalar minDelta = GREAT;
212 scalar curDelta = V[mc[faceI]]/
mag(S[fz[faceI]]);
213 avgDelta += curDelta;
214 minDelta =
min(minDelta, curDelta);
215 maxDelta =
max(maxDelta, curDelta);
218 avgDelta /= fz.
size();
269 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
270 <<
" for object " <<
name() <<
" : " <<
nl
271 <<
"Layer thickness: min: " << minDelta
272 <<
" max: " << maxDelta <<
" avg: " << avgDelta
273 <<
" old thickness: " << oldLayerThickness_ <<
nl
274 <<
"Removal threshold: " << minLayerThickness_
275 <<
" addition threshold: " << maxLayerThickness_ <<
endl;
278 bool topologicalChange =
false;
282 if (oldLayerThickness_ < 0)
286 Pout <<
"First step. No addition/removal" <<
endl;
291 oldLayerThickness_ = avgDelta;
293 topologicalChange =
false;
295 else if (avgDelta < oldLayerThickness_)
298 if (minDelta < minLayerThickness_)
301 if (setLayerPairing())
313 Pout<<
"bool layerAdditionRemoval::changeTopology() "
314 <<
" const for object " <<
name() <<
" : "
315 <<
"Triggering layer removal" <<
endl;
318 triggerRemoval_ = topoChanger().mesh().time().timeIndex();
322 oldLayerThickness_ = GREAT;
324 topologicalChange =
true;
335 oldLayerThickness_ = avgDelta;
341 if (maxDelta > maxLayerThickness_)
345 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
346 <<
" for object " <<
name() <<
" : "
347 <<
"Triggering layer addition" <<
endl;
350 triggerAddition_ = topoChanger().mesh().time().timeIndex();
354 oldLayerThickness_ = 0;
356 topologicalChange =
true;
360 oldLayerThickness_ = avgDelta;
364 return topologicalChange;
373 if (triggerRemoval_ == topoChanger().
mesh().time().
timeIndex())
375 removeCellLayer(ref);
380 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange& ref) "
381 <<
" for object " <<
name() <<
" : "
382 <<
"Clearing addressing after layer removal. " <<
endl;
385 triggerRemoval_ = -1;
389 if (triggerAddition_ == topoChanger().
mesh().time().
timeIndex())
396 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange& ref) "
397 <<
" for object " <<
name() <<
" : "
398 <<
"Clearing addressing after layer addition. " <<
endl;
401 triggerAddition_ = -1;
411 Pout<<
"layerAdditionRemoval::updateMesh(const mapPolyMesh&) "
412 <<
" for object " <<
name() <<
" : "
413 <<
"Clearing addressing on external request. ";
415 if (pointsPairingPtr_ || facesPairingPtr_)
421 Pout <<
"Pointers not set." <<
endl;
426 faceZoneID_.update(topoChanger().
mesh().faceZones());
437 || maxLayerThickness_ < t
442 "void layerAdditionRemoval::setMinLayerThickness("
443 "const scalar t) const"
444 ) <<
"Incorrect layer thickness definition."
448 minLayerThickness_ = t;
456 t < minLayerThickness_
461 "void layerAdditionRemoval::setMaxLayerThickness("
462 "const scalar t) const"
463 ) <<
"Incorrect layer thickness definition."
467 maxLayerThickness_ = t;
476 << minLayerThickness_ <<
nl
477 << oldLayerThickness_ <<
nl
478 << maxLayerThickness_ <<
endl;
485 <<
" type " <<
type()
487 <<
" faceZoneName " << faceZoneID_.name()
489 <<
" minLayerThickness " << minLayerThickness_
491 <<
" maxLayerThickness " << maxLayerThickness_
493 <<
" oldLayerThickness " << oldLayerThickness_
495 <<
" active " << active()