multiphaseMixtureThermo.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) 2013-2017 OpenFOAM Foundation
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 
29 #include "alphaContactAngleFvPatchScalarField.H"
30 #include "Time.H"
31 #include "subCycle.H"
32 #include "MULES.H"
33 #include "fvcDiv.H"
34 #include "fvcGrad.H"
35 #include "fvcSnGrad.H"
36 #include "fvcFlux.H"
37 #include "fvcMeshPhi.H"
38 #include "surfaceInterpolate.H"
39 #include "unitConversion.H"
40 
41 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45  defineTypeNameAndDebug(multiphaseMixtureThermo, 0);
46 }
47 
48 const Foam::scalar Foam::multiphaseMixtureThermo::convertToRad =
50 
51 
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
53 
54 void Foam::multiphaseMixtureThermo::calcAlphas()
55 {
56  scalar level = 0.0;
57  alphas_ == 0.0;
58 
59  for (const phaseModel& phase : phases_)
60  {
61  alphas_ += level * phase;
62  level += 1.0;
63  }
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 (
71  const volVectorField& U,
72  const surfaceScalarField& phi
73 )
74 :
75  psiThermo(U.mesh(), word::null),
76  phases_(lookup("phases"), phaseModel::iNew(p_, T_)),
77 
78  mesh_(U.mesh()),
79  U_(U),
80  phi_(phi),
81 
82  rhoPhi_
83  (
84  IOobject
85  (
86  "rhoPhi",
87  mesh_.time().timeName(),
88  mesh_,
89  IOobject::NO_READ,
90  IOobject::NO_WRITE
91  ),
92  mesh_,
94  ),
95 
96  alphas_
97  (
98  IOobject
99  (
100  "alphas",
101  mesh_.time().timeName(),
102  mesh_,
103  IOobject::NO_READ,
104  IOobject::AUTO_WRITE
105  ),
106  mesh_,
108  ),
109 
110  sigmas_(lookup("sigmas")),
111  dimSigma_(1, 0, -2, 0, 0),
112  deltaN_
113  (
114  "deltaN",
115  1e-8/cbrt(average(mesh_.V()))
116  )
117 {
118  rhoPhi_.setOriented();
119  calcAlphas();
120  alphas_.write();
121  correct();
122 }
123 
124 
125 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
126 
128 {
129  for (phaseModel& phase : phases_)
130  {
131  phase.correct();
132  }
133 
134  auto phasei = phases_.cbegin();
135 
136  psi_ = phasei()*phasei().thermo().psi();
137  mu_ = phasei()*phasei().thermo().mu();
138  alpha_ = phasei()*phasei().thermo().alpha();
139 
140  for (++phasei; phasei != phases_.cend(); ++phasei)
141  {
142  psi_ += phasei()*phasei().thermo().psi();
143  mu_ += phasei()*phasei().thermo().mu();
144  alpha_ += phasei()*phasei().thermo().alpha();
145  }
146 }
147 
148 
150 {
151  for (phaseModel& phase : phases_)
152  {
153  phase.thermo().rho() += phase.thermo().psi()*dp;
154  }
155 }
156 
157 
159 {
160  auto phasei = phases_.cbegin();
161 
162  word name = phasei().thermo().thermoName();
163 
164  for (++phasei; phasei != phases_.cend(); ++phasei)
165  {
166  name += ',' + phasei().thermo().thermoName();
167  }
168 
169  return name;
170 }
171 
172 
174 {
175  for (const phaseModel& phase : phases_)
176  {
177  if (!phase.thermo().incompressible())
178  {
179  return false;
180  }
181  }
182 
183  return true;
184 }
185 
186 
188 {
189  for (const phaseModel& phase : phases_)
190  {
191  if (!phase.thermo().isochoric())
192  {
193  return false;
194  }
195  }
196 
197  return true;
198 }
199 
200 
202 (
203  const volScalarField& p,
204  const volScalarField& T
205 ) const
206 {
207  auto phasei = phases_.cbegin();
208 
209  tmp<volScalarField> the(phasei()*phasei().thermo().he(p, T));
210 
211  for (++phasei; phasei != phases_.cend(); ++phasei)
212  {
213  the.ref() += phasei()*phasei().thermo().he(p, T);
214  }
215 
216  return the;
217 }
218 
219 
221 (
222  const scalarField& p,
223  const scalarField& T,
224  const labelList& cells
225 ) const
226 {
227  auto phasei = phases_.cbegin();
228 
229  tmp<scalarField> the
230  (
232  );
233 
234  for (++phasei; phasei != phases_.cend(); ++phasei)
235  {
236  the.ref() +=
237  scalarField(phasei(), cells)*phasei().thermo().he(p, T, cells);
238  }
239 
240  return the;
241 }
242 
243 
245 (
246  const scalarField& p,
247  const scalarField& T,
248  const label patchi
249 ) const
250 {
251  auto phasei = phases_.cbegin();
252 
253  tmp<scalarField> the
254  (
255  phasei().boundaryField()[patchi]*phasei().thermo().he(p, T, patchi)
256  );
257 
258  for (++phasei; phasei != phases_.cend(); ++phasei)
259  {
260  the.ref() +=
261  phasei().boundaryField()[patchi]*phasei().thermo().he(p, T, patchi);
262  }
263 
264  return the;
265 }
266 
267 
269 {
270  auto phasei = phases_.cbegin();
271 
272  tmp<volScalarField> thc(phasei()*phasei().thermo().hc());
273 
274  for (++phasei; phasei != phases_.cend(); ++phasei)
275  {
276  thc.ref() += phasei()*phasei().thermo().hc();
277  }
278 
279  return thc;
280 }
281 
282 
284 (
285  const scalarField& h,
286  const scalarField& p,
287  const scalarField& T0,
288  const labelList& cells
289 ) const
290 {
292  return T0;
293 }
294 
295 
297 (
298  const scalarField& h,
299  const scalarField& p,
300  const scalarField& T0,
301  const label patchi
302 ) const
303 {
305  return T0;
306 }
307 
308 
310 {
311  auto phasei = phases_.cbegin();
312 
313  tmp<volScalarField> trho(phasei()*phasei().thermo().rho());
314 
315  for (++phasei; phasei != phases_.cend(); ++phasei)
316  {
317  trho.ref() += phasei()*phasei().thermo().rho();
318  }
319 
320  return trho;
321 }
322 
323 
325 (
326  const label patchi
327 ) const
328 {
329  auto phasei = phases_.cbegin();
330 
331  tmp<scalarField> trho
332  (
333  phasei().boundaryField()[patchi]*phasei().thermo().rho(patchi)
334  );
335 
336  for (++phasei; phasei != phases_.cend(); ++phasei)
337  {
338  trho.ref() +=
339  phasei().boundaryField()[patchi]*phasei().thermo().rho(patchi);
340  }
341 
342  return trho;
343 }
344 
345 
347 {
348  auto phasei = phases_.cbegin();
349 
350  tmp<volScalarField> tCp(phasei()*phasei().thermo().Cp());
351 
352  for (++phasei; phasei != phases_.cend(); ++phasei)
353  {
354  tCp.ref() += phasei()*phasei().thermo().Cp();
355  }
356 
357  return tCp;
358 }
359 
360 
362 (
363  const scalarField& p,
364  const scalarField& T,
365  const label patchi
366 ) const
367 {
368  auto phasei = phases_.cbegin();
369 
370  tmp<scalarField> tCp
371  (
372  phasei().boundaryField()[patchi]*phasei().thermo().Cp(p, T, patchi)
373  );
374 
375  for (++phasei; phasei != phases_.cend(); ++phasei)
376  {
377  tCp.ref() +=
378  phasei().boundaryField()[patchi]*phasei().thermo().Cp(p, T, patchi);
379  }
380 
381  return tCp;
382 }
383 
384 
386 {
387  auto phasei = phases_.cbegin();
388 
389  tmp<volScalarField> tCv(phasei()*phasei().thermo().Cv());
390 
391  for (++phasei; phasei != phases_.cend(); ++phasei)
392  {
393  tCv.ref() += phasei()*phasei().thermo().Cv();
394  }
395 
396  return tCv;
397 }
398 
399 
401 (
402  const scalarField& p,
403  const scalarField& T,
404  const label patchi
405 ) const
406 {
407  auto phasei = phases_.cbegin();
408 
409  tmp<scalarField> tCv
410  (
411  phasei().boundaryField()[patchi]*phasei().thermo().Cv(p, T, patchi)
412  );
413 
414  for (++phasei; phasei != phases_.cend(); ++phasei)
415  {
416  tCv.ref() +=
417  phasei().boundaryField()[patchi]*phasei().thermo().Cv(p, T, patchi);
418  }
419 
420  return tCv;
421 }
422 
423 
425 {
426  auto phasei = phases_.cbegin();
427 
428  tmp<volScalarField> tgamma(phasei()*phasei().thermo().gamma());
429 
430  for (++phasei; phasei != phases_.cend(); ++phasei)
431  {
432  tgamma.ref() += phasei()*phasei().thermo().gamma();
433  }
434 
435  return tgamma;
436 }
437 
438 
440 (
441  const scalarField& p,
442  const scalarField& T,
443  const label patchi
444 ) const
445 {
446  auto phasei = phases_.cbegin();
447 
448  tmp<scalarField> tgamma
449  (
450  phasei().boundaryField()[patchi]*phasei().thermo().gamma(p, T, patchi)
451  );
452 
453  for (++phasei; phasei != phases_.cend(); ++phasei)
454  {
455  tgamma.ref() +=
456  phasei().boundaryField()[patchi]
457  *phasei().thermo().gamma(p, T, patchi);
458  }
459 
460  return tgamma;
461 }
462 
463 
465 {
466  auto phasei = phases_.cbegin();
467 
468  tmp<volScalarField> tCpv(phasei()*phasei().thermo().Cpv());
469 
470  for (++phasei; phasei != phases_.cend(); ++phasei)
471  {
472  tCpv.ref() += phasei()*phasei().thermo().Cpv();
473  }
474 
475  return tCpv;
476 }
477 
478 
480 (
481  const scalarField& p,
482  const scalarField& T,
483  const label patchi
484 ) const
485 {
486  auto phasei = phases_.cbegin();
487 
488  tmp<scalarField> tCpv
489  (
490  phasei().boundaryField()[patchi]*phasei().thermo().Cpv(p, T, patchi)
491  );
492 
493  for (++phasei; phasei != phases_.cend(); ++phasei)
494  {
495  tCpv.ref() +=
496  phasei().boundaryField()[patchi]
497  *phasei().thermo().Cpv(p, T, patchi);
498  }
499 
500  return tCpv;
501 }
502 
503 
505 {
506  auto phasei = phases_.cbegin();
507 
508  tmp<volScalarField> tCpByCpv(phasei()*phasei().thermo().CpByCpv());
509 
510  for (++phasei; phasei != phases_.cend(); ++phasei)
511  {
512  tCpByCpv.ref() += phasei()*phasei().thermo().CpByCpv();
513  }
514 
515  return tCpByCpv;
516 }
517 
518 
520 (
521  const scalarField& p,
522  const scalarField& T,
523  const label patchi
524 ) const
525 {
526  auto phasei = phases_.cbegin();
527 
528  tmp<scalarField> tCpByCpv
529  (
530  phasei().boundaryField()[patchi]*phasei().thermo().CpByCpv(p, T, patchi)
531  );
532 
533  for (++phasei; phasei != phases_.cend(); ++phasei)
534  {
535  tCpByCpv.ref() +=
536  phasei().boundaryField()[patchi]
537  *phasei().thermo().CpByCpv(p, T, patchi);
538  }
539 
540  return tCpByCpv;
541 }
542 
543 
545 {
546  auto phasei = phases_.cbegin();
547 
548  tmp<volScalarField> tW(phasei()*phasei().thermo().W());
549 
550  for (++phasei; phasei != phases_.cend(); ++phasei)
551  {
552  tW.ref() += phasei()*phasei().thermo().W();
553  }
554 
555  return tW;
556 }
557 
558 
560 {
561  return mu()/rho();
562 }
563 
564 
566 (
567  const label patchi
568 ) const
569 {
570  return mu(patchi)/rho(patchi);
571 }
572 
573 
575 {
576  auto phasei = phases_.cbegin();
577 
578  tmp<volScalarField> tkappa(phasei()*phasei().thermo().kappa());
579 
580  for (++phasei; phasei != phases_.cend(); ++phasei)
581  {
582  tkappa.ref() += phasei()*phasei().thermo().kappa();
583  }
584 
585  return tkappa;
586 }
587 
588 
590 (
591  const label patchi
592 ) const
593 {
594  auto phasei = phases_.cbegin();
595 
596  tmp<scalarField> tkappa
597  (
598  phasei().boundaryField()[patchi]*phasei().thermo().kappa(patchi)
599  );
600 
601  for (++phasei; phasei != phases_.cend(); ++phasei)
602  {
603  tkappa.ref() +=
604  phasei().boundaryField()[patchi]*phasei().thermo().kappa(patchi);
605  }
606 
607  return tkappa;
608 }
609 
610 
612 {
613  PtrDictionary<phaseModel>::const_iterator phasei = phases_.begin();
614 
615  tmp<volScalarField> talphaEff(phasei()*phasei().thermo().alphahe());
616 
617  for (++phasei; phasei != phases_.end(); ++phasei)
618  {
619  talphaEff.ref() += phasei()*phasei().thermo().alphahe();
620  }
621 
622  return talphaEff;
623 }
624 
625 
627 (
628  const label patchi
629 ) const
630 {
631  PtrDictionary<phaseModel>::const_iterator phasei = phases_.begin();
632 
633  tmp<scalarField> talphaEff
634  (
635  phasei().boundaryField()[patchi]
636  *phasei().thermo().alphahe(patchi)
637  );
638 
639  for (++phasei; phasei != phases_.end(); ++phasei)
640  {
641  talphaEff.ref() +=
642  phasei().boundaryField()[patchi]
643  *phasei().thermo().alphahe(patchi);
644  }
645 
646  return talphaEff;
647 }
648 
649 
651 (
652  const volScalarField& alphat
653 ) const
654 {
655  auto phasei = phases_.cbegin();
656 
657  tmp<volScalarField> tkappaEff(phasei()*phasei().thermo().kappaEff(alphat));
658 
659  for (++phasei; phasei != phases_.cend(); ++phasei)
660  {
661  tkappaEff.ref() += phasei()*phasei().thermo().kappaEff(alphat);
662  }
663 
664  return tkappaEff;
665 }
666 
667 
669 (
670  const scalarField& alphat,
671  const label patchi
672 ) const
673 {
674  auto phasei = phases_.cbegin();
675 
676  tmp<scalarField> tkappaEff
677  (
678  phasei().boundaryField()[patchi]
679  *phasei().thermo().kappaEff(alphat, patchi)
680  );
681 
682  for (++phasei; phasei != phases_.cend(); ++phasei)
683  {
684  tkappaEff.ref() +=
685  phasei().boundaryField()[patchi]
686  *phasei().thermo().kappaEff(alphat, patchi);
687  }
688 
689  return tkappaEff;
690 }
691 
692 
694 (
695  const volScalarField& alphat
696 ) const
697 {
698  auto phasei = phases_.cbegin();
699 
700  tmp<volScalarField> talphaEff(phasei()*phasei().thermo().alphaEff(alphat));
701 
702  for (++phasei; phasei != phases_.cend(); ++phasei)
703  {
704  talphaEff.ref() += phasei()*phasei().thermo().alphaEff(alphat);
705  }
706 
707  return talphaEff;
708 }
709 
710 
712 (
713  const scalarField& alphat,
714  const label patchi
715 ) const
716 {
717  auto phasei = phases_.cbegin();
718 
719  tmp<scalarField> talphaEff
720  (
721  phasei().boundaryField()[patchi]
722  *phasei().thermo().alphaEff(alphat, patchi)
723  );
724 
725  for (++phasei; phasei != phases_.cend(); ++phasei)
726  {
727  talphaEff.ref() +=
728  phasei().boundaryField()[patchi]
729  *phasei().thermo().alphaEff(alphat, patchi);
730  }
731 
732  return talphaEff;
733 }
734 
735 
737 {
738  auto phasei = phases_.cbegin();
739 
740  tmp<volScalarField> trCv(phasei()/phasei().thermo().Cv());
741 
742  for (++phasei; phasei != phases_.cend(); ++phasei)
743  {
744  trCv.ref() += phasei()/phasei().thermo().Cv();
745  }
746 
747  return trCv;
748 }
749 
750 
753 {
754  tmp<surfaceScalarField> tstf
755  (
757  (
758  IOobject
759  (
760  "surfaceTensionForce",
761  mesh_.time().timeName(),
762  mesh_
763  ),
764  mesh_,
765  dimensionedScalar(dimensionSet(1, -2, -2, 0, 0), Zero)
766  )
767  );
768 
769  surfaceScalarField& stf = tstf.ref();
770  stf.setOriented();
771 
772  forAllConstIters(phases_, phase1)
773  {
774  const phaseModel& alpha1 = *phase1;
775 
776  auto phase2 = phase1;
777 
778  for (++phase2; phase2 != phases_.cend(); ++phase2)
779  {
780  const phaseModel& alpha2 = *phase2;
781 
782  auto sigma = sigmas_.cfind(interfacePair(alpha1, alpha2));
783 
784  if (!sigma.found())
785  {
787  << "Cannot find interface " << interfacePair(alpha1, alpha2)
788  << " in list of sigma values"
789  << exit(FatalError);
790  }
791 
792  stf += dimensionedScalar("sigma", dimSigma_, *sigma)
794  (
797  );
798  }
799  }
800 
801  return tstf;
802 }
803 
804 
806 {
807  const Time& runTime = mesh_.time();
808 
809  const dictionary& alphaControls = mesh_.solverDict("alpha");
810  label nAlphaSubCycles(alphaControls.get<label>("nAlphaSubCycles"));
811  scalar cAlpha(alphaControls.get<scalar>("cAlpha"));
812 
813  volScalarField& alpha = phases_.first();
814 
815  if (nAlphaSubCycles > 1)
816  {
817  surfaceScalarField rhoPhiSum(0.0*rhoPhi_);
818  dimensionedScalar totalDeltaT = runTime.deltaT();
819 
820  for
821  (
822  subCycle<volScalarField> alphaSubCycle(alpha, nAlphaSubCycles);
823  !(++alphaSubCycle).end();
824  )
825  {
826  solveAlphas(cAlpha);
827  rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi_;
828  }
829 
830  rhoPhi_ = rhoPhiSum;
831  }
832  else
833  {
834  solveAlphas(cAlpha);
835  }
836 }
837 
838 
839 Foam::tmp<Foam::surfaceVectorField> Foam::multiphaseMixtureThermo::nHatfv
840 (
841  const volScalarField& alpha1,
842  const volScalarField& alpha2
843 ) const
844 {
845  /*
846  // Cell gradient of alpha
847  volVectorField gradAlpha =
848  alpha2*fvc::grad(alpha1) - alpha1*fvc::grad(alpha2);
849 
850  // Interpolated face-gradient of alpha
851  surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
852  */
853 
854  surfaceVectorField gradAlphaf
855  (
858  );
859 
860  // Face unit interface normal
861  return gradAlphaf/(mag(gradAlphaf) + deltaN_);
862 }
863 
864 
865 Foam::tmp<Foam::surfaceScalarField> Foam::multiphaseMixtureThermo::nHatf
866 (
867  const volScalarField& alpha1,
868  const volScalarField& alpha2
869 ) const
870 {
871  // Face unit interface normal flux
872  return nHatfv(alpha1, alpha2) & mesh_.Sf();
873 }
874 
875 
876 // Correction for the boundary condition on the unit normal nHat on
877 // walls to produce the correct contact angle.
878 
879 // The dynamic contact angle is calculated from the component of the
880 // velocity on the direction of the interface, parallel to the wall.
881 
882 void Foam::multiphaseMixtureThermo::correctContactAngle
883 (
884  const phaseModel& alpha1,
885  const phaseModel& alpha2,
886  surfaceVectorField::Boundary& nHatb
887 ) const
888 {
889  const volScalarField::Boundary& gbf
890  = alpha1.boundaryField();
891 
892  const fvBoundaryMesh& boundary = mesh_.boundary();
893 
894  forAll(boundary, patchi)
895  {
896  if (isA<alphaContactAngleFvPatchScalarField>(gbf[patchi]))
897  {
898  const alphaContactAngleFvPatchScalarField& acap =
899  refCast<const alphaContactAngleFvPatchScalarField>(gbf[patchi]);
900 
901  vectorField& nHatPatch = nHatb[patchi];
902 
903  vectorField AfHatPatch
904  (
905  mesh_.Sf().boundaryField()[patchi]
906  /mesh_.magSf().boundaryField()[patchi]
907  );
908 
909  const auto tp =
910  acap.thetaProps().cfind(interfacePair(alpha1, alpha2));
911 
912  if (!tp.found())
913  {
915  << "Cannot find interface " << interfacePair(alpha1, alpha2)
916  << "\n in table of theta properties for patch "
917  << acap.patch().name()
918  << exit(FatalError);
919  }
920 
921  const bool matched = (tp.key().first() == alpha1.name());
922 
923  const scalar theta0 = degToRad(tp().theta0(matched));
924  scalarField theta(boundary[patchi].size(), theta0);
925 
926  const scalar uTheta = tp().uTheta();
927 
928  // Calculate the dynamic contact angle if required
929  if (uTheta > SMALL)
930  {
931  const scalar thetaA = degToRad(tp().thetaA(matched));
932  const scalar thetaR = degToRad(tp().thetaR(matched));
933 
934  // Calculated the component of the velocity parallel to the wall
935  vectorField Uwall
936  (
937  U_.boundaryField()[patchi].patchInternalField()
938  - U_.boundaryField()[patchi]
939  );
940  Uwall -= (AfHatPatch & Uwall)*AfHatPatch;
941 
942  // Find the direction of the interface parallel to the wall
943  vectorField nWall
944  (
945  nHatPatch - (AfHatPatch & nHatPatch)*AfHatPatch
946  );
947 
948  // Normalise nWall
949  nWall /= (mag(nWall) + SMALL);
950 
951  // Calculate Uwall resolved normal to the interface parallel to
952  // the interface
953  scalarField uwall(nWall & Uwall);
954 
955  theta += (thetaA - thetaR)*tanh(uwall/uTheta);
956  }
957 
958 
959  // Reset nHatPatch to correspond to the contact angle
960 
961  scalarField a12(nHatPatch & AfHatPatch);
962 
963  scalarField b1(cos(theta));
964 
965  scalarField b2(nHatPatch.size());
966 
967  forAll(b2, facei)
968  {
969  b2[facei] = cos(acos(a12[facei]) - theta[facei]);
970  }
971 
972  scalarField det(1.0 - a12*a12);
973 
974  scalarField a((b1 - a12*b2)/det);
975  scalarField b((b2 - a12*b1)/det);
976 
977  nHatPatch = a*AfHatPatch + b*nHatPatch;
978 
979  nHatPatch /= (mag(nHatPatch) + deltaN_.value());
980  }
981  }
982 }
983 
984 
985 Foam::tmp<Foam::volScalarField> Foam::multiphaseMixtureThermo::K
986 (
987  const phaseModel& alpha1,
988  const phaseModel& alpha2
989 ) const
990 {
991  tmp<surfaceVectorField> tnHatfv = nHatfv(alpha1, alpha2);
992 
993  correctContactAngle(alpha1, alpha2, tnHatfv.ref().boundaryFieldRef());
994 
995  // Simple expression for curvature
996  return -fvc::div(tnHatfv & mesh_.Sf());
997 }
998 
999 
1002 {
1003  tmp<volScalarField> tnearInt
1004  (
1005  new volScalarField
1006  (
1007  IOobject
1008  (
1009  "nearInterface",
1010  mesh_.time().timeName(),
1011  mesh_
1012  ),
1013  mesh_,
1015  )
1016  );
1017 
1018  for (const phaseModel& phase : phases_)
1019  {
1020  tnearInt.ref() =
1021  max(tnearInt(), pos0(phase - 0.01)*pos0(0.99 - phase));
1022  }
1023 
1024  return tnearInt;
1025 }
1026 
1027 
1028 void Foam::multiphaseMixtureThermo::solveAlphas
1029 (
1030  const scalar cAlpha
1031 )
1032 {
1033  static label nSolves(-1);
1034  ++nSolves;
1035 
1036  const word alphaScheme("div(phi,alpha)");
1037  const word alpharScheme("div(phirb,alpha)");
1038 
1039  surfaceScalarField phic(mag(phi_/mesh_.magSf()));
1040  phic = min(cAlpha*phic, max(phic));
1041 
1042  PtrList<surfaceScalarField> alphaPhiCorrs(phases_.size());
1043 
1044  int phasei = 0;
1045  for (phaseModel& alpha : phases_)
1046  {
1047  alphaPhiCorrs.set
1048  (
1049  phasei,
1050  new surfaceScalarField
1051  (
1052  phi_.name() + alpha.name(),
1053  fvc::flux
1054  (
1055  phi_,
1056  alpha,
1057  alphaScheme
1058  )
1059  )
1060  );
1061 
1062  surfaceScalarField& alphaPhiCorr = alphaPhiCorrs[phasei];
1063 
1064  for (phaseModel& alpha2 : phases_)
1065  {
1066  if (&alpha2 == &alpha) continue;
1067 
1069 
1070  alphaPhiCorr += fvc::flux
1071  (
1073  alpha,
1074  alpharScheme
1075  );
1076  }
1077 
1078  MULES::limit
1079  (
1080  1.0/mesh_.time().deltaT().value(),
1081  geometricOneField(),
1082  alpha,
1083  phi_,
1084  alphaPhiCorr,
1085  zeroField(),
1086  zeroField(),
1087  oneField(),
1088  zeroField(),
1089  true
1090  );
1091 
1092  ++phasei;
1093  }
1094 
1095  MULES::limitSum(alphaPhiCorrs);
1096 
1097  rhoPhi_ = dimensionedScalar(dimensionSet(1, 0, -1, 0, 0), Zero);
1098 
1099  volScalarField sumAlpha
1100  (
1101  IOobject
1102  (
1103  "sumAlpha",
1104  mesh_.time().timeName(),
1105  mesh_
1106  ),
1107  mesh_,
1109  );
1110 
1111 
1113 
1114 
1115  phasei = 0;
1116 
1117  for (phaseModel& alpha : phases_)
1118  {
1119  surfaceScalarField& alphaPhi = alphaPhiCorrs[phasei];
1120  alphaPhi += upwind<scalar>(mesh_, phi_).flux(alpha);
1121 
1123  (
1124  IOobject
1125  (
1126  "Sp",
1127  mesh_.time().timeName(),
1128  mesh_
1129  ),
1130  mesh_,
1132  );
1133 
1135  (
1136  IOobject
1137  (
1138  "Su",
1139  mesh_.time().timeName(),
1140  mesh_
1141  ),
1142  // Divergence term is handled explicitly to be
1143  // consistent with the explicit transport solution
1144  divU*min(alpha, scalar(1))
1145  );
1146 
1147  {
1148  const scalarField& dgdt = alpha.dgdt();
1149 
1150  forAll(dgdt, celli)
1151  {
1152  if (dgdt[celli] < 0.0 && alpha[celli] > 0.0)
1153  {
1154  Sp[celli] += dgdt[celli]*alpha[celli];
1155  Su[celli] -= dgdt[celli]*alpha[celli];
1156  }
1157  else if (dgdt[celli] > 0.0 && alpha[celli] < 1.0)
1158  {
1159  Sp[celli] -= dgdt[celli]*(1.0 - alpha[celli]);
1160  }
1161  }
1162  }
1163 
1164  for (const phaseModel& alpha2 : phases_)
1165  {
1166  if (&alpha2 == &alpha) continue;
1167 
1168  const scalarField& dgdt2 = alpha2.dgdt();
1169 
1170  forAll(dgdt2, celli)
1171  {
1172  if (dgdt2[celli] > 0.0 && alpha2[celli] < 1.0)
1173  {
1174  Sp[celli] -= dgdt2[celli]*(1.0 - alpha2[celli]);
1175  Su[celli] += dgdt2[celli]*alpha[celli];
1176  }
1177  else if (dgdt2[celli] < 0.0 && alpha2[celli] > 0.0)
1178  {
1179  Sp[celli] += dgdt2[celli]*alpha2[celli];
1180  }
1181  }
1182  }
1183 
1185  (
1186  geometricOneField(),
1187  alpha,
1188  alphaPhi,
1189  Sp,
1190  Su
1191  );
1192 
1193  rhoPhi_ += fvc::interpolate(alpha.thermo().rho())*alphaPhi;
1194 
1195  Info<< alpha.name() << " volume fraction, min, max = "
1196  << alpha.weightedAverage(mesh_.V()).value()
1197  << ' ' << min(alpha).value()
1198  << ' ' << max(alpha).value()
1199  << endl;
1200 
1201  sumAlpha += alpha;
1202 
1203  ++phasei;
1204  }
1205 
1206  Info<< "Phase-sum volume fraction, min, max = "
1207  << sumAlpha.weightedAverage(mesh_.V()).value()
1208  << ' ' << min(sumAlpha).value()
1209  << ' ' << max(sumAlpha).value()
1210  << endl;
1211 
1212  calcAlphas();
1213 }
1214 
1215 
1216 // ************************************************************************* //
Foam::multiphaseMixtureThermo::nu
virtual tmp< volScalarField > nu() const
Kinematic viscosity of mixture [m^2/s].
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::fvc::snGrad
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:47
Foam::psiThermo::psi_
volScalarField psi_
Compressibility [s^2/m^2].
Definition: psiThermo.H:65
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::fvc::flux
tmp< surfaceScalarField > flux(const volVectorField &vvf)
Return the face-flux field obtained from the given volVectorField.
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::MULES::explicitSolve
void explicitSolve(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiPsi, const SpType &Sp, const SuType &Su)
Definition: MULESTemplates.C:41
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::multiphaseMixtureThermo::alphahe
virtual tmp< volScalarField > alphahe() const
Thermal diffusivity for energy of mixture [kg/m/s].
Foam::multiphaseMixtureThermo::CpByCpv
virtual tmp< volScalarField > CpByCpv() const
Heat capacity ratio [].
Foam::MULES::limit
void limit(const RdeltaTType &rDeltaT, const RhoType &rho, const volScalarField &psi, const surfaceScalarField &phi, surfaceScalarField &phiPsi, const SpType &Sp, const SuType &Su, const PsiMaxType &psiMax, const PsiMinType &psiMin, const bool returnCorr)
Definition: MULESTemplates.C:581
Foam::TimeState::deltaT
dimensionedScalar deltaT() const
Return time step.
Definition: TimeStateI.H:54
Foam::constant::physicoChemical::mu
const dimensionedScalar mu
Atomic mass unit.
Definition: createFieldRefs.H:4
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
fvcMeshPhi.H
Calculate the mesh motion flux and convert fluxes from absolute to relative and back.
alpha2
const volScalarField & alpha2
Definition: setRegionFluidFields.H:9
subCycle.H
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:186
fvcSnGrad.H
Calculate the snGrad of the given volField.
Foam::vtk::Tools::zeroField
vtkSmartPointer< vtkFloatArray > zeroField(const word &name, const label size)
Create named field initialized to zero.
Definition: foamVtkToolsTemplates.C:327
kappaEff
kappaEff
Definition: TEqn.H:10
Sp
zeroField Sp
Definition: alphaSuSp.H:2
Foam::basicThermo::alpha_
volScalarField alpha_
Laminar thermal diffusivity [kg/m/s].
Definition: basicThermo.H:89
Cv
const volScalarField & Cv
Definition: EEqn.H:8
tCp
const tmp< volScalarField > & tCp
Definition: EEqn.H:4
fvcDiv.H
Calculate the divergence of the given field.
Foam::dimensioned::name
const word & name() const
Return const reference to name.
Definition: dimensionedType.C:406
unitConversion.H
Unit conversion functions.
Foam::fvc::div
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:49
phasei
label phasei
Definition: pEqn.H:27
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::multiphaseMixtureThermo::Cpv
virtual tmp< volScalarField > Cpv() const
Heat capacity at constant pressure/volume [J/kg/K].
Foam::pos0
dimensionedScalar pos0(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:188
alpha1
const volScalarField & alpha1
Definition: setRegionFluidFields.H:8
Foam::multiphaseMixtureThermo::isochoric
virtual bool isochoric() const
Return true if the equation of state is isochoric.
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
nAlphaSubCycles
label nAlphaSubCycles(alphaControls.get< label >("nAlphaSubCycles"))
Foam::constant::electromagnetic::kappa
const dimensionedScalar kappa
Coulomb constant: default SI units: [N.m2/C2].
Foam::multiphaseMixtureThermo::nearInterface
tmp< volScalarField > nearInterface() const
Indicator of the proximity of the interface.
rho
rho
Definition: readInitialConditions.H:88
alpharScheme
word alpharScheme("div(phirb,alpha)")
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
h
volScalarField & h
Planck constant.
Definition: setRegionSolidFields.H:33
Foam::multiphaseMixtureThermo::surfaceTensionForce
tmp< surfaceScalarField > surfaceTensionForce() const
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
phic
surfaceScalarField phic(mixture.cAlpha() *mag(alphaPhic/mesh.magSf()))
K
CGAL::Exact_predicates_exact_constructions_kernel K
Definition: CGALTriangulation3DKernel.H:58
Foam::multiphaseMixtureThermo::kappaEff
virtual tmp< volScalarField > kappaEff(const volScalarField &alphat) const
Effective thermal diffusivity of mixture [J/m/s/K].
Su
zeroField Su
Definition: alphaSuSp.H:1
trho
tmp< volScalarField > trho
Definition: setRegionSolidFields.H:4
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
phir
surfaceScalarField phir(fvc::flux(UdmModel.Udm()))
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::tanh
dimensionedScalar tanh(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:272
alphaPhi
surfaceScalarField alphaPhi(phi.name()+alpha1.name(), fvc::flux(phi, alpha1, alphaScheme))
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
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::cellModeller::lookup
const cellModel * lookup(const word &modelName)
Deprecated(2017-11) equivalent to cellModel::ptr static method.
Definition: cellModeller.H:46
correct
fvOptions correct(rho)
Foam::MULES::limitSum
void limitSum(UPtrList< scalarField > &phiPsiCorrs)
Definition: MULES.C:35
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
divU
zeroField divU
Definition: alphaSuSp.H:3
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
Foam::multiphaseMixtureThermo::Cv
virtual tmp< volScalarField > Cv() const
Heat capacity at constant volume [J/kg/K].
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::multiphaseMixtureThermo::rho
virtual tmp< volScalarField > rho() const
Density [kg/m^3].
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
timeName
word timeName
Definition: getTimeIndex.H:3
phase2
phaseModel & phase2
Definition: setRegionFluidFields.H:6
Foam::FatalError
error FatalError
Foam::multiphaseMixtureThermo::he
virtual volScalarField & he()
Enthalpy/Internal energy [J/kg].
Definition: multiphaseMixtureThermo.H:251
Foam::multiphaseMixtureThermo::thermoName
virtual word thermoName() const
Return the name of the thermo physics.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam::multiphaseMixtureThermo::W
virtual tmp< volScalarField > W() const
Molecular weight [kg/kmol].
Foam::psiThermo::mu_
volScalarField mu_
Dynamic viscosity [kg/m/s].
Definition: psiThermo.H:68
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::fvc::interpolate
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.
Foam::degToRad
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Definition: unitConversion.H:48
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
multiphaseMixtureThermo.H
Foam::multiphaseMixtureThermo::hc
virtual tmp< volScalarField > hc() const
Chemical enthalpy [J/kg].
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:60
Time.H
U
U
Definition: pEqn.H:72
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::multiphaseMixtureThermo::rCv
tmp< volScalarField > rCv() const
Return the phase-averaged reciprocal Cv.
Foam::constant::mathematical::pi
constexpr scalar pi(M_PI)
he
volScalarField & he
Definition: YEEqn.H:52
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::multiphaseMixtureThermo::THE
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.
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::GeometricField::ref
Internal & ref(const bool updateAccessTime=true)
Return a reference to the dimensioned internal field.
Definition: GeometricField.C:749
Foam::acos
dimensionedScalar acos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:268
fvcGrad.H
Calculate the gradient of the given field.
Foam::multiphaseMixtureThermo::Cp
virtual tmp< volScalarField > Cp() const
Heat capacity at constant pressure [J/kg/K].
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
fvcFlux.H
Calculate the face-flux of the given field.
gamma
const scalar gamma
Definition: EEqn.H:9
Foam::multiphaseMixtureThermo::alphaEff
virtual tmp< volScalarField > alphaEff(const volScalarField &alphat) const
Effective thermal diffusivity of mixture [J/m/s/K].
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
alphaEff
volScalarField alphaEff("alphaEff", turbulence->nu()/Pr+alphat)
Cp
const volScalarField & Cp
Definition: EEqn.H:7
Foam::multiphaseMixtureThermo::multiphaseMixtureThermo
multiphaseMixtureThermo(const volVectorField &U, const surfaceScalarField &phi)
Construct from components.
Foam::DimensionedField::setOriented
void setOriented(const bool oriented=true)
Set the oriented flag.
Definition: DimensionedFieldI.H:79
Foam::multiphaseMixtureThermo::kappa
virtual tmp< volScalarField > kappa() const
Thermal diffusivity for temperature of mixture [J/m/s/K].
Foam::multiphaseMixtureThermo::gamma
virtual tmp< volScalarField > gamma() const
Gamma = Cp/Cv [].
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::det
dimensionedScalar det(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:62
Foam::multiphaseMixtureThermo::solve
void solve()
Solve for the mixture phase-fractions.
Foam::multiphaseMixtureThermo::incompressible
virtual bool incompressible() const
Return true if the equation of state is incompressible.
Foam::multiphaseMixtureThermo::correct
virtual void correct()
Update properties.
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
phase1
phaseModel & phase1
Definition: setRegionFluidFields.H:5
Foam::surfaceVectorField
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
Definition: surfaceFieldsFwd.H:57
Foam::dimensioned::dimensions
const dimensionSet & dimensions() const
Return const reference to dimensions.
Definition: dimensionedType.C:420
Foam::cbrt
dimensionedScalar cbrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:155
MULES.H
MULES: Multidimensional universal limiter for explicit solution.
T0
scalar T0
Definition: createFields.H:22
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
boundary
faceListList boundary
Definition: createBlockMesh.H:4
Foam::fvc::absolute
tmp< surfaceScalarField > absolute(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given relative flux in absolute form.
Definition: fvcMeshPhi.C:190
Foam::multiphaseMixtureThermo::correctRho
void correctRho(const volScalarField &dp)
Update densities for given pressure change.
tCv
const tmp< volScalarField > & tCv
Definition: EEqn.H:5
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
Foam::cos
dimensionedScalar cos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:265
alphaControls
const dictionary & alphaControls
Definition: alphaControls.H:1