diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H index 61503b9264..56511b7cfe 100644 --- a/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H +++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensor.H @@ -87,6 +87,9 @@ public: //- Construct given three components inline DiagTensor(const Cmpt& txx, const Cmpt& tyy, const Cmpt& tzz); + //- Construct from Vector + inline explicit DiagTensor(const Vector& v); + //- Construct from Istream inline DiagTensor(Istream&); @@ -103,7 +106,7 @@ public: inline Cmpt& yy(); inline Cmpt& zz(); - //- Explicit conversion to vector + //- Explicit conversion to Vector explicit inline operator Vector() const; }; diff --git a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H index ec26edd88f..f056a96c16 100644 --- a/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H +++ b/src/OpenFOAM/primitives/DiagTensor/DiagTensorI.H @@ -65,6 +65,13 @@ inline Foam::DiagTensor::DiagTensor } +template +inline Foam::DiagTensor::DiagTensor(const Vector& v) +: + VectorSpace, Cmpt, 3>(v) +{} + + template inline Foam::DiagTensor::DiagTensor(Istream& is) : diff --git a/src/fvModels/derived/actuationDiskSource/actuationDiskSource.C b/src/fvModels/derived/actuationDiskSource/actuationDiskSource.C index 07bfaac041..9a89ba9919 100644 --- a/src/fvModels/derived/actuationDiskSource/actuationDiskSource.C +++ b/src/fvModels/derived/actuationDiskSource/actuationDiskSource.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,7 +50,14 @@ namespace fv void Foam::fv::actuationDiskSource::readCoeffs() { - UName_ = coeffs().lookupOrDefault("U", "U"); + phaseName_ = coeffs().lookupOrDefault("phase", word::null); + + UName_ = + coeffs().lookupOrDefault + ( + "U", + IOobject::groupName("U", phaseName_) + ); diskDir_ = coeffs().lookup("diskDir"); if (mag(diskDir_) < vSmall) @@ -100,6 +107,7 @@ Foam::fv::actuationDiskSource::actuationDiskSource : fvModel(name, modelType, dict, mesh), set_(coeffs(), mesh), + phaseName_(word::null), UName_(word::null), diskDir_(vector::uniform(NaN)), Cp_(NaN), @@ -138,6 +146,7 @@ void Foam::fv::actuationDiskSource::addSup set_.cells(), cellsV, geometricOneField(), + geometricOneField(), U ); } @@ -162,6 +171,34 @@ void Foam::fv::actuationDiskSource::addSup Usource, set_.cells(), cellsV, + geometricOneField(), + rho, + U + ); + } +} + + +void Foam::fv::actuationDiskSource::addSup +( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const word& fieldName +) const +{ + const scalarField& cellsV = mesh().V(); + vectorField& Usource = eqn.source(); + const vectorField& U = eqn.psi(); + + if (set_.V() > vSmall) + { + addActuationDiskAxialInertialResistance + ( + Usource, + set_.cells(), + cellsV, + alpha, rho, U ); diff --git a/src/fvModels/derived/actuationDiskSource/actuationDiskSource.H b/src/fvModels/derived/actuationDiskSource/actuationDiskSource.H index 7480659caa..fd86d8b602 100644 --- a/src/fvModels/derived/actuationDiskSource/actuationDiskSource.H +++ b/src/fvModels/derived/actuationDiskSource/actuationDiskSource.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,8 +54,6 @@ Usage selectionMode cellSet; cellSet actuationDisk1; - U U; // Name of the velocity field - diskDir (-1 0 0); // Disk direction Cp 0.1; // Power coefficient Ct 0.5; // Thrust coefficient @@ -99,6 +97,9 @@ protected: //- The set of cells the fvConstraint applies to fvCellSet set_; + //- The name of the phase to which this fvModel applies + word phaseName_; + //- Name of the velocity field word UName_; @@ -129,12 +130,13 @@ private: void readCoeffs(); //- Add resistance to the UEqn - template + template void addActuationDiskAxialInertialResistance ( vectorField& Usource, const labelList& cells, const scalarField& V, + const AlphaFieldType& alpha, const RhoFieldType& rho, const vectorField& U ) const; @@ -192,6 +194,15 @@ public: const word& fieldName ) const; + //- Explicit and implicit sources for phase equations + virtual void addSup + ( + const volScalarField& alpha, + const volScalarField& rho, + fvMatrix& eqn, + const word& fieldName + ) const; + // Mesh motion diff --git a/src/fvModels/derived/actuationDiskSource/actuationDiskSourceTemplates.C b/src/fvModels/derived/actuationDiskSource/actuationDiskSourceTemplates.C index 6d4f45f2fe..6f1cbf601b 100644 --- a/src/fvModels/derived/actuationDiskSource/actuationDiskSourceTemplates.C +++ b/src/fvModels/derived/actuationDiskSource/actuationDiskSourceTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,38 +28,34 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template +template void Foam::fv::actuationDiskSource::addActuationDiskAxialInertialResistance ( vectorField& Usource, const labelList& cells, const scalarField& Vcells, + const AlphaFieldType& alpha, const RhoFieldType& rho, const vectorField& U ) const { - scalar a = 1.0 - Cp_/Ct_; - vector uniDiskDir = diskDir_/mag(diskDir_); - tensor E(Zero); - E.xx() = uniDiskDir.x(); - E.yy() = uniDiskDir.y(); - E.zz() = uniDiskDir.z(); + const scalar a = 1 - Cp_/Ct_; + const diagTensor E(diskDir_/mag(diskDir_)); - vector upU = vector(vGreat, vGreat, vGreat); - scalar upRho = vGreat; + vector upU(vector::max); if (upstreamCellId_ != -1) { upU = U[upstreamCellId_]; - upRho = rho[upstreamCellId_]; } reduce(upU, minOp()); - reduce(upRho, minOp()); - scalar T = 2.0*upRho*diskArea_*mag(upU)*a*(1 - a); + const scalar T = 2*diskArea_*mag(upU)*a*(1 - a); forAll(cells, i) { - Usource[cells[i]] += ((Vcells[cells[i]]/set_.V())*T*E) & upU; + Usource[cells[i]] += + alpha[cells[i]]*rho[cells[i]] + *(((Vcells[cells[i]]/set_.V())*T*E) & upU); } }