Skip to content

Instantly share code, notes, and snippets.

@wence-
Created April 2, 2014 10:03
Show Gist options
  • Select an option

  • Save wence-/9931324 to your computer and use it in GitHub Desktop.

Select an option

Save wence-/9931324 to your computer and use it in GitHub Desktop.
PetscErrorCode PetscSectionSetField(PetscSection s, PetscInt field, PetscSection sub)
{
PetscErrorCode ierr;
const char *fieldName;
PetscFunctionBegin;
PetscValidHeaderSpecific(s,PETSC_SECTION_CLASSID,1);
PetscValidHeaderSpecific(sub,PETSC_SECTION_CLASSID,1);
if ((field <0) || (field >= s->numFields)) SETERRQ3(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Section field %d should be in [%d, %d)", field, 0, s->numFields);
ierr = PetscObjectReference((PetscObject) sub);CHKERRQ(ierr);
s->field[field] = sub;
ierr = PetscSectionGetFieldName(sub, 0, &fieldName);CHKERRQ(ierr);
ierr = PetscSectionSetFieldName(s, field, fieldName);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment