Mixing plane update

This commit is contained in:
Hrvoje Jasak 2013-06-13 16:50:19 +01:00
parent 75ff3d51f3
commit 002040be85
6 changed files with 185 additions and 37 deletions

View file

@ -158,6 +158,7 @@ mixingPlaneFvPatchField<Type>::mixingPlaneFvPatchField
coupledFvPatchField<Type>(p, iF),
mixingPlanePatch_(refCast<const mixingPlaneFvPatch>(p)),
fluxAveraging_(false),
surfaceAveraging_(true),
phiName_("phi"),
fluxMask_(),
fluxWeights_(p.size(), 0)
@ -175,6 +176,7 @@ mixingPlaneFvPatchField<Type>::mixingPlaneFvPatchField
coupledFvPatchField<Type>(p, iF, dict, false),
mixingPlanePatch_(refCast<const mixingPlaneFvPatch>(p)),
fluxAveraging_(dict.lookup("fluxAveraging")),
surfaceAveraging_(dict.lookup("surfaceAveraging")),
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
fluxMask_(),
fluxWeights_(p.size(), 0)
@ -215,6 +217,7 @@ mixingPlaneFvPatchField<Type>::mixingPlaneFvPatchField
coupledFvPatchField<Type>(ptf, p, iF, mapper),
mixingPlanePatch_(refCast<const mixingPlaneFvPatch>(p)),
fluxAveraging_(ptf.fluxAveraging_),
surfaceAveraging_(ptf.surfaceAveraging_),
phiName_(ptf.phiName_),
fluxMask_(),
fluxWeights_(ptf.fluxWeights_, mapper)
@ -249,6 +252,7 @@ mixingPlaneFvPatchField<Type>::mixingPlaneFvPatchField
coupledFvPatchField<Type>(ptf),
mixingPlanePatch_(refCast<const mixingPlaneFvPatch>(ptf.patch())),
fluxAveraging_(ptf.fluxAveraging_),
surfaceAveraging_(ptf.surfaceAveraging_),
phiName_(ptf.phiName_),
fluxMask_(),
fluxWeights_(ptf.fluxWeights_)
@ -266,6 +270,7 @@ mixingPlaneFvPatchField<Type>::mixingPlaneFvPatchField
coupledFvPatchField<Type>(ptf, iF),
mixingPlanePatch_(refCast<const mixingPlaneFvPatch>(ptf.patch())),
fluxAveraging_(ptf.fluxAveraging_),
surfaceAveraging_(ptf.surfaceAveraging_),
phiName_(ptf.phiName_),
fluxMask_(),
fluxWeights_(ptf.fluxWeights_)
@ -516,6 +521,61 @@ void mixingPlaneFvPatchField<Type>::updateInterfaceMatrix
{}
template<class Type>
void mixingPlaneFvPatchField<Type>::patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL
) const
{
// Code moved from surfaceInterpolationScheme.C
// HJ, 13/Jun/2013
const label patchI = this->patch().index();
// Use circumferential average of internal field when interpolating to
// patch
// HJ and MB, 13/Jun/2013
if (surfaceAveraging_)
{
fField.boundaryField()[patchI] =
pL*this->mixingPlanePatch_.circumferentialAverage
(
this->patchInternalField()
)
+ (1 - pL)*this->patchNeighbourField();
}
else
{
fField.boundaryField()[patchI] =
pL*this->patchInternalField()
+ (1 - pL)*this->patchNeighbourField();
}
}
template<class Type>
void mixingPlaneFvPatchField<Type>::patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL,
const scalarField& pY
) const
{
// Code moved from surfaceInterpolationScheme.C
// HJ, 13/Jun/2013
const label patchI = this->patch().index();
::abort(); //HJ, HERE!!!
// Use circumferential average of internal field
// HJ and MB, 13/Jun/2013
fField.boundaryField()[patchI] =
pL*this->mixingPlanePatch_.circumferentialAverage
(
this->patchInternalField()
)
+ pY*this->patchNeighbourField();
}
template<class Type>
void mixingPlaneFvPatchField<Type>::write(Ostream& os) const
{
@ -524,6 +584,9 @@ void mixingPlaneFvPatchField<Type>::write(Ostream& os) const
os.writeKeyword("fluxAveraging")
<< fluxAveraging_ << token::END_STATEMENT << nl;
os.writeKeyword("surfaceAveraging")
<< surfaceAveraging_ << token::END_STATEMENT << nl;
this->writeEntryIfDifferent(os, "phi", word("phi"), phiName_);
this->writeEntry("value", os);
}

View file

@ -70,6 +70,9 @@ class mixingPlaneFvPatchField
//- Perform flux averaging
Switch fluxAveraging_;
//- Perform surface averaging
Switch surfaceAveraging_;
//- Name of flux field
word phiName_;
@ -196,7 +199,6 @@ public:
//- Return neighbour patch field
virtual tmp<Field<Type> > patchNeighbourField() const;
//- Initialise the evaluation of the patch field
virtual void initEvaluate(const Pstream::commsTypes commsType);
@ -226,6 +228,26 @@ public:
// Gradient coefficients remain unchanged. HJ, 8/Feb/2013
// Patch interpolation and patch flux
//- Calculate patch face interpolate given weighting factors
virtual void patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL
) const;
//- Calculate patch face interpolate given two weighting factors
virtual void patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL,
const scalarField& pY
) const;
// Matrix manipulation
//- Initialise neighbour matrix update
virtual void initInterfaceMatrixUpdate
(

View file

@ -28,6 +28,7 @@ License
#include "dictionary.H"
#include "fvMesh.H"
#include "fvPatchFieldMapper.H"
#include "GeometricField.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -248,10 +249,65 @@ void Foam::fvPatchField<Type>::manipulateMatrix(fvMatrix<Type>& matrix)
}
template<class Type>
void Foam::fvPatchField<Type>::patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL
) const
{
// Code moved from surfaceInterpolationScheme.C
// HJ, 29/May/2013
const label patchI = this->patch().index();
// Virtual function for patch face interpolate. HJ, 13/Jun/2013
if (this->coupled())
{
// Coupled patch
fField.boundaryField()[patchI] =
pL*this->patchInternalField()
+ (1 - pL)*this->patchNeighbourField();
}
else
{
// Uncoupled patch, re-use face values
fField.boundaryField()[patchI] = *this;
}
}
template<class Type>
void Foam::fvPatchField<Type>::patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL,
const scalarField& pY
) const
{
// Code moved from surfaceInterpolationScheme.C
// HJ, 29/May/2013
const label patchI = this->patch().index();
// Virtual function for patch face interpolate. HJ, 13/Jun/2013
if (this->coupled())
{
// Coupled patch
fField.boundaryField()[patchI] =
pL*this->patchInternalField()
+ pY*this->patchNeighbourField();
}
else
{
// Uncoupled patch, re-used face values
fField.boundaryField()[patchI] = *this;
}
}
template<class Type>
void Foam::fvPatchField<Type>::patchFlux
(
GeometricField<Type, fvsPatchField, surfaceMesh>& pFlux,
GeometricField<Type, fvsPatchField, surfaceMesh>& flux,
const fvMatrix<Type>& matrix
) const
{
@ -263,7 +319,7 @@ void Foam::fvPatchField<Type>::patchFlux
if (this->coupled())
{
// Coupled patch
pFlux.boundaryField()[patchI] =
flux.boundaryField()[patchI] =
cmptMultiply
(
matrix.internalCoeffs()[patchI],
@ -278,7 +334,7 @@ void Foam::fvPatchField<Type>::patchFlux
else
{
// Uncoupled patch
pFlux.boundaryField()[patchI] =
flux.boundaryField()[patchI] =
cmptMultiply
(
matrix.internalCoeffs()[patchI],

View file

@ -80,7 +80,7 @@ Ostream& operator<<(Ostream&, const fvPatchField<Type>&);
/*---------------------------------------------------------------------------*\
Class fvPatchField Declaration
Class fvPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
@ -436,17 +436,37 @@ public:
}
//- Manipulate matrix
virtual void manipulateMatrix(fvMatrix<Type>& matrix);
// Patch interpolation and patch flux
//- Calculate patch face interpolate given weighting factors
virtual void patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL
) const;
//- Calculate patch face interpolate given two weighting factors
virtual void patchInterpolate
(
GeometricField<Type, fvsPatchField, surfaceMesh>& fField,
const scalarField& pL,
const scalarField& pY
) const;
//- Calculate patch flux
virtual void patchFlux
(
GeometricField<Type, fvsPatchField, surfaceMesh>& pFlux,
GeometricField<Type, fvsPatchField, surfaceMesh>& flux,
const fvMatrix<Type>& matrix
) const;
// Matrix manipulation
//- Manipulate matrix
virtual void manipulateMatrix(fvMatrix<Type>& matrix);
// I-O
//- Write

View file

@ -38,7 +38,7 @@ SourceFiles
#include "GeometricFields.H"
#include "volMesh.H"
#include "fvMesh.H"
#include "fvPatchField.H"
#include "fvPatchFields.H"
#include "volFieldsFwd.H"
#include "calculatedFvPatchFields.H"
#include "fvMatrices.H"

View file

@ -214,21 +214,14 @@ surfaceInterpolationScheme<Type>::interpolate
// Interpolate across coupled patches using given lambdas and ys
forAll (lambdas.boundaryField(), pi)
forAll (vf.boundaryField(), patchI)
{
const fvsPatchScalarField& pLambda = lambdas.boundaryField()[pi];
const fvsPatchScalarField& pY = ys.boundaryField()[pi];
if (vf.boundaryField()[pi].coupled())
{
sf.boundaryField()[pi] =
pLambda*vf.boundaryField()[pi].patchInternalField()
+ pY*vf.boundaryField()[pi].patchNeighbourField();
}
else
{
sf.boundaryField()[pi] = vf.boundaryField()[pi];
}
vf.boundaryField()[patchI].patchInterpolate
(
sf,
lambdas.boundaryField()[patchI],
ys.boundaryField()[patchI]
);
}
tlambdas.clear();
@ -291,21 +284,15 @@ surfaceInterpolationScheme<Type>::interpolate
}
// Interpolate across coupled patches using given lambdas
forAll (lambdas.boundaryField(), pi)
// Code moved under virtual functions into fvPatchField
// HJ, 13/Jun/2013
forAll (vf.boundaryField(), patchI)
{
const fvsPatchScalarField& pLambda = lambdas.boundaryField()[pi];
if (vf.boundaryField()[pi].coupled())
{
tsf().boundaryField()[pi] =
pLambda*vf.boundaryField()[pi].patchInternalField()
+ (1.0 - pLambda)*vf.boundaryField()[pi].patchNeighbourField();
}
else
{
sf.boundaryField()[pi] = vf.boundaryField()[pi];
}
vf.boundaryField()[patchI].patchInterpolate
(
sf,
lambdas.boundaryField()[patchI]
);
}
tlambdas.clear();