void Foam::porousBafflePressureFvPatchField::updateCoeffs() { if (updated()) { return; } const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>(phiName_); const fvsPatchField<scalar>& phip = patch().patchField<surfaceScalarField, scalar>(phi); scalarField Un(phip/patch().magSf()); if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_); } scalarField magUn(mag(Un)); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, internalField().group() ) ); jump_ = -sign(Un) *( D_*turbModel.nu(patch().index()) + I_*0.5*magUn )*magUn*length_; if (internalField().dimensions() == dimPressure) { jump_ *= patch().lookupPatchField<volScalarField, scalar>(rhoName_); } if (debug) { scalar avePressureJump = gAverage(jump_); scalar aveVelocity = gAverage(mag(Un)); Info<< patch().boundaryMesh().mesh().name() << ':' << patch().name() << ':' << " Average pressure drop :" << avePressureJump << " Average velocity :" << aveVelocity << endl; } fixedJumpFvPatchField<scalar>::updateCoeffs(); }
tmp<vectorField> atmBoundaryLayer::U(const vectorField& p) const { scalarField Un ( (Ustar_/kappa_) *log(((zDir_ & p) - zGround_ + z0_)/z0_) ); return flowDir_*Un; }
void myMovingWallVelocityFvPatchVectorField::updateCoeffs() { if ( updated() ) { return; } // Info << "void myMovingWallVelocityFvPatchVectorField::updateCoeffs()" <<endl; const fvMesh & mesh = dimensionedInternalField().mesh(); const fvPatch & p = patch(); const polyPatch & pp = p.patch(); if ( myTimeIndex_ < mesh.time().timeIndex() ) { oldoldFc_ = oldFc_; oldFc_ = Fc_; Fc_ = pp.faceCentres(); myTimeIndex_ = mesh.time().timeIndex(); } // const pointField& oldPoints = mesh.oldPoints(); const volVectorField & U = mesh.lookupObject<volVectorField>( dimensionedInternalField().name() ); scalar deltaT = mesh.time().deltaT().value(); scalar deltaT0 = mesh.time().deltaT0().value(); if ( U.oldTime().timeIndex() == U.oldTime().oldTime().timeIndex() || U.oldTime().oldTime().timeIndex() < 0 ) { deltaT0 = GREAT; } // Set coefficients based on deltaT and deltaT0 scalar coefft = 1 + deltaT / (deltaT + deltaT0); scalar coefft00 = deltaT * deltaT / ( deltaT0 * (deltaT + deltaT0) ); scalar coefft0 = coefft + coefft00; tmp<vectorField> Up = (coefft * Fc_ - coefft0 * oldFc_ + coefft00 * oldoldFc_) / mesh.time().deltaT().value(); scalarField phip = p.patchField<surfaceScalarField, scalar>( fvc::meshPhi( U ) ); tmp<vectorField> n = p.nf(); const scalarField & magSf = p.magSf(); tmp<scalarField> Un = phip / (magSf + VSMALL); vectorField::operator=( Up() + n() *( Un() - ( n() & Up() ) ) ); fixedValueFvPatchVectorField::updateCoeffs(); }
void Foam::fanFvPatchField<Foam::scalar>::calcFanJump() { if (this->cyclicPatch().owner()) { const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>(phiName_); const fvsPatchField<scalar>& phip = patch().patchField<surfaceScalarField, scalar>(phi); scalarField Un(max(phip/patch().magSf(), scalar(0))); if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_); } this->jump_ = max(this->jumpTable_->value(Un), scalar(0)); } }
void Foam::porousBafflePressureFvPatchField<Foam::scalar>::updateCoeffs() { if (updated()) { return; } const label patchI = patch().index(); const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>("phi"); const fvsPatchField<scalar>& phip = patch().patchField<surfaceScalarField, scalar>(phi); scalarField Un(phip/patch().magSf()); scalarField magUn(mag(Un)); if (phi.dimensions() == dimensionSet(0, 3, -1, 0, 0)) { const incompressible::turbulenceModel& turbModel = db().lookupObject<incompressible::turbulenceModel> ( "turbulenceModel" ); const scalarField nuEffw = turbModel.nuEff()().boundaryField()[patchI]; jump_ = -sign(Un)*(I_*nuEffw + D_*0.5*magUn*length_)*magUn; } else { const compressible::turbulenceModel& turbModel = db().lookupObject<compressible::turbulenceModel> ( "turbulenceModel" ); const scalarField muEffw = turbModel.muEff()().boundaryField()[patchI]; const scalarField rhow = patch().lookupPatchField<volScalarField, scalar>("rho"); Un /= rhow; jump_ = -sign(Un)*(I_*muEffw + D_*0.5*rhow*magUn*length_)*magUn; } if (debug) { scalar avePressureJump = gAverage(jump_); scalar aveVelocity = gAverage(mag(Un)); Info<< patch().boundaryMesh().mesh().name() << ':' << patch().name() << ':' << " Average pressure drop :" << avePressureJump << " Average velocity :" << aveVelocity << endl; } fixedJumpFvPatchField<scalar>::updateCoeffs(); }
// <int Order_s, int Order_p, int Order_t> void Convection ::initLinearOperator2( sparse_matrix_ptrtype& L ) { boost::timer ti; LOG(INFO) << "[initLinearOperator2] start\n"; mesh_ptrtype mesh = Xh->mesh(); element_type U( Xh, "u" ); element_type Un( Xh, "un" ); element_type V( Xh, "v" ); element_0_type u = U. element<0>(); // fonction vitesse element_0_type un = Un. element<0>(); // fonction vitesse element_0_type v = V. element<0>(); // fonction test vitesse element_1_type p = U. element<1>(); // fonction pression element_1_type pn = Un. element<1>(); // fonction pression element_1_type q = V. element<1>(); // fonction test pression element_2_type t = U. element<2>(); // fonction temperature element_2_type tn = Un. element<2>(); // fonction temperature element_2_type s = V. element<2>(); // fonction test temperature #if defined( FEELPP_USE_LM ) element_3_type xi = U. element<3>(); // fonction multipliers element_3_type eta = V. element<3>(); // fonction test multipliers #endif double gr= M_current_Grashofs; double sqgr( 1/math::sqrt( gr ) ); double pr = M_current_Prandtl; double sqgrpr( 1/( pr*math::sqrt( gr ) ) ); double gamma( this->vm()["penalbc"]. as<double>() ); double k=this->vm()["k"]. as<double>(); double nu=this->vm()["nu"]. as<double>(); double rho=this->vm()["rho"]. as<double>(); //double dt=this->vm()["dt"]. as<double>(); int adim=this->vm()["adim"]. as<int>(); int weakdir=this->vm()["weakdir"]. as<int>(); //choix de la valeur des paramètres dimensionnés ou adimensionnés double a=0.0,b=0.0,c=0.0; double pC=1; if ( adim == 0 ) pC = this->vm()["pC"]. as<double>(); if ( adim==1 ) { a=1; b=sqgr; c=sqgrpr; } else { a=rho; b=nu; c=k; } double expansion = 1; if ( adim == 0 ) expansion=3.7e-3; auto bf = form2( _test=Xh, _trial=Xh, _matrix=L ); // Temperature #if CONVECTION_DIM==2 // buyoancy forces c(theta,v) bf +=integrate( _range=elements( mesh ), _expr=-expansion*idt( t )*( trans( vec( constant( 0. ),constant( 1.0 ) ) )*id( v ) ) ); #else bf +=integrate( _range=elements( mesh ), _expr=-expansion*idt( t )*( trans( vec( cst(0.), constant( 0. ),constant( 1.0 ) ) )*id( v ) ) ); #endif LOG(INFO) << "[initLinearOperator] temperature Force terms done\n"; // heat conduction/diffusion: e(beta1,theta,chi)+f(theta,chi) bf += integrate( _range=elements( mesh ), _expr=cst( c )*gradt( t )*trans( grad( s ) ) ); LOG(INFO) << "[initLinearOperator] Temperature Diffusion terms done\n"; if ( weakdir == 1 ) { // weak Dirichlet on temperature (T=0|left wall) bf += integrate ( markedfaces( mesh, "Tfixed" ), - gradt( t )*N()*id( s )*cst_ref( sqgrpr ) ); bf += integrate ( markedfaces( mesh, "Tfixed" ), - grad( s )*N()*idt( t )*cst_ref( sqgrpr ) ); bf += integrate ( markedfaces( mesh, "Tfixed" ), gamma*idt( t )*id( s )/hFace() ); } LOG(INFO) << "[initLinearOperator2] done in " << ti.elapsed() << "s\n"; }