105 Eigen::VectorXd CLHistory;
106 index CLHistorySize = 0;
107 index CLHistoryHead = 0;
108 index CLAtTargetAcc = 0;
114 void PushCL_(
real CL)
116 CLHistoryHead = mod<index>(CLHistoryHead + 1, CLHistory.size());
117 CLHistory(CLHistoryHead) = CL;
143 auto assertOnAxisString = [](
const std::string &ax)
146 DNDS_assert(std::set<std::string>({
"x",
"y",
"z"}).count(ax) == 1);
148 assertOnAxisString(settings.
AOAAxis);
149 assertOnAxisString(settings.
CL0Axis);
150 assertOnAxisString(settings.
CD0Axis);
195 if (CLHistorySize >= CLHistory.size() && CLHistorySize >= settings.
nIterConvergeMin)
197 real curCL = CLHistory.mean();
200 real maxCLDeviation = std::max(CLHistory.maxCoeff() - curCL, curCL - CLHistory.minCoeff());
201 if (maxCLDeviation <= currentCLThreshold)
203 real CLSlope = (lastCL - CL) / (lastAOA - AOA);
206 CLSlope = CLSlopeStandard;
209 CLSlope = CLSlopeStandard;
214 CLSlope = std::min(CLSlope, 10 * CLSlopeStandard);
215 CLSlope = std::max(CLSlope, 0.9 * CLSlopeStandard);
227 log() << fmt::format(
"=== CLDriver at iter [{}], CL converged = [{}+-{:.1e}], CLSlope = [{}], newAOA [{}]",
228 iter, curCL, maxCLDeviation, CLSlope, AOA)
265 else if (settings.
AOAAxis ==
"y")
288 else if (settings.
CL0Axis ==
"z")
pybind11-style configuration registration with macro-based field declaration and namespace-scoped tag...
#define DNDS_FIELD(name_, desc_,...)
Register a field inside a DNDS_DECLARE_CONFIG body.
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
#define DNDS_assert_info(expr, info)
Debug-only assertion with an extra std::string info message.
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
JSON-to-Eigen conversion utilities and nlohmann_json helper macros.
MPI wrappers: MPIInfo, collective operations, type mapping, CommStrategy.
Lift-coefficient driver controller.
void Update(index iter, real CL, const MPIInfo &mpi)
Main driver update — call once per solver iteration.
real GetAOA()
Get the current angle of attack.
Geom::tPoint GetCL0Direction()
Get the unit vector for the zero-AoA lift direction.
Geom::tPoint GetCD0Direction()
Get the unit vector for the zero-AoA drag direction.
bool ConvergedAtTarget()
Check whether the long-window convergence criterion is satisfied.
Geom::tGPoint GetAOARotation()
Compute the rotation matrix that rotates the freestream from AoA = 0 to the current AoA.
real GetForce2CoeffRatio()
Compute the multiplicative factor that converts an integrated force to a non-dimensional aerodynamic ...
CLDriver(const CLDriverSettings &settingsIn)
Construct a CLDriver from the given settings.
EnumValuesTag enum_values(std::vector< std::string > vals)
Create an enum allowed-values tag.
RangeTag range(double min)
Create a minimum-only range constraint.
DNDS_CONSTANT const real pi
π in double precision (matches DNDS_E_PI macro).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
constexpr T sqr(const T &a)
a * a, constexpr. Works for all arithmetic types.
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
std::ostream & log()
Return the current DNDSR log stream (either std::cout or the installed file).
DNDS_CONSTANT const real veryLargeReal
Catch-all upper bound ("practically infinity") for physical scalars.
JSON-configurable settings for the CL (lift coefficient) driver.
std::string CD0Axis
Coordinate axis defining the zero-AoA drag direction ("x", "y", or "z").
real CLIncrementRelax
Under-relaxation factor applied to each AoA increment (0,1]. // reduce each alpha increment.
index CLconvergeWindow
Number of most-recent CL samples in the sliding convergence window.
index CLconvergeLongWindow
Number of consecutive iterations within tolerance required for final (long-window) convergence....
std::string AOAAxis
Coordinate axis about which AoA rotation is applied ("x", "y", or "z").
DNDS_DECLARE_CONFIG(CLDriverSettings)
index nIterConvergeMin
Minimum number of iterations before the CL convergence window is evaluated.
real CLconvergeLongThreshold
CL error tolerance for the long-window converged-at-target check.
real thresholdTargetRatio
Fraction of |targetCL - lastCL| used to tighten the convergence threshold near the target....
real targetCL
Target lift coefficient that the driver attempts to achieve.
real refArea
Reference area for aerodynamic coefficient normalization.
std::string CL0Axis
Coordinate axis defining the zero-AoA lift direction ("x", "y", or "z").
real CLconvergeThreshold
Maximum deviation within the sliding window for CL to be considered converged.
index nIterStartDrive
Solver iteration at which the CL driver becomes active.
real refDynamicPressure
Reference dynamic pressure (0.5 * rho_inf * V_inf^2) for coefficient normalization.
bool CLconvergeLongStrictAoA
If true, reset the long-window counter whenever the AoA is updated.
real AOAInit
Initial angle of attack in degrees.
Lightweight bundle of an MPI communicator and the calling rank's coordinates.