偏微分方程算法之二维初边值问题(交替方向隐(ADI)格式)

一、研究对象

        以二维抛物型方程初边值问题为研究对象:

\left\{\begin{matrix} \frac{\partial u(x,y,t)}{\partial t}-(\frac{\partial^{2}u(x,y,t)}{\partial x^{2}}+\frac{\partial^{2}u(x,y,t)}{\partial y^{2}})=f(x,y,t),(x,y)\in \Omega=[0,a]\times [0,b],0<t\leqslant T,\\ u(x,y,0)=\varphi(x,y),(x,y)\in \Omega,\space\space\space\space(1)\\ u(0,y,t)=g_{1}(y,t),u(a,y,t)=g_{2}(y,t),0\leqslant y\leqslant b,0<t\leqslant T,\\ u(x,0,t)=g_{3}(x,t),u(x,b,t)=g_{4}(x,t),0\leqslant x\leqslant a,0<t\leqslant T \end{matrix}\right.

        为了确保连续性,公式(1)中的相关函数满足:

g_{1}(0,t)=g_{3}(0,t),g_1(b,t)=g_4(0,t),

g_{2}(0,t)=g_{3}(a,t),g_{2}(b,t)=g_{4}(a,t)

\varphi(0,y)=g_{1}(y,0),\varphi(a,y)=g_{2}(y,0),

\varphi(x,0)=g_{3}(x,0),\varphi(x,b)=g_{4}(x,0)

二、理论推导

2.1 向前欧拉格式

        首先进行网格剖分。将三维长方体空间(二维位置平面+一维时间轴)进行剖分,将区域[0,a]等分m份,区域[0,b]等分n份,区域[0,T]等分l份,有:

x_{i}=i\cdot \Delta x=\frac{ia}{m},0\leqslant i\leqslant m,

y_{j}=j\cdot \Delta y=\frac{jb}{n},0\leqslant j\leqslant n,t_{k}=k\cdot \Delta t=\frac{kT}{l},0\leqslant k\leqslant l

得到网格节点坐标(x_{i},y_{j},t_{k})。利用数值法求的数值解u(x,y,t)在网格节点(x_{i},y_{j},t_{k})处的近似值u^{k}_{i,j}

        然后将原方程弱化为节点离散方程,即

\left\{\begin{matrix} \frac{\partial u}{\partial t}|_{(x_{i},y_{j},t_{k})}- (\frac{\partial^{2}u}{\partial x^{2}}+\frac{\partial^{2}u}{\partial y^{2}})|_{(x_{i},y_{j},t_{k})}=f(x_{i},y_{j},t_{k}),0\leqslant i\leqslant m,0\leqslant j\leqslant n,0<k\leqslant l,\\ u(x_{i},y_{j},t_{0})=\varphi(x_{i},y_{j}),0\leqslant i \leqslant m,0\leqslant j\leqslant n, \space\space\space\space (2)\\ u(x_{0},y_{j},t_{k})=g_{1}(y_{j},t_{k}),u(x_{m},y_{j},t_{k})=g_{2}(y_{j},t_{k}),0\leqslant j\leqslant n,0<k\leqslant l,\\ u(x_{i},y_{0},t_{k})=g_{3}(x_{i},t_{k}),u(x_{i},y_{n},t_{k})=g_{4}(x_{i},t_{k}),0\leqslant i\leqslant m,0<k\leqslant l \end{matrix}\right.

        然后利用差商代替微商,取

\frac{\partial u}{\partial t}|_{(x_{i},y_{j},t_{k})}\approx \frac{u(x_{i},y_{j},t_{k+1})-u(x_{i},y_{j},t_{k})}{\Delta t}

\frac{\partial^{2}u}{\partial x^{2}}|_{(x_{i},y_{j},t_{k})}\approx \frac{u(x_{i+1},y_{j},t_{k})-2u(x_{i},y_{j},t_{k})+u(x_{i-1},y_{j},t_{k})}{\Delta x^{2}}

\frac{\partial^{2}u}{\partial y^{2}}|_{(x_{i},y_{j},t_{k})}\approx \frac{u(x_{i},y_{j+1},t_{k})-2u(x_{i},y_{j},t_{k})+u(x_{i},y_{j-1},t_{k})}{\Delta y^{2}}

将上面三式代入公式(2),用数值解代替精确解并忽略高阶项,可得数值格式为

\left\{\begin{matrix} \frac{u^{k+1}_{i,j}-u^{k}_{i,j}}{\Delta t}-(\frac{u^{k}_{i+1,j}-2u^{k}_{i,j}+u^{k}_{i-1,j}}{\Delta x^{2}}+\frac{u^{k}_{i,j+1}-2u^{k}_{i,j}+u^{k}_{i,j-1}}{\Delta y^{2}})=f(x_{i},y_{j},t_{k}),1\leqslant i\leqslant m-1,1\leqslant j\leqslant n-1,0\leqslant k\leqslant l-1,\\ u^{0}_{i,j}=\varphi(x_{i},y_{j}),0\leqslant i\leqslant m,0\leqslant j\leqslant n,\\ u^{k}_{0,j}=g_{1}(y_{j},t_{k}),u^{k}_{m,j}=g_{2}(y_{j},t_{k}),0\leqslant j\leqslant n,0<k\leqslant l,\\ u^{k}_{i,0}=g_{3}(x_{i},t_{k}),u^{k}_{i,n}=g_{4}(x_{i},t_{k}),0\leqslant i\leqslant m,0<k\leqslant l \end{matrix}\right.

        记r_{1}=\frac{\Delta t}{\Delta x^{2}},r_{2}=\frac{\Delta t}{\Delta y^{2}},则上式可整理为

\left\{\begin{matrix} u^{k+1}_{i,j}=r_{1}u^{k}_{i-1,j}+r_{1}u^{k}_{i+1,j}+r_{2}u^{k}_{i,j-1}+r_{2}u^{k}_{i,j+1}+(1-2r_{1}-2r_{2})u^{k}_{i,j}+f(x_{i},y_{j},t_{k})\Delta t,1\leqslant i\leqslant m-1,1\leqslant j\leqslant n-1,0\leqslant k\leqslant l-1,\\ u^{0}_{i,j}=\varphi(x_{i},y_{j}),0\leqslant i\leqslant m,0\leqslant j\leqslant n,\space\space\space\space(3)\\ u^{k}_{0,j}=g_{1}(y_{j},t_{k}),u^{k}_{m,j}=g_{2}(y_{j},t_{k}),0\leqslant j\leqslant n,0<k\leqslant l, \\ u^{k}_{i,0}=g_{3}(x_{i},t_{k}),u^{k}_{i,n}=g_{4}(x_{i},t_{k}),0\leqslant i\leqslant m,0<k\leqslant l \end{matrix}\right.

        公式(3)的截断误差为O(\Delta t +\Delta x^{2}+\Delta y^{2}),可证明其稳定性条件为r_{1}+r_{2}\leqslant \frac{1}{2}。可见,时间、空间步长的选择条件苛刻,应用价值不大,需要通过其它方式来降低使用局限性。

2.2 Crank-Nicolson格式

        显格式方法稳定性条件差,尝试采用隐格式来计算。将原节点离散方程公式(2)改为:

\left\{\begin{matrix} \frac{\partial u}{\partial t}|_{(x_{i},y_{j},t_{k+\frac{1}{2}})}- (\frac{\partial^{2}u}{\partial x^{2}}+\frac{\partial^{2}u}{\partial y^{2}})|_{(x_{i},y_{j},t_{k+\frac{1}{2}})}=f(x_{i},y_{j},t_{k+\frac{1}{2}}),0\leqslant i\leqslant m,0\leqslant j\leqslant n,0<k\leqslant l,\\ u(x_{i},y_{j},t_{0})=\varphi(x_{i},y_{j}),0\leqslant i \leqslant m,0\leqslant j\leqslant n, \space\space\space\space (4)\\ u(x_{0},y_{j},t_{k})=g_{1}(y_{j},t_{k}),u(x_{m},y_{j},t_{k})=g_{2}(y_{j},t_{k}),0\leqslant j\leqslant n,0<k\leqslant l,\\ u(x_{i},y_{0},t_{k})=g_{3}(x_{i},t_{k}),u(x_{i},y_{n},t_{k})=g_{4}(x_{i},t_{k}),0\leqslant i\leqslant m,0<k\leqslant l \end{matrix}\right.

        然后利用差商代替微商,取

\frac{\partial u}{\partial t}|_{(x_{i},y_{j},t_{k+\frac{1}{2}})}\approx \frac{u(x_{i},y_{j},t_{k+1})-u(x_{i},y_{j},t_{k})}{\Delta t}

\frac{\partial^{2}u}{\partial x^{2}}|_{(x_{i},y_{j},t_{k+\frac{1}{2}})}\approx \frac{1}{2}[\frac{\partial^{2}u}{\partial x^{2}}|_{(x_{i},y_{j},t_{k})}+\frac{\partial^{2}u}{\partial x^{2}}|_{(x_{i},y_{j},t_{k+1})}]\approx\frac{1}{2}[\frac{u(x_{i+1},y_{j},t_{k})-2u(x_{i},y_{j},t_{k})+u(x_{i-1},y_{j},t_{k})}{\Delta x^{2}}+\frac{u(x_{i+1},y_{j},t_{k+1})-2u(x_{i},y_{j},t_{k+1})+u(x_{i-1},y_{j},t_{k+1})}{\Delta x^{2}}]

\frac{\partial^{2}u}{\partial y^{2}}|_{(x_{i},y_{j},t_{k+\frac{1}{2}})}\approx \frac{1}{2}[\frac{\partial^{2}u}{\partial y^{2}}|_{(x_{i},y_{j},t_{k})}+\frac{\partial^{2}u}{\partial y^{2}}|_{(x_{i},y_{j},t_{k+1})}]\approx\frac{1}{2}[\frac{u(x_{i},y_{j+1},t_{k})-2u(x_{i},y_{j},t_{k})+u(x_{i},y_{j-1},t_{k})}{\Delta y^{2}}+\frac{u(x_{i},y_{j+1},t_{k+1})-2u(x_{i},y_{j},t_{k+1})+u(x_{i},y_{j-1},t_{k+1})}{\Delta y^{2}}]

将上面三式代入公式(4),用数值解代替精确解并忽略高阶项,可得数值格式为

\frac{u^{k+1}_{i,j}-u^{k}_{i,j}}{\Delta t}-\frac{1}{2}(\frac{u^{k+1}_{i+1,j}-2u^{k+1}_{i,j}+u^{k+1}_{i-1,j}+u^{k}_{i+1,j}-2u^{k}_{i,j}+u^{k}_{i-1,j}}{\Delta x^{2}}+\frac{u^{k+1}_{i,j+1}-2u^{k+1}_{i,j}+u^{k+1}_{i,j-1}+u^{k}_{i,j+1}-2u^{k}_{i,j}+u^{k}_{i,j-1}}{\Delta y^{2}})=f(x_{i},y_{j},t_{k+\frac{1}{2}}) \space\space(5)

        上式可整理为

\left\{\begin{matrix} -\frac{r_{1}}{2}u^{k+1}_{i-1,j}+(1+r_{1}+r_{2})u^{k+1}_{i,j}-\frac{r_{1}}{2}u^{k+1}_{i+1,j}-\frac{r_{2}}{2}u^{k+1}_{i,j-1}-\frac{r_{2}}{2}u^{k+1}_{i,j+1}=\\ \frac{r_{1}}{2}u^{k}_{i-1,j}+(1-r_{1}-r_{2})u^{k}_{i,j}+\frac{r_{1}}{2}u^{k}_{i+1,j}+\frac{r_{2}}{2}u^{k}_{i,j-1}+\frac{r_{2}}{2}u^{k}_{i,j+1}+f(x_{i},y_{j},t_{k})\Delta t, \\1\leqslant i\leqslant m-1,1\leqslant j\leqslant n-1,0\leqslant k\leqslant l-1, \\ u^{0}_{i,j}=\varphi(x_{i},y_{j}),0\leqslant i\leqslant m,0\leqslant j\leqslant n,\\ u^{k}_{0,j}=g_{1}(y_{j},t_{k}),u^{k}_{m,j}=g_{2}(y_{j},t_{k}),0\leqslant j\leqslant n,0<k\leqslant l,\\ u^{k}_{i,0}=g_{3}(x_{i},t_{k}),u^{k}_{i,n}=g_{4}(x_{i},t_{k}),0\leqslant i\leqslant m,0<k\leqslant l \end{matrix}\right.

        上式写成矩阵形式为

\begin{pmatrix} -\frac{r_{2}}{2} & & & & \\ & -\frac{r_{2}}{2} & & 0 & \\ & & \vdots & & \\ & 0 & & -\frac{r_{2}}{2} & \\ & & & & -\frac{r_{2}}{2} \end{pmatrix}\begin{pmatrix} u^{k+1}_{1,j-1}\\ u^{k+1}_{2,j-1}\\ \vdots\\ u^{k+1}_{m-2,j-1}\\ u^{k+1}_{m-1,j-1} \end{pmatrix}+\begin{pmatrix} 1+r_{1}+r_{2} & -\frac{r_{1}}{2} & & & \\ -\frac{r_{1}}{2}& 1+r_{1}+r_{2} & -\frac{r_{1}}{2} & 0 & \\ & & \ddots & & \\ & 0 & -\frac{r_{1}}{2} & 1+r_{1}+r_{2} &-\frac{r_{1}}{2} \\ & & & -\frac{r_{1}}{2}& 1+r_{1}+r_{2} \end{pmatrix}\begin{pmatrix} u^{k+1}_{1,j}\\ u^{k+1}_{2,j}\\ \vdots\\ u^{k+1}_{m-2,j}\\ u^{k+1}_{m-1,j} \end{pmatrix}+\begin{pmatrix} -\frac{r_{2}}{2} & & & & \\ & -\frac{r_{2}}{2} & & 0 & \\ & & \vdots & & \\ & 0 & & -\frac{r_{2}}{2} & \\ & & & & -\frac{r_{2}}{2} \end{pmatrix}\begin{pmatrix} u^{k+1}_{1,j+1}\\ u^{k+1}_{2,j+1}\\ \vdots\\ u^{k+1}_{m-2,j+1}\\ u^{k+1}_{m-1,j+1} \end{pmatrix}=\begin{pmatrix} \frac{r_{1}}{2}u^{k}_{0,j}+(1-r_{1}-r_{2})u^{k}_{1,j}+\frac{r_{1}}{2}u^{k}_{2,j}+\frac{r_{2}}{2}u^{k}_{1,j-1}+\frac{r_{2}}{2}u^{k}_{1,j+1}+f(x_{1},y_{j},t_{k+\frac{1}{2}})\Delta t+\frac{r_{1}}{2}u^{k+1}_{0,j}\\ \frac{r_{1}}{2}u^{k}_{1,j}+(1-r_{1}-r_{2})u^{k}_{2,j}+\frac{r_{1}}{2}u^{k}_{3,j}+\frac{r_{2}}{2}u^{k}_{2,j-1}+\frac{r_{2}}{2}u^{k}_{2,j+1}+f(x_{2},y_{j},t_{k+\frac{1}{2}})\Delta t\\ \vdots \\ \frac{r_{1}}{2}u^{k}_{m-3,j}+(1-r_{1}-r_{2})u^{k}_{m-2,j}+\frac{r_{1}}{2}u^{k}_{m-1,j}+\frac{r_{2}}{2}u^{k}_{m-2,j-1}+\frac{r_{2}}{2}u^{k}_{m-2,j+1}+f(x_{m-2},y_{j},t_{k+\frac{1}{2}})\Delta t\\ \frac{r_{1}}{2}u^{k}_{m-2,j}+(1-r_{1}-r_{2})u^{k}_{m-1,j}+\frac{r_{1}}{2}u^{k}_{m,j}+\frac{r_{2}}{2}u^{k}_{m-1,j-1}+\frac{r_{2}}{2}u^{k}_{m-1,j+1}+f(x_{m-1},y_{j},t_{k+\frac{1}{2}})\Delta t+\frac{r_{1}}{2}u^{k+1}_{m,j} \end{pmatrix}

上式为五对角矩阵的线性方程组,求解困难。

2.3 交替方向隐(ADI)格式

        为了分别求解对角矩阵,我们需要用到一个二阶中心差分记号,即算子符合:

\left\{\begin{matrix} \delta ^{2}_{x}u(x_{i},y_{j},t_{k})=u(x_{i-1},y_{j},t_{k})-2u(x_{i},y_{j},t_{k})+u(x_{i+1},y_{j},t_{k})\\ \delta ^{2}_{y}u(x_{i},y_{j},t_{k})=u(x_{i},y_{j-1},t_{k})-2u(x_{i},y_{j},t_{k})+u(x_{i},y_{j+1},t_{k})\\ \delta ^{2}_{t}u(x_{i},y_{j},t_{k-1})=u(x_{i},y_{j},t_{k})-2u(x_{i},y_{j},t_{k})+u(x_{i},y_{j},t_{k+1}) \end{matrix}\right.

及其离散形式:

\left\{\begin{matrix} \delta^{2}_{x}u^{k}_{ij}=u^{k}_{i-1,j}-2u^{k}_{ij}+u^{k}_{i+1,j},\\ \delta^{2}_{y}u^{k}_{ij}=u^{k}_{i,j-1}-2u^{k}_{ij}+u^{k}_{i,j+1},\\ \delta^{2}_{t}u^{k}_{ij}=u^{k-1}_{ij}-2u^{k}_{ij}+u^{k+1}_{ij} \end{matrix}\right.

        利用这些记号,可以将公式(5)写成

\frac{u^{k+1}_{i,j}-u^{k}_{i,j}}{\Delta t}-\frac{1}{2}(\frac{\delta^{2}_{x}u^{k+1}_{i,j}+\delta^{2}_{x}u^{k}_{i,j}}{\Delta x^{2}}+\frac{\delta^{2}_{y}u^{k+1}_{i,j}+\delta^{2}_{y}u^{k}_{i,j}}{\Delta y^{2}})=f(x_{i},y_{j},t_{k+\frac{1}{2}})

整理可得

u^{k+1}_{i,j}-u^{k}_{i,j}-\frac{1}{2}(r_{1}(\delta^{2}_{x}u^{k+1}_{i,j}+\delta^{2}_{x}u^{k}_{i,j})+r_{2}(\delta^{2}_{y}u^{k+1}_{i,j}+\delta^{2}_{y}u^{k}_{i,j}))=f(x_{i},y_{j},t_{k+\frac{1}{2}})\Delta t

再整理,可得

(1-\frac{r_{1}}{2}\delta^{2}_{x}-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}=(1+\frac{r_{1}}{2}\delta^{2}_{x}+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+f(x_{i},y_{j},t_{k+\frac{1}{2}})\Delta t \space\space(6)

        在公式(6)左右两端分别添加辅助项\frac{r_{1}r_{2}}{4}\delta^{2}_{x}\delta^{2}_{y}u^{k+1}_{i,j}\frac{r_{1}r_{2}}{4}\delta^{2}_{x}\delta^{2}_{y}u^{k}_{i,j}。于是Crank-Nicolson格式可以修正为:

(1-\frac{r_{1}}{2}\delta^{2}_{x}-\frac{r_{2}}{2}\delta^{2}_{y}+\frac{r_{1}r_{2}}{4}\delta^{2}_{x}\delta^{2}_{y})u^{k+1}_{i,j}=(1+\frac{r_{1}}{2}\delta^{2}_{x}+\frac{r_{2}}{2}\delta^{2}_{y}+\frac{r_{1}r_{2}}{4}\delta^{2}_{x}\delta^{2}_{y})u^{k}_{i,j}+f(x_{i},y_{j},t_{k+\frac{1}{2}})\Delta t

 即

                    (1-\frac{r_{1}}{2}\delta^{2}_{x})(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}=(1+\frac{r_{1}}{2}\delta^{2}_{x})(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+f^{k+\frac{1}{2}}_{ij}\Delta t

其中,f^{k+\frac{1}{2}}_{i,j}=f(x_{i},y_{j},t_{k+\frac{1}{2}})。为使分解更彻底,上式可以写成

(1-\frac{r_{1}}{2}\delta^{2}_{x})(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}=(1+\frac{r_{1}}{2}\delta^{2}_{x})(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+\frac{1}{2}(1-\frac{r_{1}}{2}\delta^{2}_{x}+1+\frac{r_{1}}{2}\delta^{2}_{x})f^{k+\frac{1}{2}}_{i,j}\Delta t

进一步分解得

(1-\frac{r_{1}}{2}\delta^{2}_{x})[(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}-\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t]=(1+\frac{r_{1}}{2}\delta^{2}_{x})[(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t] \space\space\space\space (7)

        引入中间变量V_{i,j},使公式(7)中最右端方括号内的元素满足:

(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t =(1-\frac{r_{1}}{2}\delta^{2}_{x})V_{i,j} \space\space(8)

        再由于差分算子具有可交换性,由公式(7)有:

(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}-\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t =(1+\frac{r_{1}}{2}\delta^{2}_{x})V_{i,j} \space\space(9)

       2.3.1 Peaceman-Rachford格式

        组合公式(8)和公式(9),可得Peaceman-Rachford格式:

\left\{\begin{matrix} (1-\frac{r_{1}}{2}\delta^{2}_{x})V_{i,j}=(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t \\ (1+\frac{r_{1}}{2}\delta^{2}_{x})V_{i,j}=(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}-\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t \end{matrix}\right.(10)

将公式(10)中两式相减,整理后可得:

V_{i,j}=\frac{1}{2}(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+\frac{1}{2}(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}

从而有:

\left\{\begin{matrix} V_{0,j}=\frac{1}{2}(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{0,j}+\frac{1}{2}(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{0,j}\\ V_{m,j}=\frac{1}{2}(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{m,j}+\frac{1}{2}(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{m,j} \end{matrix}\right.(11)

公式(10)和(11)即为完整的Peaceman-Rachford格式。整个求解过程从k=0第0层开始逐层求解。这种方式是关于x方向和y方向交替求解的隐式方法,称为ADI方法。将其写成差分形式:

\left\{\begin{matrix} -\frac{r_{1}}{2}V_{i-1,j}+(1+r_{1})V_{i,j}-\frac{r_{1}}{2}V_{i+1,j}=\frac{r_{2}}{2}u^{k}_{i,j-1}+(1-r_{2})u^{k}_{i,j}+\frac{r_{2}}{2}u^{k}_{i,j+1}+\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t\\ -\frac{r_{2}}{2}u^{k+1}_{i,j-1}+(1+r_{2})u^{k+1}_{i,j}-\frac{r_{2}}{2}u^{k+1}_{i,j+1}=\frac{r_{1}}{2}(V_{i-1,j}+V_{i+1,j})+(1-r_{1})V_{i,j}+\frac{1}{2}f^{k+\frac{1}{2}}_{i,j}\Delta t \end{matrix}\right.

其中,1\leqslant i\leqslant m-1,1\leqslant j\leqslant n-1,0\leqslant k\leqslant l-1,

\left\{\begin{matrix} V_{0,j}=\frac{1-r_{2}}{2}u^{k}_{0,j}+\frac{1+r_{2}}{2}u^{k+1}_{0,j}+\frac{r_{2}}{4}(u^{k}_{0,j-1}+u^{k}_{0,j+1}-u^{k+1}_{0,j-1}-u^{k+1}_{0,j+1})\\ V_{m,j}=\frac{1-r_{2}}{2}u^{k}_{m,j}+\frac{1+r_{2}}{2}u^{k+1}_{m,j}+\frac{r_{2}}{4}(u^{k}_{m,j-1}+u^{k}_{m,j+1}-u^{k+1}_{m,j-1}-u^{k+1}_{m,j+1}) \end{matrix}\right.

        2.3.2 D’Yakonov格式

        公式        (1-\frac{r_{1}}{2}\delta^{2}_{x})(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}=(1+\frac{r_{1}}{2}\delta^{2}_{x})(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+f^{k+\frac{1}{2}}_{ij}\Delta t还可以分解为:

\left\{\begin{matrix} (1-\frac{r_{1}}{2}\delta^{2}_{x})V_{i,j}=(1+\frac{r_{1}}{2}\delta^{2}_{x})(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+f^{k+\frac{1}{2}}_{i,j}\Delta t\\ (1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}=V_{i,j} \end{matrix}\right.

V_{0,j},V_{m,j}可以直接从上式的第2式中获得:

\left\{\begin{matrix} V_{0,j}=(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{0,j} \\ V_{m,j}=(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{m,j} \end{matrix}\right.

        将其写成差分形式:

\left\{\begin{matrix} -\frac{r_{1}}{2}V_{i-1,j}+(1+r_{1})V_{i,j}-\frac{r_{1}}{2}V_{i+1,j}=\frac{r_{1}(1-r_{2})}{2}(u^{k}_{i-1,j}+u^{k}_{i+1,j}) +\frac{r_{2}(1-r_{1})}{2}(u^{k}_{i,j-1}+u^{k}_{i,j+1}) +\\(1-r_{1})(1-r_{2})u^{k}_{i,j}+f^{k+\frac{1}{2}}_{i,j}\Delta t +\frac{r_{1}r_{2}}{4}(u^{k}_{i-1,j-1}+u^{k}_{i+1,j-1}+u^{k}_{i-1,j+1}+u^{k}_{i+1,j+1}) \\ -\frac{r_{2}}{2}u^{k+1}_{i,j-1}+(1+r_{2})u^{k+1}_{i,j}-\frac{r_{2}}{2}u^{k+1}_{i,j+1}=V_{i,j} \end{matrix}\right.

其中,1\leqslant i\leqslant m-1,1\leqslant j\leqslant n-1,0\leqslant k\leqslant l-1,

\left\{\begin{matrix} V_{0,j}=-\frac{r_{2}}{2}(u^{k+1}_{0,j-1}+u^{k+1}_{0,j+1})+(1+r_{2})u^{k+1}_{0,j} \\ V_{m,j}=-\frac{r_{2}}{2}(u^{k+1}_{m,j-1}+u^{k+1}_{m,j+1})+(1+r_{2})u^{k+1}_{m,j} \end{matrix}\right.

        2.3.3 Douglas格式

          公式        (1-\frac{r_{1}}{2}\delta^{2}_{x})(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}=(1+\frac{r_{1}}{2}\delta^{2}_{x})(1+\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j}+f^{k+\frac{1}{2}}_{ij}\Delta t还可以分解为:

(1-\frac{r_{1}}{2}\delta^{2}_{x})(1-\frac{r_{2}}{2}\delta^{2}_{y})(u^{k+1}_{i,j}-u^{k}_{i,j})=(r_{1}\delta^{2}_{x}+r_{2}\delta^{2}_{y})u^{k}_{i,j}+f^{k+\frac{1}{2}}_{i,j})\Delta t

        借助中间变量V_{i,j}可以分解为下式:

\left\{\begin{matrix} (1-\frac{r_{1}}{2}\delta^{2}_{x})V_{i,j}=(r_{1}\delta^{2}_{x}+r_{2}\delta^{2}_{y})u^{k}_{i,j}+f^{k+\frac{1}{2}}_{i,j}\Delta t \\ (1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{i,j}=V_{i,j}+(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{i,j} \end{matrix}\right.

V_{0,j},V_{m,j}可以直接从上式的第2式中获得:

\left\{\begin{matrix} V_{0,j}=(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{0,j} -(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{0,j} \\ V_{m,j}=(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k+1}_{m,j}-(1-\frac{r_{2}}{2}\delta^{2}_{y})u^{k}_{m,j} \end{matrix}\right.

 将其写成差分形式:

\left\{\begin{matrix} -\frac{r_{1}}{2}V_{i-1,j}+(1+r_{1})V_{i,j}-\frac{r_{1}}{2}V_{i+1,j}=r_{1}(u^{k}_{i-1,j}-2u^{k}_{i,j}+u^{k}_{i+1,j}) +r_{2}(u^{k}_{i,j-1}-2u^{k}_{i,j}+u^{k}_{i,j+1}) +f^{k+\frac{1}{2}}_{i,j}\Delta t \\ -\frac{r_{2}}{2}u^{k+1}_{i,j-1}+(1+r_{2})u^{k+1}_{i,j}-\frac{r_{2}}{2}u^{k+1}_{i,j+1}=V_{i,j} -\frac{r_{2}}{2}(u^{k}_{i,j-1}+u^{k}_{i,j+1})+(1+r_{2})u^{k}_{i,j} \end{matrix}\right.

其中,1\leqslant i\leqslant m-1,1\leqslant j\leqslant n-1,0\leqslant k\leqslant l-1,

\left\{\begin{matrix} V_{0,j}= -\frac{r_{2}}{2}(u^{k+1}_{0,j-1}+u^{k+1}_{0,j+1}-u^{k}_{0,j-1}-u^{k}_{0,j+1})+(1+r_{2})(u^{k+1}_{0,j} - u^{k}_{0,j}) \\ V_{m,j}=-\frac{r_{2}}{2}(u^{k+1}_{m,j-1}+u^{k+1}_{m,j+1}-u^{k}_{m,j-1}-u^{k}_{m,j+1})+(1+r_{2})(u^{k+1}_{m,j} - u^{k}_{m,j}) \end{matrix}\right.

三、算例实现

        二维抛物型方程初边值问题:

\left\{\begin{matrix} \frac{\partial u}{\partial t}-(\frac{\partial^{2}u}{\partial x^{2}}+\frac{\partial^{2}u}{\partial y^{2}})=-\frac{3}{2}e^{(x+y)/2-t},(x,y)\in [0,1]\times[0,1],0<t\leqslant 1,\\ u(x,y,0)=e^{(x+y)/2},(x,y)\in[0,1]\times[0,1],\\ u(0,y,t)=e^{y/2-t},u(1,y,t)=e^{(1+y)/2-t},0\leqslant y\leqslant 1,0<t\leqslant 1,\\ u(x,0,t)=e^{x/2-t},u(x,1,t)=e^{(1+x)/2-t},0\leqslant x\leqslant 1,0<t\leqslant 1 \end{matrix}\right.

已知精确解为u(x,y,t)=e^{(x+y)/2-t}。分别计算两种不同步长条件下的数值解,并输出18个节点处的数值解和误差。【18个点分别为:(0.25i,0.25j,0.50)及(0.25i,0.25j,1.00),其中i,j=1,2,3.】

条件1:\Delta x =\frac{1}{60},\Delta y =\frac{1}{40},\Delta t =\frac{1}{20}

条件2:\Delta x =\frac{1}{120},\Delta y =\frac{1}{80},\Delta t =\frac{1}{40}

3.1 Peaceman-Rachford格式

        代码如下:


#include <cmath>
#include<stdlib.h>
#include<stdio.h>

int main(int argc, char* argv[])
{
        int i, j, k, m, n, L, gap_i, gap_j;
        double a, b, T, r1, r2, dx, dy, dt;
        double  *x, *y, *t, ***u, **v;
        double *a1, *b1, *c1, *d1, *a2, *b2, *c2, *d2, tmid, *ans, temp;
        double f(double x, double y, double t);
        double phi(double x, double y);
        double g1(double y, double t);
        double g2(double y, double t);
        double g3(double x, double t);
        double g4(double x, double t);
        double *chase_algorithm(double *a, double *b, double *c, double *d, int n);
        double exact(double x, double y, double t);

        a=1.0;
        b=1.0;
        T=1.0;
        m=60;
        n=40;
        L=20;
        dx=a/m;
        dy=b/n;
        dt=T/L;
        r1=dt/(dx*dx);
        r2=dt/(dy*dy);
        printf("m=%d, n=%d, L=%d\n", m, n, L);
        printf("r1=%.4f,   r2=%.4f\n", r1, r2);

        x=(double *)malloc(sizeof(double)*(m+1));
        for(i=0;i<=m;i++)
                x[i]=i*dx;

        y=(double *)malloc(sizeof(double)*(n+1));
        for(j=0;j<=n;j++)
                y[j]=j*dy;

        t=(double *)malloc(sizeof(double)*(L+1));
        for(k=0;k<=L;k++)
                t[k]=k*dt;

        u=(double ***)malloc(sizeof(double *)*((m+1)*(n+1)*(L+1)));
        for(i=0;i<=m;i++)
                u[i]=(double **)malloc(sizeof(double *)*((n+1)*(L+1)));
        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                        u[i][j]=(double *)malloc(sizeof(double)*(L+1));
        }
                                                         
        v=(double **)malloc(sizeof(double *)*(m+1));
        for(i=0;i<=m;i++)
                v[i]=(double *)malloc(sizeof(double)*(n+1));

        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                {
                        u[i][j][0]=phi(x[i], y[j]);
                }
        }

        for(k=1;k<=L;k++)
        {
                for(j=0;j<=n;j++)
                {
                         u[0][j][k]=g1(y[j], t[k]);
                         u[m][j][k]=g2(y[j], t[k]);
                }
                for(i=1;i<=m-1;i++)
                {
                         u[i][0][k]=g3(x[i], t[k]);
                         u[i][n][k]=g4(x[i], t[k]);
                }
        }

        a1=(double *)malloc(sizeof(double)*(m-1));
        b1=(double *)malloc(sizeof(double)*(m-1));
        c1=(double *)malloc(sizeof(double)*(m-1));
        d1=(double *)malloc(sizeof(double)*(m-1));
        for(i=0;i<m-1;i++)
        {
                a1[i]=-r1/2.0;
                b1[i]=1.0+r1;
                c1[i]=a1[i];
        }

        a2=(double *)malloc(sizeof(double)*(n-1));
        b2=(double *)malloc(sizeof(double)*(n-1));
        c2=(double *)malloc(sizeof(double)*(n-1));
        d2=(double *)malloc(sizeof(double)*(n-1));
        for(j=0;j<n-1;j++)
        {
                a2[j]=-r2/2.0;
                b2[j]=1.0+r2;
                c2[j]=a2[j];
        }

        for(k=0;k<L;k++)
        {
                tmid=(t[k]+t[k+1])/2.0;
                for(j=1;j<=n-1;j++)
                {
                        for(i=1;i<=m-1;i++)
                                  d1[i-1]=r2*(u[i][j-1][k]+u[i][j+1][k])/2.0+(1.0-r2)*u[i][j][k]+f(x[i], y[j], tmid)*dt/2.0;
                        v[0][j]=(1-r2)*u[0][j][k]/2.0+(1+r2)*u[0][j][k+1]/2.0+r2*(u[0][j-1][k]+u[0][j+1][k]-u[0][j-1][k+1]-u[0][j+1][k+1])/4.0;
                        v[m][j]=(1-r2)*u[m][j][k]/2.0+(1+r2)*u[m][j][k+1]/2.0+r2*(u[m][j-1][k]+u[m][j+1][k]-u[m][j-1][k+1]-u[m][j+1][k+1])/4.0;
                        d1[0]=d1[0]+r1*v[0][j]/2.0;
                        d1[m-2]=d1[m-2]+r1*v[m][j]/2.0;
                        ans=chase_algorithm(a1, b1, c1, d1, m-1);

                        for(i=1;i<=m-1;i++)
                                v[i][j]=ans[i-1];
                        free(ans);
                }

                for(i=1;i<=m-1;i++)
                {
                        for(j=1;j<=n-1;j++)
                                d2[j-1]=r1*(v[i-1][j]+v[i+1][j])/2.0+(1.0-r1)*v[i][j]+f(x[i], y[j], tmid)*dt/2.0;
                        d2[0]=d2[0]+r2*u[i][0][k+1]/2.0;
                        d2[n-2]=d2[n-2]+r2*u[i][n][k+1]/2.0;
                        ans=chase_algorithm(a2, b2, c2, d2, n-1);

                        for(j=1;j<=n-1;j++)
                                u[i][j][k+1]=ans[j-1];
                        free(ans);
                }
        }

        gap_i=m/4;
        gap_j=n/4;

        for(i=gap_i;i<=m-1;i=i+gap_i)
        {
                for(j=gap_j;j<=n-1;j=j+gap_j)
                {
                        temp=fabs(exact(x[i], y[j], T/2.0)-u[i][j][L/2]);
                        printf("(%.2f, %.2f, 0.50)     y=%f,    err=%.4e\n", x[i], y[j], u[i][j][L/2], temp);
                }
        }

        printf("\n");
        printf("\n");

        for(i=gap_i;i<=m-1;i=i+gap_i)
        {
                for(j=gap_j;j<=n-1;j=j+gap_j)
                {
                        temp=fabs(exact(x[i], y[j], T)-u[i][j][L]);
                        printf("(%.2f, %.2f, 1.00)     y=%f,    err=%.4e\n", x[i], y[j], u[i][j][L], temp);
                }
        }

        free(x); free(y); free(t);
        free(a1); free(b1); free(c1); free(d1);
        free(a2); free(b2); free(c2); free(d2);

        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                      free(u[i][j]);
        }
        for(i=0;i<=m;i++)
        {
                free(u[i]); free(v[i]);
        }

        free(u); free(v);

        return 0;
}



double f(double x, double y, double t)
{
        return -3.0*exp((x+y)/2.0-t)/2.0;
}
double phi(double x, double y)
{
        return exp((x+y)/2.0);
}
double g1(double y, double t)
{
        return exp(y/2.0-t);
}
double g2(double y, double t)
{
        return exp((1.0+y)/2.0-t);
}
double g3(double x, double t)
{
        return exp(x/2.0-t);
}
double g4(double x, double t)
{
        return exp((1.0+x)/2.0-t);
}
double * chase_algorithm(double *a, double *b, double *c, double *d, int n)
{
        int i;
        double *ans, *g, *w, p;

        ans=(double *)malloc(sizeof(double)*n);
        g=(double *)malloc(sizeof(double)*n);
        w=(double *)malloc(sizeof(double)*n);
        g[0]=d[0]/b[0];
        w[0]=c[0]/b[0];

        for(i=1;i<n;i++)
        {
                p=b[i]-a[i]*w[i-1];
                g[i]=(d[i]-a[i]*g[i-1])/p;
                w[i]=c[i]/p;
        }

        ans[n-1]=g[n-1];
        i=n-2;
        do
        {
                ans[i]=g[i]-w[i]*ans[i+1];
                i=i-1;
        }while(i>=0);

        free(g);free(w);
        return ans;
}
double exact(double x, double y, double t)
{
        return exp((x+y)/2.0-t);
}

当m=60,n=40,L=20时,结果如下:

m=60, n=40, L=20
r1=180.0000,   r2=80.0000
(0.25, 0.25, 0.50)     y=0.778814,    err=1.2876e-05
(0.25, 0.50, 0.50)     y=0.882514,    err=1.7519e-05
(0.25, 0.75, 0.50)     y=1.000015,    err=1.4611e-05
(0.50, 0.25, 0.50)     y=0.882514,    err=1.7519e-05
(0.50, 0.50, 0.50)     y=1.000024,    err=2.3999e-05
(0.50, 0.75, 0.50)     y=1.133168,    err=1.9757e-05
(0.75, 0.25, 0.50)     y=1.000015,    err=1.4611e-05
(0.75, 0.50, 0.50)     y=1.133168,    err=1.9757e-05
(0.75, 0.75, 0.50)     y=1.284042,    err=1.6707e-05


(0.25, 0.25, 1.00)     y=0.472374,    err=7.8105e-06
(0.25, 0.50, 1.00)     y=0.535272,    err=1.0627e-05
(0.25, 0.75, 1.00)     y=0.606540,    err=8.8626e-06
(0.50, 0.25, 1.00)     y=0.535272,    err=1.0627e-05
(0.50, 0.50, 1.00)     y=0.606545,    err=1.4557e-05
(0.50, 0.75, 1.00)     y=0.687301,    err=1.1984e-05
(0.75, 0.25, 1.00)     y=0.606540,    err=8.8626e-06
(0.75, 0.50, 1.00)     y=0.687301,    err=1.1984e-05
(0.75, 0.75, 1.00)     y=0.778811,    err=1.0134e-05

当m=120,n=80,L=40时,结果如下:

m=120, n=80, L=40
r1=360.0000,   r2=160.0000
(0.25, 0.25, 0.50)     y=0.778804,    err=3.2127e-06
(0.25, 0.50, 0.50)     y=0.882501,    err=4.3716e-06
(0.25, 0.75, 0.50)     y=1.000004,    err=3.6449e-06
(0.50, 0.25, 0.50)     y=0.882501,    err=4.3717e-06
(0.50, 0.50, 0.50)     y=1.000006,    err=5.9884e-06
(0.50, 0.75, 0.50)     y=1.133153,    err=4.9297e-06
(0.75, 0.25, 0.50)     y=1.000004,    err=3.6449e-06
(0.75, 0.50, 0.50)     y=1.133153,    err=4.9297e-06
(0.75, 0.75, 0.50)     y=1.284030,    err=4.1668e-06


(0.25, 0.25, 1.00)     y=0.472369,    err=1.9488e-06
(0.25, 0.50, 1.00)     y=0.535264,    err=2.6518e-06
(0.25, 0.75, 1.00)     y=0.606533,    err=2.2109e-06
(0.50, 0.25, 1.00)     y=0.535264,    err=2.6518e-06
(0.50, 0.50, 1.00)     y=0.606534,    err=3.6325e-06
(0.50, 0.75, 1.00)     y=0.687292,    err=2.9903e-06
(0.75, 0.25, 1.00)     y=0.606533,    err=2.2109e-06
(0.75, 0.50, 1.00)     y=0.687292,    err=2.9902e-06
(0.75, 0.75, 1.00)     y=0.778803,    err=2.5275e-06

3.2 D’Yakonov格式

代码如下:


#include <cmath>
#include <stdlib.h>
#include <stdio.h>


int main(int argc, char* argv[])
{
        int i, j, k, m, n, L, gap_i, gap_j;
        double a, b, T, r1, r2, dx, dy, dt;
        double *x, *y, *t, ***u, **v;
        double *a1, *b1, *c1, *d1, *a2, *b2, *c2, *d2, tmid, *ans, temp;
        double f(double x, double y, double t);
        double phi(double x, double y);
        double g1(double y, double t);
        double g2(double y, double t);
        double g3(double x, double t);
        double g4(double x, double t);
        double *chase_algorithm(double *a, double *b, double *c, double *d, int n);
        double exact(double x, double y, double t);

        a=1.0;
        b=1.0;
        T=1.0;
        m=60;
        n=40;
        L=20;
        dx=a/m;
        dy=b/n;
        dt=T/L;
        r1=dt/(dx*dx);
        r2=dt/(dy*dy);
        printf("m=%d, n=%d, L=%d\n", m, n, L);
        printf("r1=%.4f,   r2=%.4f\n", r1, r2);

        x=(double *)malloc(sizeof(double)*(m+1));
        for(i=0;i<=m;i++)
                x[i]=i*dx;

        y=(double *)malloc(sizeof(double)*(n+1));
        for(j=0;j<=n;j++)
                y[j]=j*dy;
        t=(double *)malloc(sizeof(double)*(L+1));
        for(k=0;k<=L;k++)
                t[k]=k*dt;

        u=(double ***)malloc(sizeof(double *)*((m+1)*(n+1)*(L+1)));
        for(i=0;i<=m;i++)
                u[i]=(double **)malloc(sizeof(double *)*((n+1)*(L+1)));
        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                u[i][j]=(double *)malloc(sizeof(double)*(L+1));
        }
        
        v=(double **)malloc(sizeof(double *)*(m+1));
        for(i=0;i<=m;i++)
                v[i]=(double *)malloc(sizeof(double)*(n+1));

        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                {
                        u[i][j][0]=phi(x[i], y[j]);
                }
        }

        for(k=1;k<=L;k++)
        {
                for(j=0;j<=n;j++)
                {
                        u[0][j][k]=g1(y[j], t[k]);
                        u[m][j][k]=g2(y[j], t[k]);
                }
                for(i=1;i<=m-1;i++)
                {
                        u[i][0][k]=g3(x[i], t[k]);
                        u[i][n][k]=g4(x[i], t[k]);
                }
        }

        a1=(double *)malloc(sizeof(double)*(m-1));
        b1=(double *)malloc(sizeof(double)*(m-1));
        c1=(double *)malloc(sizeof(double)*(m-1));
        d1=(double *)malloc(sizeof(double)*(m-1));
        for(i=0;i<m-1;i++)
        {
                a1[i]=-r1/2.0;
                b1[i]=1.0+r1;
                c1[i]=a1[i];
        }

        a2=(double *)malloc(sizeof(double)*(n-1));
        b2=(double *)malloc(sizeof(double)*(n-1));
        c2=(double *)malloc(sizeof(double)*(n-1));
        d2=(double *)malloc(sizeof(double)*(n-1));
        for(j=0;j<n-1;j++)
        {
                a2[j]=-r2/2.0;
                b2[j]=1.0+r2;
                c2[j]=a2[j];
        }

        for(k=0;k<L;k++)
        {
                tmid=(t[k]+t[k+1])/2.0;
                for(j=1;j<=n-1;j++)
                {
                        for(i=1;i<=m-1;i++)
                        {
                                temp=r2*(1-r1)*(u[i][j-1][k]+u[i][j+1][k])/2.0+r1*(1-r2)*(u[i-1][j][k]+u[i+1][j][k])/2.0+(1-r1)*(1-r2)*u[i][j][k];
                                d1[i-1]=temp+f(x[i], y[j], tmid)*dt+r1*r2*(u[i-1][j-1][k]+u[i+1][j-1][k]+u[i-1][j+1][k]+u[i+1][j+1][k])/4.0;
                        }
                        v[0][j]=(1+r2)*u[0][j][k+1]-r2*(u[0][j-1][k+1]+u[0][j+1][k+1])/2.0;
                        v[m][j]=(1+r2)*u[m][j][k+1]-r2*(u[m][j-1][k+1]+u[m][j+1][k+1])/2.0;
                        d1[0]=d1[0]+r1*v[0][j]/2.0;
                        d1[m-2]=d1[m-2]+r1*v[m][j]/2.0;
                        ans=chase_algorithm(a1, b1, c1, d1, m-1);

                        for(i=1;i<=m-1;i++)
                                v[i][j]=ans[i-1];
                        free(ans);
                }

                for(i=1;i<=m-1;i++)
                {
                        for(j=1;j<=n-1;j++)
                                d2[j-1]=v[i][j];
                        d2[0]=d2[0]+r2*u[i][0][k+1]/2.0;
                        d2[n-2]=d2[n-2]+r2*u[i][n][k+1]/2.0;
                        ans=chase_algorithm(a2, b2, c2, d2, n-1);

                        for(j=1;j<=n-1;j++)
                                u[i][j][k+1]=ans[j-1];

                        free(ans);
                }
        }

        gap_i=m/4;
        gap_j=n/4;

        for(i=gap_i;i<=m-1;i=i+gap_i)
        {
                for(j=gap_j;j<=n-1;j=j+gap_j)
                {
                        temp=fabs(exact(x[i], y[j], T/2.0)-u[i][j][L/2]);
                        printf("(%.2f, %.2f, 0.50)     y=%f,    err=%.4e\n", x[i], y[j], u[i][j][L/2], temp);
                }
        }

        printf("\n");
        printf("\n");

        for(i=gap_i;i<=m-1;i=i+gap_i)
        {
                for(j=gap_j;j<=n-1;j=j+gap_j)
                {
                        temp=fabs(exact(x[i], y[j], T)-u[i][j][L]);
                        printf("(%.2f, %.2f, 1.00)     y=%f,    err=%.4e\n", x[i], y[j], u[i][j][L], temp);
                }
        }

        free(x); free(y); free(t);
        free(a1); free(b1); free(c1); free(d1);
        free(a2); free(b2); free(c2); free(d2);
        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                        free(u[i][j]);
        }

        for(i=0;i<=m;i++)
        {
                free(u[i]);free(v[i]);
        }

        free(u); free(v);

        return 0;
}


double f(double x, double y, double t)
{
        return -3.0*exp((x+y)/2.0-t)/2.0;
}
double phi(double x, double y)
{
        return exp((x+y)/2.0);
}
double g1(double y, double t)
{
        return exp(y/2.0-t);
}
double g2(double y, double t)
{
        return exp((1.0+y)/2.0-t);
}
double g3(double x, double t)
{
        return exp(x/2.0-t);
}
double g4(double x, double t)
{
        return exp((1.0+x)/2.0-t);
}
double *chase_algorithm(double *a, double *b, double *c, double *d, int n)
{
        int i;
        double *ans, *g, *w, p;

        ans=(double *)malloc(sizeof(double)*n);
        g=(double *)malloc(sizeof(double)*n);
        w=(double *)malloc(sizeof(double)*n);
        g[0]=d[0]/b[0];
        w[0]=c[0]/b[0];

        for(i=1;i<n;i++)
        {
                p=b[i]-a[i]*w[i-1];
                g[i]=(d[i]-a[i]*g[i-1])/p;
                w[i]=c[i]/p;
        }

        ans[n-1]=g[n-1];
        i=n-2;
        do
        {
                ans[i]=g[i]-w[i]*ans[i+1];
                i=i-1;
        }while(i>=0);

        free(g); free(w);

        return ans;
}
double exact(double x, double y, double t)
{
        return exp((x+y)/2.0-t);
}

 


当m=60,n=40,L=20时,结果如下:

m=60, n=40, L=20
r1=180.0000,   r2=80.0000
(0.25, 0.25, 0.50)     y=0.778814,    err=1.2876e-05
(0.25, 0.50, 0.50)     y=0.882514,    err=1.7519e-05
(0.25, 0.75, 0.50)     y=1.000015,    err=1.4611e-05
(0.50, 0.25, 0.50)     y=0.882514,    err=1.7519e-05
(0.50, 0.50, 0.50)     y=1.000024,    err=2.3999e-05
(0.50, 0.75, 0.50)     y=1.133168,    err=1.9757e-05
(0.75, 0.25, 0.50)     y=1.000015,    err=1.4611e-05
(0.75, 0.50, 0.50)     y=1.133168,    err=1.9757e-05
(0.75, 0.75, 0.50)     y=1.284042,    err=1.6707e-05


(0.25, 0.25, 1.00)     y=0.472374,    err=7.8105e-06
(0.25, 0.50, 1.00)     y=0.535272,    err=1.0627e-05
(0.25, 0.75, 1.00)     y=0.606540,    err=8.8626e-06
(0.50, 0.25, 1.00)     y=0.535272,    err=1.0627e-05
(0.50, 0.50, 1.00)     y=0.606545,    err=1.4557e-05
(0.50, 0.75, 1.00)     y=0.687301,    err=1.1984e-05
(0.75, 0.25, 1.00)     y=0.606540,    err=8.8626e-06
(0.75, 0.50, 1.00)     y=0.687301,    err=1.1984e-05
(0.75, 0.75, 1.00)     y=0.778811,    err=1.0134e-05

当m=120,n=80,L=40时,结果如下:

m=120, n=80, L=40
r1=360.0000,   r2=160.0000
(0.25, 0.25, 0.50)     y=0.778804,    err=3.2127e-06
(0.25, 0.50, 0.50)     y=0.882501,    err=4.3716e-06
(0.25, 0.75, 0.50)     y=1.000004,    err=3.6449e-06
(0.50, 0.25, 0.50)     y=0.882501,    err=4.3717e-06
(0.50, 0.50, 0.50)     y=1.000006,    err=5.9884e-06
(0.50, 0.75, 0.50)     y=1.133153,    err=4.9297e-06
(0.75, 0.25, 0.50)     y=1.000004,    err=3.6449e-06
(0.75, 0.50, 0.50)     y=1.133153,    err=4.9297e-06
(0.75, 0.75, 0.50)     y=1.284030,    err=4.1668e-06


(0.25, 0.25, 1.00)     y=0.472369,    err=1.9488e-06
(0.25, 0.50, 1.00)     y=0.535264,    err=2.6518e-06
(0.25, 0.75, 1.00)     y=0.606533,    err=2.2109e-06
(0.50, 0.25, 1.00)     y=0.535264,    err=2.6518e-06
(0.50, 0.50, 1.00)     y=0.606534,    err=3.6325e-06
(0.50, 0.75, 1.00)     y=0.687292,    err=2.9903e-06
(0.75, 0.25, 1.00)     y=0.606533,    err=2.2109e-06
(0.75, 0.50, 1.00)     y=0.687292,    err=2.9902e-06
(0.75, 0.75, 1.00)     y=0.778803,    err=2.5275e-06

3.3 Douglas格式

代码如下:


#include <stdlib.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
        int i, j, k, m, n, L, gap_i, gap_j;
        double a, b, T, r1, r2, dx, dy, dt;
        double *x, *y, *t, ***u, **v;
        double *a1, *b1, *c1, *d1, *a2, *b2, *c2, *d2, tmid, *ans, temp;
        double f(double x, double y, double t);
        double phi(double x, double y);
        double g1(double y, double t);
        double g2(double y, double t);
        double g3(double x, double t);
        double g4(double x, double t);
        double *chase_algorithm(double *a, double *b, double *c, double *d, int n);
        double exact(double x, double y, double t);

        a=1.0;
        b=1.0;
        T=1.0;
        m=60;
        n=40;
        L=20;
        dx=a/m;
        dy=b/n;
        dt=T/L;
        r1=dt/(dx*dx);
        r2=dt/(dy*dy);
        printf("m=%d, n=%d, L=%d\n", m, n, L);
        printf("r1=%.4f,   r2=%.4f\n", r1, r2);

        x=(double *)malloc(sizeof(double)*(m+1));
        for(i=0;i<=m;i++)
                x[i]=i*dx;

        y=(double *)malloc(sizeof(double)*(n+1));
        for(j=0;j<=n;j++)
                y[j]=j*dy;

        t=(double *)malloc(sizeof(double)*(L+1));
        for(k=0;k<=L;k++)
                t[k]=k*dt;

        u=(double ***)malloc(sizeof(double *)*((m+1)*(n+1)*(L+1)));
        for(i=0;i<=m;i++)
                u[i]=(double **)malloc(sizeof(double *)*((n+1)*(L+1)));
        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                        u[i][j]=(double *)malloc(sizeof(double)*(L+1));
        }

        v=(double **)malloc(sizeof(double *)*(m+1));
        for(i=0;i<=m;i++)
                v[i]=(double *)malloc(sizeof(double)*(n+1));

        for(i=0;i<=m;i++)
        {
                for(j=0;j<=n;j++)
                {
                         u[i][j][0]=phi(x[i], y[j]);
                }
        }

        for(k=1;k<=L;k++)
        {
                for(j=0;j<=n;j++)
                {
                         u[0][j][k]=g1(y[j], t[k]);
                         u[m][j][k]=g2(y[j], t[k]);
                }
                for(i=1;i<=m-1;i++)
                {
                         u[i][0][k]=g3(x[i], t[k]);
                         u[i][n][k]=g4(x[i], t[k]);
                }
        }

        a1=(double *)malloc(sizeof(double)*(m-1));
        b1=(double *)malloc(sizeof(double)*(m-1));
        c1=(double *)malloc(sizeof(double)*(m-1));
        d1=(double *)malloc(sizeof(double)*(m-1));
        for(i=0;i<m-1;i++)
        {
                a1[i]=-r1/2.0;
                b1[i]=1.0+r1;
                c1[i]=a1[i];
        }

        a2=(double *)malloc(sizeof(double)*(n-1));
        b2=(double *)malloc(sizeof(double)*(n-1));
        c2=(double *)malloc(sizeof(double)*(n-1));
        d2=(double *)malloc(sizeof(double)*(n-1));
        for(j=0;j<n-1;j++)
        {
                a2[j]=-r2/2.0;
                b2[j]=1.0+r2;
                c2[j]=a2[j];
        }

        for(k=0;k<L;k++)
        {
                tmid=(t[k]+t[k+1])/2.0;
                for(j=1;j<=n-1;j++)
                {
                        for(i=1;i<=m-1;i++)
                        {
                                d1[i-1]=r1*(u[i-1][j][k]-2*u[i][j][k]+u[i+1][j][k])+r2*(u[i][j-1][k]-2*u[i][j][k]+u[i][j+1][k])+f(x[i], y[j], tmid)*dt;
                        }
                        v[0][j]=(1+r2)*(u[0][j][k+1]-u[0][j][k])-r2*(u[0][j+1][k+1]-u[0][j+1][k]+u[0][j-1][k+1]-u[0][j-1][k])/2.0;
                        v[m][j]=(1+r2)*(u[m][j][k+1]-u[m][j][k])-r2*(u[m][j+1][k+1]-u[m][j+1][k]+u[m][j-1][k+1]-u[m][j-1][k])/2.0;
                        d1[0]=d1[0]+r1*v[0][j]/2.0;
                        d1[m-2]=d1[m-2]+r1*v[m][j]/2.0;
                        ans=chase_algorithm(a1, b1, c1, d1, m-1);

                        for(i=1;i<=m-1;i++)
                                v[i][j]=ans[i-1];
                        free(ans);
                }

                for(i=1;i<=m-1;i++)
                {
                        for(j=1;j<=n-1;j++)
                                d2[j-1]=(1+r2)*u[i][j][k]-r2*(u[i][j-1][k]+u[i][j+1][k])/2.0+v[i][j];
                        d2[0]=d2[0]+r2*u[i][0][k+1]/2.0;
                        d2[n-2]=d2[n-2]+r2*u[i][n][k+1]/2.0;
                        ans=chase_algorithm(a2, b2, c2, d2, n-1);

                        for(j=1;j<=n-1;j++)
                                u[i][j][k+1]=ans[j-1];
                        free(ans);
                }
        }

        gap_i=m/4;
        gap_j=n/4;

        for(i=gap_i;i<=m-1;i=i+gap_i)
        {
                for(j=gap_j;j<=n-1;j=j+gap_j)
                {
                        temp=fabs(exact(x[i], y[j], T/2.0)-u[i][j][L/2]);
                        printf("(%.2f, %.2f, 0.50)     y=%f,    err=%.4e\n", x[i], y[j], u[i][j][L/2], temp);
                }
        }

        printf("\n");
        printf("\n");

        for(i=gap_i;i<=m-1;i=i+gap_i)
        {
               for(j=gap_j;j<=n-1;j=j+gap_j)
               {
                        temp=fabs(exact(x[i], y[j], T)-u[i][j][L]);
                        printf("(%.2f, %.2f, 1.00)     y=%f,    err=%.4e\n", x[i], y[j], u[i][j][L], temp);
               }
        }

        free(x); free(y); free(t);
        free(a1); free(b1); free(c1); free(d1);
        free(a2); free(b2); free(c2); free(d2);

        for(i=0;i<=m;i++)
        {
               for(j=0;j<=n;j++)
                       free(u[i][j]);
        }

        for(i=0;i<=m;i++)
        {
               free(u[i]); free(v[i]);
        }

        free(u); free(v);

        return 0;
}


double f(double x, double y, double t)
{
        return -3.0*exp((x+y)/2.0-t)/2.0;
}
double phi(double x, double y)
{
        return exp((x+y)/2.0);
}
double g1(double y, double t)
{
        return exp(y/2.0-t);
}
double g2(double y, double t)
{
        return exp((1.0+y)/2.0-t);
}
double g3(double x, double t)
{
        return exp(x/2.0-t);
}
double g4(double x, double t)
{
        return exp((1.0+x)/2.0-t);
}
double *chase_algorithm(double *a, double *b, double *c, double *d, int n)
{
        int i;
        double * ans, *g, *w, p;

        ans=(double *)malloc(sizeof(double)*n);
        g=(double *)malloc(sizeof(double)*n);
        w=(double *)malloc(sizeof(double)*n);

        g[0]=d[0]/b[0];
        w[0]=c[0]/b[0];

        for(i=1;i<n;i++)
        {
                p=b[i]-a[i]*w[i-1];
                g[i]=(d[i]-a[i]*g[i-1])/p;
                w[i]=c[i]/p;
        }

        ans[n-1]=g[n-1];
        i=n-2;
        do
        {
                ans[i]=g[i]-w[i]*ans[i+1];
                i=i-1;
        }while(i>=0);

        free(g); free(w);

        return ans;
}
double exact(double x, double y, double t)
{
        return exp((x+y)/2.0-t);
}

 


当m=60,n=40,L=20时,结果如下:

m=60, n=40, L=20
r1=180.0000,   r2=80.0000
(0.25, 0.25, 0.50)     y=0.778814,    err=1.2876e-05
(0.25, 0.50, 0.50)     y=0.882514,    err=1.7519e-05
(0.25, 0.75, 0.50)     y=1.000015,    err=1.4611e-05
(0.50, 0.25, 0.50)     y=0.882514,    err=1.7519e-05
(0.50, 0.50, 0.50)     y=1.000024,    err=2.3999e-05
(0.50, 0.75, 0.50)     y=1.133168,    err=1.9757e-05
(0.75, 0.25, 0.50)     y=1.000015,    err=1.4611e-05
(0.75, 0.50, 0.50)     y=1.133168,    err=1.9757e-05
(0.75, 0.75, 0.50)     y=1.284042,    err=1.6707e-05


(0.25, 0.25, 1.00)     y=0.472374,    err=7.8105e-06
(0.25, 0.50, 1.00)     y=0.535272,    err=1.0627e-05
(0.25, 0.75, 1.00)     y=0.606540,    err=8.8626e-06
(0.50, 0.25, 1.00)     y=0.535272,    err=1.0627e-05
(0.50, 0.50, 1.00)     y=0.606545,    err=1.4557e-05
(0.50, 0.75, 1.00)     y=0.687301,    err=1.1984e-05
(0.75, 0.25, 1.00)     y=0.606540,    err=8.8626e-06
(0.75, 0.50, 1.00)     y=0.687301,    err=1.1984e-05
(0.75, 0.75, 1.00)     y=0.778811,    err=1.0134e-05

当m=120,n=80,L=40时,结果如下:

m=120, n=80, L=40
r1=360.0000,   r2=160.0000
(0.25, 0.25, 0.50)     y=0.778804,    err=3.2127e-06
(0.25, 0.50, 0.50)     y=0.882501,    err=4.3716e-06
(0.25, 0.75, 0.50)     y=1.000004,    err=3.6449e-06
(0.50, 0.25, 0.50)     y=0.882501,    err=4.3717e-06
(0.50, 0.50, 0.50)     y=1.000006,    err=5.9884e-06
(0.50, 0.75, 0.50)     y=1.133153,    err=4.9297e-06
(0.75, 0.25, 0.50)     y=1.000004,    err=3.6449e-06
(0.75, 0.50, 0.50)     y=1.133153,    err=4.9297e-06
(0.75, 0.75, 0.50)     y=1.284030,    err=4.1668e-06


(0.25, 0.25, 1.00)     y=0.472369,    err=1.9488e-06
(0.25, 0.50, 1.00)     y=0.535264,    err=2.6518e-06
(0.25, 0.75, 1.00)     y=0.606533,    err=2.2109e-06
(0.50, 0.25, 1.00)     y=0.535264,    err=2.6518e-06
(0.50, 0.50, 1.00)     y=0.606534,    err=3.6325e-06
(0.50, 0.75, 1.00)     y=0.687292,    err=2.9903e-06
(0.75, 0.25, 1.00)     y=0.606533,    err=2.2109e-06
(0.75, 0.50, 1.00)     y=0.687292,    err=2.9902e-06
(0.75, 0.75, 1.00)     y=0.778803,    err=2.5275e-06

四、结论

        从三种不同格式的计算结果可以看出,虽然分解方法不同,但计算结果是完全一致的。同时,如果时间步长、空间步长同时减半,则误差减小为1/4。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/547585.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

微服务之CircuitBreaker断路器

一、概述 1.1背景 在一个分布式系统中&#xff0c;每个服务都可能会调用其它的服务器&#xff0c;服务之间是相互调用相互依赖。假如微服务A调用微服务B和微服务C&#xff0c;微服务B和微服务C又调用其他的微服务。这就是构成所谓“扇出”。 如果扇出的链路上某个微服务的调…

图数据库Neo4J入门——Neo4J下载安装+Cypher基本操作+《西游记》人物关系图实例

这里写目录标题 一、效果图二、环境准备三、数据库设计3.1 人物节点设计3.2 关系设计 四、操作步骤4.1 下载、安装、启动Neo4J服务4.1.1 配置Neo4J环境变量4.1.2 启动Neo4J服务器4.1.3 启动Ne04J客户端 4.2 创建节点4.3 创建关系&#xff08;从已有节点创建关系&#xff09;4.4…

数据结构和算法(哈希表和图(A*算法精讲))

一 、哈希表 1.1 哈希表原理精讲 哈希表-散列表&#xff0c;它是基于快速存取的角度设计的&#xff0c;也是一种典型的“空间换时间”的做法 键(key)&#xff1a; 组员的编号如&#xff0c;1、5、19。。。 值(value)&#xff1a; 组员的其它信息&#xff08;包含性别、年龄和…

并查集练习

前言&#xff1a; 关于并查集的一些训练题。 正文&#xff1a; 1.亲戚&#xff1a; #include<bits/stdc.h> using namespace std; const int N5005; int fa[N]; int find(int x){if(xfa[x])return x;return fa[x]find(fa[x]); } void merge(int x,int y){fa[find(x)]fi…

MajorDoMo thumb.php 未授权RCE漏洞复现(CNVD-2024-02175)

0x01 产品简介 MajorDoMo是MajorDoMo社区的一个开源DIY智能家居自动化平台。 0x02 漏洞概述 MajorDoMo /modules/thumb/thumb.php接口处存在远程命令执行漏洞&#xff0c;未经身份验证的攻击者可利用此漏洞执行任意指令&#xff0c;获取服务器权限。 0x03 影响范围 MajorD…

消息队列和分布式消息队列

文章目录 分析系统现状不足中间件消息队列什么是消息队列&#xff1f;应用场景消息队列的模型为什么不直接传输&#xff0c;而要用消息队列&#xff1f;为什么要用消息队列&#xff1f;消息队列的缺点&#xff1f; 分布式消息队列分布式消息队列的优势&#xff1f;消息队列应用…

数字晶体管数字三极管

数字晶体管 指内部集成了电阻的三极管&#xff0c;有PNP和NPN型&#xff0c;也有双管&#xff0c;双管有3种形式&#xff0c;其中一种是PNPNPN。下面以双NPN示例&#xff0c;好处是外面没有电阻&#xff0c;批量应用时&#xff0c;焊点费用就可省下不少。双NPN的用在串口自动下…

SSH客户端工具输入目标地址端口远程失败故障原因和解决方案

问题表现&#xff1a;SSH客户端工具输入目标地址端口远程失败时&#xff0c;出现ssh client 报 algorithm negotiation failed的异常信息。 使用SSH Secure Shell Client连接Linux服务器的SSH的时候有时会出现错误提示信息&#xff1a;ssh algorithm negotiation failed。这是…

HarmonyOS NEXT星河版之实战知乎App评论功能

文章目录 一、目标完成页面二、实战2.1 定义数据2.2 mock数据2.3 封装顶部标题栏2.4 封装评论Item2.5 定义回复组件2.6 主页面 三、小结 一、目标完成页面 二、实战 2.1 定义数据 export interface ReplyItem {avatar: ResourceStr // 头像author: string // 作者id: number …

【数据结构|C语言版】顺序表应用

前言1. 基于动态顺序表实现通讯录1.1 通讯录功能1.2 代码实现1.2.1 SeqList.h1.2.2 SeqList.c1.2.3 Contact.h1.2.4 Contact.c1.2.5 test.c 1.3 控制台测试1.3.1 添加联系人1.3.2 删除联系人1.3.3 修改联系人1.3.4 查找联系人1.3.5 清空通讯录1.3.6 通讯录读档和存档 2. 好题测…

Day 41:动态规划 LeedCode 343. 整数拆分 96.不同的二叉搜索树

343. 整数拆分 给定一个正整数 n &#xff0c;将其拆分为 k 个 正整数 的和&#xff08; k > 2 &#xff09;&#xff0c;并使这些整数的乘积最大化。 返回 你可以获得的最大乘积 。 示例 1: 输入: n 2 输出: 1 解释: 2 1 1, 1 1 1。 思路: 1.确定dp数组&#xff0…

支付系统核心逻辑 — — 状态机(JavaGolang版本)

支付系统核心逻辑 — — 状态机 代码地址&#xff1a;https://github.com/ziyifast/ziyifast-code_instruction/tree/main/state_machine_demo 1 概念&#xff1a;FSM&#xff08;有限状态机&#xff09;&#xff0c;模式之间转换 状态机&#xff0c;也叫有限状态机&#xff08…

OpenWrt 多拨负载均衡不起作用

检查 负载均衡->规则->Https->粘滞模式 是否启动&#xff0c;设置为 否 如果设置为是&#xff0c;那么根据官方描述&#xff1a; 来自相同源 IP 的流量&#xff0c;如果已经匹配过此规则并且在粘滞超时时间内&#xff0c;将会使用相同的 WAN 接口 意思就是如果你同一个…

R语言 并行计算makeCluster报错

问题&#xff1a;使用parallel包进行并行计算&#xff0c; cl <- makeCluster(detectCores()) 出现以下问题&#xff1a; 解决方式&#xff1a;用makeClusterPSOCK命令代替即可 library("future") cl <- makeClusterPSOCK(124, revtunnel TRUE, outfile &…

【QT入门】Qt自定义控件与样式设计之自定义QTabWidget实现tab在左,文本水平的效果

往期回顾 【QT入门】Qt自定义控件与样式设计之控件提升与自定义控件-CSDN博客 【QT入门】Qt自定义控件与样式设计之鼠标相对、绝对位置、窗口位置、控件位置-CSDN博客【QT入门】Qt自定义控件与样式设计之自定义QLineEdit实现搜索编辑框-CSDN博客 【QT入门】Qt自定义控件与样式…

(一)基于IDEA的JAVA基础16(end)

二维数组 二维数组就是数组里面再放一个数组 语法: <数据类型> [] [] 数组名&#xff1b; 或: <数据类型> 数组名 [] []&#xff1b; 比如这里有5个单位&#xff0c;每个单位员工有20个&#xff0c;他们都在忙几个相同的项目&#xff0c;现在要对某项项目进行操…

html、css、QQ音乐移动端静态页面,资源免费分享,可作为参考,提供InsCode在线运行演示

CSDN将我上传的免费资源私自变成VIP专享资源&#xff0c;且作为作者的我不可修改为免费资源&#xff0c;不可删除&#xff0c;寻找客服无果&#xff0c;很愤怒&#xff0c;&#xff08;我发布免费资源就是希望大家能免费一起用、一起学习&#xff09;&#xff0c;接下来继续寻找…

Linux进阶篇:centos7搭建jdk环境

Linux服务搭建篇&#xff1a;centos7搭建jdk环境 本文主要介绍的是如何是Linux环境下安装JDK的&#xff0c;关于jdk的概念就不做赘述了&#xff0c;相信大家都有所耳闻了&#xff0c;Linux环境下&#xff0c;很多时候也离不开Java的&#xff0c;下面笔者就和大家一起分享如何jd…

【数据结构|C语言版】单链表应用

前言1. 基于单链表实现通讯录1.1 知识要求1.2 功能要求 2. 代码总结2.1 SeqList.h2.2 SeqList.c2.3 Contact.h2.4 Contact.c2.5 test.c 后言 上期回顾&#xff1a;【数据结构|C语言版】单链表 前言 各位小伙伴大家好&#xff01;上期小编讲解了单链表相关知识&#xff0c;在此…

SpringCloudAlibaba真的不行了吗?

Spring Cloud Alibaba 作为SpringCloudAlibaba微服务架构实战派上下册和RocketMQ消息中间件实战派上下册的作者胡弦&#xff0c;我想和技术人聊一下&#xff0c;阿里巴巴开源的SpringCloudAlibaba真的不行了吗&#xff1f; 目前SpringCloudAlibaba最新的版本为2023.0.0.0-RC1 …