1db4d5e8cSToby Isaac #include <petsc-private/dmforestimpl.h> 2db4d5e8cSToby Isaac #include <petsc-private/dmimpl.h> 3db4d5e8cSToby Isaac #include <petscsf.h> /*I "petscsf.h" */ 4db4d5e8cSToby Isaac 5db4d5e8cSToby Isaac #undef __FUNCT__ 6db4d5e8cSToby Isaac #define __FUNCT__ "DMClone_Forest" 7db4d5e8cSToby Isaac PETSC_EXTERN PetscErrorCode DMClone_Forest(DM dm, DM *newdm) 8db4d5e8cSToby Isaac { 9db4d5e8cSToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 10db4d5e8cSToby Isaac const char *type; 11db4d5e8cSToby Isaac PetscErrorCode ierr; 12db4d5e8cSToby Isaac 13db4d5e8cSToby Isaac PetscFunctionBegin; 14db4d5e8cSToby Isaac forest->refct++; 15db4d5e8cSToby Isaac (*newdm)->data = forest; 16db4d5e8cSToby Isaac ierr = PetscObjectGetType((PetscObject) dm, &type);CHKERRQ(ierr); 17db4d5e8cSToby Isaac ierr = PetscObjectChangeTypeName((PetscObject) *newdm, type);CHKERRQ(ierr); 18db4d5e8cSToby Isaac PetscFunctionReturn(0); 19db4d5e8cSToby Isaac } 20db4d5e8cSToby Isaac 21db4d5e8cSToby Isaac #undef __FUNCT__ 22db4d5e8cSToby Isaac #define __FUNCT__ "DMDestroy_Forest" 23db4d5e8cSToby Isaac PetscErrorCode DMDestroy_Forest(DM dm) 24db4d5e8cSToby Isaac { 25db4d5e8cSToby Isaac DM_Forest *forest = (DM_Forest*) dm->data; 26db4d5e8cSToby Isaac PetscErrorCode ierr; 27db4d5e8cSToby Isaac 28db4d5e8cSToby Isaac PetscFunctionBegin; 29db4d5e8cSToby Isaac if (--forest->refct > 0) PetscFunctionReturn(0); 30db4d5e8cSToby Isaac ierr = PetscSFDestroy(&forest->cellSF);CHKERRQ(ierr); 31db4d5e8cSToby Isaac if (forest->adaptCopyMode == PETSC_OWN_POINTER) { 32db4d5e8cSToby Isaac ierr = PetscFree(forest->adaptMarkers);CHKERRQ(ierr); 33db4d5e8cSToby Isaac } 34db4d5e8cSToby Isaac if (forest->cellWeightsCopyMode == PETSC_OWN_POINTER) { 35db4d5e8cSToby Isaac ierr = PetscFree(forest->cellWeights);CHKERRQ(ierr); 36db4d5e8cSToby Isaac } 37db4d5e8cSToby Isaac PetscFunctionReturn(0); 38db4d5e8cSToby Isaac } 39db4d5e8cSToby Isaac 40db4d5e8cSToby Isaac #undef __FUNCT__ 41dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetTopology" 42dd8e54a2SToby Isaac PetscErrorCode DMForestSetTopology(DM dm, DMForestTopology topology) 43db4d5e8cSToby Isaac { 44db4d5e8cSToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 45db4d5e8cSToby Isaac PetscErrorCode ierr; 46db4d5e8cSToby Isaac 47db4d5e8cSToby Isaac PetscFunctionBegin; 48db4d5e8cSToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 49dd8e54a2SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the topology after setup"); 50dd8e54a2SToby Isaac ierr = PetscFree(forest->topology);CHKERRQ(ierr); 51dd8e54a2SToby Isaac ierr = PetscStrallocpy((const char *)topology,(char **) &forest->topology);CHKERRQ(ierr); 52db4d5e8cSToby Isaac PetscFunctionReturn(0); 53db4d5e8cSToby Isaac } 54db4d5e8cSToby Isaac 55db4d5e8cSToby Isaac #undef __FUNCT__ 56dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetTopology" 57dd8e54a2SToby Isaac PetscErrorCode DMForestGetTopology(DM dm, DMForestTopology *topology) 58dd8e54a2SToby Isaac { 59dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 60dd8e54a2SToby Isaac 61dd8e54a2SToby Isaac PetscFunctionBegin; 62dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 63dd8e54a2SToby Isaac PetscValidPointer(topology,2); 64dd8e54a2SToby Isaac *topology = forest->topology; 65dd8e54a2SToby Isaac PetscFunctionReturn(0); 66dd8e54a2SToby Isaac } 67dd8e54a2SToby Isaac 68dd8e54a2SToby Isaac #undef __FUNCT__ 69dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetBaseDM" 70dd8e54a2SToby Isaac PetscErrorCode DMForestSetBaseDM(DM dm, DM base) 71dd8e54a2SToby Isaac { 72dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 73dd8e54a2SToby Isaac PetscInt dim, dimEmbed; 74dd8e54a2SToby Isaac PetscErrorCode ierr; 75dd8e54a2SToby Isaac 76dd8e54a2SToby Isaac PetscFunctionBegin; 77dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 78dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 2); 79dd8e54a2SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the base after setup"); 80dd8e54a2SToby Isaac ierr = PetscObjectReference((PetscObject)base);CHKERRQ(ierr); 81dd8e54a2SToby Isaac ierr = DMDestroy(&forest->base);CHKERRQ(ierr); 82dd8e54a2SToby Isaac forest->base = base; 83dd8e54a2SToby Isaac ierr = DMGetDimension(base,&dim);CHKERRQ(ierr); 84dd8e54a2SToby Isaac ierr = DMSetDimension(dm,dim);CHKERRQ(ierr); 85dd8e54a2SToby Isaac ierr = DMGetCoordinateDim(base,&dimEmbed);CHKERRQ(ierr); 86dd8e54a2SToby Isaac ierr = DMSetCoordinateDim(dm,dimEmbed);CHKERRQ(ierr); 87dd8e54a2SToby Isaac PetscFunctionReturn(0); 88dd8e54a2SToby Isaac } 89dd8e54a2SToby Isaac 90dd8e54a2SToby Isaac #undef __FUNCT__ 91dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetBaseDM" 92dd8e54a2SToby Isaac PetscErrorCode DMForestGetBaseDM(DM dm, DM *base) 93dd8e54a2SToby Isaac { 94dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 95dd8e54a2SToby Isaac 96dd8e54a2SToby Isaac PetscFunctionBegin; 97dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 98dd8e54a2SToby Isaac PetscValidPointer(base, 2); 99dd8e54a2SToby Isaac *base = forest->base; 100dd8e54a2SToby Isaac PetscFunctionReturn(0); 101dd8e54a2SToby Isaac } 102dd8e54a2SToby Isaac 103dd8e54a2SToby Isaac #undef __FUNCT__ 104dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetCoarseForest" 105dd8e54a2SToby Isaac PetscErrorCode DMForestSetCoarseForest(DM dm,DM coarse) 106dd8e54a2SToby Isaac { 107dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 108dd8e54a2SToby Isaac DM base; 109dd8e54a2SToby Isaac PetscErrorCode ierr; 110dd8e54a2SToby Isaac 111dd8e54a2SToby Isaac PetscFunctionBegin; 112dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 113dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 2); 114dd8e54a2SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the coarse forest after setup"); 115dd8e54a2SToby Isaac ierr = PetscObjectReference((PetscObject)coarse);CHKERRQ(ierr); 116dd8e54a2SToby Isaac ierr = DMDestroy(&forest->coarse);CHKERRQ(ierr); 117dd8e54a2SToby Isaac ierr = DMForestGetBaseDM(coarse,&base);CHKERRQ(ierr); 118dd8e54a2SToby Isaac ierr = DMForestSetBaseDM(dm,base);CHKERRQ(ierr); 119dd8e54a2SToby Isaac forest->coarse = coarse; 120dd8e54a2SToby Isaac PetscFunctionReturn(0); 121dd8e54a2SToby Isaac } 122dd8e54a2SToby Isaac 123dd8e54a2SToby Isaac #undef __FUNCT__ 124dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetCoarseForest" 125dd8e54a2SToby Isaac PetscErrorCode DMForestGetCoarseForest(DM dm, DM *coarse) 126dd8e54a2SToby Isaac { 127dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 128dd8e54a2SToby Isaac 129dd8e54a2SToby Isaac PetscFunctionBegin; 130dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 131dd8e54a2SToby Isaac PetscValidPointer(coarse, 2); 132dd8e54a2SToby Isaac *coarse = forest->coarse; 133dd8e54a2SToby Isaac PetscFunctionReturn(0); 134dd8e54a2SToby Isaac } 135dd8e54a2SToby Isaac 136dd8e54a2SToby Isaac #undef __FUNCT__ 137dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetFineForest" 138dd8e54a2SToby Isaac PetscErrorCode DMForestSetFineForest(DM dm,DM fine) 139dd8e54a2SToby Isaac { 140dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 141dd8e54a2SToby Isaac DM base; 142dd8e54a2SToby Isaac PetscErrorCode ierr; 143dd8e54a2SToby Isaac 144dd8e54a2SToby Isaac PetscFunctionBegin; 145dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 146dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 2); 147dd8e54a2SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the fine forest after setup"); 148dd8e54a2SToby Isaac ierr = PetscObjectReference((PetscObject)fine);CHKERRQ(ierr); 149dd8e54a2SToby Isaac ierr = DMDestroy(&forest->fine);CHKERRQ(ierr); 150dd8e54a2SToby Isaac ierr = DMForestGetBaseDM(fine,&base);CHKERRQ(ierr); 151dd8e54a2SToby Isaac ierr = DMForestSetBaseDM(dm,base);CHKERRQ(ierr); 152dd8e54a2SToby Isaac forest->fine = fine; 153dd8e54a2SToby Isaac PetscFunctionReturn(0); 154dd8e54a2SToby Isaac } 155dd8e54a2SToby Isaac 156dd8e54a2SToby Isaac #undef __FUNCT__ 157dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetFineForest_Forest" 158dd8e54a2SToby Isaac PetscErrorCode DMForestGetFineForest(DM dm, DM *fine) 159dd8e54a2SToby Isaac { 160dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 161dd8e54a2SToby Isaac 162dd8e54a2SToby Isaac PetscFunctionBegin; 163dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 164dd8e54a2SToby Isaac PetscValidPointer(fine, 2); 165dd8e54a2SToby Isaac *fine = forest->fine; 166dd8e54a2SToby Isaac PetscFunctionReturn(0); 167dd8e54a2SToby Isaac } 168dd8e54a2SToby Isaac 169dd8e54a2SToby Isaac #undef __FUNCT__ 170dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetAdjacencyDimension" 171dd8e54a2SToby Isaac PetscErrorCode DMForestSetAdjacencyDimension(DM dm, PetscInt adjDim) 172dd8e54a2SToby Isaac { 173dd8e54a2SToby Isaac PetscInt dim; 174dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 175dd8e54a2SToby Isaac PetscErrorCode ierr; 176dd8e54a2SToby Isaac 177dd8e54a2SToby Isaac PetscFunctionBegin; 178dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 179dd8e54a2SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the adjacency dimension after setup"); 180dd8e54a2SToby Isaac if (adjDim < 0) SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"adjacency dim cannot be < 0: %d", adjDim); 181dd8e54a2SToby Isaac ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr); 182dd8e54a2SToby Isaac if (adjDim > dim) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"adjacency dim cannot be > %d: %d", dim, adjDim); 183dd8e54a2SToby Isaac forest->adjDim = adjDim; 184dd8e54a2SToby Isaac PetscFunctionReturn(0); 185dd8e54a2SToby Isaac } 186dd8e54a2SToby Isaac 187dd8e54a2SToby Isaac #undef __FUNCT__ 188dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetAdjacencyCodimension" 189dd8e54a2SToby Isaac PetscErrorCode DMForestSetAdjacencyCodimension(DM dm, PetscInt adjCodim) 190dd8e54a2SToby Isaac { 191dd8e54a2SToby Isaac PetscInt dim; 192dd8e54a2SToby Isaac PetscErrorCode ierr; 193dd8e54a2SToby Isaac 194dd8e54a2SToby Isaac PetscFunctionBegin; 195dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 196dd8e54a2SToby Isaac ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr); 197dd8e54a2SToby Isaac ierr = DMForestSetAdjacencyDimension(dm,dim-adjCodim);CHKERRQ(ierr); 198dd8e54a2SToby Isaac PetscFunctionReturn(0); 199dd8e54a2SToby Isaac } 200dd8e54a2SToby Isaac 201dd8e54a2SToby Isaac #undef __FUNCT__ 202dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetAdjacencyDimension" 203dd8e54a2SToby Isaac PetscErrorCode DMForestGetAdjacencyDimension(DM dm, PetscInt *adjDim) 204dd8e54a2SToby Isaac { 205dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 206dd8e54a2SToby Isaac 207dd8e54a2SToby Isaac PetscFunctionBegin; 208dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 209dd8e54a2SToby Isaac PetscValidIntPointer(adjDim,2); 210dd8e54a2SToby Isaac *adjDim = forest->adjDim; 211dd8e54a2SToby Isaac PetscFunctionReturn(0); 212dd8e54a2SToby Isaac } 213dd8e54a2SToby Isaac 214dd8e54a2SToby Isaac #undef __FUNCT__ 215dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetAdjacencyCodimension" 216dd8e54a2SToby Isaac PetscErrorCode DMForestGetAdjacencyCodimension(DM dm, PetscInt *adjCodim) 217dd8e54a2SToby Isaac { 218dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 219dd8e54a2SToby Isaac PetscInt dim; 220dd8e54a2SToby Isaac PetscErrorCode ierr; 221dd8e54a2SToby Isaac 222dd8e54a2SToby Isaac PetscFunctionBegin; 223dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 224dd8e54a2SToby Isaac PetscValidIntPointer(adjCodim,2); 225dd8e54a2SToby Isaac ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr); 226dd8e54a2SToby Isaac *adjCodim = dim - forest->adjDim; 227dd8e54a2SToby Isaac PetscFunctionReturn(0); 228dd8e54a2SToby Isaac } 229dd8e54a2SToby Isaac 230dd8e54a2SToby Isaac #undef __FUNCT__ 231dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetParititionOverlap" 232dd8e54a2SToby Isaac PetscErrorCode DMForestSetPartitionOverlap(DM dm, PetscInt overlap) 233dd8e54a2SToby Isaac { 234dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 235dd8e54a2SToby Isaac 236dd8e54a2SToby Isaac PetscFunctionBegin; 237dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 238dd8e54a2SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the overlap after setup"); 239dd8e54a2SToby Isaac if (overlap < 0) SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"overlap cannot be < 0: %d", overlap); 240dd8e54a2SToby Isaac forest->overlap = overlap; 241dd8e54a2SToby Isaac PetscFunctionReturn(0); 242dd8e54a2SToby Isaac } 243dd8e54a2SToby Isaac 244dd8e54a2SToby Isaac #undef __FUNCT__ 245dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetPartitionOverlap" 246dd8e54a2SToby Isaac PetscErrorCode DMForestGetPartitionOverlap(DM dm, PetscInt *overlap) 247dd8e54a2SToby Isaac { 248dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 249dd8e54a2SToby Isaac 250dd8e54a2SToby Isaac PetscFunctionBegin; 251dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 252dd8e54a2SToby Isaac PetscValidIntPointer(overlap,2); 253dd8e54a2SToby Isaac *overlap = forest->overlap; 254dd8e54a2SToby Isaac PetscFunctionReturn(0); 255dd8e54a2SToby Isaac } 256dd8e54a2SToby Isaac 257dd8e54a2SToby Isaac #undef __FUNCT__ 258dd8e54a2SToby Isaac #define __FUNCT__ "DMForestSetMinimumRefinement" 259dd8e54a2SToby Isaac PetscErrorCode DMForestSetMinimumRefinement(DM dm, PetscInt minRefinement) 260dd8e54a2SToby Isaac { 261dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 262dd8e54a2SToby Isaac 263dd8e54a2SToby Isaac PetscFunctionBegin; 264dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 265dd8e54a2SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the minimum refinement after setup"); 266dd8e54a2SToby Isaac forest->minRefinement = minRefinement; 267dd8e54a2SToby Isaac PetscFunctionReturn(0); 268dd8e54a2SToby Isaac } 269dd8e54a2SToby Isaac 270dd8e54a2SToby Isaac #undef __FUNCT__ 271dd8e54a2SToby Isaac #define __FUNCT__ "DMForestGetMinimumRefinement" 272dd8e54a2SToby Isaac PetscErrorCode DMForestGetMinimumRefinement(DM dm, PetscInt *minRefinement) 273dd8e54a2SToby Isaac { 274dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 275dd8e54a2SToby Isaac 276dd8e54a2SToby Isaac PetscFunctionBegin; 277dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 278dd8e54a2SToby Isaac PetscValidIntPointer(minRefinement,2); 279dd8e54a2SToby Isaac *minRefinement = forest->minRefinement; 280dd8e54a2SToby Isaac PetscFunctionReturn(0); 281dd8e54a2SToby Isaac } 282dd8e54a2SToby Isaac 283dd8e54a2SToby Isaac #undef __FUNCT__ 284*c7eeac06SToby Isaac #define __FUNCT__ "DMForestSetMaximumRefinement" 285*c7eeac06SToby Isaac PetscErrorCode DMForestSetMaximumRefinement(DM dm, PetscInt maxRefinement) 286dd8e54a2SToby Isaac { 287dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 288dd8e54a2SToby Isaac 289dd8e54a2SToby Isaac PetscFunctionBegin; 290dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 291*c7eeac06SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the maximum refinement after setup"); 292*c7eeac06SToby Isaac forest->maxRefinement = maxRefinement; 293dd8e54a2SToby Isaac PetscFunctionReturn(0); 294dd8e54a2SToby Isaac } 295dd8e54a2SToby Isaac 296dd8e54a2SToby Isaac #undef __FUNCT__ 297*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetMaximumRefinement" 298*c7eeac06SToby Isaac PetscErrorCode DMForestGetMaximumRefinement (DM dm, PetscInt *maxRefinement) 299dd8e54a2SToby Isaac { 300dd8e54a2SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 301dd8e54a2SToby Isaac 302dd8e54a2SToby Isaac PetscFunctionBegin; 303dd8e54a2SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 304*c7eeac06SToby Isaac PetscValidIntPointer(maxRefinement,2); 305*c7eeac06SToby Isaac *maxRefinement = forest->maxRefinement; 306dd8e54a2SToby Isaac PetscFunctionReturn(0); 307dd8e54a2SToby Isaac } 308*c7eeac06SToby Isaac 309*c7eeac06SToby Isaac #undef __FUNCT__ 310*c7eeac06SToby Isaac #define __FUNCT__ "DMForestSetAdaptivityStrategy" 311*c7eeac06SToby Isaac PetscErrorCode DMForestSetAdaptivityStrategy(DM dm, DMForestAdaptivityStrategy adaptStrategy) 312*c7eeac06SToby Isaac { 313*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 314*c7eeac06SToby Isaac PetscErrorCode ierr; 315*c7eeac06SToby Isaac 316*c7eeac06SToby Isaac PetscFunctionBegin; 317*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 318*c7eeac06SToby Isaac ierr = PetscFree(forest->adaptStrategy);CHKERRQ(ierr); 319*c7eeac06SToby Isaac ierr = PetscStrallocpy((const char *)adaptStrategy,(char **)adaptStrategy);CHKERRQ(ierr); 320*c7eeac06SToby Isaac PetscFunctionReturn(0); 321*c7eeac06SToby Isaac } 322*c7eeac06SToby Isaac 323*c7eeac06SToby Isaac #undef __FUNCT__ 324*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetAdaptivityStrategy" 325*c7eeac06SToby Isaac PetscErrorCode DMForestGetAdaptivityStrategy(DM dm, DMForestAdaptivityStrategy *adaptStrategy) 326*c7eeac06SToby Isaac { 327*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 328*c7eeac06SToby Isaac 329*c7eeac06SToby Isaac PetscFunctionBegin; 330*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 331*c7eeac06SToby Isaac PetscValidPointer(adaptStrategy,2); 332*c7eeac06SToby Isaac *adaptStrategy = forest->adaptStrategy; 333*c7eeac06SToby Isaac PetscFunctionReturn(0); 334*c7eeac06SToby Isaac } 335*c7eeac06SToby Isaac 336*c7eeac06SToby Isaac #undef __FUNCT__ 337*c7eeac06SToby Isaac #define __FUNCT__ "DMForestSetGradeFactor" 338*c7eeac06SToby Isaac PetscErrorCode DMForestSetGradeFactor(DM dm, PetscInt grade) 339*c7eeac06SToby Isaac { 340*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 341*c7eeac06SToby Isaac 342*c7eeac06SToby Isaac PetscFunctionBegin; 343*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 344*c7eeac06SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the grade factor after setup"); 345*c7eeac06SToby Isaac forest->gradeFactor = grade; 346*c7eeac06SToby Isaac PetscFunctionReturn(0); 347*c7eeac06SToby Isaac } 348*c7eeac06SToby Isaac 349*c7eeac06SToby Isaac #undef __FUNCT__ 350*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetGradeFactor" 351*c7eeac06SToby Isaac PetscErrorCode DMForestGetGradeFactor(DM dm, PetscInt *grade) 352*c7eeac06SToby Isaac { 353*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 354*c7eeac06SToby Isaac 355*c7eeac06SToby Isaac PetscFunctionBegin; 356*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 357*c7eeac06SToby Isaac PetscValidIntPointer(grade,2); 358*c7eeac06SToby Isaac *grade = forest->gradeFactor; 359*c7eeac06SToby Isaac PetscFunctionReturn(0); 360*c7eeac06SToby Isaac } 361*c7eeac06SToby Isaac 362*c7eeac06SToby Isaac #undef __FUNCT__ 363*c7eeac06SToby Isaac #define __FUNCT__ "DMForestSetCellWeightsFactor" 364*c7eeac06SToby Isaac PetscErrorCode DMForestSetCellWeightsFactor(DM dm, PetscReal weightsFactor) 365*c7eeac06SToby Isaac { 366*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 367*c7eeac06SToby Isaac 368*c7eeac06SToby Isaac PetscFunctionBegin; 369*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 370*c7eeac06SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the weights factor after setup"); 371*c7eeac06SToby Isaac forest->weightsFactor = weightsFactor; 372*c7eeac06SToby Isaac PetscFunctionReturn(0); 373*c7eeac06SToby Isaac } 374*c7eeac06SToby Isaac 375*c7eeac06SToby Isaac #undef __FUNCT__ 376*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetCellWeightsFactor" 377*c7eeac06SToby Isaac PetscErrorCode DMForestGetCellWeightsFactor(DM dm, PetscReal *weightsFactor) 378*c7eeac06SToby Isaac { 379*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 380*c7eeac06SToby Isaac 381*c7eeac06SToby Isaac PetscFunctionBegin; 382*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 383*c7eeac06SToby Isaac PetscValidRealPointer(weightsFactor,2); 384*c7eeac06SToby Isaac *weightsFactor = forest->weightsFactor; 385*c7eeac06SToby Isaac PetscFunctionReturn(0); 386*c7eeac06SToby Isaac } 387*c7eeac06SToby Isaac 388*c7eeac06SToby Isaac #undef __FUNCT__ 389*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetCellChart" 390*c7eeac06SToby Isaac PetscErrorCode DMForestGetCellChart(DM dm, PetscInt *cStart, PetscInt *cEnd) 391*c7eeac06SToby Isaac { 392*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 393*c7eeac06SToby Isaac PetscErrorCode ierr; 394*c7eeac06SToby Isaac 395*c7eeac06SToby Isaac PetscFunctionBegin; 396*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 397*c7eeac06SToby Isaac PetscValidIntPointer(cStart,2); 398*c7eeac06SToby Isaac PetscValidIntPointer(cEnd,2); 399*c7eeac06SToby Isaac if (((forest->cStart == PETSC_DETERMINE) || (forest->cEnd == PETSC_DETERMINE)) && forest->createcellchart) { 400*c7eeac06SToby Isaac ierr = forest->createcellchart(dm,&forest->cStart,&forest->cEnd);CHKERRQ(ierr); 401*c7eeac06SToby Isaac } 402*c7eeac06SToby Isaac *cStart = forest->cStart; 403*c7eeac06SToby Isaac *cEnd = forest->cEnd; 404*c7eeac06SToby Isaac PetscFunctionReturn(0); 405*c7eeac06SToby Isaac } 406*c7eeac06SToby Isaac 407*c7eeac06SToby Isaac #undef __FUNCT__ 408*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetCellSF" 409*c7eeac06SToby Isaac PetscErrorCode DMForestGetCellSF(DM dm, PetscSF *cellSF) 410*c7eeac06SToby Isaac { 411*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 412*c7eeac06SToby Isaac PetscErrorCode ierr; 413*c7eeac06SToby Isaac 414*c7eeac06SToby Isaac PetscFunctionBegin; 415*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 416*c7eeac06SToby Isaac PetscValidPointer(cellSF,2); 417*c7eeac06SToby Isaac if ((!forest->cellSF) && forest->createcellsf) { 418*c7eeac06SToby Isaac ierr = forest->createcellsf(dm,&forest->cellSF);CHKERRQ(ierr); 419*c7eeac06SToby Isaac } 420*c7eeac06SToby Isaac *cellSF = forest->cellSF; 421*c7eeac06SToby Isaac PetscFunctionReturn(0); 422*c7eeac06SToby Isaac } 423*c7eeac06SToby Isaac 424*c7eeac06SToby Isaac #undef __FUNCT__ 425*c7eeac06SToby Isaac #define __FUNCT__ "DMForestSetAdaptivityMarkers" 426*c7eeac06SToby Isaac PetscErrorCode DMForestSetAdaptivityMarkers(DM dm, PetscInt markers[], PetscCopyMode copyMode) 427*c7eeac06SToby Isaac { 428*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 429*c7eeac06SToby Isaac PetscInt cStart, cEnd; 430*c7eeac06SToby Isaac PetscErrorCode ierr; 431*c7eeac06SToby Isaac 432*c7eeac06SToby Isaac PetscFunctionBegin; 433*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm,DM_CLASSID,1); 434*c7eeac06SToby Isaac ierr = DMForestGetCellChart(dm,&cStart,&cEnd);CHKERRQ(ierr); 435*c7eeac06SToby Isaac if (cEnd < cStart) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"cell chart [%d,%d) is not valid",cStart,cEnd); 436*c7eeac06SToby Isaac if (copyMode == PETSC_COPY_VALUES) { 437*c7eeac06SToby Isaac if (forest->adaptCopyMode != PETSC_OWN_POINTER || forest->adaptMarkers == markers) { 438*c7eeac06SToby Isaac ierr = PetscMalloc1(cEnd-cStart,&forest->adaptMarkers);CHKERRQ(ierr); 439*c7eeac06SToby Isaac } 440*c7eeac06SToby Isaac ierr = PetscMemcpy(forest->adaptMarkers,markers,(cEnd-cStart)*sizeof(*markers));CHKERRQ(ierr); 441*c7eeac06SToby Isaac forest->adaptCopyMode = PETSC_OWN_POINTER; 442*c7eeac06SToby Isaac PetscFunctionReturn(0); 443*c7eeac06SToby Isaac } 444*c7eeac06SToby Isaac if (forest->adaptCopyMode == PETSC_OWN_POINTER) { 445*c7eeac06SToby Isaac ierr = PetscFree(forest->adaptMarkers);CHKERRQ(ierr); 446*c7eeac06SToby Isaac } 447*c7eeac06SToby Isaac forest->adaptMarkers = markers; 448*c7eeac06SToby Isaac forest->adaptCopyMode = copyMode; 449*c7eeac06SToby Isaac PetscFunctionReturn(0); 450*c7eeac06SToby Isaac } 451*c7eeac06SToby Isaac 452*c7eeac06SToby Isaac #undef __FUNCT__ 453*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetAdaptivityMarkers" 454*c7eeac06SToby Isaac PetscErrorCode DMForestGetAdaptivityMarkers(DM dm, PetscInt **markers) 455*c7eeac06SToby Isaac { 456*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 457*c7eeac06SToby Isaac 458*c7eeac06SToby Isaac PetscFunctionBegin; 459*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 460*c7eeac06SToby Isaac PetscValidPointer(markers,2); 461*c7eeac06SToby Isaac *markers = forest->adaptMarkers; 462*c7eeac06SToby Isaac PetscFunctionReturn(0); 463*c7eeac06SToby Isaac } 464*c7eeac06SToby Isaac 465*c7eeac06SToby Isaac #undef __FUNCT__ 466*c7eeac06SToby Isaac #define __FUNCT__ "DMForestSetCellWeights" 467*c7eeac06SToby Isaac PetscErrorCode DMForestSetCellWeights(DM dm, PetscReal weights[], PetscCopyMode copyMode) 468*c7eeac06SToby Isaac { 469*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 470*c7eeac06SToby Isaac PetscInt cStart, cEnd; 471*c7eeac06SToby Isaac PetscErrorCode ierr; 472*c7eeac06SToby Isaac 473*c7eeac06SToby Isaac PetscFunctionBegin; 474*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm,DM_CLASSID,1); 475*c7eeac06SToby Isaac ierr = DMForestGetCellChart(dm,&cStart,&cEnd);CHKERRQ(ierr); 476*c7eeac06SToby Isaac if (cEnd < cStart) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"cell chart [%d,%d) is not valid",cStart,cEnd); 477*c7eeac06SToby Isaac if (copyMode == PETSC_COPY_VALUES) { 478*c7eeac06SToby Isaac if (forest->cellWeightsCopyMode != PETSC_OWN_POINTER || forest->cellWeights == weights) { 479*c7eeac06SToby Isaac ierr = PetscMalloc1(cEnd-cStart,&forest->cellWeights);CHKERRQ(ierr); 480*c7eeac06SToby Isaac } 481*c7eeac06SToby Isaac ierr = PetscMemcpy(forest->cellWeights,weights,(cEnd-cStart)*sizeof(*weights));CHKERRQ(ierr); 482*c7eeac06SToby Isaac forest->cellWeightsCopyMode = PETSC_OWN_POINTER; 483*c7eeac06SToby Isaac PetscFunctionReturn(0); 484*c7eeac06SToby Isaac } 485*c7eeac06SToby Isaac if (forest->cellWeightsCopyMode == PETSC_OWN_POINTER) { 486*c7eeac06SToby Isaac ierr = PetscFree(forest->cellWeights);CHKERRQ(ierr); 487*c7eeac06SToby Isaac } 488*c7eeac06SToby Isaac forest->cellWeights = weights; 489*c7eeac06SToby Isaac forest->cellWeightsCopyMode = copyMode; 490*c7eeac06SToby Isaac PetscFunctionReturn(0); 491*c7eeac06SToby Isaac } 492*c7eeac06SToby Isaac 493*c7eeac06SToby Isaac #undef __FUNCT__ 494*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetCellWeights" 495*c7eeac06SToby Isaac PetscErrorCode DMForestGetCellWeights(DM dm, PetscReal **weights) 496*c7eeac06SToby Isaac { 497*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 498*c7eeac06SToby Isaac 499*c7eeac06SToby Isaac PetscFunctionBegin; 500*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 501*c7eeac06SToby Isaac PetscValidPointer(weights,2); 502*c7eeac06SToby Isaac *weights = forest->cellWeights; 503*c7eeac06SToby Isaac PetscFunctionReturn(0); 504*c7eeac06SToby Isaac } 505*c7eeac06SToby Isaac 506*c7eeac06SToby Isaac #undef __FUNCT__ 507*c7eeac06SToby Isaac #define __FUNCT__ "DMForestSetWeightCapacity" 508*c7eeac06SToby Isaac PetscErrorCode DMForestSetWeightCapacity(DM dm, PetscReal capacity) 509*c7eeac06SToby Isaac { 510*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 511*c7eeac06SToby Isaac 512*c7eeac06SToby Isaac PetscFunctionBegin; 513*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm,DM_CLASSID,1); 514*c7eeac06SToby Isaac if (forest->setup) SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_WRONGSTATE,"Cannot change the weight capacity after setup"); 515*c7eeac06SToby Isaac if (capacity < 0.) SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"Cannot have negative weight capacity; %f",capacity); 516*c7eeac06SToby Isaac forest->weightCapacity = capacity; 517*c7eeac06SToby Isaac PetscFunctionReturn(0); 518*c7eeac06SToby Isaac } 519*c7eeac06SToby Isaac 520*c7eeac06SToby Isaac #undef __FUNCT__ 521*c7eeac06SToby Isaac #define __FUNCT__ "DMForestGetWeightCapacity" 522*c7eeac06SToby Isaac PetscErrorCode DMForestGetWeightCapacity(DM dm, PetscReal *capacity) 523*c7eeac06SToby Isaac { 524*c7eeac06SToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 525*c7eeac06SToby Isaac 526*c7eeac06SToby Isaac PetscFunctionBegin; 527*c7eeac06SToby Isaac PetscValidHeaderSpecific(dm,DM_CLASSID,1); 528*c7eeac06SToby Isaac PetscValidRealPointer(capacity,2); 529*c7eeac06SToby Isaac *capacity = forest->weightCapacity; 530*c7eeac06SToby Isaac PetscFunctionReturn(0); 531*c7eeac06SToby Isaac } 532*c7eeac06SToby Isaac 533dd8e54a2SToby Isaac #undef __FUNCT__ 534db4d5e8cSToby Isaac #define __FUNCT__ "DMSetFromOptions_Forest" 535db4d5e8cSToby Isaac PetscErrorCode DMSetFromFromOptions_Forest(DM dm) 536db4d5e8cSToby Isaac { 537db4d5e8cSToby Isaac DM_Forest *forest = (DM_Forest *) dm->data; 538dd8e54a2SToby Isaac PetscBool flg; 539dd8e54a2SToby Isaac DMForestTopology oldTopo; 540*c7eeac06SToby Isaac char stringBuffer[256]; 541dd8e54a2SToby Isaac PetscViewer viewer; 542dd8e54a2SToby Isaac PetscViewerFormat format; 543*c7eeac06SToby Isaac PetscInt adjDim, adjCodim, overlap, minRefinement, maxRefinement, grade; 544*c7eeac06SToby Isaac PetscReal weightsFactor; 545*c7eeac06SToby Isaac DMForestAdaptivityStrategy adaptStrategy; 546db4d5e8cSToby Isaac PetscErrorCode ierr; 547db4d5e8cSToby Isaac 548db4d5e8cSToby Isaac PetscFunctionBegin; 549db4d5e8cSToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 550db4d5e8cSToby Isaac forest->setFromOptions = PETSC_TRUE; 551db4d5e8cSToby Isaac ierr = PetscOptionsHead("DMForest Options");CHKERRQ(ierr); 552dd8e54a2SToby Isaac ierr = DMForestGetTopology(dm, &oldTopo);CHKERRQ(ierr); 553*c7eeac06SToby Isaac ierr = PetscOptionsString("-dm_forest_topology","the topology of the forest's base mesh","DMForestSetTopology",oldTopo,stringBuffer,256,&flg);CHKERRQ(ierr); 554db4d5e8cSToby Isaac if (flg) { 555*c7eeac06SToby Isaac ierr = DMForestSetTopology(dm,(DMForestTopology)stringBuffer);CHKERRQ(ierr); 556dd8e54a2SToby Isaac } 557dd8e54a2SToby Isaac ierr = PetscOptionsViewer("-dm_forest_base_dm","load the base DM from a viewer specification","DMForestSetBaseDM",&viewer,&format,&flg);CHKERRQ(ierr); 558dd8e54a2SToby Isaac if (flg) { 559dd8e54a2SToby Isaac DM base; 560dd8e54a2SToby Isaac 561dd8e54a2SToby Isaac ierr = DMCreate(PetscObjectComm((PetscObject)dm),&base);CHKERRQ(ierr); 562dd8e54a2SToby Isaac ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); 563dd8e54a2SToby Isaac ierr = DMLoad(base,viewer);CHKERRQ(ierr); 564dd8e54a2SToby Isaac ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); 565dd8e54a2SToby Isaac ierr = DMForestSetBaseDM(dm,base);CHKERRQ(ierr); 566dd8e54a2SToby Isaac ierr = DMDestroy(&base);CHKERRQ(ierr); 567dd8e54a2SToby Isaac } 568dd8e54a2SToby Isaac ierr = PetscOptionsViewer("-dm_forest_coarse_forest","load the coarse forest from a viewer specification","DMForestSetCoarseForest",&viewer,&format,&flg);CHKERRQ(ierr); 569dd8e54a2SToby Isaac if (flg) { 570dd8e54a2SToby Isaac DM coarse; 571dd8e54a2SToby Isaac 572dd8e54a2SToby Isaac ierr = DMCreate(PetscObjectComm((PetscObject)dm),&coarse);CHKERRQ(ierr); 573dd8e54a2SToby Isaac ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); 574dd8e54a2SToby Isaac ierr = DMLoad(coarse,viewer);CHKERRQ(ierr); 575dd8e54a2SToby Isaac ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); 576dd8e54a2SToby Isaac ierr = DMForestSetCoarseForest(dm,coarse);CHKERRQ(ierr); 577dd8e54a2SToby Isaac ierr = DMDestroy(&coarse);CHKERRQ(ierr); 578dd8e54a2SToby Isaac } 579dd8e54a2SToby Isaac ierr = PetscOptionsViewer("-dm_forest_fine_forest","load the fine forest from a viewer specification","DMForestSetFineForest",&viewer,&format,&flg);CHKERRQ(ierr); 580dd8e54a2SToby Isaac if (flg) { 581dd8e54a2SToby Isaac DM fine; 582dd8e54a2SToby Isaac 583dd8e54a2SToby Isaac ierr = DMCreate(PetscObjectComm((PetscObject)dm),&fine);CHKERRQ(ierr); 584dd8e54a2SToby Isaac ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); 585dd8e54a2SToby Isaac ierr = DMLoad(fine,viewer);CHKERRQ(ierr); 586dd8e54a2SToby Isaac ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); 587dd8e54a2SToby Isaac ierr = DMForestSetFineForest(dm,fine);CHKERRQ(ierr); 588dd8e54a2SToby Isaac ierr = DMDestroy(&fine);CHKERRQ(ierr); 589dd8e54a2SToby Isaac } 590dd8e54a2SToby Isaac ierr = DMForestGetAdjacencyDimension(dm,&adjDim);CHKERRQ(ierr); 591dd8e54a2SToby Isaac ierr = PetscOptionsInt("-dm_forest_adjacency_dimension","set the dimension of points that define adjacency in the forest","DMForestSetAdjacencyDimension",adjDim,&adjDim,&flg);CHKERRQ(ierr); 592dd8e54a2SToby Isaac if (flg) { 593dd8e54a2SToby Isaac ierr = DMForestSetAdjacencyDimension(dm,adjDim);CHKERRQ(ierr); 594dd8e54a2SToby Isaac } 595dd8e54a2SToby Isaac else { 596dd8e54a2SToby Isaac ierr = DMForestGetAdjacencyCodimension(dm,&adjCodim);CHKERRQ(ierr); 597dd8e54a2SToby Isaac ierr = PetscOptionsInt("-dm_forest_adjacency_codimension","set the codimension of points that define adjacency in the forest","DMForestSetAdjacencyCodimension",adjCodim,&adjCodim,&flg);CHKERRQ(ierr); 598dd8e54a2SToby Isaac if (flg) { 599dd8e54a2SToby Isaac ierr = DMForestSetAdjacencyCodimension(dm,adjCodim);CHKERRQ(ierr); 600dd8e54a2SToby Isaac } 601dd8e54a2SToby Isaac } 602dd8e54a2SToby Isaac ierr = DMForestGetPartitionOverlap(dm,&overlap);CHKERRQ(ierr); 603dd8e54a2SToby Isaac ierr = PetscOptionsInt("-dm_forest_partition_overlap","set the degree of partition overlap","DMForestSetPartitionOverlap",overlap,&overlap,&flg);CHKERRQ(ierr); 604dd8e54a2SToby Isaac if (flg) { 605dd8e54a2SToby Isaac ierr = DMForestSetPartitionOverlap(dm,overlap);CHKERRQ(ierr); 606dd8e54a2SToby Isaac } 607dd8e54a2SToby Isaac ierr = DMForestGetMinimumRefinement(dm,&minRefinement);CHKERRQ(ierr); 608dd8e54a2SToby Isaac ierr = PetscOptionsInt("-dm_forest_minimum_refinement","set the minimum level of refinement in the forest","DMForestSetMinimumRefinement",minRefinement,&minRefinement,&flg);CHKERRQ(ierr); 609dd8e54a2SToby Isaac if (flg) { 610dd8e54a2SToby Isaac ierr = DMForestSetMinimumRefinement(dm,minRefinement);CHKERRQ(ierr); 611db4d5e8cSToby Isaac } 612*c7eeac06SToby Isaac ierr = DMForestGetMaximumRefinement(dm,&maxRefinement);CHKERRQ(ierr); 613*c7eeac06SToby Isaac ierr = PetscOptionsInt("-dm_forest_maximum_refinement","set the maximum level of refinement in the forest","DMForestSetMaximumRefinement",maxRefinement,&maxRefinement,&flg);CHKERRQ(ierr); 614*c7eeac06SToby Isaac if (flg) { 615*c7eeac06SToby Isaac ierr = DMForestSetMaximumRefinement(dm,maxRefinement);CHKERRQ(ierr); 616*c7eeac06SToby Isaac } 617*c7eeac06SToby Isaac ierr = DMForestGetAdaptivityStrategy(dm,&adaptStrategy);CHKERRQ(ierr); 618*c7eeac06SToby Isaac ierr = PetscOptionsString("-dm_forest_adaptivity_strategy","the forest's adaptivity-flag resolution strategy","DMForestSetAdaptivityStrategy",adaptStrategy,stringBuffer,256,&flg);CHKERRQ(ierr); 619*c7eeac06SToby Isaac if (flg) { 620*c7eeac06SToby Isaac ierr = DMForestSetAdaptivityStrategy(dm,(DMForestAdaptivityStrategy)stringBuffer);CHKERRQ(ierr); 621*c7eeac06SToby Isaac } 622*c7eeac06SToby Isaac ierr = DMForestGetGradeFactor(dm,&grade);CHKERRQ(ierr); 623*c7eeac06SToby Isaac ierr = PetscOptionsInt("-dm_forest_grade_factor","grade factor between neighboring cells","DMForestSetGradeFactor",grade,&grade,&flg);CHKERRQ(ierr); 624*c7eeac06SToby Isaac if (flg) { 625*c7eeac06SToby Isaac ierr = DMForestSetGradeFactor(dm,grade);CHKERRQ(ierr); 626*c7eeac06SToby Isaac } 627*c7eeac06SToby Isaac ierr = DMForestGetCellWeightFactor(dm,&weightsFactor);CHKERRQ(ierr); 628*c7eeac06SToby Isaac ierr = PetscOptionsReal("-dm_forest_cell_weight_factor","multiplying weight factor for cell refinement","DMForestSetCellWeightFactor",weightsFactor,&weightsFactor,&flg);CHKERRQ(ierr); 629*c7eeac06SToby Isaac if (flg) { 630*c7eeac06SToby Isaac ierr = DMForestSetCellWeightFactor(dm,weightsFactor);CHKERRQ(ierr); 631*c7eeac06SToby Isaac } 632db4d5e8cSToby Isaac ierr = PetscOptionsTail();CHKERRQ(ierr); 633db4d5e8cSToby Isaac PetscFunctionReturn(0); 634db4d5e8cSToby Isaac } 635db4d5e8cSToby Isaac 636db4d5e8cSToby Isaac #undef __FUNCT__ 637db4d5e8cSToby Isaac #define __FUNCT__ "DMCreate_Forest" 638db4d5e8cSToby Isaac PETSC_EXTERN PetscErrorCode DMCreate_Forest(DM dm) 639db4d5e8cSToby Isaac { 640db4d5e8cSToby Isaac DM_Forest *forest; 641db4d5e8cSToby Isaac PetscErrorCode ierr; 642db4d5e8cSToby Isaac 643db4d5e8cSToby Isaac PetscFunctionBegin; 644db4d5e8cSToby Isaac PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 645db4d5e8cSToby Isaac ierr = PetscNewLog(dm,&forest);CHKERRQ(ierr); 646db4d5e8cSToby Isaac dm->dim = 0; 647db4d5e8cSToby Isaac dm->data = forest; 648db4d5e8cSToby Isaac forest->refct = 1; 649db4d5e8cSToby Isaac forest->data = NULL; 650db4d5e8cSToby Isaac forest->setup = 0; 651dd8e54a2SToby Isaac forest->setFromOptions = PETSC_FALSE; 652db4d5e8cSToby Isaac forest->topology = NULL; 653db4d5e8cSToby Isaac forest->base = NULL; 654db4d5e8cSToby Isaac forest->coarse = NULL; 655db4d5e8cSToby Isaac forest->fine = NULL; 656db4d5e8cSToby Isaac forest->adjDim = PETSC_DEFAULT; 657db4d5e8cSToby Isaac forest->overlap = PETSC_DEFAULT; 658db4d5e8cSToby Isaac forest->minRefinement = PETSC_DEFAULT; 659db4d5e8cSToby Isaac forest->maxRefinement = PETSC_DEFAULT; 660*c7eeac06SToby Isaac forest->cStart = PETSC_DETERMINE; 661*c7eeac06SToby Isaac forest->cEnd = PETSC_DETERMINE; 662db4d5e8cSToby Isaac forest->cellSF = 0; 663db4d5e8cSToby Isaac forest->adaptMarkers = NULL; 664db4d5e8cSToby Isaac forest->adaptCopyMode = PETSC_USE_POINTER; 665db4d5e8cSToby Isaac forest->adaptStrategy = DMFORESTADAPTALL; 666db4d5e8cSToby Isaac forest->gradeFactor = 2; 667db4d5e8cSToby Isaac forest->cellWeights = NULL; 668db4d5e8cSToby Isaac forest->cellWeightsCopyMode = PETSC_USE_POINTER; 669db4d5e8cSToby Isaac forest->weightsFactor = 1.; 670db4d5e8cSToby Isaac forest->weightCapacity = 1.; 671db4d5e8cSToby Isaac PetscFunctionReturn(0); 672db4d5e8cSToby Isaac } 673db4d5e8cSToby Isaac 674