I want to test PETSc and parallelization, so test the code:
load "PETSc"
macro dimension()2// EOM
include "macro_ddm.idp"
macro grad(u)[dx(u), dy(u)]// EOM
func Pk = P1;
border upper(t=0, pi) { x=cos(t); y=sin(t); label=1; }
border lower(t=pi, 2*pi) { x=cos(t); y=sin(t); label=2; }
mesh Th = buildmesh(upper(100) + lower(100));
Mat A;
MatCreate(Th, A, Pk);
fespace Vh(Th, Pk);
varf vPb(u, v) = intN(Th)(grad(u)' * grad(v)) + intN(Th)(v) + on(2, u = 0);
matrix Loc = vPb(Vh, Vh, tgv = -2);
real[int] b = vPb(0, Vh, tgv = -1);
A = Loc;
Vh u;
set(A, sparams = "-pc_type lu");
u[] = A^-1 * b;
plotD(Th, u, cmm = "Solution");
real[int] r = A * u[];
exchange(A, b, scaled = true);
r -= b;
r *= -1;
Vh v;
v[] = r;
plotD(Th, v, cmm = "Residual");
r = A' * u[];
r -= b;
r *= -1;
v[] = r;
plotD(Th, v, cmm = "Residual computed with A'");
real[int] bPETSc, xPETSc;
ChangeNumbering(A, b, bPETSc);
xPETSc.resize(bPETSc.n);
KSPSolve(A, bPETSc, xPETSc);
ChangeNumbering(A, u[], xPETSc, inverse = true, exchange = true);
plotD(Th, u, cmm = "Solution with KSPSolve");
But get this wrong information :
-- FreeFem++ v4.15 (Wed Dec 11 16:48:56 CET 2024 - git v4.15-7-gb1e524c8c)
file : .\E1.edp
Load: lg_fem lg_mesh lg_mesh3 eigenvalue parallelempi
(load: loadLibary D:\MathTool\FreeFem++\\.\PETSc = 0)(load: loadLibary D:\MathTool\FreeFem++\\.\metis = 0) load: init metis (v 5 )
sizestack + 1024 =12400 ( 11376 )
-- mesh: Nb of Triangles = 6982, Nb of Vertices 3592
-- mesh: Nb of Triangles = 6982, Nb of Vertices 3592
-- mesh: Nb of Triangles = 6982, Nb of Vertices 3592
-- mesh: Nb of Triangles = 6982, Nb of Vertices 3592
--- global mesh of 6982 elements (prior to refinement) partitioned with metis --metisA: 4-way Edge-Cut: 3, Balance: 1.00 Nodal=0/Dual 1
(in 4.471700e-03)
--- partition of unity built (in 6.910000e-03)
--- global numbering created (in 6.967000e-04)
--- global CSR created (in 1.900000e-04)
Warning: -- Your set of boundary condition is incompatible with the mesh label.
Warning: -- Your set of boundary condition is incompatible with the mesh label.
Warning: -- Your set of boundary condition is incompatible with the mesh label.
Warning: -- Your set of boundary condition is incompatible with the mesh label.
[1]PETSC ERROR: ------------------------------------------------------------------------
[1]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[1]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[1]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/
[1]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[1]PETSC ERROR: to get more information on the crash.
[1]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
job aborted:
[ranks] message
[0] terminated
[1] application aborted
aborting MPI_COMM_WORLD (comm=0x44000000), error 59, comm rank 1
[2-3] terminated
---- error analysis -----
[1] on Z-Z-M
FreeFem++-mpi.exe aborted the job. abort code 59
---- error analysis -----
So How can I deal this problem? I use the windows Powershell:
mpiexec.exe -np 4 FreeFem++-mpi.exe .\E1.edp -wg -ns