MULES.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 | Copyright (C) 2011-2015 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 "MULES.H"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
31 (
32  volScalarField& psi,
33  const surfaceScalarField& phi,
34  surfaceScalarField& phiPsi,
35  const scalar psiMax,
36  const scalar psiMin
37 )
38 {
40  (
41  geometricOneField(),
42  psi,
43  phi,
44  phiPsi,
45  zeroField(), zeroField(),
46  psiMax, psiMin
47  );
48 }
49 
50 
52 {
53  forAll(phiPsiCorrs[0], facei)
54  {
55  scalar sumPos = 0;
56  scalar sumNeg = 0;
57 
58  for (int phasei=0; phasei<phiPsiCorrs.size(); phasei++)
59  {
60  if (phiPsiCorrs[phasei][facei] > 0)
61  {
62  sumPos += phiPsiCorrs[phasei][facei];
63  }
64  else
65  {
66  sumNeg += phiPsiCorrs[phasei][facei];
67  }
68  }
69 
70  scalar sum = sumPos + sumNeg;
71 
72  if (sum > 0 && sumPos > VSMALL)
73  {
74  scalar lambda = -sumNeg/sumPos;
75 
76  for (int phasei=0; phasei<phiPsiCorrs.size(); phasei++)
77  {
78  if (phiPsiCorrs[phasei][facei] > 0)
79  {
80  phiPsiCorrs[phasei][facei] *= lambda;
81  }
82  }
83  }
84  else if (sum < 0 && sumNeg < -VSMALL)
85  {
86  scalar lambda = -sumPos/sumNeg;
87 
88  for (int phasei=0; phasei<phiPsiCorrs.size(); phasei++)
89  {
90  if (phiPsiCorrs[phasei][facei] < 0)
91  {
92  phiPsiCorrs[phasei][facei] *= lambda;
93  }
94  }
95  }
96  }
97 }
98 
99 
100 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
label phasei
Definition: pEqn.H:27
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
void limitSum(UPtrList< scalarField > &phiPsiCorrs)
Definition: MULES.C:51
void explicitSolve(const RdeltaTType &rDeltaT, const RhoType &rho, volScalarField &psi, const surfaceScalarField &phiPsi, const SpType &Sp, const SuType &Su)
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:54
dimensionedScalar lambda(laminarTransport.lookup("lambda"))
MULES: Multidimensional universal limiter for explicit solution.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29