51 const Foam::scalar Foam::layerAdditionRemoval::addDelta_ = 0.3;
52 const Foam::scalar Foam::layerAdditionRemoval::removeDelta_ = 0.1;
57 void Foam::layerAdditionRemoval::checkDefinition()
59 if (!faceZoneID_.active())
62 <<
"Master face zone named " << faceZoneID_.name()
63 <<
" cannot be found." 69 minLayerThickness_ < vSmall
70 || maxLayerThickness_ < minLayerThickness_
74 <<
"Incorrect layer thickness definition." 78 label nFaces = topoChanger().mesh().faceZones()[faceZoneID_.index()].size();
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
103 return dict.lookupOrDefault(
"oldLayerThickness", -1.0);
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
148 minLayerThickness_(minThickness),
149 maxLayerThickness_(maxThickness),
150 thicknessFromVolume_(thicknessFromVolume),
151 oldLayerThickness_(-1.0),
152 pointsPairingPtr_(
nullptr),
153 facesPairingPtr_(
nullptr),
171 minLayerThickness_(dict.
lookup<scalar>(
"minLayerThickness")),
172 maxLayerThickness_(dict.
lookup<scalar>(
"maxLayerThickness")),
177 oldLayerThickness_(readOldThickness(dict)),
178 pointsPairingPtr_(
nullptr),
179 facesPairingPtr_(
nullptr),
200 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
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]))
267 avgDelta += curDelta;
269 minDelta =
min(minDelta, curDelta);
270 maxDelta =
max(maxDelta, curDelta);
275 if (meshZonePointMap.
found(e[1]))
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::updateMesh(const mapPolyMesh&) " 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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual void write(Ostream &) const
Write.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool changeTopology() const
Check for topology change.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
const labelList & masterCells() const
Return labels of master cells (cells next to the master face.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
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.
const cellList & cells() const
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Macros for easy insertion into run-time selection tables.
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
virtual const pointField & points() const
Return raw points.
edgeList edges(const faceUList &) const
Return cell edges.
virtual ~layerAdditionRemoval()
Destructor.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool found(const Key &) const
Return true if hashedEntry is found in table.
List of mesh modifiers defining the mesh dynamics.
A class for handling words, derived from string.
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const GeometricField< Type, fvPatchField, volMesh > &)
scalar mag(const pointField &) const
Return scalar magnitude.
virtual const faceList & faces() const
Return raw faces.
Virtual base class for mesh modifiers.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
const Time & time() const
Return time.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
word name(const complex &)
Return a string representation of a complex.
label timeIndex() const
Return current time index.
virtual void writeDict(Ostream &) const
Write dictionary.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A cell is defined as a list of faces with extra functionality.
prefixOSstream Pout(cout, "Pout")
const meshFaceZones & faceZones() const
Return face zones.
const vectorField & faceAreas() const
Direct mesh changes based on v1.3 polyTopoChange syntax.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
const polyMesh & mesh() const
Return the mesh reference.
void deleteDemandDrivenData(DataPtr &dataPtr)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const scalarField & cellVolumes() const