51const Foam::scalar Foam::layerAdditionRemoval::addDelta_ = 0.3;
52const Foam::scalar Foam::layerAdditionRemoval::removeDelta_ = 0.1;
57void Foam::layerAdditionRemoval::checkDefinition()
62 <<
"Master face zone named " << faceZoneID_.
name()
63 <<
" cannot be found."
69 minLayerThickness_ < VSMALL
70 || maxLayerThickness_ < minLayerThickness_
74 <<
"Incorrect layer thickness definition."
85 <<
"Face extrusion zone contains no faces. "
86 <<
"Please check your mesh definition."
92 Pout<<
"Cell layer addition/removal object " <<
name() <<
" :" <<
nl
93 <<
" faceZoneID: " << faceZoneID_ <<
endl;
98void Foam::layerAdditionRemoval::clearAddressing()
const
100 pointsPairingPtr_.reset(
nullptr);
101 facesPairingPtr_.reset(
nullptr);
112 const word& zoneName,
113 const scalar minThickness,
114 const scalar maxThickness,
115 const bool thicknessFromVolume
119 faceZoneID_(zoneName, ptc.
mesh().faceZones()),
120 minLayerThickness_(minThickness),
121 maxLayerThickness_(maxThickness),
122 thicknessFromVolume_(thicknessFromVolume),
123 oldLayerThickness_(-1.0),
124 pointsPairingPtr_(nullptr),
125 facesPairingPtr_(nullptr),
143 minLayerThickness_(
dict.get<scalar>(
"minLayerThickness")),
144 maxLayerThickness_(
dict.get<scalar>(
"maxLayerThickness")),
145 thicknessFromVolume_(
dict.getOrDefault(
"thicknessFromVolume", true)),
146 oldLayerThickness_(
dict.getOrDefault<scalar>(
"oldLayerThickness", -1)),
147 pointsPairingPtr_(nullptr),
148 facesPairingPtr_(nullptr),
161 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
182 if (
min(V) < -VSMALL)
185 <<
"negative cell volume. Error in mesh motion before "
186 <<
"topological change.\n V: " << V
191 scalar minDelta = GREAT;
195 if (thicknessFromVolume_)
200 scalar curDelta = V[mc[facei]]/
mag(S[fz[facei]]);
201 avgDelta += curDelta;
202 minDelta =
min(minDelta, curDelta);
203 maxDelta =
max(maxDelta, curDelta);
211 const Map<label>& zoneMeshPointMap = fz().meshPointMap();
221 const edge&
e = cellEdges[i];
223 if (zoneMeshPointMap.
found(
e[0]))
225 if (!zoneMeshPointMap.
found(
e[1]))
228 avgDelta += curDelta;
230 minDelta =
min(minDelta, curDelta);
231 maxDelta =
max(maxDelta, curDelta);
236 if (zoneMeshPointMap.
found(
e[1]))
239 avgDelta += curDelta;
241 minDelta =
min(minDelta, curDelta);
242 maxDelta =
max(maxDelta, curDelta);
258 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
259 <<
" for object " <<
name() <<
" : " <<
nl
260 <<
"Layer thickness: min: " << minDelta
261 <<
" max: " << maxDelta <<
" avg: " << avgDelta
262 <<
" old thickness: " << oldLayerThickness_ <<
nl
263 <<
"Removal threshold: " << minLayerThickness_
264 <<
" addition threshold: " << maxLayerThickness_ <<
endl;
267 bool topologicalChange =
false;
271 if (oldLayerThickness_ < 0)
275 Pout<<
"First step. No addition/removal" <<
endl;
279 oldLayerThickness_ = avgDelta;
281 topologicalChange =
false;
283 else if (avgDelta < oldLayerThickness_)
286 if (minDelta < minLayerThickness_)
289 if (setLayerPairing())
301 Pout<<
"bool layerAdditionRemoval::changeTopology() "
302 <<
" const for object " <<
name() <<
" : "
303 <<
"Triggering layer removal" <<
endl;
310 oldLayerThickness_ = GREAT;
312 topologicalChange =
true;
323 oldLayerThickness_ = avgDelta;
329 if (maxDelta > maxLayerThickness_)
333 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
334 <<
" for object " <<
name() <<
" : "
335 <<
"Triggering layer addition" <<
endl;
342 oldLayerThickness_ = 0;
344 topologicalChange =
true;
348 oldLayerThickness_ = avgDelta;
352 return topologicalChange;
361 if (triggerRemoval_ == topoChanger().
mesh().time().
timeIndex())
363 removeCellLayer(
ref);
368 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
369 <<
"for object " <<
name() <<
" : "
370 <<
"Clearing addressing after layer removal" <<
endl;
373 triggerRemoval_ = -1;
377 if (triggerAddition_ == topoChanger().
mesh().time().
timeIndex())
384 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
385 <<
"for object " <<
name() <<
" : "
386 <<
"Clearing addressing after layer addition" <<
endl;
389 triggerAddition_ = -1;
399 Pout<<
"layerAdditionRemoval::updateMesh(const mapPolyMesh&) "
400 <<
"for object " <<
name() <<
" : "
401 <<
"Clearing addressing on external request";
403 if (pointsPairingPtr_ || facesPairingPtr_)
414 faceZoneID_.update(topoChanger().
mesh().faceZones());
422 if (t < VSMALL || maxLayerThickness_ < t)
425 <<
"Incorrect layer thickness definition."
429 minLayerThickness_ = t;
435 if (t < minLayerThickness_)
438 <<
"Incorrect layer thickness definition."
442 maxLayerThickness_ = t;
451 << minLayerThickness_ <<
nl
452 << oldLayerThickness_ <<
nl
453 << maxLayerThickness_ <<
nl
454 << thicknessFromVolume_ <<
endl;
461 <<
" type " <<
type()
463 <<
" faceZoneName " << faceZoneID_.name()
465 <<
" minLayerThickness " << minLayerThickness_
467 <<
" maxLayerThickness " << maxLayerThickness_
469 <<
" thicknessFromVolume " << thicknessFromVolume_
471 <<
" oldLayerThickness " << oldLayerThickness_
473 <<
" active " << active()
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
label index() const
The index of the first matching items, -1 if no matches.
bool active() const noexcept
Has the zone been found.
const wordRe & name() const noexcept
The selector name.
bool found(const Key &key) const
Return true if hashed entry is found in table.
A HashTable to objects of type <T> with a label key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label timeIndex() const noexcept
Return current time index.
void size(const label n)
Older name for setAddressableSize.
label size() const noexcept
The number of elements in the list.
A cell is defined as a list of faces with extra functionality.
edgeList edges(const faceUList &meshFaces) const
Return cell edges.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
A subset of mesh faces organised as a primitive patch.
const labelList & masterCells() const
virtual bool write()
Write the output fields.
Foam::dictionary writeDict() const
Write to dictionary.
const Time & time() const
Return the top-level database.
Cell layer addition mesh modifier.
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
virtual bool changeTopology() const
Check for topology change.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
void updateMesh()
Update for new mesh topology.
Virtual base class for mesh modifiers.
const word & name() const
Return name of this modifier.
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
Mesh consisting of general polyhedral cells.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
Direct mesh changes based on v1.3 polyTopoChange syntax.
List of mesh modifiers defining the mesh dynamics.
const polyMesh & mesh() const
Return the mesh reference.
const scalarField & cellVolumes() const
const vectorField & faceAreas() const
const cellList & cells() const
Lookup type of boundary radiation properties.
@ BEGIN_BLOCK
Begin block [isseparator].
@ END_BLOCK
End block [isseparator].
@ END_STATEMENT
End entry [isseparator].
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.