Skip to content
Snippets Groups Projects
Verified Commit b579c340 authored by Paul Dechamps's avatar Paul Dechamps :speech_balloon:
Browse files

(format) Switch to format 14 in code

parent 0b739292
No related branches found
No related tags found
1 merge request!1BLASTER v1.0
Pipeline #50746 passed
This diff is collapsed.
...@@ -7,153 +7,162 @@ ...@@ -7,153 +7,162 @@
#include <algorithm> #include <algorithm>
namespace blast { namespace blast
{
/** /**
* @brief Boundary layer region upper/lower side or wake. * @brief Boundary layer region upper/lower side or wake.
* @author Paul Dechamps * @author Paul Dechamps
*/ */
class BLAST_API BoundaryLayer : public fwk::wSharedObject { class BLAST_API BoundaryLayer : public fwk::wSharedObject
{
private: private:
unsigned int const nVar = unsigned int const nVar =
5; ///< Number of variables of the partial differential problem. 5; ///< Number of variables of the partial differential problem.
double nCrit = 9.0; ///< Critical amplification factor. double nCrit = 9.0; ///< Critical amplification factor.
public: public:
Closures *closSolver; ///< Closure relations class. Closures *closSolver; ///< Closure relations class.
std::string name; ///< Name of the region. std::string name; ///< Name of the region.
// Mesh // Mesh
size_t nNodes; ///< Number of points in the domain. size_t nNodes; ///< Number of points in the domain.
size_t nElms; ///< Number of cells in the domain. size_t nElms; ///< Number of cells in the domain.
std::vector<double> x; ///< x coordinate in the global frame of reference. std::vector<double> x; ///< x coordinate in the global frame of reference.
std::vector<double> y; ///< y coordinate in the global frame of reference. std::vector<double> y; ///< y coordinate in the global frame of reference.
std::vector<double> z; ///< z coordinate in the global frame of reference. std::vector<double> z; ///< z coordinate in the global frame of reference.
std::vector<double> xoc; ///< x/c coordinate in the global frame of reference. std::vector<double> xoc; ///< x/c coordinate in the global frame of reference.
std::vector<double> loc; ///< xi coordinate in the local frame of reference. std::vector<double> loc; ///< xi coordinate in the local frame of reference.
std::vector<int> rows; ///< Reference numbers of the nodes. std::vector<int> rows; ///< Reference numbers of the nodes.
std::vector<int> no; ///< Reference numbers of the nodes. std::vector<int> no; ///< Reference numbers of the nodes.
std::vector<double> dx; ///< Cell size. std::vector<double> dx; ///< Cell size.
std::vector<double> alpha; ///< Angle of the cell wrt the x axis of the global std::vector<double> alpha; ///< Angle of the cell wrt the x axis of the global
///< frame of reference. ///< frame of reference.
double chord; ///< Chord of the section. double chord; ///< Chord of the section.
double xMin; ///< Minimum x coordinate of the mesh (for local coordinates double xMin; ///< Minimum x coordinate of the mesh (for local coordinates
///< computation). ///< computation).
// Boundary layer variables. // Boundary layer variables.
std::vector<double> u; ///< Solution vector (theta, H, N, ue, Ct). std::vector<double> u; ///< Solution vector (theta, H, N, ue, Ct).
std::vector<double> std::vector<double>
Ret; ///< Reynolds number based on the momentum thickness (theta). Ret; ///< Reynolds number based on the momentum thickness (theta).
std::vector<double> cd; ///< Local dissipation coefficient. std::vector<double> cd; ///< Local dissipation coefficient.
std::vector<double> cf; ///< Local friction coefficient. std::vector<double> cf; ///< Local friction coefficient.
std::vector<double> std::vector<double>
Hstar; ///< Kinetic energy shape parameter (thetaStar/theta). Hstar; ///< Kinetic energy shape parameter (thetaStar/theta).
std::vector<double> std::vector<double>
Hstar2; ///< Density shape parameter (deltaStarStar/theta). Hstar2; ///< Density shape parameter (deltaStarStar/theta).
std::vector<double> Hk; ///< Kinematic shape parameter (int(1-u/ue d_eta)). std::vector<double> Hk; ///< Kinematic shape parameter (int(1-u/ue d_eta)).
std::vector<double> std::vector<double>
ctEq; ///< Equilibrium shear stress coefficient (turbulent BL). ctEq; ///< Equilibrium shear stress coefficient (turbulent BL).
std::vector<double> us; ///< Equivalent normalized wall slip velocity. std::vector<double> us; ///< Equivalent normalized wall slip velocity.
std::vector<double> delta; ///< Boundary layer thickness. std::vector<double> delta; ///< Boundary layer thickness.
std::vector<double> std::vector<double>
deltaStar; ///< Displacement thickness (int(1-rho*u/rhoe*ue d_eta)). deltaStar; ///< Displacement thickness (int(1-rho*u/rhoe*ue d_eta)).
std::vector<double> Me; ///< Mach number. std::vector<double> Me; ///< Mach number.
std::vector<double> vt; ///< Velocity. std::vector<double> vt; ///< Velocity.
std::vector<double> rhoe; ///< Density. std::vector<double> rhoe; ///< Density.
std::vector<double> xxExt; ///< xi coordinate in the local frame of reference, std::vector<double> xxExt; ///< xi coordinate in the local frame of reference,
///< at the edge of the boundary layer. ///< at the edge of the boundary layer.
std::vector<double> deltaStarExt; ///< Displacement thickness. std::vector<double> deltaStarExt; ///< Displacement thickness.
std::vector<double> vtExt; ///< Previous velocity. std::vector<double> vtExt; ///< Previous velocity.
std::vector<double> blowingVelocity; ///< Blowing velocity. std::vector<double> blowingVelocity; ///< Blowing velocity.
// Transition related variables. // Transition related variables.
std::vector<int> regime; ///< Laminar (0) or turbulent (1) regime. std::vector<int> regime; ///< Laminar (0) or turbulent (1) regime.
size_t transitionNode; ///< Node id of the transition location. size_t transitionNode; ///< Node id of the transition location.
double xtrF; ///< Forced transition location in the local frame of reference double xtrF; ///< Forced transition location in the local frame of reference
///< (x/c). ///< (x/c).
double xtr; ///< Transition location in the local frame of reference (x/c). double xtr; ///< Transition location in the local frame of reference (x/c).
BoundaryLayer(double _xtrF = -1.0, std::string _name = "None"); BoundaryLayer(double _xtrF = -1.0, std::string _name = "None");
~BoundaryLayer(); ~BoundaryLayer();
void reset(); void reset();
// Getters // Getters
std::string getName() const { return name; }; std::string getName() const { return name; };
size_t getnNodes() const { return nNodes; }; size_t getnNodes() const { return nNodes; };
size_t getnElms() const { return nElms; }; size_t getnElms() const { return nElms; };
std::vector<double> getDeltaStar() const { return deltaStar; }; std::vector<double> getDeltaStar() const { return deltaStar; };
std::vector<double> getUe() const { std::vector<double> getUe() const
std::vector<double> ue(nNodes, 0.); {
for (size_t i = 0; i < nNodes; ++i) std::vector<double> ue(nNodes, 0.);
ue[i] = u[i * nVar + 3]; for (size_t i = 0; i < nNodes; ++i)
return ue; ue[i] = u[i * nVar + 3];
}; return ue;
std::vector<double> getBlowing() const { return blowingVelocity; }; };
double getMaxMach() const { return *std::max_element(Me.begin(), Me.end()); }; std::vector<double> getBlowing() const { return blowingVelocity; };
double getMaxMach() const { return *std::max_element(Me.begin(), Me.end()); };
// Setters
void setMesh(std::vector<double> const _x, std::vector<double> const y, // Setters
std::vector<double> const z, double const _chord, void setMesh(std::vector<double> const _x, std::vector<double> const y,
double const _xMin, std::vector<double> const z, double const _chord,
std::vector<int> const _rows = std::vector<int>(0), double const _xMin,
std::vector<int> const _no = std::vector<int>(0)); std::vector<int> const _rows = std::vector<int>(0),
void computeLocalCoordinates(); std::vector<int> const _no = std::vector<int>(0));
void setMe(std::vector<double> const _Me) { void computeLocalCoordinates();
if (_Me.size() != nNodes) void setMe(std::vector<double> const _Me)
throw std::runtime_error("Mach number vector is not consistent."); {
Me = _Me; if (_Me.size() != nNodes)
}; throw std::runtime_error("Mach number vector is not consistent.");
void setVt(std::vector<double> const _vt) { Me = _Me;
if (_vt.size() != nNodes) };
throw std::runtime_error("Velocity vector is not consistent."); void setVt(std::vector<double> const _vt)
vt = _vt; {
}; if (_vt.size() != nNodes)
void setRhoe(std::vector<double> const _rhoe) { throw std::runtime_error("Velocity vector is not consistent.");
if (_rhoe.size() != nNodes) vt = _vt;
throw std::runtime_error("Density vector is not consistent."); };
rhoe = _rhoe; void setRhoe(std::vector<double> const _rhoe)
}; {
void setxxExt(std::vector<double> const _xxExt) { if (_rhoe.size() != nNodes)
if (_xxExt.size() != nNodes) throw std::runtime_error("Density vector is not consistent.");
throw std::runtime_error("External mesh vector is not consistent."); rhoe = _rhoe;
xxExt = _xxExt; };
}; void setxxExt(std::vector<double> const _xxExt)
void setDeltaStarExt(std::vector<double> const _deltaStarExt) { {
if (_deltaStarExt.size() != nNodes) if (_xxExt.size() != nNodes)
throw std::runtime_error( throw std::runtime_error("External mesh vector is not consistent.");
"Displacement thickness vector is not consistent."); xxExt = _xxExt;
deltaStarExt = _deltaStarExt; };
}; void setDeltaStarExt(std::vector<double> const _deltaStarExt)
void setVtExt(std::vector<double> const _vtExt) { {
if (_vtExt.size() != nNodes) if (_deltaStarExt.size() != nNodes)
throw std::runtime_error("Velocity vector is not consistent."); throw std::runtime_error(
vtExt = _vtExt; "Displacement thickness vector is not consistent.");
}; deltaStarExt = _deltaStarExt;
void setxtrF(double const _xtrF) { xtrF = _xtrF; }; };
void setVtExt(std::vector<double> const _vtExt)
// Boundary conditions. {
void setStagnationBC(double Re); if (_vtExt.size() != nNodes)
void setWakeBC(double Re, std::vector<double> upperConditions, throw std::runtime_error("Velocity vector is not consistent.");
std::vector<double> lowerConditions); vtExt = _vtExt;
};
// Getters. void setxtrF(double const _xtrF) { xtrF = _xtrF; };
size_t getnVar() const { return nVar; };
double getnCrit() const { return nCrit; }; // Boundary conditions.
void setnCrit(double const _nCrit) { nCrit = _nCrit; }; void setStagnationBC(double Re);
void setWakeBC(double Re, std::vector<double> upperConditions,
// Others std::vector<double> lowerConditions);
void printSolution(size_t iPoint) const;
void computeBlowingVelocity(); // Getters.
std::vector<std::vector<double>> evalGradwrtRho(); size_t getnVar() const { return nVar; };
std::vector<std::vector<double>> evalGradwrtVt(); double getnCrit() const { return nCrit; };
std::vector<std::vector<double>> evalGradwrtDeltaStar(); void setnCrit(double const _nCrit) { nCrit = _nCrit; };
std::vector<std::vector<double>> evalGradwrtX();
std::vector<std::vector<double>> evalGradwrtY(); // Others
void printSolution(size_t iPoint) const;
void computeBlowingVelocity();
std::vector<std::vector<double>> evalGradwrtRho();
std::vector<std::vector<double>> evalGradwrtVt();
std::vector<std::vector<double>> evalGradwrtDeltaStar();
std::vector<std::vector<double>> evalGradwrtX();
std::vector<std::vector<double>> evalGradwrtY();
}; };
} // namespace blast } // namespace blast
#endif // DBOUNDARYLAYER_H #endif // DBOUNDARYLAYER_H
...@@ -16,66 +16,72 @@ using namespace blast; ...@@ -16,66 +16,72 @@ using namespace blast;
*/ */
void Closures::laminarClosures(std::vector<double> &closureVars, double theta, void Closures::laminarClosures(std::vector<double> &closureVars, double theta,
double H, double Ret, const double Me, double H, double Ret, const double Me,
const std::string name) { const std::string name)
H = std::max(H, 1.00005); {
H = std::max(H, 1.00005);
// Kinematic shape factor H*.
double Hk = (H - 0.29 * Me * Me) / (1 + 0.113 * Me * Me); // Kinematic shape factor H*.
if (name == "wake") double Hk = (H - 0.29 * Me * Me) / (1 + 0.113 * Me * Me);
Hk = std::max(Hk, 1.00005); if (name == "wake")
else Hk = std::max(Hk, 1.00005);
Hk = std::max(Hk, 1.05000); else
Hk = std::max(Hk, 1.05000);
// Density shape parameter.
double Hstar2 = (0.064 / (Hk - 0.8) + 0.251) * Me * Me; // Density shape parameter.
double Hstar2 = (0.064 / (Hk - 0.8) + 0.251) * Me * Me;
// Boundary layer thickness.
double delta = std::min((3.15 + H + (1.72 / (Hk - 1))) * theta, 12 * theta); // Boundary layer thickness.
double delta = std::min((3.15 + H + (1.72 / (Hk - 1))) * theta, 12 * theta);
double Hstar = 0.;
double Hks = Hk - 4.35; double Hstar = 0.;
if (Hk <= 4.35) double Hks = Hk - 4.35;
Hstar = 0.0111 * Hks * Hks / (Hk + 1) - if (Hk <= 4.35)
0.0278 * Hks * Hks * Hks / (Hk + 1) + 1.528 - Hstar = 0.0111 * Hks * Hks / (Hk + 1) -
0.0002 * (Hks * Hk) * (Hks * Hk); 0.0278 * Hks * Hks * Hks / (Hk + 1) + 1.528 -
else 0.0002 * (Hks * Hk) * (Hks * Hk);
Hstar = 1.528 + 0.015 * Hks * Hks / Hk; else
Hstar = 1.528 + 0.015 * Hks * Hks / Hk;
// Whitfield's minor additional compressibility correction.
Hstar = (Hstar + 0.028 * Me * Me) / (1 + 0.014 * Me * Me); // Whitfield's minor additional compressibility correction.
Hstar = (Hstar + 0.028 * Me * Me) / (1 + 0.014 * Me * Me);
// Friction coefficient.
double tmp = 0.; // Friction coefficient.
double cf = 0.; double tmp = 0.;
if (Hk < 5.5) { double cf = 0.;
tmp = (5.5 - Hk) * (5.5 - Hk) * (5.5 - Hk) / (Hk + 1.0); if (Hk < 5.5)
cf = (-0.07 + 0.0727 * tmp) / Ret; {
} else if (Hk >= 5.5) { tmp = (5.5 - Hk) * (5.5 - Hk) * (5.5 - Hk) / (Hk + 1.0);
tmp = 1.0 - 1.0 / (Hk - 4.5); cf = (-0.07 + 0.0727 * tmp) / Ret;
cf = (-0.07 + 0.015 * tmp * tmp) / Ret; }
} else if (Hk >= 5.5)
{
// Dissipation coefficient. tmp = 1.0 - 1.0 / (Hk - 4.5);
double Cd = 0.; cf = (-0.07 + 0.015 * tmp * tmp) / Ret;
if (Hk < 4) }
Cd = (0.00205 * std::pow(4.0 - Hk, 5.5) + 0.207) * (Hstar / (2 * Ret));
else { // Dissipation coefficient.
double HkCd = (Hk - 4) * (Hk - 4); double Cd = 0.;
double denCd = 1 + 0.02 * HkCd; if (Hk < 4)
Cd = (-0.0016 * HkCd / denCd + 0.207) * (Hstar / (2 * Ret)); Cd = (0.00205 * std::pow(4.0 - Hk, 5.5) + 0.207) * (Hstar / (2 * Ret));
} else
{
// Wake relations. double HkCd = (Hk - 4) * (Hk - 4);
if (name == "wake") { double denCd = 1 + 0.02 * HkCd;
Cd = 2 * (1.10 * (1.0 - 1.0 / Hk) * (1.0 - 1.0 / Hk) / Hk) * Cd = (-0.0016 * HkCd / denCd + 0.207) * (Hstar / (2 * Ret));
(Hstar / (2 * Ret)); }
cf = 0.;
} // Wake relations.
if (name == "wake")
double us = 0.; {
double ctEq = 0.; Cd = 2 * (1.10 * (1.0 - 1.0 / Hk) * (1.0 - 1.0 / Hk) / Hk) *
(Hstar / (2 * Ret));
closureVars = {Hstar, Hstar2, Hk, cf, Cd, delta, ctEq, us}; cf = 0.;
}
double us = 0.;
double ctEq = 0.;
closureVars = {Hstar, Hstar2, Hk, cf, Cd, delta, ctEq, us};
} }
/** /**
...@@ -91,113 +97,117 @@ void Closures::laminarClosures(std::vector<double> &closureVars, double theta, ...@@ -91,113 +97,117 @@ void Closures::laminarClosures(std::vector<double> &closureVars, double theta,
*/ */
void Closures::turbulentClosures(std::vector<double> &closureVars, double theta, void Closures::turbulentClosures(std::vector<double> &closureVars, double theta,
double H, double Ct, double Ret, double H, double Ct, double Ret,
const double Me, const std::string name) { const double Me, const std::string name)
H = std::max(H, 1.00005); {
Ct = std::min(Ct, 0.3); H = std::max(H, 1.00005);
// Ct = std::max(std::min(Ct, 0.30), 0.0000001); Ct = std::min(Ct, 0.3);
// Ct = std::max(std::min(Ct, 0.30), 0.0000001);
double Hk = (H - 0.29 * Me * Me) / (1. + 0.113 * Me * Me);
if (name == "wake") double Hk = (H - 0.29 * Me * Me) / (1. + 0.113 * Me * Me);
Hk = std::max(Hk, 1.00005); if (name == "wake")
else Hk = std::max(Hk, 1.00005);
Hk = std::max(Hk, 1.05000); else
Hk = std::max(Hk, 1.05000);
double Hstar2 = ((0.064 / (Hk - 0.8)) + 0.251) * Me * Me;
double gamma = 1.4 - 1.; double Hstar2 = ((0.064 / (Hk - 0.8)) + 0.251) * Me * Me;
double Fc = std::sqrt(1. + 0.5 * gamma * Me * Me); double gamma = 1.4 - 1.;
double Fc = std::sqrt(1. + 0.5 * gamma * Me * Me);
double H0 = 0.;
if (Ret <= 400.) double H0 = 0.;
H0 = 4.0; if (Ret <= 400.)
else H0 = 4.0;
H0 = 3. + (400. / Ret); else
if (Ret <= 200.) H0 = 3. + (400. / Ret);
Ret = 200.; if (Ret <= 200.)
Ret = 200.;
double Hstar = 0.;
if (Hk <= H0) double Hstar = 0.;
Hstar = if (Hk <= H0)
((0.5 - 4. / Ret) * ((H0 - Hk) / (H0 - 1.)) * ((H0 - Hk) / (H0 - 1.))) * Hstar =
(1.5 / (Hk + 0.5)) + ((0.5 - 4. / Ret) * ((H0 - Hk) / (H0 - 1.)) * ((H0 - Hk) / (H0 - 1.))) *
1.5 + 4. / Ret; (1.5 / (Hk + 0.5)) +
else
Hstar = (Hk - H0) * (Hk - H0) *
(0.007 * std::log(Ret) /
((Hk - H0 + 4. / std::log(Ret)) *
(Hk - H0 + 4. / std::log(Ret))) +
0.015 / Hk) +
1.5 + 4. / Ret; 1.5 + 4. / Ret;
else
Hstar = (Hk - H0) * (Hk - H0) *
(0.007 * std::log(Ret) /
((Hk - H0 + 4. / std::log(Ret)) *
(Hk - H0 + 4. / std::log(Ret))) +
0.015 / Hk) +
1.5 + 4. / Ret;
// Whitfield's minor additional compressibility correction.
Hstar = (Hstar + 0.028 * Me * Me) / (1. + 0.014 * Me * Me);
double logRt = std::log(Ret / Fc);
logRt = std::max(logRt, 3.0);
double arg = std::max(-1.33 * Hk, -20.0);
// Equivalent normalized wall slip velocity.
double us = (Hstar / 2.) * (1. - 4. * (Hk - 1.) / (3. * H));
// Boundary layer thickness.
double delta = std::min((3.15 + H + (1.72 / (Hk - 1.))) * theta, 12. * theta);
double Ctcon = 0.5 / (6.7 * 6.7 * 0.75);
double Hkc = 0.;
double Cdw = 0.;
double Cdd = 0.;
double Cdl = 0.;
double Hmin = 0.;
double Fl = 0.;
double Dfac = 0.;
double cf = 0.;
double Cd = 0.;
double n = 1.0;
double ctEq = 0.;
if (name == "wake")
{
if (us > 0.99995)
us = 0.99995;
n = 2.0; // two wake halves
cf = 0.0; // no friction inside the wake
Hkc = Hk - 1.;
Cdw = 0.0; // Wall contribution.
Cdd = (0.995 - us) * Ct * Ct; // Turbulent outer layer contribution.
Cdl = 0.15 * (0.995 - us) * (0.995 - us) /
Ret; // Laminar stress contribution to outer layer.
ctEq = std::sqrt(4. * Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5.
}
else
{
if (us > 0.95)
us = 0.98;
n = 1.0;
cf = (1 / Fc) *
(0.3 * std::exp(arg) * std::pow(logRt / 2.3026, (-1.74 - 0.31 * Hk)) +
0.00011 * (std::tanh(4. - (Hk / 0.875)) - 1.));
Hkc = std::max(Hk - 1. - 18. / Ret, 0.01);
// Dissipation coefficient.
Hmin = 1. + 2.1 / std::log(Ret);
Fl = (Hk - 1.) / (Hmin - 1);
Dfac = 0.5 + 0.5 * std::tanh(Fl);
Cdw = 0.5 * (cf * us) * Dfac;
Cdd = (0.995 - us) * Ct * Ct;
Cdl = 0.15 * (0.995 - us) * (0.995 - us) / Ret;
ctEq = std::sqrt(Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5
// ctEq = std::sqrt(Hstar * 0.015/(1-us) * (Hk-1)*(Hk-1)*(Hk-1)/(Hk*Hk*H));
// // Drela 1987
}
if (n * Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
((1. - us) * (Hk * Hk) * H) <
0.)
std::cout << "Negative sqrt encountered " << std::endl;
// Whitfield's minor additional compressibility correction.
Hstar = (Hstar + 0.028 * Me * Me) / (1. + 0.014 * Me * Me);
double logRt = std::log(Ret / Fc);
logRt = std::max(logRt, 3.0);
double arg = std::max(-1.33 * Hk, -20.0);
// Equivalent normalized wall slip velocity.
double us = (Hstar / 2.) * (1. - 4. * (Hk - 1.) / (3. * H));
// Boundary layer thickness.
double delta = std::min((3.15 + H + (1.72 / (Hk - 1.))) * theta, 12. * theta);
double Ctcon = 0.5 / (6.7 * 6.7 * 0.75);
double Hkc = 0.;
double Cdw = 0.;
double Cdd = 0.;
double Cdl = 0.;
double Hmin = 0.;
double Fl = 0.;
double Dfac = 0.;
double cf = 0.;
double Cd = 0.;
double n = 1.0;
double ctEq = 0.;
if (name == "wake") {
if (us > 0.99995)
us = 0.99995;
n = 2.0; // two wake halves
cf = 0.0; // no friction inside the wake
Hkc = Hk - 1.;
Cdw = 0.0; // Wall contribution.
Cdd = (0.995 - us) * Ct * Ct; // Turbulent outer layer contribution.
Cdl = 0.15 * (0.995 - us) * (0.995 - us) /
Ret; // Laminar stress contribution to outer layer.
ctEq = std::sqrt(4. * Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5.
} else {
if (us > 0.95)
us = 0.98;
n = 1.0;
cf = (1 / Fc) *
(0.3 * std::exp(arg) * std::pow(logRt / 2.3026, (-1.74 - 0.31 * Hk)) +
0.00011 * (std::tanh(4. - (Hk / 0.875)) - 1.));
Hkc = std::max(Hk - 1. - 18. / Ret, 0.01);
// Dissipation coefficient. // Dissipation coefficient.
Hmin = 1. + 2.1 / std::log(Ret); Cd = n * (Cdw + Cdd + Cdl);
Fl = (Hk - 1.) / (Hmin - 1); closureVars = {Hstar, Hstar2, Hk, cf, Cd, delta, ctEq, us};
Dfac = 0.5 + 0.5 * std::tanh(Fl);
Cdw = 0.5 * (cf * us) * Dfac;
Cdd = (0.995 - us) * Ct * Ct;
Cdl = 0.15 * (0.995 - us) * (0.995 - us) / Ret;
ctEq = std::sqrt(Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5
// ctEq = std::sqrt(Hstar * 0.015/(1-us) * (Hk-1)*(Hk-1)*(Hk-1)/(Hk*Hk*H));
// // Drela 1987
}
if (n * Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
((1. - us) * (Hk * Hk) * H) <
0.)
std::cout << "Negative sqrt encountered " << std::endl;
// Dissipation coefficient.
Cd = n * (Cdw + Cdd + Cdl);
closureVars = {Hstar, Hstar2, Hk, cf, Cd, delta, ctEq, us};
} }
/** /**
...@@ -213,65 +223,69 @@ void Closures::turbulentClosures(std::vector<double> &closureVars, double theta, ...@@ -213,65 +223,69 @@ void Closures::turbulentClosures(std::vector<double> &closureVars, double theta,
*/ */
void Closures::turbulentClosures(double &closureVars, double theta, double H, void Closures::turbulentClosures(double &closureVars, double theta, double H,
double Ct, double Ret, const double Me, double Ct, double Ret, const double Me,
const std::string name) { const std::string name)
H = std::max(H, 1.00005); {
Ct = std::min(Ct, 0.3); H = std::max(H, 1.00005);
Ct = std::min(Ct, 0.3);
double Hk = (H - 0.29 * Me * Me) / (1 + 0.113 * Me * Me);
if (name == "wake") double Hk = (H - 0.29 * Me * Me) / (1 + 0.113 * Me * Me);
Hk = std::max(Hk, 1.00005); if (name == "wake")
else Hk = std::max(Hk, 1.00005);
Hk = std::max(Hk, 1.05000); else
Hk = std::max(Hk, 1.05000);
double H0 = 0.;
if (Ret <= 400.) double H0 = 0.;
H0 = 4.0; if (Ret <= 400.)
else H0 = 4.0;
H0 = 3. + (400. / Ret); else
if (Ret <= 200.) H0 = 3. + (400. / Ret);
Ret = 200.; if (Ret <= 200.)
Ret = 200.;
double Hstar = 0.;
if (Hk <= H0) double Hstar = 0.;
Hstar = if (Hk <= H0)
((0.5 - 4. / Ret) * ((H0 - Hk) / (H0 - 1.)) * ((H0 - Hk) / (H0 - 1.))) * Hstar =
(1.5 / (Hk + 0.5)) + ((0.5 - 4. / Ret) * ((H0 - Hk) / (H0 - 1.)) * ((H0 - Hk) / (H0 - 1.))) *
1.5 + 4. / Ret; (1.5 / (Hk + 0.5)) +
else
Hstar = (Hk - H0) * (Hk - H0) *
(0.007 * std::log(Ret) /
((Hk - H0 + 4. / std::log(Ret)) *
(Hk - H0 + 4. / std::log(Ret))) +
0.015 / Hk) +
1.5 + 4. / Ret; 1.5 + 4. / Ret;
else
// Whitfield's minor additional compressibility correction. Hstar = (Hk - H0) * (Hk - H0) *
Hstar = (Hstar + 0.028 * Me * Me) / (1. + 0.014 * Me * Me); (0.007 * std::log(Ret) /
((Hk - H0 + 4. / std::log(Ret)) *
// Equivalent normalized wall slip velocity. (Hk - H0 + 4. / std::log(Ret))) +
double us = (Hstar / 2.) * (1 - 4 * (Hk - 1.) / (3. * H)); 0.015 / Hk) +
1.5 + 4. / Ret;
double Ctcon = 0.5 / (6.7 * 6.7 * 0.75);
// Whitfield's minor additional compressibility correction.
double Hkc = 0.; Hstar = (Hstar + 0.028 * Me * Me) / (1. + 0.014 * Me * Me);
double ctEq = 0.;
// Equivalent normalized wall slip velocity.
if (name == "wake") { double us = (Hstar / 2.) * (1 - 4 * (Hk - 1.) / (3. * H));
if (us > 0.99995)
us = 0.99995; double Ctcon = 0.5 / (6.7 * 6.7 * 0.75);
Hkc = Hk - 1.;
ctEq = std::sqrt(4. * Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) / double Hkc = 0.;
((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5 double ctEq = 0.;
} else {
if (us > 0.95) if (name == "wake")
us = 0.98; {
Hkc = std::max(Hk - 1. - 18. / Ret, 0.01); if (us > 0.99995)
ctEq = std::sqrt(Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) / us = 0.99995;
((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5 Hkc = Hk - 1.;
} ctEq = std::sqrt(4. * Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
if (Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) / ((1. - us) * (Hk * Hk) * H) < ((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5
0.) }
std::cout << "Negative sqrt encountered " << std::endl; else
{
closureVars = ctEq; if (us > 0.95)
us = 0.98;
Hkc = std::max(Hk - 1. - 18. / Ret, 0.01);
ctEq = std::sqrt(Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) /
((1. - us) * (Hk * Hk) * H)); // Here it is ctEq^0.5
}
if (Hstar * Ctcon * ((Hk - 1.) * Hkc * Hkc) / ((1. - us) * (Hk * Hk) * H) <
0.)
std::cout << "Negative sqrt encountered " << std::endl;
closureVars = ctEq;
} }
\ No newline at end of file
...@@ -5,24 +5,26 @@ ...@@ -5,24 +5,26 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace blast { namespace blast
{
/** /**
* @brief Boundary layer closure relations. * @brief Boundary layer closure relations.
* @author Paul Dechamps * @author Paul Dechamps
*/ */
class BLAST_API Closures { class BLAST_API Closures
{
public: public:
static void laminarClosures(std::vector<double> &closureVars, double theta, static void laminarClosures(std::vector<double> &closureVars, double theta,
double H, double Ret, const double Me, double H, double Ret, const double Me,
const std::string name);
static void turbulentClosures(std::vector<double> &closureVars, double theta,
double H, double Ct, double Ret, double Me,
const std::string name);
static void turbulentClosures(double &closureVars, double theta, double H,
double Ct, double Ret, const double Me,
const std::string name); const std::string name);
static void turbulentClosures(std::vector<double> &closureVars, double theta,
double H, double Ct, double Ret, double Me,
const std::string name);
static void turbulentClosures(double &closureVars, double theta, double H,
double Ct, double Ret, const double Me,
const std::string name);
}; };
} // namespace blast } // namespace blast
#endif // DCLOSURES_H #endif // DCLOSURES_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -5,65 +5,68 @@ ...@@ -5,65 +5,68 @@
#include "blast.h" #include "blast.h"
#include "wObject.h" #include "wObject.h"
#include "wTimers.h" #include "wTimers.h"
namespace blast { namespace blast
{
/** /**
* @brief Boundary layer solver driver. Performs the space marching and set up * @brief Boundary layer solver driver. Performs the space marching and set up
* time marching for each point. * time marching for each point.
* @authors Paul Dechamps * @authors Paul Dechamps
*/ */
class BLAST_API Driver : public fwk::wSharedObject { class BLAST_API Driver : public fwk::wSharedObject
{
public: public:
double Cdt; ///< Total drag coefficient. double Cdt; ///< Total drag coefficient.
double Cdf; ///< Total friction drag coefficient. double Cdf; ///< Total friction drag coefficient.
double Cdp; ///< Total pressure drag coefficient. double Cdp; ///< Total pressure drag coefficient.
std::vector<double> Cdt_sec; ///< Sectional total drag coefficient. std::vector<double> Cdt_sec; ///< Sectional total drag coefficient.
std::vector<double> Cdf_sec; ///< Sectional friction drag coefficient. std::vector<double> Cdf_sec; ///< Sectional friction drag coefficient.
std::vector<double> Cdp_sec; ///< Sectional pressure drag coefficient. std::vector<double> Cdp_sec; ///< Sectional pressure drag coefficient.
std::vector<std::vector<BoundaryLayer *>> std::vector<std::vector<BoundaryLayer *>>
sections; ///< Boundary layer regions sorted by section. sections; ///< Boundary layer regions sorted by section.
unsigned int verbose; ///< Verbosity level of the solver 0<=verbose<=1. unsigned int verbose; ///< Verbosity level of the solver 0<=verbose<=1.
private: private:
double Re; ///< Freestream Reynolds number. double Re; ///< Freestream Reynolds number.
double CFL0; ///< Initial CFL number for pseudo time integration. double CFL0; ///< Initial CFL number for pseudo time integration.
double span; ///< Wing Span (Used only for drag computation, not used if 2D double span; ///< Wing Span (Used only for drag computation, not used if 2D
///< case). ///< case).
Solver *tSolver; ///< Pseudo-time solver. Solver *tSolver; ///< Pseudo-time solver.
int solverExitCode; ///< Exit code of viscous calculations. int solverExitCode; ///< Exit code of viscous calculations.
std::vector<std::vector<std::vector<size_t>>> std::vector<std::vector<std::vector<size_t>>>
convergenceStatus; ///< Vector containing points that did not converged. convergenceStatus; ///< Vector containing points that did not converged.
protected: protected:
fwk::Timers tms; ///< Internal timers fwk::Timers tms; ///< Internal timers
public: public:
Driver(double _Re, double _Minf, double _CFL0, size_t nSections, Driver(double _Re, double _Minf, double _CFL0, size_t nSections,
double xtrF_top = -1., double xtrF_bot = -1., double _span = 0., double xtrF_top = -1., double xtrF_bot = -1., double _span = 0.,
unsigned int _verbose = 1); unsigned int _verbose = 1);
~Driver(); ~Driver();
int run(); int run();
void reset(); void reset();
// Getters. // Getters.
double getAverageTransition(size_t const iRegion) const; double getAverageTransition(size_t const iRegion) const;
double getRe() const { return Re; }; double getRe() const { return Re; };
std::vector<std::vector<double>> getSolution(size_t iSec); std::vector<std::vector<double>> getSolution(size_t iSec);
// Setters. // Setters.
void setVerbose(unsigned int _verbose) { verbose = _verbose; }; void setVerbose(unsigned int _verbose) { verbose = _verbose; };
void addSection(size_t iSec, BoundaryLayer *&bl) { void addSection(size_t iSec, BoundaryLayer *&bl)
sections[iSec].push_back(bl); {
}; sections[iSec].push_back(bl);
};
private: private:
void checkWaves(size_t iPoint, BoundaryLayer *bl); void checkWaves(size_t iPoint, BoundaryLayer *bl);
void averageTransition(size_t iPoint, BoundaryLayer *bl, bool forced); void averageTransition(size_t iPoint, BoundaryLayer *bl, bool forced);
void computeSectionalDrag(std::vector<BoundaryLayer *> const &bl, size_t i); void computeSectionalDrag(std::vector<BoundaryLayer *> const &bl, size_t i);
void computeTotalDrag(); void computeTotalDrag();
void computeBlwVel(); void computeBlwVel();
int outputStatus(double maxMach) const; int outputStatus(double maxMach) const;
}; };
} // namespace blast } // namespace blast
#endif // DDRIVER_H #endif // DDRIVER_H
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -34,7 +34,8 @@ ...@@ -34,7 +34,8 @@
/** /**
* @brief Namespace for blast module * @brief Namespace for blast module
*/ */
namespace blast { namespace blast
{
// Solvers // Solvers
class Driver; class Driver;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment