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
119 faceZoneID_(zoneName, ptc.
mesh().faceZones()),
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")),
145 thicknessFromVolume_(
dict.getOrDefault(
"thicknessFromVolume", true)),
146 oldLayerThickness_(
dict.getOrDefault<scalar>(
"oldLayerThickness", -1)),
147 pointsPairingPtr_(nullptr),
148 facesPairingPtr_(nullptr),
161 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
174 const polyMesh&
mesh = topoChanger().mesh();
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();
216 const cell& cFaces =
mesh.
cells()[mc[facei]];
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);
249 reduce(minDelta, minOp<scalar>());
250 reduce(maxDelta, maxOp<scalar>());
251 reduce(avgDelta, sumOp<scalar>());
252 reduce(nDelta, sumOp<label>());
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()
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
List< label > labelList
A List of labels.
virtual const pointField & points() const
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual bool changeTopology() const
List< edge > edgeList
A List of edges.
A class for handling words, derived from Foam::string.
virtual void updateMesh(const mapPolyMesh &)
const polyTopoChanger & topoChanger() const
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
Ostream & endl(Ostream &os)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
label min(const labelHashSet &set, label minValue=labelMax)
Mesh consisting of general polyhedral cells.
Field< vector > vectorField
Specialisation of Field<T> for vector.
void setMaxLayerThickness(const scalar t) const
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
label timeIndex() const noexcept
Generic templated field type.
const wordRe & name() const noexcept
A subset of mesh faces organised as a primitive patch.
void setMinLayerThickness(const scalar t) const
edgeList edges(const faceUList &meshFaces) const
const faceZoneMesh & faceZones() const noexcept
@ END_STATEMENT
End entry [isseparator].
label max(const labelHashSet &set, label maxValue=labelMin)
Lookup type of boundary radiation properties.
@ END_BLOCK
End block [isseparator].
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
Begin block [isseparator].
Virtual base class for mesh modifiers.
const word & name() const
const labelList & masterCells() const
virtual const faceList & faces() const
#define FatalErrorInFunction
const polyMesh & mesh() const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fileName::Type type(const fileName &name, const bool followLink=true)
const dimensionedScalar e
bool active() const noexcept
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
virtual void write(Ostream &) const
word name(const expressions::valueTypeCode typeCode)
const Time & time() const
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
defineTypeNameAndDebug(combustionModel, 0)
A cell is defined as a list of faces with extra functionality.
const vectorField & faceAreas() const