momentumPredictor.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022-2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "multiphaseEuler.H"
27 #include "fvmSup.H"
28 
29 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
30 
31 void Foam::solvers::multiphaseEuler::cellMomentumPredictor()
32 {
33  Info<< "Constructing momentum equations" << endl;
34 
35  autoPtr<HashPtrTable<fvVectorMatrix>> popBalMomentumTransferPtr =
37  HashPtrTable<fvVectorMatrix>& popBalMomentumTransfer =
38  popBalMomentumTransferPtr();
39 
40  forAll(movingPhases, movingPhasei)
41  {
42  phaseModel& phase = movingPhases_[movingPhasei];
43 
44  const volScalarField& alpha = phase;
45  const volScalarField& rho = phase.rho();
46  volVectorField& U = phase.URef();
47 
48  UEqns.set
49  (
50  phase.index(),
51  new fvVectorMatrix
52  (
53  phase.UEqn()
54  ==
55  *popBalMomentumTransfer[phase.name()]
56  + fvModels().source(alpha, rho, U)
57  )
58  );
59 
60  UEqns[phase.index()].relax();
61  fvConstraints().constrain(UEqns[phase.index()]);
62  U.correctBoundaryConditions();
64  }
65 }
66 
67 
68 void Foam::solvers::multiphaseEuler::faceMomentumPredictor()
69 {
70  Info<< "Constructing face momentum equations" << endl;
71 
72  autoPtr<HashPtrTable<fvVectorMatrix>> popBalMomentumTransferPtr =
73  populationBalanceSystem_.momentumTransferf();
74  HashPtrTable<fvVectorMatrix>& popBalMomentumTransfer =
75  popBalMomentumTransferPtr();
76 
77  forAll(movingPhases, movingPhasei)
78  {
79  phaseModel& phase = movingPhases_[movingPhasei];
80 
81  const volScalarField& alpha = phase;
82  const volScalarField& rho = phase.rho();
83  volVectorField& U = phase.URef();
84 
85  UEqns.set
86  (
87  phase.index(),
88  new fvVectorMatrix
89  (
90  phase.UfEqn()
91  ==
92  *popBalMomentumTransfer[phase.name()]
93  + fvModels().source(alpha, rho, U)
94  )
95  );
96 
97  UEqns[phase.index()].relax();
98  fvConstraints().constrain(UEqns[phase.index()]);
99  U.correctBoundaryConditions();
101  }
102 }
103 
104 
105 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
106 
108 {
109  UEqns.setSize(phases.size());
110 
111  if (faceMomentum)
112  {
113  faceMomentumPredictor();
114  }
115  else
116  {
117  cellMomentumPredictor();
118  }
119 }
120 
121 
122 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
autoPtr< HashPtrTable< fvVectorMatrix > > momentumTransfer()
Return the momentum transfer matrices for the cell-based algorithm.
Foam::fvModels & fvModels() const
Return the fvModels that are created on demand.
Definition: solver.C:96
Foam::fvConstraints & fvConstraints() const
Return the fvConstraints that are created on demand.
Definition: solver.C:107
PtrList< fvVectorMatrix > UEqns
Temporary phase momentum matrices.
const phaseSystem::phaseModelPartialList & movingPhases
Reference to the moving phases.
virtual void momentumPredictor()
Construct and optionally solve the momentum equation.
phaseSystem::phaseModelPartialList & movingPhases_
populationBalanceSystem populationBalanceSystem_
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
Calculate the matrix for implicit and explicit sources.
U
Definition: pEqn.H:72
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45