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."
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;
100void Foam::layerAdditionRemoval::clearAddressing()
const
102 pointsPairingPtr_.reset(
nullptr);
103 facesPairingPtr_.reset(
nullptr);
109Foam::layerAdditionRemoval::layerAdditionRemoval
114 const word& zoneName,
115 const scalar minThickness,
116 const scalar maxThickness,
117 const bool thicknessFromVolume
121 faceZoneID_(zoneName, ptc.
mesh().faceZones()),
122 minLayerThickness_(minThickness),
123 maxLayerThickness_(maxThickness),
124 thicknessFromVolume_(thicknessFromVolume),
125 oldLayerThickness_(-1.0),
126 pointsPairingPtr_(nullptr),
127 facesPairingPtr_(nullptr),
135Foam::layerAdditionRemoval::layerAdditionRemoval
145 minLayerThickness_(
dict.get<scalar>(
"minLayerThickness")),
146 maxLayerThickness_(
dict.get<scalar>(
"maxLayerThickness")),
147 thicknessFromVolume_(
dict.getOrDefault(
"thicknessFromVolume", true)),
148 oldLayerThickness_(
dict.getOrDefault<scalar>(
"oldLayerThickness", -1)),
149 pointsPairingPtr_(nullptr),
150 facesPairingPtr_(nullptr),
163 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
176 const polyMesh&
mesh = topoChanger().mesh();
178 const faceZone& fz =
mesh.faceZones()[faceZoneID_.index()];
184 if (
min(V) < -VSMALL)
187 <<
"negative cell volume. Error in mesh motion before "
188 <<
"topological change.\n V: " << V
193 scalar minDelta = GREAT;
197 if (thicknessFromVolume_)
202 scalar curDelta =
V[mc[facei]]/
mag(S[fz[facei]]);
203 avgDelta += curDelta;
204 minDelta =
min(minDelta, curDelta);
205 maxDelta =
max(maxDelta, curDelta);
213 const Map<label>& zoneMeshPointMap = fz().meshPointMap();
223 const edge&
e = cellEdges[i];
225 if (zoneMeshPointMap.found(
e[0]))
227 if (!zoneMeshPointMap.found(
e[1]))
230 avgDelta += curDelta;
232 minDelta =
min(minDelta, curDelta);
233 maxDelta =
max(maxDelta, curDelta);
238 if (zoneMeshPointMap.found(
e[1]))
241 avgDelta += curDelta;
243 minDelta =
min(minDelta, curDelta);
244 maxDelta =
max(maxDelta, curDelta);
260 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
261 <<
" for object " <<
name() <<
" : " <<
nl
262 <<
"Layer thickness: min: " << minDelta
263 <<
" max: " << maxDelta <<
" avg: " << avgDelta
264 <<
" old thickness: " << oldLayerThickness_ <<
nl
265 <<
"Removal threshold: " << minLayerThickness_
266 <<
" addition threshold: " << maxLayerThickness_ <<
endl;
269 bool topologicalChange =
false;
273 if (oldLayerThickness_ < 0)
277 Pout<<
"First step. No addition/removal" <<
endl;
281 oldLayerThickness_ = avgDelta;
283 topologicalChange =
false;
285 else if (avgDelta < oldLayerThickness_)
288 if (minDelta < minLayerThickness_)
291 if (setLayerPairing())
303 Pout<<
"bool layerAdditionRemoval::changeTopology() "
304 <<
" const for object " <<
name() <<
" : "
305 <<
"Triggering layer removal" <<
endl;
312 oldLayerThickness_ = GREAT;
314 topologicalChange =
true;
325 oldLayerThickness_ = avgDelta;
331 if (maxDelta > maxLayerThickness_)
335 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
336 <<
" for object " <<
name() <<
" : "
337 <<
"Triggering layer addition" <<
endl;
344 oldLayerThickness_ = 0;
346 topologicalChange =
true;
350 oldLayerThickness_ = avgDelta;
354 return topologicalChange;
363 if (triggerRemoval_ == topoChanger().
mesh().time().
timeIndex())
365 removeCellLayer(
ref);
370 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
371 <<
"for object " <<
name() <<
" : "
372 <<
"Clearing addressing after layer removal" <<
endl;
375 triggerRemoval_ = -1;
379 if (triggerAddition_ == topoChanger().
mesh().time().
timeIndex())
386 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
387 <<
"for object " <<
name() <<
" : "
388 <<
"Clearing addressing after layer addition" <<
endl;
391 triggerAddition_ = -1;
401 Pout<<
"layerAdditionRemoval::updateMesh(const mapPolyMesh&) "
402 <<
"for object " <<
name() <<
" : "
403 <<
"Clearing addressing on external request";
405 if (pointsPairingPtr_ || facesPairingPtr_)
424 if (t < VSMALL || maxLayerThickness_ < t)
427 <<
"Incorrect layer thickness definition."
431 minLayerThickness_ = t;
437 if (t < minLayerThickness_)
440 <<
"Incorrect layer thickness definition."
444 maxLayerThickness_ = t;
453 << minLayerThickness_ <<
nl
454 << oldLayerThickness_ <<
nl
455 << maxLayerThickness_ <<
nl
456 << thicknessFromVolume_ <<
endl;
466 os.writeEntry(
"type",
type());
467 os.writeEntry(
"faceZoneName", faceZoneID_.name());
468 os.writeEntry(
"minLayerThickness", minLayerThickness_);
469 os.writeEntry(
"maxLayerThickness", maxLayerThickness_);
470 os.writeEntry(
"thicknessFromVolume", thicknessFromVolume_);
471 os.writeEntry(
"oldLayerThickness", oldLayerThickness_);
472 os.writeEntry(
"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.
bool active() const noexcept
Has the zone been found.
const wordRe & name() const noexcept
The selector name.
bool found(const Key &key) const
Same as contains().
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 the current time index.
void size(const label n)
Older name for setAddressableSize.
bool empty() const noexcept
True if the list is empty (ie, size() is zero).
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 vertex labels. This can correspond to a directed graph edge or an edge on a ...
A subset of mesh faces organised as a primitive patch.
const labelList & masterCells() const
Deprecated(2023-09) same as frontCells.
const Time & time() const
Return the top-level database.
Cell layer addition mesh modifier.
virtual void write(Ostream &) const
Write.
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
virtual bool changeTopology() const
Check for topology change.
virtual void writeDict(Ostream &) const
Write dictionary.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Virtual base class for mesh modifiers.
label index() const
Return the index of this modifier.
const word & name() const
Return name of this modifier.
Switch active() const
If modifier activate?
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
Mesh consisting of general polyhedral cells.
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 cellList & cells() const
Lookup type of boundary radiation properties.
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 expr V(m.psi().mesh().V())
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
List< label > labelList
A List of labels.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::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.