void buoyantPressureFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const uniformDimensionedVectorField& g = db().lookupObject<uniformDimensionedVectorField>("g"); const fvPatchField<scalar>& rho = patch().lookupPatchField<volScalarField, scalar>(rhoName_); // If the variable name is "p_rgh", "ph_rgh" or "pd" // assume it is p? - rho*g.h and set the gradient appropriately. // Otherwise assume the variable is the static pressure. if ( dimensionedInternalField().name() == "p_rgh" || dimensionedInternalField().name() == "ph_rgh" || dimensionedInternalField().name() == "pd" ) { gradient() = -rho.snGrad()*(g.value() & patch().Cf()); } else { gradient() = rho*(g.value() & patch().nf()); } fixedGradientFvPatchScalarField::updateCoeffs(); }
Foam::turbulentTemperatureCoupledBaffleFvPatchScalarField:: turbulentTemperatureCoupledBaffleFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : fixedValueFvPatchScalarField(p, iF, dict), neighbourFieldName_(dict.lookup("neighbourFieldName")), KName_(dict.lookup("K")) { if (!isA<directMappedPatchBase>(this->patch().patch())) { FatalErrorIn ( "turbulentTemperatureCoupledBaffleFvPatchScalarField::" "turbulentTemperatureCoupledBaffleFvPatchScalarField\n" "(\n" " const fvPatch& p,\n" " const DimensionedField<scalar, volMesh>& iF,\n" " const dictionary& dict\n" ")\n" ) << "\n patch type '" << p.type() << "' not type '" << directMappedPatchBase::typeName << "'" << "\n for patch " << p.name() << " of field " << dimensionedInternalField().name() << " in file " << dimensionedInternalField().objectPath() << exit(FatalError); } }
filmPyrolysisRadiativeCoupledMixedFvPatchScalarField:: filmPyrolysisRadiativeCoupledMixedFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), dict), filmRegionName_ ( dict.lookupOrDefault<word>("filmRegion", "surfaceFilmProperties") ), pyrolysisRegionName_ ( dict.lookupOrDefault<word>("pyrolysisRegion", "pyrolysisProperties") ), TnbrName_(dict.lookup("Tnbr")), QrName_(dict.lookup("Qr")), convectiveScaling_(dict.lookupOrDefault<scalar>("convectiveScaling", 1.0)), filmDeltaDry_(readScalar(dict.lookup("filmDeltaDry"))), filmDeltaWet_(readScalar(dict.lookup("filmDeltaWet"))) { if (!isA<mappedPatchBase>(this->patch().patch())) { FatalErrorIn ( "filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::" "filmPyrolysisRadiativeCoupledMixedFvPatchScalarField\n" "(\n" " const fvPatch& p,\n" " const DimensionedField<scalar, volMesh>& iF,\n" " const dictionary& dict\n" ")\n" ) << "\n patch type '" << p.type() << "' not type '" << mappedPatchBase::typeName << "'" << "\n for patch " << p.name() << " of field " << dimensionedInternalField().name() << " in file " << dimensionedInternalField().objectPath() << exit(FatalError); } fvPatchScalarField::operator=(scalarField("value", dict, p.size())); if (dict.found("refValue")) { // Full restart refValue() = scalarField("refValue", dict, p.size()); refGrad() = scalarField("refGradient", dict, p.size()); valueFraction() = scalarField("valueFraction", dict, p.size()); } else { // Start from user entered data. Assume fixedValue. refValue() = *this; refGrad() = 0.0; valueFraction() = 1.0; } }
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() == dimensionSet(0, 3, -1, 0, 0)) { Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_); } scalarField magUn(mag(Un)); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, dimensionedInternalField().group() ) ); jump_ = -sign(Un) *( D_*turbModel.nu(patch().index()) + I_*0.5*magUn )*magUn*length_; if (dimensionedInternalField().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(); }
thermalBaffle1DFvPatchScalarField<solidType>:: thermalBaffle1DFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : mixedFvPatchScalarField(p, iF), TName_("T"), baffleActivated_(readBool(dict.lookup("baffleActivated"))), thickness_(scalarField("thickness", dict, p.size())), Qs_(scalarField("Qs", dict, p.size())), solidDict_(dict), solidPtr_(new solidType(dict)) { if (!isA<mappedPatchBase>(this->patch().patch())) { FatalErrorIn ( "thermalBaffle1DFvPatchScalarField::" "thermalBaffle1DFvPatchScalarField" "(" "const fvPatch&,\n" "const DimensionedField<scalar, volMesh>&, " "const dictionary&" ")" ) << "\n patch type '" << patch().type() << "' not type '" << mappedPatchBase::typeName << "'" << "\n for patch " << patch().name() << " of field " << dimensionedInternalField().name() << " in file " << dimensionedInternalField().objectPath() << exit(FatalError); } fvPatchScalarField::operator=(scalarField("value", dict, p.size())); if (dict.found("refValue") && baffleActivated_) { // Full restart refValue() = scalarField("refValue", dict, p.size()); refGrad() = scalarField("refGradient", dict, p.size()); valueFraction() = scalarField("valueFraction", dict, p.size()); } else { // Start from user entered data. Assume zeroGradient. refValue() = *this; refGrad() = 0.0; valueFraction() = 0.0; } }
CFDHAMfluidMoistureCoupledMixedFvPatchScalarField:: CFDHAMfluidMoistureCoupledMixedFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), dict), wnbrName_(dict.lookupOrDefault<word>("wnbr", "none")), TnbrName_(dict.lookupOrDefault<word>("Tnbr", "none")), QrNbrName_(dict.lookupOrDefault<word>("QrNbr", "none")), QrName_(dict.lookupOrDefault<word>("Qr", "none")), QsNbrName_(dict.lookupOrDefault<word>("QsNbr", "none")), QsName_(dict.lookupOrDefault<word>("Qs", "none")) { if (!isA<mappedPatchBase>(this->patch().patch())) { FatalErrorIn ( "CFDHAMfluidMoistureCoupledMixedFvPatchScalarField::" "CFDHAMfluidMoistureCoupledMixedFvPatchScalarField\n" "(\n" " const fvPatch& p,\n" " const DimensionedField<scalar, volMesh>& iF,\n" " const dictionary& dict\n" ")\n" ) << "\n patch type '" << p.type() << "' not type '" << mappedPatchBase::typeName << "'" << "\n for patch " << p.name() << " of field " << dimensionedInternalField().name() << " in file " << dimensionedInternalField().objectPath() << exit(FatalError); } fvPatchScalarField::operator=(scalarField("value", dict, p.size())); if (dict.found("refValue")) { // Full restart refValue() = scalarField("refValue", dict, p.size()); refGrad() = scalarField("refGradient", dict, p.size()); valueFraction() = scalarField("valueFraction", dict, p.size()); } else { // Start from user entered data. Assume fixedValue. refValue() = *this; refGrad() = 0.0; valueFraction() = 1.0; } }
surfaceChargeCoupledFvPatchScalarField:: surfaceChargeCoupledFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : mixedFvPatchScalarField(p, iF), temperatureCoupledBase(patch(), dict), neighbourFieldName_(dict.lookup("neighbourFieldName")), surfCharge_(readScalar(dict.lookup("surfaceCharge"))), myEpr_(readScalar(dict.lookup("myEpr"))), nbrEpr_(readScalar(dict.lookup("nbrEpr"))) { if (!isA<mappedPatchBase>(this->patch().patch())) { FatalErrorIn ( "surfaceChargeCoupledFvPatchScalarField::" "surfaceChargeCoupledFvPatchScalarField\n" "(\n" " const fvPatch& p,\n" " const DimensionedField<scalar, volMesh>& iF,\n" " const dictionary& dict\n" ")\n" ) << "\n patch type '" << p.type() << "' not type '" << mappedPatchBase::typeName << "'" << "\n for patch " << p.name() << " of field " << dimensionedInternalField().name() << " in file " << dimensionedInternalField().objectPath() << exit(FatalError); } fvPatchScalarField::operator=(scalarField("value", dict, p.size())); if (dict.found("refValue")) { // Full restart refValue() = scalarField("refValue", dict, p.size()); refGrad() = scalarField("refGradient", dict, p.size()); valueFraction() = scalarField("valueFraction", dict, p.size()); } else { // Start from user entered data. Assume fixedValue. refValue() = *this; refGrad() = 0.0; valueFraction() = 1.0; } }
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 turbulentMixingLengthFrequencyInletFvPatchScalarField::updateCoeffs() { if (updated()) { return; } // Lookup Cmu corresponding to the turbulence model selected const turbulenceModel& turbulence = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, dimensionedInternalField().group() ) ); const scalar Cmu = turbulence.coeffDict().lookupOrDefault<scalar>("Cmu", 0.09); const scalar Cmu25 = pow(Cmu, 0.25); const fvPatchScalarField& kp = patch().lookupPatchField<volScalarField, scalar>(kName_); const fvsPatchScalarField& phip = patch().lookupPatchField<surfaceScalarField, scalar>(this->phiName_); this->refValue() = sqrt(kp)/(Cmu25*mixingLength_); this->valueFraction() = 1.0 - pos(phip); inletOutletFvPatchScalarField::updateCoeffs(); }
solidDirectionMixedFvPatchVectorField::solidDirectionMixedFvPatchVectorField ( const fvPatch& p, const DimensionedField<vector, volMesh>& iF, const dictionary& dict ) : directionMixedFvPatchVectorField(p, iF, dict), fieldName_(dimensionedInternalField().name()) { Field<vector> normalValue = transform(valueFraction(), refValue()); Field<vector> gradValue = this->patchInternalField() + refGrad()/this->patch().deltaCoeffs(); //- non-ortho corrected gradValue //- gradField will not have been created so I must do this during updateCoeffs /*const fvPatchField<tensor>& gradField = patch().lookupPatchField<volTensorField, tensor>("grad(" +fieldName_ + ")"); vectorField n = patch().nf(); vectorField delta = patch().delta(); vectorField k = delta - n*(n&delta); Field<vector> gradValue = this->patchInternalField() + (k&gradField.patchInternalField()) + refGrad()/this->patch().deltaCoeffs(); */ Field<vector> transformGradValue = transform(I - valueFraction(), gradValue); Field<vector>::operator=(normalValue + transformGradValue); }
void Foam::fixedShearStressFvPatchVectorField::updateCoeffs() { if (updated()) { return; } const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, dimensionedInternalField().group() ) ); scalarField nuEff(turbModel.nuEff()()[patch().index()]); const vectorField Uc(patchInternalField()); vector tauHat = tau0_/(mag(tau0_) + ROOTVSMALL); const scalarField& ry = patch().deltaCoeffs(); operator==(tauHat*(tauHat & (tau0_*(1.0/(ry*nuEff)) + Uc))); fixedValueFvPatchVectorField::updateCoeffs(); }
void Foam::backwardDiffusionFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const label patchi = patch().index(); // Calculating alfa const volVectorField& U = db().lookupObject<volVectorField>("U"); tmp<vectorField> n = patch().nf(); alfa() = -(n & U.boundaryField()[patchi]); // Calculating eta const volScalarField& rho = db().lookupObject<volScalarField>("rho"); eta() = rho0() / rho.boundaryField()[patchi]; nameInternal_ = dimensionedInternalField().name(); bool soretEffect = db().foundObject<volScalarField>("gas::Dsoret_" + nameInternal_); // Calculating epsilon if (soretEffect == true) { const volScalarField& Dsoret = db().lookupObject<volScalarField>("gas::Dsoret_" + nameInternal_); const volScalarField& T = db().lookupObject<volScalarField>("T"); epsilon() = -T.boundaryField()[patchi].snGrad() / T.boundaryField()[patchi] * Dsoret.boundaryField()[patchi]; } else { epsilon() = 0.; } // Calculating beta nameInternal_ = dimensionedInternalField().name(); const volScalarField& Dmix = db().lookupObject<volScalarField>("gas::Dmix_" + nameInternal_); beta() = Dmix.boundaryField()[patchi]*this->patch().deltaCoeffs(); if (debug) { } mixedUserDefinedFvPatchScalarField::updateCoeffs(); }
void movingWallVelocityFvPatchVectorField::updateCoeffs() { if (updated()) { return; } const fvMesh& mesh = dimensionedInternalField().mesh(); if (mesh.changing()) { const fvPatch& p = patch(); const polyPatch& pp = p.patch(); const pointField& oldPoints = mesh.oldPoints(); vectorField oldFc(pp.size()); forAll(oldFc, i) { oldFc[i] = pp[i].centre(oldPoints); } // Get wall-parallel mesh motion velocity from geometry vectorField Up = (pp.faceCentres() - oldFc)/mesh.time().deltaT().value(); const volVectorField& U = mesh.lookupObject<volVectorField> ( dimensionedInternalField().name() ); scalarField phip = p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U)); vectorField n = p.nf(); const scalarField& magSf = p.magSf(); scalarField Un = phip/(magSf + VSMALL); // Adjust for surface-normal mesh motion flux vectorField::operator=(Up + n*(Un - (n & Up))); }
myMovingWallVelocityFvPatchVectorField::myMovingWallVelocityFvPatchVectorField( const fvPatch & p, const DimensionedField<vector, volMesh> & iF ) : fixedValueFvPatchVectorField( p, iF ), myTimeIndex_( dimensionedInternalField().mesh().time().timeIndex() ), Fc_( p.patch().size(), vector::zero ), oldFc_( p.patch().size(), vector::zero ), oldoldFc_( p.patch().size(), vector::zero ) {}
tmp<scalargpuField> nutURoughWallFunctionFvPatchScalarField::calcNut() const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, dimensionedInternalField().group() ) ); const scalargpuField& y = turbModel.y()[patchi]; const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const tmp<scalargpuField> tnuw = turbModel.nu(patchi); const scalargpuField& nuw = tnuw(); // The flow velocity at the adjacent cell centre const scalargpuField magUp(mag(Uw.patchInternalField() - Uw)); tmp<scalargpuField> tyPlus = calcYPlus(magUp); scalargpuField& yPlus = tyPlus(); tmp<scalargpuField> tnutw(new scalargpuField(patch().size(), 0.0)); scalargpuField& nutw = tnutw(); thrust::transform ( y.begin(), y.end(), thrust::make_zip_iterator(thrust::make_tuple ( yPlus.begin(), nuw.begin(), magUp.begin() )), nutw.begin(), nutURoughCalcNutFunctor(yPlusLam_) ); /* forAll(yPlus, facei) { if (yPlus[facei] > yPlusLam_) { const scalar Re = magUp[facei]*y[facei]/nuw[facei] + ROOTVSMALL; nutw[facei] = nuw[facei]*(sqr(yPlus[facei])/Re - 1); } } */ return tnutw; }
timeVaryingSolidTractionFvPatchVectorField:: timeVaryingSolidTractionFvPatchVectorField ( const fvPatch& p, const DimensionedField<vector, volMesh>& iF, const dictionary& dict ) : solidTractionFvPatchVectorField(p, iF), timeSeries_(dict) { fieldName() = dimensionedInternalField().name(); traction() = vector::zero; pressure() = 0.0; nonLinear() = nonLinearGeometry::nonLinearNames_.read(dict.lookup("nonLinear")); //- the leastSquares has zero non-orthogonal correction //- on the boundary //- so the gradient scheme should be extendedLeastSquares if ( Foam::word ( dimensionedInternalField().mesh().schemesDict().gradScheme ( "grad(" + fieldName() + ")" ) ) != "extendedLeastSquares" ) { Warning << "The gradScheme for " << fieldName() << " should be \"extendedLeastSquares 0\" for the boundary " << "non-orthogonal correction to be right" << endl; } }
tmp<scalarField> nutUWallFunctionFvPatchScalarField::yPlus() const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, dimensionedInternalField().group() ) ); const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi]; const scalarField magUp(mag(Uw.patchInternalField() - Uw)); return calcYPlus(magUp); }
Foam::backwardDiffusionFvPatchScalarField::backwardDiffusionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF ) : mixedUserDefinedFvPatchScalarField(p, iF) { alfa() = 0.0; beta() = 0.0; eta() = 0.0; omega0() = 0.0; rho0() = 0.0; epsilon() = 0.0; nameInternal_ = dimensionedInternalField().name(); }
void Foam::mixedEnthalpyFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const basicThermo& thermo = db().lookupObject<basicThermo> ( "thermophysicalProperties" ); const label patchi = patch().index(); mixedFvPatchScalarField& Tw = refCast<mixedFvPatchScalarField> ( const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]) ); Tw.evaluate(); valueFraction() = Tw.valueFraction(); if (dimensionedInternalField().name() == "h") { refValue() = thermo.h(Tw.refValue(), patchi); refGrad() = thermo.Cp(Tw, patchi)*Tw.refGrad() + patch().deltaCoeffs()* ( thermo.h(Tw, patchi) - thermo.h(Tw, patch().faceCells()) ); } else { refValue() = thermo.hs(Tw.refValue(), patchi); refGrad() = thermo.Cp(Tw, patchi)*Tw.refGrad() + patch().deltaCoeffs()* ( thermo.hs(Tw, patchi) - thermo.hs(Tw, patch().faceCells()) ); } mixedFvPatchScalarField::updateCoeffs(); }
void Foam::movingWallVelocityFvPatchVectorField::updateCoeffs() { if (updated()) { return; } const fvPatch& p = patch(); const polyPatch& pp = p.patch(); const fvMesh& mesh = dimensionedInternalField().mesh(); const pointField& oldPoints = mesh.oldPoints(); vectorField oldFc(pp.size()); forAll(oldFc, i) { oldFc[i] = pp[i].centre(oldPoints); }
myMovingWallVelocityFvPatchVectorField::myMovingWallVelocityFvPatchVectorField( const fvPatch & p, const DimensionedField<vector, volMesh> & iF, const dictionary & dict ) : fixedValueFvPatchVectorField( p, iF ), myTimeIndex_( dimensionedInternalField().mesh().time().timeIndex() ), Fc_( p.patch().size(), vector::zero ), oldFc_( p.patch().size(), vector::zero ), oldoldFc_( p.patch().size(), vector::zero ) { fvPatchVectorField::operator=( vectorField( "value", dict, p.size() ) ); Fc_ = p.patch().faceCentres(); oldFc_ = p.patch().faceCentres(); oldoldFc_ = p.patch().faceCentres(); }
void Foam::gradientEnthalpyFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const basicThermo& thermo = db().lookupObject<basicThermo> ( "thermophysicalProperties" ); const label patchi = patch().index(); fvPatchScalarField& Tw = const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]); Tw.evaluate(); if (dimensionedInternalField().name() == "h") { gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() + patch().deltaCoeffs()* ( thermo.h(Tw, patchi) - thermo.h(Tw, patch().faceCells()) ); } else { gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad() + patch().deltaCoeffs()* ( thermo.hs(Tw, patchi) - thermo.hs(Tw, patch().faceCells()) ); } fixedGradientFvPatchScalarField::updateCoeffs(); }
Foam::backwardDiffusionFvPatchScalarField::backwardDiffusionFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, const dictionary& dict ) : mixedUserDefinedFvPatchScalarField(p, iF) { // Name of field nameInternal_ = dimensionedInternalField().name(); // Set the nominal value omega0() = scalarField("omega0", dict, p.size()); rho0() = scalarField("rho0", dict, p.size()); // Fixed value condition is forced alfa() = 1000.; eta() = 1.; // Calculating epsilon epsilon() = 0; // Calculating beta const double Dmix = 1e-10; beta() = Dmix*this->patch().deltaCoeffs(); // Read value if available if (dict.found("value")) { fvPatchField<scalar>::operator= ( scalarField("value", dict, p.size()) ); } else { evaluate(); } }
tmp<scalarField> nutkWallFunctionFvPatchScalarField::yPlus() const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, dimensionedInternalField().group() ) ); const scalarField& y = turbModel.y()[patchi]; const tmp<volScalarField> tk = turbModel.k(); const volScalarField& k = tk(); tmp<scalarField> kwc = k.boundaryField()[patchi].patchInternalField(); const tmp<scalarField> tnuw = turbModel.nu(patchi); const scalarField& nuw = tnuw(); return pow025(Cmu_)*y*sqrt(kwc)/nuw; }
solidTractionFvPatchVectorField:: solidTractionFvPatchVectorField ( const fvPatch& p, const DimensionedField<vector, volMesh>& iF, const dictionary& dict ) : fixedGradientFvPatchVectorField(p, iF), fieldName_(dimensionedInternalField().name()), traction_("traction", dict, p.size()), pressure_("pressure", dict, p.size()), nonLinear_(nonLinearGeometry::OFF), orthotropic_(false) { fvPatchVectorField::operator=(patchInternalField()); gradient() = vector::zero; Info << "Patch " << patch().name() << "\tTraction boundary field: " << fieldName_ << endl; //- check if traction boundary is for non linear solver if (dict.found("nonLinear")) { nonLinear_ = nonLinearGeometry::nonLinearNames_.read ( dict.lookup("nonLinear") ); if (nonLinear_ == nonLinearGeometry::UPDATED_LAGRANGIAN) { Info << "\tnonLinear set to updated Lagrangian" << endl; } else if (nonLinear_ == nonLinearGeometry::TOTAL_LAGRANGIAN) { Info << "\tnonLinear set to total Lagrangian" << endl; } } if (dict.found("orthotropic")) { orthotropic_ = Switch(dict.lookup("orthotropic")); Info<< "\t\torthotropic set to " << orthotropic_ << endl; } //- the leastSquares has zero non-orthogonal correction //- on the boundary //- so the gradient scheme should be extendedLeastSquares if ( Foam::word ( dimensionedInternalField().mesh().schemesDict().gradScheme ( "grad(" + fieldName_ + ")" ) ) != "extendedLeastSquares" ) { Warning << "The gradScheme for " << fieldName_ << " should be \"extendedLeastSquares 0\" for the boundary " << "non-orthogonal correction to be right" << endl; } }
{ label cellI = faceCells[i]; weights[cellI]++; } } } cornerWeights_.setSize(bf.size()); forAll(epsilonPatches, i) { label patchI = epsilonPatches[i]; const fvPatchScalarField& wf = weights.boundaryField()[patchI]; cornerWeights_[patchI] = 1.0/wf.patchInternalField(); } G_.setSize(dimensionedInternalField().size(), 0.0); epsilon_.setSize(dimensionedInternalField().size(), 0.0); initialised_ = true; } epsilonWallFunctionFvPatchScalarField& epsilonWallFunctionFvPatchScalarField::epsilonPatch(const label patchI) { const volScalarField& epsilon = static_cast<const volScalarField&>(this->dimensionedInternalField()); const volScalarField::GeometricBoundaryField& bf = epsilon.boundaryField(); const epsilonWallFunctionFvPatchScalarField& epf =
), thrust::make_permutation_iterator(weights.getField().begin(),pcells.begin()), addOperatorFunctor<scalar,label,scalar>() ); } } cornerWeights_.setSize(bf.size()); forAll(omegaPatches, i) { label patchI = omegaPatches[i]; const fvPatchScalarField& wf = weights.boundaryField()[patchI]; cornerWeights_[patchI] = 1.0/wf.patchInternalField(); } G_.setSize(dimensionedInternalField().size()); omega_.setSize(dimensionedInternalField().size()); initialised_ = true; } omegaWallFunctionFvPatchScalarField& omegaWallFunctionFvPatchScalarField::omegaPatch(const label patchI) { const volScalarField& omega = static_cast<const volScalarField&>(this->dimensionedInternalField()); const volScalarField::GeometricBoundaryField& bf = omega.boundaryField(); const omegaWallFunctionFvPatchScalarField& opf =
void Foam::timeVaryingMappedTotalPressureFvPatchScalarField::updateCoeffs ( const vectorField& Up ) { if (updated()) { return; } // Map the total-pressure field onto this field timeVaryingMappedFixedValueFvPatchScalarField::updateCoeffs(); const scalarField p0 = *this; const fvsPatchField<scalar>& phip = lookupPatchField<surfaceScalarField, scalar>(phiName_); if (dimensionedInternalField().dimensions() == dimPressure/dimDensity) { if (rhoName_ == "none") { operator==(p0 - 0.5*(1.0 - pos(phip))*magSqr(Up)); } else if (rhoName_ == "rho") { operator==(p0/rho_ - 0.5*(1.0 - pos(phip))*magSqr(Up)); } else { FatalErrorIn ( "timeVaryingMappedTotalPressureFvPatchScalarField::" "updateCoeffs()" ) << " rhoName set inconsistently, rhoName = " << rhoName_ << ".\n" << " Set rhoName to 'rho' or 'none' depending on the " "definition of total pressure." << nl << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); } } else if (dimensionedInternalField().dimensions() == dimPressure) { if (rhoName_ != "none") { const fvPatchField<scalar>& rho = lookupPatchField<volScalarField, scalar>(rhoName_); operator==(p0 - 0.5*rho*(1.0 - pos(phip))*magSqr(Up)); } else if (psiName_ != "none") { const fvPatchField<scalar>& psip = lookupPatchField<volScalarField, scalar>(psiName_); if (gamma_ > 1.0) { scalar gM1ByG = (gamma_ - 1.0)/gamma_; operator== ( p0 /pow ( (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)), 1.0/gM1ByG ) ); } else { operator==(p0/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up))); } } else { FatalErrorIn ( "timeVaryingMappedTotalPressureFvPatchScalarField::" "updateCoeffs()" ) << " rhoName or psiName set inconsistently, rhoName = " << rhoName_ << ", psiName = " << psiName_ << ".\n" << " Set either rhoName or psiName depending on the " "definition of total pressure." << nl << " Set the unused variable(s) to 'none'.\n" << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); } } else { FatalErrorIn ( "timeVaryingMappedTotalPressureFvPatchScalarField::updateCoeffs()" ) << "Incorrect dimensions for pressure " << dimensionedInternalField().dimensions() << " Should be either " << dimPressure << " for compressible/variable density flow\n" << " or " << dimPressure/dimDensity << " for incompressible flow.\n" << " on patch " << this->patch().name() << " of field " << this->dimensionedInternalField().name() << " in file " << this->dimensionedInternalField().objectPath() << exit(FatalError); } }
void greyDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs() { if (this->updated()) { return; } const label patchI = this->patch().index(); // Access radiation model const radiationModel& radiation = db().lookupObject<radiationModel>("radiationProperties"); const fvDOM& dom = dynamic_cast<const fvDOM&>(radiation); if (dom.nLambda() == 0) { FatalErrorIn ( "" "wideBandDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs" ) << " a non-grey boundary condition is used with a grey " << "absorption model" << nl << exit(FatalError); } // Get rayId and lambda Id for this ray label rayId = -1; label lambdaId = -1; dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId); // Make shortcut to ray belonging to this field const radiativeIntensityRay& ray = dom.IRay(rayId); // Access incoming radiation for this patch for this band const scalarField& Qin = dom.Qin(lambdaId)[patchI]; // Access black body radiation for this patch for this band const scalarField& Eb = dom.blackBody().bLambda(lambdaId).boundaryField()[patchI]; // Get face normals vectorField nHat = patch().nf(); // Calculate cos of incoming angle of current ray with every face scalarField incomingAngle = this->patch().nf() & ray.dAve(); // Set to zeroGradient (=0; incomingAngle > 0) for faces with incoming rays // and to fixedValue (=1; incomingAngle < 0) for outgoing rays this->valueFraction() = neg(incomingAngle); // Set intensity value for fixedValue part (see reference in header file) this->refValue() = emissivity_*Eb + ((1 - emissivity_)*Qin)/sumOutgoingAngles(); // Update boundary field now, so values for incoming and outgoing rays // are in balance scalarField::operator= ( this->valueFraction()*this->refValue() + (1.0 - this->valueFraction())* ( this->patchInternalField() + this->refGrad()/this->patch().deltaCoeffs() ) ); mixedFvPatchScalarField::updateCoeffs(); }
tmp<scalargpuField> nutURoughWallFunctionFvPatchScalarField::calcYPlus ( const scalargpuField& magUp ) const { const label patchi = patch().index(); const turbulenceModel& turbModel = db().lookupObject<turbulenceModel> ( IOobject::groupName ( turbulenceModel::propertiesName, dimensionedInternalField().group() ) ); const scalargpuField& y = turbModel.y()[patchi]; const tmp<scalargpuField> tnuw = turbModel.nu(patchi); const scalargpuField& nuw = tnuw(); tmp<scalargpuField> tyPlus(new scalargpuField(patch().size(), 0.0)); scalargpuField& yPlus = tyPlus(); if (roughnessHeight_ > 0.0) { thrust::transform ( y.begin(), y.end(), thrust::make_zip_iterator(thrust::make_tuple ( nuw.begin(), magUp.begin() )), yPlus.begin(), nutURoughCalcYPlusRoughFunctor ( yPlusLam_, kappa_, E_, roughnessHeight_, roughnessConstant_, roughnessFactor_ ) ); /* // Rough Walls const scalar c_1 = 1/(90 - 2.25) + roughnessConstant_; static const scalar c_2 = 2.25/(90 - 2.25); static const scalar c_3 = 2.0*atan(1.0)/log(90/2.25); static const scalar c_4 = c_3*log(2.25); //if (KsPlusBasedOnYPlus_) { // If KsPlus is based on YPlus the extra term added to the law // of the wall will depend on yPlus forAll(yPlus, facei) { const scalar magUpara = magUp[facei]; const scalar Re = magUpara*y[facei]/nuw[facei]; const scalar kappaRe = kappa_*Re; scalar yp = yPlusLam_; const scalar ryPlusLam = 1.0/yp; int iter = 0; scalar yPlusLast = 0.0; scalar dKsPlusdYPlus = roughnessHeight_/y[facei]; // Additional tuning parameter - nominally = 1 dKsPlusdYPlus *= roughnessFactor_; do { yPlusLast = yp; // The non-dimensional roughness height scalar KsPlus = yp*dKsPlusdYPlus; // The extra term in the law-of-the-wall scalar G = 0.0; scalar yPlusGPrime = 0.0; if (KsPlus >= 90) { const scalar t_1 = 1 + roughnessConstant_*KsPlus; G = log(t_1); yPlusGPrime = roughnessConstant_*KsPlus/t_1; } else if (KsPlus > 2.25) { const scalar t_1 = c_1*KsPlus - c_2; const scalar t_2 = c_3*log(KsPlus) - c_4; const scalar sint_2 = sin(t_2); const scalar logt_1 = log(t_1); G = logt_1*sint_2; yPlusGPrime = (c_1*sint_2*KsPlus/t_1) + (c_3*logt_1*cos(t_2)); } scalar denom = 1.0 + log(E_*yp) - G - yPlusGPrime; if (mag(denom) > VSMALL) { yp = (kappaRe + yp*(1 - yPlusGPrime))/denom; } } while ( mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 && ++iter < 10 && yp > VSMALL ); yPlus[facei] = max(0.0, yp); } } */ } else { thrust::transform ( y.begin(), y.end(), thrust::make_zip_iterator(thrust::make_tuple ( nuw.begin(), magUp.begin() )), yPlus.begin(), nutURoughCalcYPlusSmoothFunctor ( yPlusLam_, kappa_,E_ ) ); /* // Smooth Walls forAll(yPlus, facei) { const scalar magUpara = magUp[facei]; const scalar Re = magUpara*y[facei]/nuw[facei]; const scalar kappaRe = kappa_*Re; scalar yp = yPlusLam_; const scalar ryPlusLam = 1.0/yp; int iter = 0; scalar yPlusLast = 0.0; do { yPlusLast = yp; yp = (kappaRe + yp)/(1.0 + log(E_*yp)); } while (mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 && ++iter < 10); yPlus[facei] = max(0.0, yp); } */ } return tyPlus; }