53 void 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." 69 const auto& bm =
mesh.boundaryMesh();
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: " 212 void Foam::attachDetach::clearAddressing()
const 214 pointMatchMapPtr_.reset(
nullptr);
220 Foam::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)
247 Foam::attachDetach::attachDetach
259 mme.
mesh().faceZones()
274 manualTrigger_(
dict.
get<bool>(
"manualTrigger")),
276 pointMatchMapPtr_(nullptr)
286 trigger_ = (!attached());
294 trigger_ = (attached());
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." 406 const polyMesh&
mesh = topoChanger().mesh();
420 << faceZoneID_.name() <<
nl 421 << masterPatchID_.name() <<
nl 422 << slavePatchID_.name() <<
nl 423 << triggerTimes_ <<
endl;
434 os.
writeEntry(
"masterPatchName", masterPatchID_.name());
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
virtual void write(Ostream &) const
Write.
virtual void setRefinement(polyTopoChange &) const
Insert the layer addition/removal instructions.
void size(const label n)
Older name for setAddressableSize.
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.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
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.
Lookup type of boundary radiation properties.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Macros for easy insertion into run-time selection tables.
#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.
static const char * name(const bool b) noexcept
A string representation of bool as "false" / "true".
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.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
virtual void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
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)
virtual void writeDict(Ostream &) const
Write dictionary.
virtual bool changeTopology() const
Check for topology change.
const polyTopoChanger & topoChanger() const
Return reference to morph engine.
const word & name() const
Return name of this modifier.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
List< label > labelList
A List of labels.
const polyMesh & mesh() const
Return the mesh reference.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)