Skip to main content
Version: 0.3.0

FoilState

Everything the solver knows. Scirocco holds one and exposes the common fields through getters; read it directly for the rest. Header scirocco/data/state.h.

struct FoilState {
std::string version = "1.0.0";
Geom geom; // input geometry (xpoint, NACA digits)
Panel foil; // airfoil panel discretization
Panel wake; // wake panel discretization
Oper oper; // operating conditions
Isol isol; // inviscid linear-system data
Vsol vsol; // viscous-system bookkeeping
Glob glob; // global Newton state and Jacobian
Post post; // forces and distributions
Param param; // solver parameters
};

Access via:

FoilState& state = foil.GetState();
state.param.verb = 2;
double cl = state.post.cl;

Sub-structs in detail​

Panel​

The panel discretization. Used for both foil and wake. scirocco/data/panel.h.

FieldShapeMeaning
NintNumber of nodes
x2 × NNode coordinates
sNArc-length at each node
t2 × NUnit tangent at each node

Oper​

Operating conditions, mostly set by SetOper. scirocco/data/oper.h.

FieldDefaultMeaning
Vinf1.0Freestream speed magnitude
alpha0.0Angle of attack, degrees
rho1.0Density
cltgt0.0Target lift coefficient (active when givencl = true)
givenclfalseTrue if the solver should iterate to hit cltgt
initbltrueInitialize the boundary layer at the next solve
viscousfalseViscous (BL-coupled) analysis
redowakefalseRebuild wake after an change
Re1e5Reynolds number
Ma0.0Mach number

Post​

Output quantities, populated by the solver and CalcForce. scirocco/data/post.h.

Scalars:

FieldMeaning
cl, cd, cmForce coefficients
cdf, cdpFriction / pressure drag components
cdpiNear-field inviscid pressure drag
cl_alpha, cdpi_alphaLinearizations w.r.t.

Distributions (Eigen::VectorXd):

FieldMeaning
cp, cpiCompressible and inviscid
cfSkin friction
th, ds, sa, , amplification or
ue, ueiEdge velocity, compressible and inviscid
Ret, Hk and kinematic shape parameter

Post also holds partial Jacobians for the adjoint, such as dcl_dx_partial, cl_V, and cd_V. They're internal.

Param​

Solver parameters. scirocco/data/param.h.

Geom, Isol, Vsol, Glob​

Internal bookkeeping structs:

StructRoleHeader
GeomRaw input point cloud (xpoint) plus NACA-digit stringdata/geom.h
IsolInviscid AIC matrix, solutions, edge-velocity sensitivitiesdata/isol.h
VsolViscous-station bookkeeping (transition indices, station-type masks)data/vsol.h
GlobGlobal Newton state vector , sparse Jacobian , residual, convergence flagdata/glob.h

These belong to the solver kernels and tests.

When to reach below the wrapper​

Common patterns:

// Solver verbosity
foil.GetState().param.verb = 1;

// Non-default transition threshold
foil.GetState().param.ncrit = 11.0;

// Turn off PTC for an A/B comparison
foil.GetState().param.use_ptc = false;

// After solving, inspect through a const reference to preserve cached gradients.
const scirocco::Scirocco& solved = foil;
const Eigen::VectorXd& Hk = solved.GetState().post.Hk;

// Inspect the stored BL residual (not the complete coupled residual).
double rnorm = solved.GetState().glob.R.norm();

Writing to glob.U or the Jacobian directly is outside the supported API; the unit tests show how it's done.

Watch the Newton iteration​

glob.iteration_observer is an optional callback that the coupled viscous solve calls at every Newton iteration, after the residual and forces are evaluated and before the convergence test. It receives the state and the 0-based iteration number. From iteration 1 on, glob.dU holds the step that produced the current glob.U and glob.relax the under-relaxation factor applied to it. The callback reads the state; it must not modify it, and it does not change the solve. fauXFOIL uses it to print XFOIL's iteration lines.

scirocco::Scirocco foil("2412", 160);
foil.SetOper(4.0, -1.0, 1.0e6, 0.0);
foil.GetState().glob.iteration_observer =
[](const scirocco::FoilState& s, int iteration) {
std::printf("%3d CL = %.4f CD = %.5f\n", iteration, s.post.cl,
s.post.cd);
};
foil.Solve();

Glob::relax and Glob::iteration_observer are declared in data/glob.h.