1af0996ceSBarry Smith #include <petsc/private/fortranimpl.h> 2c6db04a5SJed Brown #include <petscksp.h> 3e54e4138SSatish Balay 4e54e4138SSatish Balay #if defined(PETSC_HAVE_FORTRAN_CAPS) 5ab32a8f3SSatish Balay #define pcasmgetsubksp1_ PCASMGETSUBKSP1 6ab32a8f3SSatish Balay #define pcasmgetsubksp2_ PCASMGETSUBKSP2 759fc98c0SBarry Smith #define pcasmgetsubksp3_ PCASMGETSUBKSP3 859fc98c0SBarry Smith #define pcasmgetsubksp4_ PCASMGETSUBKSP4 959fc98c0SBarry Smith #define pcasmgetsubksp5_ PCASMGETSUBKSP5 1059fc98c0SBarry Smith #define pcasmgetsubksp6_ PCASMGETSUBKSP6 1159fc98c0SBarry Smith #define pcasmgetsubksp7_ PCASMGETSUBKSP7 1259fc98c0SBarry Smith #define pcasmgetsubksp8_ PCASMGETSUBKSP8 13e54e4138SSatish Balay #define pcasmsetlocalsubdomains_ PCASMSETLOCALSUBDOMAINS 14e54e4138SSatish Balay #define pcasmsetglobalsubdomains_ PCASMSETGLOBALSUBDOMAINS 15e54e4138SSatish Balay #define pcasmgetlocalsubmatrices_ PCASMGETLOCALSUBMATRICES 16e54e4138SSatish Balay #define pcasmgetlocalsubdomains_ PCASMGETLOCALSUBDOMAINS 17ef356e52SBarry Smith #define pcasmcreatesubdomains_ PCASMCREATESUBDOMAINS 18ef356e52SBarry Smith #define pcasmdestroysubdomains_ PCASMDESTROYSUBDOMAINS 19*6141accfSBarry Smith #define pcasmcreatesubdomains2d_ PCASMCREATESUBDOMAINS2D 20e54e4138SSatish Balay #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 21ab32a8f3SSatish Balay #define pcasmgetsubksp1_ pcasmgetsubksp1 22ab32a8f3SSatish Balay #define pcasmgetsubksp2_ pcasmgetsubksp2 2359fc98c0SBarry Smith #define pcasmgetsubksp3_ pcasmgetsubksp3 2459fc98c0SBarry Smith #define pcasmgetsubksp4_ pcasmgetsubksp4 2559fc98c0SBarry Smith #define pcasmgetsubksp5_ pcasmgetsubksp5 2659fc98c0SBarry Smith #define pcasmgetsubksp6_ pcasmgetsubksp6 2759fc98c0SBarry Smith #define pcasmgetsubksp7_ pcasmgetsubksp7 2859fc98c0SBarry Smith #define pcasmgetsubksp8_ pcasmgetsubksp8 29e54e4138SSatish Balay #define pcasmsetlocalsubdomains_ pcasmsetlocalsubdomains 30e54e4138SSatish Balay #define pcasmsetglobalsubdomains_ pcasmsetglobalsubdomains 31e54e4138SSatish Balay #define pcasmgetlocalsubmatrices_ pcasmgetlocalsubmatrices 32e54e4138SSatish Balay #define pcasmgetlocalsubdomains_ pcasmgetlocalsubdomains 33ef356e52SBarry Smith #define pcasmcreatesubdomains_ pcasmcreatesubdomains 34ef356e52SBarry Smith #define pcasmdestroysubdomains_ pcasmdestroysubdomains 35*6141accfSBarry Smith #define pcasmcreatesubdomains2d_ pcasmcreatesubdomains2d 36e54e4138SSatish Balay #endif 37e54e4138SSatish Balay 38*6141accfSBarry Smith PETSC_EXTERN void pcasmcreatesubdomains2d_(PetscInt *m, PetscInt *n, PetscInt *M, PetscInt *N, PetscInt *dof, PetscInt *overlap, PetscInt *Nsub, IS *is, IS *isl, int *ierr) 39*6141accfSBarry Smith { 40*6141accfSBarry Smith IS *iis, *iisl; 41*6141accfSBarry Smith *ierr = PCASMCreateSubdomains2D(*m, *n, *M, *N, *dof, *overlap, Nsub, &iis, &iisl); 42*6141accfSBarry Smith if (*ierr) return; 43*6141accfSBarry Smith *ierr = PetscMemcpy(is, iis, *Nsub * sizeof(IS)); 44*6141accfSBarry Smith if (*ierr) return; 45*6141accfSBarry Smith *ierr = PetscMemcpy(isl, iisl, *Nsub * sizeof(IS)); 46*6141accfSBarry Smith if (*ierr) return; 47*6141accfSBarry Smith *ierr = PetscFree(iis); 48*6141accfSBarry Smith if (*ierr) return; 49*6141accfSBarry Smith *ierr = PetscFree(iisl); 50*6141accfSBarry Smith } 51*6141accfSBarry Smith 5219caf8f3SSatish Balay PETSC_EXTERN void pcasmcreatesubdomains_(Mat *mat, PetscInt *n, IS *subs, PetscErrorCode *ierr) 53ef356e52SBarry Smith { 54ef356e52SBarry Smith PetscInt i; 55ef356e52SBarry Smith IS *insubs; 56ef356e52SBarry Smith 575975b3b6SBarry Smith *ierr = PCASMCreateSubdomains(*mat, *n, &insubs); 585975b3b6SBarry Smith if (*ierr) return; 592fa5cd67SKarl Rupp for (i = 0; i < *n; i++) subs[i] = insubs[i]; 60ef356e52SBarry Smith *ierr = PetscFree(insubs); 61ef356e52SBarry Smith } 62ef356e52SBarry Smith 6319caf8f3SSatish Balay PETSC_EXTERN void pcasmdestroysubdomains_(Mat *mat, PetscInt *n, IS *subs, PetscErrorCode *ierr) 64ef356e52SBarry Smith { 65ef356e52SBarry Smith PetscInt i; 66ef356e52SBarry Smith 67ef356e52SBarry Smith for (i = 0; i < *n; i++) { 685975b3b6SBarry Smith *ierr = ISDestroy(&subs[i]); 695975b3b6SBarry Smith if (*ierr) return; 70ef356e52SBarry Smith } 71ef356e52SBarry Smith } 72ef356e52SBarry Smith 73ab32a8f3SSatish Balay PETSC_EXTERN void pcasmgetsubksp1_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 74e54e4138SSatish Balay { 75e54e4138SSatish Balay KSP *tksp; 76e54e4138SSatish Balay PetscInt i, nloc; 77e54e4138SSatish Balay CHKFORTRANNULLINTEGER(n_local); 78e54e4138SSatish Balay CHKFORTRANNULLINTEGER(first_local); 79d29017ddSJed Brown CHKFORTRANNULLOBJECT(ksp); 80e54e4138SSatish Balay *ierr = PCASMGetSubKSP(*pc, &nloc, first_local, &tksp); 81e54e4138SSatish Balay if (n_local) *n_local = nloc; 82d29017ddSJed Brown if (ksp) { 832fa5cd67SKarl Rupp for (i = 0; i < nloc; i++) ksp[i] = tksp[i]; 84e54e4138SSatish Balay } 85d29017ddSJed Brown } 86e54e4138SSatish Balay 87ab32a8f3SSatish Balay PETSC_EXTERN void pcasmgetsubksp2_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 88ab32a8f3SSatish Balay { 89ab32a8f3SSatish Balay pcasmgetsubksp1_(pc, n_local, first_local, ksp, ierr); 90ab32a8f3SSatish Balay } 91ab32a8f3SSatish Balay 9259fc98c0SBarry Smith PETSC_EXTERN void pcasmgetsubksp3_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 9359fc98c0SBarry Smith { 9459fc98c0SBarry Smith pcasmgetsubksp1_(pc, n_local, first_local, ksp, ierr); 9559fc98c0SBarry Smith } 9659fc98c0SBarry Smith 9759fc98c0SBarry Smith PETSC_EXTERN void pcasmgetsubksp4_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 9859fc98c0SBarry Smith { 9959fc98c0SBarry Smith pcasmgetsubksp1_(pc, n_local, first_local, ksp, ierr); 10059fc98c0SBarry Smith } 10159fc98c0SBarry Smith 10259fc98c0SBarry Smith PETSC_EXTERN void pcasmgetsubksp5_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 10359fc98c0SBarry Smith { 10459fc98c0SBarry Smith pcasmgetsubksp1_(pc, n_local, first_local, ksp, ierr); 10559fc98c0SBarry Smith } 10659fc98c0SBarry Smith 10759fc98c0SBarry Smith PETSC_EXTERN void pcasmgetsubksp6_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 10859fc98c0SBarry Smith { 10959fc98c0SBarry Smith pcasmgetsubksp1_(pc, n_local, first_local, ksp, ierr); 11059fc98c0SBarry Smith } 11159fc98c0SBarry Smith 11259fc98c0SBarry Smith PETSC_EXTERN void pcasmgetsubksp7_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 11359fc98c0SBarry Smith { 11459fc98c0SBarry Smith pcasmgetsubksp1_(pc, n_local, first_local, ksp, ierr); 11559fc98c0SBarry Smith } 11659fc98c0SBarry Smith 11759fc98c0SBarry Smith PETSC_EXTERN void pcasmgetsubksp8_(PC *pc, PetscInt *n_local, PetscInt *first_local, KSP *ksp, PetscErrorCode *ierr) 11859fc98c0SBarry Smith { 11959fc98c0SBarry Smith pcasmgetsubksp1_(pc, n_local, first_local, ksp, ierr); 12059fc98c0SBarry Smith } 12159fc98c0SBarry Smith 12219caf8f3SSatish Balay PETSC_EXTERN void pcasmsetlocalsubdomains_(PC *pc, PetscInt *n, IS *is, IS *is_local, PetscErrorCode *ierr) 123e54e4138SSatish Balay { 124e54e4138SSatish Balay CHKFORTRANNULLOBJECT(is); 1252b691e39SMatthew Knepley CHKFORTRANNULLOBJECT(is_local); 1262b691e39SMatthew Knepley *ierr = PCASMSetLocalSubdomains(*pc, *n, is, is_local); 127e54e4138SSatish Balay } 128e54e4138SSatish Balay 12919caf8f3SSatish Balay PETSC_EXTERN void pcasmsettotalsubdomains_(PC *pc, PetscInt *N, IS *is, IS *is_local, PetscErrorCode *ierr) 130e54e4138SSatish Balay { 131e54e4138SSatish Balay CHKFORTRANNULLOBJECT(is); 1322b691e39SMatthew Knepley CHKFORTRANNULLOBJECT(is_local); 1332b691e39SMatthew Knepley *ierr = PCASMSetTotalSubdomains(*pc, *N, is, is_local); 134e54e4138SSatish Balay } 135e54e4138SSatish Balay 13619caf8f3SSatish Balay PETSC_EXTERN void pcasmgetlocalsubmatrices_(PC *pc, PetscInt *n, Mat *mat, PetscErrorCode *ierr) 137e54e4138SSatish Balay { 138e54e4138SSatish Balay PetscInt nloc, i; 139e54e4138SSatish Balay Mat *tmat; 140e54e4138SSatish Balay CHKFORTRANNULLOBJECT(mat); 141e54e4138SSatish Balay CHKFORTRANNULLINTEGER(n); 142e54e4138SSatish Balay *ierr = PCASMGetLocalSubmatrices(*pc, &nloc, &tmat); 143e54e4138SSatish Balay if (n) *n = nloc; 144e54e4138SSatish Balay if (mat) { 1452fa5cd67SKarl Rupp for (i = 0; i < nloc; i++) mat[i] = tmat[i]; 146e54e4138SSatish Balay } 147e54e4138SSatish Balay } 14819caf8f3SSatish Balay PETSC_EXTERN void pcasmgetlocalsubdomains_(PC *pc, PetscInt *n, IS *is, IS *is_local, PetscErrorCode *ierr) 149e54e4138SSatish Balay { 150e54e4138SSatish Balay PetscInt nloc, i; 1512b691e39SMatthew Knepley IS *tis, *tis_local; 152e54e4138SSatish Balay CHKFORTRANNULLOBJECT(is); 1532b691e39SMatthew Knepley CHKFORTRANNULLOBJECT(is_local); 154e54e4138SSatish Balay CHKFORTRANNULLINTEGER(n); 1552b691e39SMatthew Knepley *ierr = PCASMGetLocalSubdomains(*pc, &nloc, &tis, &tis_local); 156e54e4138SSatish Balay if (n) *n = nloc; 157e54e4138SSatish Balay if (is) { 1582fa5cd67SKarl Rupp for (i = 0; i < nloc; i++) is[i] = tis[i]; 159e54e4138SSatish Balay } 1602b691e39SMatthew Knepley if (is_local && tis_local) { 1612a808120SBarry Smith for (i = 0; i < nloc; i++) is_local[i] = tis_local[i]; 1622b691e39SMatthew Knepley } 163e54e4138SSatish Balay } 164