36 #include "volFields.H"
37 #include "surfaceFields.H"
38 #include "fvMatrices.H"
40 #include "geometricOneField.H"
41 #include "syncTools.H"
52 void Foam::MRFZoneDF::setMRFFaces()
54 const polyBoundaryMesh& patches = mesh_.boundaryMesh();
60 labelList faceType(mesh_.nFaces(), 0);
66 const labelList& own = mesh_.faceOwner();
67 const labelList& nei = mesh_.faceNeighbour();
70 boolList zoneCell(mesh_.nCells(),
false);
72 if (cellZoneID_ != -1)
74 const labelList& cellLabels = mesh_.cellZones()[cellZoneID_];
77 zoneCell[cellLabels[i]] =
true;
83 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
85 if (zoneCell[own[facei]] || zoneCell[nei[facei]])
92 labelHashSet excludedPatches(excludedPatchLabels_);
96 const polyPatch& pp = patches[patchi];
98 if (pp.coupled() || excludedPatches.found(patchi))
102 label facei = pp.start() + i;
104 if (zoneCell[own[facei]])
111 else if (!isA<emptyPolyPatch>(pp))
115 label facei = pp.start() + i;
117 if (zoneCell[own[facei]])
127 syncTools::syncFaceList(mesh_, faceType, maxEqOp<label>());
136 internalFaces_.setSize(mesh_.nFaces());
139 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
141 if (faceType[facei] == 1)
143 internalFaces_[nInternal++] = facei;
146 internalFaces_.setSize(nInternal);
148 labelList nIncludedFaces(patches.size(), 0);
149 labelList nExcludedFaces(patches.size(), 0);
153 const polyPatch& pp = patches[patchi];
157 label facei = pp.start() + patchFacei;
159 if (faceType[facei] == 1)
161 nIncludedFaces[patchi]++;
163 else if (faceType[facei] == 2)
165 nExcludedFaces[patchi]++;
170 includedFaces_.setSize(patches.size());
171 excludedFaces_.setSize(patches.size());
172 forAll(nIncludedFaces, patchi)
174 includedFaces_[patchi].setSize(nIncludedFaces[patchi]);
175 excludedFaces_[patchi].setSize(nExcludedFaces[patchi]);
182 const polyPatch& pp = patches[patchi];
186 label facei = pp.start() + patchFacei;
188 if (faceType[facei] == 1)
190 includedFaces_[patchi][nIncludedFaces[patchi]++] = patchFacei;
192 else if (faceType[facei] == 2)
194 excludedFaces_[patchi][nExcludedFaces[patchi]++] = patchFacei;
202 Foam::MRFZoneDF::MRFZoneDF(
205 const dictionary& dict,
206 const word& cellZoneName)
210 active_(coeffs_.lookupOrDefault(
"active", true)),
211 cellZoneName_(cellZoneName),
214 coeffs_.lookupOrDefault<wordRes>(
"nonRotatingPatches", wordRes())),
215 origin_(coeffs_.lookup(
"origin")),
216 axis_(coeffs_.lookup(
"axis")),
217 omega_(coeffs_.lookupOrDefault<scalar>(
"omega", 0.0))
219 if (cellZoneName_ == word::null)
221 coeffs_.readEntry(
"cellZone", cellZoneName_);
230 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
232 axis_ = axis_ / mag(axis_);
234 const labelHashSet excludedPatchSet(
235 mesh_.boundaryMesh().patchSet(excludedPatchNames_));
237 excludedPatchLabels_.setSize(excludedPatchSet.size());
240 for (
const label patchi : excludedPatchSet)
242 excludedPatchLabels_[i++] = patchi;
245 bool cellZoneFound = (cellZoneID_ != -1);
247 reduce(cellZoneFound, orOp<bool>());
252 <<
"cannot find MRF cellZone " << cellZoneName_
264 return omega_ * axis_;
268 const volVectorField&
U,
269 volVectorField& ddtU)
const
271 if (cellZoneID_ == -1)
276 const labelList& cells = mesh_.cellZones()[cellZoneID_];
277 vectorField& ddtUc = ddtU.primitiveFieldRef();
278 const vectorField& Uc =
U;
280 const vector Omega = this->Omega();
284 label celli = cells[i];
285 ddtUc[celli] += (Omega ^ Uc[celli]);
291 if (cellZoneID_ == -1)
296 const volVectorField& C = mesh_.C();
298 const vector Omega = this->Omega();
300 const labelList& cells = mesh_.cellZones()[cellZoneID_];
304 label celli = cells[i];
305 U[celli] -= (Omega ^ (C[celli] - origin_));
310 volVectorField::Boundary& Ubf =
U.boundaryFieldRef();
312 forAll(includedFaces_, patchi)
314 forAll(includedFaces_[patchi], i)
316 label patchFacei = includedFaces_[patchi][i];
317 Ubf[patchi][patchFacei] = Zero;
322 forAll(excludedFaces_, patchi)
324 forAll(excludedFaces_[patchi], i)
326 label patchFacei = excludedFaces_[patchi][i];
327 Ubf[patchi][patchFacei] -=
329 ^ (C.boundaryField()[patchi][patchFacei] - origin_));
336 makeRelativeRhoFlux(geometricOneField(),
phi);
350 const surfaceScalarField&
rho,
351 surfaceScalarField&
phi)
const
353 makeRelativeRhoFlux(
rho,
phi);
363 const vector Omega = this->Omega();
366 volVectorField::Boundary& Ubf =
U.boundaryFieldRef();
368 forAll(includedFaces_, patchi)
370 const vectorField& patchC = mesh_.Cf().boundaryField()[patchi];
372 vectorField pfld(Ubf[patchi]);
374 forAll(includedFaces_[patchi], i)
376 label patchFacei = includedFaces_[patchi][i];
378 pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_));