代写program、代做C/C++设计编程
Final Project of The Practice of Mathematics
due 2023 AUG 18 (Friday), 22:00
1 The assignments
Write a C++ package to implement the fourth-order FVMOL algorithm in Section 12.3 and the approximate projection method in Section 12.4 to solve the advectiondiffusion equation and the incompressible Navier-Stokes
equations (INSE), respectively. You should use a multigrid method as in Chapter 9 to solve the linear systems.
Verify the validity of your program using the tests in
Sections 1.1, 1.2, and 1.3. For each test, you should plot
your solutions and report errors and convergence rates on
successively refined grids.
1.1 Traveling sinusoidal waves
For ν = 0.01, u = (1.0, 0.5, 0.25) and k = (2π, 4π, 6π),
we use an expression of the form φ =
Q
d
sin θd with
θd = kdxd − udt as an exact solution to the advectiondiffusion equation to derive the forcing term as
f(x, t) = P
d
νk2
d
Q
d
sin θd
+
P
d
n
ud (kd − 1) cos θd
Q
d06=d
sin θd0
o
.
(1)
On the unit domain [0, 1]2
, the initial condition is calculated as the exact average hφi
i
evaluated at t0 = 0,
which is then advanced to te = 1 with the time-step chosen such that the Courant number Cr = 1.0. For each dimension, you should use the Dirichlet boundary condition
and the Neumann boundary condition for the low side and
the high side, respectively. The test should be carried on
four successively refined grids with h =
1
64 ,
1
128 ,
1
256 ,
1
512 .
1.2 Gaussian patch in vortex shear
The velocity field of this test is steady and divergence-free:
u(x, y) = aV
sin2
(πx) sin(2πy), − sin(2πx) sin2
(πy)
,
(2)
where aV = 0.1 is a scaling parameter.
On the periodic domain [0, 1]2
, the advection-diffusion
equation is advanced with ν = 0.001 and Cr = 1.0 from
t0 = 0 to te = 1/aV on four successively refined grids with
h =
1
64 ,
1
128 ,
1
256 ,
1
512 . Errors and convergence rates should
be calculated via Richardson extrapolation; see Section
5.4 in [Zhang et. al. 2012 SIAM Journal on Scientific
Computing 34(2):B179-B201].
1.3 Taylor vortex
The exact solution of the INSE in this test is
u(x, y, t) = 1 + 2 exp(−8π
2νt)
− cos(2π(x − t)) sin(2π(y − t))
sin(2π(x − t)) cos(2π(y − t)) p(x, y, t) = − exp(−16π
2νt)
cos(4π(x − t)) + cos(4π(y − t))
.
(3)
On the periodic domain [0, 1]2
, (3) is advanced from
t0 = 0 to te = 0.5 for Courant number Cr = 0.75, 1.5
and Reynolds numbers Re= U0L0
ν = 30, 300, 3000, 30000 on
four successively refined grids with h =
1
64 ,
1
128 ,
1
256 ,
1
512 .
The initial cell-averaged velocity is calculated by (3) and
a sixth-order Newton-Cotes formula.
2 Extra credit and others
The total number of points is 100.
However, if the story in your report is extremely good
in terms of software design, interesting new methods/tests,
and insights that relate mathematical theory to numerical
results, you can earn extra credit up to 15 points.
If you further implement the GePUP-SAV-DIRK
schemes in Section 12.5.6 and test your programs appropriately using test in [Zhang 2016 Journal of Scientific
Computing 67(3):1134-1180], you can earn extra credit up
to 50 points.
In case of this project being way too difficult for you,
here are some tradeoff rules to make your life easier:
• Instead of writing your own multigrid solver, you
may use a third-party linear solver package such as
lapack; but 15 points will be deducted from your
total score.
• Instead of C or C++, you may use another programming language such as matlab or python, but 20
points will be deducted from your total score.
3 How to submit
Your submission must contain
(a) the LATEX source code and its Makefile so that the
command “make story” generates a document that
contains the story required in Section 1,
(b) a C++ package so that the command “make run”
would trigger the compilation of your source code,
the production of the executable, the running of your
tests, the display of test results, and even the generation of the elements in your story.
You should archive your source code in a single gzipped
tar ball (format: YourName_finalProject.tar.gz) and
send it to sxsj2023@126.com. A number of tips are given
as follows.
(i) You can use either GNU Make or cmake or a mixture
of them.
(ii) You may use either GNU plot or matlab to plot your
results.
(iii) You can use Chinese or English for writing the story
document.
(iv) Your gzipped tar ball should neither contain anything that can be generated from your Makefile, nor
contain anything irrelevant to this homework. In
other words, your answers to this project should be
both sufficient and necessary.
(v) You are encouraged to use a unit test framework such
as CppUnit; of course you can choose your own unittest framework as you see fit.
2