tmp<DimensionedField<scalar, GeoMesh> > pow ( const dimensionedScalar& ds, const DimensionedField<scalar, GeoMesh>& dsf ) { tmp<DimensionedField<scalar, GeoMesh> > tPow ( new DimensionedField<scalar, GeoMesh> ( IOobject ( "pow(" + ds.name() + ',' + dsf.name() + ')', dsf.instance(), dsf.db() ), dsf.mesh(), pow(ds, dsf.dimensions()) ) ); pow(tPow().getField(), ds.value(), dsf.getField()); return tPow; }
void Foam::bound(volScalarField& vsf, const dimensionedScalar& vsf0) { scalar minVsf = min(vsf).value(); if (minVsf < vsf0.value()) { Info<< "bounding " << vsf.name() << ", min: " << gMin(vsf.internalField()) << " max: " << gMax(vsf.internalField()) << " average: " << gAverage(vsf.internalField()) << endl; vsf.internalField() = max ( max ( vsf.internalField(), fvc::average(max(vsf, vsf0))().internalField() // Bug fix: was assuming bound on zero. HJ, 25/Nov/2008 *pos(vsf0.value() - vsf.internalField()) ), vsf0.value() ); vsf.correctBoundaryConditions(); vsf.boundaryField() = max(vsf.boundaryField(), vsf0.value()); } }
vector horizontalVelocityField::streamfunctionAt ( const point& p, const Time& t ) const { const vector unitNormal(0, -1, 0); const dimensionedScalar z("z", dimLength, p.z()); dimensionedScalar psi("psi", cmptMultiply(dimVelocity, dimLength), scalar(0)); if (z.value() <= z1.value()) { // psi is zero } else if (z.value() <= z2.value()) { psi = -0.5*u0*(z - z1 - (z2-z1)/M_PI*Foam::sin(M_PI*(z-z1)/(z2-z1))); } else { psi = -0.5*u0*(2*z - z2 - z1); } return unitNormal * psi.value(); }
tmp<GeometricField<Type, fvPatchField, volMesh> > steadyStateDdtScheme<Type>::fvcDdt ( const dimensionedScalar& rho, const GeometricField<Type, fvPatchField, volMesh>& vf ) { return tmp<GeometricField<Type, fvPatchField, volMesh> > ( new GeometricField<Type, fvPatchField, volMesh> ( IOobject ( "ddt("+rho.name()+','+vf.name()+')', mesh().time().timeName(), mesh() ), mesh(), dimensioned<Type> ( "0", rho.dimensions()*vf.dimensions()/dimTime, pTraits<Type>::zero ) ) ); }
tmp<DimensionedField<scalar, GeoMesh> > atan2 ( const dimensionedScalar& ds, const DimensionedField<scalar, GeoMesh>& dsf ) { tmp<DimensionedField<scalar, GeoMesh> > tAtan2 ( new DimensionedField<scalar, GeoMesh> ( IOobject ( "atan2(" + ds.name() + ',' + dsf.name() + ')', dsf.instance(), dsf.db() ), dsf.mesh(), atan2(ds, dsf.dimensions()) ) ); atan2(tAtan2().getField(), ds.value(), dsf.getField()); return tAtan2; }
void fixedFluxBuoyantExnerFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const dictionary& environmentalProperties = db().lookupObject<IOdictionary>("environmentalProperties"); const dictionary& thermoProperties = db().lookupObject<IOdictionary>("thermophysicalProperties"); dimensionedVector g(environmentalProperties.lookup("g")); const constTransport<hConstThermo<perfectGas<specie> > > air ( thermoProperties.subDict("mixture") ); const dimensionedScalar Cp("Cp", dimGasConstant, air.Cp(0,0)); const fvsPatchField<scalar>& thetaf = patch().lookupPatchField<surfaceScalarField, scalar>("thetaf"); gradient() = (g.value() & patch().nf())/(Cp.value()*thetaf); fixedGradientFvPatchScalarField::updateCoeffs(); }
tmp<fvMatrix<Type>> EulerD2dt2Scheme<Type>::fvmD2dt2 ( const dimensionedScalar& rho, const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type>> tfvm ( new fvMatrix<Type> ( vf, rho.dimensions()*vf.dimensions()*dimVol /dimTime/dimTime ) ); fvMatrix<Type>& fvm = tfvm.ref(); scalar deltaT = mesh().time().deltaTValue(); scalar deltaT0 = mesh().time().deltaT0Value(); scalar coefft = (deltaT + deltaT0)/(2*deltaT); scalar coefft00 = (deltaT + deltaT0)/(2*deltaT0); scalar rDeltaT2 = 4.0/sqr(deltaT + deltaT0); if (mesh().moving()) { scalar halfRdeltaT2 = 0.5*rDeltaT2; const scalarField VV0(mesh().V() + mesh().V0()); const scalarField V0V00(mesh().V0() + mesh().V00()); fvm.diag() = rho.value()*(coefft*halfRdeltaT2)*VV0; fvm.source() = halfRdeltaT2*rho.value()* ( (coefft*VV0 + coefft00*V0V00) *vf.oldTime().primitiveField() - (coefft00*V0V00)*vf.oldTime().oldTime().primitiveField() ); } else { fvm.diag() = (coefft*rDeltaT2)*mesh().V()*rho.value(); fvm.source() = rDeltaT2*mesh().V()*rho.value()* ( (coefft + coefft00)*vf.oldTime().primitiveField() - coefft00*vf.oldTime().oldTime().primitiveField() ); } return tfvm; }
Foam::tmp<Foam::volScalarField> Foam::SrivastavaSundaresanFrictionalStress::muf ( const volScalarField& alpha, const volScalarField& Theta, const dimensionedScalar& alphaMinFriction, const dimensionedScalar& alphaMax, const volScalarField& pf, const volSymmTensorField& D, const dimensionedScalar& phi ) const { const scalar I2Dsmall = 1.0e-35; //Creating muf assuming it should be 0 on the boundary which may not be // true tmp<volScalarField> tmuf ( new volScalarField ( IOobject ( "muf", alpha.mesh().time().timeName(), alpha.mesh() ), alpha.mesh(), dimensionedScalar("muf", dimensionSet(1, -1, -1, 0, 0), 1e30) ) ); volScalarField& muff = tmuf(); forAll (D, celli) { if (alpha[celli] >= alphaMinFriction.value()) { muff[celli] = 0.5*pf[celli]*sin(phi.value()) /( sqrt(1.0/6.0*(sqr(D[celli].xx() - D[celli].yy()) + sqr(D[celli].yy() - D[celli].zz()) + sqr(D[celli].zz() - D[celli].xx())) + sqr(D[celli].xy()) + sqr(D[celli].xz()) + sqr(D[celli].yz())) + I2Dsmall ); } if (alpha[celli] < alphaMinFriction.value()) { muff[celli] = 0.0; } } muff.correctBoundaryConditions(); return tmuf; }
tmp<GeometricField<Type, fvPatchField, volMesh> > EulerLocalDdtScheme<Type>::fvcDdt ( const dimensionedScalar& rho, const GeometricField<Type, fvPatchField, volMesh>& vf ) { const objectRegistry& registry = this->mesh(); // get access to the scalar beta[i] const scalarField& beta = registry.lookupObject<scalarField>(deltaTName_); volScalarField rDeltaT = 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_)); IOobject ddtIOobject ( "ddt("+rho.name()+','+vf.name()+')', mesh().time().timeName(), mesh() ); if (mesh().moving()) { return tmp<GeometricField<Type, fvPatchField, volMesh> > ( new GeometricField<Type, fvPatchField, volMesh> ( ddtIOobject, mesh(), rDeltaT.dimensions()*rho.dimensions()*vf.dimensions(), rDeltaT.internalField()*rho.value()* ( vf.internalField() - vf.oldTime().internalField()*mesh().V0()/mesh().V() ), rDeltaT.boundaryField()*rho.value()* ( vf.boundaryField() - vf.oldTime().boundaryField() ) ) ); } else { return tmp<GeometricField<Type, fvPatchField, volMesh> > ( new GeometricField<Type, fvPatchField, volMesh> ( ddtIOobject, rDeltaT*rho*(vf - vf.oldTime()) ) ); } }
Foam::dimensionSet Foam::pow ( const dimensionSet& ds, const dimensionedScalar& dS ) { if (dimensionSet::debug && !dS.dimensions().dimensionless()) { FatalErrorInFunction << "Exponent of pow is not dimensionless" << abort(FatalError); } dimensionSet dimPow ( ds[dimensionSet::MASS]*dS.value(), ds[dimensionSet::LENGTH]*dS.value(), ds[dimensionSet::TIME]*dS.value(), ds[dimensionSet::TEMPERATURE]*dS.value(), ds[dimensionSet::MOLES]*dS.value(), ds[dimensionSet::CURRENT]*dS.value(), ds[dimensionSet::LUMINOUS_INTENSITY]*dS.value() ); return dimPow; }
Foam::tmp<Foam::volScalarField> Foam::SchaefferFrictionalStress::muf ( const volScalarField& alpha, const dimensionedScalar& alphaMax, const volScalarField& pf, const volTensorField& D, const dimensionedScalar& phi ) const { const scalar I2Dsmall = 1.0e-15; // Creating muf assuming it should be 0 on the boundary which may not be // true tmp<volScalarField> tmuf ( new volScalarField ( IOobject ( "muf", alpha.mesh().time().timeName(), alpha.mesh() ), alpha.mesh(), dimensionedScalar("muf", dimensionSet(1, -1, -1, 0, 0), 0.0) ) ); volScalarField& muff = tmuf(); forAll (D, celli) { if (alpha[celli] > alphaMax.value()-5e-2) { muff[celli] = 0.5*pf[celli]*sin(phi.value()) /( sqrt(1.0/6.0*(sqr(D[celli].xx() - D[celli].yy()) + sqr(D[celli].yy() - D[celli].zz()) + sqr(D[celli].zz() - D[celli].xx())) + sqr(D[celli].xy()) + sqr(D[celli].xz()) + sqr(D[celli].yz())) + I2Dsmall ); } } return tmuf; }
vector geodesicSolidBodyVelocityField::streamfunctionAt ( const point& p, const Time& t ) const { const dimensionedScalar T = (endTime.value() == -1 ) ? t.endTime() : endTime; const scalar u0 = 2 * M_PI * radius.value() / T.value(); const polarPoint& polarp = convertToPolar(p); const scalar lat = polarp.lat(); const scalar lon = polarp.lon(); const scalar psi = - u0 * (Foam::sin(lat) * Foam::cos(alpha) - Foam::cos(lon) * Foam::cos(lat) * Foam::sin(alpha)); return p/mag(p) * psi * radius.value(); }
tmp<fvMatrix<Type> > ddt ( const dimensionedScalar& rho, GeometricField<Type, fvPatchField, volMesh>& vf ) { return fvm::ddt(rho, vf, "ddt(" + rho.name() + ',' + vf.name() + ')'); }
point geodesicSolidBodyVelocityField::initialPositionOf ( const point& p, const Time& t ) const { // assume alpha = 0 const dimensionedScalar T = (endTime.value() == -1 ) ? t.endTime() : endTime; const scalar u0 = 2 * M_PI * radius.value() / T.value(); const polarPoint& polarp = convertToPolar(p); const scalar lat = polarp.lat(); scalar lon = polarp.lon(); lon -= u0/radius.value() * t.value(); const polarPoint departureP(lon, lat, radius.value()); return departureP.cartesian(); }
Foam::tmp<Foam::volScalarField> Foam::kineticTheoryModels::frictionalStressModels::Schaeffer::nu ( const volScalarField& alpha1, const dimensionedScalar& alphaMax, const volScalarField& pf, const volSymmTensorField& D ) const { const scalar I2Dsmall = 1.0e-15; // Creating nu assuming it should be 0 on the boundary which may not be // true tmp<volScalarField> tnu ( new volScalarField ( IOobject ( "Schaeffer:nu", alpha1.mesh().time().timeName(), alpha1.mesh(), IOobject::NO_READ, IOobject::NO_WRITE, false ), alpha1.mesh(), dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0.0) ) ); volScalarField& nuf = tnu(); forAll (D, celli) { if (alpha1[celli] > alphaMax.value() - 5e-2) { nuf[celli] = 0.5*pf[celli]*sin(phi_.value()) /( sqrt(1.0/6.0*(sqr(D[celli].xx() - D[celli].yy()) + sqr(D[celli].yy() - D[celli].zz()) + sqr(D[celli].zz() - D[celli].xx())) + sqr(D[celli].xy()) + sqr(D[celli].xz()) + sqr(D[celli].yz())) + I2Dsmall ); } } // Correct coupled BCs nuf.correctBoundaryConditions(); return tnu; }
tmp<fvMatrix<Type> > EulerLocalDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, GeometricField<Type, fvPatchField, volMesh>& vf ) { const objectRegistry& registry = this->mesh(); // get access to the scalar beta[i] const scalarField& beta = registry.lookupObject<scalarField>(deltaTName_); tmp<fvMatrix<Type> > tfvm ( new fvMatrix<Type> ( vf, rho.dimensions()*vf.dimensions()*dimVol/dimTime ) ); fvMatrix<Type>& fvm = tfvm(); scalarField rDeltaT = 1.0/(beta[0]*registry.lookupObject<volScalarField>(deltaTauName_).internalField()); fvm.diag() = rDeltaT*rho.value()*mesh().V(); if (mesh().moving()) { fvm.source() = rDeltaT *rho.value()*vf.oldTime().internalField()*mesh().V0(); } else { fvm.source() = rDeltaT *rho.value()*vf.oldTime().internalField()*mesh().V(); } return tfvm; }
Foam::tmp<Foam::surfaceScalarField> Foam::fvc::meshPhi ( const dimensionedScalar& rho, const volVectorField& vf ) { return fv::ddtScheme<vector>::New ( vf.mesh(), vf.mesh().ddtScheme("ddt(" + rho.name() + ',' + vf.name() + ')') )().meshPhi(vf); }
point horizontalVelocityField::initialPositionOf ( const point& p, const Time& t ) const { const dimensionedScalar z("z", dimLength, p.z()); if (z.value() <= z1.value()) { return p; } else if (z.value() <= z2.value()) { return point(p.x() - (u0*sqr(Foam::sin(0.5*M_PI*(z-z1)/(z2-z1)))*t).value(), p.y(), p.z()); } else { return point(p.x() - u0.value()*t.value(), p.y(), p.z()); } }
tmp<GeometricField<Type, faPatchField, areaMesh> > laplacian ( const dimensionedScalar& gamma, const GeometricField<Type, faPatchField, areaMesh>& vf ) { return gamma*fac::laplacian ( vf, "laplacian(" + gamma.name() + ',' + vf.name() + ')' ); }
void geostrophicZeroFluxFvPatchScalarField::updateCoeffs() { if (updated()) { return; } const dictionary& environmentalProperties = db().lookupObject<IOdictionary>("environmentalProperties"); const dimensionedScalar g(environmentalProperties.lookup("g")); const dimensionedScalar beta(environmentalProperties.lookup("beta")); const dimensionedScalar f0(environmentalProperties.lookup("f0")); const vector OmegaHat(environmentalProperties.lookup("OmegaHat")); const surfaceVectorField& Uf = db().lookupObject<surfaceVectorField>("Uf"); const fvsPatchField<vector> Ufp = patch().patchField<surfaceVectorField, vector>(Uf); const surfaceVectorField& Cf = Uf.mesh().Cf(); fvsPatchField<vector> Cfp = patch().patchField<surfaceVectorField, vector>(Cf); gradient() = -(f0.value() + beta.value()*Cfp.component(vector::Y))* ((OmegaHat ^ Ufp) & patch().nf())/g.value(); fixedGradientFvPatchScalarField::updateCoeffs(); }
tmp<DimensionedField<scalar, GeoMesh> > atan2 ( const dimensionedScalar& ds, const tmp<DimensionedField<scalar, GeoMesh> >& tdsf ) { const DimensionedField<scalar, GeoMesh>& dsf = tdsf(); tmp<DimensionedField<scalar, GeoMesh> > tAtan2 = reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New ( tdsf, "atan2(" + ds.name() + ',' + dsf.name() + ')', atan2(ds, dsf.dimensions()) ); atan2(tAtan2().getField(), ds.value(), dsf.getField()); reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf); return tAtan2; }
tmp<DimensionedField<scalar, GeoMesh> > pow ( const dimensionedScalar& ds, const tmp<DimensionedField<scalar, GeoMesh> >& tdsf ) { const DimensionedField<scalar, GeoMesh>& dsf = tdsf(); tmp<DimensionedField<scalar, GeoMesh> > tPow = reuseTmpDimensionedField<scalar, scalar, GeoMesh>::New ( tdsf, "pow(" + ds.name() + ',' + dsf.name() + ')', pow(ds, dsf.dimensions()) ); pow(tPow().getField(), ds.value(), dsf.getField()); reuseTmpDimensionedField<scalar, scalar, GeoMesh>::clear(tdsf); return tPow; }
tmp<GeometricField<Type, fvPatchField, volMesh> > ddt ( const dimensionedScalar& rho, const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::ddtScheme<Type>::New ( vf.mesh(), vf.mesh().ddtScheme("ddt(" + rho.name() + ',' + vf.name() + ')') )().fvcDdt(rho, vf); }
tmp<fvMatrix<Type> > d2dt2 ( const dimensionedScalar& rho, GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::d2dt2Scheme<Type>::New ( vf.mesh(), vf.mesh().d2dt2Scheme("d2dt2(" + rho.name() + ',' + vf.name() + ')') )().fvmD2dt2(rho, vf); }
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvm::Sp ( const dimensionedScalar& sp, const GeometricField<Type, fvPatchField, volMesh>& vf ) { const fvMesh& mesh = vf.mesh(); tmp<fvMatrix<Type>> tfvm ( new fvMatrix<Type> ( vf, dimVol*sp.dimensions()*vf.dimensions() ) ); fvMatrix<Type>& fvm = tfvm.ref(); fvm.diag() += mesh.V()*sp.value(); return tfvm; }
tmp<faMatrix<Type> > ddt ( const dimensionedScalar& rho, GeometricField<Type, faPatchField, areaMesh>& vf ) { return fa::faDdtScheme<Type>::New ( vf.mesh(), vf.mesh().schemesDict().ddtScheme ( "ddt(" + rho.name() + ',' + vf.name() + ')' ) )().famDdt(rho, vf); }
tmp<fvMatrix<Type> > steadyStateDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm ( new fvMatrix<Type> ( vf, rho.dimensions()*vf.dimensions()*dimVol/dimTime ) ); return tfvm; }
Foam::dimensionSet Foam::pow ( const dimensionedScalar& dS, const dimensionSet& ds ) { if ( dimensionSet::debug && !dS.dimensions().dimensionless() && !ds.dimensionless()) { FatalErrorIn("pow(const dimensionedScalar& dS, const dimensionSet& ds)") << "Argument or exponent of pow not dimensionless" << endl << abort(FatalError); } return ds; }
tmp<tetFemMatrix<Type> > tetFem::laplacianTrace ( const dimensionedScalar& gamma, GeometricField<Type, tetPolyPatchField, tetPointMesh>& vf ) { elementScalarField Gamma ( IOobject ( gamma.name(), vf.instance(), vf.db(), IOobject::NO_READ ), vf.mesh(), gamma ); return tetFem::laplacianTrace(Gamma, vf); }
tmp<faMatrix<Type> > laplacian ( const dimensionedScalar& gamma, GeometricField<Type, faPatchField, areaMesh>& vf ) { edgeScalarField Gamma ( IOobject ( gamma.name(), vf.instance(), vf.db(), IOobject::NO_READ ), vf.mesh(), gamma ); return fam::laplacian(Gamma, vf); }