Go to the documentation of this file.
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 void Foam::layerAdditionRemoval::clearAddressing()
const
100 pointsPairingPtr_.reset(
nullptr);
101 facesPairingPtr_.reset(
nullptr);
107 Foam::layerAdditionRemoval::layerAdditionRemoval
112 const word& zoneName,
113 const scalar minThickness,
114 const scalar maxThickness,
115 const bool thicknessFromVolume
120 minLayerThickness_(minThickness),
121 maxLayerThickness_(maxThickness),
122 thicknessFromVolume_(thicknessFromVolume),
123 oldLayerThickness_(-1.0),
124 pointsPairingPtr_(
nullptr),
125 facesPairingPtr_(
nullptr),
133 Foam::layerAdditionRemoval::layerAdditionRemoval
143 minLayerThickness_(
dict.
get<scalar>(
"minLayerThickness")),
144 maxLayerThickness_(
dict.
get<scalar>(
"maxLayerThickness")),
147 pointsPairingPtr_(
nullptr),
148 facesPairingPtr_(
nullptr),
161 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
182 if (
min(V) < -VSMALL)
185 <<
"negative cell volume. Error in mesh motion before "
186 <<
"topological change.\n V: " << V
191 scalar minDelta = GREAT;
195 if (thicknessFromVolume_)
200 scalar curDelta = V[mc[facei]]/
mag(S[fz[facei]]);
201 avgDelta += curDelta;
202 minDelta =
min(minDelta, curDelta);
203 maxDelta =
max(maxDelta, curDelta);
211 const Map<label>& zoneMeshPointMap = fz().meshPointMap();
221 const edge&
e = cellEdges[i];
223 if (zoneMeshPointMap.found(
e[0]))
225 if (!zoneMeshPointMap.found(
e[1]))
228 avgDelta += curDelta;
230 minDelta =
min(minDelta, curDelta);
231 maxDelta =
max(maxDelta, curDelta);
236 if (zoneMeshPointMap.found(
e[1]))
239 avgDelta += curDelta;
241 minDelta =
min(minDelta, curDelta);
242 maxDelta =
max(maxDelta, curDelta);
258 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
259 <<
" for object " <<
name() <<
" : " <<
nl
260 <<
"Layer thickness: min: " << minDelta
261 <<
" max: " << maxDelta <<
" avg: " << avgDelta
262 <<
" old thickness: " << oldLayerThickness_ <<
nl
263 <<
"Removal threshold: " << minLayerThickness_
264 <<
" addition threshold: " << maxLayerThickness_ <<
endl;
267 bool topologicalChange =
false;
271 if (oldLayerThickness_ < 0)
275 Pout<<
"First step. No addition/removal" <<
endl;
279 oldLayerThickness_ = avgDelta;
281 topologicalChange =
false;
283 else if (avgDelta < oldLayerThickness_)
286 if (minDelta < minLayerThickness_)
289 if (setLayerPairing())
301 Pout<<
"bool layerAdditionRemoval::changeTopology() "
302 <<
" const for object " <<
name() <<
" : "
303 <<
"Triggering layer removal" <<
endl;
310 oldLayerThickness_ = GREAT;
312 topologicalChange =
true;
323 oldLayerThickness_ = avgDelta;
329 if (maxDelta > maxLayerThickness_)
333 Pout<<
"bool layerAdditionRemoval::changeTopology() const "
334 <<
" for object " <<
name() <<
" : "
335 <<
"Triggering layer addition" <<
endl;
342 oldLayerThickness_ = 0;
344 topologicalChange =
true;
348 oldLayerThickness_ = avgDelta;
352 return topologicalChange;
361 if (triggerRemoval_ == topoChanger().
mesh().time().
timeIndex())
363 removeCellLayer(
ref);
368 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
369 <<
"for object " <<
name() <<
" : "
370 <<
"Clearing addressing after layer removal" <<
endl;
373 triggerRemoval_ = -1;
377 if (triggerAddition_ == topoChanger().
mesh().time().
timeIndex())
384 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) "
385 <<
"for object " <<
name() <<
" : "
386 <<
"Clearing addressing after layer addition" <<
endl;
389 triggerAddition_ = -1;
399 Pout<<
"layerAdditionRemoval::updateMesh(const mapPolyMesh&) "
400 <<
"for object " <<
name() <<
" : "
401 <<
"Clearing addressing on external request";
403 if (pointsPairingPtr_ || facesPairingPtr_)
414 faceZoneID_.update(topoChanger().
mesh().faceZones());
422 if (t < VSMALL || maxLayerThickness_ < t)
425 <<
"Incorrect layer thickness definition."
429 minLayerThickness_ = t;
435 if (t < minLayerThickness_)
438 <<
"Incorrect layer thickness definition."
442 maxLayerThickness_ = t;
451 << minLayerThickness_ <<
nl
452 << oldLayerThickness_ <<
nl
453 << maxLayerThickness_ <<
nl
454 << thicknessFromVolume_ <<
endl;
461 <<
" type " <<
type()
463 <<
" faceZoneName " << faceZoneID_.name()
465 <<
" minLayerThickness " << minLayerThickness_
467 <<
" maxLayerThickness " << maxLayerThickness_
469 <<
" thicknessFromVolume " << thicknessFromVolume_
471 <<
" oldLayerThickness " << oldLayerThickness_
473 <<
" active " << active()
int debug
Static debugging option.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
virtual const pointField & points() const
Return raw points.
virtual bool changeTopology() const
Check for topology change.
A class for handling words, derived from Foam::string.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
List of mesh modifiers defining the mesh dynamics.
const cellList & cells() const
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
void setMaxLayerThickness(const scalar t) const
Set max layer thickness which triggers removal.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
label timeIndex() const noexcept
Return current time index.
const wordRe & name() const noexcept
The selector name.
A subset of mesh faces organised as a primitive patch.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
edgeList edges(const faceUList &meshFaces) const
Return cell edges.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
errorManip< error > abort(error &err)
const scalarField & cellVolumes() const
Begin block [isseparator].
Virtual base class for mesh modifiers.
const word & name() const
Return name of this modifier.
const labelList & masterCells() const
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const polyMesh & mesh() const
Return the mesh reference.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const dimensionedScalar e
Elementary charge.
bool active() const noexcept
Has the zone been found.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
virtual void write(Ostream &) const
Write.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const Time & time() const
Return the top-level database.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
virtual void writeDict(Ostream &) const
Write dictionary.
defineTypeNameAndDebug(combustionModel, 0)
A cell is defined as a list of faces with extra functionality.
label index() const
The index of the first matching items, -1 if no matches.
const vectorField & faceAreas() const