diff --git a/src/fvOptions/Make/files b/src/fvOptions/Make/files index 52ce4a542876f83d1b7e0fee50da2e6cf32c4803..ff2f45032b136b493cf081ee17ef518fcbaa7773 100644 --- a/src/fvOptions/Make/files +++ b/src/fvOptions/Make/files @@ -22,6 +22,7 @@ $(derivedSources)/effectivenessHeatExchangerSource/effectivenessHeatExchangerSou $(derivedSources)/explicitPorositySource/explicitPorositySource.C $(derivedSources)/meanVelocityForce/meanVelocityForce.C $(derivedSources)/meanVelocityForce/meanVelocityForceIO.C +$(derivedSources)/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C $(derivedSources)/radialActuationDiskSource/radialActuationDiskSource.C $(derivedSources)/rotorDiskSource/rotorDiskSource.C $(derivedSources)/rotorDiskSource/bladeModel/bladeModel.C diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C index 393acaadf102db66848bdfef7597e6b57942ecc9..4b717229cebe36dd2ca34cca1474f2f32f297b6b 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C @@ -132,33 +132,50 @@ Foam::fv::meanVelocityForce::meanVelocityForce // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::scalar Foam::fv::meanVelocityForce::magUbarAve +( + const volVectorField& U +) const +{ + scalar magUbarAve = 0.0; + + const scalarField& cv = mesh_.V(); + forAll(cells_, i) + { + label cellI = cells_[i]; + scalar volCell = cv[cellI]; + magUbarAve += (flowDir_ & U[cellI])*volCell; + } + + reduce(magUbarAve, sumOp<scalar>()); + + magUbarAve /= V_; + + return magUbarAve; +} + + void Foam::fv::meanVelocityForce::correct(volVectorField& U) { const scalarField& rAU = rAPtr_().internalField(); // Integrate flow variables over cell set - scalar magUbarAve = 0.0; scalar rAUave = 0.0; const scalarField& cv = mesh_.V(); forAll(cells_, i) { label cellI = cells_[i]; scalar volCell = cv[cellI]; - magUbarAve += (flowDir_ & U[cellI])*volCell; rAUave += rAU[cellI]*volCell; } // Collect across all processors - reduce(magUbarAve, sumOp<scalar>()); reduce(rAUave, sumOp<scalar>()); // Volume averages - magUbarAve /= V_; rAUave /= V_; - // magUbarAve = - // gSum((flowDir_ & U.boundaryField()[0])*mesh_.boundary()[0].magSf()) - // /gSum(mesh_.boundary()[0].magSf()); + scalar magUbarAve = this->magUbarAve(U); // Calculate the pressure gradient increment needed to adjust the average // flow-rate to the desired value diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H index e34904f88e4135e1b95ef06aa8897c24855ea4db..a9cbfa725add0e8fe6ccece596964d8123db5715 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.H @@ -72,7 +72,9 @@ class meanVelocityForce : public cellSetOption { - // Private data +protected: + + // Protected data //- Average velocity vector Ubar_; @@ -93,7 +95,11 @@ class meanVelocityForce autoPtr<volScalarField> rAPtr_; - // Private Member Functions + // Protected Member Functions + + //- Calculate and return the magnitude of the mean velocity + // averaged over the selected cellSet + virtual scalar magUbarAve(const volVectorField& U) const; //- Write the pressure gradient to file (for restarts etc) void writeProps(const scalar gradP) const; @@ -101,6 +107,11 @@ class meanVelocityForce //- Correct driving force for a constant mass flow rate void update(fvMatrix<vector>& eqn); + +private: + + // Private Member Functions + //- Disallow default bitwise copy construct meanVelocityForce(const meanVelocityForce&); diff --git a/src/fvOptions/sources/derived/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C new file mode 100644 index 0000000000000000000000000000000000000000..8fdf8a988155c544733741a14225f1e50a3a9b94 --- /dev/null +++ b/src/fvOptions/sources/derived/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "patchMeanVelocityForce.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + defineTypeNameAndDebug(patchMeanVelocityForce, 0); + + addToRunTimeSelectionTable + ( + option, + patchMeanVelocityForce, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fv::patchMeanVelocityForce::patchMeanVelocityForce +( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + meanVelocityForce(sourceName, modelType, dict, mesh), + patch_(coeffs_.lookup("patch")), + patchi_(mesh.boundaryMesh().findPatchID(patch_)) +{ + if (patchi_ < 0) + { + FatalErrorIn("fv::patchMeanVelocityForce::patchMeanVelocityForce") + << "Cannot find patch " << patch_ + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::fv::patchMeanVelocityForce::magUbarAve +( + const volVectorField& U +) const +{ + return + gSum + ( + (flowDir_ & U.boundaryField()[patchi_]) + *mesh_.boundary()[patchi_].magSf() + )/gSum(mesh_.boundary()[patchi_].magSf()); +} + + +// ************************************************************************* // diff --git a/src/fvOptions/sources/derived/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.H b/src/fvOptions/sources/derived/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.H new file mode 100644 index 0000000000000000000000000000000000000000..b261b4d9f922acd2a08e509dc32b709e1441a620 --- /dev/null +++ b/src/fvOptions/sources/derived/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Class + Foam::fv::patchMeanVelocityForce + +Description + Calculates and applies the force necessary to maintain the specified mean + velocity averaged over the specified patch. + + Note: Currently only handles kinematic pressure (incompressible solvers). + + \heading Source usage + Example usage: + \verbatim + patchMeanVelocityForceCoeffs + { + fieldNames (U); // Name of velocity field + patch inlet; // Name of the patch + Ubar (10.0 0 0); // Desired mean velocity + relaxation 0.2; // Optional relaxation factor + } + \endverbatim + +SourceFiles + patchMeanVelocityForce.C + +\*---------------------------------------------------------------------------*/ + +#ifndef patchMeanVelocityForce_H +#define patchMeanVelocityForce_H + +#include "meanVelocityForce.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class patchMeanVelocityForce Declaration +\*---------------------------------------------------------------------------*/ + +class patchMeanVelocityForce +: + public meanVelocityForce +{ +protected: + + // Protected data + + //- Patch name + word patch_; + + //- Patch index + label patchi_; + + + // Protected Member Functions + + //- Calculate and return the magnitude of the mean velocity + // averaged over the specified patch + virtual scalar magUbarAve(const volVectorField& U) const; + + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + patchMeanVelocityForce(const patchMeanVelocityForce&); + + //- Disallow default bitwise assignment + void operator=(const patchMeanVelocityForce&); + + +public: + + //- Runtime type information + TypeName("patchMeanVelocityForce"); + + + // Constructors + + //- Construct from explicit source name and mesh + patchMeanVelocityForce + ( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //