for a convection-diffusion equation with Dirichlet boundary conditions as follows: $$-u''+qu'=f$$ Using centered difference for $u''$ and $u'$, we get a linear system $$Ax=b$$where matrix $A$ is nonsymetric. Let $H = (A+A')/2,S = (A-A')/2$, we know that matrix $H$ is symmetric positive definite. Given a constant $\alpha>0$, we can get two linear large sparse systems, and $I$ is a identity matrix. $$(\alpha I+H)x_{k+1/2} = b_1$$and $$(\alpha I+S)x_{k+1} = b_2$$
My question is in 3D case, the above two systems are so large and sparse, how to use sin and modified sin transfomation to solve the 2 systems quickly, or some other fast methods, because in matlab, the backslash command '\' tend to be slow for this very large sparse in 3D. Can someone give the matlab codes, thanks very much.
Below is my matlab codes: for n=64 equidistance so slow.
clc;clear;close all
n=64;q=1;
h=1/(n+1);
I = speye(n);
r = q*h/2;
t1 = 6; t2 = -1-r; t3 = -1+r;
Tx = spdiags(ones(n,1).*[t2 t1 t3],[-1 0 1],n,n);
Ty = spdiags(ones(n,1).*[t2 0 t3],[-1 0 1],n,n);
Tz = spdiags(ones(n,1).*[t2 0 t3],[-1 0 1],n,n);
A = kron(Tx,kron(I,I))+kron(I,kron(Ty,I))+kron(I,kron(I,Tz));
H = (A+A')/2; S = (A-A')/2;
lambda_maxH = eigs(H,1,'largestabs');
lambda_minH = eigs(H,1,'smallestabs');
alpha = sqrt(lambda_maxH*lambda_minH);
N = length(A);
I = speye(N);
b = A*ones(N,1);
% this 2 systems are solved so slow
x1 = (alpha*I+H)\b;
x2 = (alpha*I+S)\b;