Skip to content

Commit 8afd2ab

Browse files
authored
Allowed saving features to the disk and fixed a few feature definitions (#626)
* Enabled writting features to the disk. * Fixed a syntax error. * Updated tests for regModel. * Added tests for ReLU and RBF. * Fixed a few features in the turbulence models. * Fixed feature output function. * Added DARegression to solid solvers. * Added the missing content in Make/files * Fixed an issue in regModel for solids.
1 parent b24b19b commit 8afd2ab

29 files changed

+241
-137
lines changed

src/adjoint/DAModel/DAModel.C

+3-3
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void DAModel::updateIntermediateVariables()
270270

271271
}
272272

273-
void DAModel::getTurbProdTerm(scalarList& prodTerm) const
273+
void DAModel::getTurbProdTerm(volScalarField& prodTerm) const
274274
{
275275
/*
276276
Description:
@@ -292,7 +292,7 @@ void DAModel::getTurbProdTerm(scalarList& prodTerm) const
292292

293293
}
294294

295-
void DAModel::getTurbProdOverDestruct(scalarList& PoD) const
295+
void DAModel::getTurbProdOverDestruct(volScalarField& PoD) const
296296
{
297297
/*
298298
Description:
@@ -314,7 +314,7 @@ void DAModel::getTurbProdOverDestruct(scalarList& PoD) const
314314

315315
}
316316

317-
void DAModel::getTurbConvOverProd(scalarList& CoP) const
317+
void DAModel::getTurbConvOverProd(volScalarField& CoP) const
318318
{
319319
/*
320320
Description:

src/adjoint/DAModel/DAModel.H

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ public:
106106
void updateIntermediateVariables();
107107

108108
/// return the value of the production term from the turbulence model
109-
void getTurbProdTerm(scalarList& prodTerm) const;
109+
void getTurbProdTerm(volScalarField& prodTerm) const;
110110

111111
/// return the value of the destruction term from the turbulence model
112-
void getTurbProdOverDestruct(scalarList& PoD) const;
112+
void getTurbProdOverDestruct(volScalarField& PoD) const;
113113

114114
/// return the value of the convective over production term from the turbulence model
115-
void getTurbConvOverProd(scalarList& CoP) const;
115+
void getTurbConvOverProd(volScalarField& CoP) const;
116116

117117
#ifndef SolidDASolver
118118
/// get a reference to DATurbulenceModel

src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void DASpalartAllmaras::getFvMatrixFields(
516516
lower = nuTildaEqn.lower();
517517
}
518518

519-
void DASpalartAllmaras::getTurbProdOverDestruct(scalarList& PoD) const
519+
void DASpalartAllmaras::getTurbProdOverDestruct(volScalarField& PoD) const
520520
{
521521
/*
522522
Description:
@@ -537,7 +537,7 @@ void DASpalartAllmaras::getTurbProdOverDestruct(scalarList& PoD) const
537537
}
538538
}
539539

540-
void DASpalartAllmaras::getTurbConvOverProd(scalarList& CoP) const
540+
void DASpalartAllmaras::getTurbConvOverProd(volScalarField& CoP) const
541541
{
542542
/*
543543
Description:

src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ public:
148148
scalarField& lower);
149149

150150
/// return the value of the destruction term from the turbulence model
151-
virtual void getTurbProdOverDestruct(scalarList& PoD) const;
151+
virtual void getTurbProdOverDestruct(volScalarField& PoD) const;
152152

153153
/// return the value of the convective over production term from the turbulence model
154-
virtual void getTurbConvOverProd(scalarList& CoP) const;
154+
virtual void getTurbConvOverProd(volScalarField& CoP) const;
155155
};
156156

157157
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.C

+2-2
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ void DASpalartAllmarasFv3::getFvMatrixFields(
741741
lower = nuTildaEqn.lower();
742742
}
743743

744-
void DASpalartAllmarasFv3::getTurbProdOverDestruct(scalarList& PoD) const
744+
void DASpalartAllmarasFv3::getTurbProdOverDestruct(volScalarField& PoD) const
745745
{
746746
/*
747747
Description:
@@ -764,7 +764,7 @@ void DASpalartAllmarasFv3::getTurbProdOverDestruct(scalarList& PoD) const
764764
}
765765
}
766766

767-
void DASpalartAllmarasFv3::getTurbConvOverProd(scalarList& CoP) const
767+
void DASpalartAllmarasFv3::getTurbConvOverProd(volScalarField& CoP) const
768768
{
769769
/*
770770
Description:

src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ public:
170170
scalarField& lower);
171171

172172
/// return the value of the destruction term from the turbulence model
173-
virtual void getTurbProdOverDestruct(scalarList& PoD) const;
173+
virtual void getTurbProdOverDestruct(volScalarField& PoD) const;
174174

175175
/// return the value of the convective over production term from the turbulence model
176-
virtual void getTurbConvOverProd(scalarList& CoP) const;
176+
virtual void getTurbConvOverProd(volScalarField& CoP) const;
177177
};
178178

179179
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3FieldInversion.C

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void DASpalartAllmarasFv3FieldInversion::calcResiduals(const dictionary& options
487487
return;
488488
}
489489

490-
void DASpalartAllmarasFv3FieldInversion::getTurbProdTerm(scalarList& prodTerm) const
490+
void DASpalartAllmarasFv3FieldInversion::getTurbProdTerm(volScalarField& prodTerm) const
491491
{
492492
/*
493493
Description:

src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3FieldInversion.H

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public:
159159
virtual void correct(label printToScreen);
160160

161161
/// return the value of the production term from the turbulence model
162-
virtual void getTurbProdTerm(scalarList& prodTerm) const;
162+
virtual void getTurbProdTerm(volScalarField& prodTerm) const;
163163
};
164164

165165
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAModel/DATurbulenceModel/DATurbulenceModel.C

+3-3
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ label DATurbulenceModel::isPrintTime(
480480
}
481481
}
482482

483-
void DATurbulenceModel::getTurbProdTerm(scalarList& prodTerm) const
483+
void DATurbulenceModel::getTurbProdTerm(volScalarField& prodTerm) const
484484
{
485485
/*
486486
Description:
@@ -492,7 +492,7 @@ void DATurbulenceModel::getTurbProdTerm(scalarList& prodTerm) const
492492
<< abort(FatalError);
493493
}
494494

495-
void DATurbulenceModel::getTurbProdOverDestruct(scalarList& PoD) const
495+
void DATurbulenceModel::getTurbProdOverDestruct(volScalarField& PoD) const
496496
{
497497
/*
498498
Description:
@@ -504,7 +504,7 @@ void DATurbulenceModel::getTurbProdOverDestruct(scalarList& PoD) const
504504
<< abort(FatalError);
505505
}
506506

507-
void DATurbulenceModel::getTurbConvOverProd(scalarList& CoP) const
507+
void DATurbulenceModel::getTurbConvOverProd(volScalarField& CoP) const
508508
{
509509
/*
510510
Description:

src/adjoint/DAModel/DATurbulenceModel/DATurbulenceModel.H

+3-3
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,13 @@ public:
212212
virtual void correct(label printToScreen) = 0;
213213

214214
/// return the value of the production term from the turbulence model
215-
virtual void getTurbProdTerm(scalarList& prodTerm) const;
215+
virtual void getTurbProdTerm(volScalarField& prodTerm) const;
216216

217217
/// return the ratio of the production over destruction term from the turbulence model
218-
virtual void getTurbProdOverDestruct(scalarList& PoD) const;
218+
virtual void getTurbProdOverDestruct(volScalarField& PoD) const;
219219

220220
/// return the value of the convective over production term from the turbulence model
221-
virtual void getTurbConvOverProd(scalarList& CoP) const;
221+
virtual void getTurbConvOverProd(volScalarField& CoP) const;
222222

223223
/// dev terms
224224
tmp<volSymmTensorField> devRhoReff() const;

src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.C

+6-6
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ void DAkEpsilon::getFvMatrixFields(
707707
}
708708
}
709709

710-
void DAkEpsilon::getTurbProdOverDestruct(scalarList& PoD) const
710+
void DAkEpsilon::getTurbProdOverDestruct(volScalarField& PoD) const
711711
{
712712
/*
713713
Description:
@@ -718,16 +718,16 @@ void DAkEpsilon::getTurbProdOverDestruct(scalarList& PoD) const
718718
"kEpsilon:G",
719719
nut_.v() * (dev(twoSymm(tgradU().v())) && tgradU().v()));
720720

721-
volScalarField::Internal P = C1_ * phase_() * rho_() * G * epsilon_() / k_();
722-
volScalarField::Internal D = C2_ * phase_() * rho_() * sqr(epsilon_()) / k_();
721+
volScalarField::Internal P = phase_() * rho_() * G;
722+
volScalarField::Internal D = phase_() * rho_() * epsilon_();
723723

724724
forAll(P, cellI)
725725
{
726726
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
727727
}
728728
}
729729

730-
void DAkEpsilon::getTurbConvOverProd(scalarList& CoP) const
730+
void DAkEpsilon::getTurbConvOverProd(volScalarField& CoP) const
731731
{
732732
/*
733733
Description:
@@ -739,8 +739,8 @@ void DAkEpsilon::getTurbConvOverProd(scalarList& CoP) const
739739
"kEpsilon:G",
740740
nut_.v() * (dev(twoSymm(tgradU().v())) && tgradU().v()));
741741

742-
volScalarField::Internal P = C1_ * phase_() * rho_() * G * epsilon_() / k_();
743-
volScalarField C = fvc::div(phaseRhoPhi_, epsilon_);
742+
volScalarField::Internal P = phase_() * rho_() * G;
743+
volScalarField C = fvc::div(phaseRhoPhi_, k_);
744744

745745
forAll(P, cellI)
746746
{

src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ public:
160160
scalarField& lower);
161161

162162
/// return the value of the destruction term from the turbulence model
163-
virtual void getTurbProdOverDestruct(scalarList& PoD) const;
163+
virtual void getTurbProdOverDestruct(volScalarField& PoD) const;
164164

165165
/// return the value of the convective over production term from the turbulence model
166-
virtual void getTurbConvOverProd(scalarList& CoP) const;
166+
virtual void getTurbConvOverProd(volScalarField& CoP) const;
167167
};
168168

169169
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAModel/DATurbulenceModel/DAkOmega.C

+6-6
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ void DAkOmega::getFvMatrixFields(
708708
}
709709
}
710710

711-
void DAkOmega::getTurbProdOverDestruct(scalarList& PoD) const
711+
void DAkOmega::getTurbProdOverDestruct(volScalarField& PoD) const
712712
{
713713
/*
714714
Description:
@@ -717,16 +717,16 @@ void DAkOmega::getTurbProdOverDestruct(scalarList& PoD) const
717717
tmp<volTensorField> tgradU = fvc::grad(U_);
718718
volScalarField G("kOmega:G", nut_ * (tgradU() && dev(twoSymm(tgradU()))));
719719

720-
volScalarField P = gamma_ * phase_ * rho_ * G * omega_ / k_;
721-
volScalarField D = beta_ * phase_ * rho_ * sqr(omega_);
720+
volScalarField P = phase_ * rho_ * G;
721+
volScalarField D = Cmu_ * phase_ * rho_ * omega_ * k_;
722722

723723
forAll(P, cellI)
724724
{
725725
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
726726
}
727727
}
728728

729-
void DAkOmega::getTurbConvOverProd(scalarList& CoP) const
729+
void DAkOmega::getTurbConvOverProd(volScalarField& CoP) const
730730
{
731731
/*
732732
Description:
@@ -736,8 +736,8 @@ void DAkOmega::getTurbConvOverProd(scalarList& CoP) const
736736
tmp<volTensorField> tgradU = fvc::grad(U_);
737737
volScalarField G("kOmega:G", nut_ * (tgradU() && dev(twoSymm(tgradU()))));
738738

739-
volScalarField P = gamma_ * phase_ * rho_ * G * omega_ / k_;
740-
volScalarField C = fvc::div(phaseRhoPhi_, omega_);
739+
volScalarField P = phase_ * rho_ * G;
740+
volScalarField C = fvc::div(phaseRhoPhi_, k_);
741741

742742
forAll(P, cellI)
743743
{

src/adjoint/DAModel/DATurbulenceModel/DAkOmega.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ public:
167167
scalarField& lower);
168168

169169
/// return the value of the destruction term from the turbulence model
170-
virtual void getTurbProdOverDestruct(scalarList& PoD) const;
170+
virtual void getTurbProdOverDestruct(volScalarField& PoD) const;
171171

172172
/// return the value of the convective over production term from the turbulence model
173-
virtual void getTurbConvOverProd(scalarList& CoP) const;
173+
virtual void getTurbConvOverProd(volScalarField& CoP) const;
174174
};
175175

176176
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.C

+6-14
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ void DAkOmegaSST::getFvMatrixFields(
894894
}
895895
}
896896

897-
void DAkOmegaSST::getTurbProdOverDestruct(scalarList& PoD) const
897+
void DAkOmegaSST::getTurbProdOverDestruct(volScalarField& PoD) const
898898
{
899899
/*
900900
Description:
@@ -909,21 +909,17 @@ void DAkOmegaSST::getTurbProdOverDestruct(scalarList& PoD) const
909909
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);
910910

911911
volScalarField F1(this->F1(CDkOmega));
912-
volScalarField F23(this->F23());
913-
914-
volScalarField::Internal gamma(this->gamma(F1));
915-
volScalarField::Internal beta(this->beta(F1));
916912

917-
volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
918-
volScalarField::Internal D = phase_() * rho_() * beta * sqr(omega_());
913+
volScalarField::Internal P = phase_() * rho_() * Pk(G);
914+
volScalarField::Internal D = phase_() * rho_() * epsilonByk(F1, tgradU()) * k_();
919915

920916
forAll(P, cellI)
921917
{
922918
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
923919
}
924920
}
925921

926-
void DAkOmegaSST::getTurbConvOverProd(scalarList& CoP) const
922+
void DAkOmegaSST::getTurbConvOverProd(volScalarField& CoP) const
927923
{
928924
/*
929925
Description:
@@ -939,13 +935,9 @@ void DAkOmegaSST::getTurbConvOverProd(scalarList& CoP) const
939935
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);
940936

941937
volScalarField F1(this->F1(CDkOmega));
942-
volScalarField F23(this->F23());
943-
944-
volScalarField::Internal gamma(this->gamma(F1));
945-
volScalarField::Internal beta(this->beta(F1));
946938

947-
volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
948-
volScalarField C = fvc::div(phaseRhoPhi_, omega_);
939+
volScalarField::Internal P = phase_() * rho_() * Pk(G);
940+
volScalarField C = fvc::div(phaseRhoPhi_, k_);
949941

950942
forAll(P, cellI)
951943
{

src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ public:
241241
scalarField& lower);
242242

243243
/// return the value of the destruction term from the turbulence model
244-
virtual void getTurbProdOverDestruct(scalarList& PoD) const;
244+
virtual void getTurbProdOverDestruct(volScalarField& PoD) const;
245245

246246
/// return the value of the convective over production term from the turbulence model
247-
virtual void getTurbConvOverProd(scalarList& CoP) const;
247+
virtual void getTurbConvOverProd(volScalarField& CoP) const;
248248
};
249249

250250
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.C

+6-14
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ void DAkOmegaSSTLM::getFvMatrixFields(
14721472
}
14731473
}
14741474

1475-
void DAkOmegaSSTLM::getTurbProdOverDestruct(scalarList& PoD) const
1475+
void DAkOmegaSSTLM::getTurbProdOverDestruct(volScalarField& PoD) const
14761476
{
14771477
/*
14781478
Description:
@@ -1487,21 +1487,17 @@ void DAkOmegaSSTLM::getTurbProdOverDestruct(scalarList& PoD) const
14871487
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);
14881488

14891489
volScalarField F1(this->F1(CDkOmega));
1490-
volScalarField F23(this->F23());
1491-
1492-
volScalarField::Internal gamma(this->gamma(F1));
1493-
volScalarField::Internal beta(this->beta(F1));
14941490

1495-
volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
1496-
volScalarField::Internal D = phase_() * rho_() * beta * sqr(omega_());
1491+
volScalarField::Internal P = phase_() * rho_() * Pk(G);
1492+
volScalarField::Internal D = phase_() * rho_() * epsilonByk(F1, tgradU()) * k_();
14971493

14981494
forAll(P, cellI)
14991495
{
15001496
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
15011497
}
15021498
}
15031499

1504-
void DAkOmegaSSTLM::getTurbConvOverProd(scalarList& CoP) const
1500+
void DAkOmegaSSTLM::getTurbConvOverProd(volScalarField& CoP) const
15051501
{
15061502
/*
15071503
Description:
@@ -1517,13 +1513,9 @@ void DAkOmegaSSTLM::getTurbConvOverProd(scalarList& CoP) const
15171513
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);
15181514

15191515
volScalarField F1(this->F1(CDkOmega));
1520-
volScalarField F23(this->F23());
1521-
1522-
volScalarField::Internal gamma(this->gamma(F1));
1523-
volScalarField::Internal beta(this->beta(F1));
15241516

1525-
volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
1526-
volScalarField C = fvc::div(phaseRhoPhi_, omega_);
1517+
volScalarField::Internal P = phase_() * rho_() * Pk(G);
1518+
volScalarField C = fvc::div(phaseRhoPhi_, k_);
15271519

15281520
forAll(P, cellI)
15291521
{

src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ public:
319319
scalarField& lower);
320320

321321
/// return the value of the destruction term from the turbulence model
322-
virtual void getTurbProdOverDestruct(scalarList& PoD) const;
322+
virtual void getTurbProdOverDestruct(volScalarField& PoD) const;
323323

324324
/// return the value of the convective over production term from the turbulence model
325-
virtual void getTurbConvOverProd(scalarList& CoP) const;
325+
virtual void getTurbConvOverProd(volScalarField& CoP) const;
326326
};
327327

328328
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

0 commit comments

Comments
 (0)