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 label facei = pp.start()+i;
99 if (zoneCell[own[facei]])
106 else if (!isA<emptyPolyPatch>(pp))
110 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 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 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_);
198 Pout<<
"Writing " << internalFaces.size()
199 <<
" internal faces in MRF zone to faceSet " 201 internalFaces.
write();
203 faceSet MRFFaces(mesh_,
"includedFaces", 100);
204 forAll(includedFaces_, patchi)
206 forAll(includedFaces_[patchi], i)
209 MRFFaces.insert(patches[patchi].start()+patchFacei);
212 Pout<<
"Writing " << MRFFaces.size()
213 <<
" patch faces in MRF zone to faceSet " 217 faceSet excludedFaces(mesh_,
"excludedFaces", 100);
218 forAll(excludedFaces_, patchi)
220 forAll(excludedFaces_[patchi], i)
223 excludedFaces.insert(patches[patchi].start()+patchFacei);
226 Pout<<
"Writing " << excludedFaces.size()
227 <<
" faces in MRF zone with special handling to faceSet " 229 excludedFaces.
write();
241 const word& cellZoneName
247 cellZoneName_(cellZoneName),
253 origin_(coeffs_.lookup(
"origin")),
254 axis_(coeffs_.lookup(
"axis")),
259 coeffs_.lookup(
"cellZone") >> cellZoneName_;
262 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
264 axis_ = axis_/
mag(axis_);
268 mesh_.boundaryMesh().patchSet(excludedPatchNames_)
271 excludedPatchLabels_.setSize(excludedPatchSet.size());
276 excludedPatchLabels_[i++] = iter.key();
279 bool cellZoneFound = (cellZoneID_ != -1);
286 <<
"cannot find MRF cellZone " << cellZoneName_
298 return omega_->value(mesh_.time().timeOutputValue())*axis_;
308 if (cellZoneID_ == -1)
317 const vector Omega = this->Omega();
321 label celli = cells[i];
322 ddtUc[celli] += (Omega ^ Uc[celli]);
329 if (cellZoneID_ == -1)
339 const vector Omega = this->Omega();
345 label celli = cells[i];
346 Usource[celli] += V[celli]*(Omega ^ U[celli]);
353 label celli = cells[i];
354 Usource[celli] -= V[celli]*(Omega ^ U[celli]);
367 if (cellZoneID_ == -1)
377 const vector Omega = this->Omega();
383 label celli = cells[i];
384 Usource[celli] += V[celli]*rho[celli]*(Omega ^ U[celli]);
391 label celli = cells[i];
392 Usource[celli] -= V[celli]*rho[celli]*(Omega ^ U[celli]);
400 if (cellZoneID_ == -1)
407 const vector Omega = this->Omega();
413 label celli = cells[i];
414 U[celli] -= (Omega ^ (C[celli] - origin_));
421 forAll(includedFaces_, patchi)
423 forAll(includedFaces_[patchi], i)
431 forAll(excludedFaces_, patchi)
433 forAll(excludedFaces_[patchi], i)
436 Ubf[
patchi][patchFacei] -=
458 makeRelativeRhoFlux(
oneField(), phi, patchi);
468 makeRelativeRhoFlux(rho, phi);
474 if (cellZoneID_ == -1)
481 const vector Omega = this->Omega();
487 label celli = cells[i];
488 U[celli] += (Omega ^ (C[celli] - origin_));
494 forAll(includedFaces_, patchi)
496 forAll(includedFaces_[patchi], i)
505 forAll(excludedFaces_, patchi)
507 forAll(excludedFaces_[patchi], i)
510 Ubf[
patchi][patchFacei] +=
529 makeAbsoluteRhoFlux(rho, phi);
535 const vector Omega = this->Omega();
540 forAll(includedFaces_, patchi)
546 forAll(includedFaces_[patchi], i)
550 pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_));
568 if (excludedPatchNames_.size())
570 writeEntry(os,
"nonRotatingPatches", excludedPatchNames_);
581 coeffs_.
lookup(
"cellZone") >> cellZoneName_;
582 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
590 if (mesh_.topoChanging())
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.
intWM_LABEL_SIZE_t 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.
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 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.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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.