fluxPredictor.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) 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 "shockFluid.H"
27 
28 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
29 
30 void Foam::solvers::shockFluid::fluxPredictor()
31 {
32  if (!pos.valid())
33  {
35  (
36  "pos",
37  mesh,
39  );
40 
42  (
43  "neg",
44  mesh,
46  );
47  }
48 
49  rho_pos = interpolate(rho, pos());
50  rho_neg = interpolate(rho, neg());
51 
52  const volVectorField rhoU(rho*U);
53  rhoU_pos = interpolate(rhoU, pos(), U.name());
54  rhoU_neg = interpolate(rhoU, neg(), U.name());
55 
58 
59  const volScalarField& T = thermo.T();
60 
61  const volScalarField rPsi("rPsi", 1.0/thermo.psi());
62  const surfaceScalarField rPsi_pos(interpolate(rPsi, pos(), T.name()));
63  const surfaceScalarField rPsi_neg(interpolate(rPsi, neg(), T.name()));
64 
65  p_pos = surfaceScalarField::New("p_pos", rho_pos()*rPsi_pos);
66  p_neg = surfaceScalarField::New("p_neg", rho_neg()*rPsi_neg);
67 
68  surfaceScalarField phiv_pos("phiv_pos", U_pos() & mesh.Sf());
69  surfaceScalarField phiv_neg("phiv_neg", U_neg() & mesh.Sf());
70 
71  // Make fluxes relative to mesh-motion
72  if (mesh.moving())
73  {
74  phiv_pos -= mesh.phi();
75  phiv_neg -= mesh.phi();
76  }
77 
78  const volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi));
79  const surfaceScalarField cSf_pos
80  (
81  "cSf_pos",
82  interpolate(c, pos(), T.name())*mesh.magSf()
83  );
84  const surfaceScalarField cSf_neg
85  (
86  "cSf_neg",
87  interpolate(c, neg(), T.name())*mesh.magSf()
88  );
89 
90  const dimensionedScalar v_zero("v_zero", dimVolume/dimTime, 0);
91 
92  const surfaceScalarField ap
93  (
94  "ap",
95  max(max(phiv_pos + cSf_pos, phiv_neg + cSf_neg), v_zero)
96  );
97  const surfaceScalarField am
98  (
99  "am",
100  min(min(phiv_pos - cSf_pos, phiv_neg - cSf_neg), v_zero)
101  );
102 
104  (
105  "a_pos",
106  fluxScheme == "Tadmor"
107  ? surfaceScalarField::New("a_pos", mesh, 0.5)
108  : ap/(ap - am)
109  );
110 
111  a_neg = surfaceScalarField::New("a_neg", 1.0 - a_pos());
112 
113  phiv_pos *= a_pos();
114  phiv_neg *= a_neg();
115 
117  (
118  "aSf",
119  fluxScheme == "Tadmor"
120  ? -0.5*max(mag(am), mag(ap))
121  : am*a_pos()
122  );
123 
124  aphiv_pos = surfaceScalarField::New("aphiv_pos", phiv_pos - aSf());
125  aphiv_neg = surfaceScalarField::New("aphiv_neg", phiv_neg + aSf());
126 
127  phi_ = aphiv_pos()*rho_pos() + aphiv_neg()*rho_neg();
128 }
129 
130 
131 // ************************************************************************* //
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
const word & name() const
Return name.
Definition: IOobject.H:310
virtual const volScalarField & Cv() const =0
Heat capacity at constant volume [J/kg/K].
virtual const volScalarField & T() const =0
Temperature [K].
virtual const volScalarField & Cp() const =0
Heat capacity at constant pressure [J/kg/K].
virtual const volScalarField & psi() const =0
Compressibility [s^2/m^2].
const surfaceScalarField & phi() const
Return cell face motion fluxes.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
bool moving() const
Is mesh moving.
Definition: polyMesh.H:476
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
tmp< surfaceVectorField > U_neg
Definition: shockFluid.H:136
tmp< surfaceVectorField > U_pos
Definition: shockFluid.H:135
tmp< surfaceScalarField > p_neg
Definition: shockFluid.H:139
tmp< surfaceScalarField > aphiv_pos
Definition: shockFluid.H:146
tmp< surfaceScalarField > neg
Definition: shockFluid.H:127
const psiThermo & thermo
Reference to the fluid thermophysical properties.
Definition: shockFluid.H:206
tmp< surfaceVectorField > rhoU_pos
Definition: shockFluid.H:132
const volVectorField & U
Reference to the velocity field.
Definition: shockFluid.H:215
tmp< surfaceScalarField > p_pos
Definition: shockFluid.H:138
tmp< surfaceScalarField > rho_neg
Definition: shockFluid.H:130
tmp< surfaceScalarField > pos
Definition: shockFluid.H:126
tmp< surfaceScalarField > aSf
Definition: shockFluid.H:144
tmp< surfaceScalarField > a_pos
Definition: shockFluid.H:141
surfaceScalarField phi_
Mass-flux field.
Definition: shockFluid.H:98
const volScalarField & rho
Reference to the continuity density field.
Definition: shockFluid.H:212
tmp< surfaceScalarField > a_neg
Definition: shockFluid.H:142
tmp< surfaceVectorField > rhoU_neg
Definition: shockFluid.H:133
tmp< surfaceScalarField > rho_pos
Definition: shockFluid.H:129
tmp< surfaceScalarField > aphiv_neg
Definition: shockFluid.H:147
const dimensionedScalar c
Speed of light in a vacuum.
VolField< vector > volVectorField
Definition: volFieldsFwd.H:65
const dimensionSet dimless
SurfaceField< scalar > surfaceScalarField
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const dimensionSet dimTime
dimensionedScalar sqrt(const dimensionedScalar &ds)
const dimensionSet dimVolume
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:64
dimensioned< scalar > mag(const dimensioned< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.