60 { typeOfMatch::INTEGRAL,
"integral" },
61 { typeOfMatch::PARTIAL,
"partial" },
67 void Foam::slidingInterface::checkDefinition()
73 !masterFaceZoneID_.
active()
74 || !slaveFaceZoneID_.
active()
75 || !cutPointZoneID_.
active()
76 || !cutFaceZoneID_.
active()
77 || !masterPatchID_.
active()
82 <<
"Not all zones and patches needed in the definition " 83 <<
"have been found. Please check your mesh definition." 90 mesh.faceZones()[masterFaceZoneID_.
index()].empty()
91 ||
mesh.faceZones()[slaveFaceZoneID_.
index()].empty()
95 <<
"Please check your mesh definition." 101 Pout<<
"Sliding interface object " <<
name() <<
" :" <<
nl 102 <<
" master face zone: " << masterFaceZoneID_.
index() <<
nl 103 <<
" slave face zone: " << slaveFaceZoneID_.
index() <<
endl;
108 void Foam::slidingInterface::clearOut()
const 110 clearPointProjection();
111 clearAttachedAddressing();
118 Foam::slidingInterface::slidingInterface
123 const word& masterFaceZoneName,
124 const word& slaveFaceZoneName,
125 const word& cutPointZoneName,
126 const word& cutFaceZoneName,
127 const word& masterPatchName,
128 const word& slavePatchName,
129 const typeOfMatch tom,
130 const bool coupleDecouple,
138 mme.
mesh().faceZones()
143 mme.
mesh().faceZones()
148 mme.
mesh().pointZones()
153 mme.
mesh().faceZones()
166 coupleDecouple_(coupleDecouple),
168 projectionAlgo_(algo),
170 pointMergeTol_(pointMergeTolDefault_),
171 edgeMergeTol_(edgeMergeTolDefault_),
172 nFacesPerSlaveEdge_(nFacesPerSlaveEdgeDefault_),
173 edgeFaceEscapeLimit_(edgeFaceEscapeLimitDefault_),
174 integralAdjTol_(integralAdjTolDefault_),
175 edgeMasterCatchFraction_(edgeMasterCatchFractionDefault_),
176 edgeCoPlanarTol_(edgeCoPlanarTolDefault_),
177 edgeEndCutoffTol_(edgeEndCutoffTolDefault_),
178 cutFaceMasterPtr_(nullptr),
179 cutFaceSlavePtr_(nullptr),
180 masterFaceCellsPtr_(nullptr),
181 slaveFaceCellsPtr_(nullptr),
182 masterStickOutFacesPtr_(nullptr),
183 slaveStickOutFacesPtr_(nullptr),
184 retiredPointMapPtr_(nullptr),
185 cutPointEdgePairMapPtr_(nullptr),
186 slavePointPointHitsPtr_(nullptr),
187 slavePointEdgeHitsPtr_(nullptr),
188 slavePointFaceHitsPtr_(nullptr),
189 masterPointEdgeHitsPtr_(nullptr),
190 projectedSlavePointsPtr_(nullptr)
197 <<
"Creation of a sliding interface from components " 198 <<
"in attached state not supported." 203 calcAttachedAddressing();
208 Foam::slidingInterface::slidingInterface
211 const dictionary&
dict,
213 const polyTopoChanger& mme
216 polyMeshModifier(
name, index, mme,
dict.
get<bool>(
"active")),
219 dict.
get<keyType>(
"masterFaceZoneName"),
220 mme.
mesh().faceZones()
224 dict.
get<keyType>(
"slaveFaceZoneName"),
225 mme.
mesh().faceZones()
229 dict.
get<keyType>(
"cutPointZoneName"),
230 mme.
mesh().pointZones()
234 dict.
get<keyType>(
"cutFaceZoneName"),
235 mme.
mesh().faceZones()
239 dict.
get<keyType>(
"masterPatchName"),
240 mme.
mesh().boundaryMesh()
244 dict.
get<keyType>(
"slavePatchName"),
245 mme.
mesh().boundaryMesh()
247 matchType_(typeOfMatchNames.
get(
"typeOfMatch",
dict)),
248 coupleDecouple_(
dict.
get<bool>(
"coupleDecouple")),
249 attached_(
dict.
get<bool>(
"attached")),
252 intersection::algorithmNames_.
get(
"projection",
dict)
255 cutFaceMasterPtr_(nullptr),
256 cutFaceSlavePtr_(nullptr),
257 masterFaceCellsPtr_(nullptr),
258 slaveFaceCellsPtr_(nullptr),
259 masterStickOutFacesPtr_(nullptr),
260 slaveStickOutFacesPtr_(nullptr),
261 retiredPointMapPtr_(nullptr),
262 cutPointEdgePairMapPtr_(nullptr),
263 slavePointPointHitsPtr_(nullptr),
264 slavePointEdgeHitsPtr_(nullptr),
265 slavePointFaceHitsPtr_(nullptr),
266 masterPointEdgeHitsPtr_(nullptr),
267 projectedSlavePointsPtr_(nullptr)
280 Pout<<
"slidingInterface::slidingInterface(...) " 281 <<
" for object " <<
name <<
" : " 282 <<
"Interface attached. Reading master and slave face zones " 283 <<
"and retired point lookup." <<
endl;
287 masterFaceCellsPtr_.reset(
new labelList());
288 slaveFaceCellsPtr_.reset(
new labelList());
289 masterStickOutFacesPtr_.reset(
new labelList());
290 slaveStickOutFacesPtr_.reset(
new labelList());
291 retiredPointMapPtr_.reset(
new Map<label>());
292 cutPointEdgePairMapPtr_.reset(
new Map<Pair<edge>>());
294 dict.readEntry(
"masterFaceCells", *masterFaceCellsPtr_);
295 dict.readEntry(
"slaveFaceCells", *slaveFaceCellsPtr_);
296 dict.readEntry(
"masterStickOutFaces", *masterStickOutFacesPtr_);
297 dict.readEntry(
"slaveStickOutFaces", *slaveStickOutFacesPtr_);
298 dict.readEntry(
"retiredPointMap", *retiredPointMapPtr_);
299 dict.readEntry(
"cutPointEdgePairMap", *cutPointEdgePairMapPtr_);
303 calcAttachedAddressing();
310 void Foam::slidingInterface::clearAddressing()
const 312 cutFaceMasterPtr_.reset(
nullptr);
313 cutFaceSlavePtr_.reset(
nullptr);
319 return masterFaceZoneID_;
325 return slaveFaceZoneID_;
336 Pout<<
"bool slidingInterface::changeTopology() const " 337 <<
"for object " <<
name() <<
" : " 338 <<
"Couple-decouple mode." <<
endl;
355 && !topoChanger().
mesh().changing()
365 return projectPoints();
377 decoupleInterface(
ref);
382 coupleInterface(
ref);
407 Pout<<
"void slidingInterface::modifyMotionPoints(" 408 <<
"pointField& motionPoints) const for object " <<
name() <<
" : " 409 <<
"Adjusting motion points." <<
endl;
412 const polyMesh&
mesh = topoChanger().mesh();
417 if (cutPoints.size() && !projectedSlavePointsPtr_)
423 const pointField& projectedSlavePoints = *projectedSlavePointsPtr_;
425 const Map<label>& rpm = retiredPointMap();
427 const Map<Pair<edge>>& cpepm = cutPointEdgePairMap();
429 const Map<label>& slaveZonePointMap =
434 const edgeList& masterEdges = masterPatch.edges();
435 const pointField& masterLocalPoints = masterPatch.localPoints();
439 const edgeList& slaveEdges = slavePatch.edges();
440 const pointField& slaveLocalPoints = slavePatch.localPoints();
441 const vectorField& slavePointNormals = slavePatch.pointNormals();
443 for (
const label pointi : cutPoints)
446 const auto rpmIter = rpm.cfind(pointi);
456 motionPoints[cutPoints[pointi]] =
457 projectedSlavePoints[slaveZonePointMap.find(rpmIter())()];
464 const auto cpepmIter = cpepm.cfind(pointi);
466 if (cpepmIter.good())
479 const edge& globalMasterEdge = cpepmIter().first();
481 const label curMasterEdgeIndex =
482 masterPatch.whichEdge
486 masterPatch.whichPoint
488 globalMasterEdge.start()
490 masterPatch.whichPoint
492 globalMasterEdge.end()
497 const edge& cme = masterEdges[curMasterEdgeIndex];
503 const edge& globalSlaveEdge = cpepmIter().second();
505 const label curSlaveEdgeIndex =
510 slavePatch.whichPoint
512 globalSlaveEdge.start()
514 slavePatch.whichPoint
516 globalSlaveEdge.end()
521 const edge& curSlaveEdge = slaveEdges[curSlaveEdgeIndex];
525 const point& a = projectedSlavePoints[curSlaveEdge.start()];
526 const point&
b = projectedSlavePoints[curSlaveEdge.end()];
531 slaveLocalPoints[curSlaveEdge.start()]
532 + slavePointNormals[curSlaveEdge.start()]
533 + slaveLocalPoints[curSlaveEdge.end()]
534 + slavePointNormals[curSlaveEdge.end()]
538 plane cutPlane(a,
b,
c);
541 curSlaveEdge.line(slaveLocalPoints);
542 const scalar curSlaveLineMag = curSlaveLine.mag();
545 cutPlane.lineIntersect
547 cme.line(masterLocalPoints)
552 cutOnMaster > edgeEndCutoffTol_
553 && cutOnMaster < 1.0 - edgeEndCutoffTol_
557 point masterCutPoint =
558 masterLocalPoints[cme.start()]
559 + cutOnMaster*cme.vec(masterLocalPoints);
562 curSlaveLine.nearestDist(masterCutPoint);
572 - curSlaveLine.start()
573 ) & curSlaveLine.vec()
574 )/
sqr(curSlaveLineMag);
579 edgeCoPlanarTol_*
mag(
b - a);
583 cutOnSlave > edgeEndCutoffTol_
584 && cutOnSlave < 1.0 - edgeEndCutoffTol_
585 && slaveCut.distance() < mergeTol
589 motionPoints[pointi] = masterCutPoint;
594 Pout<<
"Missed slave edge!!! This is an error. " 596 << cme.line(masterLocalPoints)
597 <<
" slave edge: " << curSlaveLine
598 <<
" point: " << masterCutPoint
603 - curSlaveLine.start()
604 ) & curSlaveLine.vec()
605 )/
sqr(curSlaveLineMag)
611 Pout<<
"Missed master edge!!! This is an error" 618 <<
"Cut point " << cutPoints[pointi]
619 <<
" not recognised as either the projected " 620 <<
"or as intersection point. Error in point " 621 <<
"projection or data mapping" 638 Pout<<
"void slidingInterface::updateMesh(const mapPolyMesh& m)" 639 <<
" const for object " <<
name() <<
" : " 640 <<
"Updating topology." <<
endl;
644 const polyMesh&
mesh = topoChanger().mesh();
668 if (!projectedSlavePointsPtr_)
673 return *projectedSlavePointsPtr_;
691 "nFacesPerSlaveEdge",
696 "edgeFaceEscapeLimit",
706 "edgeMasterCatchFraction",
707 edgeMasterCatchFraction_
722 Info<<
"Sliding interface parameters:" <<
nl 723 <<
"pointMergeTol : " << pointMergeTol_ <<
nl 724 <<
"edgeMergeTol : " << edgeMergeTol_ <<
nl 725 <<
"nFacesPerSlaveEdge : " << nFacesPerSlaveEdge_ <<
nl 726 <<
"edgeFaceEscapeLimit : " << edgeFaceEscapeLimit_ <<
nl 727 <<
"integralAdjTol : " << integralAdjTol_ <<
nl 728 <<
"edgeMasterCatchFraction : " << edgeMasterCatchFraction_ <<
nl 729 <<
"edgeCoPlanarTol : " << edgeCoPlanarTol_ <<
nl 730 <<
"edgeEndCutoffTol : " << edgeEndCutoffTol_ <<
endl;
739 << masterFaceZoneID_.name() <<
nl 740 << slaveFaceZoneID_.name() <<
nl 741 << cutPointZoneID_.name() <<
nl 742 << cutFaceZoneID_.name() <<
nl 743 << masterPatchID_.name() <<
nl 744 << slavePatchID_.name() <<
nl 745 << typeOfMatchNames[matchType_] <<
nl 746 << coupleDecouple_ <<
nl 747 << attached_ <<
endl;
752 #define WRITE_NON_DEFAULT(name) \ 753 if ( name ## _ != name ## Default_ )\ 755 os << " " #name " " << name ## _ << token::END_STATEMENT << nl; \ 766 os.
writeEntry(
"masterFaceZoneName", masterFaceZoneID_.name());
767 os.
writeEntry(
"slaveFaceZoneName", slaveFaceZoneID_.name());
768 os.
writeEntry(
"cutPointZoneName", cutPointZoneID_.name());
769 os.
writeEntry(
"cutFaceZoneName", cutFaceZoneID_.name());
770 os.
writeEntry(
"masterPatchName", masterPatchID_.name());
772 os.
writeEntry(
"typeOfMatch", typeOfMatchNames[matchType_]);
782 masterStickOutFacesPtr_->
writeEntry(
"masterStickOutFaces",
os);
783 slaveStickOutFacesPtr_->
writeEntry(
"slaveStickOutFaces",
os);
786 os.
writeEntry(
"cutPointEdgePairMap", cutPointEdgePairMap());
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
static const Enum< algorithm > algorithmNames_
Projection algorithm names.
const faceZoneID & slaveFaceZoneID() const
Return slave face zone ID.
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...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
List< edge > edgeList
List of edge.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface...
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
virtual void write(Ostream &) const
Write.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
Macros for easy insertion into run-time selection tables.
const pointField & pointProjection() const
Return projected points for a slave patch.
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.
vectorField pointField
pointField is a vectorField.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
line< point, const point & > linePointRef
A line using referred points.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
List of mesh modifiers defining the mesh dynamics.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
#define WRITE_NON_DEFAULT(name)
virtual Ostream & endBlock()
Write end block group.
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...
virtual bool update()=0
Update the mesh for both mesh motion and topology change.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
defineTypeNameAndDebug(combustionModel, 0)
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
typeOfMatch
Type of match.
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
vector point
Point is a vector.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
const dimensionedScalar c
Speed of light in a vacuum.
const word & name() const
Return name of this modifier.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Field< vector > vectorField
Specialisation of Field<T> for vector.
const faceZoneID & masterFaceZoneID() const
Return master face zone ID.
void setTolerances(const dictionary &, bool report=false)
Set the tolerances from the values in a dictionary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
const polyMesh & mesh() const
Return the mesh reference.
static const Enum< typeOfMatch > typeOfMatchNames
Names for the types of matches.
virtual void writeDict(Ostream &) const
Write dictionary.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
virtual bool changeTopology() const
Check for topology change.
PointHit< point > pointHit
A PointHit with a 3D point.