48 void Foam::MRFZone::setMRFFaces()
68 if (cellZoneID_ != -1)
73 zoneCell[cellLabels[i]] =
true;
82 if (zoneCell[own[facei]] || zoneCell[nei[facei]])
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);
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]);
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_));
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_));
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();
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;
599 <<
"cannot find MRF cellZone " << cellZoneName_
612 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
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
void makeRelative(volVectorField &U) const
Make the given absolute velocity relative within the MRF region.
Graphite solid properties.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
constexpr char nl
The newline '\n' character (0x0a)
void makeAbsolute(volVectorField &U) const
Make the given relative velocity absolute within the MRF region.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
GeometricBoundaryField< vector, fvPatchField, volMesh > Boundary
Type of boundary fields.
void update()
Update MRFZone faces if the mesh topology changes.
label nFaces() const noexcept
Number of mesh faces.
GeometricField< vector, fvPatchField, volMesh > volVectorField
A class representing the concept of a field of oneFields used to avoid unnecessary manipulations for ...
A field of fields is a PtrList of fields with reference counting.
bool read(const char *buf, int32_t &val)
Same as readInt32.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
void setSize(const label n)
Alias for resize()
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual Ostream & endBlock()
Write end block group.
virtual const labelList & faceOwner() const
Return face owner.
static const word null
An empty word.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
label nInternalFaces() const noexcept
Number of internal faces.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
void correctBoundaryVelocity(volVectorField &U) const
Correct the boundary velocity for the rotation of the MRF region.
vector Omega() const
Return the current Omega vector.
Field< Type > & source() noexcept
A class representing the concept of a field of 1 used to avoid unnecessary manipulations for objects ...
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
label nCells() const noexcept
Number of mesh cells.
fvMatrix< vector > fvVectorMatrix
const polyBoundaryMesh & patches
A special matrix type and solver, designed for finite volume solutions of scalar equations.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
bool returnReduceOr(const bool value, const label comm=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
void writeData(Ostream &os) const
Write.
List< bool > boolList
A List of bools.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
static constexpr const zero Zero
Global zero (0)