48 void Foam::MRFZone::setMRFFaces()
68 if (cellZoneID_ != -1)
73 zoneCell[cellLabels[i]] =
true;
82 if (zoneCell[own[facei]] || zoneCell[nei[facei]])
94 if (
pp.coupled() || excludedPatchLabels_.
contains(patchi))
98 label facei =
pp.start()+i;
100 if (zoneCell[own[facei]])
107 else if (!isA<emptyPolyPatch>(
pp))
111 label facei =
pp.start()+i;
113 if (zoneCell[own[facei]])
137 if (faceType[facei] == 1)
139 internalFaces_[nInternal++] = facei;
142 internalFaces_.
setSize(nInternal);
153 label facei =
pp.start() + patchFacei;
155 if (faceType[facei] == 1)
157 nIncludedFaces[patchi]++;
159 else if (faceType[facei] == 2)
161 nExcludedFaces[patchi]++;
168 forAll(nIncludedFaces, patchi)
170 includedFaces_[patchi].
setSize(nIncludedFaces[patchi]);
171 excludedFaces_[patchi].
setSize(nExcludedFaces[patchi]);
182 label facei =
pp.start() + patchFacei;
184 if (faceType[facei] == 1)
186 includedFaces_[patchi][nIncludedFaces[patchi]++] = patchFacei;
188 else if (faceType[facei] == 2)
190 excludedFaces_[patchi][nExcludedFaces[patchi]++] = patchFacei;
198 faceSet internalFaces(mesh_,
"internalFaces", internalFaces_);
199 Pout<<
"Writing " << internalFaces.size()
200 <<
" internal faces in MRF zone to faceSet " 202 internalFaces.
write();
204 faceSet MRFFaces(mesh_,
"includedFaces", 100);
205 forAll(includedFaces_, patchi)
207 forAll(includedFaces_[patchi], i)
209 label patchFacei = includedFaces_[patchi][i];
210 MRFFaces.insert(
patches[patchi].start()+patchFacei);
213 Pout<<
"Writing " << MRFFaces.size()
214 <<
" patch faces in MRF zone to faceSet " 218 faceSet excludedFaces(mesh_,
"excludedFaces", 100);
219 forAll(excludedFaces_, patchi)
221 forAll(excludedFaces_[patchi], i)
223 label patchFacei = excludedFaces_[patchi][i];
224 excludedFaces.insert(
patches[patchi].start()+patchFacei);
227 Pout<<
"Writing " << excludedFaces.size()
228 <<
" faces in MRF zone with special handling to faceSet " 230 excludedFaces.
write();
237 Foam::MRFZone::MRFZone
241 const dictionary&
dict,
242 const word& cellZoneName
249 cellZoneName_(cellZoneName),
251 excludedPatchNames_(),
264 return omega_->value(mesh_.time().timeOutputValue())*axis_;
274 if (cellZoneID_ == -1)
283 const vector Omega = this->Omega();
287 label celli =
cells[i];
288 ddtUc[celli] += (Omega ^ Uc[celli]);
295 if (cellZoneID_ == -1)
305 const vector Omega = this->Omega();
311 label celli =
cells[i];
312 Usource[celli] += V[celli]*(Omega ^
U[celli]);
319 label celli =
cells[i];
320 Usource[celli] -= V[celli]*(Omega ^
U[celli]);
333 if (cellZoneID_ == -1)
343 const vector Omega = this->Omega();
349 label celli =
cells[i];
350 Usource[celli] += V[celli]*
rho[celli]*(Omega ^
U[celli]);
358 Usource[celli] -= V[celli]*
rho[celli]*(Omega ^
U[celli]);
366 if (cellZoneID_ == -1)
373 const vector Omega = this->Omega();
379 label celli =
cells[i];
380 U[celli] -= (Omega ^ (
C[celli] - origin_));
387 forAll(includedFaces_, patchi)
389 forAll(includedFaces_[patchi], i)
391 label patchFacei = includedFaces_[patchi][i];
392 Ubf[patchi][patchFacei] =
Zero;
397 forAll(excludedFaces_, patchi)
399 forAll(excludedFaces_[patchi], i)
401 label patchFacei = excludedFaces_[patchi][i];
402 Ubf[patchi][patchFacei] -=
404 ^ (
C.boundaryField()[patchi][patchFacei] - origin_));
434 makeRelativeRhoFlux(
rho,
phi);
440 if (cellZoneID_ == -1)
447 const vector Omega = this->Omega();
453 label celli =
cells[i];
454 U[celli] += (Omega ^ (
C[celli] - origin_));
460 forAll(includedFaces_, patchi)
462 forAll(includedFaces_[patchi], i)
464 label patchFacei = includedFaces_[patchi][i];
465 Ubf[patchi][patchFacei] =
471 forAll(excludedFaces_, patchi)
473 forAll(excludedFaces_[patchi], i)
475 label patchFacei = excludedFaces_[patchi][i];
476 Ubf[patchi][patchFacei] +=
477 (Omega ^ (
C.boundaryField()[patchi][patchFacei] - origin_));
495 makeAbsoluteRhoFlux(
rho,
phi);
506 const vector Omega = this->Omega();
511 forAll(includedFaces_, patchi)
513 const vectorField& patchC = mesh_.Cf().boundaryField()[patchi];
517 forAll(includedFaces_[patchi], i)
519 label patchFacei = includedFaces_[patchi][i];
521 pfld[patchFacei] = (Omega ^ (patchC[patchFacei] - origin_));
538 omega_->writeData(
os);
540 if (excludedPatchNames_.size())
561 coeffs_.readIfPresent(
"nonRotatingPatches", excludedPatchNames_);
563 origin_ = coeffs_.get<
vector>(
"origin");
564 axis_ = coeffs_.get<
vector>(
"axis").normalise();
565 omega_.reset(Function1<scalar>::New(
"omega", coeffs_, &mesh_));
567 const word oldCellZoneName = cellZoneName_;
568 if (cellZoneName_.empty())
570 coeffs_.readEntry(
"cellZone", cellZoneName_);
574 coeffs_.readIfPresent(
"cellZone", cellZoneName_);
577 if (cellZoneID_ == -1 || oldCellZoneName != cellZoneName_)
579 cellZoneID_ = mesh_.cellZones().findZoneID(cellZoneName_);
581 excludedPatchLabels_ =
582 mesh_.boundaryMesh().indices(excludedPatchNames_);
587 <<
"cannot find MRF cellZone " << cellZoneName_
600 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.
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
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
bool contains(const T &val) const
True if the value is contained in the list.
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
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 expressions::valueTypeCode::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.
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)