48void Foam::MRFZone::setMRFFaces()
68 if (cellZoneID_ != -1)
73 zoneCell[cellLabels[i]] =
true;
80 for (label facei = 0; facei < mesh_.nInternalFaces(); facei++)
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]])
111 label facei =
pp.start()+i;
113 if (zoneCell[own[facei]])
132 internalFaces_.setSize(mesh_.nFaces());
135 for (label facei = 0; facei < mesh_.nInternalFaces(); 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]++;
166 includedFaces_.setSize(
patches.size());
167 excludedFaces_.setSize(
patches.size());
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 "
237Foam::MRFZone::MRFZone
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]);
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] =
466 (Omega ^ (
C.boundaryField()[patchi][patchFacei] - origin_));
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())
542 os.writeEntry(
"nonRotatingPatches", excludedPatchNames_);
553 coeffs_.readIfPresent(
"active", active_);
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())
static const Foam::dimensionedScalar C("", Foam::dimTemperature, 234.5)
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
Graphite solid properties.
C() noexcept
Default construct.
A field of fields is a PtrList of fields with reference counting.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
GeometricBoundaryField< vector, fvPatchField, volMesh > Boundary
MRF zone definition based on cell zone and parameters obtained from a control dictionary constructed ...
vector Omega() const
Return the current Omega vector.
void writeData(Ostream &os) const
Write.
bool read(const dictionary &dict)
Read MRF dictionary.
void makeAbsolute(volVectorField &U) const
Make the given relative velocity absolute within the MRF region.
void correctBoundaryVelocity(volVectorField &U) const
Correct the boundary velocity for the rotation of the MRF region.
void makeRelative(volVectorField &U) const
Make the given absolute velocity relative within the MRF region.
void update()
Update MRFZone faces if the mesh topology changes.
void addCoriolis(const volVectorField &U, volVectorField &ddtU) const
Add the Coriolis force contribution to the acceleration field.
const word & name() const
Return const access to the MRF region name.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
Field< Type > & source() noexcept
Mesh data needed to do the Finite Volume discretisation.
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
A class representing the concept of a field of oneFields used to avoid unnecessary manipulations for ...
A class representing the concept of a field of 1 used to avoid unnecessary manipulations for objects ...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
virtual const labelList & faceOwner() const
Return face owner.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
label nCells() const noexcept
Number of mesh cells.
label nFaces() const noexcept
Number of mesh faces.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const polyBoundaryMesh & patches
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
A special matrix type and solver, designed for finite volume solutions of scalar equations.
const expr V(m.psi().mesh().V())
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
GeometricField< vector, fvPatchField, volMesh > volVectorField
bool read(const char *buf, int32_t &val)
Same as readInt32.
List< label > labelList
A List of labels.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
fvMatrix< vector > fvVectorMatrix
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< bool > boolList
A List of bools.
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.