Hi, Stefano, I am trying to understand the example there you mentioned. I have a question, the example always use DMDA there. Does BDDC also work for DMPLEX?
Thanks , On Tue, Jul 30, 2024 at 1:47 PM neil liu <[email protected]> wrote: > Thanks, Stefano, > > I am trying to modify the code as follows, > MatCreate(PETSC_COMM_WORLD, &A); > MatSetSizes(A, PETSC_DECIDE, PETSC_DECIDE, numberDof_global, > numberDof_global); > MatSetType(A, MATIS); > MatSetUp(A); > MatZeroEntries(A); > VecCreate(PETSC_COMM_WORLD, &b); > VecSetSizes(b, PETSC_DECIDE, numberDof_global); > VecSetUp(b); > VecSet(b,0.0); > VecDuplicate(b, &x); > > const PetscInt *g_idx; > ISLocalToGlobalMapping ltogm; > DMGetLocalToGlobalMapping(dm, <ogm); > ISLocalToGlobalMappingGetIndices(ltogm, &g_idx); > > //Build idxm_global and Set LHS > idxm_Global[ idxDofLocal ] = g_idx[ numdofPerFace*idxm[idxDofLocal]]; > MatSetValues(A, numberDof_local, idxm_Global.data(), numberDof_local, > idxm_Global.data(), MatrixLocal.data(), ADD_VALUES); > > //Set RHS > PetscScalar valueDiag = 1.0 ; > MatZeroRows(A, objGeometryInfo.numberDof_Dirichlet, (objGeometryInfo. > arrayDofSeqGlobal_Dirichlet).data(), valueDiag, 0, 0); > > VecSetValues(b, objGeometryInfo.numberDof_Dirichlet, (objGeometryInfo. > arrayDofSeqGlobal_Dirichlet).data(), (objGeometryInfo.dof_Dirichlet).data(), > INSERT_VALUES); > VecSetValues(x, objGeometryInfo.numberDof_Dirichlet, (objGeometryInfo. > arrayDofSeqGlobal_Dirichlet).data(), (objGeometryInfo.dof_Dirichlet).data(), > INSERT_VALUES); > ISLocalToGlobalMappingRestoreIndices(ltogm, &g_idx); > VecAssemblyBegin(b); > VecAssemblyEnd(b); > VecAssemblyBegin(x); > VecAssemblyEnd(x); > It shows the attached error when I run the code. It seems something wrong > is with setting RHS. > Could you please help me double check my above code to setup the RHS? > Thanks, > > On Tue, Jul 30, 2024 at 11:56 AM Stefano Zampini < > [email protected]> wrote: > >> BDDC needs the matrix in MATIS format. Using MatConvert will give you >> back the right format, but the subdomain matrices are wrong. You need to >> assemble directly in MATIS format, something like >> >> MatCreate(comm,&A) >> MatSetType(A,MATIS) >> MatSetLocalToGlobalMapping(A,l2gmap, l2gmap) >> for e in local_elements: >> E = compute_element_matrix(e) >> MatSetValues(A,local_element_dofs,local_element_dofs,....) >> >> l2gmap is an ISLocalToGlobalMapping that stores the global dof number of >> the dofs that are local to the mesh >> >> See e.g. >> https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/ksp/tutorials/ex59.c?ref_type=heads__;!!G_uCfscf7eWS!YZTeegRXq8o-IIT2OMXi5DW9t-AcAW7uZK8sHK5c9smyhbUNh3uZuwx305oWSbpKrkFCmCE_9yKGjm8EhI7eHA$ >> >> or >> https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/blob/main/src/ksp/ksp/tutorials/ex71.c?ref_type=heads__;!!G_uCfscf7eWS!YZTeegRXq8o-IIT2OMXi5DW9t-AcAW7uZK8sHK5c9smyhbUNh3uZuwx305oWSbpKrkFCmCE_9yKGjm_k5lEofA$ >> >> >> Il giorno mar 30 lug 2024 alle ore 17:50 neil liu <[email protected]> >> ha scritto: >> >>> Hi, >>> I am trying to use PCBDDC for the vector based FEM. (Complex system, >>> double precision ) >>> My code can work well with *asm*, >>> petsc-3.21.1/petsc/arch-linux-c-opt/bin/mpirun -n 8 ./app -pc_type asm >>> -pc_asm_overlap 6 -ksp_converged_reason -ksp_view >>> -ksp_gmres_modifiedgramschmidt -ksp_gmres_restart 1500 -ksp_rtol 1e-8 >>> -ksp_monitor -ksp_max_it 100000 >>> >>> When I tried BDDC, it was stuck for solving the linear system (it can >>> not print anything for ksp_monitor). I did the conversion for matrix, >>> >>> * Mat J;* >>> * MatConvert(A, MATIS, MAT_INITIAL_MATRIX, &J);* >>> * KSPSetOperators(ksp, A, J);* >>> * MatDestroy(&J);* >>> * KSPSetInitialGuessNonzero(ksp, PETSC_TRUE);* >>> * KSPSetFromOptions(ksp);* >>> >>> petsc-3.21.1/petsc/arch-linux-c-debug/bin/mpirun -n 2 ./app -ksp_type cg >>> -pc_type bddc -ksp_monitor -mat_type is >>> >>> Do you have any suggestions? >>> >>> Thanks , >>> Xiaodong >>> >>> >>> On Mon, Jul 29, 2024 at 6:19 PM neil liu <[email protected]> wrote: >>> >>>> When I compile with real data, >>>> it shows the attached error. >>>> >>>> The data file is in binary format, right? >>>> >>>> >>>> >>>> On Mon, Jul 29, 2024 at 5:36 PM Stefano Zampini < >>>> [email protected]> wrote: >>>> >>>>> Your PETSc installation is for complex, data is for real >>>>> >>>>> On Mon, Jul 29, 2024, 23:14 neil liu <[email protected]> wrote: >>>>> >>>>>> I compiled Petsc with single precision. However, it is not converged >>>>>> with the data. Please see the attached file. On Mon, Jul 29, 2024 at 4: >>>>>> 25 >>>>>> PM Barry Smith <bsmith@ petsc. dev> wrote: This can happen if the >>>>>> data was stored in single precision >>>>>> ZjQcmQRYFpfptBannerStart >>>>>> This Message Is From an External Sender >>>>>> This message came from outside your organization. >>>>>> >>>>>> ZjQcmQRYFpfptBannerEnd >>>>>> I compiled Petsc with single precision. However, it is not converged >>>>>> with the data. >>>>>> >>>>>> Please see the attached file. >>>>>> >>>>>> On Mon, Jul 29, 2024 at 4:25 PM Barry Smith <[email protected]> wrote: >>>>>> >>>>>>> >>>>>>> This can happen if the data was stored in single precision and >>>>>>> PETSc was built for double. >>>>>>> >>>>>>> >>>>>>> On Jul 29, 2024, at 3:55 PM, neil liu <[email protected]> wrote: >>>>>>> >>>>>>> This Message Is From an External Sender >>>>>>> This message came from outside your organization. >>>>>>> Dear Petsc developers,, >>>>>>> >>>>>>> I am trying to run >>>>>>> https://urldefense.us/v3/__https://petsc.org/release/src/ksp/ksp/tutorials/ex72.c.html__;!!G_uCfscf7eWS!YZTeegRXq8o-IIT2OMXi5DW9t-AcAW7uZK8sHK5c9smyhbUNh3uZuwx305oWSbpKrkFCmCE_9yKGjm_Z20MEcA$ >>>>>>> >>>>>>> <https://urldefense.us/v3/__https://petsc.org/release/src/ksp/ksp/tutorials/ex72.c.html__;!!G_uCfscf7eWS!ZG4gvmS6hQD8ymbvCUDfAatzRUJHzmWO-hOgp9m0xXuAXgIB-fxe_xspYs3WEPi_Ed0UFLMHKanYuYWrTlQGrA$> >>>>>>> with >>>>>>> >>>>>>> petsc-3.21.1/petsc/arch-linux-c-opt/bin/mpirun -n 2 ./ex72 -f >>>>>>> /Documents/PetscData/poisson_DMPLEX_32x32_16.dat -pc_type bddc >>>>>>> -ksp_type cg >>>>>>> -ksp_norm_type natural -ksp_error_if_not_converged -mat_type is >>>>>>> >>>>>>> The file was downloaded and put in the directory PetscData. >>>>>>> >>>>>>> The error is shown as follows, >>>>>>> >>>>>>> 0]PETSC ERROR: --------------------- Error Message >>>>>>> -------------------------------------------------------------- >>>>>>> [0]PETSC ERROR: Read from file failed >>>>>>> [0]PETSC ERROR: Read past end of file >>>>>>> [0]PETSC ERROR: WARNING! There are unused option(s) set! Could be >>>>>>> the program crashed before usage or a spelling mistake, etc! >>>>>>> [0]PETSC ERROR: Option left: name:-ksp_error_if_not_converged (no >>>>>>> value) source: command line >>>>>>> [0]PETSC ERROR: Option left: name:-ksp_norm_type value: natural >>>>>>> source: command line >>>>>>> [0]PETSC ERROR: Option left: name:-ksp_type value: cg source: >>>>>>> command line >>>>>>> [0]PETSC ERROR: Option left: name:-pc_type value: bddc source: >>>>>>> command line >>>>>>> [0]PETSC ERROR: See >>>>>>> https://urldefense.us/v3/__https://petsc.org/release/faq/__;!!G_uCfscf7eWS!YZTeegRXq8o-IIT2OMXi5DW9t-AcAW7uZK8sHK5c9smyhbUNh3uZuwx305oWSbpKrkFCmCE_9yKGjm_9Texx-Q$ >>>>>>> >>>>>>> <https://urldefense.us/v3/__https://petsc.org/release/faq/__;!!G_uCfscf7eWS!ZG4gvmS6hQD8ymbvCUDfAatzRUJHzmWO-hOgp9m0xXuAXgIB-fxe_xspYs3WEPi_Ed0UFLMHKanYuYVR0x14Xg$> >>>>>>> for trouble shooting. >>>>>>> [0]PETSC ERROR: Petsc Release Version 3.21.1, unknown >>>>>>> [0]PETSC ERROR: ./ex72 on a arch-linux-c-opt named >>>>>>> Mon Jul 29 15:50:04 2024 >>>>>>> [0]PETSC ERROR: Configure options --with-cc=gcc --with-fc=gfortran >>>>>>> --with-cxx=g++ --download-fblaslapack --download-mpich >>>>>>> --with-scalar-type=complex --download-triangle --with-debugging=no >>>>>>> [0]PETSC ERROR: #1 PetscBinaryRead() at >>>>>>> /home/xxxxxx/Documents/petsc-3.21.1/petsc/src/sys/fileio/sysio.c:327 >>>>>>> [0]PETSC ERROR: #2 PetscViewerBinaryWriteReadAll() at >>>>>>> /home/xiaodong.liu/Documents/petsc-3.21.1/petsc/src/sys/classes/viewer/impls/binary/binv.c:1077 >>>>>>> [0]PETSC ERROR: #3 PetscViewerBinaryReadAll() at >>>>>>> /home/xiaodong.liu/Documents/petsc-3.21.1/petsc/src/sys/classes/viewer/impls/binary/binv.c:1119 >>>>>>> [0]PETSC ERROR: #4 MatLoad_MPIAIJ_Binary() at >>>>>>> Documents/petsc-3.21.1/petsc/src/mat/impls/aij/mpi/mpiaij.c:3093 >>>>>>> [0]PETSC ERROR: #5 MatLoad_MPIAIJ() at >>>>>>> /Documents/petsc-3.21.1/petsc/src/mat/impls/aij/mpi/mpiaij.c:3035 >>>>>>> [0]PETSC ERROR: #6 MatLoad() at >>>>>>> /Documents/petsc-3.21.1/petsc/src/mat/interface/matrix.c:1344 >>>>>>> [0]PETSC ERROR: #7 MatLoad_IS() at >>>>>>> /Documents/petsc-3.21.1/petsc/src/mat/impls/is/matis.c:2575 >>>>>>> [0]PETSC ERROR: #8 MatLoad() at >>>>>>> /home/Documents/petsc-3.21.1/petsc/src/mat/interface/matrix.c:1344 >>>>>>> [0]PETSC ERROR: #9 main() at ex72.c:105 >>>>>>> [0]PETSC ERROR: PETSc Option Table entries: >>>>>>> [0]PETSC ERROR: -f >>>>>>> /Documents/PetscData/poisson_DMPLEX_32x32_16.dat (source: command >>>>>>> line) >>>>>>> [0]PETSC ERROR: -ksp_error_if_not_converged (source: command line) >>>>>>> [0]PETSC ERROR: -ksp_norm_type natural (source: command line) >>>>>>> [0]PETSC ERROR: -ksp_type cg (source: command line) >>>>>>> [0]PETSC ERROR: -mat_type is (source: command line) >>>>>>> [0]PETSC ERROR: -pc_type bddc (source: command line) >>>>>>> [0]PETSC ERROR: ----------------End of Error Message -------send >>>>>>> entire error message to [email protected] >>>>>>> application called MPI_Abort(MPI_COMM_SELF, 66) - process 0 >>>>>>> >>>>>>> >>>>>>> >> >> -- >> Stefano >> >
