48 void Foam::MRFZone::setMRFFaces()
68 if (cellZoneID_ != -1)
73 zoneCell[cellLabels[i]] =
true;
82 if (zoneCell[own[facei]] || zoneCell[nei[facei]])
94 const polyPatch& pp =
patches[patchi];
96 if (pp.coupled() || excludedPatches.found(patchi))
100 label facei = pp.start()+i;
102 if (zoneCell[own[facei]])
109 else if (!isA<emptyPolyPatch>(pp))
113 label facei = pp.start()+i;
115 if (zoneCell[own[facei]])
139 if (faceType[facei] == 1)
141 internalFaces_[nInternal++] = facei;
144 internalFaces_.
setSize(nInternal);
151 const polyPatch& pp =
patches[patchi];
155 label facei = pp.start() + patchFacei;
157 if (faceType[facei] == 1)
159 nIncludedFaces[patchi]++;
161 else if (faceType[facei] == 2)
163 nExcludedFaces[patchi]++;
170 forAll(nIncludedFaces, patchi)
172 includedFaces_[patchi].
setSize(nIncludedFaces[patchi]);
173 excludedFaces_[patchi].
setSize(nExcludedFaces[patchi]);
180 const polyPatch& pp =
patches[patchi];
184 label facei = pp.start() + patchFacei;
186 if (faceType[facei] == 1)
188 includedFaces_[patchi][nIncludedFaces[patchi]++] = patchFacei;
190 else if (faceType[facei] == 2)
192 excludedFaces_[patchi][nExcludedFaces[patchi]++] = patchFacei;
200 faceSet internalFaces(mesh_,
"internalFaces", internalFaces_);
201 Pout<<
"Writing " << internalFaces.size()
202 <<
" internal faces in MRF zone to faceSet "
204 internalFaces.
write();
206 faceSet MRFFaces(mesh_,
"includedFaces", 100);
207 forAll(includedFaces_, patchi)
209 forAll(includedFaces_[patchi], i)
211 label patchFacei = includedFaces_[patchi][i];
212 MRFFaces.insert(
patches[patchi].start()+patchFacei);
215 Pout<<
"Writing " << MRFFaces.size()
216 <<
" patch faces in MRF zone to faceSet "
220 faceSet excludedFaces(mesh_,
"excludedFaces", 100);
221 forAll(excludedFaces_, patchi)
223 forAll(excludedFaces_[patchi], i)
225 label patchFacei = excludedFaces_[patchi][i];
226 excludedFaces.insert(
patches[patchi].start()+patchFacei);
229 Pout<<
"Writing " << excludedFaces.size()
230 <<
" faces in MRF zone with special handling to faceSet "
232 excludedFaces.
write();
239 Foam::MRFZone::MRFZone
243 const dictionary&
dict,
244 const word& cellZoneName
251 cellZoneName_(cellZoneName),
253 excludedPatchNames_(wordRes()),
266 return omega_->value(mesh_.time().timeOutputValue())*axis_;
276 if (cellZoneID_ == -1)
285 const vector Omega = this->Omega();
289 label celli =
cells[i];
290 ddtUc[celli] += (Omega ^ Uc[celli]);
297 if (cellZoneID_ == -1)
307 const vector Omega = this->Omega();
313 label celli =
cells[i];
314 Usource[celli] += V[celli]*(Omega ^
U[celli]);
321 label celli =
cells[i];
322 Usource[celli] -= V[celli]*(Omega ^
U[celli]);
335 if (cellZoneID_ == -1)
345 const vector Omega = this->Omega();
351 label celli =
cells[i];
352 Usource[celli] += V[celli]*
rho[celli]*(Omega ^
U[celli]);
360 Usource[celli] -= V[celli]*
rho[celli]*(Omega ^
U[celli]);
368 if (cellZoneID_ == -1)
375 const vector Omega = this->Omega();
381 label celli =
cells[i];
382 U[celli] -= (Omega ^ (
C[celli] - origin_));
387 volVectorField::Boundary& Ubf =
U.boundaryFieldRef();
389 forAll(includedFaces_, patchi)
391 forAll(includedFaces_[patchi], i)
393 label patchFacei = includedFaces_[patchi][i];
394 Ubf[patchi][patchFacei] =
Zero;
399 forAll(excludedFaces_, patchi)
401 forAll(excludedFaces_[patchi], i)
403 label patchFacei = excludedFaces_[patchi][i];
404 Ubf[patchi][patchFacei] -=
406 ^ (
C.boundaryField()[patchi][patchFacei] - origin_));
436 makeRelativeRhoFlux(
rho,
phi);
442 if (cellZoneID_ == -1)
449 const vector Omega = this->Omega();
455 label celli =
cells[i];
456 U[celli] += (Omega ^ (
C[celli] - origin_));
460 volVectorField::Boundary& Ubf =
U.boundaryFieldRef();
462 forAll(includedFaces_, patchi)
464 forAll(includedFaces_[patchi], i)
466 label patchFacei = includedFaces_[patchi][i];
467 Ubf[patchi][patchFacei] =
473 forAll(excludedFaces_, patchi)
475 forAll(excludedFaces_[patchi], i)
477 label patchFacei = excludedFaces_[patchi][i];
478 Ubf[patchi][patchFacei] +=
479 (Omega ^ (
C.boundaryField()[patchi][patchFacei] - origin_));
497 makeAbsoluteRhoFlux(
rho,
phi);
508 const vector Omega = this->Omega();
511 volVectorField::Boundary& Ubf =
U.boundaryFieldRef();
513 forAll(includedFaces_, patchi)
515 const vectorField& patchC = mesh_.Cf().boundaryField()[patchi];
519 forAll(includedFaces_[patchi], i)
521 label patchFacei = includedFaces_[patchi][i];
523 pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_));
540 omega_->writeData(
os);
542 if (excludedPatchNames_.size())
563 coeffs_.readIfPresent(
"nonRotatingPatches", excludedPatchNames_);
565 origin_ = coeffs_.get<
vector>(
"origin");
566 axis_ = coeffs_.get<
vector>(
"axis").normalise();
567 omega_.reset(Function1<scalar>::New(
"omega", coeffs_, &mesh_));
569 const word oldCellZoneName = cellZoneName_;
572 coeffs_.readEntry(
"cellZone", cellZoneName_);
576 coeffs_.readIfPresent(
"cellZone", cellZoneName_);
579 if (cellZoneID_ == -1 || oldCellZoneName != cellZoneName_)
581 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
585 mesh_.boundaryMesh().patchSet(excludedPatchNames_)
588 excludedPatchLabels_.setSize(excludedPatchSet.size());
591 for (
const label patchi : excludedPatchSet)
593 excludedPatchLabels_[i++] = patchi;
596 bool cellZoneFound = (cellZoneID_ != -1);
598 reduce(cellZoneFound, orOp<bool>());
603 <<
"cannot find MRF cellZone " << cellZoneName_
616 if (mesh_.topoChanging())