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())
61 FatalErrorIn(
"void Foam::layerAdditionRemoval::checkDefinition()")
62 <<
"Master face zone named " << faceZoneID_.name()
63 <<
" cannot be found." 69 minLayerThickness_ < VSMALL
70 || maxLayerThickness_ < minLayerThickness_
75 "void Foam::layerAdditionRemoval::checkDefinition()" 76 ) <<
"Incorrect layer thickness definition." 80 label nFaces = topoChanger().mesh().faceZones()[faceZoneID_.index()].size();
82 reduce(nFaces, sumOp<label>());
86 FatalErrorIn(
"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;
100 Foam::scalar Foam::layerAdditionRemoval::readOldThickness
102 const dictionary& dict
105 return dict.lookupOrDefault(
"oldLayerThickness", -1.0);
109 void Foam::layerAdditionRemoval::clearAddressing()
const 111 if (pointsPairingPtr_)
115 Pout<<
"layerAdditionRemoval::clearAddressing()" <<
nl 116 <<
" clearing pointsPairingPtr_" <<
endl;
122 if (facesPairingPtr_)
126 Pout<<
"layerAdditionRemoval::clearAddressing()" <<
nl 127 <<
" clearing facesPairingPtr_" <<
endl;
137 Foam::layerAdditionRemoval::layerAdditionRemoval
142 const word& zoneName,
143 const scalar minThickness,
144 const scalar maxThickness,
145 const Switch thicknessFromVolume
150 minLayerThickness_(minThickness),
151 maxLayerThickness_(maxThickness),
152 thicknessFromVolume_(thicknessFromVolume),
153 oldLayerThickness_(-1.0),
154 pointsPairingPtr_(NULL),
155 facesPairingPtr_(NULL),
163 Foam::layerAdditionRemoval::layerAdditionRemoval
179 oldLayerThickness_(readOldThickness(dict)),
180 pointsPairingPtr_(NULL),
181 facesPairingPtr_(NULL),
202 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
223 if (
min(V) < -VSMALL)
225 FatalErrorIn(
"bool layerAdditionRemoval::changeTopology() const")
226 <<
"negative cell volume. Error in mesh motion before " 227 <<
"topological change.\n V: " << V
232 scalar minDelta = GREAT;
236 if (thicknessFromVolume_)
241 scalar curDelta = V[mc[faceI]]/
mag(S[fz[faceI]]);
242 avgDelta += curDelta;
243 minDelta =
min(minDelta, curDelta);
244 maxDelta =
max(maxDelta, curDelta);
252 const Map<label>& zoneMeshPointMap = fz().meshPointMap();
257 const cell& cFaces = mesh.
cells()[mc[faceI]];
262 const edge&
e = cellEdges[i];
264 if (zoneMeshPointMap.
found(e[0]))
266 if (!zoneMeshPointMap.
found(e[1]))
269 avgDelta += curDelta;
271 minDelta =
min(minDelta, curDelta);
272 maxDelta =
max(maxDelta, curDelta);
277 if (zoneMeshPointMap.
found(e[1]))
280 avgDelta += curDelta;
282 minDelta =
min(minDelta, curDelta);
283 maxDelta =
max(maxDelta, curDelta);
299 Pout<<
"bool layerAdditionRemoval::changeTopology() const " 300 <<
" for object " <<
name() <<
" : " <<
nl 301 <<
"Layer thickness: min: " << minDelta
302 <<
" max: " << maxDelta <<
" avg: " << avgDelta
303 <<
" old thickness: " << oldLayerThickness_ <<
nl 304 <<
"Removal threshold: " << minLayerThickness_
305 <<
" addition threshold: " << maxLayerThickness_ <<
endl;
308 bool topologicalChange =
false;
312 if (oldLayerThickness_ < 0)
316 Pout<<
"First step. No addition/removal" <<
endl;
320 oldLayerThickness_ = avgDelta;
322 topologicalChange =
false;
324 else if (avgDelta < oldLayerThickness_)
327 if (minDelta < minLayerThickness_)
330 if (setLayerPairing())
342 Pout<<
"bool layerAdditionRemoval::changeTopology() " 343 <<
" const for object " <<
name() <<
" : " 344 <<
"Triggering layer removal" <<
endl;
351 oldLayerThickness_ = GREAT;
353 topologicalChange =
true;
364 oldLayerThickness_ = avgDelta;
370 if (maxDelta > maxLayerThickness_)
374 Pout<<
"bool layerAdditionRemoval::changeTopology() const " 375 <<
" for object " <<
name() <<
" : " 376 <<
"Triggering layer addition" <<
endl;
383 oldLayerThickness_ = 0;
385 topologicalChange =
true;
389 oldLayerThickness_ = avgDelta;
393 return topologicalChange;
402 if (triggerRemoval_ == topoChanger().
mesh().time().
timeIndex())
404 removeCellLayer(ref);
409 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) " 410 <<
"for object " <<
name() <<
" : " 411 <<
"Clearing addressing after layer removal" <<
endl;
414 triggerRemoval_ = -1;
418 if (triggerAddition_ == topoChanger().
mesh().time().
timeIndex())
425 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) " 426 <<
"for object " <<
name() <<
" : " 427 <<
"Clearing addressing after layer addition" <<
endl;
430 triggerAddition_ = -1;
440 Pout<<
"layerAdditionRemoval::updateMesh(const mapPolyMesh&) " 441 <<
"for object " <<
name() <<
" : " 442 <<
"Clearing addressing on external request";
444 if (pointsPairingPtr_ || facesPairingPtr_)
455 faceZoneID_.update(topoChanger().
mesh().faceZones());
463 if (t < VSMALL || maxLayerThickness_ < t)
467 "void layerAdditionRemoval::setMinLayerThickness" 471 ) <<
"Incorrect layer thickness definition." 475 minLayerThickness_ = t;
481 if (t < minLayerThickness_)
485 "void layerAdditionRemoval::setMaxLayerThickness" 489 ) <<
"Incorrect layer thickness definition." 493 maxLayerThickness_ = t;
502 << minLayerThickness_ <<
nl 503 << oldLayerThickness_ <<
nl 504 << maxLayerThickness_ <<
nl 505 << thicknessFromVolume_ <<
endl;
512 <<
" type " <<
type()
514 <<
" faceZoneName " << faceZoneID_.name()
516 <<
" minLayerThickness " << minLayerThickness_
518 <<
" maxLayerThickness " << maxLayerThickness_
520 <<
" thicknessFromVolume " << thicknessFromVolume_
522 <<
" oldLayerThickness " << oldLayerThickness_
524 <<
" active " << active()
const vectorField & faceAreas() const
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const faceZoneMesh & faceZones() const
Return face zone mesh.
edgeList edges(const faceUList &) const
Return cell edges.
dimensioned< scalar > mag(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
A cell is defined as a list of faces with extra functionality.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Virtual base class for mesh modifiers.
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.
void deleteDemandDrivenData(DataPtr &dataPtr)
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
const cellList & cells() const
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.
const polyMesh & mesh() const
Return the mesh reference.
A list of keyword definitions, which are a keyword followed by any number of values (e...
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
virtual ~layerAdditionRemoval()
Destructor.
scalar mag(const pointField &) const
Return scalar magnitude.
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void writeDict(Ostream &) const
Write dictionary.
virtual const pointField & points() const
Return raw points.
label timeIndex() const
Return current time index.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Macros for easy insertion into run-time selection tables.
List of mesh modifiers defining the mesh dynamics.
errorManip< error > abort(error &err)
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Mesh consisting of general polyhedral cells.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
virtual void write(Ostream &) const
Write.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Direct mesh changes based on v1.3 polyTopoChange syntax.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
const Time & time() const
Return time.
virtual const faceList & faces() const
Return raw faces.
const scalarField & cellVolumes() const
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
bool found(const Key &) const
Return true if hashedEntry is found in table.
virtual bool changeTopology() const
Check for topology change.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")