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." 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 void Foam::layerAdditionRemoval::clearAddressing()
const 102 pointsPairingPtr_.reset(
nullptr);
103 facesPairingPtr_.reset(
nullptr);
109 Foam::layerAdditionRemoval::layerAdditionRemoval
114 const word& zoneName,
115 const scalar minThickness,
116 const scalar maxThickness,
117 const bool thicknessFromVolume
121 faceZoneID_(zoneName, ptc.
mesh().faceZones()),
122 minLayerThickness_(minThickness),
123 maxLayerThickness_(maxThickness),
124 thicknessFromVolume_(thicknessFromVolume),
125 oldLayerThickness_(-1.0),
126 pointsPairingPtr_(nullptr),
127 facesPairingPtr_(nullptr),
135 Foam::layerAdditionRemoval::layerAdditionRemoval
145 minLayerThickness_(
dict.
get<scalar>(
"minLayerThickness")),
146 maxLayerThickness_(
dict.
get<scalar>(
"maxLayerThickness")),
147 thicknessFromVolume_(
dict.getOrDefault(
"thicknessFromVolume", true)),
148 oldLayerThickness_(
dict.getOrDefault<scalar>(
"oldLayerThickness", -1)),
149 pointsPairingPtr_(nullptr),
150 facesPairingPtr_(nullptr),
163 if (triggerRemoval_ > -1 || triggerAddition_ > -1)
176 const polyMesh&
mesh = topoChanger().mesh();
184 if (
min(V) < -VSMALL)
187 <<
"negative cell volume. Error in mesh motion before " 188 <<
"topological change.\n V: " << V
193 scalar minDelta = GREAT;
197 if (thicknessFromVolume_)
202 scalar curDelta = V[mc[facei]]/
mag(S[fz[facei]]);
203 avgDelta += curDelta;
204 minDelta =
min(minDelta, curDelta);
205 maxDelta =
max(maxDelta, curDelta);
213 const Map<label>& zoneMeshPointMap = fz().meshPointMap();
218 const cell& cFaces =
mesh.
cells()[mc[facei]];
223 const edge&
e = cellEdges[i];
225 if (zoneMeshPointMap.found(
e[0]))
227 if (!zoneMeshPointMap.found(
e[1]))
230 avgDelta += curDelta;
232 minDelta =
min(minDelta, curDelta);
233 maxDelta =
max(maxDelta, curDelta);
238 if (zoneMeshPointMap.found(
e[1]))
241 avgDelta += curDelta;
243 minDelta =
min(minDelta, curDelta);
244 maxDelta =
max(maxDelta, curDelta);
251 reduce(minDelta, minOp<scalar>());
252 reduce(maxDelta, maxOp<scalar>());
253 reduce(avgDelta, sumOp<scalar>());
254 reduce(nDelta, sumOp<label>());
260 Pout<<
"bool layerAdditionRemoval::changeTopology() const " 261 <<
" for object " <<
name() <<
" : " <<
nl 262 <<
"Layer thickness: min: " << minDelta
263 <<
" max: " << maxDelta <<
" avg: " << avgDelta
264 <<
" old thickness: " << oldLayerThickness_ <<
nl 265 <<
"Removal threshold: " << minLayerThickness_
266 <<
" addition threshold: " << maxLayerThickness_ <<
endl;
269 bool topologicalChange =
false;
273 if (oldLayerThickness_ < 0)
277 Pout<<
"First step. No addition/removal" <<
endl;
281 oldLayerThickness_ = avgDelta;
283 topologicalChange =
false;
285 else if (avgDelta < oldLayerThickness_)
288 if (minDelta < minLayerThickness_)
291 if (setLayerPairing())
303 Pout<<
"bool layerAdditionRemoval::changeTopology() " 304 <<
" const for object " <<
name() <<
" : " 305 <<
"Triggering layer removal" <<
endl;
312 oldLayerThickness_ = GREAT;
314 topologicalChange =
true;
325 oldLayerThickness_ = avgDelta;
331 if (maxDelta > maxLayerThickness_)
335 Pout<<
"bool layerAdditionRemoval::changeTopology() const " 336 <<
" for object " <<
name() <<
" : " 337 <<
"Triggering layer addition" <<
endl;
344 oldLayerThickness_ = 0;
346 topologicalChange =
true;
350 oldLayerThickness_ = avgDelta;
354 return topologicalChange;
363 if (triggerRemoval_ == topoChanger().
mesh().time().
timeIndex())
365 removeCellLayer(
ref);
370 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) " 371 <<
"for object " <<
name() <<
" : " 372 <<
"Clearing addressing after layer removal" <<
endl;
375 triggerRemoval_ = -1;
379 if (triggerAddition_ == topoChanger().
mesh().time().
timeIndex())
386 Pout<<
"layerAdditionRemoval::setRefinement(polyTopoChange&) " 387 <<
"for object " <<
name() <<
" : " 388 <<
"Clearing addressing after layer addition" <<
endl;
391 triggerAddition_ = -1;
401 Pout<<
"layerAdditionRemoval::updateMesh(const mapPolyMesh&) " 402 <<
"for object " <<
name() <<
" : " 403 <<
"Clearing addressing on external request";
405 if (pointsPairingPtr_ || facesPairingPtr_)
416 faceZoneID_.update(topoChanger().
mesh().faceZones());
424 if (t < VSMALL || maxLayerThickness_ < t)
427 <<
"Incorrect layer thickness definition." 431 minLayerThickness_ = t;
437 if (t < minLayerThickness_)
440 <<
"Incorrect layer thickness definition." 444 maxLayerThickness_ = t;
453 << minLayerThickness_ <<
nl 454 << oldLayerThickness_ <<
nl 455 << maxLayerThickness_ <<
nl 456 << thicknessFromVolume_ <<
endl;
470 os.
writeEntry(
"thicknessFromVolume", thicknessFromVolume_);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
const wordRe & name() const noexcept
The selector name.
virtual void write(Ostream &) const
Write.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< edge > edgeList
List of edge.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool changeTopology() const
Check for topology change.
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.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
const cellList & cells() const
const Time & time() const
Return the top-level database.
Lookup type of boundary radiation properties.
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.
#define forAll(list, i)
Loop across all elements in list.
bool active() const noexcept
Has the zone been found.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
void setMinLayerThickness(const scalar t) const
Set min layer thickness which triggers removal.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
List of mesh modifiers defining the mesh dynamics.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual Ostream & endBlock()
Write end block group.
label timeIndex() const noexcept
Return the current time index.
virtual const faceList & faces() const
Return raw faces.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Virtual base class for mesh modifiers.
errorManip< error > abort(error &err)
label index() const
The index of the first matching items, -1 if no matches.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
defineTypeNameAndDebug(combustionModel, 0)
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
virtual void writeDict(Ostream &) const
Write dictionary.
const vectorField & faceAreas() const
const word & name() const
Return name of this modifier.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
const scalarField & cellVolumes() const