fvMatrix.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "volFields.H"
30 #include "surfaceFields.H"
33 #include "coupledFvPatchFields.H"
34 #include "UIndirectList.H"
35 #include "demandDrivenData.H"
36 
37 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
38 
39 template<class Type>
40 template<class Type2>
42 (
43  const labelUList& addr,
44  const Field<Type2>& pf,
45  Field<Type2>& intf
46 ) const
47 {
48  if (addr.size() != pf.size())
49  {
51  << "sizes of addressing and field are different"
52  << abort(FatalError);
53  }
54 
55  forAll(addr, facei)
56  {
57  intf[addr[facei]] += pf[facei];
58  }
59 }
60 
61 
62 template<class Type>
63 template<class Type2>
65 (
66  const labelUList& addr,
67  const tmp<Field<Type2>>& tpf,
68  Field<Type2>& intf
69 ) const
70 {
71  addToInternalField(addr, tpf(), intf);
72  tpf.clear();
73 }
74 
75 
76 template<class Type>
77 template<class Type2>
79 (
80  const labelUList& addr,
81  const Field<Type2>& pf,
82  Field<Type2>& intf
83 ) const
84 {
85  if (addr.size() != pf.size())
86  {
88  << "sizes of addressing and field are different"
89  << abort(FatalError);
90  }
91 
92  forAll(addr, facei)
93  {
94  intf[addr[facei]] -= pf[facei];
95  }
96 }
97 
98 
99 template<class Type>
100 template<class Type2>
102 (
103  const labelUList& addr,
104  const tmp<Field<Type2>>& tpf,
105  Field<Type2>& intf
106 ) const
107 {
108  subtractFromInternalField(addr, tpf(), intf);
109  tpf.clear();
110 }
111 
112 
113 template<class Type>
115 (
116  scalarField& diag,
117  const direction solveCmpt
118 ) const
119 {
120  forAll(internalCoeffs_, patchi)
121  {
122  addToInternalField
123  (
124  lduAddr().patchAddr(patchi),
125  internalCoeffs_[patchi].component(solveCmpt),
126  diag
127  );
128  }
129 }
130 
131 
132 template<class Type>
134 {
135  forAll(internalCoeffs_, patchi)
136  {
137  addToInternalField
138  (
139  lduAddr().patchAddr(patchi),
140  cmptAv(internalCoeffs_[patchi]),
141  diag
142  );
143  }
144 }
145 
146 
147 template<class Type>
149 (
150  Field<Type>& source,
151  const bool couples
152 ) const
153 {
154  forAll(psi_.boundaryField(), patchi)
155  {
156  const fvPatchField<Type>& ptf = psi_.boundaryField()[patchi];
157  const Field<Type>& pbc = boundaryCoeffs_[patchi];
158 
159  if (!ptf.coupled())
160  {
161  addToInternalField(lduAddr().patchAddr(patchi), pbc, source);
162  }
163  else if (couples)
164  {
165  const tmp<Field<Type>> tpnf = ptf.patchNeighbourField();
166  const Field<Type>& pnf = tpnf();
167 
168  const labelUList& addr = lduAddr().patchAddr(patchi);
169 
170  forAll(addr, facei)
171  {
172  source[addr[facei]] += cmptMultiply(pbc[facei], pnf[facei]);
173  }
174  }
175  }
176 }
177 
178 
179 template<class Type>
180 template<template<class> class ListType>
182 (
183  const labelUList& cellLabels,
184  const ListType<Type>& values
185 )
186 {
187  const fvMesh& mesh = psi_.mesh();
188 
189  const cellList& cells = mesh.cells();
190  const labelUList& own = mesh.owner();
191  const labelUList& nei = mesh.neighbour();
192 
193  scalarField& Diag = diag();
194  Field<Type>& psi =
195  const_cast
196  <
198  >(psi_).primitiveFieldRef();
199 
200  forAll(cellLabels, i)
201  {
202  const label celli = cellLabels[i];
203  const Type& value = values[i];
204 
205  psi[celli] = value;
206  source_[celli] = value*Diag[celli];
207 
208  if (symmetric() || asymmetric())
209  {
210  const cell& c = cells[celli];
211 
212  forAll(c, j)
213  {
214  const label facei = c[j];
215 
216  if (mesh.isInternalFace(facei))
217  {
218  if (symmetric())
219  {
220  if (celli == own[facei])
221  {
222  source_[nei[facei]] -= upper()[facei]*value;
223  }
224  else
225  {
226  source_[own[facei]] -= upper()[facei]*value;
227  }
228 
229  upper()[facei] = 0.0;
230  }
231  else
232  {
233  if (celli == own[facei])
234  {
235  source_[nei[facei]] -= lower()[facei]*value;
236  }
237  else
238  {
239  source_[own[facei]] -= upper()[facei]*value;
240  }
241 
242  upper()[facei] = 0.0;
243  lower()[facei] = 0.0;
244  }
245  }
246  else
247  {
248  label patchi = mesh.boundaryMesh().whichPatch(facei);
249 
250  if (internalCoeffs_[patchi].size())
251  {
252  label patchFacei =
253  mesh.boundaryMesh()[patchi].whichFace(facei);
254 
255  internalCoeffs_[patchi][patchFacei] =
256  Zero;
257 
258  boundaryCoeffs_[patchi][patchFacei] =
259  Zero;
260  }
261  }
262  }
263  }
264  }
265 }
266 
267 
268 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
269 
270 template<class Type>
272 (
274  const dimensionSet& ds
275 )
276 :
277  lduMatrix(psi.mesh()),
278  psi_(psi),
279  dimensions_(ds),
280  source_(psi.size(), Zero),
281  internalCoeffs_(psi.mesh().boundary().size()),
282  boundaryCoeffs_(psi.mesh().boundary().size()),
283  faceFluxCorrectionPtr_(nullptr)
284 {
286  << "Constructing fvMatrix<Type> for field " << psi_.name() << endl;
287 
288  // Initialise coupling coefficients
289  forAll(psi.mesh().boundary(), patchi)
290  {
291  internalCoeffs_.set
292  (
293  patchi,
294  new Field<Type>
295  (
296  psi.mesh().boundary()[patchi].size(),
297  Zero
298  )
299  );
300 
301  boundaryCoeffs_.set
302  (
303  patchi,
304  new Field<Type>
305  (
306  psi.mesh().boundary()[patchi].size(),
307  Zero
308  )
309  );
310  }
311 
312  // Update the boundary coefficients of psi without changing its event No.
315 
316  label currentStatePsi = psiRef.eventNo();
317  psiRef.boundaryFieldRef().updateCoeffs();
318  psiRef.eventNo() = currentStatePsi;
319 }
320 
321 
322 template<class Type>
324 :
325  refCount(),
326  lduMatrix(fvm),
327  psi_(fvm.psi_),
328  dimensions_(fvm.dimensions_),
329  source_(fvm.source_),
330  internalCoeffs_(fvm.internalCoeffs_),
331  boundaryCoeffs_(fvm.boundaryCoeffs_),
332  faceFluxCorrectionPtr_(nullptr)
333 {
335  << "Copying fvMatrix<Type> for field " << psi_.name() << endl;
336 
337  if (fvm.faceFluxCorrectionPtr_)
338  {
339  faceFluxCorrectionPtr_ = new
341  (
342  *(fvm.faceFluxCorrectionPtr_)
343  );
344  }
345 }
346 
347 
348 template<class Type>
350 :
351  lduMatrix
352  (
353  const_cast<fvMatrix<Type>&>(tfvm()),
354  tfvm.isTmp()
355  ),
356  psi_(tfvm().psi_),
357  dimensions_(tfvm().dimensions_),
358  source_
359  (
360  const_cast<fvMatrix<Type>&>(tfvm()).source_,
361  tfvm.isTmp()
362  ),
363  internalCoeffs_
364  (
365  const_cast<fvMatrix<Type>&>(tfvm()).internalCoeffs_,
366  tfvm.isTmp()
367  ),
368  boundaryCoeffs_
369  (
370  const_cast<fvMatrix<Type>&>(tfvm()).boundaryCoeffs_,
371  tfvm.isTmp()
372  ),
373  faceFluxCorrectionPtr_(nullptr)
374 {
376  << "Copying fvMatrix<Type> for field " << psi_.name() << endl;
377 
378  if (tfvm().faceFluxCorrectionPtr_)
379  {
380  if (tfvm.isTmp())
381  {
382  faceFluxCorrectionPtr_ = tfvm().faceFluxCorrectionPtr_;
383  tfvm().faceFluxCorrectionPtr_ = nullptr;
384  }
385  else
386  {
387  faceFluxCorrectionPtr_ = new
389  (
390  *(tfvm().faceFluxCorrectionPtr_)
391  );
392  }
393  }
394 
395  tfvm.clear();
396 }
397 
398 
399 template<class Type>
401 (
403  Istream& is
404 )
405 :
406  lduMatrix(psi.mesh()),
407  psi_(psi),
408  dimensions_(is),
409  source_(is),
410  internalCoeffs_(psi.mesh().boundary().size()),
411  boundaryCoeffs_(psi.mesh().boundary().size()),
412  faceFluxCorrectionPtr_(nullptr)
413 {
415  << "Constructing fvMatrix<Type> for field " << psi_.name() << endl;
416 
417  // Initialise coupling coefficients
418  forAll(psi.mesh().boundary(), patchi)
419  {
420  internalCoeffs_.set
421  (
422  patchi,
423  new Field<Type>
424  (
425  psi.mesh().boundary()[patchi].size(),
426  Zero
427  )
428  );
429 
430  boundaryCoeffs_.set
431  (
432  patchi,
433  new Field<Type>
434  (
435  psi.mesh().boundary()[patchi].size(),
436  Zero
437  )
438  );
439  }
440 
441 }
442 
443 
444 template<class Type>
446 {
447  return tmp<fvMatrix<Type>>
448  (
449  new fvMatrix<Type>(*this)
450  );
451 }
452 
453 
454 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
455 
456 template<class Type>
458 {
460  << "Destroying fvMatrix<Type> for field " << psi_.name() << endl;
461 
462  if (faceFluxCorrectionPtr_)
463  {
464  delete faceFluxCorrectionPtr_;
465  }
466 }
467 
468 
469 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
470 
471 template<class Type>
473 (
474  const labelUList& cellLabels,
475  const UList<Type>& values
476 )
477 {
478  this->setValuesFromList(cellLabels, values);
479 }
480 
481 
482 template<class Type>
484 (
485  const labelUList& cellLabels,
487 )
488 {
489  this->setValuesFromList(cellLabels, values);
490 }
491 
492 
493 template<class Type>
495 (
496  const label celli,
497  const Type& value,
498  const bool forceReference
499 )
500 {
501  if ((forceReference || psi_.needReference()) && celli >= 0)
502  {
503  source()[celli] += diag()[celli]*value;
504  diag()[celli] += diag()[celli];
505  }
506 }
507 
508 
509 template<class Type>
511 (
512  const labelUList& cellLabels,
513  const Type& value,
514  const bool forceReference
515 )
516 {
517  const bool needRef = (forceReference || psi_.needReference());
518 
519  if (needRef)
520  {
521  forAll(cellLabels, celli)
522  {
523  const label cellId = cellLabels[celli];
524  if (cellId >= 0)
525  {
526  source()[cellId] += diag()[cellId]*value;
527  diag()[cellId] += diag()[cellId];
528  }
529  }
530  }
531 }
532 
533 
534 template<class Type>
536 (
537  const labelUList& cellLabels,
538  const UList<Type>& values,
539  const bool forceReference
540 )
541 {
542  const bool needRef = (forceReference || psi_.needReference());
543 
544  if (needRef)
545  {
546  forAll(cellLabels, celli)
547  {
548  const label cellId = cellLabels[celli];
549  if (cellId >= 0)
550  {
551  source()[cellId] += diag()[cellId]*values[celli];
552  diag()[cellId] += diag()[cellId];
553  }
554  }
555  }
556 }
557 
558 
559 template<class Type>
561 {
562  if (alpha <= 0)
563  {
564  return;
565  }
566 
568  << "Relaxing " << psi_.name() << " by " << alpha << endl;
569 
570  Field<Type>& S = source();
571  scalarField& D = diag();
572 
573  // Store the current unrelaxed diagonal for use in updating the source
574  scalarField D0(D);
575 
576  // Calculate the sum-mag off-diagonal from the interior faces
577  scalarField sumOff(D.size(), Zero);
578  sumMagOffDiag(sumOff);
579 
580  // Handle the boundary contributions to the diagonal
581  forAll(psi_.boundaryField(), patchi)
582  {
583  const fvPatchField<Type>& ptf = psi_.boundaryField()[patchi];
584 
585  if (ptf.size())
586  {
587  const labelUList& pa = lduAddr().patchAddr(patchi);
588  Field<Type>& iCoeffs = internalCoeffs_[patchi];
589 
590  if (ptf.coupled())
591  {
592  const Field<Type>& pCoeffs = boundaryCoeffs_[patchi];
593 
594  // For coupled boundaries add the diagonal and
595  // off-diagonal contributions
596  forAll(pa, face)
597  {
598  D[pa[face]] += component(iCoeffs[face], 0);
599  sumOff[pa[face]] += mag(component(pCoeffs[face], 0));
600  }
601  }
602  else
603  {
604  // For non-coupled boundaries add the maximum magnitude diagonal
605  // contribution to ensure stability
606  forAll(pa, face)
607  {
608  D[pa[face]] += cmptMax(cmptMag(iCoeffs[face]));
609  }
610  }
611  }
612  }
613 
614 
615  if (debug)
616  {
617  // Calculate amount of non-dominance.
618  label nNon = 0;
619  scalar maxNon = 0.0;
620  scalar sumNon = 0.0;
621  forAll(D, celli)
622  {
623  scalar d = (sumOff[celli] - D[celli])/mag(D[celli]);
624 
625  if (d > 0)
626  {
627  nNon++;
628  maxNon = max(maxNon, d);
629  sumNon += d;
630  }
631  }
632 
633  reduce(nNon, sumOp<label>(), UPstream::msgType(), psi_.mesh().comm());
634  reduce
635  (
636  maxNon,
637  maxOp<scalar>(),
639  psi_.mesh().comm()
640  );
641  reduce
642  (
643  sumNon,
644  sumOp<scalar>(),
646  psi_.mesh().comm()
647  );
648  sumNon /= returnReduce
649  (
650  D.size(),
651  sumOp<label>(),
653  psi_.mesh().comm()
654  );
655 
657  << "Matrix dominance test for " << psi_.name() << nl
658  << " number of non-dominant cells : " << nNon << nl
659  << " maximum relative non-dominance : " << maxNon << nl
660  << " average relative non-dominance : " << sumNon << nl
661  << endl;
662  }
663 
664 
665  // Ensure the matrix is diagonally dominant...
666  // Assumes that the central coefficient is positive and ensures it is
667  forAll(D, celli)
668  {
669  D[celli] = max(mag(D[celli]), sumOff[celli]);
670  }
671 
672  // ... then relax
673  D /= alpha;
674 
675  // Now remove the diagonal contribution from coupled boundaries
676  forAll(psi_.boundaryField(), patchi)
677  {
678  const fvPatchField<Type>& ptf = psi_.boundaryField()[patchi];
679 
680  if (ptf.size())
681  {
682  const labelUList& pa = lduAddr().patchAddr(patchi);
683  Field<Type>& iCoeffs = internalCoeffs_[patchi];
684 
685  if (ptf.coupled())
686  {
687  forAll(pa, face)
688  {
689  D[pa[face]] -= component(iCoeffs[face], 0);
690  }
691  }
692  else
693  {
694  forAll(pa, face)
695  {
696  D[pa[face]] -= cmptMin(iCoeffs[face]);
697  }
698  }
699  }
700  }
701 
702  // Finally add the relaxation contribution to the source.
703  S += (D - D0)*psi_.primitiveField();
704 }
705 
706 
707 template<class Type>
709 {
710  word name = psi_.select
711  (
712  psi_.mesh().data::template getOrDefault<bool>
713  ("finalIteration", false)
714  );
715 
716  if (psi_.mesh().relaxEquation(name))
717  {
718  relax(psi_.mesh().equationRelaxationFactor(name));
719  }
720 }
721 
722 
723 template<class Type>
725 (
727  Boundary& bFields
728 )
729 {
730  forAll(bFields, patchi)
731  {
732  bFields[patchi].manipulateMatrix(*this);
733  }
734 }
735 
736 
737 template<class Type>
739 {
740  tmp<scalarField> tdiag(new scalarField(diag()));
741  addCmptAvBoundaryDiag(tdiag.ref());
742  return tdiag;
743 }
744 
745 
746 template<class Type>
748 {
750 
751  forAll(psi_.boundaryField(), patchi)
752  {
753  const fvPatchField<Type>& ptf = psi_.boundaryField()[patchi];
754 
755  if (!ptf.coupled() && ptf.size())
756  {
757  addToInternalField
758  (
759  lduAddr().patchAddr(patchi),
760  internalCoeffs_[patchi],
761  tdiag.ref()
762  );
763  }
764  }
765 
766  return tdiag;
767 }
768 
769 
770 template<class Type>
772 {
773  tmp<volScalarField> tAphi
774  (
775  new volScalarField
776  (
777  IOobject
778  (
779  "A("+psi_.name()+')',
780  psi_.instance(),
781  psi_.mesh(),
784  ),
785  psi_.mesh(),
786  dimensions_/psi_.dimensions()/dimVol,
787  extrapolatedCalculatedFvPatchScalarField::typeName
788  )
789  );
790 
791  tAphi.ref().primitiveFieldRef() = D()/psi_.mesh().V();
792  tAphi.ref().correctBoundaryConditions();
793 
794  return tAphi;
795 }
796 
797 
798 template<class Type>
801 {
803  (
805  (
806  IOobject
807  (
808  "H("+psi_.name()+')',
809  psi_.instance(),
810  psi_.mesh(),
813  ),
814  psi_.mesh(),
815  dimensions_/dimVol,
816  extrapolatedCalculatedFvPatchScalarField::typeName
817  )
818  );
820 
821  // Loop over field components
822  for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
823  {
824  scalarField psiCmpt(psi_.primitiveField().component(cmpt));
825 
826  scalarField boundaryDiagCmpt(psi_.size(), Zero);
827  addBoundaryDiag(boundaryDiagCmpt, cmpt);
828  boundaryDiagCmpt.negate();
829  addCmptAvBoundaryDiag(boundaryDiagCmpt);
830 
831  Hphi.primitiveFieldRef().replace(cmpt, boundaryDiagCmpt*psiCmpt);
832  }
833 
834  Hphi.primitiveFieldRef() += lduMatrix::H(psi_.primitiveField()) + source_;
835  addBoundarySource(Hphi.primitiveFieldRef());
836 
837  Hphi.primitiveFieldRef() /= psi_.mesh().V();
839 
840  typename Type::labelType validComponents
841  (
842  psi_.mesh().template validComponents<Type>()
843  );
844 
845  for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
846  {
847  if (validComponents[cmpt] == -1)
848  {
849  Hphi.replace
850  (
851  cmpt,
852  dimensionedScalar(Hphi.dimensions(), Zero)
853  );
854  }
855  }
856 
857  return tHphi;
858 }
859 
860 
861 template<class Type>
863 {
865  (
866  new volScalarField
867  (
868  IOobject
869  (
870  "H(1)",
871  psi_.instance(),
872  psi_.mesh(),
875  ),
876  psi_.mesh(),
877  dimensions_/(dimVol*psi_.dimensions()),
878  extrapolatedCalculatedFvPatchScalarField::typeName
879  )
880  );
881  volScalarField& H1_ = tH1.ref();
882 
883  H1_.primitiveFieldRef() = lduMatrix::H1();
884 
885  forAll(psi_.boundaryField(), patchi)
886  {
887  const fvPatchField<Type>& ptf = psi_.boundaryField()[patchi];
888 
889  if (ptf.coupled() && ptf.size())
890  {
891  addToInternalField
892  (
893  lduAddr().patchAddr(patchi),
894  boundaryCoeffs_[patchi].component(0),
895  H1_
896  );
897  }
898  }
899 
900  H1_.primitiveFieldRef() /= psi_.mesh().V();
901  H1_.correctBoundaryConditions();
902 
903  return tH1;
904 }
905 
906 
907 template<class Type>
910 flux() const
911 {
912  if (!psi_.mesh().fluxRequired(psi_.name()))
913  {
915  << "flux requested but " << psi_.name()
916  << " not specified in the fluxRequired sub-dictionary"
917  " of fvSchemes."
918  << abort(FatalError);
919  }
920 
921  // construct GeometricField<Type, fvsPatchField, surfaceMesh>
923  (
925  (
926  IOobject
927  (
928  "flux("+psi_.name()+')',
929  psi_.instance(),
930  psi_.mesh(),
933  ),
934  psi_.mesh(),
935  dimensions()
936  )
937  );
939  tfieldFlux.ref();
940 
941  fieldFlux.setOriented();
942 
943  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
944  {
945  fieldFlux.primitiveFieldRef().replace
946  (
947  cmpt,
948  lduMatrix::faceH(psi_.primitiveField().component(cmpt))
949  );
950  }
951 
952  FieldField<Field, Type> InternalContrib = internalCoeffs_;
953 
954  forAll(InternalContrib, patchi)
955  {
956  InternalContrib[patchi] =
958  (
959  InternalContrib[patchi],
960  psi_.boundaryField()[patchi].patchInternalField()
961  );
962  }
963 
964  FieldField<Field, Type> NeighbourContrib = boundaryCoeffs_;
965 
966  forAll(NeighbourContrib, patchi)
967  {
968  if (psi_.boundaryField()[patchi].coupled())
969  {
970  NeighbourContrib[patchi] =
972  (
973  NeighbourContrib[patchi],
974  psi_.boundaryField()[patchi].patchNeighbourField()
975  );
976  }
977  }
978 
980  Boundary& ffbf = fieldFlux.boundaryFieldRef();
981 
982  forAll(ffbf, patchi)
983  {
984  ffbf[patchi] = InternalContrib[patchi] - NeighbourContrib[patchi];
985  }
986 
987  if (faceFluxCorrectionPtr_)
988  {
989  fieldFlux += *faceFluxCorrectionPtr_;
990  }
991 
992  return tfieldFlux;
993 }
994 
995 
996 template<class Type>
998 {
999  return psi_.mesh().solverDict
1000  (
1001  psi_.select
1002  (
1003  psi_.mesh().data::template getOrDefault<bool>
1004  ("finalIteration", false)
1005  )
1006  );
1007 }
1008 
1009 
1010 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1011 
1012 template<class Type>
1014 {
1015  if (this == &fvmv)
1016  {
1017  return; // Self-assignment is a no-op
1018  }
1019 
1020  if (&psi_ != &(fvmv.psi_))
1021  {
1023  << "different fields"
1024  << abort(FatalError);
1025  }
1026 
1027  dimensions_ = fvmv.dimensions_;
1028  lduMatrix::operator=(fvmv);
1029  source_ = fvmv.source_;
1030  internalCoeffs_ = fvmv.internalCoeffs_;
1031  boundaryCoeffs_ = fvmv.boundaryCoeffs_;
1032 
1033  if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
1034  {
1035  *faceFluxCorrectionPtr_ = *fvmv.faceFluxCorrectionPtr_;
1036  }
1037  else if (fvmv.faceFluxCorrectionPtr_)
1038  {
1039  faceFluxCorrectionPtr_ =
1041  (*fvmv.faceFluxCorrectionPtr_);
1042  }
1043 }
1044 
1045 
1046 template<class Type>
1048 {
1049  operator=(tfvmv());
1050  tfvmv.clear();
1051 }
1052 
1053 
1054 template<class Type>
1056 {
1058  source_.negate();
1059  internalCoeffs_.negate();
1060  boundaryCoeffs_.negate();
1061 
1062  if (faceFluxCorrectionPtr_)
1063  {
1064  faceFluxCorrectionPtr_->negate();
1065  }
1066 }
1067 
1068 
1069 template<class Type>
1071 {
1072  checkMethod(*this, fvmv, "+=");
1073 
1074  dimensions_ += fvmv.dimensions_;
1075  lduMatrix::operator+=(fvmv);
1076  source_ += fvmv.source_;
1077  internalCoeffs_ += fvmv.internalCoeffs_;
1078  boundaryCoeffs_ += fvmv.boundaryCoeffs_;
1079 
1080  if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
1081  {
1082  *faceFluxCorrectionPtr_ += *fvmv.faceFluxCorrectionPtr_;
1083  }
1084  else if (fvmv.faceFluxCorrectionPtr_)
1085  {
1086  faceFluxCorrectionPtr_ = new
1088  (
1089  *fvmv.faceFluxCorrectionPtr_
1090  );
1091  }
1092 }
1093 
1094 
1095 template<class Type>
1097 {
1098  operator+=(tfvmv());
1099  tfvmv.clear();
1100 }
1101 
1102 
1103 template<class Type>
1105 {
1106  checkMethod(*this, fvmv, "-=");
1107 
1108  dimensions_ -= fvmv.dimensions_;
1109  lduMatrix::operator-=(fvmv);
1110  source_ -= fvmv.source_;
1111  internalCoeffs_ -= fvmv.internalCoeffs_;
1112  boundaryCoeffs_ -= fvmv.boundaryCoeffs_;
1113 
1114  if (faceFluxCorrectionPtr_ && fvmv.faceFluxCorrectionPtr_)
1115  {
1116  *faceFluxCorrectionPtr_ -= *fvmv.faceFluxCorrectionPtr_;
1117  }
1118  else if (fvmv.faceFluxCorrectionPtr_)
1119  {
1120  faceFluxCorrectionPtr_ =
1122  (-*fvmv.faceFluxCorrectionPtr_);
1123  }
1124 }
1125 
1126 
1127 template<class Type>
1129 {
1130  operator-=(tfvmv());
1131  tfvmv.clear();
1132 }
1133 
1134 
1135 template<class Type>
1139 )
1140 {
1141  checkMethod(*this, su, "+=");
1142  source() -= su.mesh().V()*su.field();
1143 }
1144 
1145 
1146 template<class Type>
1150 )
1151 {
1152  operator+=(tsu());
1153  tsu.clear();
1154 }
1155 
1156 
1157 template<class Type>
1161 )
1162 {
1163  operator+=(tsu());
1164  tsu.clear();
1165 }
1166 
1167 
1168 template<class Type>
1172 )
1173 {
1174  checkMethod(*this, su, "-=");
1175  source() += su.mesh().V()*su.field();
1176 }
1177 
1178 
1179 template<class Type>
1183 )
1184 {
1185  operator-=(tsu());
1186  tsu.clear();
1187 }
1188 
1189 
1190 template<class Type>
1194 )
1195 {
1196  operator-=(tsu());
1197  tsu.clear();
1198 }
1199 
1200 
1201 template<class Type>
1204  const dimensioned<Type>& su
1205 )
1206 {
1207  source() -= psi().mesh().V()*su;
1208 }
1209 
1210 
1211 template<class Type>
1214  const dimensioned<Type>& su
1215 )
1216 {
1217  source() += psi().mesh().V()*su;
1218 }
1219 
1220 
1221 template<class Type>
1224  const zero&
1225 )
1226 {}
1227 
1228 
1229 template<class Type>
1232  const zero&
1233 )
1234 {}
1235 
1236 
1237 template<class Type>
1240  const volScalarField::Internal& dsf
1241 )
1242 {
1243  dimensions_ *= dsf.dimensions();
1244  lduMatrix::operator*=(dsf.field());
1245  source_ *= dsf.field();
1246 
1247  forAll(boundaryCoeffs_, patchi)
1248  {
1249  scalarField pisf
1250  (
1251  dsf.mesh().boundary()[patchi].patchInternalField(dsf.field())
1252  );
1253 
1254  internalCoeffs_[patchi] *= pisf;
1255  boundaryCoeffs_[patchi] *= pisf;
1256  }
1257 
1258  if (faceFluxCorrectionPtr_)
1259  {
1261  << "cannot scale a matrix containing a faceFluxCorrection"
1262  << abort(FatalError);
1263  }
1264 }
1265 
1266 
1267 template<class Type>
1270  const tmp<volScalarField::Internal>& tdsf
1271 )
1272 {
1273  operator*=(tdsf());
1274  tdsf.clear();
1275 }
1276 
1277 
1278 template<class Type>
1281  const tmp<volScalarField>& tvsf
1282 )
1283 {
1284  operator*=(tvsf());
1285  tvsf.clear();
1286 }
1287 
1288 
1289 template<class Type>
1292  const dimensioned<scalar>& ds
1293 )
1294 {
1295  dimensions_ *= ds.dimensions();
1296  lduMatrix::operator*=(ds.value());
1297  source_ *= ds.value();
1298  internalCoeffs_ *= ds.value();
1299  boundaryCoeffs_ *= ds.value();
1300 
1301  if (faceFluxCorrectionPtr_)
1302  {
1303  *faceFluxCorrectionPtr_ *= ds.value();
1304  }
1305 }
1306 
1307 
1308 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
1309 
1310 template<class Type>
1311 void Foam::checkMethod
1313  const fvMatrix<Type>& fvm1,
1314  const fvMatrix<Type>& fvm2,
1315  const char* op
1316 )
1317 {
1318  if (&fvm1.psi() != &fvm2.psi())
1319  {
1321  << "incompatible fields for operation "
1322  << endl << " "
1323  << "[" << fvm1.psi().name() << "] "
1324  << op
1325  << " [" << fvm2.psi().name() << "]"
1326  << abort(FatalError);
1327  }
1328 
1329  if (dimensionSet::debug && fvm1.dimensions() != fvm2.dimensions())
1330  {
1332  << "incompatible dimensions for operation "
1333  << endl << " "
1334  << "[" << fvm1.psi().name() << fvm1.dimensions()/dimVolume << " ] "
1335  << op
1336  << " [" << fvm2.psi().name() << fvm2.dimensions()/dimVolume << " ]"
1337  << abort(FatalError);
1338  }
1339 }
1340 
1341 
1342 template<class Type>
1343 void Foam::checkMethod
1345  const fvMatrix<Type>& fvm,
1347  const char* op
1348 )
1349 {
1350  if (dimensionSet::debug && fvm.dimensions()/dimVolume != df.dimensions())
1351  {
1353  << endl << " "
1354  << "[" << fvm.psi().name() << fvm.dimensions()/dimVolume << " ] "
1355  << op
1356  << " [" << df.name() << df.dimensions() << " ]"
1357  << abort(FatalError);
1358  }
1359 }
1360 
1361 
1362 template<class Type>
1363 void Foam::checkMethod
1365  const fvMatrix<Type>& fvm,
1366  const dimensioned<Type>& dt,
1367  const char* op
1368 )
1369 {
1370  if (dimensionSet::debug && fvm.dimensions()/dimVolume != dt.dimensions())
1371  {
1373  << "incompatible dimensions for operation "
1374  << endl << " "
1375  << "[" << fvm.psi().name() << fvm.dimensions()/dimVolume << " ] "
1376  << op
1377  << " [" << dt.name() << dt.dimensions() << " ]"
1378  << abort(FatalError);
1379  }
1380 }
1381 
1382 
1383 template<class Type>
1385 (
1386  fvMatrix<Type>& fvm,
1387  const dictionary& solverControls
1388 )
1389 {
1390  return fvm.solve(solverControls);
1391 }
1392 
1393 template<class Type>
1395 (
1396  const tmp<fvMatrix<Type>>& tfvm,
1397  const dictionary& solverControls
1398 )
1399 {
1400  SolverPerformance<Type> solverPerf =
1401  const_cast<fvMatrix<Type>&>(tfvm()).solve(solverControls);
1402 
1403  tfvm.clear();
1404 
1405  return solverPerf;
1406 }
1407 
1408 
1409 template<class Type>
1410 Foam::SolverPerformance<Type> Foam::solve(fvMatrix<Type>& fvm)
1411 {
1412  return fvm.solve();
1413 }
1414 
1415 template<class Type>
1416 Foam::SolverPerformance<Type> Foam::solve(const tmp<fvMatrix<Type>>& tfvm)
1417 {
1418  SolverPerformance<Type> solverPerf =
1419  const_cast<fvMatrix<Type>&>(tfvm()).solve();
1420 
1421  tfvm.clear();
1422 
1423  return solverPerf;
1424 }
1425 
1426 
1427 template<class Type>
1429 (
1430  const fvMatrix<Type>& A
1431 )
1432 {
1433  tmp<Foam::fvMatrix<Type>> tAcorr = A - (A & A.psi());
1434 
1435  // Delete the faceFluxCorrection from the correction matrix
1436  // as it does not have a clear meaning or purpose
1437  deleteDemandDrivenData(tAcorr.ref().faceFluxCorrectionPtr());
1438 
1439  return tAcorr;
1440 }
1441 
1442 
1443 template<class Type>
1445 (
1446  const tmp<fvMatrix<Type>>& tA
1447 )
1448 {
1449  tmp<Foam::fvMatrix<Type>> tAcorr = tA - (tA() & tA().psi());
1450 
1451  // Delete the faceFluxCorrection from the correction matrix
1452  // as it does not have a clear meaning or purpose
1453  deleteDemandDrivenData(tAcorr.ref().faceFluxCorrectionPtr());
1454 
1455  return tAcorr;
1456 }
1457 
1458 
1459 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
1460 
1461 template<class Type>
1462 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1463 (
1464  const fvMatrix<Type>& A,
1465  const fvMatrix<Type>& B
1466 )
1467 {
1468  checkMethod(A, B, "==");
1469  return (A - B);
1470 }
1471 
1472 template<class Type>
1473 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1474 (
1475  const tmp<fvMatrix<Type>>& tA,
1476  const fvMatrix<Type>& B
1477 )
1478 {
1479  checkMethod(tA(), B, "==");
1480  return (tA - B);
1481 }
1482 
1483 template<class Type>
1484 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1485 (
1486  const fvMatrix<Type>& A,
1487  const tmp<fvMatrix<Type>>& tB
1488 )
1489 {
1490  checkMethod(A, tB(), "==");
1491  return (A - tB);
1492 }
1493 
1494 template<class Type>
1495 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1496 (
1497  const tmp<fvMatrix<Type>>& tA,
1498  const tmp<fvMatrix<Type>>& tB
1499 )
1500 {
1501  checkMethod(tA(), tB(), "==");
1502  return (tA - tB);
1503 }
1504 
1505 template<class Type>
1506 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1507 (
1508  const fvMatrix<Type>& A,
1509  const DimensionedField<Type, volMesh>& su
1510 )
1511 {
1512  checkMethod(A, su, "==");
1513  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1514  tC.ref().source() += su.mesh().V()*su.field();
1515  return tC;
1516 }
1517 
1518 template<class Type>
1519 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1520 (
1521  const fvMatrix<Type>& A,
1522  const tmp<DimensionedField<Type, volMesh>>& tsu
1523 )
1524 {
1525  checkMethod(A, tsu(), "==");
1526  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1527  tC.ref().source() += tsu().mesh().V()*tsu().field();
1528  tsu.clear();
1529  return tC;
1530 }
1531 
1532 template<class Type>
1533 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1534 (
1535  const fvMatrix<Type>& A,
1536  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu
1537 )
1538 {
1539  checkMethod(A, tsu(), "==");
1540  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1541  tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
1542  tsu.clear();
1543  return tC;
1544 }
1545 
1546 template<class Type>
1547 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1548 (
1549  const tmp<fvMatrix<Type>>& tA,
1550  const DimensionedField<Type, volMesh>& su
1551 )
1552 {
1553  checkMethod(tA(), su, "==");
1554  tmp<fvMatrix<Type>> tC(tA.ptr());
1555  tC.ref().source() += su.mesh().V()*su.field();
1556  return tC;
1557 }
1558 
1559 template<class Type>
1560 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1561 (
1562  const tmp<fvMatrix<Type>>& tA,
1563  const tmp<DimensionedField<Type, volMesh>>& tsu
1564 )
1565 {
1566  checkMethod(tA(), tsu(), "==");
1567  tmp<fvMatrix<Type>> tC(tA.ptr());
1568  tC.ref().source() += tsu().mesh().V()*tsu().field();
1569  tsu.clear();
1570  return tC;
1571 }
1572 
1573 template<class Type>
1574 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1575 (
1576  const tmp<fvMatrix<Type>>& tA,
1577  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu
1578 )
1579 {
1580  checkMethod(tA(), tsu(), "==");
1581  tmp<fvMatrix<Type>> tC(tA.ptr());
1582  tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
1583  tsu.clear();
1584  return tC;
1585 }
1586 
1587 template<class Type>
1588 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1589 (
1590  const fvMatrix<Type>& A,
1591  const dimensioned<Type>& su
1592 )
1593 {
1594  checkMethod(A, su, "==");
1595  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1596  tC.ref().source() += A.psi().mesh().V()*su.value();
1597  return tC;
1598 }
1599 
1600 template<class Type>
1601 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1602 (
1603  const tmp<fvMatrix<Type>>& tA,
1604  const dimensioned<Type>& su
1605 )
1606 {
1607  checkMethod(tA(), su, "==");
1608  tmp<fvMatrix<Type>> tC(tA.ptr());
1609  tC.ref().source() += tC().psi().mesh().V()*su.value();
1610  return tC;
1611 }
1612 
1613 template<class Type>
1614 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1615 (
1616  const fvMatrix<Type>& A,
1617  const zero&
1618 )
1619 {
1620  return A;
1621 }
1622 
1623 
1624 template<class Type>
1625 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator==
1626 (
1627  const tmp<fvMatrix<Type>>& tA,
1628  const zero&
1629 )
1630 {
1631  return tA;
1632 }
1633 
1634 
1635 template<class Type>
1636 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1637 (
1638  const fvMatrix<Type>& A
1639 )
1640 {
1641  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1642  tC.ref().negate();
1643  return tC;
1644 }
1645 
1646 template<class Type>
1647 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1648 (
1649  const tmp<fvMatrix<Type>>& tA
1650 )
1651 {
1652  tmp<fvMatrix<Type>> tC(tA.ptr());
1653  tC.ref().negate();
1654  return tC;
1655 }
1656 
1657 
1658 template<class Type>
1659 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1660 (
1661  const fvMatrix<Type>& A,
1662  const fvMatrix<Type>& B
1663 )
1664 {
1665  checkMethod(A, B, "+");
1666  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1667  tC.ref() += B;
1668  return tC;
1669 }
1670 
1671 template<class Type>
1672 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1673 (
1674  const tmp<fvMatrix<Type>>& tA,
1675  const fvMatrix<Type>& B
1676 )
1677 {
1678  checkMethod(tA(), B, "+");
1679  tmp<fvMatrix<Type>> tC(tA.ptr());
1680  tC.ref() += B;
1681  return tC;
1682 }
1683 
1684 template<class Type>
1685 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1686 (
1687  const fvMatrix<Type>& A,
1688  const tmp<fvMatrix<Type>>& tB
1689 )
1690 {
1691  checkMethod(A, tB(), "+");
1692  tmp<fvMatrix<Type>> tC(tB.ptr());
1693  tC.ref() += A;
1694  return tC;
1695 }
1696 
1697 template<class Type>
1698 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1699 (
1700  const tmp<fvMatrix<Type>>& tA,
1701  const tmp<fvMatrix<Type>>& tB
1702 )
1703 {
1704  checkMethod(tA(), tB(), "+");
1705  tmp<fvMatrix<Type>> tC(tA.ptr());
1706  tC.ref() += tB();
1707  tB.clear();
1708  return tC;
1709 }
1710 
1711 template<class Type>
1712 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1713 (
1714  const fvMatrix<Type>& A,
1715  const DimensionedField<Type, volMesh>& su
1716 )
1717 {
1718  checkMethod(A, su, "+");
1719  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1720  tC.ref().source() -= su.mesh().V()*su.field();
1721  return tC;
1722 }
1723 
1724 template<class Type>
1725 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1726 (
1727  const fvMatrix<Type>& A,
1728  const tmp<DimensionedField<Type, volMesh>>& tsu
1729 )
1730 {
1731  checkMethod(A, tsu(), "+");
1732  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1733  tC.ref().source() -= tsu().mesh().V()*tsu().field();
1734  tsu.clear();
1735  return tC;
1736 }
1737 
1738 template<class Type>
1739 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1740 (
1741  const fvMatrix<Type>& A,
1742  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu
1743 )
1744 {
1745  checkMethod(A, tsu(), "+");
1746  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1747  tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
1748  tsu.clear();
1749  return tC;
1750 }
1751 
1752 template<class Type>
1753 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1754 (
1755  const tmp<fvMatrix<Type>>& tA,
1756  const DimensionedField<Type, volMesh>& su
1757 )
1758 {
1759  checkMethod(tA(), su, "+");
1760  tmp<fvMatrix<Type>> tC(tA.ptr());
1761  tC.ref().source() -= su.mesh().V()*su.field();
1762  return tC;
1763 }
1764 
1765 template<class Type>
1766 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1767 (
1768  const tmp<fvMatrix<Type>>& tA,
1769  const tmp<DimensionedField<Type, volMesh>>& tsu
1770 )
1771 {
1772  checkMethod(tA(), tsu(), "+");
1773  tmp<fvMatrix<Type>> tC(tA.ptr());
1774  tC.ref().source() -= tsu().mesh().V()*tsu().field();
1775  tsu.clear();
1776  return tC;
1777 }
1778 
1779 template<class Type>
1780 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1781 (
1782  const tmp<fvMatrix<Type>>& tA,
1783  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu
1784 )
1785 {
1786  checkMethod(tA(), tsu(), "+");
1787  tmp<fvMatrix<Type>> tC(tA.ptr());
1788  tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
1789  tsu.clear();
1790  return tC;
1791 }
1792 
1793 template<class Type>
1794 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1795 (
1796  const DimensionedField<Type, volMesh>& su,
1797  const fvMatrix<Type>& A
1798 )
1799 {
1800  checkMethod(A, su, "+");
1801  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1802  tC.ref().source() -= su.mesh().V()*su.field();
1803  return tC;
1804 }
1805 
1806 template<class Type>
1807 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1808 (
1809  const tmp<DimensionedField<Type, volMesh>>& tsu,
1810  const fvMatrix<Type>& A
1811 )
1812 {
1813  checkMethod(A, tsu(), "+");
1814  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1815  tC.ref().source() -= tsu().mesh().V()*tsu().field();
1816  tsu.clear();
1817  return tC;
1818 }
1819 
1820 template<class Type>
1821 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1822 (
1823  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu,
1824  const fvMatrix<Type>& A
1825 )
1826 {
1827  checkMethod(A, tsu(), "+");
1828  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1829  tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
1830  tsu.clear();
1831  return tC;
1832 }
1833 
1834 template<class Type>
1835 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1836 (
1837  const DimensionedField<Type, volMesh>& su,
1838  const tmp<fvMatrix<Type>>& tA
1839 )
1840 {
1841  checkMethod(tA(), su, "+");
1842  tmp<fvMatrix<Type>> tC(tA.ptr());
1843  tC.ref().source() -= su.mesh().V()*su.field();
1844  return tC;
1845 }
1846 
1847 template<class Type>
1848 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1849 (
1850  const tmp<DimensionedField<Type, volMesh>>& tsu,
1851  const tmp<fvMatrix<Type>>& tA
1852 )
1853 {
1854  checkMethod(tA(), tsu(), "+");
1855  tmp<fvMatrix<Type>> tC(tA.ptr());
1856  tC.ref().source() -= tsu().mesh().V()*tsu().field();
1857  tsu.clear();
1858  return tC;
1859 }
1860 
1861 template<class Type>
1862 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
1863 (
1864  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu,
1865  const tmp<fvMatrix<Type>>& tA
1866 )
1867 {
1868  checkMethod(tA(), tsu(), "+");
1869  tmp<fvMatrix<Type>> tC(tA.ptr());
1870  tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
1871  tsu.clear();
1872  return tC;
1873 }
1874 
1875 
1876 template<class Type>
1877 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1878 (
1879  const fvMatrix<Type>& A,
1880  const fvMatrix<Type>& B
1881 )
1882 {
1883  checkMethod(A, B, "-");
1884  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1885  tC.ref() -= B;
1886  return tC;
1887 }
1888 
1889 template<class Type>
1890 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1891 (
1892  const tmp<fvMatrix<Type>>& tA,
1893  const fvMatrix<Type>& B
1894 )
1895 {
1896  checkMethod(tA(), B, "-");
1897  tmp<fvMatrix<Type>> tC(tA.ptr());
1898  tC.ref() -= B;
1899  return tC;
1900 }
1901 
1902 template<class Type>
1903 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1904 (
1905  const fvMatrix<Type>& A,
1906  const tmp<fvMatrix<Type>>& tB
1907 )
1908 {
1909  checkMethod(A, tB(), "-");
1910  tmp<fvMatrix<Type>> tC(tB.ptr());
1911  tC.ref() -= A;
1912  tC.ref().negate();
1913  return tC;
1914 }
1915 
1916 template<class Type>
1917 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1918 (
1919  const tmp<fvMatrix<Type>>& tA,
1920  const tmp<fvMatrix<Type>>& tB
1921 )
1922 {
1923  checkMethod(tA(), tB(), "-");
1924  tmp<fvMatrix<Type>> tC(tA.ptr());
1925  tC.ref() -= tB();
1926  tB.clear();
1927  return tC;
1928 }
1929 
1930 template<class Type>
1931 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1932 (
1933  const fvMatrix<Type>& A,
1934  const DimensionedField<Type, volMesh>& su
1935 )
1936 {
1937  checkMethod(A, su, "-");
1938  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1939  tC.ref().source() += su.mesh().V()*su.field();
1940  return tC;
1941 }
1942 
1943 template<class Type>
1944 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1945 (
1946  const fvMatrix<Type>& A,
1947  const tmp<DimensionedField<Type, volMesh>>& tsu
1948 )
1949 {
1950  checkMethod(A, tsu(), "-");
1951  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1952  tC.ref().source() += tsu().mesh().V()*tsu().field();
1953  tsu.clear();
1954  return tC;
1955 }
1956 
1957 template<class Type>
1958 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1959 (
1960  const fvMatrix<Type>& A,
1961  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu
1962 )
1963 {
1964  checkMethod(A, tsu(), "-");
1965  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
1966  tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
1967  tsu.clear();
1968  return tC;
1969 }
1970 
1971 template<class Type>
1972 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1973 (
1974  const tmp<fvMatrix<Type>>& tA,
1975  const DimensionedField<Type, volMesh>& su
1976 )
1977 {
1978  checkMethod(tA(), su, "-");
1979  tmp<fvMatrix<Type>> tC(tA.ptr());
1980  tC.ref().source() += su.mesh().V()*su.field();
1981  return tC;
1982 }
1983 
1984 template<class Type>
1985 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
1986 (
1987  const tmp<fvMatrix<Type>>& tA,
1988  const tmp<DimensionedField<Type, volMesh>>& tsu
1989 )
1990 {
1991  checkMethod(tA(), tsu(), "-");
1992  tmp<fvMatrix<Type>> tC(tA.ptr());
1993  tC.ref().source() += tsu().mesh().V()*tsu().field();
1994  tsu.clear();
1995  return tC;
1996 }
1997 
1998 template<class Type>
1999 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2000 (
2001  const tmp<fvMatrix<Type>>& tA,
2002  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu
2003 )
2004 {
2005  checkMethod(tA(), tsu(), "-");
2006  tmp<fvMatrix<Type>> tC(tA.ptr());
2007  tC.ref().source() += tsu().mesh().V()*tsu().primitiveField();
2008  tsu.clear();
2009  return tC;
2010 }
2011 
2012 template<class Type>
2013 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2014 (
2015  const DimensionedField<Type, volMesh>& su,
2016  const fvMatrix<Type>& A
2017 )
2018 {
2019  checkMethod(A, su, "-");
2020  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2021  tC.ref().negate();
2022  tC.ref().source() -= su.mesh().V()*su.field();
2023  return tC;
2024 }
2025 
2026 template<class Type>
2027 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2028 (
2029  const tmp<DimensionedField<Type, volMesh>>& tsu,
2030  const fvMatrix<Type>& A
2031 )
2032 {
2033  checkMethod(A, tsu(), "-");
2034  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2035  tC.ref().negate();
2036  tC.ref().source() -= tsu().mesh().V()*tsu().field();
2037  tsu.clear();
2038  return tC;
2039 }
2040 
2041 template<class Type>
2042 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2043 (
2044  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu,
2045  const fvMatrix<Type>& A
2046 )
2047 {
2048  checkMethod(A, tsu(), "-");
2049  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2050  tC.ref().negate();
2051  tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2052  tsu.clear();
2053  return tC;
2054 }
2055 
2056 template<class Type>
2057 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2058 (
2059  const DimensionedField<Type, volMesh>& su,
2060  const tmp<fvMatrix<Type>>& tA
2061 )
2062 {
2063  checkMethod(tA(), su, "-");
2064  tmp<fvMatrix<Type>> tC(tA.ptr());
2065  tC.ref().negate();
2066  tC.ref().source() -= su.mesh().V()*su.field();
2067  return tC;
2068 }
2069 
2070 template<class Type>
2071 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2072 (
2073  const tmp<DimensionedField<Type, volMesh>>& tsu,
2074  const tmp<fvMatrix<Type>>& tA
2075 )
2076 {
2077  checkMethod(tA(), tsu(), "-");
2078  tmp<fvMatrix<Type>> tC(tA.ptr());
2079  tC.ref().negate();
2080  tC.ref().source() -= tsu().mesh().V()*tsu().field();
2081  tsu.clear();
2082  return tC;
2083 }
2084 
2085 template<class Type>
2086 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2087 (
2088  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tsu,
2089  const tmp<fvMatrix<Type>>& tA
2090 )
2091 {
2092  checkMethod(tA(), tsu(), "-");
2093  tmp<fvMatrix<Type>> tC(tA.ptr());
2094  tC.ref().negate();
2095  tC.ref().source() -= tsu().mesh().V()*tsu().primitiveField();
2096  tsu.clear();
2097  return tC;
2098 }
2099 
2100 template<class Type>
2101 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2102 (
2103  const fvMatrix<Type>& A,
2104  const dimensioned<Type>& su
2105 )
2106 {
2107  checkMethod(A, su, "+");
2108  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2109  tC.ref().source() -= su.value()*A.psi().mesh().V();
2110  return tC;
2111 }
2112 
2113 template<class Type>
2114 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2115 (
2116  const tmp<fvMatrix<Type>>& tA,
2117  const dimensioned<Type>& su
2118 )
2119 {
2120  checkMethod(tA(), su, "+");
2121  tmp<fvMatrix<Type>> tC(tA.ptr());
2122  tC.ref().source() -= su.value()*tC().psi().mesh().V();
2123  return tC;
2124 }
2125 
2126 template<class Type>
2127 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2128 (
2129  const dimensioned<Type>& su,
2130  const fvMatrix<Type>& A
2131 )
2132 {
2133  checkMethod(A, su, "+");
2134  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2135  tC.ref().source() -= su.value()*A.psi().mesh().V();
2136  return tC;
2137 }
2138 
2139 template<class Type>
2140 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator+
2141 (
2142  const dimensioned<Type>& su,
2143  const tmp<fvMatrix<Type>>& tA
2144 )
2145 {
2146  checkMethod(tA(), su, "+");
2147  tmp<fvMatrix<Type>> tC(tA.ptr());
2148  tC.ref().source() -= su.value()*tC().psi().mesh().V();
2149  return tC;
2150 }
2151 
2152 template<class Type>
2153 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2154 (
2155  const fvMatrix<Type>& A,
2156  const dimensioned<Type>& su
2157 )
2158 {
2159  checkMethod(A, su, "-");
2160  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2161  tC.ref().source() += su.value()*tC().psi().mesh().V();
2162  return tC;
2163 }
2164 
2165 template<class Type>
2166 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2167 (
2168  const tmp<fvMatrix<Type>>& tA,
2169  const dimensioned<Type>& su
2170 )
2171 {
2172  checkMethod(tA(), su, "-");
2173  tmp<fvMatrix<Type>> tC(tA.ptr());
2174  tC.ref().source() += su.value()*tC().psi().mesh().V();
2175  return tC;
2176 }
2177 
2178 template<class Type>
2179 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2180 (
2181  const dimensioned<Type>& su,
2182  const fvMatrix<Type>& A
2183 )
2184 {
2185  checkMethod(A, su, "-");
2186  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2187  tC.ref().negate();
2188  tC.ref().source() -= su.value()*A.psi().mesh().V();
2189  return tC;
2190 }
2191 
2192 template<class Type>
2193 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator-
2194 (
2195  const dimensioned<Type>& su,
2196  const tmp<fvMatrix<Type>>& tA
2197 )
2198 {
2199  checkMethod(tA(), su, "-");
2200  tmp<fvMatrix<Type>> tC(tA.ptr());
2201  tC.ref().negate();
2202  tC.ref().source() -= su.value()*tC().psi().mesh().V();
2203  return tC;
2204 }
2205 
2206 
2207 template<class Type>
2208 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2209 (
2210  const volScalarField::Internal& dsf,
2211  const fvMatrix<Type>& A
2212 )
2213 {
2214  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2215  tC.ref() *= dsf;
2216  return tC;
2217 }
2218 
2219 template<class Type>
2220 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2221 (
2222  const tmp<volScalarField::Internal>& tdsf,
2223  const fvMatrix<Type>& A
2224 )
2225 {
2226  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2227  tC.ref() *= tdsf;
2228  return tC;
2229 }
2230 
2231 template<class Type>
2232 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2233 (
2234  const tmp<volScalarField>& tvsf,
2235  const fvMatrix<Type>& A
2236 )
2237 {
2238  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2239  tC.ref() *= tvsf;
2240  return tC;
2241 }
2242 
2243 template<class Type>
2244 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2245 (
2246  const volScalarField::Internal& dsf,
2247  const tmp<fvMatrix<Type>>& tA
2248 )
2249 {
2250  tmp<fvMatrix<Type>> tC(tA.ptr());
2251  tC.ref() *= dsf;
2252  return tC;
2253 }
2254 
2255 template<class Type>
2256 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2257 (
2258  const tmp<volScalarField::Internal>& tdsf,
2259  const tmp<fvMatrix<Type>>& tA
2260 )
2261 {
2262  tmp<fvMatrix<Type>> tC(tA.ptr());
2263  tC.ref() *= tdsf;
2264  return tC;
2265 }
2266 
2267 template<class Type>
2268 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2269 (
2270  const tmp<volScalarField>& tvsf,
2271  const tmp<fvMatrix<Type>>& tA
2272 )
2273 {
2274  tmp<fvMatrix<Type>> tC(tA.ptr());
2275  tC.ref() *= tvsf;
2276  return tC;
2277 }
2278 
2279 template<class Type>
2280 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2281 (
2282  const dimensioned<scalar>& ds,
2283  const fvMatrix<Type>& A
2284 )
2285 {
2286  tmp<fvMatrix<Type>> tC(new fvMatrix<Type>(A));
2287  tC.ref() *= ds;
2288  return tC;
2289 }
2290 
2291 template<class Type>
2292 Foam::tmp<Foam::fvMatrix<Type>> Foam::operator*
2293 (
2294  const dimensioned<scalar>& ds,
2295  const tmp<fvMatrix<Type>>& tA
2296 )
2297 {
2298  tmp<fvMatrix<Type>> tC(tA.ptr());
2299  tC.ref() *= ds;
2300  return tC;
2301 }
2302 
2303 
2304 template<class Type>
2306 Foam::operator&
2307 (
2308  const fvMatrix<Type>& M,
2309  const DimensionedField<Type, volMesh>& psi
2310 )
2311 {
2312  tmp<GeometricField<Type, fvPatchField, volMesh>> tMphi
2313  (
2314  new GeometricField<Type, fvPatchField, volMesh>
2315  (
2316  IOobject
2317  (
2318  "M&" + psi.name(),
2319  psi.instance(),
2320  psi.mesh(),
2323  ),
2324  psi.mesh(),
2325  M.dimensions()/dimVol,
2326  extrapolatedCalculatedFvPatchScalarField::typeName
2327  )
2328  );
2329  GeometricField<Type, fvPatchField, volMesh>& Mphi = tMphi.ref();
2330 
2331  // Loop over field components
2332  if (M.hasDiag())
2333  {
2334  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
2335  {
2336  scalarField psiCmpt(psi.field().component(cmpt));
2337  scalarField boundaryDiagCmpt(M.diag());
2338  M.addBoundaryDiag(boundaryDiagCmpt, cmpt);
2339  Mphi.primitiveFieldRef().replace(cmpt, -boundaryDiagCmpt*psiCmpt);
2340  }
2341  }
2342  else
2343  {
2344  Mphi.primitiveFieldRef() = Zero;
2345  }
2346 
2347  Mphi.primitiveFieldRef() += M.lduMatrix::H(psi.field()) + M.source();
2348  M.addBoundarySource(Mphi.primitiveFieldRef());
2349 
2350  Mphi.primitiveFieldRef() /= -psi.mesh().V();
2352 
2353  return tMphi;
2354 }
2355 
2356 template<class Type>
2358 Foam::operator&
2359 (
2360  const fvMatrix<Type>& M,
2361  const tmp<DimensionedField<Type, volMesh>>& tpsi
2362 )
2363 {
2364  tmp<GeometricField<Type, fvPatchField, volMesh>> tMpsi = M & tpsi();
2365  tpsi.clear();
2366  return tMpsi;
2367 }
2368 
2369 template<class Type>
2371 Foam::operator&
2372 (
2373  const fvMatrix<Type>& M,
2374  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tpsi
2375 )
2376 {
2377  tmp<GeometricField<Type, fvPatchField, volMesh>> tMpsi = M & tpsi();
2378  tpsi.clear();
2379  return tMpsi;
2380 }
2381 
2382 template<class Type>
2384 Foam::operator&
2385 (
2386  const tmp<fvMatrix<Type>>& tM,
2387  const DimensionedField<Type, volMesh>& psi
2388 )
2389 {
2390  tmp<GeometricField<Type, fvPatchField, volMesh>> tMpsi = tM() & psi;
2391  tM.clear();
2392  return tMpsi;
2393 }
2394 
2395 template<class Type>
2397 Foam::operator&
2398 (
2399  const tmp<fvMatrix<Type>>& tM,
2400  const tmp<DimensionedField<Type, volMesh>>& tpsi
2401 )
2402 {
2403  tmp<GeometricField<Type, fvPatchField, volMesh>> tMpsi = tM() & tpsi();
2404  tM.clear();
2405  tpsi.clear();
2406  return tMpsi;
2407 }
2408 
2409 template<class Type>
2411 Foam::operator&
2412 (
2413  const tmp<fvMatrix<Type>>& tM,
2414  const tmp<GeometricField<Type, fvPatchField, volMesh>>& tpsi
2415 )
2416 {
2417  tmp<GeometricField<Type, fvPatchField, volMesh>> tMpsi = tM() & tpsi();
2418  tM.clear();
2419  tpsi.clear();
2420  return tMpsi;
2421 }
2422 
2423 
2424 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
2425 
2426 template<class Type>
2427 Foam::Ostream& Foam::operator<<(Ostream& os, const fvMatrix<Type>& fvm)
2428 {
2429  os << static_cast<const lduMatrix&>(fvm) << nl
2430  << fvm.dimensions_ << nl
2431  << fvm.source_ << nl
2432  << fvm.internalCoeffs_ << nl
2433  << fvm.boundaryCoeffs_ << endl;
2434 
2435  os.check(FUNCTION_NAME);
2436 
2437  return os;
2438 }
2439 
2440 
2441 // * * * * * * * * * * * * * * * * Solvers * * * * * * * * * * * * * * * * * //
2442 
2443 #include "fvMatrixSolve.C"
2444 
2445 // ************************************************************************* //
Foam::checkMethod
void checkMethod(const faMatrix< Type > &, const faMatrix< Type > &, const char *)
Definition: faMatrix.C:957
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
volFields.H
Foam::lduMatrix::operator-=
void operator-=(const lduMatrix &)
Definition: lduMatrixOperations.C:223
Foam::fvMatrix::H
tmp< GeometricField< Type, fvPatchField, volMesh > > H() const
Return the H operation source.
Definition: fvMatrix.C:800
Foam::maxOp
Definition: ops.H:223
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::fvMatrix::addBoundarySource
void addBoundarySource(Field< Type > &source, const bool couples=true) const
Definition: fvMatrix.C:149
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
fvMatrixSolve.C
Foam::GeometricField::component
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Foam::fvMatrix::boundaryManipulate
void boundaryManipulate(typename GeometricField< Type, fvPatchField, volMesh >::Boundary &values)
Manipulate based on a boundary field.
Definition: fvMatrix.C:725
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:320
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:44
Foam::GeometricField::replace
void replace(const direction d, const GeometricField< cmptType, PatchField, GeoMesh > &gcf)
Replace specified field component with content from another field.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
UIndirectList.H
Foam::fvMatrix::addCmptAvBoundaryDiag
void addCmptAvBoundaryDiag(scalarField &diag) const
Definition: fvMatrix.C:133
Foam::FieldField
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:53
Foam::tmp::clear
void clear() const noexcept
Definition: tmpI.H:325
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::cmptMultiply
dimensioned< Type > cmptMultiply(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::lduMatrix::operator+=
void operator+=(const lduMatrix &)
Definition: lduMatrixOperations.C:144
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::diag
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
Definition: pointPatchFieldFunctions.H:287
Foam::fvMatrix::D
tmp< scalarField > D() const
Return the matrix scalar diagonal.
Definition: fvMatrix.C:738
Foam::fvMatrix::subtractFromInternalField
void subtractFromInternalField(const labelUList &addr, const Field< Type2 > &pf, Field< Type2 > &intf) const
Subtract patch contribution from internal field.
Definition: fvMatrix.C:79
calculatedFvPatchFields.H
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::fvMatrix::operator=
void operator=(const fvMatrix< Type > &)
Definition: fvMatrix.C:1013
Foam::lduMatrix
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:83
Foam::fvMatrix::dimensions
const dimensionSet & dimensions() const
Definition: fvMatrix.H:290
Foam::fvMatrix::relax
void relax()
Relax matrix (for steady-state solution).
Definition: fvMatrix.C:708
B
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
Foam::dimensioned::name
const word & name() const
Return const reference to name.
Definition: dimensionedType.C:406
Foam::fvMatrix::negate
void negate()
Definition: fvMatrix.C:1055
A
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
surfaceFields.H
Foam::surfaceFields.
Foam::correction
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix.
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:434
Foam::fvMatrix::addBoundaryDiag
void addBoundaryDiag(scalarField &diag, const direction cmpt) const
Definition: fvMatrix.C:115
Foam::fvMatrix::setReference
void setReference(const label celli, const Type &value, const bool forceReference=false)
Set reference level for solution.
Definition: fvMatrix.C:495
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:65
primitiveFieldRef
conserve primitiveFieldRef()+
Foam::fvMatrix::setReferences
void setReferences(const labelUList &cells, const Type &value, const bool forceReference=false)
Set references level for solution.
Definition: fvMatrix.C:511
Foam::fvMatrix::psi
const GeometricField< Type, fvPatchField, volMesh > & psi() const
Definition: fvMatrix.H:285
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::cmptMin
void cmptMin(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:302
Foam::cmptMag
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:400
coupledFvPatchFields.H
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::cmptMax
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:253
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::fvPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvPatchField.H:331
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::fvMatrix::setValues
void setValues(const labelUList &cells, const UList< Type > &values)
Set solution in given cells to the specified values.
Definition: fvMatrix.C:473
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::stringOps::lower
string lower(const std::string &s)
Return string copy transformed with std::tolower on each character.
Definition: stringOps.C:1186
Foam::fvMatrix::operator-=
void operator-=(const fvMatrix< Type > &)
Definition: fvMatrix.C:1104
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:360
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::GeometricField< scalar, fvPatchField, volMesh >::Internal
DimensionedField< scalar, volMesh > Internal
Type of the internal field from which this GeometricField is derived.
Definition: GeometricField.H:107
Foam::fvMatrix::H1
tmp< volScalarField > H1() const
Return H(1)
Definition: fvMatrix.C:862
Foam::fvMatrix::~fvMatrix
virtual ~fvMatrix()
Destructor.
Definition: fvMatrix.C:457
Foam::cmptAv
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:246
Foam::solve
SolverPerformance< Type > solve(faMatrix< Type > &, Istream &)
Solve returning the solution statistics given convergence tolerance.
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
Foam::Field::replace
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
Definition: Field.C:563
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::lduMatrix::H1
tmp< scalarField > H1() const
Definition: lduMatrixATmul.C:306
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::fvMatrix::DD
tmp< Field< Type > > DD() const
Return the matrix Type diagonal.
Definition: fvMatrix.C:747
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:43
Foam::fvMatrix::A
tmp< volScalarField > A() const
Return the central coefficient.
Definition: fvMatrix.C:771
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam::lduMatrix::negate
void negate()
Definition: lduMatrixOperations.C:125
Foam::tmp::ptr
T * ptr() const
Definition: tmpI.H:296
Foam::lduMatrix::H
tmp< Field< Type > > H(const Field< Type > &) const
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::DimensionedField::dimensions
const dimensionSet & dimensions() const
Return dimensions.
Definition: DimensionedFieldI.H:49
cellId
label cellId
Definition: interrogateWallPatches.H:67
Foam::fvPatchField::patchNeighbourField
virtual tmp< Field< Type > > patchNeighbourField() const
Return patchField on the opposite patch of a coupled patch.
Definition: fvPatchField.H:434
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:492
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::fvMatrix::setValuesFromList
void setValuesFromList(const labelUList &cells, const ListType< Type > &values)
Set solution in given cells to the specified values.
Definition: fvMatrix.C:182
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::lduMatrix::operator=
void operator=(const lduMatrix &)
Definition: lduMatrixOperations.C:91
Foam::GeometricField::ref
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Definition: GeometricField.C:749
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::fvMatrix::operator+=
void operator+=(const fvMatrix< Type > &)
Definition: fvMatrix.C:1070
Foam::List< cell >
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:54
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::lduMatrix::operator*=
void operator*=(const scalarField &)
Definition: lduMatrixOperations.C:302
Foam::lduMatrix::faceH
tmp< Field< Type > > faceH(const Field< Type > &) const
Foam::fvMatrix::solverDict
const dictionary & solverDict() const
Return the solver dictionary taking into account finalIteration.
Definition: fvMatrix.C:997
M
#define M(I)
Foam::UList< label >
D
const dimensionedScalar & D
Definition: solveBulkSurfactant.H:4
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::fvMatrix::clone
tmp< fvMatrix< Type > > clone() const
Clone.
Definition: fvMatrix.C:445
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:265
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:109
Foam::dimVol
const dimensionSet dimVol(dimVolume)
Older spelling for dimVolume.
Definition: dimensionSets.H:65
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::stringOps::upper
string upper(const std::string &s)
Return string copy transformed with std::toupper on each character.
Definition: stringOps.C:1202
Foam::dimensioned::dimensions
const dimensionSet & dimensions() const
Return const reference to dimensions.
Definition: dimensionedType.C:420
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:61
Foam::GeometricField< Type, fvPatchField, volMesh >
psi
const volScalarField & psi
Definition: createFieldRefs.H:1
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::fvMatrix::addToInternalField
void addToInternalField(const labelUList &addr, const Field< Type2 > &pf, Field< Type2 > &intf) const
Add patch contribution to internal field.
Definition: fvMatrix.C:42
Foam::SolverPerformance
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics.
Definition: SolverPerformance.H:51
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:54
Foam::fvMatrix::flux
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > flux() const
Return the face-flux field from the matrix.
Definition: fvMatrix.C:910
Foam::fvMatrix::fvMatrix
fvMatrix(const GeometricField< Type, fvPatchField, volMesh > &, const dimensionSet &)
Construct given a field to solve for.
Definition: fvMatrix.C:272
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
extrapolatedCalculatedFvPatchFields.H
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
relax
UEqn relax()