OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

fvMatrix.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "volFields.H"
00028 #include "surfaceFields.H"
00029 #include "calculatedFvPatchFields.H"
00030 #include "zeroGradientFvPatchFields.H"
00031 #include "coupledFvPatchFields.H"
00032 
00033 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00034 
00035 template<class Type>
00036 template<class Type2>
00037 void Foam::fvMatrix<Type>::addToInternalField
00038 (
00039     const unallocLabelList& addr,
00040     const Field<Type2>& pf,
00041     Field<Type2>& intf
00042 ) const
00043 {
00044     if (addr.size() != pf.size())
00045     {
00046         FatalErrorIn
00047         (
00048             "fvMatrix<Type>::addToInternalField(const unallocLabelList&, "
00049             "const Field&, Field&)"
00050         )   << "sizes of addressing and field are different"
00051             << abort(FatalError);
00052     }
00053 
00054     forAll(addr, faceI)
00055     {
00056         intf[addr[faceI]] += pf[faceI];
00057     }
00058 }
00059 
00060 
00061 template<class Type>
00062 template<class Type2>
00063 void Foam::fvMatrix<Type>::addToInternalField
00064 (
00065     const unallocLabelList& addr,
00066     const tmp<Field<Type2> >& tpf,
00067     Field<Type2>& intf
00068 ) const
00069 {
00070     addToInternalField(addr, tpf(), intf);
00071     tpf.clear();
00072 }
00073 
00074 
00075 template<class Type>
00076 template<class Type2>
00077 void Foam::fvMatrix<Type>::subtractFromInternalField
00078 (
00079     const unallocLabelList& addr,
00080     const Field<Type2>& pf,
00081     Field<Type2>& intf
00082 ) const
00083 {
00084     if (addr.size() != pf.size())
00085     {
00086         FatalErrorIn
00087         (
00088             "fvMatrix<Type>::addToInternalField(const unallocLabelList&, "
00089             "const Field&, Field&)"
00090         )   << "sizes of addressing and field are different"
00091             << abort(FatalError);
00092     }
00093 
00094     forAll(addr, faceI)
00095     {
00096         intf[addr[faceI]] -= pf[faceI];
00097     }
00098 }
00099 
00100 
00101 template<class Type>
00102 template<class Type2>
00103 void Foam::fvMatrix<Type>::subtractFromInternalField
00104 (
00105     const unallocLabelList& addr,
00106     const tmp<Field<Type2> >& tpf,
00107     Field<Type2>& intf
00108 ) const
00109 {
00110     subtractFromInternalField(addr, tpf(), intf);
00111     tpf.clear();
00112 }
00113 
00114 
00115 template<class Type>
00116 void Foam::fvMatrix<Type>::addBoundaryDiag
00117 (
00118     scalarField& diag,
00119     const direction solveCmpt
00120 ) const
00121 {
00122     forAll(internalCoeffs_, patchI)
00123     {
00124         addToInternalField
00125         (
00126             lduAddr().patchAddr(patchI),
00127             internalCoeffs_[patchI].component(solveCmpt),
00128             diag
00129         );
00130     }
00131 }
00132 
00133 
00134 template<class Type>
00135 void Foam::fvMatrix<Type>::addCmptAvBoundaryDiag(scalarField& diag) const
00136 {
00137     forAll(internalCoeffs_, patchI)
00138     {
00139         addToInternalField
00140         (
00141             lduAddr().patchAddr(patchI),
00142             cmptAv(internalCoeffs_[patchI]),
00143             diag
00144         );
00145     }
00146 }
00147 
00148 
00149 template<class Type>
00150 void Foam::fvMatrix<Type>::addBoundarySource
00151 (
00152     Field<Type>& source,
00153     const bool couples
00154 ) const
00155 {
00156     forAll(psi_.boundaryField(), patchI)
00157     {
00158         const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
00159         const Field<Type>& pbc = boundaryCoeffs_[patchI];
00160 
00161         if (!ptf.coupled())
00162         {
00163             addToInternalField(lduAddr().patchAddr(patchI), pbc, source);
00164         }
00165         else if (couples)
00166         {
00167             tmp<Field<Type> > tpnf = ptf.patchNeighbourField();
00168             const Field<Type>& pnf = tpnf();
00169 
00170             const unallocLabelList& addr = lduAddr().patchAddr(patchI);
00171 
00172             forAll(addr, facei)
00173             {
00174                 source[addr[facei]] += cmptMultiply(pbc[facei], pnf[facei]);
00175             }
00176         }
00177     }
00178 }
00179 
00180 
00181 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00182 
00183 template<class Type>
00184 Foam::fvMatrix<Type>::fvMatrix
00185 (
00186     GeometricField<Type, fvPatchField, volMesh>& psi,
00187     const dimensionSet& ds
00188 )
00189 :
00190     lduMatrix(psi.mesh()),
00191     psi_(psi),
00192     dimensions_(ds),
00193     source_(psi.size(), pTraits<Type>::zero),
00194     internalCoeffs_(psi.mesh().boundary().size()),
00195     boundaryCoeffs_(psi.mesh().boundary().size()),
00196     faceFluxCorrectionPtr_(NULL)
00197 {
00198     if (debug)
00199     {
00200         Info<< "fvMatrix<Type>(GeometricField<Type, fvPatchField, volMesh>&,"
00201                " const dimensionSet&) : "
00202                "constructing fvMatrix<Type> for field " << psi_.name()
00203             << endl;
00204     }
00205 
00206     // Initialise coupling coefficients
00207     forAll (psi.mesh().boundary(), patchI)
00208     {
00209         internalCoeffs_.set
00210         (
00211             patchI,
00212             new Field<Type>
00213             (
00214                 psi.mesh().boundary()[patchI].size(),
00215                 pTraits<Type>::zero
00216             )
00217         );
00218 
00219         boundaryCoeffs_.set
00220         (
00221             patchI,
00222             new Field<Type>
00223             (
00224                 psi.mesh().boundary()[patchI].size(),
00225                 pTraits<Type>::zero
00226             )
00227         );
00228     }
00229 
00230     psi_.boundaryField().updateCoeffs();
00231 }
00232 
00233 
00234 template<class Type>
00235 Foam::fvMatrix<Type>::fvMatrix(const fvMatrix<Type>& fvm)
00236 :
00237     refCount(),
00238     lduMatrix(fvm),
00239     psi_(fvm.psi_),
00240     dimensions_(fvm.dimensions_),
00241     source_(fvm.source_),
00242     internalCoeffs_(fvm.internalCoeffs_),
00243     boundaryCoeffs_(fvm.boundaryCoeffs_),
00244     faceFluxCorrectionPtr_(NULL)
00245 {
00246     if (debug)
00247     {
00248         Info<< "fvMatrix<Type>::fvMatrix(const fvMatrix<Type>&) : "
00249             << "copying fvMatrix<Type> for field " << psi_.name()
00250             << endl;
00251     }
00252 
00253     if (fvm.faceFluxCorrectionPtr_)
00254     {
00255         faceFluxCorrectionPtr_ = new
00256         GeometricField<Type, fvsPatchField, surfaceMesh>
00257         (
00258             *(fvm.faceFluxCorrectionPtr_)
00259         );
00260     }
00261 }
00262 
00263 
00264 #ifdef ConstructFromTmp
00265 template<class Type>
00266 Foam::fvMatrix<Type>::fvMatrix(const tmp<fvMatrix<Type> >& tfvm)
00267 :
00268     refCount(),
00269     lduMatrix
00270     (
00271         const_cast<fvMatrix<Type>&>(tfvm()),
00272         tfvm.isTmp()
00273     ),
00274     psi_(tfvm().psi_),
00275     dimensions_(tfvm().dimensions_),
00276     source_
00277     (
00278         const_cast<fvMatrix<Type>&>(tfvm()).source_,
00279         tfvm.isTmp()
00280     ),
00281     internalCoeffs_
00282     (
00283         const_cast<fvMatrix<Type>&>(tfvm()).internalCoeffs_,
00284         tfvm.isTmp()
00285     ),
00286     boundaryCoeffs_
00287     (
00288         const_cast<fvMatrix<Type>&>(tfvm()).boundaryCoeffs_,
00289         tfvm.isTmp()
00290     ),
00291     faceFluxCorrectionPtr_(NULL)
00292 {
00293     if (debug)
00294     {
00295         Info<< "fvMatrix<Type>::fvMatrix(const tmp<fvMatrix<Type> >&) : "
00296             << "copying fvMatrix<Type> for field " << psi_.name()
00297             << endl;
00298     }
00299 
00300     if (tfvm().faceFluxCorrectionPtr_)
00301     {
00302         if (tfvm.isTmp())
00303         {
00304             faceFluxCorrectionPtr_ = tfvm().faceFluxCorrectionPtr_;
00305             tfvm().faceFluxCorrectionPtr_ = NULL;
00306         }
00307         else
00308         {
00309             faceFluxCorrectionPtr_ = new
00310                 GeometricField<Type, fvsPatchField, surfaceMesh>
00311                 (
00312                     *(tfvm().faceFluxCorrectionPtr_)
00313                 );
00314         }
00315     }
00316 
00317     tfvm.clear();
00318 }
00319 #endif
00320 
00321 
00322 template<class Type>
00323 Foam::fvMatrix<Type>::fvMatrix
00324 (
00325     GeometricField<Type, fvPatchField, volMesh>& psi,
00326     Istream& is
00327 )
00328 :
00329     lduMatrix(psi.mesh()),
00330     psi_(psi),
00331     dimensions_(is),
00332     source_(is),
00333     internalCoeffs_(psi.mesh().boundary().size()),
00334     boundaryCoeffs_(psi.mesh().boundary().size()),
00335     faceFluxCorrectionPtr_(NULL)
00336 {
00337     if (debug)
00338     {
00339         Info<< "fvMatrix<Type>"
00340                "(GeometricField<Type, fvPatchField, volMesh>&, Istream&) : "
00341                "constructing fvMatrix<Type> for field " << psi_.name()
00342             << endl;
00343     }
00344 
00345     // Initialise coupling coefficients
00346     forAll (psi.mesh().boundary(), patchI)
00347     {
00348         internalCoeffs_.set
00349         (
00350             patchI,
00351             new Field<Type>
00352             (
00353                 psi.mesh().boundary()[patchI].size(),
00354                 pTraits<Type>::zero
00355             )
00356         );
00357 
00358         boundaryCoeffs_.set
00359         (
00360             patchI,
00361             new Field<Type>
00362             (
00363                 psi.mesh().boundary()[patchI].size(),
00364                 pTraits<Type>::zero
00365             )
00366         );
00367     }
00368 
00369 }
00370 
00371 
00372 template<class Type>
00373 Foam::fvMatrix<Type>::~fvMatrix()
00374 {
00375     if (debug)
00376     {
00377         Info<< "fvMatrix<Type>::~fvMatrix<Type>() : "
00378             << "destroying fvMatrix<Type> for field " << psi_.name()
00379             << endl;
00380     }
00381 
00382     if (faceFluxCorrectionPtr_)
00383     {
00384         delete faceFluxCorrectionPtr_;
00385     }
00386 }
00387 
00388 
00389 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00390 
00391 // Set solution in given cells and eliminate corresponding
00392 // equations from the matrix
00393 template<class Type>
00394 void Foam::fvMatrix<Type>::setValues
00395 (
00396     const labelList& cellLabels,
00397     const Field<Type>& values
00398 )
00399 {
00400     const fvMesh& mesh = psi_.mesh();
00401 
00402     const cellList& cells = mesh.cells();
00403     const unallocLabelList& own = mesh.owner();
00404     const unallocLabelList& nei = mesh.neighbour();
00405 
00406     scalarField& Diag = diag();
00407 
00408     forAll(cellLabels, i)
00409     {
00410         label celli = cellLabels[i];
00411 
00412         psi_[celli] = values[i];
00413         source_[celli] = values[i]*Diag[celli];
00414 
00415         if (symmetric() || asymmetric())
00416         {
00417             const cell& c = cells[celli];
00418 
00419             forAll(c, j)
00420             {
00421                 label facei = c[j];
00422 
00423                 if (mesh.isInternalFace(facei))
00424                 {
00425                     if (symmetric())
00426                     {
00427                         if (celli == own[facei])
00428                         {
00429                             source_[nei[facei]] -= upper()[facei]*values[i];
00430                         }
00431                         else
00432                         {
00433                             source_[own[facei]] -= upper()[facei]*values[i];
00434                         }
00435 
00436                         upper()[facei] = 0.0;
00437                     }
00438                     else
00439                     {
00440                         if (celli == own[facei])
00441                         {
00442                             source_[nei[facei]] -= lower()[facei]*values[i];
00443                         }
00444                         else
00445                         {
00446                             source_[own[facei]] -= upper()[facei]*values[i];
00447                         }
00448 
00449                         upper()[facei] = 0.0;
00450                         lower()[facei] = 0.0;
00451                     }
00452                 }
00453                 else
00454                 {
00455                     label patchi = mesh.boundaryMesh().whichPatch(facei);
00456 
00457                     if (internalCoeffs_[patchi].size())
00458                     {
00459                         label patchFacei =
00460                             mesh.boundaryMesh()[patchi].whichFace(facei);
00461 
00462                         internalCoeffs_[patchi][patchFacei] =
00463                             pTraits<Type>::zero;
00464 
00465                         boundaryCoeffs_[patchi][patchFacei] =
00466                             pTraits<Type>::zero;
00467                     }
00468                 }
00469             }
00470         }
00471     }
00472 }
00473 
00474 
00475 template<class Type>
00476 void Foam::fvMatrix<Type>::setReference
00477 (
00478     const label celli,
00479     const Type& value,
00480     const bool forceReference
00481 )
00482 {
00483     if ((forceReference || psi_.needReference()) && celli >= 0)
00484     {
00485         source()[celli] += diag()[celli]*value;
00486         diag()[celli] += diag()[celli];
00487     }
00488 }
00489 
00490 
00491 template<class Type>
00492 void Foam::fvMatrix<Type>::relax(const scalar alpha)
00493 {
00494     if (alpha <= 0)
00495     {
00496         return;
00497     }
00498 
00499     Field<Type>& S = source();
00500     scalarField& D = diag();
00501 
00502     // Store the current unrelaxed diagonal for use in updating the source
00503     scalarField D0(D);
00504 
00505     // Calculate the sum-mag off-diagonal from the interior faces
00506     scalarField sumOff(D.size(), 0.0);
00507     sumMagOffDiag(sumOff);
00508 
00509     // Handle the boundary contributions to the diagonal
00510     forAll(psi_.boundaryField(), patchI)
00511     {
00512         const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
00513 
00514         if (ptf.size())
00515         {
00516             const unallocLabelList& pa = lduAddr().patchAddr(patchI);
00517             Field<Type>& iCoeffs = internalCoeffs_[patchI];
00518 
00519             if (ptf.coupled())
00520             {
00521                 const Field<Type>& pCoeffs = boundaryCoeffs_[patchI];
00522 
00523                 // For coupled boundaries add the diagonal and
00524                 // off-diagonal contributions
00525                 forAll(pa, face)
00526                 {
00527                     D[pa[face]] += component(iCoeffs[face], 0);
00528                     sumOff[pa[face]] += mag(component(pCoeffs[face], 0));
00529                 }
00530             }
00531             else
00532             {
00533                 // For non-coupled boundaries subtract the diagonal
00534                 // contribution off-diagonal sum which avoids having to remove
00535                 // it from the diagonal later.
00536                 // Also add the source contribution from the relaxation
00537                 forAll(pa, face)
00538                 {
00539                     Type iCoeff0 = iCoeffs[face];
00540                     iCoeffs[face] = cmptMag(iCoeffs[face]);
00541                     sumOff[pa[face]] -= cmptMin(iCoeffs[face]);
00542                     iCoeffs[face] /= alpha;
00543                     S[pa[face]] +=
00544                         cmptMultiply(iCoeffs[face] - iCoeff0, psi_[pa[face]]);
00545                 }
00546             }
00547         }
00548     }
00549 
00550     // Ensure the matrix is diagonally dominant...
00551     max(D, D, sumOff);
00552 
00553     // ... then relax
00554     D /= alpha;
00555 
00556     // Now remove the diagonal contribution from coupled boundaries
00557     forAll(psi_.boundaryField(), patchI)
00558     {
00559         const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
00560 
00561         if (ptf.size())
00562         {
00563             const unallocLabelList& pa = lduAddr().patchAddr(patchI);
00564             Field<Type>& iCoeffs = internalCoeffs_[patchI];
00565 
00566             if (ptf.coupled())
00567             {
00568                 forAll(pa, face)
00569                 {
00570                     D[pa[face]] -= component(iCoeffs[face], 0);
00571                 }
00572             }
00573         }
00574     }
00575 
00576     // Finally add the relaxation contribution to the source.
00577     S += (D - D0)*psi_.internalField();
00578 }
00579 
00580 
00581 template<class Type>
00582 void Foam::fvMatrix<Type>::relax()
00583 {
00584     if (psi_.mesh().relax(psi_.name()))
00585     {
00586         relax(psi_.mesh().relaxationFactor(psi_.name()));
00587     }
00588 }
00589 
00590 
00591 template<class Type>
00592 void Foam::fvMatrix<Type>::boundaryManipulate
00593 (
00594     typename GeometricField<Type, fvPatchField, volMesh>::
00595         GeometricBoundaryField& bFields
00596 )
00597 {
00598     forAll(bFields, patchI)
00599     {
00600         bFields[patchI].manipulateMatrix(*this);
00601     }
00602 }
00603 
00604 
00605 template<class Type>
00606 Foam::tmp<Foam::scalarField> Foam::fvMatrix<Type>::D() const
00607 {
00608     tmp<scalarField> tdiag(new scalarField(diag()));
00609     addCmptAvBoundaryDiag(tdiag());
00610     return tdiag;
00611 }
00612 
00613 
00614 template<class Type>
00615 Foam::tmp<Foam::Field<Type> > Foam::fvMatrix<Type>::DD() const
00616 {
00617     tmp<Field<Type> > tdiag(pTraits<Type>::one*diag());
00618 
00619     forAll(psi_.boundaryField(), patchI)
00620     {
00621         const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
00622 
00623         if (!ptf.coupled() && ptf.size())
00624         {
00625             addToInternalField
00626             (
00627                 lduAddr().patchAddr(patchI),
00628                 internalCoeffs_[patchI],
00629                 tdiag()
00630             );
00631         }
00632     }
00633 
00634     return tdiag;
00635 }
00636 
00637 
00638 template<class Type>
00639 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Type>::A() const
00640 {
00641     tmp<volScalarField> tAphi
00642     (
00643         new volScalarField
00644         (
00645             IOobject
00646             (
00647                 "A("+psi_.name()+')',
00648                 psi_.instance(),
00649                 psi_.mesh(),
00650                 IOobject::NO_READ,
00651                 IOobject::NO_WRITE
00652             ),
00653             psi_.mesh(),
00654             dimensions_/psi_.dimensions()/dimVol,
00655             zeroGradientFvPatchScalarField::typeName
00656         )
00657     );
00658 
00659     tAphi().internalField() = D()/psi_.mesh().V();
00660     tAphi().correctBoundaryConditions();
00661 
00662     return tAphi;
00663 }
00664 
00665 
00666 template<class Type>
00667 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
00668 Foam::fvMatrix<Type>::H() const
00669 {
00670     tmp<GeometricField<Type, fvPatchField, volMesh> > tHphi
00671     (
00672         new GeometricField<Type, fvPatchField, volMesh>
00673         (
00674             IOobject
00675             (
00676                 "H("+psi_.name()+')',
00677                 psi_.instance(),
00678                 psi_.mesh(),
00679                 IOobject::NO_READ,
00680                 IOobject::NO_WRITE
00681             ),
00682             psi_.mesh(),
00683             dimensions_/dimVol,
00684             zeroGradientFvPatchScalarField::typeName
00685         )
00686     );
00687     GeometricField<Type, fvPatchField, volMesh>& Hphi = tHphi();
00688 
00689     // Loop over field components
00690     for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
00691     {
00692         scalarField psiCmpt = psi_.internalField().component(cmpt);
00693 
00694         scalarField boundaryDiagCmpt(psi_.size(), 0.0);
00695         addBoundaryDiag(boundaryDiagCmpt, cmpt);
00696         boundaryDiagCmpt.negate();
00697         addCmptAvBoundaryDiag(boundaryDiagCmpt);
00698 
00699         Hphi.internalField().replace(cmpt, boundaryDiagCmpt*psiCmpt);
00700     }
00701 
00702     Hphi.internalField() += lduMatrix::H(psi_.internalField()) + source_;
00703     addBoundarySource(Hphi.internalField());
00704 
00705     Hphi.internalField() /= psi_.mesh().V();
00706     Hphi.correctBoundaryConditions();
00707 
00708     typename Type::labelType validComponents
00709     (
00710         pow
00711         (
00712             psi_.mesh().solutionD(),
00713             pTraits<typename powProduct<Vector<label>, Type::rank>::type>::zero
00714         )
00715     );
00716 
00717     for(direction cmpt=0; cmpt<Type::nComponents; cmpt++)
00718     {
00719         if (validComponents[cmpt] == -1)
00720         {
00721             Hphi.replace
00722             (
00723                 cmpt,
00724                 dimensionedScalar("0", Hphi.dimensions(), 0.0)
00725             );
00726         }
00727     }
00728 
00729     return tHphi;
00730 }
00731 
00732 
00733 template<class Type>
00734 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Type>::H1() const
00735 {
00736     tmp<volScalarField> tH1
00737     (
00738         new volScalarField
00739         (
00740             IOobject
00741             (
00742                 "H(1)",
00743                 psi_.instance(),
00744                 psi_.mesh(),
00745                 IOobject::NO_READ,
00746                 IOobject::NO_WRITE
00747             ),
00748             psi_.mesh(),
00749             dimensions_/(dimVol*psi_.dimensions()),
00750             zeroGradientFvPatchScalarField::typeName
00751         )
00752     );
00753     volScalarField& H1_ = tH1();
00754 
00755     // Loop over field components
00756     /*
00757     for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
00758     {
00759         scalarField psiCmpt = psi_.internalField().component(cmpt);
00760 
00761         scalarField boundaryDiagCmpt(psi_.size(), 0.0);
00762         addBoundaryDiag(boundaryDiagCmpt, cmpt);
00763         boundaryDiagCmpt.negate();
00764         addCmptAvBoundaryDiag(boundaryDiagCmpt);
00765 
00766         H1_.internalField().replace(cmpt, boundaryDiagCmpt);
00767     }
00768 
00769     H1_.internalField() += lduMatrix::H1();
00770     */
00771 
00772     H1_.internalField() = lduMatrix::H1();
00773 
00774     H1_.internalField() /= psi_.mesh().V();
00775     H1_.correctBoundaryConditions();
00776 
00777     return tH1;
00778 }
00779 
00780 
00781 template<class Type>
00782 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
00783 Foam::fvMatrix<Type>::
00784 flux() const
00785 {
00786     if (!psi_.mesh().fluxRequired(psi_.name()))
00787     {
00788         FatalErrorIn("fvMatrix<Type>::flux()")
00789             << "flux requested but " << psi_.name()
00790             << " not specified in the fluxRequired sub-dictionary"
00791                " of fvSchemes."
00792             << abort(FatalError);
00793     }
00794 
00795     // construct GeometricField<Type, fvsPatchField, surfaceMesh>
00796     tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tfieldFlux
00797     (
00798         new GeometricField<Type, fvsPatchField, surfaceMesh>
00799         (
00800             IOobject
00801             (
00802                 "flux("+psi_.name()+')',
00803                 psi_.instance(),
00804                 psi_.mesh(),
00805                 IOobject::NO_READ,
00806                 IOobject::NO_WRITE
00807             ),
00808             psi_.mesh(),
00809             dimensions()
00810         )
00811     );
00812     GeometricField<Type, fvsPatchField, surfaceMesh>& fieldFlux = tfieldFlux();
00813 
00814     for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
00815     {
00816         fieldFlux.internalField().replace
00817         (
00818             cmpt,
00819             lduMatrix::faceH(psi_.internalField().component(cmpt))
00820         );
00821     }
00822 
00823     FieldField<Field, Type> InternalContrib = internalCoeffs_;
00824 
00825     forAll(InternalContrib, patchI)
00826     {
00827         InternalContrib[patchI] =
00828             cmptMultiply
00829             (
00830                 InternalContrib[patchI],
00831                 psi_.boundaryField()[patchI].patchInternalField()
00832             );
00833     }
00834 
00835     FieldField<Field, Type> NeighbourContrib = boundaryCoeffs_;
00836 
00837     forAll(NeighbourContrib, patchI)
00838     {
00839         if (psi_.boundaryField()[patchI].coupled())
00840         {
00841             NeighbourContrib[patchI] =
00842                 cmptMultiply
00843                 (
00844                     NeighbourContrib[patchI],
00845                     psi_.boundaryField()[patchI].patchNeighbourField()
00846                 );
00847         }
00848     }
00849 
00850     forAll(fieldFlux.boundaryField(), patchI)
00851     {
00852         fieldFlux.boundaryField()[patchI] =
00853             InternalContrib[patchI] - NeighbourContrib[patchI];
00854     }
00855 
00856     if (faceFluxCorrectionPtr_)
00857     {
00858         fieldFlux += *faceFluxCorrectionPtr_;
00859     }
00860 
00861     return tfieldFlux;
00862 }
00863 
00864 
00865 // * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //
00866 
00867 template<class Type>
00868 void Foam::fvMatrix<Type>::operator=(const fvMatrix<Type>& fvmv)
00869 {
00870     if (this == &fvmv)
00871     {
00872         FatalErrorIn("fvMatrix<Type>::operator=(const fvMatrix<Type>&)")
00873             << "attempted assignment to self"
00874             << abort(FatalError);
00875     }
00876 
00877     if (&psi_ != &(fvmv.psi_))
00878     {
00879         FatalErrorIn("fvMatrix<Type>::operator=(const fvMatrix<Type>&)")
00880             << "different fields"
00881             << abort(FatalError);
00882     }
00883 
00884     lduMatrix::operator=(fvmv);
00885     source_ = fvmv.source_;
00886     internalCoeffs_ = fvmv.internalCoeffs_;
00887     boundaryCoeffs_ = fvmv.boundaryCoeffs_;
00888 
00889     if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
00890     {
00891         *faceFluxCorrectionPtr_ = *fvmv.faceFluxCorrectionPtr_;
00892     }
00893     else if (fvmv.faceFluxCorrectionPtr_)
00894     {
00895         faceFluxCorrectionPtr_ =
00896             new GeometricField<Type, fvsPatchField, surfaceMesh>
00897         (*fvmv.faceFluxCorrectionPtr_);
00898     }
00899 }
00900 
00901 
00902 template<class Type>
00903 void Foam::fvMatrix<Type>::operator=(const tmp<fvMatrix<Type> >& tfvmv)
00904 {
00905     operator=(tfvmv());
00906     tfvmv.clear();
00907 }
00908 
00909 
00910 template<class Type>
00911 void Foam::fvMatrix<Type>::negate()
00912 {
00913     lduMatrix::negate();
00914     source_.negate();
00915     internalCoeffs_.negate();
00916     boundaryCoeffs_.negate();
00917 
00918     if (faceFluxCorrectionPtr_)
00919     {
00920         faceFluxCorrectionPtr_->negate();
00921     }
00922 }
00923 
00924 
00925 template<class Type>
00926 void Foam::fvMatrix<Type>::operator+=(const fvMatrix<Type>& fvmv)
00927 {
00928     checkMethod(*this, fvmv, "+=");
00929 
00930     dimensions_ += fvmv.dimensions_;
00931     lduMatrix::operator+=(fvmv);
00932     source_ += fvmv.source_;
00933     internalCoeffs_ += fvmv.internalCoeffs_;
00934     boundaryCoeffs_ += fvmv.boundaryCoeffs_;
00935 
00936     if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
00937     {
00938         *faceFluxCorrectionPtr_ += *fvmv.faceFluxCorrectionPtr_;
00939     }
00940     else if (fvmv.faceFluxCorrectionPtr_)
00941     {
00942         faceFluxCorrectionPtr_ = new
00943         GeometricField<Type, fvsPatchField, surfaceMesh>
00944         (
00945             *fvmv.faceFluxCorrectionPtr_
00946         );
00947     }
00948 }
00949 
00950 
00951 template<class Type>
00952 void Foam::fvMatrix<Type>::operator+=(const tmp<fvMatrix<Type> >& tfvmv)
00953 {
00954     operator+=(tfvmv());
00955     tfvmv.clear();
00956 }
00957 
00958 
00959 template<class Type>
00960 void Foam::fvMatrix<Type>::operator-=(const fvMatrix<Type>& fvmv)
00961 {
00962     checkMethod(*this, fvmv, "+=");
00963 
00964     dimensions_ -= fvmv.dimensions_;
00965     lduMatrix::operator-=(fvmv);
00966     source_ -= fvmv.source_;
00967     internalCoeffs_ -= fvmv.internalCoeffs_;
00968     boundaryCoeffs_ -= fvmv.boundaryCoeffs_;
00969 
00970     if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
00971     {
00972         *faceFluxCorrectionPtr_ -= *fvmv.faceFluxCorrectionPtr_;
00973     }
00974     else if (fvmv.faceFluxCorrectionPtr_)
00975     {
00976         faceFluxCorrectionPtr_ =
00977             new GeometricField<Type, fvsPatchField, surfaceMesh>
00978         (-*fvmv.faceFluxCorrectionPtr_);
00979     }
00980 }
00981 
00982 
00983 template<class Type>
00984 void Foam::fvMatrix<Type>::operator-=(const tmp<fvMatrix<Type> >& tfvmv)
00985 {
00986     operator-=(tfvmv());
00987     tfvmv.clear();
00988 }
00989 
00990 
00991 template<class Type>
00992 void Foam::fvMatrix<Type>::operator+=
00993 (
00994     const DimensionedField<Type, volMesh>& su
00995 )
00996 {
00997     checkMethod(*this, su, "+=");
00998     source() -= su.mesh().V()*su.field();
00999 }
01000 
01001 
01002 template<class Type>
01003 void Foam::fvMatrix<Type>::operator+=
01004 (
01005     const tmp<DimensionedField<Type, volMesh> >& tsu
01006 )
01007 {
01008     operator+=(tsu());
01009     tsu.clear();
01010 }
01011 
01012 
01013 template<class Type>
01014 void Foam::fvMatrix<Type>::operator+=
01015 (
01016     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01017 )
01018 {
01019     operator+=(tsu());
01020     tsu.clear();
01021 }
01022 
01023 
01024 template<class Type>
01025 void Foam::fvMatrix<Type>::operator-=
01026 (
01027     const DimensionedField<Type, volMesh>& su
01028 )
01029 {
01030     checkMethod(*this, su, "-=");
01031     source() += su.mesh().V()*su.field();
01032 }
01033 
01034 
01035 template<class Type>
01036 void Foam::fvMatrix<Type>::operator-=
01037 (
01038     const tmp<DimensionedField<Type, volMesh> >& tsu
01039 )
01040 {
01041     operator-=(tsu());
01042     tsu.clear();
01043 }
01044 
01045 
01046 template<class Type>
01047 void Foam::fvMatrix<Type>::operator-=
01048 (
01049     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01050 )
01051 {
01052     operator-=(tsu());
01053     tsu.clear();
01054 }
01055 
01056 
01057 template<class Type>
01058 void Foam::fvMatrix<Type>::operator+=
01059 (
01060     const dimensioned<Type>& su
01061 )
01062 {
01063     source() -= psi().mesh().V()*su;
01064 }
01065 
01066 
01067 template<class Type>
01068 void Foam::fvMatrix<Type>::operator-=
01069 (
01070     const dimensioned<Type>& su
01071 )
01072 {
01073     source() += psi().mesh().V()*su;
01074 }
01075 
01076 
01077 template<class Type>
01078 void Foam::fvMatrix<Type>::operator+=
01079 (
01080     const zeroField&
01081 )
01082 {}
01083 
01084 
01085 template<class Type>
01086 void Foam::fvMatrix<Type>::operator-=
01087 (
01088     const zeroField&
01089 )
01090 {}
01091 
01092 
01093 template<class Type>
01094 void Foam::fvMatrix<Type>::operator*=
01095 (
01096     const DimensionedField<scalar, volMesh>& dsf
01097 )
01098 {
01099     dimensions_ *= dsf.dimensions();
01100     lduMatrix::operator*=(dsf.field());
01101     source_ *= dsf.field();
01102 
01103     forAll(boundaryCoeffs_, patchI)
01104     {
01105         scalarField psf
01106         (
01107             dsf.mesh().boundary()[patchI].patchInternalField(dsf.field())
01108         );
01109 
01110         internalCoeffs_[patchI] *= psf;
01111         boundaryCoeffs_[patchI] *= psf;
01112     }
01113 
01114     if (faceFluxCorrectionPtr_)
01115     {
01116         FatalErrorIn
01117         (
01118             "fvMatrix<Type>::operator*="
01119             "(const DimensionedField<scalar, volMesh>&)"
01120         )   << "cannot scale a matrix containing a faceFluxCorrection"
01121             << abort(FatalError);
01122     }
01123 }
01124 
01125 
01126 template<class Type>
01127 void Foam::fvMatrix<Type>::operator*=
01128 (
01129     const tmp<DimensionedField<scalar, volMesh> >& tdsf
01130 )
01131 {
01132     operator*=(tdsf());
01133     tdsf.clear();
01134 }
01135 
01136 
01137 template<class Type>
01138 void Foam::fvMatrix<Type>::operator*=
01139 (
01140     const tmp<volScalarField>& tvsf
01141 )
01142 {
01143     operator*=(tvsf());
01144     tvsf.clear();
01145 }
01146 
01147 
01148 template<class Type>
01149 void Foam::fvMatrix<Type>::operator*=
01150 (
01151     const dimensioned<scalar>& ds
01152 )
01153 {
01154     dimensions_ *= ds.dimensions();
01155     lduMatrix::operator*=(ds.value());
01156     source_ *= ds.value();
01157     internalCoeffs_ *= ds.value();
01158     boundaryCoeffs_ *= ds.value();
01159 
01160     if (faceFluxCorrectionPtr_)
01161     {
01162         *faceFluxCorrectionPtr_ *= ds.value();
01163     }
01164 }
01165 
01166 
01167 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
01168 
01169 template<class Type>
01170 void Foam::checkMethod
01171 (
01172     const fvMatrix<Type>& fvm1,
01173     const fvMatrix<Type>& fvm2,
01174     const char* op
01175 )
01176 {
01177     if (&fvm1.psi() != &fvm2.psi())
01178     {
01179         FatalErrorIn
01180         (
01181             "checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)"
01182         )   << "incompatible fields for operation "
01183             << endl << "    "
01184             << "[" << fvm1.psi().name() << "] "
01185             << op
01186             << " [" << fvm2.psi().name() << "]"
01187             << abort(FatalError);
01188     }
01189 
01190     if (dimensionSet::debug && fvm1.dimensions() != fvm2.dimensions())
01191     {
01192         FatalErrorIn
01193         (
01194             "checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)"
01195         )   << "incompatible dimensions for operation "
01196             << endl << "    "
01197             << "[" << fvm1.psi().name() << fvm1.dimensions()/dimVolume << " ] "
01198             << op
01199             << " [" << fvm2.psi().name() << fvm2.dimensions()/dimVolume << " ]"
01200             << abort(FatalError);
01201     }
01202 }
01203 
01204 
01205 template<class Type>
01206 void Foam::checkMethod
01207 (
01208     const fvMatrix<Type>& fvm,
01209     const DimensionedField<Type, volMesh>& df,
01210     const char* op
01211 )
01212 {
01213     if (dimensionSet::debug && fvm.dimensions()/dimVolume != df.dimensions())
01214     {
01215         FatalErrorIn
01216         (
01217             "checkMethod(const fvMatrix<Type>&, const GeometricField<Type, "
01218             "fvPatchField, volMesh>&)"
01219         )   <<  "incompatible dimensions for operation "
01220             << endl << "    "
01221             << "[" << fvm.psi().name() << fvm.dimensions()/dimVolume << " ] "
01222             << op
01223             << " [" << df.name() << df.dimensions() << " ]"
01224             << abort(FatalError);
01225     }
01226 }
01227 
01228 
01229 template<class Type>
01230 void Foam::checkMethod
01231 (
01232     const fvMatrix<Type>& fvm,
01233     const dimensioned<Type>& dt,
01234     const char* op
01235 )
01236 {
01237     if (dimensionSet::debug && fvm.dimensions()/dimVolume != dt.dimensions())
01238     {
01239         FatalErrorIn
01240         (
01241             "checkMethod(const fvMatrix<Type>&, const dimensioned<Type>&)"
01242         )   << "incompatible dimensions for operation "
01243             << endl << "    "
01244             << "[" << fvm.psi().name() << fvm.dimensions()/dimVolume << " ] "
01245             << op
01246             << " [" << dt.name() << dt.dimensions() << " ]"
01247             << abort(FatalError);
01248     }
01249 }
01250 
01251 
01252 template<class Type>
01253 Foam::lduMatrix::solverPerformance Foam::solve
01254 (
01255     fvMatrix<Type>& fvm,
01256     const dictionary& solverControls
01257 )
01258 {
01259     return fvm.solve(solverControls);
01260 }
01261 
01262 template<class Type>
01263 Foam::lduMatrix::solverPerformance Foam::solve
01264 (
01265     const tmp<fvMatrix<Type> >& tfvm,
01266     const dictionary& solverControls
01267 )
01268 {
01269     lduMatrix::solverPerformance solverPerf =
01270         const_cast<fvMatrix<Type>&>(tfvm()).solve(solverControls);
01271 
01272     tfvm.clear();
01273 
01274     return solverPerf;
01275 }
01276 
01277 
01278 template<class Type>
01279 Foam::lduMatrix::solverPerformance Foam::solve(fvMatrix<Type>& fvm)
01280 {
01281     return fvm.solve();
01282 }
01283 
01284 template<class Type>
01285 Foam::lduMatrix::solverPerformance Foam::solve(const tmp<fvMatrix<Type> >& tfvm)
01286 {
01287     lduMatrix::solverPerformance solverPerf =
01288         const_cast<fvMatrix<Type>&>(tfvm()).solve();
01289 
01290     tfvm.clear();
01291 
01292     return solverPerf;
01293 }
01294 
01295 
01296 template<class Type>
01297 Foam::tmp<Foam::fvMatrix<Type> > Foam::correction
01298 (
01299     const fvMatrix<Type>& A
01300 )
01301 {
01302     tmp<Foam::fvMatrix<Type> > tAcorr = A - (A & A.psi());
01303 
01304     if
01305     (
01306         (A.hasUpper() || A.hasLower())
01307      && A.psi().mesh().fluxRequired(A.psi().name())
01308     )
01309     {
01310         tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr();
01311     }
01312 
01313     return tAcorr;
01314 }
01315 
01316 
01317 template<class Type>
01318 Foam::tmp<Foam::fvMatrix<Type> > Foam::correction
01319 (
01320     const tmp<fvMatrix<Type> >& tA
01321 )
01322 {
01323     tmp<Foam::fvMatrix<Type> > tAcorr = tA - (tA() & tA().psi());
01324 
01325     // Note the matrix coefficients are still that of matrix A
01326     const fvMatrix<Type>& A = tAcorr();
01327 
01328     if
01329     (
01330         (A.hasUpper() || A.hasLower())
01331      && A.psi().mesh().fluxRequired(A.psi().name())
01332     )
01333     {
01334         tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr();
01335     }
01336 
01337     return tAcorr;
01338 }
01339 
01340 
01341 // * * * * * * * * * * * * * * * Global Operators  * * * * * * * * * * * * * //
01342 
01343 template<class Type>
01344 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01345 (
01346     const fvMatrix<Type>& A,
01347     const fvMatrix<Type>& B
01348 )
01349 {
01350     checkMethod(A, B, "==");
01351     return (A - B);
01352 }
01353 
01354 template<class Type>
01355 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01356 (
01357     const tmp<fvMatrix<Type> >& tA,
01358     const fvMatrix<Type>& B
01359 )
01360 {
01361     checkMethod(tA(), B, "==");
01362     return (tA - B);
01363 }
01364 
01365 template<class Type>
01366 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01367 (
01368     const fvMatrix<Type>& A,
01369     const tmp<fvMatrix<Type> >& tB
01370 )
01371 {
01372     checkMethod(A, tB(), "==");
01373     return (A - tB);
01374 }
01375 
01376 template<class Type>
01377 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01378 (
01379     const tmp<fvMatrix<Type> >& tA,
01380     const tmp<fvMatrix<Type> >& tB
01381 )
01382 {
01383     checkMethod(tA(), tB(), "==");
01384     return (tA - tB);
01385 }
01386 
01387 template<class Type>
01388 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01389 (
01390     const fvMatrix<Type>& A,
01391     const DimensionedField<Type, volMesh>& su
01392 )
01393 {
01394     checkMethod(A, su, "==");
01395     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01396     tC().source() += su.mesh().V()*su.field();
01397     return tC;
01398 }
01399 
01400 template<class Type>
01401 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01402 (
01403     const fvMatrix<Type>& A,
01404     const tmp<DimensionedField<Type, volMesh> >& tsu
01405 )
01406 {
01407     checkMethod(A, tsu(), "==");
01408     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01409     tC().source() += tsu().mesh().V()*tsu().field();
01410     tsu.clear();
01411     return tC;
01412 }
01413 
01414 template<class Type>
01415 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01416 (
01417     const fvMatrix<Type>& A,
01418     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01419 )
01420 {
01421     checkMethod(A, tsu(), "==");
01422     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01423     tC().source() += tsu().mesh().V()*tsu().internalField();
01424     tsu.clear();
01425     return tC;
01426 }
01427 
01428 template<class Type>
01429 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01430 (
01431     const tmp<fvMatrix<Type> >& tA,
01432     const DimensionedField<Type, volMesh>& su
01433 )
01434 {
01435     checkMethod(tA(), su, "==");
01436     tmp<fvMatrix<Type> > tC(tA.ptr());
01437     tC().source() += su.mesh().V()*su.field();
01438     return tC;
01439 }
01440 
01441 template<class Type>
01442 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01443 (
01444     const tmp<fvMatrix<Type> >& tA,
01445     const tmp<DimensionedField<Type, volMesh> >& tsu
01446 )
01447 {
01448     checkMethod(tA(), tsu(), "==");
01449     tmp<fvMatrix<Type> > tC(tA.ptr());
01450     tC().source() += tsu().mesh().V()*tsu().field();
01451     tsu.clear();
01452     return tC;
01453 }
01454 
01455 template<class Type>
01456 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01457 (
01458     const tmp<fvMatrix<Type> >& tA,
01459     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01460 )
01461 {
01462     checkMethod(tA(), tsu(), "==");
01463     tmp<fvMatrix<Type> > tC(tA.ptr());
01464     tC().source() += tsu().mesh().V()*tsu().internalField();
01465     tsu.clear();
01466     return tC;
01467 }
01468 
01469 template<class Type>
01470 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01471 (
01472     const fvMatrix<Type>& A,
01473     const dimensioned<Type>& su
01474 )
01475 {
01476     checkMethod(A, su, "==");
01477     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01478     tC().source() += A.psi().mesh().V()*su.value();
01479     return tC;
01480 }
01481 
01482 template<class Type>
01483 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01484 (
01485     const tmp<fvMatrix<Type> >& tA,
01486     const dimensioned<Type>& su
01487 )
01488 {
01489     checkMethod(tA(), su, "==");
01490     tmp<fvMatrix<Type> > tC(tA.ptr());
01491     tC().source() += tC().psi().mesh().V()*su.value();
01492     return tC;
01493 }
01494 
01495 template<class Type>
01496 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01497 (
01498     const fvMatrix<Type>& A,
01499     const zeroField&
01500 )
01501 {
01502     return A;
01503 }
01504 
01505 
01506 template<class Type>
01507 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
01508 (
01509     const tmp<fvMatrix<Type> >& tA,
01510     const zeroField&
01511 )
01512 {
01513     return tA;
01514 }
01515 
01516 
01517 template<class Type>
01518 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01519 (
01520     const fvMatrix<Type>& A
01521 )
01522 {
01523     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01524     tC().negate();
01525     return tC;
01526 }
01527 
01528 template<class Type>
01529 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01530 (
01531     const tmp<fvMatrix<Type> >& tA
01532 )
01533 {
01534     tmp<fvMatrix<Type> > tC(tA.ptr());
01535     tC().negate();
01536     return tC;
01537 }
01538 
01539 
01540 template<class Type>
01541 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01542 (
01543     const fvMatrix<Type>& A,
01544     const fvMatrix<Type>& B
01545 )
01546 {
01547     checkMethod(A, B, "+");
01548     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01549     tC() += B;
01550     return tC;
01551 }
01552 
01553 template<class Type>
01554 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01555 (
01556     const tmp<fvMatrix<Type> >& tA,
01557     const fvMatrix<Type>& B
01558 )
01559 {
01560     checkMethod(tA(), B, "+");
01561     tmp<fvMatrix<Type> > tC(tA.ptr());
01562     tC() += B;
01563     return tC;
01564 }
01565 
01566 template<class Type>
01567 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01568 (
01569     const fvMatrix<Type>& A,
01570     const tmp<fvMatrix<Type> >& tB
01571 )
01572 {
01573     checkMethod(A, tB(), "+");
01574     tmp<fvMatrix<Type> > tC(tB.ptr());
01575     tC() += A;
01576     return tC;
01577 }
01578 
01579 template<class Type>
01580 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01581 (
01582     const tmp<fvMatrix<Type> >& tA,
01583     const tmp<fvMatrix<Type> >& tB
01584 )
01585 {
01586     checkMethod(tA(), tB(), "+");
01587     tmp<fvMatrix<Type> > tC(tA.ptr());
01588     tC() += tB();
01589     tB.clear();
01590     return tC;
01591 }
01592 
01593 template<class Type>
01594 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01595 (
01596     const fvMatrix<Type>& A,
01597     const DimensionedField<Type, volMesh>& su
01598 )
01599 {
01600     checkMethod(A, su, "+");
01601     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01602     tC().source() -= su.mesh().V()*su.field();
01603     return tC;
01604 }
01605 
01606 template<class Type>
01607 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01608 (
01609     const fvMatrix<Type>& A,
01610     const tmp<DimensionedField<Type, volMesh> >& tsu
01611 )
01612 {
01613     checkMethod(A, tsu(), "+");
01614     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01615     tC().source() -= tsu().mesh().V()*tsu().field();
01616     tsu.clear();
01617     return tC;
01618 }
01619 
01620 template<class Type>
01621 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01622 (
01623     const fvMatrix<Type>& A,
01624     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01625 )
01626 {
01627     checkMethod(A, tsu(), "+");
01628     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01629     tC().source() -= tsu().mesh().V()*tsu().internalField();
01630     tsu.clear();
01631     return tC;
01632 }
01633 
01634 template<class Type>
01635 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01636 (
01637     const tmp<fvMatrix<Type> >& tA,
01638     const DimensionedField<Type, volMesh>& su
01639 )
01640 {
01641     checkMethod(tA(), su, "+");
01642     tmp<fvMatrix<Type> > tC(tA.ptr());
01643     tC().source() -= su.mesh().V()*su.field();
01644     return tC;
01645 }
01646 
01647 template<class Type>
01648 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01649 (
01650     const tmp<fvMatrix<Type> >& tA,
01651     const tmp<DimensionedField<Type, volMesh> >& tsu
01652 )
01653 {
01654     checkMethod(tA(), tsu(), "+");
01655     tmp<fvMatrix<Type> > tC(tA.ptr());
01656     tC().source() -= tsu().mesh().V()*tsu().field();
01657     tsu.clear();
01658     return tC;
01659 }
01660 
01661 template<class Type>
01662 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01663 (
01664     const tmp<fvMatrix<Type> >& tA,
01665     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01666 )
01667 {
01668     checkMethod(tA(), tsu(), "+");
01669     tmp<fvMatrix<Type> > tC(tA.ptr());
01670     tC().source() -= tsu().mesh().V()*tsu().internalField();
01671     tsu.clear();
01672     return tC;
01673 }
01674 
01675 template<class Type>
01676 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01677 (
01678     const DimensionedField<Type, volMesh>& su,
01679     const fvMatrix<Type>& A
01680 )
01681 {
01682     checkMethod(A, su, "+");
01683     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01684     tC().source() -= su.mesh().V()*su.field();
01685     return tC;
01686 }
01687 
01688 template<class Type>
01689 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01690 (
01691     const tmp<DimensionedField<Type, volMesh> >& tsu,
01692     const fvMatrix<Type>& A
01693 )
01694 {
01695     checkMethod(A, tsu(), "+");
01696     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01697     tC().source() -= tsu().mesh().V()*tsu().field();
01698     tsu.clear();
01699     return tC;
01700 }
01701 
01702 template<class Type>
01703 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01704 (
01705     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
01706     const fvMatrix<Type>& A
01707 )
01708 {
01709     checkMethod(A, tsu(), "+");
01710     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01711     tC().source() -= tsu().mesh().V()*tsu().internalField();
01712     tsu.clear();
01713     return tC;
01714 }
01715 
01716 template<class Type>
01717 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01718 (
01719     const DimensionedField<Type, volMesh>& su,
01720     const tmp<fvMatrix<Type> >& tA
01721 )
01722 {
01723     checkMethod(tA(), su, "+");
01724     tmp<fvMatrix<Type> > tC(tA.ptr());
01725     tC().source() -= su.mesh().V()*su.field();
01726     return tC;
01727 }
01728 
01729 template<class Type>
01730 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01731 (
01732     const tmp<DimensionedField<Type, volMesh> >& tsu,
01733     const tmp<fvMatrix<Type> >& tA
01734 )
01735 {
01736     checkMethod(tA(), tsu(), "+");
01737     tmp<fvMatrix<Type> > tC(tA.ptr());
01738     tC().source() -= tsu().mesh().V()*tsu().field();
01739     tsu.clear();
01740     return tC;
01741 }
01742 
01743 template<class Type>
01744 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01745 (
01746     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
01747     const tmp<fvMatrix<Type> >& tA
01748 )
01749 {
01750     checkMethod(tA(), tsu(), "+");
01751     tmp<fvMatrix<Type> > tC(tA.ptr());
01752     tC().source() -= tsu().mesh().V()*tsu().internalField();
01753     tsu.clear();
01754     return tC;
01755 }
01756 
01757 
01758 template<class Type>
01759 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01760 (
01761     const fvMatrix<Type>& A,
01762     const fvMatrix<Type>& B
01763 )
01764 {
01765     checkMethod(A, B, "-");
01766     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01767     tC() -= B;
01768     return tC;
01769 }
01770 
01771 template<class Type>
01772 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01773 (
01774     const tmp<fvMatrix<Type> >& tA,
01775     const fvMatrix<Type>& B
01776 )
01777 {
01778     checkMethod(tA(), B, "-");
01779     tmp<fvMatrix<Type> > tC(tA.ptr());
01780     tC() -= B;
01781     return tC;
01782 }
01783 
01784 template<class Type>
01785 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01786 (
01787     const fvMatrix<Type>& A,
01788     const tmp<fvMatrix<Type> >& tB
01789 )
01790 {
01791     checkMethod(A, tB(), "-");
01792     tmp<fvMatrix<Type> > tC(tB.ptr());
01793     tC() -= A;
01794     tC().negate();
01795     return tC;
01796 }
01797 
01798 template<class Type>
01799 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01800 (
01801     const tmp<fvMatrix<Type> >& tA,
01802     const tmp<fvMatrix<Type> >& tB
01803 )
01804 {
01805     checkMethod(tA(), tB(), "-");
01806     tmp<fvMatrix<Type> > tC(tA.ptr());
01807     tC() -= tB();
01808     tB.clear();
01809     return tC;
01810 }
01811 
01812 template<class Type>
01813 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01814 (
01815     const fvMatrix<Type>& A,
01816     const DimensionedField<Type, volMesh>& su
01817 )
01818 {
01819     checkMethod(A, su, "-");
01820     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01821     tC().source() += su.mesh().V()*su.field();
01822     return tC;
01823 }
01824 
01825 template<class Type>
01826 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01827 (
01828     const fvMatrix<Type>& A,
01829     const tmp<DimensionedField<Type, volMesh> >& tsu
01830 )
01831 {
01832     checkMethod(A, tsu(), "-");
01833     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01834     tC().source() += tsu().mesh().V()*tsu().field();
01835     tsu.clear();
01836     return tC;
01837 }
01838 
01839 template<class Type>
01840 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01841 (
01842     const fvMatrix<Type>& A,
01843     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01844 )
01845 {
01846     checkMethod(A, tsu(), "-");
01847     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01848     tC().source() += tsu().mesh().V()*tsu().internalField();
01849     tsu.clear();
01850     return tC;
01851 }
01852 
01853 template<class Type>
01854 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01855 (
01856     const tmp<fvMatrix<Type> >& tA,
01857     const DimensionedField<Type, volMesh>& su
01858 )
01859 {
01860     checkMethod(tA(), su, "-");
01861     tmp<fvMatrix<Type> > tC(tA.ptr());
01862     tC().source() += su.mesh().V()*su.field();
01863     return tC;
01864 }
01865 
01866 template<class Type>
01867 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01868 (
01869     const tmp<fvMatrix<Type> >& tA,
01870     const tmp<DimensionedField<Type, volMesh> >& tsu
01871 )
01872 {
01873     checkMethod(tA(), tsu(), "-");
01874     tmp<fvMatrix<Type> > tC(tA.ptr());
01875     tC().source() += tsu().mesh().V()*tsu().field();
01876     tsu.clear();
01877     return tC;
01878 }
01879 
01880 template<class Type>
01881 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01882 (
01883     const tmp<fvMatrix<Type> >& tA,
01884     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
01885 )
01886 {
01887     checkMethod(tA(), tsu(), "-");
01888     tmp<fvMatrix<Type> > tC(tA.ptr());
01889     tC().source() += tsu().mesh().V()*tsu().internalField();
01890     tsu.clear();
01891     return tC;
01892 }
01893 
01894 template<class Type>
01895 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01896 (
01897     const DimensionedField<Type, volMesh>& su,
01898     const fvMatrix<Type>& A
01899 )
01900 {
01901     checkMethod(A, su, "-");
01902     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01903     tC().negate();
01904     tC().source() -= su.mesh().V()*su.field();
01905     return tC;
01906 }
01907 
01908 template<class Type>
01909 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01910 (
01911     const tmp<DimensionedField<Type, volMesh> >& tsu,
01912     const fvMatrix<Type>& A
01913 )
01914 {
01915     checkMethod(A, tsu(), "-");
01916     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01917     tC().negate();
01918     tC().source() -= tsu().mesh().V()*tsu().field();
01919     tsu.clear();
01920     return tC;
01921 }
01922 
01923 template<class Type>
01924 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01925 (
01926     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
01927     const fvMatrix<Type>& A
01928 )
01929 {
01930     checkMethod(A, tsu(), "-");
01931     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01932     tC().negate();
01933     tC().source() -= tsu().mesh().V()*tsu().internalField();
01934     tsu.clear();
01935     return tC;
01936 }
01937 
01938 template<class Type>
01939 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01940 (
01941     const DimensionedField<Type, volMesh>& su,
01942     const tmp<fvMatrix<Type> >& tA
01943 )
01944 {
01945     checkMethod(tA(), su, "-");
01946     tmp<fvMatrix<Type> > tC(tA.ptr());
01947     tC().negate();
01948     tC().source() -= su.mesh().V()*su.field();
01949     return tC;
01950 }
01951 
01952 template<class Type>
01953 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01954 (
01955     const tmp<DimensionedField<Type, volMesh> >& tsu,
01956     const tmp<fvMatrix<Type> >& tA
01957 )
01958 {
01959     checkMethod(tA(), tsu(), "-");
01960     tmp<fvMatrix<Type> > tC(tA.ptr());
01961     tC().negate();
01962     tC().source() -= tsu().mesh().V()*tsu().field();
01963     tsu.clear();
01964     return tC;
01965 }
01966 
01967 template<class Type>
01968 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
01969 (
01970     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
01971     const tmp<fvMatrix<Type> >& tA
01972 )
01973 {
01974     checkMethod(tA(), tsu(), "-");
01975     tmp<fvMatrix<Type> > tC(tA.ptr());
01976     tC().negate();
01977     tC().source() -= tsu().mesh().V()*tsu().internalField();
01978     tsu.clear();
01979     return tC;
01980 }
01981 
01982 template<class Type>
01983 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01984 (
01985     const fvMatrix<Type>& A,
01986     const dimensioned<Type>& su
01987 )
01988 {
01989     checkMethod(A, su, "+");
01990     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
01991     tC().source() -= su.value()*A.psi().mesh().V();
01992     return tC;
01993 }
01994 
01995 template<class Type>
01996 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
01997 (
01998     const tmp<fvMatrix<Type> >& tA,
01999     const dimensioned<Type>& su
02000 )
02001 {
02002     checkMethod(tA(), su, "+");
02003     tmp<fvMatrix<Type> > tC(tA.ptr());
02004     tC().source() -= su.value()*tC().psi().mesh().V();
02005     return tC;
02006 }
02007 
02008 template<class Type>
02009 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
02010 (
02011     const dimensioned<Type>& su,
02012     const fvMatrix<Type>& A
02013 )
02014 {
02015     checkMethod(A, su, "+");
02016     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
02017     tC().source() -= su.value()*A.psi().mesh().V();
02018     return tC;
02019 }
02020 
02021 template<class Type>
02022 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
02023 (
02024     const dimensioned<Type>& su,
02025     const tmp<fvMatrix<Type> >& tA
02026 )
02027 {
02028     checkMethod(tA(), su, "+");
02029     tmp<fvMatrix<Type> > tC(tA.ptr());
02030     tC().source() -= su.value()*tC().psi().mesh().V();
02031     return tC;
02032 }
02033 
02034 template<class Type>
02035 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
02036 (
02037     const fvMatrix<Type>& A,
02038     const dimensioned<Type>& su
02039 )
02040 {
02041     checkMethod(A, su, "-");
02042     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
02043     tC().source() += su.value()*tC().psi().mesh().V();
02044     return tC;
02045 }
02046 
02047 template<class Type>
02048 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
02049 (
02050     const tmp<fvMatrix<Type> >& tA,
02051     const dimensioned<Type>& su
02052 )
02053 {
02054     checkMethod(tA(), su, "-");
02055     tmp<fvMatrix<Type> > tC(tA.ptr());
02056     tC().source() += su.value()*tC().psi().mesh().V();
02057     return tC;
02058 }
02059 
02060 template<class Type>
02061 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
02062 (
02063     const dimensioned<Type>& su,
02064     const fvMatrix<Type>& A
02065 )
02066 {
02067     checkMethod(A, su, "-");
02068     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
02069     tC().negate();
02070     tC().source() -= su.value()*A.psi().mesh().V();
02071     return tC;
02072 }
02073 
02074 template<class Type>
02075 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
02076 (
02077     const dimensioned<Type>& su,
02078     const tmp<fvMatrix<Type> >& tA
02079 )
02080 {
02081     checkMethod(tA(), su, "-");
02082     tmp<fvMatrix<Type> > tC(tA.ptr());
02083     tC().negate();
02084     tC().source() -= su.value()*tC().psi().mesh().V();
02085     return tC;
02086 }
02087 
02088 
02089 template<class Type>
02090 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02091 (
02092     const DimensionedField<scalar, volMesh>& dsf,
02093     const fvMatrix<Type>& A
02094 )
02095 {
02096     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
02097     tC() *= dsf;
02098     return tC;
02099 }
02100 
02101 template<class Type>
02102 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02103 (
02104     const tmp< DimensionedField<scalar, volMesh> >& tdsf,
02105     const fvMatrix<Type>& A
02106 )
02107 {
02108     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
02109     tC() *= tdsf;
02110     return tC;
02111 }
02112 
02113 template<class Type>
02114 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02115 (
02116     const tmp<volScalarField>& tvsf,
02117     const fvMatrix<Type>& A
02118 )
02119 {
02120     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
02121     tC() *= tvsf;
02122     return tC;
02123 }
02124 
02125 template<class Type>
02126 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02127 (
02128     const DimensionedField<scalar, volMesh>& dsf,
02129     const tmp<fvMatrix<Type> >& tA
02130 )
02131 {
02132     tmp<fvMatrix<Type> > tC(tA.ptr());
02133     tC() *= dsf;
02134     return tC;
02135 }
02136 
02137 template<class Type>
02138 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02139 (
02140     const tmp<DimensionedField<scalar, volMesh> >& tdsf,
02141     const tmp<fvMatrix<Type> >& tA
02142 )
02143 {
02144     tmp<fvMatrix<Type> > tC(tA.ptr());
02145     tC() *= tdsf;
02146     return tC;
02147 }
02148 
02149 template<class Type>
02150 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02151 (
02152     const tmp<volScalarField>& tvsf,
02153     const tmp<fvMatrix<Type> >& tA
02154 )
02155 {
02156     tmp<fvMatrix<Type> > tC(tA.ptr());
02157     tC() *= tvsf;
02158     return tC;
02159 }
02160 
02161 template<class Type>
02162 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02163 (
02164     const dimensioned<scalar>& ds,
02165     const fvMatrix<Type>& A
02166 )
02167 {
02168     tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
02169     tC() *= ds;
02170     return tC;
02171 }
02172 
02173 template<class Type>
02174 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
02175 (
02176     const dimensioned<scalar>& ds,
02177     const tmp<fvMatrix<Type> >& tA
02178 )
02179 {
02180     tmp<fvMatrix<Type> > tC(tA.ptr());
02181     tC() *= ds;
02182     return tC;
02183 }
02184 
02185 
02186 template<class Type>
02187 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
02188 Foam::operator&
02189 (
02190     const fvMatrix<Type>& M,
02191     const DimensionedField<Type, volMesh>& psi
02192 )
02193 {
02194     tmp<GeometricField<Type, fvPatchField, volMesh> > tMphi
02195     (
02196         new GeometricField<Type, fvPatchField, volMesh>
02197         (
02198             IOobject
02199             (
02200                 "M&" + psi.name(),
02201                 psi.instance(),
02202                 psi.mesh(),
02203                 IOobject::NO_READ,
02204                 IOobject::NO_WRITE
02205             ),
02206             psi.mesh(),
02207             M.dimensions()/dimVol,
02208             zeroGradientFvPatchScalarField::typeName
02209         )
02210     );
02211     GeometricField<Type, fvPatchField, volMesh>& Mphi = tMphi();
02212 
02213     // Loop over field components
02214     for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
02215     {
02216         scalarField psiCmpt = psi.field().component(cmpt);
02217         scalarField boundaryDiagCmpt(M.diag());
02218         M.addBoundaryDiag(boundaryDiagCmpt, cmpt);
02219         Mphi.internalField().replace(cmpt, -boundaryDiagCmpt*psiCmpt);
02220     }
02221 
02222     Mphi.internalField() += M.lduMatrix::H(psi.field()) + M.source();
02223     M.addBoundarySource(Mphi.internalField());
02224 
02225     Mphi.internalField() /= -psi.mesh().V();
02226     Mphi.correctBoundaryConditions();
02227 
02228     return tMphi;
02229 }
02230 
02231 template<class Type>
02232 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
02233 Foam::operator&
02234 (
02235     const fvMatrix<Type>& M,
02236     const tmp<DimensionedField<Type, volMesh> >& tpsi
02237 )
02238 {
02239     tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = M & tpsi();
02240     tpsi.clear();
02241     return tMpsi;
02242 }
02243 
02244 template<class Type>
02245 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
02246 Foam::operator&
02247 (
02248     const fvMatrix<Type>& M,
02249     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tpsi
02250 )
02251 {
02252     tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = M & tpsi();
02253     tpsi.clear();
02254     return tMpsi;
02255 }
02256 
02257 template<class Type>
02258 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
02259 Foam::operator&
02260 (
02261     const tmp<fvMatrix<Type> >& tM,
02262     const DimensionedField<Type, volMesh>& psi
02263 )
02264 {
02265     tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = tM() & psi;
02266     tM.clear();
02267     return tMpsi;
02268 }
02269 
02270 template<class Type>
02271 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
02272 Foam::operator&
02273 (
02274     const tmp<fvMatrix<Type> >& tM,
02275     const tmp<DimensionedField<Type, volMesh> >& tpsi
02276 )
02277 {
02278     tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = tM() & tpsi();
02279     tM.clear();
02280     tpsi.clear();
02281     return tMpsi;
02282 }
02283 
02284 template<class Type>
02285 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
02286 Foam::operator&
02287 (
02288     const tmp<fvMatrix<Type> >& tM,
02289     const tmp<GeometricField<Type, fvPatchField, volMesh> >& tpsi
02290 )
02291 {
02292     tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = tM() & tpsi();
02293     tM.clear();
02294     tpsi.clear();
02295     return tMpsi;
02296 }
02297 
02298 
02299 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
02300 
02301 template<class Type>
02302 Foam::Ostream& Foam::operator<<(Ostream& os, const fvMatrix<Type>& fvm)
02303 {
02304     os  << static_cast<const lduMatrix&>(fvm) << nl
02305         << fvm.dimensions_ << nl
02306         << fvm.source_ << nl
02307         << fvm.internalCoeffs_ << nl
02308         << fvm.boundaryCoeffs_ << endl;
02309 
02310     os.check("Ostream& operator<<(Ostream&, fvMatrix<Type>&");
02311 
02312     return os;
02313 }
02314 
02315 
02316 // * * * * * * * * * * * * * * * * Solvers * * * * * * * * * * * * * * * * * //
02317 
02318 #include "fvMatrixSolve.C"
02319 
02320 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd