faMatrix.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2019 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 "areaFields.H"
30 #include "edgeFields.H"
33 #include "demandDrivenData.H"
34 
35 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 
37 template<class Type>
38 template<class Type2>
40 (
41  const labelUList& addr,
42  const Field<Type2>& pf,
43  Field<Type2>& intf
44 ) const
45 {
46  if (addr.size() != pf.size())
47  {
49  << "sizes of addressing and field are different"
50  << abort(FatalError);
51  }
52 
53  forAll(addr, faceI)
54  {
55  intf[addr[faceI]] += pf[faceI];
56  }
57 }
58 
59 
60 template<class Type>
61 template<class Type2>
63 (
64  const labelUList& addr,
65  const tmp<Field<Type2>>& tpf,
66  Field<Type2>& intf
67 ) const
68 {
69  addToInternalField(addr, tpf(), intf);
70  tpf.clear();
71 }
72 
73 
74 template<class Type>
75 template<class Type2>
77 (
78  const labelUList& addr,
79  const Field<Type2>& pf,
80  Field<Type2>& intf
81 ) const
82 {
83  if (addr.size() != pf.size())
84  {
86  << "sizes of addressing and field are different"
87  << abort(FatalError);
88  }
89 
90  forAll(addr, faceI)
91  {
92  intf[addr[faceI]] -= pf[faceI];
93  }
94 }
95 
96 
97 template<class Type>
98 template<class Type2>
100 (
101  const labelUList& addr,
102  const tmp<Field<Type2>>& tpf,
103  Field<Type2>& intf
104 ) const
105 {
106  subtractFromInternalField(addr, tpf(), intf);
107  tpf.clear();
108 }
109 
110 
111 template<class Type>
113 (
114  scalarField& diag,
115  const direction solveCmpt
116 ) const
117 {
118  forAll(internalCoeffs_, patchI)
119  {
120  addToInternalField
121  (
122  lduAddr().patchAddr(patchI),
123  internalCoeffs_[patchI].component(solveCmpt),
124  diag
125  );
126  }
127 }
128 
129 
130 template<class Type>
132 {
133  forAll(internalCoeffs_, patchI)
134  {
135  addToInternalField
136  (
137  lduAddr().patchAddr(patchI),
138  cmptAv(internalCoeffs_[patchI]),
139  diag
140  );
141  }
142 }
143 
144 
145 template<class Type>
147 (
148  Field<Type>& source,
149  const bool couples
150 ) const
151 {
152  forAll(psi_.boundaryField(), patchI)
153  {
154  const faPatchField<Type>& ptf = psi_.boundaryField()[patchI];
155  const Field<Type>& pbc = boundaryCoeffs_[patchI];
156 
157  if (!ptf.coupled())
158  {
159  addToInternalField(lduAddr().patchAddr(patchI), pbc, source);
160  }
161  else if (couples)
162  {
163  tmp<Field<Type>> tpnf = ptf.patchNeighbourField();
164  const Field<Type>& pnf = tpnf();
165 
166  const labelUList& addr = lduAddr().patchAddr(patchI);
167 
168  forAll(addr, facei)
169  {
170  source[addr[facei]] += cmptMultiply(pbc[facei], pnf[facei]);
171  }
172  }
173  }
174 }
175 
176 
177 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
178 
179 template<class Type>
181 (
183  const dimensionSet& ds
184 )
185 :
186  lduMatrix(psi.mesh()),
187  psi_(psi),
188  dimensions_(ds),
189  source_(psi.size(), Zero),
190  internalCoeffs_(psi.mesh().boundary().size()),
191  boundaryCoeffs_(psi.mesh().boundary().size()),
192  faceFluxCorrectionPtr_(nullptr)
193 {
195  << "constructing faMatrix<Type> for field " << psi_.name()
196  << endl;
197 
198  // Initialise coupling coefficients
199  forAll(psi.mesh().boundary(), patchI)
200  {
201  internalCoeffs_.set
202  (
203  patchI,
204  new Field<Type>
205  (
206  psi.mesh().boundary()[patchI].size(),
207  Zero
208  )
209  );
210 
211  boundaryCoeffs_.set
212  (
213  patchI,
214  new Field<Type>
215  (
216  psi.mesh().boundary()[patchI].size(),
217  Zero
218  )
219  );
220  }
221 
222  // Update the boundary coefficients of psi without changing its event No.
225 
226  label currentStatePsi = psiRef.eventNo();
227  psiRef.boundaryFieldRef().updateCoeffs();
228  psiRef.eventNo() = currentStatePsi;
229 }
230 
231 
232 template<class Type>
234 :
235  refCount(),
236  lduMatrix(fam),
237  psi_(fam.psi_),
238  dimensions_(fam.dimensions_),
239  source_(fam.source_),
240  internalCoeffs_(fam.internalCoeffs_),
241  boundaryCoeffs_(fam.boundaryCoeffs_),
242  faceFluxCorrectionPtr_(nullptr)
243 {
245  << "copying faMatrix<Type> for field " << psi_.name()
246  << endl;
247 
248  if (fam.faceFluxCorrectionPtr_)
249  {
250  faceFluxCorrectionPtr_ = new
252  (
253  *(fam.faceFluxCorrectionPtr_)
254  );
255  }
256 }
257 
258 
259 template<class Type>
261 (
263  Istream& is
264 )
265 :
266  lduMatrix(psi.mesh()),
267  psi_(psi),
268  dimensions_(is),
269  source_(is),
270  internalCoeffs_(psi.mesh().boundary().size()),
271  boundaryCoeffs_(psi.mesh().boundary().size()),
272  faceFluxCorrectionPtr_(nullptr)
273 {
275  << "constructing faMatrix<Type> for field " << psi_.name()
276  << endl;
277 
278  // Initialise coupling coefficients
279  forAll(psi.mesh().boundary(), patchI)
280  {
281  internalCoeffs_.set
282  (
283  patchI,
284  new Field<Type>
285  (
286  psi.mesh().boundary()[patchI].size(),
287  Zero
288  )
289  );
290 
291  boundaryCoeffs_.set
292  (
293  patchI,
294  new Field<Type>
295  (
296  psi.mesh().boundary()[patchI].size(),
297  Zero
298  )
299  );
300  }
301 
302 }
303 
304 
305 template<class Type>
307 {
308  return tmp<faMatrix<Type>>
309  (
310  new faMatrix<Type>(*this)
311  );
312 }
313 
314 
315 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
316 
317 
318 template<class Type>
320 {
322  << "destroying faMatrix<Type> for field " << psi_.name()
323  << endl;
324 
325  deleteDemandDrivenData(faceFluxCorrectionPtr_);
326 }
327 
328 
329 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
330 
331 template<class Type>
333 (
334  const labelUList& faceLabels,
335  const UList<Type>& values
336 )
337 {
338  const faMesh& mesh = psi_.mesh();
339 
340  // Record face labels of eliminated equations
341  for (const label i : faceLabels)
342  {
343  this->eliminatedEqns().insert(i);
344  }
345 
346  const labelListList& edges = mesh.patch().faceEdges();
347  const labelUList& own = mesh.owner();
348  const labelUList& nei = mesh.neighbour();
349 
350  scalarField& Diag = diag();
351  Field<Type>& psi =
352  const_cast
353  <
355  >(psi_).internalField();
356 
357 
358  forAll(faceLabels, i)
359  {
360  label facei = faceLabels[i];
361 
362  psi[facei] = values[i];
363  source_[facei] = values[i]*Diag[facei];
364 
365  if (symmetric() || asymmetric())
366  {
367  const labelList& c= edges[facei];
368 
369  forAll(c, j)
370  {
371  label edgei = c[j];
372 
373  if (mesh.isInternalEdge(edgei))
374  {
375  if (symmetric())
376  {
377  if (facei == own[edgei])
378  {
379  source_[nei[edgei]] -= upper()[edgei]*values[i];
380  }
381  else
382  {
383  source_[own[edgei]] -= upper()[edgei]*values[i];
384  }
385 
386  upper()[edgei] = 0.0;
387  }
388  else
389  {
390  if (facei == own[edgei])
391  {
392  source_[nei[edgei]] -= lower()[edgei]*values[i];
393  }
394  else
395  {
396  source_[own[edgei]] -= upper()[edgei]*values[i];
397  }
398 
399  upper()[edgei] = 0.0;
400  lower()[edgei] = 0.0;
401  }
402  }
403  else
404  {
405  label patchi = mesh.boundary().whichPatch(edgei);
406 
407  if (internalCoeffs_[patchi].size())
408  {
409  label patchEdgei =
410  mesh.boundary()[patchi].whichEdge(edgei);
411 
412  internalCoeffs_[patchi][patchEdgei] =
414 
415  boundaryCoeffs_[patchi][patchEdgei] =
417  }
418  }
419  }
420  }
421  }
422 }
423 
424 
425 template<class Type>
427 (
428  const label facei,
429  const Type& value
430 )
431 {
432  if (psi_.needReference())
433  {
434  if (Pstream::master())
435  {
436  source()[facei] += diag()[facei]*value;
437  diag()[facei] += diag()[facei];
438  }
439  }
440 }
441 
442 
443 template<class Type>
445 {
446  if (alpha <= 0)
447  {
448  return;
449  }
450 
451  Field<Type>& S = source();
452  scalarField& D = diag();
453 
454  // Store the current unrelaxed diagonal for use in updating the source
455  scalarField D0(D);
456 
457  // Calculate the sum-mag off-diagonal from the interior faces
458  scalarField sumOff(D.size(), Zero);
459  sumMagOffDiag(sumOff);
460 
461  // Handle the boundary contributions to the diagonal
462  forAll(psi_.boundaryField(), patchI)
463  {
464  const faPatchField<Type>& ptf = psi_.boundaryField()[patchI];
465 
466  if (ptf.size())
467  {
468  const labelUList& pa = lduAddr().patchAddr(patchI);
469  Field<Type>& iCoeffs = internalCoeffs_[patchI];
470 
471  if (ptf.coupled())
472  {
473  const Field<Type>& pCoeffs = boundaryCoeffs_[patchI];
474 
475  // For coupled boundaries add the diagonal and
476  // off-diagonal contributions
477  forAll(pa, face)
478  {
479  D[pa[face]] += component(iCoeffs[face], 0);
480  sumOff[pa[face]] += mag(component(pCoeffs[face], 0));
481  }
482  }
483  else
484  {
485  // For non-coupled boundaries subtract the diagonal
486  // contribution off-diagonal sum which avoids having to remove
487  // it from the diagonal later.
488  // Also add the source contribution from the relaxation
489  forAll(pa, face)
490  {
491  Type iCoeff0 = iCoeffs[face];
492  iCoeffs[face] = cmptMag(iCoeffs[face]);
493  sumOff[pa[face]] -= cmptMin(iCoeffs[face]);
494  iCoeffs[face] /= alpha;
495  S[pa[face]] +=
496  cmptMultiply(iCoeffs[face] - iCoeff0, psi_[pa[face]]);
497  }
498  }
499  }
500  }
501 
502  // Ensure the matrix is diagonally dominant...
503  max(D, D, sumOff);
504 
505  // ... then relax
506  D /= alpha;
507 
508  // Now remove the diagonal contribution from coupled boundaries
509  forAll(psi_.boundaryField(), patchI)
510  {
511  const faPatchField<Type>& ptf = psi_.boundaryField()[patchI];
512 
513  if (ptf.size())
514  {
515  const labelUList& pa = lduAddr().patchAddr(patchI);
516  Field<Type>& iCoeffs = internalCoeffs_[patchI];
517 
518  if (ptf.coupled())
519  {
520  forAll(pa, face)
521  {
522  D[pa[face]] -= component(iCoeffs[face], 0);
523  }
524  }
525  }
526  }
527 
528  // Finally add the relaxation contribution to the source.
529  S += (D - D0)*psi_.internalField();
530 }
531 
532 
533 template<class Type>
535 {
536  if (psi_.mesh().relaxEquation(psi_.name()))
537  {
538  relax(psi_.mesh().equationRelaxationFactor(psi_.name()));
539  }
540  else
541  {
543  << "Relaxation factor for field " << psi_.name()
544  << " not found. Relaxation will not be used." << endl;
545  }
546 }
547 
548 
549 template<class Type>
551 {
552  tmp<scalarField> tdiag(new scalarField(diag()));
553  addCmptAvBoundaryDiag(tdiag.ref());
554  return tdiag;
555 }
556 
557 
558 template<class Type>
560 {
562  (
563  new areaScalarField
564  (
565  IOobject
566  (
567  "A("+psi_.name()+')',
568  psi_.instance(),
569  psi_.db()
570  ),
571  psi_.mesh(),
572  dimensions_/psi_.dimensions()/dimArea,
573  zeroGradientFaPatchScalarField::typeName
574  )
575  );
576 
577  tAphi.ref().primitiveFieldRef() = D()/psi_.mesh().S();
578  tAphi.ref().correctBoundaryConditions();
579 
580  return tAphi;
581 }
582 
583 
584 template<class Type>
587 {
589  (
591  (
592  IOobject
593  (
594  "H("+psi_.name()+')',
595  psi_.instance(),
596  psi_.db()
597  ),
598  psi_.mesh(),
599  dimensions_/dimArea,
600  zeroGradientFaPatchScalarField::typeName
601  )
602  );
604 
605  // Loop over field components
606  for (direction cmpt=0; cmpt<Type::nComponents; ++cmpt)
607  {
608  scalarField psiCmpt(psi_.primitiveField().component(cmpt));
609 
610  scalarField boundaryDiagCmpt(psi_.size(), Zero);
611  addBoundaryDiag(boundaryDiagCmpt, cmpt);
612  boundaryDiagCmpt.negate();
613  addCmptAvBoundaryDiag(boundaryDiagCmpt);
614 
615  Hphi.primitiveFieldRef().replace(cmpt, boundaryDiagCmpt*psiCmpt);
616  }
617 
618  Hphi.primitiveFieldRef() += lduMatrix::H(psi_.internalField()) + source_;
619  addBoundarySource(Hphi.primitiveFieldRef());
620 
621  Hphi.primitiveFieldRef() /= psi_.mesh().S();
623 
624  return tHphi;
625 }
626 
627 
628 template<class Type>
631 {
632  if (!psi_.mesh().fluxRequired(psi_.name()))
633  {
635  << "flux requested but " << psi_.name()
636  << " not specified in the fluxRequired sub-dictionary of faSchemes"
637  << abort(FatalError);
638  }
639 
640  // construct GeometricField<Type, faePatchField, edgeMesh>
642  (
644  (
645  IOobject
646  (
647  "flux("+psi_.name()+')',
648  psi_.instance(),
649  psi_.db()
650  ),
651  psi_.mesh(),
652  dimensions()
653  )
654  );
656  tfieldFlux.ref();
657 
658  for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; ++cmpt)
659  {
660  fieldFlux.primitiveFieldRef().replace
661  (
662  cmpt,
663  lduMatrix::faceH(psi_.primitiveField().component(cmpt))
664  );
665  }
666 
667  FieldField<Field, Type> InternalContrib = internalCoeffs_;
668 
669  forAll(InternalContrib, patchI)
670  {
671  InternalContrib[patchI] =
673  (
674  InternalContrib[patchI],
675  psi_.boundaryField()[patchI].patchInternalField()
676  );
677  }
678 
679  FieldField<Field, Type> NeighbourContrib = boundaryCoeffs_;
680 
681  forAll(NeighbourContrib, patchI)
682  {
683  if (psi_.boundaryField()[patchI].coupled())
684  {
685  NeighbourContrib[patchI] =
687  (
688  NeighbourContrib[patchI],
689  psi_.boundaryField()[patchI].patchNeighbourField()
690  );
691  }
692  }
693 
694  forAll(fieldFlux.boundaryField(), patchI)
695  {
696  fieldFlux.boundaryFieldRef()[patchI] =
697  InternalContrib[patchI] - NeighbourContrib[patchI];
698  }
699 
700  if (faceFluxCorrectionPtr_)
701  {
702  fieldFlux += *faceFluxCorrectionPtr_;
703  }
704 
705  return tfieldFlux;
706 }
707 
708 
709 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
710 
711 template<class Type>
713 {
714  if (this == &famv)
715  {
716  return; // Self-assignment is a no-op
717  }
718 
719  if (&psi_ != &(famv.psi_))
720  {
722  << "different fields"
723  << abort(FatalError);
724  }
725 
726  lduMatrix::operator=(famv);
727  source_ = famv.source_;
728  internalCoeffs_ = famv.internalCoeffs_;
729  boundaryCoeffs_ = famv.boundaryCoeffs_;
730 
731  if (faceFluxCorrectionPtr_ && famv.faceFluxCorrectionPtr_)
732  {
733  *faceFluxCorrectionPtr_ = *famv.faceFluxCorrectionPtr_;
734  }
735  else if (famv.faceFluxCorrectionPtr_)
736  {
737  faceFluxCorrectionPtr_ =
739  (*famv.faceFluxCorrectionPtr_);
740  }
741 }
742 
743 
744 template<class Type>
746 {
747  operator=(tfamv());
748  tfamv.clear();
749 }
750 
751 
752 template<class Type>
754 {
756  source_.negate();
757  internalCoeffs_.negate();
758  boundaryCoeffs_.negate();
759 
760  if (faceFluxCorrectionPtr_)
761  {
762  faceFluxCorrectionPtr_->negate();
763  }
764 }
765 
766 
767 template<class Type>
769 {
770  checkMethod(*this, famv, "+=");
771 
772  dimensions_ += famv.dimensions_;
773  lduMatrix::operator+=(famv);
774  source_ += famv.source_;
775  internalCoeffs_ += famv.internalCoeffs_;
776  boundaryCoeffs_ += famv.boundaryCoeffs_;
777 
778  if (faceFluxCorrectionPtr_ && famv.faceFluxCorrectionPtr_)
779  {
780  *faceFluxCorrectionPtr_ += *famv.faceFluxCorrectionPtr_;
781  }
782  else if (famv.faceFluxCorrectionPtr_)
783  {
784  faceFluxCorrectionPtr_ = new
786  (
787  *famv.faceFluxCorrectionPtr_
788  );
789  }
790 }
791 
792 
793 template<class Type>
795 {
796  operator+=(tfamv());
797  tfamv.clear();
798 }
799 
800 
801 template<class Type>
803 {
804  checkMethod(*this, famv, "+=");
805 
806  dimensions_ -= famv.dimensions_;
807  lduMatrix::operator-=(famv);
808  source_ -= famv.source_;
809  internalCoeffs_ -= famv.internalCoeffs_;
810  boundaryCoeffs_ -= famv.boundaryCoeffs_;
811 
812  if (faceFluxCorrectionPtr_ && famv.faceFluxCorrectionPtr_)
813  {
814  *faceFluxCorrectionPtr_ -= *famv.faceFluxCorrectionPtr_;
815  }
816  else if (famv.faceFluxCorrectionPtr_)
817  {
818  faceFluxCorrectionPtr_ =
820  (-*famv.faceFluxCorrectionPtr_);
821  }
822 }
823 
824 
825 template<class Type>
827 {
828  operator-=(tfamv());
829  tfamv.clear();
830 }
831 
832 
833 template<class Type>
835 (
837 )
838 {
839  checkMethod(*this, su, "+=");
840  source() -= su.mesh().S()*su.internalField();
841 }
842 
843 
844 template<class Type>
846 (
848 )
849 {
850  operator+=(tsu());
851  tsu.clear();
852 }
853 
854 
855 template<class Type>
857 (
859 )
860 {
861  checkMethod(*this, su, "-=");
862  source() += su.mesh().S()*su.internalField();
863 }
864 
865 
866 template<class Type>
868 (
870 )
871 {
872  operator-=(tsu());
873  tsu.clear();
874 }
875 
876 
877 template<class Type>
879 (
880  const dimensioned<Type>& su
881 )
882 {
883  source() -= su.mesh().S()*su;
884 }
885 
886 
887 template<class Type>
889 (
890  const dimensioned<Type>& su
891 )
892 {
893  source() += su.mesh().S()*su;
894 }
895 
896 
897 template<class Type>
899 (
900  const areaScalarField& vsf
901 )
902 {
903  dimensions_ *= vsf.dimensions();
904  lduMatrix::operator*=(vsf.internalField());
905  source_ *= vsf.internalField();
906 
907  forAll(boundaryCoeffs_, patchI)
908  {
909  const scalarField psf(vsf.boundaryField()[patchI].patchInternalField());
910  internalCoeffs_[patchI] *= psf;
911  boundaryCoeffs_[patchI] *= psf;
912  }
913 
914  if (faceFluxCorrectionPtr_)
915  {
917  << "cannot scale a matrix containing a faceFluxCorrection"
918  << abort(FatalError);
919  }
920 }
921 
922 
923 template<class Type>
925 (
926  const tmp<areaScalarField>& tvsf
927 )
928 {
929  operator*=(tvsf());
930  tvsf.clear();
931 }
932 
933 
934 template<class Type>
936 (
937  const dimensioned<scalar>& ds
938 )
939 {
940  dimensions_ *= ds.dimensions();
941  lduMatrix::operator*=(ds.value());
942  source_ *= ds.value();
943  internalCoeffs_ *= ds.value();
944  boundaryCoeffs_ *= ds.value();
945 
946  if (faceFluxCorrectionPtr_)
947  {
948  *faceFluxCorrectionPtr_ *= ds.value();
949  }
950 }
951 
952 
953 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
954 
955 template<class Type>
957 (
958  const faMatrix<Type>& fam1,
959  const faMatrix<Type>& fam2,
960  const char* op
961 )
962 {
963  if (&fam1.psi() != &fam2.psi())
964  {
966  << "incompatible fields for operation "
967  << endl << " "
968  << "[" << fam1.psi().name() << "] "
969  << op
970  << " [" << fam2.psi().name() << "]"
971  << abort(FatalError);
972  }
973 
974  if (dimensionSet::debug && fam1.dimensions() != fam2.dimensions())
975  {
977  << "incompatible dimensions for operation "
978  << endl << " "
979  << "[" << fam1.psi().name() << fam1.dimensions()/dimArea << " ] "
980  << op
981  << " [" << fam2.psi().name() << fam2.dimensions()/dimArea << " ]"
982  << abort(FatalError);
983  }
984 }
985 
986 
987 template<class Type>
989 (
990  const faMatrix<Type>& fam,
992  const char* op
993 )
994 {
995  if (dimensionSet::debug && fam.dimensions()/dimArea != vf.dimensions())
996  {
998  << "incompatible dimensions for operation "
999  << endl << " "
1000  << "[" << fam.psi().name() << fam.dimensions()/dimArea << " ] "
1001  << op
1002  << " [" << vf.name() << vf.dimensions() << " ]"
1003  << abort(FatalError);
1004  }
1005 }
1006 
1007 
1008 template<class Type>
1009 void Foam::checkMethod
1011  const faMatrix<Type>& fam,
1012  const dimensioned<Type>& dt,
1013  const char* op
1014 )
1015 {
1016  if (dimensionSet::debug && fam.dimensions()/dimArea != dt.dimensions())
1017  {
1019  << "incompatible dimensions for operation "
1020  << endl << " "
1021  << "[" << fam.psi().name() << fam.dimensions()/dimArea << " ] "
1022  << op
1023  << " [" << dt.name() << dt.dimensions() << " ]"
1024  << abort(FatalError);
1025  }
1026 }
1027 
1028 
1029 template<class Type>
1031 (
1032  faMatrix<Type>& fam,
1033  Istream& solverControls
1034 )
1035 {
1036  return fam.solve(solverControls);
1037 }
1038 
1039 
1040 template<class Type>
1042 (
1043  const tmp<faMatrix<Type>>& tfam,
1044  Istream& solverControls
1045 )
1046 {
1047  SolverPerformance<Type> solverPerf =
1048  const_cast<faMatrix<Type>&>(tfam()).solve(solverControls);
1049 
1050  tfam.clear();
1051  return solverPerf;
1052 }
1053 
1054 
1055 template<class Type>
1057 {
1058  return fam.solve();
1059 }
1060 
1061 
1062 template<class Type>
1063 Foam::SolverPerformance<Type> Foam::solve(const tmp<faMatrix<Type>>& tfam)
1064 {
1065  SolverPerformance<Type> solverPerf =
1066  const_cast<faMatrix<Type>&>(tfam()).solve();
1067 
1068  tfam.clear();
1069  return solverPerf;
1070 }
1071 
1072 
1073 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
1074 
1075 template<class Type>
1076 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1077 (
1078  const faMatrix<Type>& A,
1079  const faMatrix<Type>& B
1080 )
1081 {
1082  checkMethod(A, B, "+");
1083  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1084  tC.ref() += B;
1085  return tC;
1086 }
1087 
1088 
1089 template<class Type>
1090 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1091 (
1092  const tmp<faMatrix<Type>>& tA,
1093  const faMatrix<Type>& B
1094 )
1095 {
1096  checkMethod(tA(), B, "+");
1097  tmp<faMatrix<Type>> tC(tA.ptr());
1098  tC.ref() += B;
1099  return tC;
1100 }
1101 
1102 
1103 template<class Type>
1104 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1105 (
1106  const faMatrix<Type>& A,
1107  const tmp<faMatrix<Type>>& tB
1108 )
1109 {
1110  checkMethod(A, tB(), "+");
1111  tmp<faMatrix<Type>> tC(tB.ptr());
1112  tC.ref() += A;
1113  return tC;
1114 }
1115 
1116 
1117 template<class Type>
1118 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1119 (
1120  const tmp<faMatrix<Type>>& tA,
1121  const tmp<faMatrix<Type>>& tB
1122 )
1123 {
1124  checkMethod(tA(), tB(), "+");
1125  tmp<faMatrix<Type>> tC(tA.ptr());
1126  tC.ref() += tB();
1127  tB.clear();
1128  return tC;
1129 }
1130 
1131 
1132 template<class Type>
1133 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1134 (
1135  const faMatrix<Type>& A
1136 )
1137 {
1138  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1139  tC.ref().negate();
1140  return tC;
1141 }
1142 
1143 
1144 template<class Type>
1145 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1146 (
1147  const tmp<faMatrix<Type>>& tA
1148 )
1149 {
1150  tmp<faMatrix<Type>> tC(tA.ptr());
1151  tC.ref().negate();
1152  return tC;
1153 }
1154 
1155 
1156 template<class Type>
1157 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1158 (
1159  const faMatrix<Type>& A,
1160  const faMatrix<Type>& B
1161 )
1162 {
1163  checkMethod(A, B, "-");
1164  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1165  tC.ref() -= B;
1166  return tC;
1167 }
1168 
1169 
1170 template<class Type>
1171 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1172 (
1173  const tmp<faMatrix<Type>>& tA,
1174  const faMatrix<Type>& B
1175 )
1176 {
1177  checkMethod(tA(), B, "-");
1178  tmp<faMatrix<Type>> tC(tA.ptr());
1179  tC.ref() -= B;
1180  return tC;
1181 }
1182 
1183 
1184 template<class Type>
1185 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1186 (
1187  const faMatrix<Type>& A,
1188  const tmp<faMatrix<Type>>& tB
1189 )
1190 {
1191  checkMethod(A, tB(), "-");
1192  tmp<faMatrix<Type>> tC(tB.ptr());
1193  tC.ref() -= A;
1194  tC.ref().negate();
1195  return tC;
1196 }
1197 
1198 
1199 template<class Type>
1200 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1201 (
1202  const tmp<faMatrix<Type>>& tA,
1203  const tmp<faMatrix<Type>>& tB
1204 )
1205 {
1206  checkMethod(tA(), tB(), "-");
1207  tmp<faMatrix<Type>> tC(tA.ptr());
1208  tC.ref() -= tB();
1209  tB.clear();
1210  return tC;
1211 }
1212 
1213 
1214 template<class Type>
1215 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1216 (
1217  const faMatrix<Type>& A,
1218  const faMatrix<Type>& B
1219 )
1220 {
1221  checkMethod(A, B, "==");
1222  return (A - B);
1223 }
1224 
1225 
1226 template<class Type>
1227 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1228 (
1229  const tmp<faMatrix<Type>>& tA,
1230  const faMatrix<Type>& B
1231 )
1232 {
1233  checkMethod(tA(), B, "==");
1234  return (tA - B);
1235 }
1236 
1237 
1238 template<class Type>
1239 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1240 (
1241  const faMatrix<Type>& A,
1242  const tmp<faMatrix<Type>>& tB
1243 )
1244 {
1245  checkMethod(A, tB(), "==");
1246  return (A - tB);
1247 }
1248 
1249 
1250 template<class Type>
1251 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1252 (
1253  const tmp<faMatrix<Type>>& tA,
1254  const tmp<faMatrix<Type>>& tB
1255 )
1256 {
1257  checkMethod(tA(), tB(), "==");
1258  return (tA - tB);
1259 }
1260 
1261 
1262 template<class Type>
1263 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1264 (
1265  const faMatrix<Type>& A,
1266  const GeometricField<Type, faPatchField, areaMesh>& su
1267 )
1268 {
1269  checkMethod(A, su, "+");
1270  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1271  tC.ref().source() -= su.mesh().S()*su.internalField();
1272  return tC;
1273 }
1274 
1275 
1276 template<class Type>
1277 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1278 (
1279  const tmp<faMatrix<Type>>& tA,
1280  const GeometricField<Type, faPatchField, areaMesh>& su
1281 )
1282 {
1283  checkMethod(tA(), su, "+");
1284  tmp<faMatrix<Type>> tC(tA.ptr());
1285  tC.ref().source() -= su.mesh().S()*su.internalField();
1286  return tC;
1287 }
1288 
1289 
1290 template<class Type>
1291 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1292 (
1293  const faMatrix<Type>& A,
1294  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu
1295 )
1296 {
1297  checkMethod(A, tsu(), "+");
1298  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1299  tC.ref().source() -= tsu().mesh().S()*tsu().internalField();
1300  tsu.clear();
1301  return tC;
1302 }
1303 
1304 
1305 template<class Type>
1306 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1307 (
1308  const tmp<faMatrix<Type>>& tA,
1309  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu
1310 )
1311 {
1312  checkMethod(tA(), tsu(), "+");
1313  tmp<faMatrix<Type>> tC(tA.ptr());
1314  tC.ref().source() -= tsu().mesh().S()*tsu().internalField();
1315  tsu.clear();
1316  return tC;
1317 }
1318 
1319 
1320 template<class Type>
1321 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1322 (
1323  const GeometricField<Type, faPatchField, areaMesh>& su,
1324  const faMatrix<Type>& A
1325 )
1326 {
1327  checkMethod(A, su, "+");
1328  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1329  tC.ref().source() -= su.mesh().S()*su.internalField();
1330  return tC;
1331 }
1332 
1333 
1334 template<class Type>
1335 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1336 (
1337  const GeometricField<Type, faPatchField, areaMesh>& su,
1338  const tmp<faMatrix<Type>>& tA
1339 )
1340 {
1341  checkMethod(tA(), su, "+");
1342  tmp<faMatrix<Type>> tC(tA.ptr());
1343  tC.ref().source() -= su.mesh().S()*su.internalField();
1344  return tC;
1345 }
1346 
1347 
1348 template<class Type>
1349 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1350 (
1351  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu,
1352  const faMatrix<Type>& A
1353 )
1354 {
1355  checkMethod(A, tsu(), "+");
1356  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1357  tC.ref().source() -= tsu().mesh().S()*tsu().internalField();
1358  tsu.clear();
1359  return tC;
1360 }
1361 
1362 
1363 template<class Type>
1364 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1365 (
1366  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu,
1367  const tmp<faMatrix<Type>>& tA
1368 )
1369 {
1370  checkMethod(tA(), tsu(), "+");
1371  tmp<faMatrix<Type>> tC(tA.ptr());
1372  tC.ref().source() -= tsu().mesh().S()*tsu().internalField();
1373  tsu.clear();
1374  return tC;
1375 }
1376 
1377 
1378 template<class Type>
1379 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1380 (
1381  const faMatrix<Type>& A,
1382  const GeometricField<Type, faPatchField, areaMesh>& su
1383 )
1384 {
1385  checkMethod(A, su, "-");
1386  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1387  tC.ref().source() += su.mesh().S()*su.internalField();
1388  return tC;
1389 }
1390 
1391 
1392 template<class Type>
1393 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1394 (
1395  const tmp<faMatrix<Type>>& tA,
1396  const GeometricField<Type, faPatchField, areaMesh>& su
1397 )
1398 {
1399  checkMethod(tA(), su, "-");
1400  tmp<faMatrix<Type>> tC(tA.ptr());
1401  tC.ref().source() += su.mesh().S()*su.internalField();
1402  return tC;
1403 }
1404 
1405 
1406 template<class Type>
1407 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1408 (
1409  const faMatrix<Type>& A,
1410  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu
1411 )
1412 {
1413  checkMethod(A, tsu(), "-");
1414  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1415  tC.ref().source() += tsu().mesh().S()*tsu().internalField();
1416  tsu.clear();
1417  return tC;
1418 }
1419 
1420 
1421 template<class Type>
1422 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1423 (
1424  const tmp<faMatrix<Type>>& tA,
1425  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu
1426 )
1427 {
1428  checkMethod(tA(), tsu(), "-");
1429  tmp<faMatrix<Type>> tC(tA.ptr());
1430  tC.ref().source() += tsu().mesh().S()*tsu().internalField();
1431  tsu.clear();
1432  return tC;
1433 }
1434 
1435 
1436 template<class Type>
1437 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1438 (
1439  const GeometricField<Type, faPatchField, areaMesh>& su,
1440  const faMatrix<Type>& A
1441 )
1442 {
1443  checkMethod(A, su, "-");
1444  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1445  tC.ref().negate();
1446  tC.ref().source() -= su.mesh().S()*su.internalField();
1447  return tC;
1448 }
1449 
1450 
1451 template<class Type>
1452 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1453 (
1454  const GeometricField<Type, faPatchField, areaMesh>& su,
1455  const tmp<faMatrix<Type>>& tA
1456 )
1457 {
1458  checkMethod(tA(), su, "-");
1459  tmp<faMatrix<Type>> tC(tA.ptr());
1460  tC.ref().negate();
1461  tC.ref().source() -= su.mesh().S()*su.internalField();
1462  return tC;
1463 }
1464 
1465 
1466 template<class Type>
1467 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1468 (
1469  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu,
1470  const faMatrix<Type>& A
1471 )
1472 {
1473  checkMethod(A, tsu(), "-");
1474  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1475  tC.ref().negate();
1476  tC.ref().source() -= tsu().mesh().S()*tsu().internalField();
1477  tsu.clear();
1478  return tC;
1479 }
1480 
1481 
1482 template<class Type>
1483 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1484 (
1485  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu,
1486  const tmp<faMatrix<Type>>& tA
1487 )
1488 {
1489  checkMethod(tA(), tsu(), "-");
1490  tmp<faMatrix<Type>> tC(tA.ptr());
1491  tC.ref().negate();
1492  tC.ref().source() -= tsu().mesh().S()*tsu().internalField();
1493  tsu.clear();
1494  return tC;
1495 }
1496 
1497 
1498 template<class Type>
1499 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1500 (
1501  const faMatrix<Type>& A,
1502  const dimensioned<Type>& su
1503 )
1504 {
1505  checkMethod(A, su, "+");
1506  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1507  tC.ref().source() -= su.value()*A.psi().mesh().S();
1508  return tC;
1509 }
1510 
1511 
1512 template<class Type>
1513 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1514 (
1515  const tmp<faMatrix<Type>>& tA,
1516  const dimensioned<Type>& su
1517 )
1518 {
1519  checkMethod(tA(), su, "+");
1520  tmp<faMatrix<Type>> tC(tA.ptr());
1521  tC.ref().source() -= su.value()*tC().psi().mesh().S();
1522  return tC;
1523 }
1524 
1525 
1526 template<class Type>
1527 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1528 (
1529  const dimensioned<Type>& su,
1530  const faMatrix<Type>& A
1531 )
1532 {
1533  checkMethod(A, su, "+");
1534  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1535  tC.ref().source() -= su.value()*A.psi().mesh().S();
1536  return tC;
1537 }
1538 
1539 
1540 template<class Type>
1541 Foam::tmp<Foam::faMatrix<Type>> Foam::operator+
1542 (
1543  const dimensioned<Type>& su,
1544  const tmp<faMatrix<Type>>& tA
1545 )
1546 {
1547  checkMethod(tA(), su, "+");
1548  tmp<faMatrix<Type>> tC(tA.ptr());
1549  tC.ref().source() -= su.value()*tC().psi().mesh().S();
1550  return tC;
1551 }
1552 
1553 
1554 template<class Type>
1555 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1556 (
1557  const faMatrix<Type>& A,
1558  const dimensioned<Type>& su
1559 )
1560 {
1561  checkMethod(A, su, "-");
1562  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1563  tC.ref().source() += su.value()*tC().psi().mesh().S();
1564  return tC;
1565 }
1566 
1567 
1568 template<class Type>
1569 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1570 (
1571  const tmp<faMatrix<Type>>& tA,
1572  const dimensioned<Type>& su
1573 )
1574 {
1575  checkMethod(tA(), su, "-");
1576  tmp<faMatrix<Type>> tC(tA.ptr());
1577  tC.ref().source() += su.value()*tC().psi().mesh().S();
1578  return tC;
1579 }
1580 
1581 
1582 template<class Type>
1583 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1584 (
1585  const dimensioned<Type>& su,
1586  const faMatrix<Type>& A
1587 )
1588 {
1589  checkMethod(A, su, "-");
1590  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1591  tC.ref().negate();
1592  tC.ref().source() -= su.value()*A.psi().mesh().S();
1593  return tC;
1594 }
1595 
1596 
1597 template<class Type>
1598 Foam::tmp<Foam::faMatrix<Type>> Foam::operator-
1599 (
1600  const dimensioned<Type>& su,
1601  const tmp<faMatrix<Type>>& tA
1602 )
1603 {
1604  checkMethod(tA(), su, "-");
1605  tmp<faMatrix<Type>> tC(tA.ptr());
1606  tC.ref().negate();
1607  tC.ref().source() -= su.value()*tC().psi().mesh().S();
1608  return tC;
1609 }
1610 
1611 
1612 template<class Type>
1613 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1614 (
1615  const faMatrix<Type>& A,
1616  const GeometricField<Type, faPatchField, areaMesh>& su
1617 )
1618 {
1619  checkMethod(A, su, "==");
1620  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1621  tC.ref().source() += su.mesh().S()*su.internalField();
1622  return tC;
1623 }
1624 
1625 
1626 template<class Type>
1627 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1628 (
1629  const tmp<faMatrix<Type>>& tA,
1630  const GeometricField<Type, faPatchField, areaMesh>& su
1631 )
1632 {
1633  checkMethod(tA(), su, "==");
1634  tmp<faMatrix<Type>> tC(tA.ptr());
1635  tC.ref().source() += su.mesh().S()*su.internalField();
1636  return tC;
1637 }
1638 
1639 
1640 template<class Type>
1641 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1642 (
1643  const faMatrix<Type>& A,
1644  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu
1645 )
1646 {
1647  checkMethod(A, tsu(), "==");
1648  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1649  tC.ref().source() += tsu().mesh().S()*tsu().internalField();
1650  tsu.clear();
1651  return tC;
1652 }
1653 
1654 
1655 template<class Type>
1656 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1657 (
1658  const tmp<faMatrix<Type>>& tA,
1659  const tmp<GeometricField<Type, faPatchField, areaMesh>>& tsu
1660 )
1661 {
1662  checkMethod(tA(), tsu(), "==");
1663  tmp<faMatrix<Type>> tC(tA.ptr());
1664  tC.ref().source() += tsu().mesh().S()*tsu().internalField();
1665  tsu.clear();
1666  return tC;
1667 }
1668 
1669 
1670 template<class Type>
1671 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1672 (
1673  const faMatrix<Type>& A,
1674  const dimensioned<Type>& su
1675 )
1676 {
1677  checkMethod(A, su, "==");
1678  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1679  tC.ref().source() += A.psi().mesh().S()*su.value();
1680  return tC;
1681 }
1682 
1683 
1684 template<class Type>
1685 Foam::tmp<Foam::faMatrix<Type>> Foam::operator==
1686 (
1687  const tmp<faMatrix<Type>>& tA,
1688  const dimensioned<Type>& su
1689 )
1690 {
1691  checkMethod(tA(), su, "==");
1692  tmp<faMatrix<Type>> tC(tA.ptr());
1693  tC.ref().source() += tC().psi().mesh().S()*su.value();
1694  return tC;
1695 }
1696 
1697 
1698 template<class Type>
1699 Foam::tmp<Foam::faMatrix<Type>> Foam::operator*
1700 (
1701  const areaScalarField& vsf,
1702  const faMatrix<Type>& A
1703 )
1704 {
1705  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1706  tC.ref() *= vsf;
1707  return tC;
1708 }
1709 
1710 
1711 template<class Type>
1712 Foam::tmp<Foam::faMatrix<Type>> Foam::operator*
1713 (
1714  const tmp<areaScalarField>& tvsf,
1715  const faMatrix<Type>& A
1716 )
1717 {
1718  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1719  tC.ref() *= tvsf;
1720  return tC;
1721 }
1722 
1723 
1724 template<class Type>
1725 Foam::tmp<Foam::faMatrix<Type>> Foam::operator*
1726 (
1727  const areaScalarField& vsf,
1728  const tmp<faMatrix<Type>>& tA
1729 )
1730 {
1731  tmp<faMatrix<Type>> tC(tA.ptr());
1732  tC.ref() *= vsf;
1733  return tC;
1734 }
1735 
1736 
1737 template<class Type>
1738 Foam::tmp<Foam::faMatrix<Type>> Foam::operator*
1739 (
1740  const tmp<areaScalarField>& tvsf,
1741  const tmp<faMatrix<Type>>& tA
1742 )
1743 {
1744  tmp<faMatrix<Type>> tC(tA.ptr());
1745  tC.ref() *= tvsf;
1746  return tC;
1747 }
1748 
1749 
1750 template<class Type>
1751 Foam::tmp<Foam::faMatrix<Type>> Foam::operator*
1752 (
1753  const dimensioned<scalar>& ds,
1754  const faMatrix<Type>& A
1755 )
1756 {
1757  tmp<faMatrix<Type>> tC(new faMatrix<Type>(A));
1758  tC.ref() *= ds;
1759  return tC;
1760 }
1761 
1762 
1763 template<class Type>
1764 Foam::tmp<Foam::faMatrix<Type>> Foam::operator*
1765 (
1766  const dimensioned<scalar>& ds,
1767  const tmp<faMatrix<Type>>& tA
1768 )
1769 {
1770  tmp<faMatrix<Type>> tC(tA.ptr());
1771  tC.ref() *= ds;
1772  return tC;
1773 }
1774 
1775 
1776 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
1777 
1778 template<class Type>
1779 Foam::Ostream& Foam::operator<<(Ostream& os, const faMatrix<Type>& fam)
1780 {
1781  os << static_cast<const lduMatrix&>(fam) << nl
1782  << fam.dimensions_ << nl
1783  << fam.source_ << nl
1784  << fam.internalCoeffs_ << nl
1785  << fam.boundaryCoeffs_ << endl;
1786 
1787  os.check(FUNCTION_NAME);
1788 
1789  return os;
1790 }
1791 
1792 
1793 // * * * * * * * * * * * * * * * * Solvers * * * * * * * * * * * * * * * * * //
1794 
1795 #include "faMatrixSolve.C"
1796 
1797 // ************************************************************************* //
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::faMatrix::operator+=
void operator+=(const faMatrix< Type > &)
Definition: faMatrix.C:768
Foam::lduMatrix::operator-=
void operator-=(const lduMatrix &)
Definition: lduMatrixOperations.C:223
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::faMatrix::dimensions
const dimensionSet & dimensions() const
Definition: faMatrix.H:226
Foam::faPatchField
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:50
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::faMatrix
A special matrix type and solver, designed for finite area solutions of scalar equations....
Definition: faMatrix.H:60
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::faMatrix::negate
void negate()
Definition: faMatrix.C:753
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.
Definition: zero.H:128
Foam::faMatrix::operator-=
void operator-=(const faMatrix< Type > &)
Definition: faMatrix.C:802
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
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::lduMatrix
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:83
Foam::faMatrix::faMatrix
faMatrix(const GeometricField< Type, faPatchField, areaMesh > &, const dimensionSet &)
Construct given a field to solve for.
Definition: faMatrix.C:181
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:376
Foam::HashTable::insert
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:168
A
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
Foam::faMatrix::flux
tmp< GeometricField< Type, faePatchField, edgeMesh > > flux() const
Return the face-flux field from the matrix.
Definition: faMatrix.C:630
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::stringOps::lower
string lower(const std::string &str)
Return string transformed with std::tolower on each character.
Definition: stringOps.C:1199
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:65
faMatrixSolve.C
Finite-Area matrix basic solvers.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
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
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::faMatrix::operator=
void operator=(const faMatrix< Type > &)
Definition: faMatrix.C:712
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::faPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: faPatchField.H:322
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:60
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
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:356
edgeFields.H
calculatedFaPatchFields.H
Foam::primitiveMesh::faceEdges
const labelListList & faceEdges() const
Definition: primitiveMeshEdges.C:528
Foam::cmptAv
tmp< DimensionedField< typename DimensionedField< Type, GeoMesh >::cmptType, GeoMesh >> cmptAv(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:246
Foam::stringOps::upper
string upper(const std::string &str)
Return string transformed with std::toupper on each character.
Definition: stringOps.C:1219
Foam::solve
SolverPerformance< Type > solve(faMatrix< Type > &, Istream &)
Solve returning the solution statistics given convergence tolerance.
Foam::faMatrix::relax
void relax()
Relax matrix (for steady-state solution).
Definition: faMatrix.C:534
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
areaFields.H
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::fvMesh::neighbour
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:382
Foam::faMatrix::H
tmp< GeometricField< Type, faPatchField, areaMesh > > H() const
Return the H operation source.
Definition: faMatrix.C:586
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:43
Foam::lduMatrix::negate
void negate()
Definition: lduMatrixOperations.C:125
Foam::tmp::ptr
T * ptr() const
Definition: tmpI.H:296
Foam::areaScalarField
GeometricField< scalar, faPatchField, areaMesh > areaScalarField
Definition: areaFieldsFwd.H:53
Foam::lduMatrix::H
tmp< Field< Type > > H(const Field< Type > &) const
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::fvMesh::owner
const labelUList & owner() const
Internal face owner. Note bypassing virtual mechanism so.
Definition: fvMesh.H:376
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:735
zeroGradientFaPatchFields.H
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:909
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:438
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:589
Foam::faMatrix::setReference
void setReference(const label facei, const Type &value)
Set reference level for solution.
Definition: faMatrix.C:427
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::lduMatrix::operator=
void operator=(const lduMatrix &)
Definition: lduMatrixOperations.C:91
Foam::faMatrix::psi
const GeometricField< Type, faPatchField, areaMesh > & psi() const
Definition: faMatrix.H:221
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:752
Foam::List< labelList >
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
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::UList< label >
D
const dimensionedScalar & D
Definition: solveBulkSurfactant.H:4
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::faMatrix::~faMatrix
virtual ~faMatrix()
Destructor.
Definition: faMatrix.C:319
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:77
Foam::faMatrix::D
tmp< scalarField > D() const
Return the matrix diagonal.
Definition: faMatrix.C:550
Foam::faMatrix::A
tmp< areaScalarField > A() const
Return the central coefficient.
Definition: faMatrix.C:559
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:74
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
fam
Calculate the matrix for the second temporal derivative.
Foam::labelUList
UList< label > labelUList
A UList of labels.
Definition: UList.H:79
Foam::faMatrix::clone
tmp< faMatrix< Type > > clone() const
Clone.
Definition: faMatrix.C:306
Foam::dimensioned::dimensions
const dimensionSet & dimensions() const
Return const reference to dimensions.
Definition: dimensionedType.C:390
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
psi
const volScalarField & psi
Definition: createFieldRefs.H:1
Foam::SolverPerformance
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics.
Definition: SolverPerformance.H:51
Foam::faMatrix::setValues
void setValues(const labelUList &faces, const UList< Type > &values)
Set solution in given cells and eliminate corresponding.
Definition: faMatrix.C:333
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
relax
UEqn relax()