static char help[] = "Tests the DMShellCreate() and PetscSectionCreate() for fieldsplit initialization."; #include "petscdmshell.h" #include "petscvec.h" int main(int argc, char **argv) { int i; PetscInt numeq = 10, start = 1, NF, NE, numFields = 2, numDof, numComp; PetscErrorCode ierr; DM FSDM; PetscScalar value; PetscSection FSSection; int field1inds[6], field2inds[4]; // We have a problem with 10 equations, i.e. 10dofs. // These dofs belong to two fields (field1 has 6dofs and field2 has 4dofs). // Here is a mapping from field dofs to global dofs field1inds[0] = 1; field1inds[1] = 2; field1inds[2] = 4; field1inds[3] = 6; field1inds[4] = 7; field1inds[5] = 9; field2inds[0] = 3; field2inds[1] = 5; field2inds[2] = 8; field2inds[3] = 10; // We would like to use a DMShell to represent this data structure. // To do so we start by creating a section with 10points having one dof each. PetscInitialize(&argc,&argv,(char*)0,help); ierr = PetscSectionCreate(PETSC_COMM_WORLD, &FSSection); ierr = PetscSectionSetChart(FSSection, start, numeq+1); ierr = PetscSectionGetChart(FSSection, &NF, &NE); printf("start=%i, End=%i.\n",NF,NE); for(i=0; i