Foam::tmp<Foam::fvMatrix<Type>> Foam::fvm::SuSp ( const DimensionedField<scalar, volMesh>& susp, const GeometricField<Type, fvPatchField, volMesh>& vf ) { const fvMesh& mesh = vf.mesh(); tmp<fvMatrix<Type>> tfvm ( new fvMatrix<Type> ( vf, dimVol*susp.dimensions()*vf.dimensions() ) ); fvMatrix<Type>& fvm = tfvm.ref(); fvm.diag() += mesh.V()*max(susp.field(), scalar(0)); fvm.source() -= mesh.V()*min(susp.field(), scalar(0)) *vf.primitiveField(); return tfvm; }
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > noConvectionScheme<Type>::interpolate ( const surfaceScalarField&, const GeometricField<Type, fvPatchField, volMesh>& vf ) const { return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( "interpolate("+vf.name()+')', vf.instance(), vf.db() ), vf.mesh(), dimensioned<Type> ( "0", vf.dimensions(), pTraits<Type>::zero ) ) ); }
tmp<GeometricField<Type, fvPatchField, volMesh> > steadyStateDdtScheme<Type>::fvcDdt ( const GeometricField<Type, fvPatchField, volMesh>& vf ) { return tmp<GeometricField<Type, fvPatchField, volMesh> > ( new GeometricField<Type, fvPatchField, volMesh> ( IOobject ( "ddt("+vf.name()+')', mesh().time().timeName(), mesh() ), mesh(), dimensioned<Type> ( "0", vf.dimensions()/dimTime, pTraits<Type>::zero ) ) ); }
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> limitedSnGrad<Type>::correction ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const { const GeometricField<Type, fvsPatchField, surfaceMesh> corr ( correctedScheme_().correction(vf) ); const surfaceScalarField limiter ( min ( limitCoeff_ *mag(snGradScheme<Type>::snGrad(vf, deltaCoeffs(vf), "SndGrad")) /( (1 - limitCoeff_)*mag(corr) + dimensionedScalar("small", corr.dimensions(), SMALL) ), dimensionedScalar("one", dimless, 1.0) ) ); if (fv::debug) { InfoInFunction << "limiter min: " << min(limiter.primitiveField()) << " max: "<< max(limiter.primitiveField()) << " avg: " << average(limiter.primitiveField()) << endl; } return limiter*corr; }
tmp<GeometricField<Type, fvPatchField, volMesh> > steadyStateD2dt2Scheme<Type>::fvcD2dt2 ( const volScalarField& rho, const GeometricField<Type, fvPatchField, volMesh>& vf ) { return tmp<GeometricField<Type, fvPatchField, volMesh> > ( new GeometricField<Type, fvPatchField, volMesh> ( IOobject ( "d2dt2("+rho.name()+','+vf.name()+')', mesh().time().timeName(), mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh(), dimensioned<Type> ( "0", rho.dimensions()*vf.dimensions()/dimTime/dimTime, pTraits<Type>::zero ) ) ); }
tmp<GeometricField<Type, PatchField, GeoMesh> > transform ( const GeometricField<tensor, PatchField, GeoMesh>& trf, const GeometricField<Type, PatchField, GeoMesh>& tf ) { tmp<GeometricField<Type, PatchField, GeoMesh> > tranf ( new GeometricField<Type, PatchField, GeoMesh> ( IOobject ( "transform(" + trf.name() + ',' + tf.name() + ')', tf.instance(), tf.db(), IOobject::NO_READ, IOobject::NO_WRITE ), tf.mesh(), tf.dimensions() ) ); transform(tranf(), trf, tf); return tranf; }
tmp<GeometricField<Type, fvPatchField, volMesh> > EulerLocalDdtScheme<Type>::fvcDdt ( const volScalarField& 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.internalField()*vf.internalField() - rho.oldTime().internalField() *vf.oldTime().internalField()*mesh().V0()/mesh().V() ), rDeltaT.boundaryField()* ( rho.boundaryField()*vf.boundaryField() - rho.oldTime().boundaryField() *vf.oldTime().boundaryField() ) ) ); } else { return tmp<GeometricField<Type, fvPatchField, volMesh> > ( new GeometricField<Type, fvPatchField, volMesh> ( ddtIOobject, rDeltaT*(rho*vf - rho.oldTime()*vf.oldTime()) ) ); } }
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::linearUpwind<Type>::correction ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const { const fvMesh& mesh = this->mesh(); tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( "linearUpwind::correction(" + vf.name() + ')', mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), mesh, dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero) ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr(); const surfaceScalarField& faceFlux = this->faceFlux_; const labelList& owner = mesh.owner(); const labelList& neighbour = mesh.neighbour(); const volVectorField& C = mesh.C(); const surfaceVectorField& Cf = mesh.Cf(); tmp < GeometricField < typename outerProduct<vector, Type>::type, fvPatchField, volMesh > > tgradVf = gradScheme_().grad(vf, gradSchemeName_); const GeometricField < typename outerProduct<vector, Type>::type, fvPatchField, volMesh >& gradVf = tgradVf(); forAll(faceFlux, facei) { label celli = (faceFlux[facei] > 0) ? owner[facei] : neighbour[facei]; sfCorr[facei] = (Cf[facei] - C[celli]) & gradVf[celli]; }
Foam::tmp < Foam::GeometricField < typename Foam::outerProduct<Foam::vector, Type>::type, Foam::fvPatchField, Foam::volMesh > > Foam::fv::gaussGrad<Type>::gradf ( const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf, const word& name ) { typedef typename outerProduct<vector, Type>::type GradType; const fvMesh& mesh = ssf.mesh(); tmp<GeometricField<GradType, fvPatchField, volMesh> > tgGrad ( new GeometricField<GradType, fvPatchField, volMesh> ( IOobject ( name, ssf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensioned<GradType> ( "0", ssf.dimensions()/dimLength, pTraits<GradType>::zero ), zeroGradientFvPatchField<GradType>::typeName ) ); GeometricField<GradType, fvPatchField, volMesh>& gGrad = tgGrad(); const labelUList& owner = mesh.owner(); const labelUList& neighbour = mesh.neighbour(); const vectorField& Sf = mesh.Sf(); Field<GradType>& igGrad = gGrad; const Field<Type>& issf = ssf; forAll(owner, facei) { GradType Sfssf = Sf[facei]*issf[facei]; igGrad[owner[facei]] += Sfssf; igGrad[neighbour[facei]] -= Sfssf; }
Foam::tmp < Foam::GeometricField < typename Foam::outerProduct<WeightType, Type>::type, Foam::fvPatchField, Foam::volMesh > > Foam::extendedCellToCellStencil::weightedSum ( const mapDistribute& map, const labelListList& stencil, const GeometricField<Type, fvPatchField, volMesh>& fld, const List<List<WeightType> >& stencilWeights ) { typedef typename outerProduct<WeightType, Type>::type WeightedType; typedef GeometricField<WeightedType, fvPatchField, volMesh> WeightedFieldType; const fvMesh& mesh = fld.mesh(); // Collect internal and boundary values List<List<Type> > stencilFld; extendedCellToFaceStencil::collectData(map, stencil, fld, stencilFld); tmp<WeightedFieldType> twf ( new WeightedFieldType ( IOobject ( fld.name(), mesh.time().timeName(), mesh ), mesh, dimensioned<WeightedType> ( fld.name(), fld.dimensions(), pTraits<WeightedType>::zero ) ) ); WeightedFieldType& wf = twf(); forAll(wf, celli) { const List<Type>& stField = stencilFld[celli]; const List<WeightType>& stWeight = stencilWeights[celli]; forAll(stField, i) { wf[celli] += stWeight[i]*stField[i]; } }
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::extendedUpwindCellToFaceStencil::weightedSum ( const surfaceScalarField& phi, const GeometricField<Type, fvPatchField, volMesh>& fld, const List<List<scalar> >& ownWeights, const List<List<scalar> >& neiWeights ) const { const fvMesh& mesh = fld.mesh(); // Collect internal and boundary values List<List<Type> > ownFld; collectData(ownMap(), ownStencil(), fld, ownFld); List<List<Type> > neiFld; collectData(neiMap(), neiStencil(), fld, neiFld); tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( fld.name(), mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), mesh, dimensioned<Type> ( fld.name(), fld.dimensions(), pTraits<Type>::zero ) ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& sf = tsfCorr(); // Internal faces for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) { if (phi[faceI] > 0) { // Flux out of owner. Use upwind (= owner side) stencil. const List<Type>& stField = ownFld[faceI]; const List<scalar>& stWeight = ownWeights[faceI]; forAll(stField, i) { sf[faceI] += stField[i]*stWeight[i]; } } else {
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::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::CLUST<Type>::correction ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const { const fvMesh& mesh = this->mesh(); tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( "CLUST::correction(" + vf.name() + ')', mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), mesh, dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero) ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr(); const surfaceVectorField& Uf = this->Uf_; //const GeometricField<Type,fvsPatchField,surfaceMesh> gradf=fvc::snGrad(vf); const GeometricField < typename outerProduct<vector, Type>::type, fvPatchField, volMesh > Grad = fvc::grad(vf); forAll(sfCorr, facei) { const scalar un = (Uf[facei] & mesh.Sf()[facei])/mesh.magSf()[facei]; const scalar ub = mag(un)/max(SMALL, mag(Uf[facei])); label celli = un > 0 ? mesh.owner()[facei] : mesh.neighbour()[facei]; label cellj = celli == mesh.owner()[facei] ? mesh.neighbour()[facei] : mesh.owner()[facei]; sfCorr[facei] = 0.5*b_*ub* ( ((mesh.C()[cellj] - mesh.C()[celli]) & Grad[celli]) + vf[celli] - vf[cellj] ); } return tsfCorr; }
tmp < GeometricField < typename outerProduct<vector,Type>::type, fvPatchField, volMesh > > reconstruct ( const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf ) { typedef typename outerProduct<vector, Type>::type GradType; const fvMesh& mesh = ssf.mesh(); const labelUList& owner = mesh.owner(); const labelUList& neighbour = mesh.neighbour(); const volVectorField& C = mesh.C(); const surfaceVectorField& Cf = mesh.Cf(); tmp<GeometricField<GradType, fvPatchField, volMesh>> treconField ( new GeometricField<GradType, fvPatchField, volMesh> ( IOobject ( "reconstruct("+ssf.name()+')', ssf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensioned<GradType> ( "0", ssf.dimensions()/dimArea, Zero ), extrapolatedCalculatedFvPatchField<GradType>::typeName ) ); Field<GradType>& rf = treconField(); forAll(owner, facei) { label own = owner[facei]; label nei = neighbour[facei]; rf[own] += (Cf[facei] - C[own])*ssf[facei]; rf[nei] -= (Cf[facei] - C[nei])*ssf[facei]; }
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > correctedSnGrad<Type>::correction ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const { const fvMesh& mesh = this->mesh(); // construct GeometricField<Type, fvsPatchField, surfaceMesh> tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( "snGradCorr("+vf.name()+')', vf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, vf.dimensions()*mesh.deltaCoeffs().dimensions() ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf(); for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) { ssf.replace ( cmpt, mesh.correctionVectors() & linear < typename outerProduct<vector, typename pTraits<Type>::cmptType>::type >(mesh).interpolate ( gradScheme<typename pTraits<Type>::cmptType>::New ( mesh, mesh.schemesDict().gradScheme(ssf.name()) )() //gaussGrad<typename pTraits<Type>::cmptType>(mesh) .grad(vf.component(cmpt)) ) ); } return tssf; }
dimensioned<Type> domainIntegrate ( const GeometricField<Type, fvPatchField, volMesh>& vf ) { return dimensioned<Type> ( "domainIntegrate(" + vf.name() + ')', dimVol*vf.dimensions(), gSum(fvc::volumeIntegrate(vf)) ); }
tmp<GeometricField<Type, faePatchField, edgeMesh> > correctedLnGrad<Type>::correction ( const GeometricField<Type, faPatchField, areaMesh>& vf ) const { const faMesh& mesh = this->mesh(); // construct GeometricField<Type, faePatchField, edgeMesh> tmp<GeometricField<Type, faePatchField, edgeMesh> > tssf ( new GeometricField<Type, faePatchField, edgeMesh> ( IOobject ( "lnGradCorr("+vf.name()+')', vf.instance(), vf.db() ), mesh, vf.dimensions()*mesh.deltaCoeffs().dimensions() ) ); GeometricField<Type, faePatchField, edgeMesh>& ssf = tssf(); for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) { ssf.replace ( cmpt, mesh.correctionVectors() & linearEdgeInterpolation < typename outerProduct<vector, typename pTraits<Type>::cmptType>::type >(mesh).interpolate ( gradScheme<typename pTraits<Type>::cmptType>::New ( mesh, mesh.gradScheme(ssf.name()) )() // gaussGrad<typename pTraits<Type>::cmptType>(mesh) .grad(vf.component(cmpt)) ) ); } return tssf; }
tmp<fvMatrix<Type> > steadyStateDdtScheme<Type>::fvmDdt ( const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm ( new fvMatrix<Type> ( vf, vf.dimensions()*dimVol/dimTime ) ); return tfvm; }
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> > Foam::APVM<Type>::correction ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const { const fvMesh& mesh = this->mesh(); tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( "APVM::correction(" + vf.name() + ')', mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE, false ), mesh, dimensioned<Type>(vf.name(), vf.dimensions(), pTraits<Type>::zero) ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr = tsfCorr.ref(); const dimensionedScalar& dt = mesh.time().deltaT(); const surfaceVectorField& Uf = this->Uf_; const GeometricField<Type, fvsPatchField, surfaceMesh> gradf = fvc::snGrad(vf); const GeometricField < typename outerProduct<vector, Type>::type, fvsPatchField, surfaceMesh > GradF = fvc::interpolate(fvc::reconstruct(gradf*mesh.magSf())); sfCorr = -0.5*dt*(Uf & GradF); return tsfCorr; }
tmp<fvMatrix<Type> > steadyStateD2dt2Scheme<Type>::fvmD2dt2 ( const volScalarField& rho, const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm ( new fvMatrix<Type> ( vf, rho.dimensions()*vf.dimensions()*dimVol/dimTime/dimTime ) ); return tfvm; }
tmp<GeometricField<Type, fvPatchField, volMesh> > average ( const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf ) { const fvMesh& mesh = ssf.mesh(); tmp<GeometricField<Type, fvPatchField, volMesh> > taverage ( new GeometricField<Type, fvPatchField, volMesh> ( IOobject ( "average("+ssf.name()+')', ssf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, ssf.dimensions() ) ); GeometricField<Type, fvPatchField, volMesh>& av = taverage(); av.internalField() = ( surfaceSum(mesh.magSf()*ssf)/surfaceSum(mesh.magSf()) )().internalField(); typename GeometricField<Type, fvPatchField, volMesh>:: GeometricBoundaryField& bav = av.boundaryField(); forAll(bav, patchi) { bav[patchi] = ssf.boundaryField()[patchi]; } av.correctBoundaryConditions(); return taverage; }
tmp<fvMatrix<Type> > EulerLocalDdtScheme<Type>::fvmDdt ( const volScalarField& 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.internalField()*mesh().V(); if (mesh().moving()) { fvm.source() = rDeltaT *rho.oldTime().internalField() *vf.oldTime().internalField()*mesh().V0(); } else { fvm.source() = rDeltaT *rho.oldTime().internalField() *vf.oldTime().internalField()*mesh().V(); } return tfvm; }
tmp<GeometricField<Type, faePatchField, edgeMesh> > lnGradScheme<Type>::lnGrad ( const GeometricField<Type, faPatchField, areaMesh>& vf, const tmp<edgeScalarField>& tdeltaCoeffs, const word& lnGradName ) { const faMesh& mesh = vf.mesh(); // construct GeometricField<Type, faePatchField, edgeMesh> tmp<GeometricField<Type, faePatchField, edgeMesh> > tssf ( new GeometricField<Type, faePatchField, edgeMesh> ( IOobject ( lnGradName + vf.name() + ')', vf.instance(), vf.db(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh, vf.dimensions()*tdeltaCoeffs().dimensions() ) ); GeometricField<Type, faePatchField, edgeMesh>& ssf = tssf(); // set reference to difference factors array const scalarField& deltaCoeffs = tdeltaCoeffs().internalField(); // owner/neighbour addressing const unallocLabelList& owner = mesh.owner(); const unallocLabelList& neighbour = mesh.neighbour(); forAll(owner, faceI) { ssf[faceI] = deltaCoeffs[faceI]*(vf[neighbour[faceI]] - vf[owner[faceI]]); }
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> snGradScheme<Type>::snGrad ( const GeometricField<Type, fvPatchField, volMesh>& vf, const tmp<surfaceScalarField>& tdeltaCoeffs, const word& snGradName ) { const fvMesh& mesh = vf.mesh(); // construct GeometricField<Type, fvsPatchField, surfaceMesh> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tsf ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( snGradName + "("+vf.name()+')', vf.instance(), vf.mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), mesh, vf.dimensions()*tdeltaCoeffs().dimensions() ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tsf.ref(); // set reference to difference factors array const scalarField& deltaCoeffs = tdeltaCoeffs().internalField(); // owner/neighbour addressing const labelUList& owner = mesh.owner(); const labelUList& neighbour = mesh.neighbour(); forAll(owner, facei) { ssf[facei] = deltaCoeffs[facei]*(vf[neighbour[facei]] - vf[owner[facei]]); }
tmp<fvMatrix<Type> > noConvectionScheme<Type>::fvmDiv ( const surfaceScalarField& faceFlux, GeometricField<Type, fvPatchField, volMesh>& vf ) const { tmp<fvMatrix<Type> > tfvm ( new fvMatrix<Type> ( vf, faceFlux.dimensions()*vf.dimensions() ) ); // Touch diagonal for consistency tfvm().diag() = 0; return tfvm; }
tmp<tetFemMatrix<Type> > tetFem::smoother ( GeometricField<Type, tetPolyPatchField, tetPointMesh>& vf ) { tmp<tetFemMatrix<Type> > tfem ( new tetFemMatrix<Type> ( vf, vf.dimensions() ) ); tetFemMatrix<Type>& fem = tfem(); fem.upper() = 1.0; fem.negSumDiag(); return tfem; }
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh>> Foam::fv::correctedSnGrad<Type>::correction ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const { const fvMesh& mesh = this->mesh(); // construct GeometricField<Type, fvsPatchField, surfaceMesh> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tssf ( new GeometricField<Type, fvsPatchField, surfaceMesh> ( IOobject ( "snGradCorr("+vf.name()+')', vf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, vf.dimensions()*mesh.nonOrthDeltaCoeffs().dimensions() ) ); GeometricField<Type, fvsPatchField, surfaceMesh>& ssf = tssf.ref(); for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) { ssf.replace ( cmpt, correctedSnGrad<typename pTraits<Type>::cmptType>(mesh) .fullGradCorrection(vf.component(cmpt)) ); } return tssf; }
tmp<GeometricField<Type, fvPatchField, volMesh> > cellReduce ( const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf, const CombineOp& cop ) { typedef GeometricField<Type, fvPatchField, volMesh> volFieldType; const fvMesh& mesh = ssf.mesh(); tmp<volFieldType> tresult ( new volFieldType ( IOobject ( "cellReduce(" + ssf.name() + ')', ssf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensioned<Type>("0", ssf.dimensions(), pTraits<Type>::zero), zeroGradientFvPatchField<Type>::typeName ) ); volFieldType& result = tresult(); const labelUList& own = mesh.owner(); const labelUList& nbr = mesh.neighbour(); forAll(own, i) { label cellI = own[i]; cop(result[cellI], ssf[i]); }
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvm::Sp ( const DimensionedField<scalar, volMesh>& 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.field(); return tfvm; }
tmp < GeometricField < typename outerProduct<vector, Type>::type, fvPatchField, volMesh > > leastSquaresSolidInterfaceGrad<Type>::calcGrad ( const GeometricField<Type, fvPatchField, volMesh>& vsf, const word& name ) const { typedef typename outerProduct<vector, Type>::type GradType; const fvMesh& mesh = vsf.mesh(); tmp<GeometricField<GradType, fvPatchField, volMesh> > tlsGrad ( new GeometricField<GradType, fvPatchField, volMesh> ( IOobject ( name, vsf.instance(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensioned<GradType> ( "zero", vsf.dimensions()/dimLength, pTraits<GradType>::zero ), zeroGradientFvPatchField<GradType>::typeName ) ); GeometricField<GradType, fvPatchField, volMesh>& lsGrad = tlsGrad(); // Get reference to least square vectors const leastSquaresSolidInterfaceVectors& lsv = leastSquaresSolidInterfaceVectors::New(mesh); const surfaceVectorField& ownLs = lsv.pVectors(); const surfaceVectorField& neiLs = lsv.nVectors(); const unallocLabelList& own = mesh.owner(); const unallocLabelList& nei = mesh.neighbour(); // interface fields const solidInterface& solInt = mesh.objectRegistry::lookupObject<IOReferencer<solidInterface> > ("solidInterface")(); const labelList& interfaceFacesMap = solInt.indicatorFieldMap(); const labelList& interfaceProcPatchMap = solInt.processorPatchMap(); const labelListList& interfaceProcPatchFacesMap = solInt.processorPatchFacesMap(); const vectorField& interfaceDispVec = solInt.interfaceDisplacement(); const List<vectorField>& procInterDispVec = solInt.processorInterfaceDisplacement(); // interface disp must be vector so // this is a quick hack Field<Type> interfaceDisp(interfaceDispVec.size(), pTraits<Type>::zero); if (pTraits<Type>::typeName != vector::typeName) { FatalError << "leastSquaresSolidInterface::grad() may only be used " "with a volVectorField" << exit(FatalError); } for (direction cmpt = 0; cmpt < pTraits<vector>::nComponents; cmpt++) { interfaceDisp.replace ( cmpt, interfaceDispVec.component(cmpt) ); } List<Field<Type> > procInterDisp (procInterDispVec.size(), Field<Type>(0, pTraits<Type>::zero)); forAll(procInterDisp, patchi) { procInterDisp[patchi].setSize (procInterDispVec[patchi].size(), pTraits<Type>::zero); for (direction cmpt = 0; cmpt < pTraits<vector>::nComponents; cmpt++) { procInterDisp[patchi].replace ( cmpt, procInterDispVec[patchi].component(cmpt) ); } }