51 const Foam::scalar Foam::layerAdditionRemoval::addDelta_ = 0.3;
52 const Foam::scalar Foam::layerAdditionRemoval::removeDelta_ = 0.1;
57 void 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."
80 reduce(nFaces, sumOp<label>());
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;
98 Foam::scalar Foam::layerAdditionRemoval::readOldThickness
100 const dictionary&
dict
107 void Foam::layerAdditionRemoval::clearAddressing()
const
109 if (pointsPairingPtr_)
113 Pout<<
"layerAdditionRemoval::clearAddressing()" <<
nl
114 <<
" clearing pointsPairingPtr_" <<
endl;
120 if (facesPairingPtr_)
124 Pout<<
"layerAdditionRemoval::clearAddressing()" <<
nl
125 <<
" clearing facesPairingPtr_" <<
endl;
140 const word& zoneName,
141 const scalar minThickness,
142 const scalar maxThickness,
143 const Switch thicknessFromVolume
147 faceZoneID_(zoneName, ptc.mesh().faceZones()),
148 minLayerThickness_(minThickness),
149 maxLayerThickness_(maxThickness),
150 thicknessFromVolume_(thicknessFromVolume),
151 oldLayerThickness_(-1.0),
152 pointsPairingPtr_(nullptr),
153 facesPairingPtr_(nullptr),
170 faceZoneID_(
dict.lookup(
"faceZoneName"), ptc.mesh().faceZones()),
171 minLayerThickness_(
dict.lookup<scalar>(
"minLayerThickness")),
172 maxLayerThickness_(
dict.lookup<scalar>(
"maxLayerThickness")),
175 dict.lookupOrDefault<
Switch>(
"thicknessFromVolume", true)
177 oldLayerThickness_(readOldThickness(
dict)),
178 pointsPairingPtr_(nullptr),
179 facesPairingPtr_(nullptr),
200 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
213 const polyMesh& mesh = topoChanger().mesh();
221 if (
min(V) < -vSmall)
224 <<
"negative cell volume. Error in mesh motion before "
225 <<
"topological change.\n V: " << V
230 scalar minDelta = great;
234 if (thicknessFromVolume_)
239 scalar curDelta = V[mc[facei]]/
mag(
S[fz[facei]]);
240 avgDelta += curDelta;
241 minDelta =
min(minDelta, curDelta);
242 maxDelta =
max(maxDelta, curDelta);
250 const Map<label>& meshZonePointMap = fz().meshPointMap();
255 const cell& cFaces = mesh.
cells()[mc[facei]];
260 const edge&
e = cellEdges[i];
262 if (meshZonePointMap.
found(
e[0]))
264 if (!meshZonePointMap.
found(
e[1]))
266 scalar curDelta =
e.mag(mesh.
points());
267 avgDelta += curDelta;
269 minDelta =
min(minDelta, curDelta);
270 maxDelta =
max(maxDelta, curDelta);
275 if (meshZonePointMap.
found(
e[1]))
277 scalar curDelta =
e.mag(mesh.
points());
278 avgDelta += curDelta;
280 minDelta =
min(minDelta, curDelta);
281 maxDelta =
max(maxDelta, curDelta);
297 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
298 <<
" for object " <<
name() <<
" : " <<
nl
299 <<
"Layer thickness: min: " << minDelta
300 <<
" max: " << maxDelta <<
" avg: " << avgDelta
301 <<
" old thickness: " << oldLayerThickness_ <<
nl
302 <<
"Removal threshold: " << minLayerThickness_
303 <<
" addition threshold: " << maxLayerThickness_ <<
endl;
306 bool topologicalChange =
false;
310 if (oldLayerThickness_ < 0)
314 Pout<<
"First step. No addition/removal" <<
endl;
318 oldLayerThickness_ = avgDelta;
320 topologicalChange =
false;
322 else if (avgDelta < oldLayerThickness_)
325 if (minDelta < minLayerThickness_)
328 if (setLayerPairing())
340 Pout<<
"bool layerAdditionRemoval::changeTopology() "
341 <<
" const for object " <<
name() <<
" : "
342 <<
"Triggering layer removal" <<
endl;
349 oldLayerThickness_ = great;
351 topologicalChange =
true;
362 oldLayerThickness_ = avgDelta;
368 if (maxDelta > maxLayerThickness_)
372 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
373 <<
" for object " <<
name() <<
" : "
374 <<
"Triggering layer addition" <<
endl;
381 oldLayerThickness_ = 0;
383 topologicalChange =
true;
387 oldLayerThickness_ = avgDelta;
391 return topologicalChange;
400 if (triggerRemoval_ == topoChanger().mesh().time().
timeIndex())
402 removeCellLayer(
ref);
407 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
408 <<
"for object " <<
name() <<
" : "
409 <<
"Clearing addressing after layer removal" <<
endl;
412 triggerRemoval_ = -1;
416 if (triggerAddition_ == topoChanger().mesh().time().
timeIndex())
423 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
424 <<
"for object " <<
name() <<
" : "
425 <<
"Clearing addressing after layer addition" <<
endl;
428 triggerAddition_ = -1;
438 Pout<<
"layerAdditionRemoval::topoChange(const polyTopoChangeMap&) "
439 <<
"for object " <<
name() <<
" : "
440 <<
"Clearing addressing on external request";
442 if (pointsPairingPtr_ || facesPairingPtr_)
453 faceZoneID_.update(topoChanger().mesh().faceZones());
461 if (t < vSmall || maxLayerThickness_ < t)
464 <<
"Incorrect layer thickness definition."
468 minLayerThickness_ = t;
474 if (t < minLayerThickness_)
477 <<
"Incorrect layer thickness definition."
481 maxLayerThickness_ = t;
490 << minLayerThickness_ <<
nl
491 << oldLayerThickness_ <<
nl
492 << maxLayerThickness_ <<
nl
493 << thicknessFromVolume_ <<
endl;
500 <<
" type " <<
type()
502 <<
" faceZoneName " << faceZoneID_.name()
504 <<
" minLayerThickness " << minLayerThickness_
506 <<
" maxLayerThickness " << maxLayerThickness_
508 <<
" thicknessFromVolume " << thicknessFromVolume_
510 <<
" oldLayerThickness " << oldLayerThickness_
512 <<
" active " << active()
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
const wordRe & name() const
Return name.
label index() const
Return index of first matching zone.
bool active() const
Has the zone been found.
bool found(const Key &) const
Return true if hashedEntry is found in table.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
label timeIndex() const
Return current time index.
label size() const
Return the number of elements in the UPtrList.
A cell is defined as a list of faces with extra functionality.
edgeList edges(const faceUList &) const
Return cell edges.
A list of keyword definitions, which are a keyword followed by any number of values (e....
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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
Return labels of master cells (cells next to the master face.
Cell layer addition mesh modifier.
virtual void write(Ostream &) const
Write.
virtual ~layerAdditionRemoval()
Destructor.
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
layerAdditionRemoval(const word &name, const label index, const polyTopoChanger &ptc, const word &zoneName, const scalar minThickness, const scalar maxThickness, const Switch thicknessFromVolume=true)
Construct from components.
virtual void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
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.
const Time & time() const
Return time.
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 meshFaceZones & faceZones() const
Return face zones.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
void deleteDemandDrivenData(DataPtr &dataPtr)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
prefixOSstream Pout(cout, "Pout")
word name(const complex &)
Return a string representation of a complex.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)