diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index bc3bab534d..905a565b0a 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -284,6 +284,16 @@ Foam::tmp > Foam::cyclicACMIFvPatchField::snGrad } +template +void Foam::cyclicACMIFvPatchField::updateCoeffs() +{ + const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + + const fvPatchField& npf = nonOverlapPatchField(); + const_cast&>(npf).updateCoeffs(mask); +} + + template void Foam::cyclicACMIFvPatchField::evaluate ( @@ -376,6 +386,20 @@ Foam::cyclicACMIFvPatchField::gradientBoundaryCoeffs() const } +template +void Foam::cyclicACMIFvPatchField::manipulateMatrix +( + fvMatrix& matrix +) +{ + // blend contrubutions from the coupled and non-overlap patches + const fvPatchField& npf = nonOverlapPatchField(); + + const scalarField& mask = cyclicACMIPatch_.cyclicACMIPatch().mask(); + const_cast&>(npf).manipulateMatrix(matrix, mask); +} + + template void Foam::cyclicACMIFvPatchField::write(Ostream& os) const { diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H index 9848505be1..91f414d321 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H @@ -178,12 +178,34 @@ public: //- Return reference to non-overlapping patchField const fvPatchField& nonOverlapPatchField() const; + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field&, + const Field&, + const scalarField&, + const Pstream::commsTypes commsType + ) const; + //- Return patch-normal gradient virtual tmp > snGrad ( const scalarField& deltaCoeffs ) const; + //- Update the coefficients associated with the patch field + void updateCoeffs(); + //- Evaluate the patch field virtual void evaluate ( @@ -226,24 +248,8 @@ public: // evaluation of the gradient of this patchField virtual tmp > gradientBoundaryCoeffs() const; - //- Update result field based on interface functionality - virtual void updateInterfaceMatrix - ( - scalarField& result, - const scalarField& psiInternal, - const scalarField& coeffs, - const direction cmpt, - const Pstream::commsTypes commsType - ) const; - - //- Update result field based on interface functionality - virtual void updateInterfaceMatrix - ( - Field&, - const Field&, - const scalarField&, - const Pstream::commsTypes commsType - ) const; + //- Manipulate matrix + virtual void manipulateMatrix(fvMatrix& matrix); // Cyclic AMI coupled interface functions diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index fa3d6d7a31..7fd83f41b1 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -42,6 +42,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), + manipulatedMatrix_(false), patchType_(word::null) {} @@ -58,6 +59,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), + manipulatedMatrix_(false), patchType_(word::null) {} @@ -75,6 +77,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), + manipulatedMatrix_(false), patchType_(ptf.patchType_) {} @@ -92,6 +95,7 @@ Foam::fvPatchField::fvPatchField patch_(p), internalField_(iF), updated_(false), + manipulatedMatrix_(false), patchType_(dict.lookupOrDefault("patchType", word::null)) { if (dict.found("value")) @@ -133,6 +137,7 @@ Foam::fvPatchField::fvPatchField patch_(ptf.patch_), internalField_(ptf.internalField_), updated_(false), + manipulatedMatrix_(false), patchType_(ptf.patchType_) {} @@ -148,6 +153,7 @@ Foam::fvPatchField::fvPatchField patch_(ptf.patch_), internalField_(iF), updated_(false), + manipulatedMatrix_(false), patchType_(ptf.patchType_) {} @@ -267,6 +273,28 @@ void Foam::fvPatchField::rmap } +template +void Foam::fvPatchField::updateCoeffs() +{ + updated_ = true; +} + + +template +void Foam::fvPatchField::updateCoeffs(const scalarField& weights) +{ + if (!updated_) + { + updateCoeffs(); + + Field& fld = *this; + fld *= weights; + + updated_ = true; + } +} + + template void Foam::fvPatchField::evaluate(const Pstream::commsTypes) { @@ -276,13 +304,25 @@ void Foam::fvPatchField::evaluate(const Pstream::commsTypes) } updated_ = false; + manipulatedMatrix_ = false; } template void Foam::fvPatchField::manipulateMatrix(fvMatrix& matrix) { - // do nothing + manipulatedMatrix_ = true; +} + + +template +void Foam::fvPatchField::manipulateMatrix +( + fvMatrix& matrix, + const scalarField& weights +) +{ + manipulatedMatrix_ = true; } diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 6047f1e4af..d3b2ed4e70 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -93,6 +93,10 @@ class fvPatchField // the construction of the matrix bool updated_; + //- Update index used so that manipulateMatrix is called only once + // during the construction of the matrix + bool manipulatedMatrix_; + //- Optional patch type, used to allow specified boundary conditions // to be applied to constraint patches by providing the constraint // patch type as 'patchType' @@ -327,6 +331,12 @@ public: return updated_; } + //- Return true if the matrix has already been manipulated + bool manipulatedMatrix() const + { + return manipulatedMatrix_; + } + // Mapping functions @@ -365,10 +375,12 @@ public: //- Update the coefficients associated with the patch field // Sets Updated to true - virtual void updateCoeffs() - { - updated_ = true; - } + virtual void updateCoeffs(); + + //- Update the coefficients associated with the patch field + // and apply weight field + // Sets Updated to true + virtual void updateCoeffs(const scalarField& weights); //- Return internal field next to patch as patch field virtual tmp > patchInternalField() const; @@ -479,6 +491,13 @@ public: //- Manipulate matrix virtual void manipulateMatrix(fvMatrix& matrix); + //- Manipulate matrix with given weights + virtual void manipulateMatrix + ( + fvMatrix& matrix, + const scalarField& weights + ); + // I-O diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C index 6e249d876f..30ae0adf37 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C @@ -342,6 +342,18 @@ Foam::label Foam::cyclicACMIPolyPatch::nonOverlapPatchID() const << exit(FatalError); } + if (nonOverlapPatchID_ < index()) + { + FatalErrorIn("cyclicPolyAMIPatch::neighbPatchID() const") + << "Boundary ordering error: " << type() + << " patch must be defined prior to its non-overlapping patch" + << nl + << type() << " patch: " << name() << ", ID:" << index() << nl + << "Non-overlap patch: " << nonOverlapPatchName_ + << ", ID:" << nonOverlapPatchID_ << nl + << exit(FatalError); + } + const polyPatch& noPp = this->boundaryMesh()[nonOverlapPatchID_]; bool ok = true; diff --git a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C index 55434df625..7846bec820 100644 --- a/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C +++ b/src/turbulenceModels/compressible/RAS/backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "backwardsCompatibilityWallFunctions.H" +#include "volFields.H" #include "calculatedFvPatchField.H" #include "alphatWallFunctionFvPatchScalarField.H" #include "mutkWallFunctionFvPatchScalarField.H" diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C index 84762e6beb..d079c811ea 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.C @@ -55,6 +55,67 @@ scalar epsilonLowReWallFunctionFvPatchScalarField::yPlusLam } +void epsilonLowReWallFunctionFvPatchScalarField::calculate +( + const turbulenceModel& turbulence, + const List& cornerWeights, + const fvPatch& patch, + scalarField& G, + scalarField& epsilon +) +{ + const label patchI = patch.index(); + + const scalarField& y = turbulence.y()[patchI]; + + const scalar Cmu25 = pow025(Cmu_); + const scalar Cmu75 = pow(Cmu_, 0.75); + + const tmp tk = turbulence.k(); + const volScalarField& k = tk(); + + const tmp tmu = turbulence.mu(); + const scalarField& muw = tmu().boundaryField()[patchI]; + + const tmp tmut = turbulence.mut(); + const volScalarField& mut = tmut(); + const scalarField& mutw = mut.boundaryField()[patchI]; + + const scalarField& rhow = turbulence.rho().boundaryField()[patchI]; + + const fvPatchVectorField& Uw = turbulence.U().boundaryField()[patchI]; + + const scalarField magGradUw(mag(Uw.snGrad())); + + // Set epsilon and G + forAll(mutw, faceI) + { + label cellI = patch.faceCells()[faceI]; + + scalar yPlus = Cmu25*sqrt(k[cellI])*y[faceI]/muw[faceI]/rhow[faceI]; + + scalar w = cornerWeights[faceI]; + + if (yPlus > yPlusLam_) + { + epsilon[cellI] = w*Cmu75*pow(k[cellI], 1.5)/(kappa_*y[faceI]); + } + else + { + epsilon[cellI] = + w*2.0*k[cellI]*muw[faceI]/rhow[faceI]/sqr(y[faceI]); + } + + G[cellI] = + w + *(mutw[faceI] + muw[faceI]) + *magGradUw[faceI] + *Cmu25*sqrt(k[cellI]) + /(kappa_*y[faceI]); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // epsilonLowReWallFunctionFvPatchScalarField:: @@ -119,84 +180,6 @@ epsilonLowReWallFunctionFvPatchScalarField {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void epsilonLowReWallFunctionFvPatchScalarField::updateCoeffs() -{ - if (updated()) - { - return; - } - - const label patchI = patch().index(); - - const turbulenceModel& turbulence = - db().lookupObject("turbulenceModel"); - const scalarField& y = turbulence.y()[patchI]; - - volScalarField& G = - const_cast - ( - db().lookupObject - ( - turbulence.GName() - ) - ); - - DimensionedField& epsilon = - const_cast&> - ( - dimensionedInternalField() - ); - - const tmp tk = turbulence.k(); - const volScalarField& k = tk(); - - const tmp tmu = turbulence.mu(); - const scalarField& muw = tmu().boundaryField()[patchI]; - - const tmp tmut = turbulence.mut(); - const volScalarField& mut = tmut(); - const scalarField& mutw = mut.boundaryField()[patchI]; - - const scalarField& rhow = turbulence.rho().boundaryField()[patchI]; - - const fvPatchVectorField& Uw = turbulence.U().boundaryField()[patchI]; - const scalarField magGradUw(mag(Uw.snGrad())); - - const scalar Cmu25 = pow025(Cmu_); - const scalar Cmu75 = pow(Cmu_, 0.75); - - // Set epsilon and G - forAll(mutw, faceI) - { - label faceCellI = patch().faceCells()[faceI]; - - scalar yPlus = Cmu25*sqrt(k[faceCellI])*y[faceI]/muw[faceI]/rhow[faceI]; - - if (yPlus > yPlusLam_) - { - epsilon[faceCellI] = Cmu75*pow(k[faceCellI], 1.5)/(kappa_*y[faceI]); - } - else - { - epsilon[faceCellI] = - 2.0*k[faceCellI]*muw[faceI]/rhow[faceI]/sqr(y[faceI]); - } - - G[faceCellI] = - (mutw[faceI] + muw[faceI]) - *magGradUw[faceI] - *Cmu25*sqrt(k[faceCellI]) - /(kappa_*y[faceI]); - } - - fixedInternalValueFvPatchField::updateCoeffs(); - - // TODO: perform averaging for cells sharing more than one boundary face -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H index 61434c29b5..c2f7cf178f 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonLowReWallFunction/epsilonLowReWallFunctionFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -97,6 +97,16 @@ protected: //- Calculate the Y+ at the edge of the laminar sublayer scalar yPlusLam(const scalar kappa, const scalar E); + //- Calculate the epsilon and G + virtual void calculate + ( + const turbulenceModel& turbulence, + const List& cornerWeights, + const fvPatch& patch, + scalarField& G, + scalarField& epsilon + ); + public: @@ -165,14 +175,6 @@ public: new epsilonLowReWallFunctionFvPatchScalarField(*this, iF) ); } - - - // Member functions - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); }; diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C index dc6296f2ed..5e78e48c97 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/epsilonWallFunctions/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C @@ -26,10 +26,10 @@ License #include "epsilonWallFunctionFvPatchScalarField.H" #include "compressible/turbulenceModel/turbulenceModel.H" #include "fvPatchFieldMapper.H" +#include "fvMatrix.H" #include "volFields.H" -#include "addToRunTimeSelectionTable.H" -#include "mutWallFunctionFvPatchScalarField.H" #include "wallFvPatch.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -62,6 +62,193 @@ void epsilonWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const } +void epsilonWallFunctionFvPatchScalarField::setMaster() +{ + if (master_ != -1) + { + return; + } + + const volScalarField& epsilon = + static_cast(this->dimensionedInternalField()); + + const volScalarField::GeometricBoundaryField& bf = epsilon.boundaryField(); + + label master = -1; + forAll(bf, patchI) + { + if (isA(bf[patchI])) + { + epsilonWallFunctionFvPatchScalarField& epf = epsilonPatch(patchI); + + if (master == -1) + { + master = patchI; + } + + epf.master() = master; + } + } +} + + +void epsilonWallFunctionFvPatchScalarField::createAveragingWeights() +{ + if (initialised_) + { + return; + } + + const volScalarField& epsilon = + static_cast(this->dimensionedInternalField()); + + const volScalarField::GeometricBoundaryField& bf = epsilon.boundaryField(); + + const fvMesh& mesh = epsilon.mesh(); + + volScalarField weights + ( + IOobject + ( + "weights", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // do not register + ), + mesh, + dimensionedScalar("zero", dimless, 0.0) + ); + + DynamicList