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 active_(coeffs_.lookupOrDefault(
"active",
true)),
248 cellZoneName_(cellZoneName),
254 origin_(coeffs_.lookup(
"origin")),
255 axis_(coeffs_.lookup(
"axis")),
260 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_
306 return omega_->value(mesh_.time().timeOutputValue())*axis_;
316 if (cellZoneID_ == -1)
325 const vector Omega = this->Omega();
329 label celli = cells[i];
330 ddtUc[celli] += (Omega ^ Uc[celli]);
337 if (cellZoneID_ == -1)
347 const vector Omega = this->Omega();
353 label celli = cells[i];
354 Usource[celli] += V[celli]*(Omega ^ U[celli]);
361 label celli = cells[i];
362 Usource[celli] -= V[celli]*(Omega ^ U[celli]);
375 if (cellZoneID_ == -1)
385 const vector Omega = this->Omega();
391 label celli = cells[i];
392 Usource[celli] += V[celli]*rho[celli]*(Omega ^ U[celli]);
399 label celli = cells[i];
400 Usource[celli] -= V[celli]*rho[celli]*(Omega ^ U[celli]);
408 if (cellZoneID_ == -1)
415 const vector Omega = this->Omega();
421 label celli = cells[i];
422 U[celli] -= (Omega ^ (C[celli] - origin_));
429 forAll(includedFaces_, patchi)
431 forAll(includedFaces_[patchi], i)
439 forAll(excludedFaces_, patchi)
441 forAll(excludedFaces_[patchi], i)
444 Ubf[
patchi][patchFacei] -=
466 makeRelativeRhoFlux(
oneField(), phi, patchi);
476 makeRelativeRhoFlux(rho, phi);
482 if (cellZoneID_ == -1)
489 const vector Omega = this->Omega();
495 label celli = cells[i];
496 U[celli] += (Omega ^ (C[celli] - origin_));
502 forAll(includedFaces_, patchi)
504 forAll(includedFaces_[patchi], i)
513 forAll(excludedFaces_, patchi)
515 forAll(excludedFaces_[patchi], i)
518 Ubf[
patchi][patchFacei] +=
537 makeAbsoluteRhoFlux(rho, phi);
548 const vector Omega = this->Omega();
553 forAll(includedFaces_, patchi)
559 forAll(includedFaces_[patchi], i)
563 pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_));
580 omega_->writeData(os);
582 if (excludedPatchNames_.size())
584 writeEntry(os,
"nonRotatingPatches", excludedPatchNames_);
596 coeffs_.lookup(
"cellZone") >> cellZoneName_;
597 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
605 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.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
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.
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 ...
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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 > &)
virtual Ostream & write(const token &)=0
Write next token to stream.
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.