[petsc-users] general problem with application based on PETSc

yan chang yan.chang.suse at gmail.com
Sun Jan 19 03:39:31 CST 2014


I have used Eigen (a C++ template library ) to set up a spin dynamics
simulation program, and now I would like to speed up the simulation in
parallel using PETSc, mostly use sparse Mat and Vec operations. After some
rewrite work (just replace the matrix operations by PETSc), I can firstly
set up a spin system and calculate its relaxation matrix R.

PetscErrorCode ierr;
PetscInitialize(&argc, &argv, (char*) 0, help);
  SpinSystem sys;
  sys.set_magnet(14.1);
  sys.set_isotopes("1H 13C");
  sys.set_basis("sphten_liouv");
  sys.set_zeeman_eigs("(7 15 -22) (11 18 -29)");
  sys.set_zeeman_euler("(1.0472 0.7854 0.6283) (0.5236 0.4488 0.3927)");
  sys.set_coordinates("1 (0 0 0) 2 (0 0 1.02)");
  sys.create();
  Relaxation relax(sys);
  Mat R = relax.Rmat();
  ierr = MatView(R, PETSC_VIEWER_STDOUT_WORLD);
  ierr = MatDestroy(&R);
  CHKERRQ(ierr);
  ierr = PetscFinalize();

And run it with mpirun -np 1 ./Release/spin-scenarios-petsc it is ok.
However if I set the np to be 2 or more, the program would generate the
same number of the spin system object and it is time consuming to get the
result. I am very confused that in the implementation the Mat and Vec
variables are not sequential like Eigen, so could you give me some advise
how to organize my program based on PETSc?
I am a beginner of both OPENMPI and PETSc. Also, after the simple set up
part, there will be some more time consuming work to do, that's why I
switch from Eigen to PETSc.
Thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140119/aa1c5059/attachment.html>


More information about the petsc-users mailing list