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  const PtrList<volScalarField> Kds(fluid.Kds());
44 
45  forAll(fluid.movingPhases(), movingPhasei)
46  {
47  phaseModel& phase = fluid.movingPhases()[movingPhasei];
48 
49  const volScalarField& alpha = phase;
50  const volScalarField& rho = phase.rho();
51  volVectorField& U = phase.URef();
52 
53  UEqns.set
54  (
55  phase.index(),
56  new fvVectorMatrix
57  (
58  phase.UEqn()
59  ==
60  *momentumTransfer[phase.name()]
61  + fvModels().source(alpha, rho, U)
62  // - fvm::Sp(Kds[phase.index()], U)
63  )
64  );
65 
66  UEqns[phase.index()].relax();
67  fvConstraints().constrain(UEqns[phase.index()]);
68  U.correctBoundaryConditions();
70  }
71 }
72 
73 
74 void Foam::solvers::multiphaseEuler::faceMomentumPredictor()
75 {
76  Info<< "Constructing face momentum equations" << endl;
77 
78  phaseSystem& fluid(fluid_);
79 
80  autoPtr<phaseSystem::momentumTransferTable>
81  momentumTransferPtr(fluid.momentumTransferf());
82 
84  momentumTransfer(momentumTransferPtr());
85 
86  forAll(fluid.movingPhases(), movingPhasei)
87  {
88  phaseModel& phase = fluid.movingPhases()[movingPhasei];
89 
90  const volScalarField& alpha = phase;
91  const volScalarField& rho = phase.rho();
92  volVectorField& U = phase.URef();
93 
94  UEqns.set
95  (
96  phase.index(),
97  new fvVectorMatrix
98  (
99  phase.UfEqn()
100  ==
101  *momentumTransfer[phase.name()]
102  + fvModels().source(alpha, rho, U)
103  )
104  );
105 
106  UEqns[phase.index()].relax();
107  fvConstraints().constrain(UEqns[phase.index()]);
108  U.correctBoundaryConditions();
110  }
111 }
112 
113 
114 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
115 
117 {
118  if (pimple.flow())
119  {
120  UEqns.setSize(phases.size());
121 
122  if (faceMomentum)
123  {
124  faceMomentumPredictor();
125  }
126  else
127  {
128  cellMomentumPredictor();
129  }
130  }
131 }
132 
133 
134 // ************************************************************************* //
#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 PtrList< volScalarField > Kds() const =0
Return the implicit part of the drag force.
const phaseModelPartialList & movingPhases() const
Return the models for phases that are moving.
Definition: phaseSystemI.H:55
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:85
Foam::fvConstraints & fvConstraints() const
Return the fvConstraints that are created on demand.
Definition: solver.C:96
PtrList< fvVectorMatrix > UEqns
Temporary phase momentum matrices.
virtual void momentumPredictor()
Construct and optionally solve the momentum equation.
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:62
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
messageStream Info
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:61
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45