I implemented a new wall function for mut which was derived from the analytic solution of SA model in near wall region proposed by Allmaras et al. (Eq.(33) in [1]).
2 source codes were created.
References
1. S.R. Allmaras, F.T. Johnson, P.R. Spalart, Modifications and Clarifications for the Implementation of the Spalart-Allmaras Turbulence Model, ICCFD7-1902, 7th International Conference on Computational Fluid Dynamics, 2012.
mutSAWallFunctionFvPatchScalarField.H
mutSAWallFunctionFvPatchScalarField.C
Wall Function profiles compared to u+ = y+ and u+ = 2.5*log(y+) + 5.45
2 source codes were created.
References
1. S.R. Allmaras, F.T. Johnson, P.R. Spalart, Modifications and Clarifications for the Implementation of the Spalart-Allmaras Turbulence Model, ICCFD7-1902, 7th International Conference on Computational Fluid Dynamics, 2012.
mutSAWallFunctionFvPatchScalarField.H
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | #ifndef compressibleMutSAWallFunctionFvPatchScalarField_H #define compressibleMutSAWallFunctionFvPatchScalarField_H #include "mutWallFunctionFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { namespace compressible { namespace RASModels { /*---------------------------------------------------------------------------*\ Class mutSAWallFunctionFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class mutSAWallFunctionFvPatchScalarField : public mutWallFunctionFvPatchScalarField { protected: // Protected data //- model constants scalar Bbar_; scalar a1_; scalar a2_; scalar b1_; scalar b2_; scalar c1_; scalar c2_; scalar c3_; scalar c4_; // Protected member functions //- Calculate yPLus virtual tmp<scalarField> calcYPlus(const scalarField& magUp) const; //- Calculate the turbulence viscosity virtual tmp<scalarField> calcMut() const; public: //- Runtime type information TypeName("mutSAWallFunction"); // Constructors //- Construct from patch and internal field mutSAWallFunctionFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>& ); //- Construct from patch, internal field and dictionary mutSAWallFunctionFvPatchScalarField ( const fvPatch&, const DimensionedField<scalar, volMesh>&, const dictionary& ); //- Construct by mapping given // mutSAWallFunctionFvPatchScalarField // onto a new patch mutSAWallFunctionFvPatchScalarField ( const mutSAWallFunctionFvPatchScalarField&, const fvPatch&, const DimensionedField<scalar, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy mutSAWallFunctionFvPatchScalarField ( const mutSAWallFunctionFvPatchScalarField& ); //- Construct and return a clone virtual tmp<fvPatchScalarField> clone() const { return tmp<fvPatchScalarField> ( new mutSAWallFunctionFvPatchScalarField(*this) ); } //- Construct as copy setting internal field reference mutSAWallFunctionFvPatchScalarField ( const mutSAWallFunctionFvPatchScalarField&, const DimensionedField<scalar, volMesh>& ); //- Construct and return a clone setting internal field reference virtual tmp<fvPatchScalarField> clone ( const DimensionedField<scalar, volMesh>& iF ) const { return tmp<fvPatchScalarField> ( new mutSAWallFunctionFvPatchScalarField(*this, iF) ); } // Member functions // Evaluation functions //- Calculate and return the yPlus at the boundary virtual tmp<scalarField> yPlus() const; // I-O //- Write virtual void write(Ostream& os) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace RASModels } // End namespace compressible } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* // |
mutSAWallFunctionFvPatchScalarField.C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | #include "mutSAWallFunctionFvPatchScalarField.H" #include "fvPatchFieldMapper.H" #include "volFields.H" #include "RASModel.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { namespace compressible { namespace RASModels { // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // tmp<scalarField> mutSAWallFunctionFvPatchScalarField::calcYPlus ( const scalarField& magUp ) const { const label patchi = patch().index(); const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const scalarField& y = rasModel.y()[patchi]; const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchi]; const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchi]; tmp<scalarField> tyPlus(new scalarField(patch().size(), 0.0)); scalarField& yPlus = tyPlus(); forAll(yPlus, faceI) { scalar Re = magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]); scalar yp = yPlusLam_; int iter = 0; scalar yPlusLast = 0.0; do { yPlusLast = yp; scalar f = Bbar_ + c1_*log(sqr(yp + a1_) + sqr(b1_)) - c2_*log(sqr(yp + a2_) + sqr(b2_)) - c3_*atan2(b1_, yp+a1_) - c4_*atan2(b2_, yp+a2_); yp = (Re + kappa_*yp)/(kappa_ + f); } while (mag(yp - yPlusLast) > 0.01 && ++iter < 10); yPlus[faceI] = max(0.0, yp); } return tyPlus; } tmp<scalarField> mutSAWallFunctionFvPatchScalarField::calcMut() const { const label patchi = patch().index(); const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchi]; const scalarField magUp = mag(Uw.patchInternalField() - Uw); const scalarField& muw = rasModel.mu().boundaryField()[patchi]; tmp<scalarField> tyPlus = calcYPlus(magUp); scalarField& yPlus = tyPlus(); tmp<scalarField> tmutw(new scalarField(patch().size(), 0.0)); scalarField& mutw = tmutw(); forAll(yPlus, faceI) { { scalar f = Bbar_ + c1_*log(sqr(yPlus[faceI] + a1_) + sqr(b1_)) - c2_*log(sqr(yPlus[faceI] + a2_) + sqr(b2_)) - c3_*atan2(b1_, yPlus[faceI]+a1_) - c4_*atan2(b2_, yPlus[faceI]+a2_); mutw[faceI] = max(muw[faceI]*(yPlus[faceI]/f - 1.0), scalar(0.0)); } } return tmutw; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutSAWallFunctionFvPatchScalarField::mutSAWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : mutWallFunctionFvPatchScalarField(p, iF), Bbar_(5.0333908790505579), a1_(8.148221580024245), a2_(-6.9287093849022945), b1_(7.4600876082527945), b2_(7.468145790401841), c1_(2.5496773539754747), c2_(1.3301651588535228), c3_(3.599459109332379), c4_(3.6397531868684494) {} mutSAWallFunctionFvPatchScalarField::mutSAWallFunctionFvPatchScalarField ( const mutSAWallFunctionFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const fvPatchFieldMapper& mapper ) : mutWallFunctionFvPatchScalarField(ptf, p, iF, mapper), Bbar_(ptf.Bbar_), a1_(ptf.a1_), a2_(ptf.a2_), b1_(ptf.b1_), b2_(ptf.b2_), c1_(ptf.c1_), c2_(ptf.c2_), c3_(ptf.c3_), c4_(ptf.c4_) {} mutSAWallFunctionFvPatchScalarField::mutSAWallFunctionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : mutWallFunctionFvPatchScalarField(p, iF, dict), Bbar_(dict.lookupOrDefault<scalar>("Bbar", 5.0333908790505579)), a1_(dict.lookupOrDefault<scalar>("a1", 8.148221580024245)), a2_(dict.lookupOrDefault<scalar>("a2", -6.9287093849022945)), b1_(dict.lookupOrDefault<scalar>("b1", 7.4600876082527945)), b2_(dict.lookupOrDefault<scalar>("b2", 7.468145790401841)), c1_(dict.lookupOrDefault<scalar>("c1", 2.5496773539754747)), c2_(dict.lookupOrDefault<scalar>("c2", 1.3301651588535228)), c3_(dict.lookupOrDefault<scalar>("c3", 3.599459109332379)), c4_(dict.lookupOrDefault<scalar>("c4", 3.6397531868684494)) {} mutSAWallFunctionFvPatchScalarField::mutSAWallFunctionFvPatchScalarField ( const mutSAWallFunctionFvPatchScalarField& wfpsf ) : mutWallFunctionFvPatchScalarField(wfpsf), Bbar_(wfpsf.Bbar_), a1_(wfpsf.a1_), a2_(wfpsf.a2_), b1_(wfpsf.b1_), b2_(wfpsf.b2_), c1_(wfpsf.c1_), c2_(wfpsf.c2_), c3_(wfpsf.c3_), c4_(wfpsf.c4_) {} mutSAWallFunctionFvPatchScalarField::mutSAWallFunctionFvPatchScalarField ( const mutSAWallFunctionFvPatchScalarField& wfpsf, const DimensionedField<scalar, volMesh>& iF ) : mutWallFunctionFvPatchScalarField(wfpsf, iF), Bbar_(wfpsf.Bbar_), a1_(wfpsf.a1_), a2_(wfpsf.a2_), b1_(wfpsf.b1_), b2_(wfpsf.b2_), c1_(wfpsf.c1_), c2_(wfpsf.c2_), c3_(wfpsf.c3_), c4_(wfpsf.c4_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // tmp<scalarField> mutSAWallFunctionFvPatchScalarField::yPlus() const { const label patchi = patch().index(); const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchi]; const scalarField magUp = mag(Uw.patchInternalField() - Uw); return calcYPlus(magUp); } void mutSAWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField<scalar>::write(os); writeLocalEntries(os); os.writeKeyword("Bbar") << Bbar_ << token::END_STATEMENT << nl; os.writeKeyword("a1") << a1_ << token::END_STATEMENT << nl; os.writeKeyword("a2") << a2_ << token::END_STATEMENT << nl; os.writeKeyword("b1") << b1_ << token::END_STATEMENT << nl; os.writeKeyword("b2") << b2_ << token::END_STATEMENT << nl; os.writeKeyword("c1") << c1_ << token::END_STATEMENT << nl; os.writeKeyword("c2") << c2_ << token::END_STATEMENT << nl; os.writeKeyword("c3") << c3_ << token::END_STATEMENT << nl; os.writeKeyword("c4") << c4_ << token::END_STATEMENT << nl; writeEntry("value", os); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField(fvPatchScalarField, mutSAWallFunctionFvPatchScalarField); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace RASModels } // End namespace compressible } // End namespace Foam // ************************************************************************* // |
Comments
Post a Comment