1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 #include "calculatedFvPatchFields.H"
30 #include "zeroGradientFvPatchFields.H"
31 #include "coupledFvPatchFields.H"
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 void Foam::fvMatrix<Type>::addToInternalField
39 const unallocLabelList& addr,
40 const Field<Type2>& pf,
44 if (addr.size() != pf.size())
48 "fvMatrix<Type>::addToInternalField(const unallocLabelList&, "
49 "const Field&, Field&)"
50 ) << "sizes of addressing and field are different"
56 intf[addr[faceI]] += pf[faceI];
63 void Foam::fvMatrix<Type>::addToInternalField
65 const unallocLabelList& addr,
66 const tmp<Field<Type2> >& tpf,
70 addToInternalField(addr, tpf(), intf);
77 void Foam::fvMatrix<Type>::subtractFromInternalField
79 const unallocLabelList& addr,
80 const Field<Type2>& pf,
84 if (addr.size() != pf.size())
88 "fvMatrix<Type>::addToInternalField(const unallocLabelList&, "
89 "const Field&, Field&)"
90 ) << "sizes of addressing and field are different"
96 intf[addr[faceI]] -= pf[faceI];
102 template<class Type2>
103 void Foam::fvMatrix<Type>::subtractFromInternalField
105 const unallocLabelList& addr,
106 const tmp<Field<Type2> >& tpf,
110 subtractFromInternalField(addr, tpf(), intf);
116 void Foam::fvMatrix<Type>::addBoundaryDiag
119 const direction solveCmpt
122 forAll(internalCoeffs_, patchI)
126 lduAddr().patchAddr(patchI),
127 internalCoeffs_[patchI].component(solveCmpt),
135 void Foam::fvMatrix<Type>::addCmptAvBoundaryDiag(scalarField& diag) const
137 forAll(internalCoeffs_, patchI)
141 lduAddr().patchAddr(patchI),
142 cmptAv(internalCoeffs_[patchI]),
150 void Foam::fvMatrix<Type>::addBoundarySource
156 forAll(psi_.boundaryField(), patchI)
158 const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
159 const Field<Type>& pbc = boundaryCoeffs_[patchI];
163 addToInternalField(lduAddr().patchAddr(patchI), pbc, source);
167 tmp<Field<Type> > tpnf = ptf.patchNeighbourField();
168 const Field<Type>& pnf = tpnf();
170 const unallocLabelList& addr = lduAddr().patchAddr(patchI);
174 source[addr[facei]] += cmptMultiply(pbc[facei], pnf[facei]);
181 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
184 Foam::fvMatrix<Type>::fvMatrix
186 GeometricField<Type, fvPatchField, volMesh>& psi,
187 const dimensionSet& ds
190 lduMatrix(psi.mesh()),
193 source_(psi.size(), pTraits<Type>::zero),
194 internalCoeffs_(psi.mesh().boundary().size()),
195 boundaryCoeffs_(psi.mesh().boundary().size()),
196 faceFluxCorrectionPtr_(NULL)
200 Info<< "fvMatrix<Type>(GeometricField<Type, fvPatchField, volMesh>&,"
201 " const dimensionSet&) : "
202 "constructing fvMatrix<Type> for field " << psi_.name()
206 // Initialise coupling coefficients
207 forAll (psi.mesh().boundary(), patchI)
214 psi.mesh().boundary()[patchI].size(),
224 psi.mesh().boundary()[patchI].size(),
230 psi_.boundaryField().updateCoeffs();
235 Foam::fvMatrix<Type>::fvMatrix(const fvMatrix<Type>& fvm)
240 dimensions_(fvm.dimensions_),
241 source_(fvm.source_),
242 internalCoeffs_(fvm.internalCoeffs_),
243 boundaryCoeffs_(fvm.boundaryCoeffs_),
244 faceFluxCorrectionPtr_(NULL)
248 Info<< "fvMatrix<Type>::fvMatrix(const fvMatrix<Type>&) : "
249 << "copying fvMatrix<Type> for field " << psi_.name()
253 if (fvm.faceFluxCorrectionPtr_)
255 faceFluxCorrectionPtr_ = new
256 GeometricField<Type, fvsPatchField, surfaceMesh>
258 *(fvm.faceFluxCorrectionPtr_)
264 #ifdef ConstructFromTmp
266 Foam::fvMatrix<Type>::fvMatrix(const tmp<fvMatrix<Type> >& tfvm)
271 const_cast<fvMatrix<Type>&>(tfvm()),
275 dimensions_(tfvm().dimensions_),
278 const_cast<fvMatrix<Type>&>(tfvm()).source_,
283 const_cast<fvMatrix<Type>&>(tfvm()).internalCoeffs_,
288 const_cast<fvMatrix<Type>&>(tfvm()).boundaryCoeffs_,
291 faceFluxCorrectionPtr_(NULL)
295 Info<< "fvMatrix<Type>::fvMatrix(const tmp<fvMatrix<Type> >&) : "
296 << "copying fvMatrix<Type> for field " << psi_.name()
300 if (tfvm().faceFluxCorrectionPtr_)
304 faceFluxCorrectionPtr_ = tfvm().faceFluxCorrectionPtr_;
305 tfvm().faceFluxCorrectionPtr_ = NULL;
309 faceFluxCorrectionPtr_ = new
310 GeometricField<Type, fvsPatchField, surfaceMesh>
312 *(tfvm().faceFluxCorrectionPtr_)
323 Foam::fvMatrix<Type>::fvMatrix
325 GeometricField<Type, fvPatchField, volMesh>& psi,
329 lduMatrix(psi.mesh()),
333 internalCoeffs_(psi.mesh().boundary().size()),
334 boundaryCoeffs_(psi.mesh().boundary().size()),
335 faceFluxCorrectionPtr_(NULL)
339 Info<< "fvMatrix<Type>(GeometricField<Type, fvPatchField, volMesh>&,"
341 "constructing fvMatrix<Type> for field " << psi_.name()
345 // Initialise coupling coefficients
346 forAll (psi.mesh().boundary(), patchI)
353 psi.mesh().boundary()[patchI].size(),
363 psi.mesh().boundary()[patchI].size(),
373 Foam::fvMatrix<Type>::~fvMatrix()
377 Info<< "fvMatrix<Type>::~fvMatrix<Type>() : "
378 << "destroying fvMatrix<Type> for field " << psi_.name()
382 if (faceFluxCorrectionPtr_)
384 delete faceFluxCorrectionPtr_;
389 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
391 // Set solution in given cells and eliminate corresponding
392 // equations from the matrix
394 void Foam::fvMatrix<Type>::setValues
396 const labelList& cellLabels,
397 const Field<Type>& values
400 const fvMesh& mesh = psi_.mesh();
402 const cellList& cells = mesh.cells();
403 const unallocLabelList& own = mesh.owner();
404 const unallocLabelList& nei = mesh.neighbour();
406 scalarField& Diag = diag();
408 forAll(cellLabels, i)
410 label celli = cellLabels[i];
412 psi_[celli] = values[i];
413 source_[celli] = values[i]*Diag[celli];
415 if (symmetric() || asymmetric())
417 const cell& c = cells[celli];
423 if (mesh.isInternalFace(facei))
427 if (celli == own[facei])
429 source_[nei[facei]] -= upper()[facei]*values[i];
433 source_[own[facei]] -= upper()[facei]*values[i];
436 upper()[facei] = 0.0;
440 if (celli == own[facei])
442 source_[nei[facei]] -= lower()[facei]*values[i];
446 source_[own[facei]] -= upper()[facei]*values[i];
449 upper()[facei] = 0.0;
450 lower()[facei] = 0.0;
455 label patchi = mesh.boundaryMesh().whichPatch(facei);
457 if (internalCoeffs_[patchi].size())
460 mesh.boundaryMesh()[patchi].whichFace(facei);
462 internalCoeffs_[patchi][patchFacei] =
465 boundaryCoeffs_[patchi][patchFacei] =
476 void Foam::fvMatrix<Type>::setReference
480 const bool forceReference
483 if ((forceReference || psi_.needReference()) && celli >= 0)
485 source()[celli] += diag()[celli]*value;
486 diag()[celli] += diag()[celli];
492 void Foam::fvMatrix<Type>::relax(const scalar alpha)
499 Field<Type>& S = source();
500 scalarField& D = diag();
502 // Store the current unrelaxed diagonal for use in updating the source
505 // Calculate the sum-mag off-diagonal from the interior faces
506 scalarField sumOff(D.size(), 0.0);
507 sumMagOffDiag(sumOff);
509 // Handle the boundary contributions to the diagonal
510 forAll(psi_.boundaryField(), patchI)
512 const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
516 const unallocLabelList& pa = lduAddr().patchAddr(patchI);
517 Field<Type>& iCoeffs = internalCoeffs_[patchI];
521 const Field<Type>& pCoeffs = boundaryCoeffs_[patchI];
523 // For coupled boundaries add the diagonal and
524 // off-diagonal contributions
527 D[pa[face]] += component(iCoeffs[face], 0);
528 sumOff[pa[face]] += mag(component(pCoeffs[face], 0));
533 // For non-coupled boundaries subtract the diagonal
534 // contribution off-diagonal sum which avoids having to remove
535 // it from the diagonal later.
536 // Also add the source contribution from the relaxation
539 Type iCoeff0 = iCoeffs[face];
540 iCoeffs[face] = cmptMag(iCoeffs[face]);
541 sumOff[pa[face]] -= cmptMin(iCoeffs[face]);
542 iCoeffs[face] /= alpha;
544 cmptMultiply(iCoeffs[face] - iCoeff0, psi_[pa[face]]);
550 // Ensure the matrix is diagonally dominant...
556 // Now remove the diagonal contribution from coupled boundaries
557 forAll(psi_.boundaryField(), patchI)
559 const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
563 const unallocLabelList& pa = lduAddr().patchAddr(patchI);
564 Field<Type>& iCoeffs = internalCoeffs_[patchI];
570 D[pa[face]] -= component(iCoeffs[face], 0);
576 // Finally add the relaxation contribution to the source.
577 S += (D - D0)*psi_.internalField();
582 void Foam::fvMatrix<Type>::relax()
584 if (psi_.mesh().relax(psi_.name()))
586 relax(psi_.mesh().relaxationFactor(psi_.name()));
592 Foam::tmp<Foam::scalarField> Foam::fvMatrix<Type>::D() const
594 tmp<scalarField> tdiag(new scalarField(diag()));
595 addCmptAvBoundaryDiag(tdiag());
601 Foam::tmp<Foam::Field<Type> > Foam::fvMatrix<Type>::DD() const
603 tmp<Field<Type> > tdiag(pTraits<Type>::one*diag());
605 forAll(psi_.boundaryField(), patchI)
607 const fvPatchField<Type>& ptf = psi_.boundaryField()[patchI];
609 if (!ptf.coupled() && ptf.size())
613 lduAddr().patchAddr(patchI),
614 internalCoeffs_[patchI],
625 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Type>::A() const
627 tmp<volScalarField> tAphi
633 "A("+psi_.name()+')',
640 dimensions_/psi_.dimensions()/dimVol,
641 zeroGradientFvPatchScalarField::typeName
645 tAphi().internalField() = D()/psi_.mesh().V();
646 tAphi().correctBoundaryConditions();
653 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
654 Foam::fvMatrix<Type>::H() const
656 tmp<GeometricField<Type, fvPatchField, volMesh> > tHphi
658 new GeometricField<Type, fvPatchField, volMesh>
662 "H("+psi_.name()+')',
670 zeroGradientFvPatchScalarField::typeName
673 GeometricField<Type, fvPatchField, volMesh>& Hphi = tHphi();
675 // Loop over field components
676 for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
678 scalarField psiCmpt = psi_.internalField().component(cmpt);
680 scalarField boundaryDiagCmpt(psi_.size(), 0.0);
681 addBoundaryDiag(boundaryDiagCmpt, cmpt);
682 boundaryDiagCmpt.negate();
683 addCmptAvBoundaryDiag(boundaryDiagCmpt);
685 Hphi.internalField().replace(cmpt, boundaryDiagCmpt*psiCmpt);
688 Hphi.internalField() += lduMatrix::H(psi_.internalField()) + source_;
689 addBoundarySource(Hphi.internalField());
691 Hphi.internalField() /= psi_.mesh().V();
692 Hphi.correctBoundaryConditions();
694 typename Type::labelType validComponents
698 psi_.mesh().directions(),
699 pTraits<typename powProduct<Vector<label>, Type::rank>::type>::zero
703 for(direction cmpt=0; cmpt<Type::nComponents; cmpt++)
705 if (validComponents[cmpt] == -1)
710 dimensionedScalar("0", Hphi.dimensions(), 0.0)
720 Foam::tmp<Foam::volScalarField> Foam::fvMatrix<Type>::H1() const
722 tmp<volScalarField> tH1
735 dimensions_/(dimVol*psi_.dimensions()),
736 zeroGradientFvPatchScalarField::typeName
739 volScalarField& H1_ = tH1();
741 // Loop over field components
743 for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
745 scalarField psiCmpt = psi_.internalField().component(cmpt);
747 scalarField boundaryDiagCmpt(psi_.size(), 0.0);
748 addBoundaryDiag(boundaryDiagCmpt, cmpt);
749 boundaryDiagCmpt.negate();
750 addCmptAvBoundaryDiag(boundaryDiagCmpt);
752 H1_.internalField().replace(cmpt, boundaryDiagCmpt);
755 H1_.internalField() += lduMatrix::H1();
758 H1_.internalField() = lduMatrix::H1();
760 H1_.internalField() /= psi_.mesh().V();
761 H1_.correctBoundaryConditions();
768 Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
769 Foam::fvMatrix<Type>::
772 if (!psi_.mesh().fluxRequired(psi_.name()))
774 FatalErrorIn("fvMatrix<Type>::flux()")
775 << "flux requested but " << psi_.name()
776 << " not specified in the fluxRequired sub-dictionary"
778 << abort(FatalError);
781 // construct GeometricField<Type, fvsPatchField, surfaceMesh>
782 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tfieldFlux
784 new GeometricField<Type, fvsPatchField, surfaceMesh>
788 "flux("+psi_.name()+')',
798 GeometricField<Type, fvsPatchField, surfaceMesh>& fieldFlux = tfieldFlux();
800 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
802 fieldFlux.internalField().replace
805 lduMatrix::faceH(psi_.internalField().component(cmpt))
809 FieldField<Field, Type> InternalContrib = internalCoeffs_;
811 forAll(InternalContrib, patchI)
813 InternalContrib[patchI] =
816 InternalContrib[patchI],
817 psi_.boundaryField()[patchI].patchInternalField()
821 FieldField<Field, Type> NeighbourContrib = boundaryCoeffs_;
823 forAll(NeighbourContrib, patchI)
825 if (psi_.boundaryField()[patchI].coupled())
827 NeighbourContrib[patchI] =
830 NeighbourContrib[patchI],
831 psi_.boundaryField()[patchI].patchNeighbourField()
836 forAll(fieldFlux.boundaryField(), patchI)
838 fieldFlux.boundaryField()[patchI] =
839 InternalContrib[patchI] - NeighbourContrib[patchI];
842 if (faceFluxCorrectionPtr_)
844 fieldFlux += *faceFluxCorrectionPtr_;
851 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
854 void Foam::fvMatrix<Type>::operator=(const fvMatrix<Type>& fvmv)
858 FatalErrorIn("fvMatrix<Type>::operator=(const fvMatrix<Type>&)")
859 << "attempted assignment to self"
860 << abort(FatalError);
863 if (&psi_ != &(fvmv.psi_))
865 FatalErrorIn("fvMatrix<Type>::operator=(const fvMatrix<Type>&)")
866 << "different fields"
867 << abort(FatalError);
870 lduMatrix::operator=(fvmv);
871 source_ = fvmv.source_;
872 internalCoeffs_ = fvmv.internalCoeffs_;
873 boundaryCoeffs_ = fvmv.boundaryCoeffs_;
875 if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
877 *faceFluxCorrectionPtr_ = *fvmv.faceFluxCorrectionPtr_;
879 else if (fvmv.faceFluxCorrectionPtr_)
881 faceFluxCorrectionPtr_ =
882 new GeometricField<Type, fvsPatchField, surfaceMesh>
883 (*fvmv.faceFluxCorrectionPtr_);
889 void Foam::fvMatrix<Type>::operator=(const tmp<fvMatrix<Type> >& tfvmv)
897 void Foam::fvMatrix<Type>::negate()
901 internalCoeffs_.negate();
902 boundaryCoeffs_.negate();
904 if (faceFluxCorrectionPtr_)
906 faceFluxCorrectionPtr_->negate();
912 void Foam::fvMatrix<Type>::operator+=(const fvMatrix<Type>& fvmv)
914 checkMethod(*this, fvmv, "+=");
916 dimensions_ += fvmv.dimensions_;
917 lduMatrix::operator+=(fvmv);
918 source_ += fvmv.source_;
919 internalCoeffs_ += fvmv.internalCoeffs_;
920 boundaryCoeffs_ += fvmv.boundaryCoeffs_;
922 if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
924 *faceFluxCorrectionPtr_ += *fvmv.faceFluxCorrectionPtr_;
926 else if (fvmv.faceFluxCorrectionPtr_)
928 faceFluxCorrectionPtr_ = new
929 GeometricField<Type, fvsPatchField, surfaceMesh>
931 *fvmv.faceFluxCorrectionPtr_
938 void Foam::fvMatrix<Type>::operator+=(const tmp<fvMatrix<Type> >& tfvmv)
946 void Foam::fvMatrix<Type>::operator-=(const fvMatrix<Type>& fvmv)
948 checkMethod(*this, fvmv, "+=");
950 dimensions_ -= fvmv.dimensions_;
951 lduMatrix::operator-=(fvmv);
952 source_ -= fvmv.source_;
953 internalCoeffs_ -= fvmv.internalCoeffs_;
954 boundaryCoeffs_ -= fvmv.boundaryCoeffs_;
956 if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
958 *faceFluxCorrectionPtr_ -= *fvmv.faceFluxCorrectionPtr_;
960 else if (fvmv.faceFluxCorrectionPtr_)
962 faceFluxCorrectionPtr_ =
963 new GeometricField<Type, fvsPatchField, surfaceMesh>
964 (-*fvmv.faceFluxCorrectionPtr_);
970 void Foam::fvMatrix<Type>::operator-=(const tmp<fvMatrix<Type> >& tfvmv)
978 void Foam::fvMatrix<Type>::operator+=
980 const DimensionedField<Type, volMesh>& su
983 checkMethod(*this, su, "+=");
984 source() -= su.mesh().V()*su.field();
989 void Foam::fvMatrix<Type>::operator+=
991 const tmp<DimensionedField<Type, volMesh> >& tsu
1000 void Foam::fvMatrix<Type>::operator+=
1002 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1010 template<class Type>
1011 void Foam::fvMatrix<Type>::operator-=
1013 const DimensionedField<Type, volMesh>& su
1016 checkMethod(*this, su, "-=");
1017 source() += su.mesh().V()*su.field();
1021 template<class Type>
1022 void Foam::fvMatrix<Type>::operator-=
1024 const tmp<DimensionedField<Type, volMesh> >& tsu
1032 template<class Type>
1033 void Foam::fvMatrix<Type>::operator-=
1035 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1043 template<class Type>
1044 void Foam::fvMatrix<Type>::operator+=
1046 const dimensioned<Type>& su
1049 source() -= psi().mesh().V()*su;
1053 template<class Type>
1054 void Foam::fvMatrix<Type>::operator-=
1056 const dimensioned<Type>& su
1059 source() += psi().mesh().V()*su;
1063 template<class Type>
1064 void Foam::fvMatrix<Type>::operator+=
1071 template<class Type>
1072 void Foam::fvMatrix<Type>::operator-=
1079 template<class Type>
1080 void Foam::fvMatrix<Type>::operator*=
1082 const DimensionedField<scalar, volMesh>& dsf
1085 dimensions_ *= dsf.dimensions();
1086 lduMatrix::operator*=(dsf.field());
1087 source_ *= dsf.field();
1089 forAll(boundaryCoeffs_, patchI)
1093 dsf.mesh().boundary()[patchI].patchInternalField(dsf.field())
1096 internalCoeffs_[patchI] *= psf;
1097 boundaryCoeffs_[patchI] *= psf;
1100 if (faceFluxCorrectionPtr_)
1104 "fvMatrix<Type>::operator*="
1105 "(const DimensionedField<scalar, volMesh>&)"
1106 ) << "cannot scale a matrix containing a faceFluxCorrection"
1107 << abort(FatalError);
1112 template<class Type>
1113 void Foam::fvMatrix<Type>::operator*=
1115 const tmp<DimensionedField<scalar, volMesh> >& tdsf
1123 template<class Type>
1124 void Foam::fvMatrix<Type>::operator*=
1126 const tmp<volScalarField>& tvsf
1134 template<class Type>
1135 void Foam::fvMatrix<Type>::operator*=
1137 const dimensioned<scalar>& ds
1140 dimensions_ *= ds.dimensions();
1141 lduMatrix::operator*=(ds.value());
1142 source_ *= ds.value();
1143 internalCoeffs_ *= ds.value();
1144 boundaryCoeffs_ *= ds.value();
1146 if (faceFluxCorrectionPtr_)
1148 *faceFluxCorrectionPtr_ *= ds.value();
1153 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
1155 template<class Type>
1156 void Foam::checkMethod
1158 const fvMatrix<Type>& fvm1,
1159 const fvMatrix<Type>& fvm2,
1163 if (&fvm1.psi() != &fvm2.psi())
1167 "checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)"
1168 ) << "incompatible fields for operation "
1170 << "[" << fvm1.psi().name() << "] "
1172 << " [" << fvm2.psi().name() << "]"
1173 << abort(FatalError);
1176 if (dimensionSet::debug && fvm1.dimensions() != fvm2.dimensions())
1180 "checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&)"
1181 ) << "incompatible dimensions for operation "
1183 << "[" << fvm1.psi().name() << fvm1.dimensions()/dimVolume << " ] "
1185 << " [" << fvm2.psi().name() << fvm2.dimensions()/dimVolume << " ]"
1186 << abort(FatalError);
1191 template<class Type>
1192 void Foam::checkMethod
1194 const fvMatrix<Type>& fvm,
1195 const DimensionedField<Type, volMesh>& df,
1199 if (dimensionSet::debug && fvm.dimensions()/dimVolume != df.dimensions())
1203 "checkMethod(const fvMatrix<Type>&, const GeometricField<Type, "
1204 "fvPatchField, volMesh>&)"
1205 ) << "incompatible dimensions for operation "
1207 << "[" << fvm.psi().name() << fvm.dimensions()/dimVolume << " ] "
1209 << " [" << df.name() << df.dimensions() << " ]"
1210 << abort(FatalError);
1215 template<class Type>
1216 void Foam::checkMethod
1218 const fvMatrix<Type>& fvm,
1219 const dimensioned<Type>& dt,
1223 if (dimensionSet::debug && fvm.dimensions()/dimVolume != dt.dimensions())
1227 "checkMethod(const fvMatrix<Type>&, const dimensioned<Type>&)"
1228 ) << "incompatible dimensions for operation "
1230 << "[" << fvm.psi().name() << fvm.dimensions()/dimVolume << " ] "
1232 << " [" << dt.name() << dt.dimensions() << " ]"
1233 << abort(FatalError);
1238 template<class Type>
1239 Foam::lduMatrix::solverPerformance Foam::solve
1241 fvMatrix<Type>& fvm,
1242 Istream& solverControls
1245 return fvm.solve(solverControls);
1248 template<class Type>
1249 Foam::lduMatrix::solverPerformance Foam::solve
1251 const tmp<fvMatrix<Type> >& tfvm,
1252 Istream& solverControls
1255 lduMatrix::solverPerformance solverPerf =
1256 const_cast<fvMatrix<Type>&>(tfvm()).solve(solverControls);
1264 template<class Type>
1265 Foam::lduMatrix::solverPerformance Foam::solve(fvMatrix<Type>& fvm)
1270 template<class Type>
1271 Foam::lduMatrix::solverPerformance Foam::solve
1273 const tmp<fvMatrix<Type> >& tfvm
1276 lduMatrix::solverPerformance solverPerf =
1277 const_cast<fvMatrix<Type>&>(tfvm()).solve();
1285 template<class Type>
1286 Foam::tmp<Foam::fvMatrix<Type> > Foam::correction
1288 const fvMatrix<Type>& A
1291 tmp<Foam::fvMatrix<Type> > tAcorr = A - (A & A.psi());
1295 (A.hasUpper() || A.hasLower())
1296 && A.psi().mesh().fluxRequired(A.psi().name())
1299 tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr();
1306 template<class Type>
1307 Foam::tmp<Foam::fvMatrix<Type> > Foam::correction
1309 const tmp<fvMatrix<Type> >& tA
1312 tmp<Foam::fvMatrix<Type> > tAcorr = tA - (tA() & tA().psi());
1314 // Note the matrix coefficients are still that of matrix A
1315 const fvMatrix<Type>& A = tAcorr();
1319 (A.hasUpper() || A.hasLower())
1320 && A.psi().mesh().fluxRequired(A.psi().name())
1323 tAcorr().faceFluxCorrectionPtr() = (-A.flux()).ptr();
1330 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
1332 template<class Type>
1333 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1335 const fvMatrix<Type>& A,
1336 const fvMatrix<Type>& B
1339 checkMethod(A, B, "==");
1343 template<class Type>
1344 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1346 const tmp<fvMatrix<Type> >& tA,
1347 const fvMatrix<Type>& B
1350 checkMethod(tA(), B, "==");
1354 template<class Type>
1355 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1357 const fvMatrix<Type>& A,
1358 const tmp<fvMatrix<Type> >& tB
1361 checkMethod(A, tB(), "==");
1365 template<class Type>
1366 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1368 const tmp<fvMatrix<Type> >& tA,
1369 const tmp<fvMatrix<Type> >& tB
1372 checkMethod(tA(), tB(), "==");
1376 template<class Type>
1377 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1379 const fvMatrix<Type>& A,
1380 const DimensionedField<Type, volMesh>& su
1383 checkMethod(A, su, "==");
1384 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1385 tC().source() += su.mesh().V()*su.field();
1389 template<class Type>
1390 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1392 const fvMatrix<Type>& A,
1393 const tmp<DimensionedField<Type, volMesh> >& tsu
1396 checkMethod(A, tsu(), "==");
1397 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1398 tC().source() += tsu().mesh().V()*tsu().field();
1403 template<class Type>
1404 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1406 const fvMatrix<Type>& A,
1407 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1410 checkMethod(A, tsu(), "==");
1411 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1412 tC().source() += tsu().mesh().V()*tsu().internalField();
1417 template<class Type>
1418 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1420 const tmp<fvMatrix<Type> >& tA,
1421 const DimensionedField<Type, volMesh>& su
1424 checkMethod(tA(), su, "==");
1425 tmp<fvMatrix<Type> > tC(tA.ptr());
1426 tC().source() += su.mesh().V()*su.field();
1430 template<class Type>
1431 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1433 const tmp<fvMatrix<Type> >& tA,
1434 const tmp<DimensionedField<Type, volMesh> >& tsu
1437 checkMethod(tA(), tsu(), "==");
1438 tmp<fvMatrix<Type> > tC(tA.ptr());
1439 tC().source() += tsu().mesh().V()*tsu().field();
1444 template<class Type>
1445 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1447 const tmp<fvMatrix<Type> >& tA,
1448 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1451 checkMethod(tA(), tsu(), "==");
1452 tmp<fvMatrix<Type> > tC(tA.ptr());
1453 tC().source() += tsu().mesh().V()*tsu().internalField();
1458 template<class Type>
1459 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1461 const fvMatrix<Type>& A,
1462 const dimensioned<Type>& su
1465 checkMethod(A, su, "==");
1466 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1467 tC().source() += A.psi().mesh().V()*su.value();
1471 template<class Type>
1472 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1474 const tmp<fvMatrix<Type> >& tA,
1475 const dimensioned<Type>& su
1478 checkMethod(tA(), su, "==");
1479 tmp<fvMatrix<Type> > tC(tA.ptr());
1480 tC().source() += tC().psi().mesh().V()*su.value();
1484 template<class Type>
1485 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1487 const fvMatrix<Type>& A,
1495 template<class Type>
1496 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator==
1498 const tmp<fvMatrix<Type> >& tA,
1506 template<class Type>
1507 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1509 const fvMatrix<Type>& A
1512 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1517 template<class Type>
1518 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1520 const tmp<fvMatrix<Type> >& tA
1523 tmp<fvMatrix<Type> > tC(tA.ptr());
1529 template<class Type>
1530 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1532 const fvMatrix<Type>& A,
1533 const fvMatrix<Type>& B
1536 checkMethod(A, B, "+");
1537 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1542 template<class Type>
1543 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1545 const tmp<fvMatrix<Type> >& tA,
1546 const fvMatrix<Type>& B
1549 checkMethod(tA(), B, "+");
1550 tmp<fvMatrix<Type> > tC(tA.ptr());
1555 template<class Type>
1556 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1558 const fvMatrix<Type>& A,
1559 const tmp<fvMatrix<Type> >& tB
1562 checkMethod(A, tB(), "+");
1563 tmp<fvMatrix<Type> > tC(tB.ptr());
1568 template<class Type>
1569 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1571 const tmp<fvMatrix<Type> >& tA,
1572 const tmp<fvMatrix<Type> >& tB
1575 checkMethod(tA(), tB(), "+");
1576 tmp<fvMatrix<Type> > tC(tA.ptr());
1582 template<class Type>
1583 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1585 const fvMatrix<Type>& A,
1586 const DimensionedField<Type, volMesh>& su
1589 checkMethod(A, su, "+");
1590 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1591 tC().source() -= su.mesh().V()*su.field();
1595 template<class Type>
1596 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1598 const fvMatrix<Type>& A,
1599 const tmp<DimensionedField<Type, volMesh> >& tsu
1602 checkMethod(A, tsu(), "+");
1603 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1604 tC().source() -= tsu().mesh().V()*tsu().field();
1609 template<class Type>
1610 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1612 const fvMatrix<Type>& A,
1613 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1616 checkMethod(A, tsu(), "+");
1617 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1618 tC().source() -= tsu().mesh().V()*tsu().internalField();
1623 template<class Type>
1624 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1626 const tmp<fvMatrix<Type> >& tA,
1627 const DimensionedField<Type, volMesh>& su
1630 checkMethod(tA(), su, "+");
1631 tmp<fvMatrix<Type> > tC(tA.ptr());
1632 tC().source() -= su.mesh().V()*su.field();
1636 template<class Type>
1637 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1639 const tmp<fvMatrix<Type> >& tA,
1640 const tmp<DimensionedField<Type, volMesh> >& tsu
1643 checkMethod(tA(), tsu(), "+");
1644 tmp<fvMatrix<Type> > tC(tA.ptr());
1645 tC().source() -= tsu().mesh().V()*tsu().field();
1650 template<class Type>
1651 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1653 const tmp<fvMatrix<Type> >& tA,
1654 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1657 checkMethod(tA(), tsu(), "+");
1658 tmp<fvMatrix<Type> > tC(tA.ptr());
1659 tC().source() -= tsu().mesh().V()*tsu().internalField();
1664 template<class Type>
1665 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1667 const DimensionedField<Type, volMesh>& su,
1668 const fvMatrix<Type>& A
1671 checkMethod(A, su, "+");
1672 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1673 tC().source() -= su.mesh().V()*su.field();
1677 template<class Type>
1678 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1680 const tmp<DimensionedField<Type, volMesh> >& tsu,
1681 const fvMatrix<Type>& A
1684 checkMethod(A, tsu(), "+");
1685 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1686 tC().source() -= tsu().mesh().V()*tsu().field();
1691 template<class Type>
1692 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1694 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
1695 const fvMatrix<Type>& A
1698 checkMethod(A, tsu(), "+");
1699 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1700 tC().source() -= tsu().mesh().V()*tsu().internalField();
1705 template<class Type>
1706 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1708 const DimensionedField<Type, volMesh>& su,
1709 const tmp<fvMatrix<Type> >& tA
1712 checkMethod(tA(), su, "+");
1713 tmp<fvMatrix<Type> > tC(tA.ptr());
1714 tC().source() -= su.mesh().V()*su.field();
1718 template<class Type>
1719 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1721 const tmp<DimensionedField<Type, volMesh> >& tsu,
1722 const tmp<fvMatrix<Type> >& tA
1725 checkMethod(tA(), tsu(), "+");
1726 tmp<fvMatrix<Type> > tC(tA.ptr());
1727 tC().source() -= tsu().mesh().V()*tsu().field();
1732 template<class Type>
1733 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1735 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
1736 const tmp<fvMatrix<Type> >& tA
1739 checkMethod(tA(), tsu(), "+");
1740 tmp<fvMatrix<Type> > tC(tA.ptr());
1741 tC().source() -= tsu().mesh().V()*tsu().internalField();
1747 template<class Type>
1748 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1750 const fvMatrix<Type>& A,
1751 const fvMatrix<Type>& B
1754 checkMethod(A, B, "-");
1755 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1760 template<class Type>
1761 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1763 const tmp<fvMatrix<Type> >& tA,
1764 const fvMatrix<Type>& B
1767 checkMethod(tA(), B, "-");
1768 tmp<fvMatrix<Type> > tC(tA.ptr());
1773 template<class Type>
1774 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1776 const fvMatrix<Type>& A,
1777 const tmp<fvMatrix<Type> >& tB
1780 checkMethod(A, tB(), "-");
1781 tmp<fvMatrix<Type> > tC(tB.ptr());
1787 template<class Type>
1788 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1790 const tmp<fvMatrix<Type> >& tA,
1791 const tmp<fvMatrix<Type> >& tB
1794 checkMethod(tA(), tB(), "-");
1795 tmp<fvMatrix<Type> > tC(tA.ptr());
1801 template<class Type>
1802 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1804 const fvMatrix<Type>& A,
1805 const DimensionedField<Type, volMesh>& su
1808 checkMethod(A, su, "-");
1809 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1810 tC().source() += su.mesh().V()*su.field();
1814 template<class Type>
1815 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1817 const fvMatrix<Type>& A,
1818 const tmp<DimensionedField<Type, volMesh> >& tsu
1821 checkMethod(A, tsu(), "-");
1822 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1823 tC().source() += tsu().mesh().V()*tsu().field();
1828 template<class Type>
1829 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1831 const fvMatrix<Type>& A,
1832 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1835 checkMethod(A, tsu(), "-");
1836 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1837 tC().source() += tsu().mesh().V()*tsu().internalField();
1842 template<class Type>
1843 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1845 const tmp<fvMatrix<Type> >& tA,
1846 const DimensionedField<Type, volMesh>& su
1849 checkMethod(tA(), su, "-");
1850 tmp<fvMatrix<Type> > tC(tA.ptr());
1851 tC().source() += su.mesh().V()*su.field();
1855 template<class Type>
1856 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1858 const tmp<fvMatrix<Type> >& tA,
1859 const tmp<DimensionedField<Type, volMesh> >& tsu
1862 checkMethod(tA(), tsu(), "-");
1863 tmp<fvMatrix<Type> > tC(tA.ptr());
1864 tC().source() += tsu().mesh().V()*tsu().field();
1869 template<class Type>
1870 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1872 const tmp<fvMatrix<Type> >& tA,
1873 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu
1876 checkMethod(tA(), tsu(), "-");
1877 tmp<fvMatrix<Type> > tC(tA.ptr());
1878 tC().source() += tsu().mesh().V()*tsu().internalField();
1883 template<class Type>
1884 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1886 const DimensionedField<Type, volMesh>& su,
1887 const fvMatrix<Type>& A
1890 checkMethod(A, su, "-");
1891 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1893 tC().source() -= su.mesh().V()*su.field();
1897 template<class Type>
1898 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1900 const tmp<DimensionedField<Type, volMesh> >& tsu,
1901 const fvMatrix<Type>& A
1904 checkMethod(A, tsu(), "-");
1905 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1907 tC().source() -= tsu().mesh().V()*tsu().field();
1912 template<class Type>
1913 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1915 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
1916 const fvMatrix<Type>& A
1919 checkMethod(A, tsu(), "-");
1920 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1922 tC().source() -= tsu().mesh().V()*tsu().internalField();
1927 template<class Type>
1928 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1930 const DimensionedField<Type, volMesh>& su,
1931 const tmp<fvMatrix<Type> >& tA
1934 checkMethod(tA(), su, "-");
1935 tmp<fvMatrix<Type> > tC(tA.ptr());
1937 tC().source() -= su.mesh().V()*su.field();
1941 template<class Type>
1942 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1944 const tmp<DimensionedField<Type, volMesh> >& tsu,
1945 const tmp<fvMatrix<Type> >& tA
1948 checkMethod(tA(), tsu(), "-");
1949 tmp<fvMatrix<Type> > tC(tA.ptr());
1951 tC().source() -= tsu().mesh().V()*tsu().field();
1956 template<class Type>
1957 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
1959 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu,
1960 const tmp<fvMatrix<Type> >& tA
1963 checkMethod(tA(), tsu(), "-");
1964 tmp<fvMatrix<Type> > tC(tA.ptr());
1966 tC().source() -= tsu().mesh().V()*tsu().internalField();
1971 template<class Type>
1972 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1974 const fvMatrix<Type>& A,
1975 const dimensioned<Type>& su
1978 checkMethod(A, su, "+");
1979 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
1980 tC().source() -= su.value()*A.psi().mesh().V();
1984 template<class Type>
1985 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
1987 const tmp<fvMatrix<Type> >& tA,
1988 const dimensioned<Type>& su
1991 checkMethod(tA(), su, "+");
1992 tmp<fvMatrix<Type> > tC(tA.ptr());
1993 tC().source() -= su.value()*tC().psi().mesh().V();
1997 template<class Type>
1998 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
2000 const dimensioned<Type>& su,
2001 const fvMatrix<Type>& A
2004 checkMethod(A, su, "+");
2005 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
2006 tC().source() -= su.value()*A.psi().mesh().V();
2010 template<class Type>
2011 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator+
2013 const dimensioned<Type>& su,
2014 const tmp<fvMatrix<Type> >& tA
2017 checkMethod(tA(), su, "+");
2018 tmp<fvMatrix<Type> > tC(tA.ptr());
2019 tC().source() -= su.value()*tC().psi().mesh().V();
2023 template<class Type>
2024 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
2026 const fvMatrix<Type>& A,
2027 const dimensioned<Type>& su
2030 checkMethod(A, su, "-");
2031 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
2032 tC().source() += su.value()*tC().psi().mesh().V();
2036 template<class Type>
2037 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
2039 const tmp<fvMatrix<Type> >& tA,
2040 const dimensioned<Type>& su
2043 checkMethod(tA(), su, "-");
2044 tmp<fvMatrix<Type> > tC(tA.ptr());
2045 tC().source() += su.value()*tC().psi().mesh().V();
2049 template<class Type>
2050 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
2052 const dimensioned<Type>& su,
2053 const fvMatrix<Type>& A
2056 checkMethod(A, su, "-");
2057 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
2059 tC().source() -= su.value()*A.psi().mesh().V();
2063 template<class Type>
2064 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator-
2066 const dimensioned<Type>& su,
2067 const tmp<fvMatrix<Type> >& tA
2070 checkMethod(tA(), su, "-");
2071 tmp<fvMatrix<Type> > tC(tA.ptr());
2073 tC().source() -= su.value()*tC().psi().mesh().V();
2078 template<class Type>
2079 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2081 const DimensionedField<scalar, volMesh>& dsf,
2082 const fvMatrix<Type>& A
2085 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
2090 template<class Type>
2091 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2093 const tmp< DimensionedField<scalar, volMesh> >& tdsf,
2094 const fvMatrix<Type>& A
2097 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
2102 template<class Type>
2103 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2105 const tmp<volScalarField>& tvsf,
2106 const fvMatrix<Type>& A
2109 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
2114 template<class Type>
2115 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2117 const DimensionedField<scalar, volMesh>& dsf,
2118 const tmp<fvMatrix<Type> >& tA
2121 tmp<fvMatrix<Type> > tC(tA.ptr());
2126 template<class Type>
2127 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2129 const tmp<DimensionedField<scalar, volMesh> >& tdsf,
2130 const tmp<fvMatrix<Type> >& tA
2133 tmp<fvMatrix<Type> > tC(tA.ptr());
2138 template<class Type>
2139 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2141 const tmp<volScalarField>& tvsf,
2142 const tmp<fvMatrix<Type> >& tA
2145 tmp<fvMatrix<Type> > tC(tA.ptr());
2150 template<class Type>
2151 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2153 const dimensioned<scalar>& ds,
2154 const fvMatrix<Type>& A
2157 tmp<fvMatrix<Type> > tC(new fvMatrix<Type>(A));
2162 template<class Type>
2163 Foam::tmp<Foam::fvMatrix<Type> > Foam::operator*
2165 const dimensioned<scalar>& ds,
2166 const tmp<fvMatrix<Type> >& tA
2169 tmp<fvMatrix<Type> > tC(tA.ptr());
2175 template<class Type>
2176 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
2179 const fvMatrix<Type>& M,
2180 const DimensionedField<Type, volMesh>& psi
2183 tmp<GeometricField<Type, fvPatchField, volMesh> > tMphi
2185 new GeometricField<Type, fvPatchField, volMesh>
2196 M.dimensions()/dimVol,
2197 zeroGradientFvPatchScalarField::typeName
2200 GeometricField<Type, fvPatchField, volMesh>& Mphi = tMphi();
2202 // Loop over field components
2203 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
2205 scalarField psiCmpt = psi.field().component(cmpt);
2206 scalarField boundaryDiagCmpt(M.diag());
2207 M.addBoundaryDiag(boundaryDiagCmpt, cmpt);
2208 Mphi.internalField().replace(cmpt, -boundaryDiagCmpt*psiCmpt);
2211 Mphi.internalField() += M.lduMatrix::H(psi.field()) + M.source();
2212 M.addBoundarySource(Mphi.internalField());
2214 Mphi.internalField() /= -psi.mesh().V();
2215 Mphi.correctBoundaryConditions();
2220 template<class Type>
2221 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
2224 const fvMatrix<Type>& M,
2225 const tmp<DimensionedField<Type, volMesh> >& tpsi
2228 tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = M & tpsi();
2233 template<class Type>
2234 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
2237 const fvMatrix<Type>& M,
2238 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tpsi
2241 tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = M & tpsi();
2246 template<class Type>
2247 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
2250 const tmp<fvMatrix<Type> >& tM,
2251 const DimensionedField<Type, volMesh>& psi
2254 tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = tM() & psi;
2259 template<class Type>
2260 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
2263 const tmp<fvMatrix<Type> >& tM,
2264 const tmp<DimensionedField<Type, volMesh> >& tpsi
2267 tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = tM() & tpsi();
2273 template<class Type>
2274 Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
2277 const tmp<fvMatrix<Type> >& tM,
2278 const tmp<GeometricField<Type, fvPatchField, volMesh> >& tpsi
2281 tmp<GeometricField<Type, fvPatchField, volMesh> > tMpsi = tM() & tpsi();
2288 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
2290 template<class Type>
2291 Foam::Ostream& Foam::operator<<(Ostream& os, const fvMatrix<Type>& fvm)
2293 os << static_cast<const lduMatrix&>(fvm) << nl
2294 << fvm.dimensions_ << nl
2295 << fvm.source_ << nl
2296 << fvm.internalCoeffs_ << nl
2297 << fvm.boundaryCoeffs_ << endl;
2299 os.check("Ostream& operator<<(Ostream&, fvMatrix<Type>&");
2305 // * * * * * * * * * * * * * * * * Solvers * * * * * * * * * * * * * * * * * //
2307 #include "fvMatrixSolve.C"
2309 // ************************************************************************* //