volScalarField dynOneEqEddy::ck ( const volSymmTensorField& D, const volScalarField& KK ) const { const volSymmTensorField LL ( simpleFilter_(dev(filter_(sqr(U())) - (sqr(filter_(U()))))) ); const volSymmTensorField MM ( simpleFilter_(-2.0*delta()*sqrt(KK)*filter_(D)) ); const volScalarField ck ( simpleFilter_(0.5*(LL && MM)) /( simpleFilter_(magSqr(MM)) + dimensionedScalar("small", sqr(MM.dimensions()), VSMALL) ) ); tmp<volScalarField> tfld = 0.5*(mag(ck) + ck); return tfld(); }
volScalarField dynamicKEqn<BasicTurbulenceModel>::Ck ( const volSymmTensorField& D, const volScalarField& KK ) const { const volSymmTensorField LL ( simpleFilter_(dev(filter_(sqr(this->U_)) - (sqr(filter_(this->U_))))) ); const volSymmTensorField MM ( simpleFilter_(-2.0*this->delta()*sqrt(KK)*filter_(D)) ); const volScalarField Ck ( simpleFilter_(0.5*(LL && MM)) /( simpleFilter_(magSqr(MM)) + dimensionedScalar("small", sqr(MM.dimensions()), VSMALL) ) ); tmp<volScalarField> tfld = 0.5*(mag(Ck) + Ck); return tfld(); }
void Foam::functionObjects::wallShearStress::calcShearStress ( const volSymmTensorField& Reff, volVectorField& shearStress ) { shearStress.dimensions().reset(Reff.dimensions()); forAllConstIter(labelHashSet, patchSet_, iter) { label patchi = iter.key(); vectorField& ssp = shearStress.boundaryFieldRef()[patchi]; const vectorField& Sfp = mesh_.Sf().boundaryField()[patchi]; const scalarField& magSfp = mesh_.magSf().boundaryField()[patchi]; const symmTensorField& Reffp = Reff.boundaryField()[patchi]; ssp = (-Sfp/magSfp) & Reffp; }
int main(int argc, char *argv[]) { timeSelector::addOptions(); #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); #include "createMesh.H" #include "createFields.H" forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; // Cache the turbulence fields Info<< "\nRetrieving field k from turbulence model" << endl; const volScalarField k = RASModel->k(); Info<< "\nRetrieving field epsilon from turbulence model" << endl; const volScalarField epsilon = RASModel->epsilon(); Info<< "\nRetrieving field R from turbulence model" << endl; const volSymmTensorField R = RASModel->R(); // Check availability of tubulence fields if (!IOobject("k", runTime.timeName(), mesh).headerOk()) { Info<< "\nWriting turbulence field k" << endl; k.write(); } else { Info<< "\nTurbulence k field already exists" << endl; } if (!IOobject("epsilon", runTime.timeName(), mesh).headerOk()) { Info<< "\nWriting turbulence field epsilon" << endl; epsilon.write(); } else { Info<< "\nTurbulence epsilon field already exists" << endl; } if (!IOobject("R", runTime.timeName(), mesh).headerOk()) { Info<< "\nWriting turbulence field R" << endl; R.write(); } else { Info<< "\nTurbulence R field already exists" << endl; } if (!IOobject("omega", runTime.timeName(), mesh).headerOk()) { const scalar Cmu = 0.09; Info<< "creating omega" << endl; volScalarField omega ( IOobject ( "omega", runTime.timeName(), mesh ), epsilon/(Cmu*k), epsilon.boundaryField().types() ); Info<< "\nWriting turbulence field omega" << endl; omega.write(); } else { Info<< "\nTurbulence omega field already exists" << endl; } }
tmp<fvVectorMatrix> surfaceShearForce::correct(volVectorField& U) { // local reference to film model const kinematicSingleLayer& film = static_cast<const kinematicSingleLayer&>(owner_); // local references to film fields const volScalarField& mu = film.mu(); const volVectorField& Uw = film.Uw(); const volScalarField& delta = film.delta(); const volVectorField& Up = film.UPrimary(); // film surface linear coeff to apply to velocity tmp<volScalarField> tCs; typedef compressible::turbulenceModel turbModel; if (film.primaryMesh().foundObject<turbModel>("turbulenceProperties")) { // local reference to turbulence model const turbModel& turb = film.primaryMesh().lookupObject<turbModel>("turbulenceProperties"); // calculate and store the stress on the primary region const volSymmTensorField primaryReff(turb.devRhoReff()); // create stress field on film // - note boundary condition types (mapped) // - to map, the field name must be the same as the field on the // primary region volSymmTensorField Reff ( IOobject ( primaryReff.name(), film.regionMesh().time().timeName(), film.regionMesh(), IOobject::NO_READ, IOobject::NO_WRITE ), film.regionMesh(), dimensionedSymmTensor ( "zero", primaryReff.dimensions(), symmTensor::zero ), film.mappedFieldAndInternalPatchTypes<symmTensor>() ); // map stress from primary region to film region Reff.correctBoundaryConditions(); dimensionedScalar U0("SMALL", U.dimensions(), SMALL); tCs = Cf_*mag(-film.nHat() & Reff)/(mag(Up - U) + U0); } else { // laminar case - employ simple coeff-based model const volScalarField& rho = film.rho(); tCs = Cf_*rho*mag(Up - U); } dimensionedScalar d0("SMALL", delta.dimensions(), SMALL); // linear coeffs to apply to velocity const volScalarField& Cs = tCs(); volScalarField Cw("Cw", mu/(0.3333*(delta + d0))); Cw.min(1.0e+06); return ( - fvm::Sp(Cs, U) + Cs*Up // surface contribution - fvm::Sp(Cw, U) + Cw*Uw // wall contribution ); }