1*174b6946SBarry Smith #define PETSCKSP_DLL 2*174b6946SBarry Smith 3*174b6946SBarry Smith 4*174b6946SBarry Smith #include "petscpc.h" /*I "petscpc.h" I*/ 5*174b6946SBarry Smith #include "petscmg.h" /*I "petscpc.h" I*/ 6*174b6946SBarry Smith #include "petscda.h" /*I "petscda.h" I*/ 7*174b6946SBarry Smith 8*174b6946SBarry Smith extern PetscErrorCode DAGetWireBasketInterpolation(DA,Mat,Mat*); 9*174b6946SBarry Smith 10*174b6946SBarry Smith #undef __FUNCT__ 11*174b6946SBarry Smith #define __FUNCT__ "PCSetUp_WB" 12*174b6946SBarry Smith PetscErrorCode PCSetUp_WB(PC pc,void *ida) 13*174b6946SBarry Smith { 14*174b6946SBarry Smith PetscErrorCode ierr; 15*174b6946SBarry Smith DA da = (DA)ida; 16*174b6946SBarry Smith Mat A,P; 17*174b6946SBarry Smith 18*174b6946SBarry Smith PetscFunctionBegin; 19*174b6946SBarry Smith ierr = PCGetOperators(pc,PETSC_NULL,&A,PETSC_NULL);CHKERRQ(ierr); 20*174b6946SBarry Smith ierr = DAGetWireBasketInterpolation(da,A,&P);CHKERRQ(ierr); 21*174b6946SBarry Smith ierr = PCMGSetInterpolation(pc,1,P);CHKERRQ(ierr); 22*174b6946SBarry Smith ierr = MatDestroy(P);CHKERRQ(ierr); 23*174b6946SBarry Smith PetscFunctionReturn(0); 24*174b6946SBarry Smith } 25*174b6946SBarry Smith 26*174b6946SBarry Smith #undef __FUNCT__ 27*174b6946SBarry Smith #define __FUNCT__ "PCDestroy_WB" 28*174b6946SBarry Smith PetscErrorCode PCDestroy_WB(PC pc,void *ida) 29*174b6946SBarry Smith { 30*174b6946SBarry Smith PetscErrorCode ierr; 31*174b6946SBarry Smith DA da = (DA)ida; 32*174b6946SBarry Smith 33*174b6946SBarry Smith PetscFunctionBegin; 34*174b6946SBarry Smith ierr = DADestroy(da);CHKERRQ(ierr); 35*174b6946SBarry Smith PetscFunctionReturn(0); 36*174b6946SBarry Smith } 37*174b6946SBarry Smith 38*174b6946SBarry Smith #undef __FUNCT__ 39*174b6946SBarry Smith #define __FUNCT__ "PCSetUp_WB_Error" 40*174b6946SBarry Smith PetscErrorCode PCSetUp_WB_Error(PC pc,void *ida) 41*174b6946SBarry Smith { 42*174b6946SBarry Smith PetscFunctionBegin; 43*174b6946SBarry Smith SETERRQ(PETSC_ERR_ARG_WRONGSTATE,"You are using the WB preconditioner but never called PDWBSetDA()"); 44*174b6946SBarry Smith PetscFunctionReturn(0); 45*174b6946SBarry Smith } 46*174b6946SBarry Smith 47*174b6946SBarry Smith #undef __FUNCT__ 48*174b6946SBarry Smith #define __FUNCT__ "PCWBSetDA" 49*174b6946SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCWBSetDA(PC pc,DA da) 50*174b6946SBarry Smith { 51*174b6946SBarry Smith PetscErrorCode ierr; 52*174b6946SBarry Smith 53*174b6946SBarry Smith PetscFunctionBegin; 54*174b6946SBarry Smith PetscValidHeaderSpecific(pc,PC_COOKIE,1); 55*174b6946SBarry Smith PetscValidHeaderSpecific(da,DM_COOKIE,1); 56*174b6946SBarry Smith 57*174b6946SBarry Smith ierr = PCMGSetSetup(pc,PCSetUp_WB,PCDestroy_WB,da);CHKERRQ(ierr); 58*174b6946SBarry Smith ierr = PetscObjectReference((PetscObject)da);CHKERRQ(ierr); 59*174b6946SBarry Smith PetscFunctionReturn(0); 60*174b6946SBarry Smith } 61*174b6946SBarry Smith 62*174b6946SBarry Smith 63*174b6946SBarry Smith /*MC 64*174b6946SBarry Smith PCWB - Wirebasket based coarse problem two level multigrid preconditioner 65*174b6946SBarry Smith 66*174b6946SBarry Smith .seealso: PCMG, PCWBSetDA() 67*174b6946SBarry Smith 68*174b6946SBarry Smith M*/ 69*174b6946SBarry Smith 70*174b6946SBarry Smith EXTERN_C_BEGIN 71*174b6946SBarry Smith #undef __FUNCT__ 72*174b6946SBarry Smith #define __FUNCT__ "PCCreate_WB" 73*174b6946SBarry Smith PetscErrorCode PETSCKSP_DLLEXPORT PCCreate_WB(PC pc) 74*174b6946SBarry Smith { 75*174b6946SBarry Smith PetscErrorCode ierr; 76*174b6946SBarry Smith 77*174b6946SBarry Smith PetscFunctionBegin; 78*174b6946SBarry Smith ierr = PCSetType(pc,PCMG);CHKERRQ(ierr); 79*174b6946SBarry Smith ierr = PCMGSetLevels(pc,2,PETSC_NULL);CHKERRQ(ierr); 80*174b6946SBarry Smith ierr = PCMGSetGalerkin(pc);CHKERRQ(ierr); 81*174b6946SBarry Smith ierr = PCMGSetSetup(pc,PCSetUp_WB_Error,0,0);CHKERRQ(ierr); 82*174b6946SBarry Smith PetscFunctionReturn(0); 83*174b6946SBarry Smith } 84*174b6946SBarry Smith EXTERN_C_END 85