Commits

Lisandro Dalcin  committed 1a5126a

Improve IGACreate test and add driver script to run it

  • Participants
  • Parent commits 419d6f9

Comments (0)

Files changed (2)

File test/IGACreate.c

   PetscInt       dim,dof;
   IGA            iga;
   PetscScalar    s;
+  PetscReal      xmin,xmax;
   Vec            b,x;
   Mat            A;
   KSP            ksp;
   ierr = IGACreateVec(iga,&b);CHKERRQ(ierr);
   ierr = IGACreateMat(iga,&A);CHKERRQ(ierr);
   ierr = IGACreateKSP(iga,&ksp);CHKERRQ(ierr);
+  ierr = KSPSetType(ksp,KSPCG);CHKERRQ(ierr);
   ierr = IGASetUserSystem(iga,System,0);CHKERRQ(ierr);
   ierr = IGAComputeSystem(iga,A,b);CHKERRQ(ierr);
   ierr = KSPSetOperators(ksp,A,A,SAME_NONZERO_PATTERN);CHKERRQ(ierr);
   ierr = KSPSetFromOptions(ksp);;CHKERRQ(ierr);
-  ierr = KSPSolve(ksp,b,x);;CHKERRQ(ierr);
+  ierr = KSPSetTolerances(ksp,1e-6,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRQ(ierr);
+  ierr = KSPSolve(ksp,b,x);CHKERRQ(ierr);
+  ierr = VecMin(x,0,&xmin);CHKERRQ(ierr);
+  ierr = VecMax(x,0,&xmax);CHKERRQ(ierr);
   ierr = VecDestroy(&x);CHKERRQ(ierr);
   ierr = VecDestroy(&b);CHKERRQ(ierr);
   ierr = MatDestroy(&A);CHKERRQ(ierr);
 
   ierr = IGADestroy(&iga);CHKERRQ(ierr);
 
+  if ((xmax-xmin) > 1e-2) {
+    ierr = PetscPrintf(PETSC_COMM_WORLD,"Unexpected result: x_min=%G x_max=%G\n",
+                       (PetscScalar)xmin,(PetscScalar)xmax);CHKERRQ(ierr);
+  }
+
   ierr = PetscFinalize();CHKERRQ(ierr);
   return 0;
 }

File test/IGACreate.py

+import sys, os
+VERBOSE = True
+
+for dim in [1,2,3]:
+    iga_dim = "-iga_dim %d" % dim
+    for dof in [1,2,3]:
+        iga_dof = "-iga_dof %d" % dof
+        for mat_type in ['aij', 'baij', 'sbaij', 'is']:
+            iga_mat_type = "-iga_mat_type %s" % mat_type
+            for periodic in [0,1]:
+                iga_periodic = "-iga_periodic %d" % periodic
+                for elements in [4,6,8]:#[1,2,3]:
+                    iga_elements = "-iga_elements %d" % elements
+                    for degree in range(1, 4):
+                        iga_degree = "-iga_degree %d" % degree
+                        for continuity in range(0, degree):
+                            iga_continuity = "-iga_continuity %d" % continuity
+                            for mpiexec in ["mpiexec -n %d" % 1,
+                                            "mpiexec -n %d" % 2**dim]:
+                                #
+                                IGACreate = "./IGACreate"
+                                options = [
+                                    iga_dim,
+                                    iga_dof,
+                                    iga_mat_type,
+                                    iga_periodic,
+                                    iga_elements,
+                                    iga_degree,
+                                    iga_continuity,
+                                    ]
+                                if mat_type == 'is':
+                                    options.append('-pc_type jacobi')
+                                #
+                                cmd = " ".join([mpiexec, IGACreate] + options)
+                                if VERBOSE: print (cmd)
+                                ret = os.system(cmd)
+                                if ret:
+                                    print ("Error!")
+                                    sys.exit(ret)