multiphaseInterSystem.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) 2017-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "multiphaseInterSystem.H"
29 #include "surfaceTensionModel.H"
30 #include "porousModel.H"
31 
32 #include "HashPtrTable.H"
33 
34 #include "surfaceInterpolate.H"
35 #include "fvcGrad.H"
36 #include "fvcSnGrad.H"
37 #include "fvcDiv.H"
38 #include "fvMatrix.H"
39 
44 
45 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49  defineTypeNameAndDebug(multiphaseInterSystem, 0);
50 }
51 
52 /* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
53 
54 const Foam::word
56 
57 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
58 
60 {
61  mu_ = mu()();
62 }
63 
64 
67 (
68  const wordList& phaseNames
69 ) const
70 {
71  phaseModelTable phaseModels;
72 
73  for (const word& phaseName : phaseNames)
74  {
75  phaseModels.insert
76  (
77  phaseName,
79  (
80  *this,
81  phaseName
82  )
83  );
84  }
85 
86  return phaseModels;
87 }
88 
89 
91 (
92  const phaseModelTable& phaseModels
93 ) const
94 {
95  auto iter = phaseModels.cbegin();
96 
97  auto tmpPhi = tmp<surfaceScalarField>::New
98  (
99  "phi",
100  fvc::interpolate(iter()()) * iter()->phi()
101  );
102 
103  for (++iter; iter != phaseModels.cend(); ++iter)
104  {
105  tmpPhi.ref() += fvc::interpolate(iter()()) * iter()->phi();
106  }
107 
108  return tmpPhi;
109 }
110 
111 
112 void Foam::multiphaseInterSystem::generatePairs(const dictTable& modelDicts)
113 {
114  forAllConstIters(modelDicts, iter)
115  {
116  const phasePairKey& key = iter.key();
117 
118  // pair already exists
119  if (phasePairs_.found(key))
120  {
121  // do nothing ...
122  }
123  else if (key.ordered())
124  {
125  // New ordered pair
126  phasePairs_.insert
127  (
128  key,
129  autoPtr<phasePair>
130  (
131  new orderedPhasePair
132  (
133  phaseModels_[key.first()],
134  phaseModels_[key.second()]
135  )
136  )
137  );
138  }
139  else
140  {
141  // New unordered pair
142  phasePairs_.insert
143  (
144  key,
145  autoPtr<phasePair>
146  (
147  new phasePair
148  (
149  phaseModels_[key.first()],
150  phaseModels_[key.second()]
151  )
152  )
153  );
154  }
155  }
156 }
157 
158 
160 {
161  forAllConstIters(phaseModels_, phaseIter1)
162  {
163  forAllConstIters(phaseModels_, phaseIter2)
164  {
165  if (phaseIter1()->name() != phaseIter2()->name())
166  {
167  phasePairKey key
168  (
169  phaseIter1()->name(),
170  phaseIter2()->name(),
171  true
172  );
173 
174  phasePairKey keyInverse
175  (
176  phaseIter2()->name(),
177  phaseIter1()->name(),
178  true
179  );
180 
181  if
182  (
183  !totalPhasePairs_.found(key)
184  && !totalPhasePairs_.found(keyInverse)
185  )
186  {
187  totalPhasePairs_.set
188  (
189  key,
190  autoPtr<phasePair>
191  (
192  new phasePair
193  (
194  phaseModels_[key.first()],
195  phaseModels_[key.second()]
196  )
197  )
198  );
199  }
200  }
201  }
202  }
203 }
204 
205 
206 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
207 
209 (
210  const fvMesh& mesh
211 )
212 :
213  basicThermo(mesh, word::null, phasePropertiesName),
214  mesh_(mesh),
215  mu_
216  (
217  IOobject
218  (
219  "mu",
220  mesh_.time().timeName(),
221  mesh_
222  ),
223  mesh_,
225  ),
226  phaseNames_(get<wordList>("phases")),
227  phi_
228  (
229  IOobject
230  (
231  "phi",
232  mesh_.time().timeName(),
233  mesh_,
234  IOobject::READ_IF_PRESENT,
235  IOobject::AUTO_WRITE
236  ),
237  mesh_,
239  ),
240  rhoPhi_
241  (
242  IOobject
243  (
244  "rhoPhi",
245  mesh_.time().timeName(),
246  mesh_
247  ),
248  mesh_,
250  ),
251  phaseModels_(generatePhaseModels(phaseNames_)),
252  phasePairs_(),
253  totalPhasePairs_(),
254  Prt_
255  (
256  dimensionedScalar::getOrAddToDict
257  (
258  "Prt", *this, 1.0
259  )
260  )
261 {
263  phi_.setOriented();
264 
265  // sub models
266  if (found("surfaceTension"))
267  {
269  (
270  "surfaceTension",
272  );
273  }
274  if (found("interfacePorous"))
275  {
277  (
278  "interfacePorous",
279  mesh_,
281  );
282  }
283 
284  // Total phase pair
286 
287  // Update mu_
288  calcMu();
289 }
290 
291 
292 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
293 
295 {}
296 
297 
298 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
299 
301 (
302  const volScalarField& p,
303  const volScalarField& T
304 ) const
305 {
307  return nullptr;
308 }
309 
310 
312 (
313  const scalarField& p,
314  const scalarField& T,
315  const labelList& cells
316 ) const
317 {
319  return nullptr;
320 }
321 
322 
324 (
325  const scalarField& p,
326  const scalarField& T,
327  const label patchI
328 ) const
329 {
331  return nullptr;
332 }
333 
334 
336 {
337  auto iter = phaseModels_.cbegin();
338 
339  tmp<volScalarField> tAlphaHc
340  (
341  iter()() * iter()->hc()
342  );
343 
344  for (++iter; iter != phaseModels_.cend(); ++iter)
345  {
346  tAlphaHc.ref() += iter()() * iter()->hc();
347  }
348 
349  return tAlphaHc;
350 }
351 
352 
354 (
355  const scalarField& e,
356  const scalarField& p,
357  const scalarField& T0,
358  const labelList& cells
359 ) const
360 {
362  return nullptr;
363 }
364 
365 
367 (
368  const scalarField& e,
369  const scalarField& p,
370  const scalarField& T0,
371  const label patchI
372 ) const
373 {
375  return nullptr;
376 }
377 
378 
380 {
381  auto iter = phaseModels_.cbegin();
382 
383  tmp<volScalarField> tmpRho
384  (
385  iter()() * iter()->rho()
386  );
387 
388  for (++iter; iter != phaseModels_.cend(); ++iter)
389  {
390  tmpRho.ref() += iter()() * iter()->rho();
391  }
392 
393  return tmpRho;
394 }
395 
396 
398 (
399  const label patchI
400 ) const
401 {
402  auto iter = phaseModels_.cbegin();
403 
404  tmp<scalarField> tmpRho
405  (
406  iter()().boundaryField()[patchI]
407  * iter()->rho()().boundaryField()[patchI]
408  );
409 
410  for (++iter; iter != phaseModels_.cend(); ++iter)
411  {
412  tmpRho.ref() +=
413  (
414  iter()().boundaryField()[patchI]
415  * iter()->rho()().boundaryField()[patchI]
416  );
417  }
418 
419  return tmpRho;
420 }
421 
422 
424 {
425  auto iter = phaseModels_.cbegin();
426 
427  tmp<volScalarField> tmpCp
428  (
429  iter()() * iter()->Cp()
430  );
431 
432  for (++iter; iter != phaseModels_.cend(); ++iter)
433  {
434  tmpCp.ref() += iter()() * iter()->Cp();
435  }
436 
437  return tmpCp;
438 }
439 
440 
442 (
443  const scalarField& p,
444  const scalarField& T,
445  const label patchI
446 ) const
447 {
448  auto iter = phaseModels_.cbegin();
449 
450  tmp<scalarField> tmpCp
451  (
452  iter()() * iter()->Cp(p, T, patchI)
453  );
454 
455  for (++iter; iter != phaseModels_.cend(); ++iter)
456  {
457  tmpCp.ref() += iter()() * iter()->Cp(p, T, patchI);
458  }
459 
460  return tmpCp;
461 }
462 
463 
465 {
466  auto iter = phaseModels_.cbegin();
467 
468  tmp<volScalarField> tmpCv
469  (
470  iter()() * iter()->Cv()
471  );
472 
473  for (++iter; iter != phaseModels_.cend(); ++iter)
474  {
475  tmpCv.ref() += iter()() * iter()->Cv();
476  }
477 
478  return tmpCv;
479 }
480 
481 
483 (
484  const scalarField& p,
485  const scalarField& T,
486  const label patchI
487 ) const
488 {
489  auto iter = phaseModels_.cbegin();
490 
491  tmp<scalarField> tmpCv
492  (
493  iter()() * iter()->Cv(p, T, patchI)
494  );
495 
496  for (++iter; iter != phaseModels_.cend(); ++iter)
497  {
498  tmpCv.ref() += iter()() * iter()->Cv(p, T, patchI);
499  }
500 
501  return tmpCv;
502 }
503 
504 
506 (
507  const scalarField& p,
508  const scalarField& T,
509  const labelList& cells
510 ) const
511 {
513  return nullptr;
514 }
515 
516 
518 {
519  auto iter = phaseModels_.cbegin();
520 
521  tmp<volScalarField> tmpCp
522  (
523  iter()() * iter()->Cp()
524  );
525 
526  tmp<volScalarField> tmpCv
527  (
528  iter()() * iter()->Cv()
529  );
530 
531  for (++iter; iter != phaseModels_.cend(); ++iter)
532  {
533  tmpCp.ref() += iter()() * iter()->Cp();
534  tmpCv.ref() += iter()() * iter()->Cv();
535  }
536 
537  return (tmpCp/tmpCv);
538 }
539 
540 
542 (
543  const scalarField& p,
544  const scalarField& T,
545  const label patchI
546 ) const
547 {
548  return
549  (
550  gamma()().boundaryField()[patchI]
551  );
552 }
553 
554 
556 {
557  auto iter = phaseModels_.cbegin();
558 
559  tmp<volScalarField> tmpCpv
560  (
561  iter()() * iter()->Cpv()
562  );
563 
564  for (++iter; iter != phaseModels_.cend(); ++iter)
565  {
566  tmpCpv.ref() += iter()() * iter()->Cpv();
567  }
568 
569  return tmpCpv;
570 }
571 
572 
574 (
575  const scalarField& p,
576  const scalarField& T,
577  const label patchI
578 ) const
579 {
580  auto iter = phaseModels_.cbegin();
581 
582  tmp<scalarField> tmpCpv
583  (
584  iter()() * iter()->Cpv(p, T, patchI)
585  );
586 
587  for (++iter; iter != phaseModels_.cend(); ++iter)
588  {
589  tmpCpv.ref() += iter()() * iter()->Cpv(p, T, patchI);
590  }
591 
592  return tmpCpv;
593 }
594 
595 
597 {
598  auto iter = phaseModels_.cbegin();
599 
600  tmp<volScalarField> tmpCpByCpv
601  (
602  iter()() * iter()->CpByCpv()
603  );
604 
605  for (++iter; iter != phaseModels_.cend(); ++iter)
606  {
607  tmpCpByCpv.ref() += iter()() * iter()->CpByCpv();
608  }
609 
610  return tmpCpByCpv;
611 }
612 
613 
615 (
616  const scalarField& p,
617  const scalarField& T,
618  const label patchI
619 ) const
620 {
621  auto iter = phaseModels_.cbegin();
622 
623  tmp<scalarField> tmpCpv
624  (
625  iter()().boundaryField()[patchI]
626  * iter()->CpByCpv(p, T, patchI)
627  );
628 
629  for (++iter; iter != phaseModels_.cend(); ++iter)
630  {
631  tmpCpv.ref() +=
632  (
633  iter()().boundaryField()[patchI]
634  * iter()->CpByCpv(p, T, patchI)
635  );
636  }
637 
638  return tmpCpv;
639 }
640 
641 
643 {
645  return nullptr;
646 }
647 
648 
650 {
651  auto iter = phaseModels_.cbegin();
652 
653  tmp<volScalarField> tmpkappa
654  (
655  iter()() * iter()->kappa()
656  );
657 
658  for (++iter; iter != phaseModels_.cend(); ++iter)
659  {
660  tmpkappa.ref() += iter()() * iter()->kappa();
661  }
662 
663  return tmpkappa;
664 }
665 
666 
668 (
669  const label patchI
670 ) const
671 {
672  auto iter = phaseModels_.cbegin();
673 
674  tmp<scalarField> tmpKappa
675  (
676  iter()().boundaryField()[patchI]
677  * iter()->kappa(patchI)
678  );
679 
680  for (++iter; iter != phaseModels_.cend(); ++iter)
681  {
682  tmpKappa.ref() +=
683  (
684  iter()().boundaryField()[patchI]
685  * iter()->kappa(patchI)
686  );
687  }
688 
689  return tmpKappa;
690 }
691 
692 
694 {
695  phaseModelTable::const_iterator phaseModelIter = phaseModels_.begin();
696 
697  tmp<volScalarField> talphaEff
698  (
699  phaseModelIter()()*phaseModelIter()->alphahe()
700  );
701 
702  for (; phaseModelIter != phaseModels_.end(); ++phaseModelIter)
703  {
704  talphaEff.ref() += phaseModelIter()()*phaseModelIter()->alphahe();
705  }
706 
707  return talphaEff;
708 }
709 
710 
712 (
713  const label patchi
714 ) const
715 {
716  phaseModelTable::const_iterator phaseModelIter = phaseModels_.begin();
717 
718  tmp<scalarField> talphaEff
719  (
720  phaseModelIter()().boundaryField()[patchi]
721  *phaseModelIter()->alphahe(patchi)
722  );
723 
724  for (; phaseModelIter != phaseModels_.end(); ++phaseModelIter)
725  {
726  talphaEff.ref() +=
727  phaseModelIter()().boundaryField()[patchi]
728  *phaseModelIter()->alphahe(patchi);
729  }
730 
731  return talphaEff;
732 }
733 
734 
736 (
737  const volScalarField& kappat
738 ) const
739 {
741  kappaEff.ref().rename("kappaEff");
742  return kappaEff;
743 }
744 
745 
747 (
748  const scalarField& kappat,
749  const label patchI
750 ) const
751 {
752  return kappa(patchI) + kappat;
753 }
754 
755 
757 (
758  const volScalarField& alphat
759 ) const
760 {
761  auto iter = phaseModels_.cbegin();
762 
763  tmp<volScalarField> tmpAlpha
764  (
765  iter()() * iter()->alpha()
766  );
767 
768  for (++iter; iter != phaseModels_.cend(); ++iter)
769  {
770  tmpAlpha.ref() += iter()() * iter()->alpha();
771  }
772 
773  tmpAlpha.ref() += alphat;
774 
775  return tmpAlpha;
776 }
777 
778 
780 (
781  const scalarField& alphat,
782  const label patchI
783 ) const
784 {
785  auto iter = phaseModels_.cbegin();
786 
787  tmp<scalarField> tmpAlpha
788  (
789  iter()().boundaryField()[patchI]
790  * iter()->alpha(patchI)
791  );
792 
793  for (++iter; iter != phaseModels_.cend(); ++iter)
794  {
795  tmpAlpha.ref() +=
796  (
797  iter()().boundaryField()[patchI]
798  * iter()->alpha(patchI)
799  );
800  }
802  tmpAlpha.ref() += alphat;
803 
804  return tmpAlpha;
805 }
806 
809 {
810  return Prt_;
811 }
812 
813 
815 {
816  auto iter = phaseModels_.cbegin();
817 
818  tmp<volScalarField> tmpMu
819  (
820  iter()() * iter()->mu()
821  );
822 
823  for (++iter; iter != phaseModels_.cend(); ++iter)
824  {
825  tmpMu.ref() += iter()() * iter()->mu();
826  }
827 
828  return tmpMu;
829 }
830 
831 
833 (
834  const label patchI
835 ) const
836 {
837  auto iter = phaseModels_.cbegin();
838 
839  tmp<scalarField> tmpMu
840  (
841  iter()().boundaryField()[patchI]
842  * iter()->mu(patchI)
843  );
844 
845  for (++iter; iter != phaseModels_.cend(); ++iter)
846  {
847  tmpMu.ref() +=
848  (
849  iter()().boundaryField()[patchI]
850  * iter()->mu(patchI)
851  );
852  }
853 
854  return tmpMu;
855 }
856 
857 
859 {
860  auto iter = phaseModels_.cbegin();
861 
862  tmp<volScalarField> tmpNu
863  (
864  iter()() * iter()->nu()
865  );
866 
867  for (++iter; iter != phaseModels_.cend(); ++iter)
868  {
869  tmpNu.ref() += iter()() * iter()->nu();
870  }
871 
872  return tmpNu;
873 }
874 
875 
877 (
878  const label patchI
879 ) const
880 {
881  auto iter = phaseModels_.cbegin();
882 
883  tmp<scalarField> tmpNu
884  (
885  iter()().boundaryField()[patchI]
886  * iter()->nu(patchI)
887  );
888 
889  for (++iter; iter != phaseModels_.cend(); ++iter)
890  {
891  tmpNu.ref() +=
892  (
893  iter()().boundaryField()[patchI]
894  * iter()->nu(patchI)
895  );
896  }
897 
898  return tmpNu;
899 }
900 
903 {
904  return turb_->mut();
905 }
906 
909 {
910  return turb_->muEff();
911 }
912 
915 {
916  return turb_->nut();
917 }
918 
921 {
922  return turb_->nuEff();
923 }
924 
925 
927 {
929  (
930  this->kappa() + this->Cp()*turb_->mut()/Prt_
931  );
932 
934 }
935 
936 
938 Foam::multiphaseInterSystem::kappaEff(const label patchi) const
939 {
940  const scalarField Cp(this->Cp()().boundaryField()[patchi]);
941  const scalarField kappaEffp
942  (
943  this->kappa(patchi) + Cp*turb_->mut(patchi)/Prt_.value()
944  );
945 
946  return tmp<scalarField>::New(kappaEffp);
947 }
948 
949 
951 {
952  return this->alpha() + turb_->mut()/Prt_;
953 }
954 
955 
957 Foam::multiphaseInterSystem::alphaEff(const label patchi) const
958 {
959  return (this->alpha(patchi) + turb_->mut(patchi))/Prt_.value();
960 }
961 
964 {
965  return phi_;
966 }
967 
970 {
971  return phi_;
972 }
973 
976 {
977  return rhoPhi_;
978 }
979 
982 {
983  return rhoPhi_;
984 }
985 
986 
988 {
989  forAllIters(phaseModels_, iter)
990  {
991  iter()->correct();
992  }
993 
994  calcMu();
995 }
996 
997 
999 {
1000  forAllIters(phaseModels_, iter)
1001  {
1002  iter()->correctTurbulence();
1003  }
1004 }
1005 
1006 
1009 {
1010  return phaseModels_;
1011 }
1012 
1013 
1016 {
1017  return phaseModels_;
1018 }
1019 
1020 
1023 {
1024  return totalPhasePairs_;
1025 }
1026 
1027 
1030 {
1031  return totalPhasePairs_;
1032 }
1033 
1034 
1036 {
1037  forAllConstIters(phaseModels_, iter)
1038  {
1039  if (!iter()->thermo().incompressible())
1040  {
1041  return false;
1042  }
1043  }
1044 
1045  return true;
1046 }
1047 
1049 bool Foam::multiphaseInterSystem::incompressible(const word phaseName) const
1050 {
1051  return phaseModels_[phaseName]->thermo().incompressible();
1052 }
1053 
1054 
1056 {
1057  forAllConstIters(phaseModels_, iter)
1058  {
1059  if (!iter()->thermo().isochoric())
1060  {
1061  return false;
1062  }
1063  }
1064 
1065  return true;
1066 }
1067 
1068 
1070 {
1071  return mesh_;
1072 }
1073 
1074 
1077 {
1078  auto tstf = tmp<surfaceScalarField>::New
1079  (
1080  IOobject
1081  (
1082  "surfaceTensionForce",
1083  mesh_.time().timeName(),
1084  mesh_
1085  ),
1086  mesh_,
1087  dimensionedScalar({1, -2, -2, 0, 0, 0}, Zero)
1088  );
1089 
1090  auto& stf = tstf.ref();
1091  stf.setOriented();
1092 
1093  if (surfaceTensionModels_.size())
1094  {
1095  forAllConstIters(phaseModels_, iter1)
1096  {
1097  const volScalarField& alpha1 = iter1()();
1098 
1099  auto iter2 = iter1;
1100 
1101  for (++iter2; iter2 != phaseModels_.cend(); ++iter2)
1102  {
1103  const volScalarField& alpha2 = iter2()();
1104 
1105  stf +=
1107  (
1108  surfaceTensionCoeff
1109  (
1110  phasePairKey(iter1()->name(), iter2()->name())
1111  )
1112  )
1114  (
1117  );
1118  }
1119  }
1120  }
1121 
1122  return tstf;
1123 }
1124 
1125 
1127 {
1128  auto tstf = tmp<volVectorField>::New
1129  (
1130  IOobject
1131  (
1132  "U",
1133  mesh_.time().timeName(),
1134  mesh_
1135  ),
1136  mesh_,
1138  );
1139 
1140  auto& stf = tstf.ref();
1141 
1142  forAllConstIters(phaseModels_, iter)
1143  {
1144  stf += iter()() * iter()->U();
1145  }
1146 
1147  return tstf;
1148 }
1149 
1150 
1153 {
1154  return surfaceTensionModels_[key]->sigma();
1155 }
1156 
1157 
1159 (
1160  const word& key
1161 ) const
1162 {
1163  return 1.0/(phaseModels_[key]->thermo().rho());
1164 }
1165 
1166 
1168 {
1169  const scalarField& Vc = mesh_.V();
1170  scalarField& Udiag = UEqn.diag();
1171 
1172  forAllConstIters(phaseModels_, iteri)
1173  {
1174  const multiphaseInter::phaseModel& phasei = iteri()();
1175 
1176  auto iterk = iteri;
1177 
1178  for (++iterk; iterk != phaseModels_.cend(); ++iterk)
1179  {
1180  if (iteri()().name() != iterk()().name())
1181  {
1182  const multiphaseInter::phaseModel& phasek = iterk()();
1183 
1184  // Phase i and k
1185  const phasePairKey keyik
1186  (
1187  phasei.name(),
1188  phasek.name(),
1189  false
1190  );
1191 
1192  if (interfacePorousModelTable_.found(keyik))
1193  {
1194  autoPtr<porousModel>& interfacePtr =
1195  interfacePorousModelTable_[keyik];
1196 
1197  Udiag += Vc*interfacePtr->S();
1198  }
1199  }
1200  }
1201  }
1202 }
1203 
1204 
1206 (
1207  const volScalarField& alpha1,
1208  const volScalarField& alpha2
1209 ) const
1210 {
1211  tmp<surfaceVectorField> tnHatfv = nHatfv(alpha1, alpha2);
1213  // Simple expression for curvature
1214  return -fvc::div(tnHatfv.ref() & mesh_.Sf());
1215 }
1216 
1217 
1219 (
1220  const volScalarField& alpha1,
1221  const volScalarField& alpha2
1222 ) const
1223 {
1224  return
1225  (
1226  pos(alpha1 - 0.1)*pos(0.9 - alpha1)
1227  *pos(alpha2 - 0.1)*pos(0.9 - alpha2)
1228  );
1229 }
1230 
1231 
1234 {
1235  auto tnearInt = tmp<volScalarField>::New
1236  (
1237  IOobject
1238  (
1239  "nearInterface",
1240  mesh_.time().timeName(),
1241  mesh_
1242  ),
1243  mesh_,
1245  );
1246 
1247  auto& nearInt = tnearInt.ref();
1248 
1249  forAllConstIters(phaseModels_, iter1)
1250  {
1251  const volScalarField& alpha1 = iter1()();
1252 
1253  auto iter2 = iter1;
1254 
1255  for (++iter2; iter2 != phaseModels_.cend(); ++iter2)
1256  {
1257  const volScalarField& alpha2 = iter2()();
1258 
1259  nearInt +=
1260  (
1261  pos(alpha1 - 0.1)*pos(0.9 - alpha1)
1262  *pos(alpha2 - 0.1)*pos(0.9 - alpha2)
1263  );
1264  }
1265  }
1266 
1267  return tnearInt;
1268 }
1269 
1270 
1272 (
1273  const volScalarField& alpha1,
1274  const volScalarField& alpha2
1275 ) const
1276 {
1277  const volScalarField alpha1m
1278  (
1279  clamp(alpha1, zero_one{})
1280  );
1281 
1282  const volScalarField alpha2m
1283  (
1284  clamp(alpha2, zero_one{})
1285  );
1286 
1287  const volVectorField gradAlphaf
1288  (
1289  alpha2m*(fvc::grad(alpha1m))
1290  - alpha1m*(fvc::grad(alpha2m))
1291  );
1292 
1293  const dimensionedScalar deltaN
1294  (
1295  "deltaN",
1296  1e-8/cbrt(average(mesh_.V()))
1297  );
1299  // Face unit interface normal
1300  return gradAlphaf/(mag(gradAlphaf) + deltaN);
1301 }
1302 
1303 
1305 (
1306  const volScalarField& alpha1,
1307  const volScalarField& alpha2
1308 ) const
1309 {
1310 
1311  const volScalarField alpha1b
1312  (
1313  clamp(alpha1, zero_one{})
1314  );
1315 
1316  const volScalarField alpha2b
1317  (
1318  clamp(alpha2, zero_one{})
1319  );
1320 
1321  surfaceVectorField gradAlphaf
1322  (
1323  fvc::interpolate(alpha2b)*fvc::interpolate(fvc::grad(alpha1b))
1324  - fvc::interpolate(alpha1b)*fvc::interpolate(fvc::grad(alpha2b))
1325  );
1326 
1327  const dimensionedScalar deltaN
1328  (
1329  "deltaN",
1330  1e-8/cbrt(average(mesh_.V()))
1331  );
1333  // Face unit interface normal
1334  return gradAlphaf/(mag(gradAlphaf) + deltaN);
1335 }
1336 
1337 
1339 (
1340  const volScalarField& alpha1,
1341  const volScalarField& alpha2
1342 ) const
1343 {
1344  // Face unit interface normal flux
1345  return nHatfv(alpha1, alpha2) & mesh_.Sf();
1346 }
1347 
1348 
1350 {
1351  if (regIOobject::read())
1352  {
1353  return true;
1354  }
1355 
1356  return false;
1357 }
1358 
1359 
1360 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
virtual tmp< volScalarField > coeffs(const word &key) const
Return coefficients (1/rho)
void generatePairsAndSubModels(const word &modelName, HashTable< autoPtr< modelType >, phasePairKey, phasePairKey::hash > &models)
Generate pairs and sub-model tables.
const fvMesh & mesh() const
Return mesh.
virtual tmp< volScalarField > Cv() const
Return Cv of the mixture.
void generatePairs(const dictTable &modelDicts)
Generate pairs.
const phaseModelTable & phases() const
Constant access the phases.
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:47
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &f1)
virtual bool incompressible() const
Return true if the equation of state is incompressible for all.
const surfaceScalarField & phi() const
Constant access to the total flux.
virtual tmp< volScalarField > hc() const
Chemical enthalpy of the mixture [J/kg].
label phasei
Definition: pEqn.H:27
static const word phasePropertiesName
Default name of the phase properties dictionary.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
virtual bool read()
Read object.
multiphaseInterSystem(const fvMesh &mesh)
Construct from fvMesh.
virtual bool read()
Read base phaseProperties dictionary.
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition: tmpI.H:235
static autoPtr< phaseModel > New(const multiphaseInterSystem &fluid, const word &phaseName)
Definition: phaseModel.C:65
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:42
virtual tmp< volScalarField > mu() const
Dynamic viscosity of mixture [kg/m/s].
virtual volScalarField & he()
Return access to the internal energy field [J/Kg].
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
virtual tmp< scalarField > rhoEoS(const scalarField &p, const scalarField &T, const labelList &cells) const
Density from pressure and temperature.
const dimensionSet dimViscosity
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
virtual tmp< volScalarField > alphahe() const
Thermal diffusivity for energy of mixture [kg/m/s].
tmp< volScalarField > alphaEff() const
Effective thermal turbulent diffusivity of mixture [kg/m/s].
Calculate the snGrad of the given volField.
const word & name() const
The name of this phase.
Definition: phaseModel.H:122
surfaceTensionModelTable surfaceTensionModels_
Surface tension models.
const volScalarField & alpha2
const volScalarField & Cv
Definition: EEqn.H:8
const dimensionSet dimless
Dimensionless.
virtual tmp< volScalarField > gamma() const
Gamma = Cp/Cv [].
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:82
kappaEff
Definition: TEqn.H:10
CGAL::Exact_predicates_exact_constructions_kernel K
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
tmp< volScalarField > kappaEff() const
Effective thermal turbulent diffusivity for temperature.
virtual void correct()
Correct the mixture thermos.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Definition: dictionaryI.H:104
tmp< volScalarField > K(const volScalarField &alpha1, const volScalarField &alpha2) const
Interface curvature.
virtual tmp< volScalarField > S() const =0
Momentum source.
virtual ~multiphaseInterSystem()
Destructor.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:152
psiReactionThermo & thermo
Definition: createFields.H:28
word timeName
Definition: getTimeIndex.H:3
dimensionedScalar pos(const dimensionedScalar &ds)
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
const fvMesh & mesh_
Reference to the mesh.
virtual void correctTurbulence()
Correct the turbulence.
const dimensionedScalar & Prt() const
Return Prandt number.
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
surfaceScalarField phi_
Mixture total volumetric flux.
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const cellShapeList & cells
Calculate the gradient of the given field.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual tmp< volScalarField > surfaceTensionCoeff(const phasePairKey &key) const
Return the surface tension coefficient.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar cbrt(const dimensionedScalar &ds)
void setOriented(bool on=true) noexcept
Set the oriented flag: on/off.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:336
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:206
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:64
const phasePairTable & totalPhasePairs() const
Constant access the total phase pairs.
surfaceScalarField rhoPhi_
Mixture total mass flux.
Calculate the divergence of the given field.
An ordered or unorder pair of phase names. Typically specified as follows.
Definition: phasePairKey.H:61
void calcMu()
Calculate and return the laminar viscosity.
tmp< surfaceScalarField > generatePhi(const HashTable< autoPtr< multiphaseInter::phaseModel >> &phaseModels) const
Generate the mixture flux.
const volScalarField & Cp
Definition: EEqn.H:7
virtual tmp< volScalarField > kappa() const
Thermal diffusivity for temperature of mixture [J/m/s/K].
defineTypeNameAndDebug(combustionModel, 0)
virtual tmp< volScalarField > W() const
Molecular weight [kg/kmol] of the mixture.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
tmp< volScalarField > nearInterface() const
Near Interface of alpha&#39;n.
interfacePorousModelTable interfacePorousModelTable_
Interface porous models.
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
const dimensionSet dimDensity
HashTable< autoPtr< multiphaseInter::phaseModel > > generatePhaseModels(const wordList &names) const
Generate the phases.
Represents 0/1 range or concept. Used for tagged dispatch or clamping.
Definition: pTraits.H:65
void generatePairsTable()
Generate pair table.
const dimensionedScalar mu
Atomic mass unit.
List< word > wordList
List of word.
Definition: fileName.H:59
tmp< surfaceVectorField > nHatfv(const volScalarField &alpha1, const volScalarField &alpha2) const
Interface normal surface vector.
virtual tmp< volScalarField > nu() const
Kinematic viscosity of mixture [m^2/s].
tmp< volScalarField > mut() const
Return the turbulent dynamic viscosity.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
fvVectorMatrix & UEqn
Definition: UEqn.H:13
tmp< volVectorField > nVolHatfv(const volScalarField &alpha1, const volScalarField &alpha2) const
Interface normal volField vector.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
tmp< volScalarField > nuEff() const
Return the effective kinematic viscosity.
tmp< volScalarField > nut() const
Return the turbulent kinematic viscosity.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
tmp< surfaceScalarField > nHatf(const volScalarField &alpha1, const volScalarField &alpha2) const
Interface normal surface vector.
virtual tmp< volScalarField > Cp() const
Return Cp of the mixture.
tmp< surfaceScalarField > surfaceTensionForce() const
Calculate surface tension of the mixture.
virtual tmp< volScalarField > Cpv() const
Heat capacity at constant pressure/volume [J/kg/K].
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const scalar gamma
Definition: EEqn.H:9
volScalarField mu_
Dynamic viscocity.
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
List< label > labelList
A List of labels.
Definition: List.H:62
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
scalarField & diag()
Definition: lduMatrix.C:197
const surfaceScalarField & rhoPhi() const
Constant access to the mixture mass flux.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
tmp< volVectorField > U() const
Mixture U.
volScalarField & nu
virtual tmp< scalarField > THE(const scalarField &h, const scalarField &p, const scalarField &T0, const labelList &cells) const
Temperature from enthalpy/internal energy for cell-set.
virtual tmp< volScalarField > CpByCpv() const
Heat capacity ratio [].
void addInterfacePorosity(fvVectorMatrix &UEqn)
Add interface porosity on phasePair.
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:40
virtual tmp< volScalarField > rho() const
Return the mixture density.
Namespace for OpenFOAM.
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
dimensionSet clamp(const dimensionSet &a, const dimensionSet &range)
Definition: dimensionSet.C:271
tmp< volScalarField > muEff() const
Return the effective dynamic viscosity.
scalar T0
Definition: createFields.H:22
virtual bool isochoric() const
Return true if the equation of state is isochoric for all phasses.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127
const dimensionSet dimVelocity
const volScalarField & alpha1