Skip to content

Commit aae15ac

Browse files
committed
dfGenMatrixIncompressible
1 parent a1ccf1e commit aae15ac

File tree

14 files changed

+452
-153
lines changed

14 files changed

+452
-153
lines changed

Allwmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ wmake src/dynamicMesh
1919
wmake src/dynamicFvMesh
2020
wmake src/fluxSchemes
2121
wmake src/radiationModels
22-
wmake src/dfGenMatrix
22+
# wmake src/dfGenMatrix
2323

2424
wmake applications/solvers/df0DFoam
2525
wmake applications/solvers/dfLowMachFoam

src/dfGenMatrix/Utils.C

Lines changed: 0 additions & 124 deletions
This file was deleted.
File renamed without changes.

src/dfGenMatrix/GenFvMatrix.H renamed to src/dfGenMatrixIncompressible/GenFvMatrix.H

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
#include "runTimeSelectionTables.H"
99
#include "fvMatrices.H"
1010
#include "fvMesh.H"
11-
#include "turbulentFluidThermoModel.H"
12-
#include "CombustionModel.H"
11+
// #include "turbulentFluidThermoModel.H"
12+
// #include "CombustionModel.H"
13+
14+
#include "incompressibleTwoPhaseMixture.H"
15+
#include "immiscibleIncompressibleTwoPhaseMixture.H"
16+
#include "turbulentTransportModel.H"
1317

1418
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
19+
// namespace Foam
20+
// {
21+
// namespace incompressible
22+
// {
23+
// class turbulenceModel;
24+
// }
25+
// }
1526

1627
namespace Foam
1728
{
@@ -83,29 +94,57 @@ gaussLaplacianSchemeFvmLaplacian
8394
const GeometricField<Type, fvPatchField, volMesh>& vf
8495
);
8596

97+
98+
8699
// turbulence->divDevRhoReff(U)
100+
// tmp<fvVectorMatrix>
101+
// turbulenceModelLinearViscousStressDivDevRhoReff
102+
// (
103+
// volVectorField& U,
104+
// compressible::turbulenceModel& turbulence
105+
// );
106+
107+
// tmp<fvScalarMatrix>
108+
// GenMatrix_Y(
109+
// const volScalarField& rho,
110+
// volScalarField& Yi,
111+
// const surfaceScalarField& phi,
112+
// const surfaceScalarField& phiUc,
113+
// const volScalarField& rhoD,
114+
// const volScalarField& mut,
115+
// const Switch splitting,
116+
// const scalar Sct,
117+
// CombustionModel<basicThermo>& combustion,
118+
// fv::convectionScheme<scalar>& mvConvection
119+
// );
120+
121+
// tmp<fvVectorMatrix>
122+
// GenMatrix_U(
123+
// const volScalarField& rho,
124+
// volVectorField& U,
125+
// const surfaceScalarField& rhoPhi, // phi @dfLowMachFoam
126+
// const volScalarField& p,
127+
// compressible::turbulenceModel& turbulence
128+
// );
129+
87130
tmp<fvVectorMatrix>
88131
turbulenceModelLinearViscousStressDivDevRhoReff
89132
(
90133
volVectorField& U,
91-
compressible::turbulenceModel& turbulence
134+
incompressible::turbulenceModel& turbulence
92135
);
93136

94-
95-
tmp<fvScalarMatrix>
96-
GenMatrix_Y(
137+
tmp<fvVectorMatrix>
138+
GenMatrix_U(
97139
const volScalarField& rho,
98-
volScalarField& Yi,
99-
const surfaceScalarField& phi,
100-
const surfaceScalarField& phiUc,
101-
const volScalarField& rhoD,
102-
const volScalarField& mut,
103-
const Switch splitting,
104-
const scalar Sct,
105-
CombustionModel<basicThermo>& combustion,
106-
fv::convectionScheme<scalar>& mvConvection
140+
volVectorField& U,
141+
const surfaceScalarField& rhoPhi,
142+
const volScalarField& p,
143+
incompressible::turbulenceModel& turbulence
107144
);
108145

146+
void check_fvmatrix_equal(const fvVectorMatrix& answer, const fvVectorMatrix& check, const word& name);
147+
void check_fvmatrix_equal(const fvScalarMatrix& answer, const fvScalarMatrix& check, const word& name);
109148

110149

111150
} // End namespace Foam

src/dfGenMatrix/GenMatrix_U.C renamed to src/dfGenMatrixIncompressible/GenMatrix_U.C

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include "fvOptions.H"
1010
#include "turbulentFluidThermoModel.H"
1111

12+
#include "incompressibleTwoPhaseMixture.H"
13+
#include "immiscibleIncompressibleTwoPhaseMixture.H"
14+
#include "turbulentTransportModel.H"
15+
1216
namespace Foam{
1317

1418
tmp<fvVectorMatrix>
@@ -17,11 +21,21 @@ GenMatrix_U(
1721
volVectorField& U,
1822
const surfaceScalarField& rhoPhi, // phi @dfLowMachFoam
1923
const volScalarField& p,
20-
compressible::turbulenceModel& turbulence
24+
incompressible::turbulenceModel& turbulence
2125
){
26+
word name("div("+rhoPhi.name()+','+U.name()+')');
2227

23-
Info << "UEqn EulerDdtSchemeFvmDdt" << endl;
2428
const fvMesh& mesh = U.mesh();
29+
// div
30+
tmp<fv::convectionScheme<vector>> cs = fv::convectionScheme<vector>::New(mesh,rhoPhi,mesh.divScheme(name));
31+
fv::gaussConvectionScheme<vector>& gcs = dynamic_cast<fv::gaussConvectionScheme<vector>&>(cs.ref());
32+
tmp<surfaceScalarField> tweights = gcs.interpScheme().weights(U);
33+
const surfaceScalarField& weights = tweights();
34+
35+
// -------------------------------------------------------
36+
37+
Info << "UEqn EulerDdtSchemeFvmDdt" << endl;
38+
Info << "UEqn gaussConvectionSchemeFvmDiv" << endl;
2539

2640
tmp<fvVectorMatrix> tfvm_DDT
2741
(
@@ -35,11 +49,36 @@ GenMatrix_U(
3549

3650
scalar rDeltaT = 1.0/mesh.time().deltaTValue();
3751

38-
fvm_DDT.diag() = rDeltaT*rho.primitiveField()*mesh.Vsc();
52+
// interField
53+
fvm_DDT.lower() = -weights.primitiveField()*rhoPhi.primitiveField();
54+
// fvm_DDT.upper() = fvm_DDT.lower() + rhoPhi.primitiveField();
55+
fvm_DDT.upper() = -weights.primitiveField()*rhoPhi.primitiveField() + rhoPhi.primitiveField();
56+
fvm_DDT.negSumDiag(); // diag[i] = - (sum_of_lower_coeffs[i] + sum_of_upper_coeffs[i]) 先设置对流项
57+
58+
fvm_DDT.diag() += rDeltaT*rho.primitiveField()*mesh.Vsc(); // 再加上瞬态项
3959
fvm_DDT.source() = rDeltaT
4060
*rho.oldTime().primitiveField()
4161
*U.oldTime().primitiveField()*mesh.Vsc();
4262

63+
// boundaryField
64+
forAll(U.boundaryField(), patchi)
65+
{
66+
const fvPatchField<vector>& psf = U.boundaryField()[patchi];
67+
const fvsPatchScalarField& patchFlux = rhoPhi.boundaryField()[patchi];
68+
const fvsPatchScalarField& pw = weights.boundaryField()[patchi];
69+
70+
fvm_DDT.internalCoeffs()[patchi] = patchFlux*psf.valueInternalCoeffs(pw);
71+
fvm_DDT.boundaryCoeffs()[patchi] = -patchFlux*psf.valueBoundaryCoeffs(pw);
72+
}
73+
74+
// correct
75+
if (gcs.interpScheme().corrected())
76+
{
77+
fvm_DDT += fvc::surfaceIntegrate(rhoPhi*gcs.interpScheme().correction(U));
78+
}
79+
80+
81+
4382
// scalar* __restrict__ diagPtr_ddt = fvm_DDT.diag().begin();
4483
// scalar* __restrict__ sourcePtr_ddt = fvm_DDT.source().begin();
4584
// scalar* __restrict__ lowerPtr_ddt = fvm_DDT.lower().begin();
@@ -54,13 +93,15 @@ GenMatrix_U(
5493
(
5594
new fvVectorMatrix
5695
(
57-
(tfvm_DDT
58-
// + fvm::ddt(rho, U)
59-
+ fvm::div(rhoPhi, U))
60-
// + MRF.DDt(rho, U)
96+
(
97+
tfvm_DDT
98+
// + fvm::ddt(rho, U)
99+
// + fvm::div(rhoPhi, U)
100+
)
101+
// + MRF.DDt(rho, U)
61102

62103
==
63-
(- turbulence.divDevRhoReff(U)) // fvOptions(rho, U)
104+
(- turbulence.divDevRhoReff(rho, U)) // fvOptions(rho, U)
64105
)
65106
);
66107

File renamed without changes.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include "GenFvMatrix.H"
2+
#include "multivariateGaussConvectionScheme.H"
3+
#include "gaussConvectionScheme.H"
4+
#include "snGradScheme.H"
5+
#include "linear.H"
6+
#include "orthogonalSnGrad.H"
7+
8+
#include "pimpleControl.H"
9+
#include "fvOptions.H"
10+
#include "turbulentFluidThermoModel.H"
11+
12+
#include "incompressibleTwoPhaseMixture.H"
13+
#include "immiscibleIncompressibleTwoPhaseMixture.H"
14+
#include "turbulentTransportModel.H"
15+
16+
namespace Foam{
17+
18+
tmp<fvVectorMatrix>
19+
GenMatrix_p(
20+
21+
){
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
tmp<fvScalarMatrix> tfvm
55+
(
56+
new fvScalarMatrix
57+
(
58+
(fvm::laplacian(rAUf, p_rgh))
59+
==
60+
(fvc::div(phiHbyA))
61+
)
62+
);
63+
64+
return tfvm;
65+
66+
67+
68+
}
69+
70+
71+
}

0 commit comments

Comments
 (0)