'''
   MFEM example 11

   See c++ version in the MFEM library for more detail 

   How to run:
      mpirun -np 2 python <arguments>
  
   Example of arguments:
      ex11p.py -m square-disc.mesh
      ex11p.py -m star.mesh
      ex11p.py -m escher.mesh
      ex11p.py -m fichera.mesh
      ex11p.py -m square-disc-p2.vtk -o 2
      ex11p.py -m square-disc-p3.mesh -o 3
      ex11p.py -m square-disc-nurbs.mesh -o -1
      ex11p.py -m disc-nurbs.mesh -o -1 -n 20
      ex11p.py -m pipe-nurbs.mesh -o -1
      ex11p.py -m ball-nurbs.mesh -o 2
      ex11p.py -m star-surf.mesh
      ex11p.py -m square-disc-surf.mesh
      ex11p.py -m inline-segment.mesh
      ex11p.py -m amr-quad.mesh
      ex11p.py -m amr-hex.mesh
      ex11p.py -m mobius-strip.mesh -n 8
      ex11p.py -m klein-bottle.mesh -n 10
'''
import sys
from os.path import expanduser, join, dirname
import numpy as np

from mfem.common.arg_parser import ArgParser
import mfem.par as mfem
from mpi4py import MPI


num_procs = MPI.COMM_WORLD.size
myid = MPI.COMM_WORLD.rank


parser = ArgParser(description='Ex11 ')
parser.add_argument('-m', '--mesh',
                    default='star.mesh',
                    action='store', type=str,
                    help='Mesh file to use.')
parser.add_argument('-rs', '--refine-serial',
                    default=2,
                    action='store', type=int,
                    help="Number of times to refine the mesh uniformly in serial.")

parser.add_argument('-rp', '--refine-parallel',
                    default=1,
                    action='store', type=int,
                    help="Number of times to refine the mesh uniformly in parallel.")
parser.add_argument('-o', '--order',
                    action='store', default=1, type=int,
                    help=("Finite element order (polynomial degree) or -1 for isoparametric space."))
parser.add_argument("-n", "--num-eigs",
                    action='store', default=5, type=int,
                    help="Number of desired eigenmodes.")
parser.add_argument("-sp", "--strumpack",
                    action='store_true', default=False,
                    help="Use the STRUMPACK Solver.")