45 void Foam::MRFZone::setMRFFaces()
47 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
60 const labelList& nei = mesh_.faceNeighbour();
63 boolList zoneCell(mesh_.nCells(),
false);
65 if (cellZoneID_ != -1)
67 const labelList& cellLabels = mesh_.cellZones()[cellZoneID_];
70 zoneCell[cellLabels[i]] =
true;
77 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
79 if (zoneCell[own[facei]] || zoneCell[nei[facei]])
91 const polyPatch& pp = patches[
patchi];
93 if (pp.coupled() || excludedPatches.found(patchi))
97 const label facei = pp.start() + i;
99 if (zoneCell[own[facei]])
106 else if (!isA<emptyPolyPatch>(pp))
110 const label facei = pp.start() + i;
112 if (zoneCell[own[facei]])
131 internalFaces_.setSize(mesh_.nFaces());
134 for (
label facei = 0; facei < mesh_.nInternalFaces(); facei++)
136 if (faceType[facei] == 1)
138 internalFaces_[nInternal++] = facei;
141 internalFaces_.setSize(nInternal);
143 labelList nIncludedFaces(patches.size(), 0);
144 labelList nExcludedFaces(patches.size(), 0);
148 const polyPatch& pp = patches[
patchi];
152 const label facei = pp.start() + patchFacei;
154 if (faceType[facei] == 1)
158 else if (faceType[facei] == 2)
165 includedFaces_.setSize(patches.size());
166 excludedFaces_.setSize(patches.size());
167 forAll(nIncludedFaces, patchi)
169 includedFaces_[
patchi].setSize(nIncludedFaces[patchi]);
170 excludedFaces_[
patchi].setSize(nExcludedFaces[patchi]);
177 const polyPatch& pp = patches[
patchi];
181 const label facei = pp.start() + patchFacei;
183 if (faceType[facei] == 1)
185 includedFaces_[
patchi][nIncludedFaces[
patchi]++] = patchFacei;
187 else if (faceType[facei] == 2)
189 excludedFaces_[
patchi][nExcludedFaces[
patchi]++] = patchFacei;
197 faceSet internalFaces(mesh_,
"internalFaces", internalFaces_);
199 Pout<<
"Writing " << internalFaces.size()
200 <<
" internal faces in MRF zone to faceSet " 203 internalFaces.
write();
205 faceSet MRFFaces(mesh_,
"includedFaces", 100);
207 forAll(includedFaces_, patchi)
209 forAll(includedFaces_[patchi], i)
211 const label patchFacei = includedFaces_[
patchi][i];
212 MRFFaces.insert(patches[patchi].start()+patchFacei);
216 Pout<<
"Writing " << MRFFaces.size()
217 <<
" patch faces in MRF zone to faceSet " 222 faceSet excludedFaces(mesh_,
"excludedFaces", 100);
223 forAll(excludedFaces_, patchi)
225 forAll(excludedFaces_[patchi], i)
227 const label patchFacei = excludedFaces_[
patchi][i];
228 excludedFaces.insert(patches[patchi].start()+patchFacei);
232 Pout<<
"Writing " << excludedFaces.size()
233 <<
" faces in MRF zone with special handling to faceSet " 236 excludedFaces.
write();
248 const word& cellZoneName
254 cellZoneName_(cellZoneName),
260 origin_(coeffs_.lookup(
"origin")),
261 axis_(coeffs_.lookup(
"axis")),
266 coeffs_.lookup(
"cellZone") >> cellZoneName_;
269 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
271 axis_ = axis_/
mag(axis_);
275 mesh_.boundaryMesh().patchSet(excludedPatchNames_)
278 excludedPatchLabels_.setSize(excludedPatchSet.size());
283 excludedPatchLabels_[i++] = iter.key();
286 bool cellZoneFound = (cellZoneID_ != -1);
293 <<
"cannot find MRF cellZone " << cellZoneName_
305 return omega_->value(mesh_.time().userTimeValue())*axis_;
315 if (cellZoneID_ == -1)
324 const vector Omega = this->Omega();
328 const label celli = cells[i];
329 ddtUc[celli] += (Omega ^ Uc[celli]);
336 if (cellZoneID_ == -1)
346 const vector Omega = this->Omega();
352 const label celli = cells[i];
353 Usource[celli] += V[celli]*(Omega ^ U[celli]);
360 const label celli = cells[i];
361 Usource[celli] -= V[celli]*(Omega ^ U[celli]);
374 if (cellZoneID_ == -1)
384 const vector Omega = this->Omega();
390 const label celli = cells[i];
391 Usource[celli] += V[celli]*rho[celli]*(Omega ^ U[celli]);
398 const label celli = cells[i];
399 Usource[celli] -= V[celli]*rho[celli]*(Omega ^ U[celli]);
410 if (cellZoneID_ == -1)
419 const vector Omega = this->Omega();
423 const label celli = cells[i];
424 cac[celli] -= Omega ^ (Omega ^ (C[celli] - origin_));
431 forAll(includedFaces_, patchi)
433 forAll(includedFaces_[patchi], i)
435 const label patchFacei = includedFaces_[
patchi][i];
436 caf[
patchi][patchFacei] -=
446 if (cellZoneID_ == -1)
454 const vector Omega = this->Omega();
458 const label celli = cells[i];
459 U[celli] -= (Omega ^ (C[celli] - origin_));
466 forAll(includedFaces_, patchi)
468 forAll(includedFaces_[patchi], i)
470 const label patchFacei = includedFaces_[
patchi][i];
476 forAll(excludedFaces_, patchi)
478 forAll(excludedFaces_[patchi], i)
480 const label patchFacei = excludedFaces_[
patchi][i];
481 Ubf[
patchi][patchFacei] -=
503 makeRelativeRhoFlux(
oneField(), phi, patchi);
513 makeRelativeRhoFlux(rho, phi);
519 if (cellZoneID_ == -1)
527 const vector Omega = this->Omega();
531 const label celli = cells[i];
532 U[celli] += (Omega ^ (C[celli] - origin_));
538 forAll(includedFaces_, patchi)
540 forAll(includedFaces_[patchi], i)
542 const label patchFacei = includedFaces_[
patchi][i];
549 forAll(excludedFaces_, patchi)
551 forAll(excludedFaces_[patchi], i)
553 const label patchFacei = excludedFaces_[
patchi][i];
554 Ubf[
patchi][patchFacei] +=
573 makeAbsoluteRhoFlux(rho, phi);
579 const vector Omega = this->Omega();
584 forAll(includedFaces_, patchi)
590 forAll(includedFaces_[patchi], i)
592 const label patchFacei = includedFaces_[
patchi][i];
594 pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_));
612 if (excludedPatchNames_.size())
614 writeEntry(os,
"nonRotatingPatches", excludedPatchNames_);
625 coeffs_.
lookup(
"cellZone") >> cellZoneName_;
626 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
634 if (mesh_.topoChanged())
bool read(const dictionary &dict)
Read MRF dictionary.
void addCoriolis(const volVectorField &U, volVectorField &ddtU) const
Add the Coriolis force contribution to the acceleration field.
virtual const fileName & name() const
Return the name of the stream.
Run-time selectable general function of one variable.
void makeRelative(volVectorField &U) const
Make the given absolute velocity relative within the MRF region.
Graphite solid properties.
#define forAll(list, i)
Loop across all elements in list.
virtual Ostream & write(const char)=0
Write character.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
MRFZone(const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName=word::null)
Construct from fvMesh.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
const GeometricField< Type, fvPatchField, volMesh > & psi() const
void makeAbsolute(volVectorField &U) const
Make the given relative velocity absolute within the MRF region.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void addCentrifugalAcceleration(volVectorField ¢rifugalAcceleration) const
Add the centrifugal acceleration.
void update()
Update MRFZone faces if the mesh topology changes.
A class representing the concept of a field of oneFields used to avoid unnecessary manipulations for ...
List< bool > boolList
Bool container classes.
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys.
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
A class for handling words, derived from string.
static const word null
An empty word.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
List< label > labelList
A List of labels.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Internal::FieldType & primitiveFieldRef()
Return a reference to the internal field.
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void correctBoundaryVelocity(volVectorField &U) const
Correct the boundary velocity for the rotation of the MRF region.
vector Omega() const
Return the current Omega vector.
A class representing the concept of a field of 1 used to avoid unnecessary manipulations for objects ...
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
prefixOSstream Pout(cout, "Pout")
Mesh data needed to do the Finite Volume discretisation.
A special matrix type and solver, designed for finite volume solutions of scalar equations.
dimensioned< scalar > mag(const dimensioned< Type > &)
List< wordRe > wordReList
A List of wordRe (word or regular expression)
void writeData(Ostream &os) const
Write.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.