! create matrix and vectors | call MatCreateBAIJ(PETSC_COMM_WORLD,nodof,mmdof, & | mmdof,nndof,nndof,0,dnn,0,onn, K,ierr) | call MatSetOption(AK,MAT_SYMMETRY_ETERNAL,PETSC_TRUE,ierr) | call VecCreateMPI(PETSC_COMM_WORLD, mmdof, nndof,F,ierr) | call VecDuplicate(F,x,ierr) | call VecSetOption(F,VEC_IGNORE_NEGATIVE_INDICES,PETSC_TRUE,ierr) | ! Insert values into matrix and vector | elements_loop: DO iel=1,nels | call MatSetValues(AK,ndof,g_ele,ndof,g_ele,ke,ADD_VALUES,ierr) | call VecSetValues(F,ndof,g_ele,fe,ADD_VALUES,ierr) | END DO elements_loop | ! Assembling | call MatAssemblyBegin(AK,MAT_FINAL_ASSEMBLY,ierr) | call MatAssemblyEnd(AK,MAT_FINAL_ASSEMBLY,ierr) | call VecAssemblyBegin(F,ierr) | call VecAssemblyEnd(F,ierr) |
|