Commits

Lisandro Dalcin committed 2bbf4db

Error if collocation in parallel or with periodicity

  • Participants
  • Parent commits edbf2af

Comments (0)

Files changed (3)

File demo/Laplace.c

   ierr = IGACreateVec(iga,&x);CHKERRQ(ierr);
   ierr = IGACreateVec(iga,&b);CHKERRQ(ierr);
   if (Collocation){
+    ierr = IGASetUseCollocation(iga,PETSC_TRUE);CHKERRQ(ierr); 
     ierr = IGASetUserSystem(iga,SystemCollocation,PETSC_NULL);CHKERRQ(ierr); 
     ierr = IGAComputeSystem(iga,A,b);CHKERRQ(ierr);
   }else{

File include/petiga.h

 PETSC_EXTERN PetscErrorCode IGAGetFieldName(IGA iga,PetscInt field,const char *name[]);
 PETSC_EXTERN PetscErrorCode IGASetOrder(IGA iga,PetscInt order);
 PETSC_EXTERN PetscErrorCode IGASetProcessors(IGA iga,PetscInt i,PetscInt processors);
+PETSC_EXTERN PetscErrorCode IGASetUseCollocation(IGA iga,PetscBool collocation);
 
 PETSC_EXTERN PetscErrorCode IGAGetAxis(IGA iga,PetscInt i,IGAAxis *axis);
 PETSC_EXTERN PetscErrorCode IGAGetRule(IGA iga,PetscInt i,IGARule *rule);

File src/petiga.c

   PetscFunctionReturn(0);
 }
 
-
 #undef  __FUNCT__
 #define __FUNCT__ "IGASetProcessors"
 PetscErrorCode IGASetProcessors(IGA iga,PetscInt i,PetscInt processors)
 }
 
 #undef  __FUNCT__
+#define __FUNCT__ "IGASetUseCollocation"
+PetscErrorCode IGASetUseCollocation(IGA iga,PetscBool collocation)
+{
+  PetscErrorCode ierr;
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(iga,IGA_CLASSID,1);
+  PetscValidLogicalCollectiveBool(iga,collocation,2);
+  if (!iga->collocation && collocation) {
+    PetscMPIInt size = 1;
+    PetscInt i, dim = (iga->dim > 0) ? iga->dim : 3;
+    PetscBool periodic = PETSC_FALSE;
+    ierr = MPI_Comm_size(((PetscObject)iga)->comm,&size);CHKERRQ(ierr);
+    for (i=0; i<dim; i++) if(iga->axis[i]->periodic) periodic = PETSC_TRUE;
+    if (size > 1) SETERRQ(((PetscObject)iga)->comm,PETSC_ERR_SUP,
+                          "Collocation not supported in parallel");
+    if (periodic) SETERRQ(((PetscObject)iga)->comm,PETSC_ERR_SUP,
+                          "Collocation not supported with periodicity");
+  }
+  iga->collocation = collocation;
+  PetscFunctionReturn(0);
+}
+
+#undef  __FUNCT__
 #define __FUNCT__ "IGAGetAxis"
 /*@
    IGAGetAxis - Returns a pointer to the i^th parametric axis associated with the IGA
         ierr = IGAAxisSetPeriodic(iga->axis[i],w);CHKERRQ(ierr);
       }
     
-    /* Collocation */
-    {
-      PetscBool collocation = iga->collocation;
-      ierr = PetscOptionsBool("-iga_collocation","Use collocation","IGASetCollocation",collocation,&collocation,&flg);CHKERRQ(ierr);
-      if (flg) {iga->collocation = collocation;/*ierr = IGASetCollocation(iga,collocation);CHKERRQ(ierr);*/}
-    }
-
     /* Geometry */
     ierr = PetscOptionsString("-iga_geometry","Specify IGA geometry file","IGARead",filename,filename,sizeof(filename),&flg);CHKERRQ(ierr);
     if (flg) { /* load from file */
 
   setupcalled:
 
+    /* Collocation */ {
+      PetscBool collocation = iga->collocation;
+      ierr = PetscOptionsBool("-iga_collocation","Use collocation","IGASetCollocation",collocation,&collocation,&flg);CHKERRQ(ierr);
+      if (flg) {ierr = IGASetUseCollocation(iga,collocation);CHKERRQ(ierr);}
+    }
+
     /* Matrix and Vector type */
     if (iga->dof == 1) {ierr = PetscStrcpy(mtype,MATAIJ);CHKERRQ(ierr);}
     if (iga->vectype)  {ierr = PetscStrncpy(vtype,iga->vectype,sizeof(vtype));CHKERRQ(ierr);}