Commits

Nathan Collier  committed 5246ebc

added support for setting Dirichlet BCs using values from IGAProperty

  • Participants
  • Parent commits 0ce3466

Comments (0)

Files changed (3)

File include/petiga.h

   PetscInt    count;
   PetscInt    field[64];
   PetscScalar value[64];
+  PetscInt    property[64];
 };
 
 typedef struct _IGAFormOps *IGAFormOps;
 PETSC_EXTERN PetscErrorCode IGAFormReference(IGAForm form);
 
 PETSC_EXTERN PetscErrorCode IGAFormSetBoundaryValue(IGAForm form,PetscInt axis,PetscInt side,PetscInt field,PetscScalar value);
+PETSC_EXTERN PetscErrorCode IGAFormSetBoundaryByProperty(IGAForm form,PetscInt axis,PetscInt side,PetscInt field,PetscInt property_field);
 PETSC_EXTERN PetscErrorCode IGAFormSetBoundaryLoad (IGAForm form,PetscInt axis,PetscInt side,PetscInt field,PetscScalar value);
 PETSC_EXTERN PetscErrorCode IGAFormSetBoundaryForm (IGAForm form,PetscInt axis,PetscInt side,PetscBool flag);
 PETSC_EXTERN PetscErrorCode IGAFormClearBoundary   (IGAForm form,PetscInt axis,PetscInt side);
 PETSC_EXTERN PetscErrorCode IGAFormSetIEJacobian(IGAForm form,IGAFormIEJacobian IEJacobian,void *ctx);
 
 PETSC_EXTERN PetscErrorCode IGASetBoundaryValue(IGA iga,PetscInt axis,PetscInt side,PetscInt field,PetscScalar value);
+PETSC_EXTERN PetscErrorCode IGASetBoundaryByProperty(IGA iga,PetscInt axis,PetscInt side,PetscInt field,PetscInt property_field);
 PETSC_EXTERN PetscErrorCode IGASetBoundaryLoad (IGA iga,PetscInt axis,PetscInt side,PetscInt field,PetscScalar value);
 PETSC_EXTERN PetscErrorCode IGASetBoundaryForm (IGA iga,PetscInt axis,PetscInt side,PetscBool flag);
 

File src/petigaelem.c

     PetscInt j,k,n = bc->count;
     for (k=0; k<n; k++) {
       PetscInt idx = a*dof + bc->field[k];
+      PetscInt ipr = bc->property[k];
       PetscScalar val = bc->value[k];
+      if (ipr > -1) val = element->propertyA[a*element->npd+ipr];
       for (j=0; j<count; j++)
         if (index[j] == idx) break;
       if (j == count) count++;

File src/petigaform.c

   if (k == bc->count) bc->count++;
   bc->field[k] = field;
   bc->value[k] = value;
+  bc->property[k] = -1; /* do not use property vector */
+}
+
+PETSC_STATIC_INLINE
+void IGAFormBCSetProperty(IGAFormBC bc,PetscInt field,PetscInt property_field)
+{
+  PetscInt k;
+  for (k=0; k<bc->count; k++)
+    if (bc->field[k] == field) break;
+  if (k == bc->count) bc->count++;
+  bc->field[k]    = field;
+  bc->property[k] = property_field;
 }
 
 #undef  __FUNCT__
 }
 
 #undef  __FUNCT__
+#define __FUNCT__ "IGAFormSetBoundaryByProperty"
+PetscErrorCode IGAFormSetBoundaryByProperty(IGAForm form,PetscInt axis,PetscInt side,PetscInt field,PetscInt property_field)
+{
+  PetscFunctionBegin;
+  IGAFormCheckArg(axis,3);
+  IGAFormCheckArg(side,2);
+  IGAFormCheckArg(field,64);
+  IGAFormUpdateDof(form,field);
+  IGAFormBCSetProperty(form->value[axis][side],field,property_field);
+  PetscFunctionReturn(0);
+}
+
+#undef  __FUNCT__
 #define __FUNCT__ "IGAFormSetBoundaryLoad"
 PetscErrorCode IGAFormSetBoundaryLoad(IGAForm form,PetscInt axis,PetscInt side,PetscInt field,PetscScalar value)
 {
 }
 
 #undef  __FUNCT__
+#define __FUNCT__ "IGASetBoundaryByProperty"
+PetscErrorCode IGASetBoundaryByProperty(IGA iga,PetscInt axis,PetscInt side,PetscInt field,PetscInt property_field)
+{
+  PetscErrorCode ierr;
+  PetscFunctionBegin;
+  PetscValidHeaderSpecific(iga,IGA_CLASSID,1);
+  if (iga->dim > 0) IGAFormCheckArg(axis,iga->dim);
+  if (iga->dof > 0) IGAFormCheckArg(field,iga->dof);
+  ierr = IGAFormSetBoundaryByProperty(iga->form,axis,side,field,property_field);CHKERRQ(ierr);
+  PetscFunctionReturn(0);
+}
+
+#undef  __FUNCT__
 #define __FUNCT__ "IGASetBoundaryLoad"
 PetscErrorCode IGASetBoundaryLoad(IGA iga,PetscInt axis,PetscInt side,PetscInt field,PetscScalar value)
 {