Suppose we have a diffusion equation
∂t∂T=k(T)∇2T
which we're solving with MOL. We use spectral decomposition
T=∑Tijkpi(x)pj(y)pk(z)
Suppose we want to solve newton's method
(Tti+1−Tti)−Δt(k(T)∇2T)=0
Let us work within a singular element.
At a particular GLL node indexed by ijk, if we
were to use an explicit method then
Tti+1,ijk=Tti,ijk+Δt⎝⎛k(Tijk)⎣⎡ijk∑Tijk(pi′′(xi)p(yj)p(zk)+pi(xi)pj′′(yj)pk(zk)+pi(xi)pj(yj)pk′′(zk))⎦⎤⎠⎞
Working in implicit we get
This is a system of algebraic equations
Gijk(Tlmn)=0
and in order to solve this we must find the matrix (after identifying ijk and lmn with indices)
G with
Gijk,lmn=∂TlmnGijk
and for the above equations this gives
Gijk,lmn=∂Tlmn[(Tti+1,ijk−Tti,ijk)]−Δt(k(Tti+1,ijk)(q∑Tti+1,qjkpq′′(xi)+Tti+1,iqkpq′′(yj)+Tti+1,ijqpq′′(zk)))=δ(ijk,lmn)−Δt(δ(ijk,lmn)k′(Tti+1,ijk)(q∑Tti+1,qjkpq′′(xi)+Tti+1,iqkpq′′(yj)+Tti+1,ijqpq′′(zk))+k(Tti+1,ijk)(δ(jk,mn)pl′′(xi)+δ(ik,ln)pm′′(yj)+δ(ij,lm)pn′′(zk)))
with δ(xyz,αβγ) is a kronecker delta operating on tuples (x,y,z) and (α,β,γ)
We use the split from the glass paper:
000pguess=ρt+Δt[u^−ut]+Δt(ρt+Δt(u^⋅∇u^)+ν(Tt+Δt)∇2u^+∇pguess−g)=Tt+Δt−Tt+Δt(u^⋅∇Tt+Δt+κ∇2Tt+Δt)=ρt+Δt−ρt+Δt(u^⋅∇ρt+Δt)=pt+βΔtρt1∇⋅u^
Repeat until converged.
0=∇⋅u^−Δt∇2[pt+Δt−pguess]+τ∇2pt+Δt
Then a final non-divergent form
0=ρt+Δt[ut+Δt−u^]+Δt(ρt+Δt(ut+Δt⋅∇ut+Δt)+∇(pt+Δt−pguess)))
Note that τ≡(h2∥u∥+h24ν(T))−1
lagrangian SE decomposition
For a test of the curvilinear differential operators, we start with a position function a(x) which maps the unit cube [−1,1]3 to itself
with some sort of curvature. Let's try the function
x↦∥x∥∞∥x∥2+1−∥x∥∞∥x∥∞x
Note: I think I've finally determined how to do covariant/contravariant vectors? Note that the euclidean structure into which our manifold is embedded gives us that for
physical vectors u,v then ⟨u,v⟩=upvp. Note that this site
gives that g=J⊤J. This seems to indicate that covariant uα=u⊤(J−1)⊤ and uα=J−1u
which gives
⟨uα,vα⟩=u⊤(J−1)⊤gJ−1v=u⊤(J−1)⊤J⊤JJ−1v=u⊤v
GMRES
We'll use the wikipedia writeup as a starting point,
Suppose we have a system A~x=b~
and in order to conform to the wikipidia conventions we use the modified equation (∥b∥−1A~)x=∥b∥−1b~⟹Ax=b
We want to find a basis for the Krylov subspace
Kn=span(r0,Ar0,A2r0,…,An−1r0)
where r0=b−Ax0.
We use the convention that q0=∥r0∥2−1r0 to do the Arnoldi iteration. That is
for k=1,n−1
qk=Aqk−1
for j=1,k−1
hj,k−1=⟨qj,qk⟩
qk=qk−hj,k−1qj
hk,k−1=∥qk∥
qk=hk,k−1qk
If we let Qn have as columns the qn computed above,
the wikipedia page gives the form AQn=Qn+1Hn
where the Hi,j coefficients are drawn from the
hj,k−1 given above. This is a good checkpoint in the code to make sure I'm on the right track.
Let β=∥r0∥, then we need to find the vector that minimizes ∥b−Axn∥
which can be found to be equivalent to minimizing ∥Hnyn−βe1,n+1∥
QR decomposition
We wish to find
ΩnH~n=R~n
where R~n=[Rn0]
to account for the fact that H~n is an (n+1)×n matrix.
In the subroutine where we update Ωn, we are given Ωn, H~n, hn+1,n+2 (which comes from the arnoldi iteration), hn+2.
Define
H~n+1=[H~n0hn+1hn+1,n+2]
Note that [Ωn001]H~n+1=⎣⎡Rn00rn+1ρσ⎦⎤
where rn+1, ρ and σ can be computed by matrix-vector products, I think.
Assuming we have cn=ρ2+σ2ρsn=ρ2+σ2σ.
define the Givens rotation Gn=⎣⎡In000cn−sn0sncn⎦⎤Ωn+1=Gn[Ωn001]
and under this definition we find
Ωn+1H~n+1=⎣⎡Rn00rn+1ρ2+σ20⎦⎤
(this doesn't need to be computed, but can be verified as a check.)
Therefore writing
βΩne1=[gnξ]
then we find that Rnyn=gn
Need: Q, H, Ω, and R
At a given step:
Do arnoldi iteration to calculate hn+1, hn+1,n+2 and qn+1.
Update H~ to form H~n+1
Update R to form Rn+1 via calculating rn+1,ρ, and σ.
Calculate Givens rotation Gn and use to compute Ωn+1 (possibly can be done without storing Ωn).
Use βΩn+1e1 to calculate gn and then compute Rn+1yn+1=gn+1
How to derive the matrix for an operator?
Suppose we have a subroutine f(x_i) which takes a vector x_i and populates a vector y_i satisfying Ax=y. Then if we just rewrite any
intermediate operators that comprise A and apply the first operator to I instead of x, then we will be able to populate our matrix.