// Orthotropic plate / shallow-shell strain energy on a regular grid, in energy form (weighted // squares of finite-difference strains, so K = Bᵀ D B is symmetric PSD by construction). // // Bending (Kirchhoff): curvatures κxx = δxx w, κss = δss w at the DOF nodes (3-point second // differences), twist κxs = δx⁺δs⁺ w at cell centres. Energy // U_b = ½ Σ_nodes h² [D11 κxx² + 2 D12 κxx κss + D22 κss²] + ½ Σ_cells h² 4 D66 κxs². // Constrained (OUT) nodes enter the stencils with w = 0 and carry no curvature term themselves: // on a rectangle this is exactly the simply-supported FD plate (the sin·sin modes are discrete // eigenvectors). A stencil that reaches into a HOLE node is dropped and the remaining curvature // gets the free-edge condensed rigidity (e.g. D11 − D12²/D22 when the cross-hole curvature is // free), which approximates a moment-free edge. // // Membrane (shallow shell, Donnell–Marguerre): ε_xx = u_x − z0_xx w, ε_ss = v_s − z0_ss w, // γ = u_s + v_x − 2 z0_xs w, with bilinear (Q4) u, v and 2×2 Gauss integration (no hourglass // modes) and the curvature-coupling term evaluated with the cell-mean w (relieves membrane // locking). This is the Marguerre form ε_xx = u_x + z0_x w_x rewritten with the tangential // displacement ũ = u + z0_x w, identical under the rim condition u = v = w = 0. import { Terms } from "./sparse.ts"; import { HOLE, IN, OUT, type Grid } from "./geometry.ts"; export interface Ortho { t: number; rhoh: number; D11: number; D12: number; D22: number; D66: number; A11: number; A12: number; A22: number; A66: number; } /** Orthotropic plate rigidities, L (grain) along x. nuLR is the major Poisson ratio. */ export function ortho(EL: number, ER: number, G: number, nuLR: number, rho: number, t: number): Ortho { const nuRL = (nuLR * ER) / EL; const den = 1 - nuLR * nuRL; const Q11 = EL / den, Q22 = ER / den, Q12 = (nuLR * ER) / den, Q66 = G; const c3 = (t * t * t) / 12; return { t, rhoh: rho * t, D11: Q11 * c3, D12: Q12 * c3, D22: Q22 * c3, D66: Q66 * c3, A11: Q11 * t, A12: Q12 * t, A22: Q22 * t, A66: Q66 * t }; } /** Eigen-decomposition of [[a, b], [b, c]]: [λ1, v1x, v1y, λ2, v2x, v2y]. */ export function sym2(a: number, b: number, c: number): number[] { const m = 0.5 * (a + c), d = Math.hypot(0.5 * (a - c), b); const l1 = m + d, l2 = m - d; let vx: number, vy: number; if (Math.abs(b) < 1e-300 * (Math.abs(a) + Math.abs(c) + 1)) { if (a >= c) { vx = 1; vy = 0; } else { vx = 0; vy = 1; } } else { vx = b; vy = l1 - a; const nn = Math.hypot(vx, vy); vx /= nn; vy /= nn; } return [l1, vx, vy, l2, -vy, vx]; } function typeAt(g: Grid, i: number, j: number): number { if (i < 0 || j < 0 || i >= g.nx || j >= g.ns) return OUT; return g.type[i * g.ns + j]; } function dofAt(g: Grid, dof: Int32Array, i: number, j: number): number { if (i < 0 || j < 0 || i >= g.nx || j >= g.ns) return -1; return dof[i * g.ns + j]; } /** * Bending energy of a plate on grid g (node types from g.type), w DOFs in wd (−1 = none). * rimRotK: rotational spring per unit length on the normal slope at the rim (each link from a DOF * node to a constrained neighbour contributes ½ k h (w/h)²). */ export function addBending(T: Terms, g: Grid, wd: Int32Array, P: Ortho, group: number, rimRotK: number): void { const h = g.h, area = h * h, ih2 = 1 / (h * h); const [l1, a1, b1, l2, a2, b2] = sym2(P.D11, P.D12, P.D22); const cx = P.D11 - (P.D12 * P.D12) / P.D22; const cs = P.D22 - (P.D12 * P.D12) / P.D11; const idx: number[] = [], coef: number[] = []; for (let i = 0; i < g.nx; i++) for (let j = 0; j < g.ns; j++) { const k = i * g.ns + j; if (g.type[k] !== IN) continue; const hasX = typeAt(g, i - 1, j) !== HOLE && typeAt(g, i + 1, j) !== HOLE; const hasS = typeAt(g, i, j - 1) !== HOLE && typeAt(g, i, j + 1) !== HOLE; const xI = [dofAt(g, wd, i - 1, j), wd[k], dofAt(g, wd, i + 1, j)]; const sI = [dofAt(g, wd, i, j - 1), wd[k], dofAt(g, wd, i, j + 1)]; const st = [ih2, -2 * ih2, ih2]; if (hasX && hasS) { for (const [lam, ax, bx] of [ [l1, a1, b1], [l2, a2, b2], ]) { idx.length = 0; coef.length = 0; for (let q = 0; q < 3; q++) { idx.push(xI[q], sI[q]); coef.push(ax * st[q], bx * st[q]); } T.add(idx, coef, lam * area, group); } } else if (hasX) T.add(xI, st, cx * area, group); else if (hasS) T.add(sI, st, cs * area, group); if (rimRotK > 0) { const nb = [ [i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1], ]; for (const [ii, jj] of nb) if (typeAt(g, ii, jj) === OUT) T.add([wd[k]], [1 / h], rimRotK * h, group); } } // twist at cell centres for (let i = 0; i + 1 < g.nx; i++) for (let j = 0; j + 1 < g.ns; j++) { const t00 = typeAt(g, i, j), t10 = typeAt(g, i + 1, j), t01 = typeAt(g, i, j + 1), t11 = typeAt(g, i + 1, j + 1); if (t00 === HOLE || t10 === HOLE || t01 === HOLE || t11 === HOLE) continue; if (t00 !== IN && t10 !== IN && t01 !== IN && t11 !== IN) continue; T.add( [dofAt(g, wd, i, j), dofAt(g, wd, i + 1, j), dofAt(g, wd, i, j + 1), dofAt(g, wd, i + 1, j + 1)], [ih2, -ih2, -ih2, ih2], 4 * P.D66 * area, group, ); } } /** Arching curvatures at cell centres from the nodal z0 (zero outside the grid). */ export function cellCurvatures(g: Grid): { kxx: Float64Array; kss: Float64Array; kxs: Float64Array } { const { nx, ns, h } = g; const z = (i: number, j: number) => (i < 0 || j < 0 || i >= nx || j >= ns ? 0 : g.z0[i * ns + j]); const nc = (nx - 1) * (ns - 1); const kxx = new Float64Array(nc), kss = new Float64Array(nc), kxs = new Float64Array(nc); const c = 1 / (2 * h * h); for (let i = 0; i + 1 < nx; i++) for (let j = 0; j + 1 < ns; j++) { const k = i * (ns - 1) + j; let sx = 0, ss = 0; for (const jj of [j, j + 1]) sx += (z(i + 2, jj) - z(i + 1, jj) - z(i, jj) + z(i - 1, jj)) * c; for (const ii of [i, i + 1]) ss += (z(ii, j + 2) - z(ii, j + 1) - z(ii, j) + z(ii, j - 1)) * c; kxx[k] = 0.5 * sx; kss[k] = 0.5 * ss; kxs[k] = (z(i + 1, j + 1) - z(i + 1, j) - z(i, j + 1) + z(i, j)) / (h * h); } return { kxx, kss, kxs }; } /** Nodal arching curvature z0_xx (3-point). */ export function nodeKxx(g: Grid, i: number, j: number): number { const z = (ii: number) => (ii < 0 || ii >= g.nx ? 0 : g.z0[ii * g.ns + j]); return (z(i + 1) - 2 * z(i) + z(i - 1)) / (g.h * g.h); } /** Membrane (shallow-shell) energy: Q4 cells with 2×2 Gauss points. */ export function addMembrane(T: Terms, g: Grid, wd: Int32Array, ud: Int32Array, vd: Int32Array, P: Ortho, group: number): void { const { nx, ns, h } = g; const kap = cellCurvatures(g); const [l1, a1, b1, l2, a2, b2] = sym2(P.A11, P.A12, P.A22); const gp = 1 / Math.sqrt(3); const xiA = [-1, 1, -1, 1], etA = [-1, -1, 1, 1]; const wgt = (h * h) / 4; const idx = new Array(12), c1 = new Array(12), c2 = new Array(12), cg = new Array(12); const ca = new Array(12), cb = new Array(12); for (let i = 0; i + 1 < nx; i++) for (let j = 0; j + 1 < ns; j++) { const corners = [ [i, j], [i + 1, j], [i, j + 1], [i + 1, j + 1], ]; let anyIn = false, anyHole = false; for (const [ii, jj] of corners) { const t = typeAt(g, ii, jj); if (t === IN) anyIn = true; if (t === HOLE) anyHole = true; } if (!anyIn || anyHole) continue; const kc = i * (ns - 1) + j; const kxx = kap.kxx[kc], kss = kap.kss[kc], kxs = kap.kxs[kc]; for (let a = 0; a < 4; a++) { const [ii, jj] = corners[a]; idx[a] = dofAt(g, ud, ii, jj); idx[4 + a] = dofAt(g, vd, ii, jj); idx[8 + a] = dofAt(g, wd, ii, jj); } for (const xi of [-gp, gp]) for (const et of [-gp, gp]) { for (let a = 0; a < 4; a++) { const dx = (xiA[a] * (1 + etA[a] * et)) / (2 * h); const ds = (etA[a] * (1 + xiA[a] * xi)) / (2 * h); // ε_xx c1[a] = dx; c1[4 + a] = 0; c1[8 + a] = -0.25 * kxx; // ε_ss c2[a] = 0; c2[4 + a] = ds; c2[8 + a] = -0.25 * kss; // γ cg[a] = ds; cg[4 + a] = dx; cg[8 + a] = -0.5 * kxs; } for (let q = 0; q < 12; q++) { ca[q] = a1 * c1[q] + b1 * c2[q]; cb[q] = a2 * c1[q] + b2 * c2[q]; } T.add(idx, ca, l1 * wgt, group); T.add(idx, cb, l2 * wgt, group); T.add(idx, cg, P.A66 * wgt, group); } } }