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-2023 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  phaseSystem& fluid(fluid_);
36 
37  autoPtr<phaseSystem::momentumTransferTable>
38  momentumTransferPtr(fluid.momentumTransfer());
39 
41  momentumTransfer(momentumTransferPtr());
42 
43  forAll(movingPhases, movingPhasei)
44  {
45  phaseModel& phase = movingPhases_[movingPhasei];
46 
47  const volScalarField& alpha = phase;
48  const volScalarField& rho = phase.rho();
49  volVectorField& U = phase.URef();
50 
51  UEqns.set
52  (
53  phase.index(),
54  new fvVectorMatrix
55  (
56  phase.UEqn()
57  ==
58  *momentumTransfer[phase.name()]
59  + fvModels().source(alpha, rho, U)
60  )
61  );
62 
63  UEqns[phase.index()].relax();
64  fvConstraints().constrain(UEqns[phase.index()]);
65  U.correctBoundaryConditions();
67  }
68 }
69 
70 
71 void Foam::solvers::multiphaseEuler::faceMomentumPredictor()
72 {
73  Info<< "Constructing face momentum equations" << endl;
74 
75  phaseSystem& fluid(fluid_);
76 
77  autoPtr<phaseSystem::momentumTransferTable>
78  momentumTransferPtr(fluid.momentumTransferf());
79 
81  momentumTransfer(momentumTransferPtr());
82 
83  forAll(movingPhases, movingPhasei)
84  {
85  phaseModel& phase = movingPhases_[movingPhasei];
86 
87  const volScalarField& alpha = phase;
88  const volScalarField& rho = phase.rho();
89  volVectorField& U = phase.URef();
90 
91  UEqns.set
92  (
93  phase.index(),
94  new fvVectorMatrix
95  (
96  phase.UfEqn()
97  ==
98  *momentumTransfer[phase.name()]
99  + fvModels().source(alpha, rho, U)
100  )
101  );
102 
103  UEqns[phase.index()].relax();
104  fvConstraints().constrain(UEqns[phase.index()]);
105  U.correctBoundaryConditions();
107  }
108 }
109 
110 
111 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
112 
114 {
115  if (pimple.flow())
116  {
117  UEqns.setSize(phases.size());
118 
119  if (faceMomentum)
120  {
121  faceMomentumPredictor();
122  }
123  else
124  {
125  cellMomentumPredictor();
126  }
127  }
128 }
129 
130 
131 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
virtual autoPtr< momentumTransferTable > momentumTransfer()=0
Return the momentum transfer matrices for the cell-based.
HashPtrTable< fvVectorMatrix > momentumTransferTable
Definition: phaseSystem.H:78
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_
const phaseSystem & fluid
Reference to the multiphase fluid.
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
pimpleControl pimple(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:65
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
messageStream Info
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:64
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45