60 { typeOfMatch::INTEGRAL,
"integral" },
61 { typeOfMatch::PARTIAL,
"partial" },
67void Foam::slidingInterface::checkDefinition()
73 !masterFaceZoneID_.active()
74 || !slaveFaceZoneID_.active()
75 || !cutPointZoneID_.active()
76 || !cutFaceZoneID_.active()
77 || !masterPatchID_.active()
78 || !slavePatchID_.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;
108void Foam::slidingInterface::clearOut()
const
110 clearPointProjection();
111 clearAttachedAddressing();
118Foam::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();
208Foam::slidingInterface::slidingInterface
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();
310void 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;
417 if (cutPoints.size() && !projectedSlavePointsPtr_)
423 const pointField& projectedSlavePoints = *projectedSlavePointsPtr_;
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()]
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;
668 if (!projectedSlavePointsPtr_)
673 return *projectedSlavePointsPtr_;
679 pointMergeTol_ =
dict.getOrDefault<scalar>
684 edgeMergeTol_ =
dict.getOrDefault<scalar>
689 nFacesPerSlaveEdge_ =
dict.getOrDefault<label>
691 "nFacesPerSlaveEdge",
694 edgeFaceEscapeLimit_ =
dict.getOrDefault<label>
696 "edgeFaceEscapeLimit",
699 integralAdjTol_ =
dict.getOrDefault<scalar>
704 edgeMasterCatchFraction_ =
dict.getOrDefault<scalar>
706 "edgeMasterCatchFraction",
707 edgeMasterCatchFraction_
709 edgeCoPlanarTol_ =
dict.getOrDefault<scalar>
714 edgeEndCutoffTol_ =
dict.getOrDefault<scalar>
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#undef WRITE_NON_DEFAULT
753#define WRITE_NON_DEFAULT(name) \
754 if ( name ## _ != name ## Default_ ) os.writeEntry( #name , name ## _ );
763 os.writeEntry(
"type",
type());
764 os.writeEntry(
"masterFaceZoneName", masterFaceZoneID_.name());
765 os.writeEntry(
"slaveFaceZoneName", slaveFaceZoneID_.name());
766 os.writeEntry(
"cutPointZoneName", cutPointZoneID_.name());
767 os.writeEntry(
"cutFaceZoneName", cutFaceZoneID_.name());
768 os.writeEntry(
"masterPatchName", masterPatchID_.name());
769 os.writeEntry(
"slavePatchName", slavePatchID_.name());
771 os.writeEntry(
"coupleDecouple", coupleDecouple_);
773 os.writeEntry(
"attached", attached_);
778 masterFaceCellsPtr_->writeEntry(
"masterFaceCells",
os);
779 slaveFaceCellsPtr_->writeEntry(
"slaveFaceCells",
os);
780 masterStickOutFacesPtr_->writeEntry(
"masterStickOutFaces",
os);
781 slaveStickOutFacesPtr_->writeEntry(
"slaveStickOutFaces",
os);
783 os.writeEntry(
"retiredPointMap", retiredPointMap());
784 os.writeEntry(
"cutPointEdgePairMap", cutPointEdgePairMap());
796 #undef WRITE_NON_DEFAULT
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
const_iterator cfind(const Key &key) const
Find and return an const_iterator set at the hashed entry.
iterator find(const Key &key)
Find and return an iterator set at the hashed entry.
A HashTable to objects of type <T> with a label key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
An ordered pair of two objects of type <T> with first() and second() elements.
const T & first() const noexcept
Access the first element.
const T & second() const noexcept
Access the second element.
scalar distance() const noexcept
Return distance to hit.
bool hit() const noexcept
Is there a hit.
const point_type & point() const noexcept
Return the point, no checks.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const Field< point_type > & pointNormals() const
Return point normals for patch.
label whichPoint(const label gp) const
Given a global point index, return the local point index.
label whichEdge(const edge &e) const
Identical to findEdge.
void size(const label n)
Older name for setAddressableSize.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool update()=0
Update the mesh for both mesh motion and topology change.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
label & end() noexcept
The end (second/last) vertex label.
vector vec(const UList< point > &pts) const
Return the vector (from first to second).
linePointRef line(const UList< point > &pts) const
Return edge line.
label start() const noexcept
The start (first) vertex label.
static const Enum< algorithm > algorithmNames_
Projection algorithm names.
A class for handling keywords in dictionaries.
PointHit< Point > nearestDist(const Point &p) const
Return nearest distance to line from a given point.
scalar mag() const
The magnitude (length) of the line.
PointRef start() const noexcept
The start (first) point.
Point vec() const
Return start-to-end vector.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
scalar lineIntersect(const line< PointType, PointRef > &l) const
Return the cutting point between the plane and a line passing through the supplied points.
Virtual base class for mesh modifiers.
label index() const
Return the index of this modifier.
const word & name() const
Return name of this modifier.
Switch active() const
If modifier activate?
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
Mesh consisting of general polyhedral cells.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
const pointZoneMesh & pointZones() const noexcept
Return point zone mesh.
Direct mesh changes based on v1.3 polyTopoChange syntax.
List of mesh modifiers defining the mesh dynamics.
const polyMesh & mesh() const
Return the mesh reference.
Sliding interface mesh modifier. Given two face zones, couple the master and slave side using a cutti...
const faceZoneID & masterFaceZoneID() const
Return master face zone ID.
virtual void write(Ostream &) const
Write.
void setTolerances(const dictionary &, bool report=false)
Set the tolerances from the values in a dictionary.
const pointField & pointProjection() const
Return projected points for a slave patch.
static const Enum< typeOfMatch > typeOfMatchNames
Names for the types of matches.
typeOfMatch
Type of match.
virtual bool changeTopology() const
Check for topology change.
virtual void writeDict(Ostream &) const
Write dictionary.
const faceZoneID & slaveFaceZoneID() const
Return slave face zone ID.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
virtual void modifyMotionPoints(pointField &motionPoints) const
Modify motion points to comply with the topological change.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
PointHit< point > pointHit
A PointHit with a 3D point.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
messageStream Info
Information stream (stdout output on master, null elsewhere).
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
PrimitivePatch< List< face >, const pointField & > primitiveFacePatch
A PrimitivePatch with List storage for the faces, const reference for the point field.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
line< point, const point & > linePointRef
A line using referred points.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
DynamicID< faceZoneMesh > faceZoneID
Foam::faceZoneID.
constexpr char nl
The newline '\n' character (0x0a).
#define WRITE_NON_DEFAULT(name)