morphogen.homogenization.gpu¶
The FFT solvers of voxel images on the GPU (CuPy; see morphogen.gpu).
The conjugate gradients of the linear solver (morphogen.homogenization.fft) and
the iterations of the loading paths (morphogen.homogenization.fft_nonlinear) run
on the GPU, in double precision:
the stiffness operators of the voxels are applied matrix-free by CUDA kernels, ports of the Numba kernels of
morphogen.homogenization.kernels(one thread per node, so no atomics; the point stresses one thread per voxel), with the element matrices of the materials or the tangents of the points;the Fourier preconditioner is cuFFT transforms and a kernel multiplying the blocks of its inverse symbol, computed on the GPU;
the dot products are reductions of CuPy, without cuBLAS; GMRES, for the full tangents that are not symmetric, keeps its basis on the GPU (the dot products of a Gram-Schmidt pass in one reduction over its rows, the vectors of its deflated restarts combined in place) and its small Hessenberg matrix and harmonic Ritz vectors on the CPU, as the space it recycles from a solve to the next along a path (GCRO-DR).
Along loading paths (VoxelPaths) the arrays of the integration points stay on
the GPU: their measures of strain, the integration of their behaviours (the CUDA kernels
of behaviours.cu, ports of the Numba kernels of von Mises plasticity, crystal
plasticity and the logarithmic strain space, one thread per point), the stresses
conjugate to B-bar and F-bar, the nodal forces and the tangent operator. The Newton
iterations, on the CPU, exchange with the GPU the nodal unknowns, the residuals and the
integrals of the stresses; the outputs of each step take the stresses, the measures and
the cumulated plastic strain of the points back.
- morphogen.homogenization.gpu.dot(a, b) float[source]¶
Dot product of two vectors on the GPU (a CuPy reduction, without cuBLAS).
- morphogen.homogenization.gpu.conjugate_gradient(apply, precondition, rhs, tol, maxiter)[source]¶
Preconditioned conjugate gradient from
x = 0on the GPU, the algorithm ofmorphogen.homogenization.solvers.conjugate_gradient()(minres()after a direction of negative curvature).
- morphogen.homogenization.gpu.gmres(apply, precondition, rhs, tol, maxiter, restart: int = 50, deflate: int = 20, recycle: Recycling | None = None, stagnation: int = 0)[source]¶
GMRES with deflated restarts, preconditioned on the right on the GPU, the algorithm of
morphogen.homogenization.solvers.gmres(): the basis on the GPU (the dot products of a Gram-Schmidt pass in one reduction over its rows, the vectors kept at a deflated restart combined in place), the Hessenberg matrix, its factors and the harmonic Ritz vectors on the CPU;recycleandstagnationas there, the recycled vectors on the GPU.
- morphogen.homogenization.gpu.minres(apply, precondition, rhs, tol, maxiter)[source]¶
Preconditioned MINRES on the GPU, the algorithm of
morphogen.homogenization.solvers.minres().
- class morphogen.homogenization.gpu.FourierPreconditioner(shape, k_ref, nd: int)[source]¶
Bases:
objectThe Fourier preconditioner of
morphogen.homogenization.fft. FourierPreconditioneron the GPU, for the element matrixk_refof the reference medium: its inverse symbol computed on the GPU, the fields component by component, cuFFT transforms of the grid.
- class morphogen.homogenization.gpu.LinearOperator(problem)[source]¶
Bases:
objectThe stiffness operator of the voxels of a linear FFT problem on the GPU (the element matrices of its materials).
- morphogen.homogenization.gpu.solve_linear(problem, rhs, tol: float, maxiter: int)[source]¶
Solution of the linear system of an FFT problem on the GPU: (x, iterations, relative residual),
xon the CPU. The operator and the preconditioner are kept by the problem.
- class morphogen.homogenization.gpu.VoxelPaths(problem: NonlinearFFTProblem)[source]¶
Bases:
_VoxelPathsThe discretization of the loading paths on the voxels (
_VoxelPaths) on the GPU: the arrays of the points (measures of strain, stresses, tangents, internal variables) stay in its memory, where the measures, the behaviours, the stresses conjugate to B-bar and F-bar, the nodal forces and the products by the tangent operator are computed. The weights of the points stay on the CPU (they are uniform).- arrays(n_pts: int, nc: int, width: int) tuple[source]¶
Measures of strain, weights, stresses, tangents and two sets of internal variables of
n_ptspoints (measures and stresses ofnccomponents,widthinternal variables).
- integrate(grads, dtemp, dt, old, new, stress, tangent, guess, ratio) int[source]¶
The behaviours of the points on the GPU (
behaviours.cu), in launches ofchunkpoints that follow their durations, their tangents symmetrized as the problem says.
- stress_scale(sigma, wts) float[source]¶
Integral of the norm of the stresses of the points: the scale of the residuals of the macroscopic unknowns.
- forces(sigma, wts)[source]¶
With B-bar (F-bar), the stresses of the points are first replaced by their conjugates: the outputs report them.
- asymmetry(tangent, wts) float[source]¶
The largest asymmetry of the tangents of the points of the phases (
morphogen.homogenization.nonlinear.asymmetry()), their norms on the GPU.
- symmetrize(tangent) None[source]¶
The tangents of the points replaced by their symmetric parts on the GPU, in place (to the bit those of the kernels that symmetrize them).
- class morphogen.homogenization.gpu.KrylovSolver(operator: VoxelPaths, tol: float, maxiter: int, symmetric: bool = True, recycle: Recycling | None = None)[source]¶
Bases:
objectConjugate gradients of the tangent operator of
VoxelPathson the GPU (GMRES if it is notsymmetric, recycling the space ofrecycleand stopped where it stagnates), with the interface ofmorphogen.homogenization.fft_nonlinear._KrylovSolver(vectors on the CPU).