|
339 | 339 | "CL[2:end-1] .= CL[2:end-1] .+ dt*D*diff(diff(CL)/dx)/dx\n",
|
340 | 340 | "CR[2:end-1] .= CR[2:end-1] .+ dt*D*diff(diff(CR)/dx)/dx\n",
|
341 | 341 | "# Update boundaries (MPI)\n",
|
342 |
| - "CL[end] = ...\n", |
343 |
| - "CR[1] = ...\n", |
| 342 | + "CL[end] = CR[2]\n", |
| 343 | + "CR[1] = CL[end-1]\n", |
344 | 344 | "# Global picture\n",
|
345 | 345 | "C .= [CL[1:end-1]; CR[2:end]]\n",
|
346 | 346 | "```"
|
|
385 | 385 | "\n",
|
386 | 386 | "```julia\n",
|
387 | 387 | "# Update boundaries (MPI)\n",
|
388 |
| - "CL[end] = ...\n", |
389 |
| - "CR[1] = ...\n", |
| 388 | + "CL[end] = CR[2]\n", |
| 389 | + "CR[1] = CL[end-1]\n", |
390 | 390 | "```\n",
|
391 | 391 | "\n",
|
392 | 392 | "in order make the code work properly and run it again. Note what has changed in the visualisation."
|
|
422 | 422 | " C[2:end-1,ip] .= C[2:end-1,ip] .+ dt*D*diff(diff(C[:,ip])/dxg)/dxg\n",
|
423 | 423 | "end\n",
|
424 | 424 | "for ip = 1:np-1 # update boundaries\n",
|
425 |
| - " # ...\n", |
| 425 | + " C[end,ip ] = C[ 2,ip+1]\n", |
| 426 | + " C[ 1,ip+1] = C[end-1,ip ]\n", |
426 | 427 | "end\n",
|
427 | 428 | "for ip = 1:np # global picture\n",
|
428 | 429 | " i1 = 1 + (ip-1)*(nx-2)\n",
|
|
472 | 473 | "# Initial condition\n",
|
473 | 474 | "for ip = 1:np\n",
|
474 | 475 | " for ix = 1:nx\n",
|
475 |
| - " x[ix,ip] = ...\n", |
| 476 | + " x[ix,ip] = ( (ip-1)*(nx-2) + (ix-0.5) )*dxg - 0.5*lx\n", |
476 | 477 | " C[ix,ip] = exp(-x[ix,ip]^2)\n",
|
477 | 478 | " end\n",
|
478 | 479 | " i1 = 1 + (ip-1)*(nx-2)\n",
|
|
596 | 597 | "@views function update_halo!(A, neighbors_x, comm)\n",
|
597 | 598 | " # Send to / receive from neighbour 1 (\"left neighbor\")\n",
|
598 | 599 | " if neighbors_x[1] != MPI.PROC_NULL\n",
|
599 |
| - " sendbuf = ??\n", |
600 |
| - " recvbuf = ??\n", |
601 |
| - " MPI.Send(??, neighbors_x[?], 0, comm)\n", |
602 |
| - " MPI.Recv!(??, neighbors_x[?], 1, comm)\n", |
603 |
| - " A[1] = ??\n", |
| 600 | + " sendbuf = A[2]\n", |
| 601 | + " recvbuf = zeros(1)\n", |
| 602 | + " MPI.Send(sendbuf, neighbors_x[1], 0, comm)\n", |
| 603 | + " MPI.Recv!(recvbuf, neighbors_x[1], 1, comm)\n", |
| 604 | + " A[1] = recvbuf[1]\n", |
604 | 605 | " end\n",
|
605 | 606 | " # Send to / receive from neighbour 2 (\"right neighbor\")\n",
|
606 | 607 | " if neighbors_x[2] != MPI.PROC_NULL\n",
|
607 |
| - " sendbuf = ??\n", |
608 |
| - " recvbuf = ??\n", |
609 |
| - " MPI.Recv!(??, neighbors_x[?], 0, comm)\n", |
610 |
| - " MPI.Send(??, neighbors_x[?], 1, comm)\n", |
611 |
| - " A[end] = ??\n", |
| 608 | + " sendbuf = A[end-1]\n", |
| 609 | + " recvbuf = zeros(1)\n", |
| 610 | + " MPI.Recv!(recvbuf, neighbors_x[2], 0, comm)\n", |
| 611 | + " MPI.Send(sendbuf, neighbors_x[2], 1, comm)\n", |
| 612 | + " A[end] = recvbuf[1]\n", |
612 | 613 | " end\n",
|
613 | 614 | " return\n",
|
614 | 615 | "end\n",
|
|
1077 | 1078 | "file_extension": ".jl",
|
1078 | 1079 | "mimetype": "application/julia",
|
1079 | 1080 | "name": "julia",
|
1080 |
| - "version": "1.10.5" |
| 1081 | + "version": "1.11.1" |
1081 | 1082 | },
|
1082 | 1083 | "kernelspec": {
|
1083 |
| - "name": "julia-1.10", |
1084 |
| - "display_name": "Julia 1.10.5", |
| 1084 | + "name": "julia-1.11", |
| 1085 | + "display_name": "Julia 1.11.1", |
1085 | 1086 | "language": "julia"
|
1086 | 1087 | }
|
1087 | 1088 | },
|
|
0 commit comments