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;
135 Foam::layerAdditionRemoval::layerAdditionRemoval
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_(NULL),
153 facesPairingPtr_(NULL),
161 Foam::layerAdditionRemoval::layerAdditionRemoval
177 oldLayerThickness_(readOldThickness(dict)),
178 pointsPairingPtr_(NULL),
179 facesPairingPtr_(NULL),
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>& zoneMeshPointMap = fz().meshPointMap();
255 const cell& cFaces = mesh.
cells()[mc[facei]];
260 const edge&
e = cellEdges[i];
262 if (zoneMeshPointMap.
found(e[0]))
264 if (!zoneMeshPointMap.
found(e[1]))
267 avgDelta += curDelta;
269 minDelta =
min(minDelta, curDelta);
270 maxDelta =
max(maxDelta, curDelta);
275 if (zoneMeshPointMap.
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()
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
label timeIndex() const
Return current time index.
const Time & time() const
Return time.
#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.
const double e
Elementary charge.
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.
const vectorField & faceAreas() const
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
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.
virtual const pointField & points() const
Return raw points.
virtual ~layerAdditionRemoval()
Destructor.
const polyMesh & mesh() const
Return the mesh reference.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
virtual void writeDict(Ostream &) const
Write dictionary.
List of mesh modifiers defining the mesh dynamics.
A class for handling words, derived from string.
edgeList edges(const faceUList &) const
Return cell edges.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Virtual base class for mesh modifiers.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
errorManip< error > abort(error &err)
bool found(const Key &) const
Return true if hashedEntry is found in table.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
prefixOSstream Pout(cout,"Pout")
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
scalar mag(const pointField &) const
Return scalar magnitude.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const scalarField & cellVolumes() const
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.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
A cell is defined as a list of faces with extra functionality.
Direct mesh changes based on v1.3 polyTopoChange syntax.
dimensioned< scalar > mag(const dimensioned< Type > &)
const faceZoneMesh & faceZones() const
Return face zone mesh.
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
virtual void write(Ostream &) const
Write.
virtual const faceList & faces() const
Return raw faces.
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
void deleteDemandDrivenData(DataPtr &dataPtr)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const labelList & masterCells() const
Return labels of master cells (cells next to the master face.
virtual bool changeTopology() const
Check for topology change.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.