53void Foam::attachDetach::checkDefinition()
58 || !masterPatchID_.
active()
63 <<
"Not all zones and patches needed in the definition "
64 <<
"have been found. Please check your mesh definition."
73 Pout<<
"Attach/detach object " <<
name() <<
" :" <<
nl
74 <<
" faceZoneID: " << faceZoneID_ <<
nl
75 <<
" masterPatchID: " << masterPatchID_ <<
nl
76 <<
" slavePatchID: " << slavePatchID_ <<
endl;
80 const auto& mPatch = bm[masterPatchID_.index()];
81 const label nMasterFaces =
returnReduce(mPatch.size(), sumOp<label>());
82 const auto& sPatch = bm[slavePatchID_.index()];
83 const label nSlaveFaces =
returnReduce(sPatch.size(), sumOp<label>());
84 const auto& fZone =
mesh.faceZones()[faceZoneID_.index()];
85 const label nZoneFaces =
returnReduce(fZone.size(), sumOp<label>());
87 if (nMasterFaces == 0 && nSlaveFaces == 0)
92 Pout<<
" Attached on construction" <<
endl;
101 <<
"Face zone " << fZone.name()
110 DynamicList<label> bouFacesInZone(addr.size());
114 if (!
mesh.isInternalFace(addr[facei]))
116 bouFacesInZone.append(addr[facei]);
120 if (
returnReduce(bouFacesInZone.size(), sumOp<label>()))
123 <<
"Found boundary faces in the zone defining "
124 <<
"attach/detach boundary "
125 <<
" for object " <<
name()
126 <<
" : . This is not allowed." <<
nl
127 <<
"Boundary faces: " << bouFacesInZone
137 Pout<<
" Detached on construction" <<
endl;
144 if ((nMasterFaces != nSlaveFaces) || (nMasterFaces != nZoneFaces))
147 <<
"Problem with sizes in mesh modifier. The face zone,"
148 <<
" master and slave patch should have the same size"
149 <<
" for object " <<
name() <<
". " <<
nl
150 <<
"Zone size: " << nZoneFaces
151 <<
" Master patch size: " << nMasterFaces
152 <<
" Slave patch size: " << nSlaveFaces
161 DynamicList<label> zoneProblemFaces(addr.size());
165 label facePatch = bm.whichPatch(addr[facei]);
169 facePatch != masterPatchID_.index()
170 && facePatch != slavePatchID_.index()
173 zoneProblemFaces.append(addr[facei]);
177 if (
returnReduce(zoneProblemFaces.size(), sumOp<label>()))
180 <<
"Found faces in the zone defining "
181 <<
"attach/detach boundary which do not belong to "
182 <<
"either master or slave patch. "
183 <<
"This is not allowed." <<
nl
184 <<
"Problem faces: " << zoneProblemFaces
191 bool triggersOK =
true;
193 for (label i = 0; i < triggerTimes_.size() - 1; i++)
195 triggersOK = triggersOK && (triggerTimes_[i] < triggerTimes_[i + 1]);
201 || (triggerTimes_.empty() && !manualTrigger_)
205 <<
"Problem with definition of trigger times: "
212void Foam::attachDetach::clearAddressing()
const
214 pointMatchMapPtr_.reset(
nullptr);
220Foam::attachDetach::attachDetach
225 const word& faceZoneName,
226 const word& masterPatchName,
227 const word& slavePatchName,
229 const bool manualTrigger
233 faceZoneID_(faceZoneName, mme.
mesh().faceZones()),
236 triggerTimes_(triggerTimes),
239 manualTrigger_(manualTrigger),
241 pointMatchMapPtr_(nullptr)
247Foam::attachDetach::attachDetach
259 mme.
mesh().faceZones()
274 manualTrigger_(
dict.get<bool>(
"manualTrigger")),
276 pointMatchMapPtr_(nullptr)
306 Pout<<
"bool attachDetach::changeTopology() const "
307 <<
" for object " <<
name() <<
" : "
308 <<
"Manual trigger" <<
endl;
320 Pout<<
"bool attachDetach::changeTopology() const "
321 <<
" for object " <<
name() <<
" : "
322 <<
"Already triggered for current time step" <<
endl;
330 if (triggerIndex_ >= triggerTimes_.size())
334 Pout<<
"bool attachDetach::changeTopology() const "
335 <<
" for object " <<
name() <<
" : "
336 <<
"Reached end of trigger list" <<
endl;
343 Pout<<
"bool attachDetach::changeTopology() const "
344 <<
" for object " <<
name() <<
" : "
345 <<
"Triggering attach/detach topology change." <<
nl
346 <<
"Current time: " << topoChanger().mesh().time().value()
347 <<
" current trigger time: " << triggerTimes_[triggerIndex_]
348 <<
" trigger index: " << triggerIndex_ <<
endl;
353 if (topoChanger().
mesh().time().value() >= triggerTimes_[triggerIndex_])
377 if (state_ == ATTACHED)
379 detachInterface(
ref);
384 else if (state_ == DETACHED)
386 attachInterface(
ref);
394 <<
"Requested attach/detach event. Current state is unknown."
409 masterPatchID_.update(
mesh.boundaryMesh());
410 slavePatchID_.update(
mesh.boundaryMesh());
420 << faceZoneID_.name() <<
nl
421 << masterPatchID_.name() <<
nl
422 << slavePatchID_.name() <<
nl
423 << triggerTimes_ <<
endl;
432 os.writeEntry(
"type",
type());
433 os.writeEntry(
"faceZoneName", faceZoneID_.name());
434 os.writeEntry(
"masterPatchName", masterPatchID_.name());
435 os.writeEntry(
"slavePatchName", slavePatchID_.name());
436 os.writeEntry(
"triggerTimes", triggerTimes_);
438 os.writeEntry(
"active", active());
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
bool active() const noexcept
Has the zone been found.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static const char * name(bool b) noexcept
A string representation of bool as "false" / "true".
Attach/detach boundary mesh modifier. This modifier takes a set of internal faces and converts them i...
virtual void write(Ostream &) const
Write.
const scalarField & triggerTimes() const
Get reference to trigger times.
bool attached() const
Is the interface attached?
virtual bool changeTopology() const
Check for topology change.
virtual void writeDict(Ostream &) const
Write dictionary.
bool manualTrigger() const
Is manually triggered?
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.
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.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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.
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.
Lookup type of boundary radiation properties.
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)
Namespace for handling debugging switches.
List< label > labelList
A List of labels.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
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.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.