Skip to content

Commit

Permalink
Allowed saving features to the disk and fixed a few feature definitio…
Browse files Browse the repository at this point in the history
…ns (#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.
  • Loading branch information
friedenhe committed Apr 11, 2024
1 parent b24b19b commit 8afd2ab
Show file tree
Hide file tree
Showing 29 changed files with 241 additions and 137 deletions.
6 changes: 3 additions & 3 deletions src/adjoint/DAModel/DAModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void DAModel::updateIntermediateVariables()

}

void DAModel::getTurbProdTerm(scalarList& prodTerm) const
void DAModel::getTurbProdTerm(volScalarField& prodTerm) const
{
/*
Description:
Expand All @@ -292,7 +292,7 @@ void DAModel::getTurbProdTerm(scalarList& prodTerm) const

}

void DAModel::getTurbProdOverDestruct(scalarList& PoD) const
void DAModel::getTurbProdOverDestruct(volScalarField& PoD) const
{
/*
Description:
Expand All @@ -314,7 +314,7 @@ void DAModel::getTurbProdOverDestruct(scalarList& PoD) const

}

void DAModel::getTurbConvOverProd(scalarList& CoP) const
void DAModel::getTurbConvOverProd(volScalarField& CoP) const
{
/*
Description:
Expand Down
6 changes: 3 additions & 3 deletions src/adjoint/DAModel/DAModel.H
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ public:
void updateIntermediateVariables();

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

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

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

#ifndef SolidDASolver
/// get a reference to DATurbulenceModel
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.C
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void DASpalartAllmaras::getFvMatrixFields(
lower = nuTildaEqn.lower();
}

void DASpalartAllmaras::getTurbProdOverDestruct(scalarList& PoD) const
void DASpalartAllmaras::getTurbProdOverDestruct(volScalarField& PoD) const
{
/*
Description:
Expand All @@ -537,7 +537,7 @@ void DASpalartAllmaras::getTurbProdOverDestruct(scalarList& PoD) const
}
}

void DASpalartAllmaras::getTurbConvOverProd(scalarList& CoP) const
void DASpalartAllmaras::getTurbConvOverProd(volScalarField& CoP) const
{
/*
Description:
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmaras.H
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ public:
scalarField& lower);

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

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.C
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ void DASpalartAllmarasFv3::getFvMatrixFields(
lower = nuTildaEqn.lower();
}

void DASpalartAllmarasFv3::getTurbProdOverDestruct(scalarList& PoD) const
void DASpalartAllmarasFv3::getTurbProdOverDestruct(volScalarField& PoD) const
{
/*
Description:
Expand All @@ -764,7 +764,7 @@ void DASpalartAllmarasFv3::getTurbProdOverDestruct(scalarList& PoD) const
}
}

void DASpalartAllmarasFv3::getTurbConvOverProd(scalarList& CoP) const
void DASpalartAllmarasFv3::getTurbConvOverProd(volScalarField& CoP) const
{
/*
Description:
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DASpalartAllmarasFv3.H
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ public:
scalarField& lower);

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

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void DASpalartAllmarasFv3FieldInversion::calcResiduals(const dictionary& options
return;
}

void DASpalartAllmarasFv3FieldInversion::getTurbProdTerm(scalarList& prodTerm) const
void DASpalartAllmarasFv3FieldInversion::getTurbProdTerm(volScalarField& prodTerm) const
{
/*
Description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public:
virtual void correct(label printToScreen);

/// return the value of the production term from the turbulence model
virtual void getTurbProdTerm(scalarList& prodTerm) const;
virtual void getTurbProdTerm(volScalarField& prodTerm) const;
};

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
6 changes: 3 additions & 3 deletions src/adjoint/DAModel/DATurbulenceModel/DATurbulenceModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ label DATurbulenceModel::isPrintTime(
}
}

void DATurbulenceModel::getTurbProdTerm(scalarList& prodTerm) const
void DATurbulenceModel::getTurbProdTerm(volScalarField& prodTerm) const
{
/*
Description:
Expand All @@ -492,7 +492,7 @@ void DATurbulenceModel::getTurbProdTerm(scalarList& prodTerm) const
<< abort(FatalError);
}

void DATurbulenceModel::getTurbProdOverDestruct(scalarList& PoD) const
void DATurbulenceModel::getTurbProdOverDestruct(volScalarField& PoD) const
{
/*
Description:
Expand All @@ -504,7 +504,7 @@ void DATurbulenceModel::getTurbProdOverDestruct(scalarList& PoD) const
<< abort(FatalError);
}

void DATurbulenceModel::getTurbConvOverProd(scalarList& CoP) const
void DATurbulenceModel::getTurbConvOverProd(volScalarField& CoP) const
{
/*
Description:
Expand Down
6 changes: 3 additions & 3 deletions src/adjoint/DAModel/DATurbulenceModel/DATurbulenceModel.H
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ public:
virtual void correct(label printToScreen) = 0;

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

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

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

/// dev terms
tmp<volSymmTensorField> devRhoReff() const;
Expand Down
12 changes: 6 additions & 6 deletions src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.C
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ void DAkEpsilon::getFvMatrixFields(
}
}

void DAkEpsilon::getTurbProdOverDestruct(scalarList& PoD) const
void DAkEpsilon::getTurbProdOverDestruct(volScalarField& PoD) const
{
/*
Description:
Expand All @@ -718,16 +718,16 @@ void DAkEpsilon::getTurbProdOverDestruct(scalarList& PoD) const
"kEpsilon:G",
nut_.v() * (dev(twoSymm(tgradU().v())) && tgradU().v()));

volScalarField::Internal P = C1_ * phase_() * rho_() * G * epsilon_() / k_();
volScalarField::Internal D = C2_ * phase_() * rho_() * sqr(epsilon_()) / k_();
volScalarField::Internal P = phase_() * rho_() * G;
volScalarField::Internal D = phase_() * rho_() * epsilon_();

forAll(P, cellI)
{
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
}
}

void DAkEpsilon::getTurbConvOverProd(scalarList& CoP) const
void DAkEpsilon::getTurbConvOverProd(volScalarField& CoP) const
{
/*
Description:
Expand All @@ -739,8 +739,8 @@ void DAkEpsilon::getTurbConvOverProd(scalarList& CoP) const
"kEpsilon:G",
nut_.v() * (dev(twoSymm(tgradU().v())) && tgradU().v()));

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

forAll(P, cellI)
{
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DAkEpsilon.H
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ public:
scalarField& lower);

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

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
12 changes: 6 additions & 6 deletions src/adjoint/DAModel/DATurbulenceModel/DAkOmega.C
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ void DAkOmega::getFvMatrixFields(
}
}

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

volScalarField P = gamma_ * phase_ * rho_ * G * omega_ / k_;
volScalarField D = beta_ * phase_ * rho_ * sqr(omega_);
volScalarField P = phase_ * rho_ * G;
volScalarField D = Cmu_ * phase_ * rho_ * omega_ * k_;

forAll(P, cellI)
{
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
}
}

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

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

forAll(P, cellI)
{
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DAkOmega.H
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ public:
scalarField& lower);

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

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
20 changes: 6 additions & 14 deletions src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.C
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ void DAkOmegaSST::getFvMatrixFields(
}
}

void DAkOmegaSST::getTurbProdOverDestruct(scalarList& PoD) const
void DAkOmegaSST::getTurbProdOverDestruct(volScalarField& PoD) const
{
/*
Description:
Expand All @@ -909,21 +909,17 @@ void DAkOmegaSST::getTurbProdOverDestruct(scalarList& PoD) const
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);

volScalarField F1(this->F1(CDkOmega));
volScalarField F23(this->F23());

volScalarField::Internal gamma(this->gamma(F1));
volScalarField::Internal beta(this->beta(F1));

volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
volScalarField::Internal D = phase_() * rho_() * beta * sqr(omega_());
volScalarField::Internal P = phase_() * rho_() * Pk(G);
volScalarField::Internal D = phase_() * rho_() * epsilonByk(F1, tgradU()) * k_();

forAll(P, cellI)
{
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
}
}

void DAkOmegaSST::getTurbConvOverProd(scalarList& CoP) const
void DAkOmegaSST::getTurbConvOverProd(volScalarField& CoP) const
{
/*
Description:
Expand All @@ -939,13 +935,9 @@ void DAkOmegaSST::getTurbConvOverProd(scalarList& CoP) const
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);

volScalarField F1(this->F1(CDkOmega));
volScalarField F23(this->F23());

volScalarField::Internal gamma(this->gamma(F1));
volScalarField::Internal beta(this->beta(F1));

volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
volScalarField C = fvc::div(phaseRhoPhi_, omega_);
volScalarField::Internal P = phase_() * rho_() * Pk(G);
volScalarField C = fvc::div(phaseRhoPhi_, k_);

forAll(P, cellI)
{
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSST.H
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ public:
scalarField& lower);

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

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down
20 changes: 6 additions & 14 deletions src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.C
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ void DAkOmegaSSTLM::getFvMatrixFields(
}
}

void DAkOmegaSSTLM::getTurbProdOverDestruct(scalarList& PoD) const
void DAkOmegaSSTLM::getTurbProdOverDestruct(volScalarField& PoD) const
{
/*
Description:
Expand All @@ -1487,21 +1487,17 @@ void DAkOmegaSSTLM::getTurbProdOverDestruct(scalarList& PoD) const
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);

volScalarField F1(this->F1(CDkOmega));
volScalarField F23(this->F23());

volScalarField::Internal gamma(this->gamma(F1));
volScalarField::Internal beta(this->beta(F1));

volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
volScalarField::Internal D = phase_() * rho_() * beta * sqr(omega_());
volScalarField::Internal P = phase_() * rho_() * Pk(G);
volScalarField::Internal D = phase_() * rho_() * epsilonByk(F1, tgradU()) * k_();

forAll(P, cellI)
{
PoD[cellI] = P[cellI] / (D[cellI] + 1e-16);
}
}

void DAkOmegaSSTLM::getTurbConvOverProd(scalarList& CoP) const
void DAkOmegaSSTLM::getTurbConvOverProd(volScalarField& CoP) const
{
/*
Description:
Expand All @@ -1517,13 +1513,9 @@ void DAkOmegaSSTLM::getTurbConvOverProd(scalarList& CoP) const
(scalar(2) * alphaOmega2_) * (fvc::grad(k_) & fvc::grad(omega_)) / omega_);

volScalarField F1(this->F1(CDkOmega));
volScalarField F23(this->F23());

volScalarField::Internal gamma(this->gamma(F1));
volScalarField::Internal beta(this->beta(F1));

volScalarField::Internal P = phase_() * rho_() * gamma * GbyNu(GbyNu0, F23(), S2());
volScalarField C = fvc::div(phaseRhoPhi_, omega_);
volScalarField::Internal P = phase_() * rho_() * Pk(G);
volScalarField C = fvc::div(phaseRhoPhi_, k_);

forAll(P, cellI)
{
Expand Down
4 changes: 2 additions & 2 deletions src/adjoint/DAModel/DATurbulenceModel/DAkOmegaSSTLM.H
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,10 @@ public:
scalarField& lower);

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

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

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Expand Down

0 comments on commit 8afd2ab

Please sign in to comment.