mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
patchMeanVelocityForce: Variant of patchMeanVelocityForce in which the velocity is averaged over a patch
rather than a cellSet This is useful to drive mean flow in a duct with a non-uniform cross-section.
This commit is contained in:
@ -22,6 +22,7 @@ $(derivedSources)/effectivenessHeatExchangerSource/effectivenessHeatExchangerSou
|
|||||||
$(derivedSources)/explicitPorositySource/explicitPorositySource.C
|
$(derivedSources)/explicitPorositySource/explicitPorositySource.C
|
||||||
$(derivedSources)/meanVelocityForce/meanVelocityForce.C
|
$(derivedSources)/meanVelocityForce/meanVelocityForce.C
|
||||||
$(derivedSources)/meanVelocityForce/meanVelocityForceIO.C
|
$(derivedSources)/meanVelocityForce/meanVelocityForceIO.C
|
||||||
|
$(derivedSources)/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C
|
||||||
$(derivedSources)/radialActuationDiskSource/radialActuationDiskSource.C
|
$(derivedSources)/radialActuationDiskSource/radialActuationDiskSource.C
|
||||||
$(derivedSources)/rotorDiskSource/rotorDiskSource.C
|
$(derivedSources)/rotorDiskSource/rotorDiskSource.C
|
||||||
$(derivedSources)/rotorDiskSource/bladeModel/bladeModel.C
|
$(derivedSources)/rotorDiskSource/bladeModel/bladeModel.C
|
||||||
|
|||||||
@ -132,33 +132,50 @@ Foam::fv::meanVelocityForce::meanVelocityForce
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fv::meanVelocityForce::correct(volVectorField& U)
|
Foam::scalar Foam::fv::meanVelocityForce::magUbarAve
|
||||||
|
(
|
||||||
|
const volVectorField& U
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
const scalarField& rAU = rAPtr_().internalField();
|
|
||||||
|
|
||||||
// Integrate flow variables over cell set
|
|
||||||
scalar magUbarAve = 0.0;
|
scalar magUbarAve = 0.0;
|
||||||
scalar rAUave = 0.0;
|
|
||||||
const scalarField& cv = mesh_.V();
|
const scalarField& cv = mesh_.V();
|
||||||
forAll(cells_, i)
|
forAll(cells_, i)
|
||||||
{
|
{
|
||||||
label cellI = cells_[i];
|
label cellI = cells_[i];
|
||||||
scalar volCell = cv[cellI];
|
scalar volCell = cv[cellI];
|
||||||
magUbarAve += (flowDir_ & U[cellI])*volCell;
|
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 rAUave = 0.0;
|
||||||
|
const scalarField& cv = mesh_.V();
|
||||||
|
forAll(cells_, i)
|
||||||
|
{
|
||||||
|
label cellI = cells_[i];
|
||||||
|
scalar volCell = cv[cellI];
|
||||||
rAUave += rAU[cellI]*volCell;
|
rAUave += rAU[cellI]*volCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect across all processors
|
// Collect across all processors
|
||||||
reduce(magUbarAve, sumOp<scalar>());
|
|
||||||
reduce(rAUave, sumOp<scalar>());
|
reduce(rAUave, sumOp<scalar>());
|
||||||
|
|
||||||
// Volume averages
|
// Volume averages
|
||||||
magUbarAve /= V_;
|
|
||||||
rAUave /= V_;
|
rAUave /= V_;
|
||||||
|
|
||||||
// magUbarAve =
|
scalar magUbarAve = this->magUbarAve(U);
|
||||||
// gSum((flowDir_ & U.boundaryField()[0])*mesh_.boundary()[0].magSf())
|
|
||||||
// /gSum(mesh_.boundary()[0].magSf());
|
|
||||||
|
|
||||||
// Calculate the pressure gradient increment needed to adjust the average
|
// Calculate the pressure gradient increment needed to adjust the average
|
||||||
// flow-rate to the desired value
|
// flow-rate to the desired value
|
||||||
|
|||||||
@ -72,7 +72,9 @@ class meanVelocityForce
|
|||||||
:
|
:
|
||||||
public cellSetOption
|
public cellSetOption
|
||||||
{
|
{
|
||||||
// Private data
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
//- Average velocity
|
//- Average velocity
|
||||||
vector Ubar_;
|
vector Ubar_;
|
||||||
@ -93,7 +95,11 @@ class meanVelocityForce
|
|||||||
autoPtr<volScalarField> rAPtr_;
|
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)
|
//- Write the pressure gradient to file (for restarts etc)
|
||||||
void writeProps(const scalar gradP) const;
|
void writeProps(const scalar gradP) const;
|
||||||
@ -101,6 +107,11 @@ class meanVelocityForce
|
|||||||
//- Correct driving force for a constant mass flow rate
|
//- Correct driving force for a constant mass flow rate
|
||||||
void update(fvMatrix<vector>& eqn);
|
void update(fvMatrix<vector>& eqn);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
meanVelocityForce(const meanVelocityForce&);
|
meanVelocityForce(const meanVelocityForce&);
|
||||||
|
|
||||||
|
|||||||
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user