diff --git a/Project.toml b/Project.toml index 103c1a2..8aad9e9 100644 --- a/Project.toml +++ b/Project.toml @@ -15,7 +15,7 @@ SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1" [compat] MPI = "0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20" -PETSc_jll = "=3.13.4, =3.15.2" +PETSc_jll = "3" PartitionedArrays = "0.4" Preferences = "1" SparseArrays = "1" diff --git a/src/api.jl b/src/api.jl index 69f668a..d6954b2 100644 --- a/src/api.jl +++ b/src/api.jl @@ -1,12 +1,14 @@ const libpetsc_handle = Ref{Ptr{Cvoid}}() const PRELOADS = Tuple{Ref{Ptr{Cvoid}},Symbol}[] +docs_url = "https://petsc.org/main/manualpages" + # Utils """ Julia alias to `PetscErrorCode` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscErrorCode.html). +See [PETSc manual]($docs_url/Sys/PetscErrorCode.html). """ const PetscErrorCode = Cint @@ -51,7 +53,7 @@ macro wrapper(fn,rt,argts,args,url) str = """ PetscCall.$(fn.value)$(sargs) - See [PETSc manual]($url). + See [PETSc manual]($docs_url$url). """ end expr = quote @@ -69,14 +71,14 @@ end """ Julia alias to `PetscBool` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscBool.html). +See [PETSc manual]($docs_url/Sys/PetscBool.html). """ @enum PetscBool PETSC_FALSE PETSC_TRUE """ Julia alias to `PetscDataType` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscDataType.html). +See [PETSc manual]($docs_url/Sys/PetscDataType.html). """ @enum PetscDataType begin PETSC_DATATYPE_UNKNOWN = 0 @@ -102,7 +104,7 @@ end """ PetscDataTypeFromString(name,ptype,found) -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscDataTypeFromString.html). +See [PETSc manual]($docs_url/Sys/PetscDataTypeFromString.html). """ function PetscDataTypeFromString(name,ptype,found) ccall( @@ -114,7 +116,7 @@ end """ PetscDataTypeGetSize(ptype,size) -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscDataTypeGetSize.html). +See [PETSc manual]($docs_url/Sys/PetscDataTypeGetSize.html). """ function PetscDataTypeGetSize(ptype,size) ccall( @@ -125,18 +127,18 @@ end #Petsc init related functions -@wrapper(:PetscInitializeNoArguments,PetscErrorCode,(),(),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscInitializeNoArguments.html") +@wrapper(:PetscInitializeNoArguments,PetscErrorCode,(),(),"/Sys/PetscInitializeNoArguments.html") @wrapper(:PetscInitializeNoPointers,PetscErrorCode,(Cint,Ptr{Cstring},Cstring,Cstring),(argc,args,filename,help),"") -@wrapper(:PetscFinalize,PetscErrorCode,(),(),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscFinalize.html") -@wrapper(:PetscFinalized,PetscErrorCode,(Ptr{PetscBool},),(flag,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscFinalized.html") -@wrapper(:PetscInitialized,PetscErrorCode,(Ptr{PetscBool},),(flag,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscInitialized.html") +@wrapper(:PetscFinalize,PetscErrorCode,(),(),"/Sys/PetscFinalize.html") +@wrapper(:PetscFinalized,PetscErrorCode,(Ptr{PetscBool},),(flag,),"/Sys/PetscFinalized.html") +@wrapper(:PetscInitialized,PetscErrorCode,(Ptr{PetscBool},),(flag,),"/Sys/PetscInitialized.html") # viewer related functions """ Julia alias for `PetscViewer` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewer.html). +See [PETSc manual]($docs_url/Viewer/PetscViewer.html). """ struct PetscViewer ptr::Ptr{Cvoid} @@ -145,13 +147,13 @@ PetscViewer() = PetscViewer(Ptr{Cvoid}()) Base.convert(::Type{PetscViewer},p::Ptr{Cvoid}) = PetscViewer(p) Base.unsafe_convert(::Type{Ptr{Cvoid}},v::PetscViewer) = v.ptr -@wrapper(:PETSC_VIEWER_STDOUT_,PetscViewer,(MPI.Comm,),(comm,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PETSC_VIEWER_STDOUT_.html") -@wrapper(:PETSC_VIEWER_DRAW_,PetscViewer,(MPI.Comm,),(comm,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PETSC_VIEWER_DRAW_.html") +@wrapper(:PETSC_VIEWER_STDOUT_,PetscViewer,(MPI.Comm,),(comm,),"/Viewer/PETSC_VIEWER_STDOUT_.html") +@wrapper(:PETSC_VIEWER_DRAW_,PetscViewer,(MPI.Comm,),(comm,),"/Viewer/PETSC_VIEWER_DRAW_.html") """ @PETSC_VIEWER_STDOUT_SELF -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PETSC_VIEWER_STDOUT_SELF.html). +See [PETSc manual]($docs_url/Viewer/PETSC_VIEWER_STDOUT_SELF.html). """ macro PETSC_VIEWER_STDOUT_SELF() quote @@ -162,7 +164,7 @@ end """ @PETSC_VIEWER_STDOUT_WORLD -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PETSC_VIEWER_STDOUT_WORLD.html). +See [PETSc manual]($docs_url/Viewer/PETSC_VIEWER_STDOUT_WORLD.html). """ macro PETSC_VIEWER_STDOUT_WORLD() quote @@ -173,7 +175,7 @@ end """ @PETSC_VIEWER_DRAW_SELF -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PETSC_VIEWER_DRAW_SELF.html). +See [PETSc manual]($docs_url/Viewer/PETSC_VIEWER_DRAW_SELF.html). """ macro PETSC_VIEWER_DRAW_SELF() quote @@ -184,7 +186,7 @@ end """ @PETSC_VIEWER_DRAW_WORLD -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PETSC_VIEWER_DRAW_WORLD.html). +See [PETSc manual]($docs_url/Viewer/PETSC_VIEWER_DRAW_WORLD.html). """ macro PETSC_VIEWER_DRAW_WORLD() quote @@ -197,7 +199,7 @@ end """ Julia alias for the `InsertMode` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/InsertMode.html). +See [PETSc manual]($docs_url/Sys/InsertMode.html). """ @enum InsertMode begin NOT_SET_VALUES @@ -214,7 +216,7 @@ end """ Julia alias for the `VecOption` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetOption.html). +See [PETSc manual]($docs_url/Vec/VecSetOption.html). """ @enum VecOption begin VEC_IGNORE_OFF_PROC_ENTRIES @@ -225,7 +227,7 @@ end """ Julia alias for the `NormType` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/NormType.html). +See [PETSc manual]($docs_url/Vec/NormType.html). """ @enum NormType begin NORM_1=0 @@ -238,7 +240,7 @@ end """ Julia alias for the `Vec` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/Vec.html). +See [PETSc manual]($docs_url/Vec/Vec.html). """ struct Vec ptr::Ptr{Cvoid} @@ -247,47 +249,47 @@ Vec() = Vec(Ptr{Cvoid}()) Base.convert(::Type{Vec},p::Ptr{Cvoid}) = Vec(p) Base.unsafe_convert(::Type{Ptr{Cvoid}},v::Vec) = v.ptr -@wrapper(:VecCreateSeq,PetscErrorCode,(MPI.Comm,PetscInt,Ptr{Vec}),(comm,n,vec),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecCreateSeq.html") -@wrapper(:VecCreateSeqWithArray,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,Ptr{PetscScalar},Ptr{Vec}),(comm,bs,n,array,vec),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecCreateSeqWithArray.html") -@wrapper(:VecCreateMPIWithArray,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscScalar},Ptr{Vec}),(comm,bs,n,N,array,vec),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecCreateMPIWithArray.html") -@wrapper(:VecCreateGhost,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{Vec}),(comm,n,N,nghost,ghosts,vv),"https://petsc.org/release/docs/manualpages/Vec/VecCreateGhost.html") -@wrapper(:VecCreateGhostWithArray,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscScalar},Ptr{Vec}),(comm,n,N,nghost,ghosts,array,vv),"https://petsc.org/release/docs/manualpages/Vec/VecCreateGhostWithArray.html") -@wrapper(:VecCreateMPI,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,Vec),(comm,n,N,v),"https://petsc.org/release/docs/manualpages/Vec/VecCreateMPI.html") -@wrapper(:VecDestroy,PetscErrorCode,(Ptr{Vec},),(vec,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecDestroy.html") -@wrapper(:VecView,PetscErrorCode,(Vec,PetscViewer),(vec,viewer),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecView.html") -@wrapper(:VecSetValues,PetscErrorCode,(Vec,PetscInt,Ptr{PetscInt},Ptr{PetscScalar},InsertMode),(x,ni,ix,y,iora),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetValues.html") -@wrapper(:VecGetValues,PetscErrorCode,(Vec,PetscInt,Ptr{PetscInt},Ptr{PetscScalar}),(x,ni,ix,y),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetValues.html") -@wrapper(:VecGetArray,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"https://petsc.org/release/docs/manualpages/Vec/VecGetArray.html") -@wrapper(:VecGetArrayRead,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"https://petsc.org/release/docs/manualpages/Vec/VecGetArrayRead.html") -@wrapper(:VecGetArrayWrite,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"https://petsc.org/release/docs/manualpages/Vec/VecGetArrayWrite.html") -@wrapper(:VecRestoreArray,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"https://petsc.org/release/docs/manualpages/Vec/VecRestoreArray.html") -@wrapper(:VecRestoreArrayRead,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"https://petsc.org/release/docs/manualpages/Vec/VecRestoreArrayRead.html") -@wrapper(:VecRestoreArrayWrite,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"https://petsc.org/release/docs/manualpages/Vec/VecRestoreArrayWrite.html") -@wrapper(:VecGetSize,PetscErrorCode,(Vec,Ptr{PetscInt}),(vec,n),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecGetSize.html") -@wrapper(:VecGetLocalSize,PetscErrorCode,(Vec,Ptr{PetscInt}),(vec,n),"https://petsc.org/release/docs/manualpages/Vec/VecGetLocalSize.html") -@wrapper(:VecAssemblyBegin,PetscErrorCode,(Vec,),(vec,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecAssemblyBegin.html") -@wrapper(:VecAssemblyEnd,PetscErrorCode,(Vec,),(vec,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecAssemblyEnd.html") -@wrapper(:VecPlaceArray,PetscErrorCode,(Vec,Ptr{PetscScalar}),(vec,array),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecPlaceArray.html") -@wrapper(:VecResetArray,PetscErrorCode,(Vec,),(vec,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecResetArray.html") -@wrapper(:VecScale,PetscErrorCode,(Vec,PetscScalar),(x,alpha),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScale.html") -@wrapper(:VecSet,PetscErrorCode,(Vec,PetscScalar),(x,alpha),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSet.html") -@wrapper(:VecDuplicate,PetscErrorCode,(Vec,Ptr{Vec}),(v,newv),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecDuplicate.html") -@wrapper(:VecCopy,PetscErrorCode,(Vec,Vec),(x,y),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecCopy.html") -@wrapper(:VecAXPY,PetscErrorCode,(Vec,PetscScalar,Vec),(y,alpha,x),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecAXPY.html") -@wrapper(:VecAYPX,PetscErrorCode,(Vec,PetscScalar,Vec),(y,beta,x),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecAYPX.html") -@wrapper(:VecAXPBY,PetscErrorCode,(Vec,PetscScalar,PetscScalar,Vec),(y,alpha,beta,x),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecAXPBY.html") -@wrapper(:VecSetOption,PetscErrorCode,(Vec,VecOption,PetscBool),(x,op,flg),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSetOption.html") -@wrapper(:VecNorm,PetscErrorCode,(Vec,NormType,Ptr{PetscReal}),(x,typ,val),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecNorm.html") -@wrapper(:VecGhostGetLocalForm,PetscErrorCode,(Vec,Ptr{Vec}),(g,l),"https://petsc.org/release/docs/manualpages/Vec/VecGhostGetLocalForm.html") -@wrapper(:VecGhostRestoreLocalForm,PetscErrorCode,(Vec,Ptr{Vec}),(g,l),"https://petsc.org/release/docs/manualpages/Vec/VecGhostRestoreLocalForm.html") -@wrapper(:VecZeroEntries,PetscErrorCode,(Vec,),(v,),"https://petsc.org/release/docs/manualpages/Vec/VecZeroEntries.html") +@wrapper(:VecCreateSeq,PetscErrorCode,(MPI.Comm,PetscInt,Ptr{Vec}),(comm,n,vec),"/Vec/VecCreateSeq.html") +@wrapper(:VecCreateSeqWithArray,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,Ptr{PetscScalar},Ptr{Vec}),(comm,bs,n,array,vec),"/Vec/VecCreateSeqWithArray.html") +@wrapper(:VecCreateMPIWithArray,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscScalar},Ptr{Vec}),(comm,bs,n,N,array,vec),"/Vec/VecCreateMPIWithArray.html") +@wrapper(:VecCreateGhost,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{Vec}),(comm,n,N,nghost,ghosts,vv),"/Vec/VecCreateGhost.html") +@wrapper(:VecCreateGhostWithArray,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscScalar},Ptr{Vec}),(comm,n,N,nghost,ghosts,array,vv),"/Vec/VecCreateGhostWithArray.html") +@wrapper(:VecCreateMPI,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,Vec),(comm,n,N,v),"/Vec/VecCreateMPI.html") +@wrapper(:VecDestroy,PetscErrorCode,(Ptr{Vec},),(vec,),"/Vec/VecDestroy.html") +@wrapper(:VecView,PetscErrorCode,(Vec,PetscViewer),(vec,viewer),"/Vec/VecView.html") +@wrapper(:VecSetValues,PetscErrorCode,(Vec,PetscInt,Ptr{PetscInt},Ptr{PetscScalar},InsertMode),(x,ni,ix,y,iora),"/Vec/VecSetValues.html") +@wrapper(:VecGetValues,PetscErrorCode,(Vec,PetscInt,Ptr{PetscInt},Ptr{PetscScalar}),(x,ni,ix,y),"/Vec/VecGetValues.html") +@wrapper(:VecGetArray,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"/Vec/VecGetArray.html") +@wrapper(:VecGetArrayRead,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"/Vec/VecGetArrayRead.html") +@wrapper(:VecGetArrayWrite,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"/Vec/VecGetArrayWrite.html") +@wrapper(:VecRestoreArray,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"/Vec/VecRestoreArray.html") +@wrapper(:VecRestoreArrayRead,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"/Vec/VecRestoreArrayRead.html") +@wrapper(:VecRestoreArrayWrite,PetscErrorCode,(Vec,Ptr{Ptr{PetscScalar}}),(x,a),"/Vec/VecRestoreArrayWrite.html") +@wrapper(:VecGetSize,PetscErrorCode,(Vec,Ptr{PetscInt}),(vec,n),"/Vec/VecGetSize.html") +@wrapper(:VecGetLocalSize,PetscErrorCode,(Vec,Ptr{PetscInt}),(vec,n),"/Vec/VecGetLocalSize.html") +@wrapper(:VecAssemblyBegin,PetscErrorCode,(Vec,),(vec,),"/Vec/VecAssemblyBegin.html") +@wrapper(:VecAssemblyEnd,PetscErrorCode,(Vec,),(vec,),"/Vec/VecAssemblyEnd.html") +@wrapper(:VecPlaceArray,PetscErrorCode,(Vec,Ptr{PetscScalar}),(vec,array),"/Vec/VecPlaceArray.html") +@wrapper(:VecResetArray,PetscErrorCode,(Vec,),(vec,),"/Vec/VecResetArray.html") +@wrapper(:VecScale,PetscErrorCode,(Vec,PetscScalar),(x,alpha),"/Vec/VecScale.html") +@wrapper(:VecSet,PetscErrorCode,(Vec,PetscScalar),(x,alpha),"/Vec/VecSet.html") +@wrapper(:VecDuplicate,PetscErrorCode,(Vec,Ptr{Vec}),(v,newv),"/Vec/VecDuplicate.html") +@wrapper(:VecCopy,PetscErrorCode,(Vec,Vec),(x,y),"/Vec/VecCopy.html") +@wrapper(:VecAXPY,PetscErrorCode,(Vec,PetscScalar,Vec),(y,alpha,x),"/Vec/VecAXPY.html") +@wrapper(:VecAYPX,PetscErrorCode,(Vec,PetscScalar,Vec),(y,beta,x),"/Vec/VecAYPX.html") +@wrapper(:VecAXPBY,PetscErrorCode,(Vec,PetscScalar,PetscScalar,Vec),(y,alpha,beta,x),"/Vec/VecAXPBY.html") +@wrapper(:VecSetOption,PetscErrorCode,(Vec,VecOption,PetscBool),(x,op,flg),"/Vec/VecSetOption.html") +@wrapper(:VecNorm,PetscErrorCode,(Vec,NormType,Ptr{PetscReal}),(x,typ,val),"/Vec/VecNorm.html") +@wrapper(:VecGhostGetLocalForm,PetscErrorCode,(Vec,Ptr{Vec}),(g,l),"/Vec/VecGhostGetLocalForm.html") +@wrapper(:VecGhostRestoreLocalForm,PetscErrorCode,(Vec,Ptr{Vec}),(g,l),"/Vec/VecGhostRestoreLocalForm.html") +@wrapper(:VecZeroEntries,PetscErrorCode,(Vec,),(v,),"/Vec/VecZeroEntries.html") # Matrix related functions """ Julia alias for the `MatAssemblyType` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatAssemblyType.html). +See [PETSc manual]($docs_url/Mat/MatAssemblyType.html). """ @enum MatAssemblyType begin MAT_FINAL_ASSEMBLY=0 @@ -297,7 +299,7 @@ end """ Julia alias for the `MatDuplicateOption` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDuplicateOption.html). +See [PETSc manual]($docs_url/Mat/MatDuplicateOption.html). """ @enum MatDuplicateOption begin MAT_DO_NOT_COPY_VALUES @@ -308,7 +310,7 @@ end """ Julia alias for the `MatReuse` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatReuse.html). +See [PETSc manual]($docs_url/Mat/MatReuse.html). """ @enum MatReuse begin MAT_INITIAL_MATRIX @@ -320,7 +322,7 @@ end """ Julia alias for the `MatInfoType` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatInfoType.html). +See [PETSc manual]($docs_url/Mat/MatInfoType.html). """ @enum MatInfoType begin MAT_LOCAL=1 @@ -331,7 +333,7 @@ end """ Julia alias for the `MatStructure` C enum. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatStructure.html). +See [PETSc manual]($docs_url/Mat/MatStructure.html). """ @enum MatStructure begin DIFFERENT_NONZERO_PATTERN @@ -343,14 +345,14 @@ end """ Julia alias to `PetscLogDouble` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscLogDouble.html). +See [PETSc manual]($docs_url/Sys/PetscLogDouble.html). """ const PetscLogDouble = Cdouble """ Julia alias for the `MatInfo` C struct. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatInfo.html). +See [PETSc manual]($docs_url/Mat/MatInfo.html). """ struct MatInfo block_size ::PetscLogDouble @@ -368,28 +370,28 @@ end """ Julia constant storing the `PETSC_DEFAULT` value. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PETSC_DEFAULT.html). +See [PETSc manual]($docs_url/Sys/PETSC_DEFAULT.html). """ const PETSC_DEFAULT = Cint(-2) """ Julia constant storing the `PETSC_DECIDE` value. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PETSC_DECIDE.html). +See [PETSc manual]($docs_url/Sys/PETSC_DECIDE.html). """ const PETSC_DECIDE = Cint(-1) """ Julia constant storing the `PETSC_DETERMINE` value. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PETSC_DETERMINE.html). +See [PETSc manual]($docs_url/Sys/PETSC_DETERMINE.html). """ const PETSC_DETERMINE = PETSC_DECIDE """ Julia alias for `MatType` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatType.html). +See [PETSc manual]($docs_url/Mat/MatType.html). """ const MatType = Cstring const MATSAME = "same" @@ -500,7 +502,7 @@ const MATSOLVERCUSPARSE = "cusparse" """ Julia alias for the `Mat` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/Mat.html). +See [PETSc manual]($docs_url/Mat/Mat.html). """ struct Mat ptr::Ptr{Cvoid} @@ -509,42 +511,99 @@ Mat() = Mat(Ptr{Cvoid}()) Base.convert(::Type{Mat},p::Ptr{Cvoid}) = Mat(p) Base.unsafe_convert(::Type{Ptr{Cvoid}},v::Mat) = v.ptr -@wrapper(:MatCreate,PetscErrorCode,(MPI.Comm,Ptr{Mat}),(comm,mat),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreate.html") -@wrapper(:MatCreateAIJ,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt},Ptr{Mat}),(comm,m,n,M,N,d_nz,d_nnz,o_nz,o_nnz,mat),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateAIJ.html") -@wrapper(:MatCreateSeqAIJ,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{Mat}),(comm,m,n,nz,nnz,mat),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateSeqAIJ.html") -@wrapper(:MatCreateSeqAIJWithArrays,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{Mat}),(comm,m,n,i,j,a,mat),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateSeqAIJWithArrays.html") -@wrapper(:MatCreateMPIAIJWithArrays,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{Mat}),(comm,m,n,M,N,i,j,a,mat),"https://petsc.org/release/docs/manualpages/Mat/MatCreateMPIAIJWithArrays.html") -@wrapper(:MatCreateMPIAIJWithSplitArrays,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{Mat}),(comm,m,n,M,N,i,j,a,oi,oj,oa,mat),"https://petsc.org/release/docs/manualpages/Mat/MatCreateMPIAIJWithSplitArrays.html") -@wrapper(:MatDestroy,PetscErrorCode,(Ptr{Mat},),(A,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDestroy.html") -@wrapper(:MatView,PetscErrorCode,(Mat,PetscViewer),(mat,viewer),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatView.html") -@wrapper(:MatSetType,PetscErrorCode,(Mat,MatType),(mat,matype),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetType.html") -@wrapper(:MatSetSizes,PetscErrorCode,(Mat,PetscInt,PetscInt,PetscInt,PetscInt),(A,m,n,M,N),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetSizes.html") -@wrapper(:MatSetPreallocationCOO,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},Ptr{PetscInt}),(A,ncoo,coo_i,coo_j),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetPreallocationCOO.html") -@wrapper(:MatSetValuesCOO,PetscErrorCode,(Mat,Ptr{PetscScalar},InsertMode),(A,coo_v,imode),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValuesCOO.html") -@wrapper(:MatSetValues,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt},Ptr{PetscScalar},InsertMode),(mat,m,idxm,n,idxn,v,addv),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValues.html") -@wrapper(:MatGetValues,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt},Ptr{PetscScalar}),(mat,m,idxm,n,idxn,v),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetValues.html") -@wrapper(:MatAssemblyBegin,PetscErrorCode,(Mat,MatAssemblyType),(mat,typ),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatAssemblyBegin.html") -@wrapper(:MatAssemblyEnd,PetscErrorCode,(Mat,MatAssemblyType),(mat,typ),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatAssemblyEnd.html") -@wrapper(:MatGetSize,PetscErrorCode,(Mat,Ptr{PetscInt},Ptr{PetscInt}),(mat,m,n),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetSize.html") -@wrapper(:MatEqual,PetscErrorCode,(Mat,Mat,Ptr{PetscBool}),(A,B,flg),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatEqual.html") -@wrapper(:MatMultAdd,PetscErrorCode,(Mat,Vec,Vec,Vec),(mat,v1,v2,v3),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMultAdd.html") -@wrapper(:MatMult,PetscErrorCode,(Mat,Vec,Vec),(mat,x,y),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMult.html") -@wrapper(:MatScale,PetscErrorCode,(Mat,PetscScalar),(mat,alpha),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatScale.html") -@wrapper(:MatConvert,PetscErrorCode,(Mat,MatType,MatReuse,Ptr{Mat}),(mat,newtype,reuse,M),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatConvert.html") -@wrapper(:MatGetInfo,PetscErrorCode,(Mat,MatInfoType,Ptr{MatInfo}),(mat,flag,info),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatGetInfo.html") -@wrapper(:MatZeroEntries,PetscErrorCode,(Mat,),(mat,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatZeroEntries.html") -@wrapper(:MatCopy,PetscErrorCode,(Mat,Mat,MatStructure),(A,B,str),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCopy.html") -@wrapper(:MatSetBlockSize,PetscErrorCode,(Mat,PetscInt),(mat,bs),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetBlockSize.html") -@wrapper(:MatMumpsSetIcntl,PetscErrorCode,(Mat,PetscInt,PetscInt),(mat,icntl,val),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMumpsSetIcntl.html") -@wrapper(:MatMumpsSetCntl,PetscErrorCode,(Mat,PetscInt,PetscReal),(mat,icntl,val),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMumpsSetCntl.html") -@wrapper(:MatMPIAIJSetPreallocation,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt}),(B,d_nz,d_nnz,o_nz,o_nnz),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html") +@wrapper(:MatCreate,PetscErrorCode,(MPI.Comm,Ptr{Mat}),(comm,mat),"/Mat/MatCreate.html") +@wrapper(:MatCreateAIJ,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt},Ptr{Mat}),(comm,m,n,M,N,d_nz,d_nnz,o_nz,o_nnz,mat),"/Mat/MatCreateAIJ.html") +@wrapper(:MatCreateSeqAIJ,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{Mat}),(comm,m,n,nz,nnz,mat),"/Mat/MatCreateSeqAIJ.html") +@wrapper(:MatCreateSeqAIJWithArrays,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{Mat}),(comm,m,n,i,j,a,mat),"/Mat/MatCreateSeqAIJWithArrays.html") +@wrapper(:MatCreateMPIAIJWithArrays,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{Mat}),(comm,m,n,M,N,i,j,a,mat),"/Mat/MatCreateMPIAIJWithArrays.html") +@wrapper(:MatCreateMPIAIJWithSplitArrays,PetscErrorCode,(MPI.Comm,PetscInt,PetscInt,PetscInt,PetscInt,Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{PetscInt},Ptr{PetscInt},Ptr{PetscScalar},Ptr{Mat}),(comm,m,n,M,N,i,j,a,oi,oj,oa,mat),"/Mat/MatCreateMPIAIJWithSplitArrays.html") +@wrapper(:MatDestroy,PetscErrorCode,(Ptr{Mat},),(A,),"/Mat/MatDestroy.html") +@wrapper(:MatView,PetscErrorCode,(Mat,PetscViewer),(mat,viewer),"/Mat/MatView.html") +@wrapper(:MatSetType,PetscErrorCode,(Mat,MatType),(mat,matype),"/Mat/MatSetType.html") +@wrapper(:MatSetSizes,PetscErrorCode,(Mat,PetscInt,PetscInt,PetscInt,PetscInt),(A,m,n,M,N),"/Mat/MatSetSizes.html") +@wrapper(:MatSetPreallocationCOO,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},Ptr{PetscInt}),(A,ncoo,coo_i,coo_j),"/Mat/MatSetPreallocationCOO.html") +@wrapper(:MatSetValuesCOO,PetscErrorCode,(Mat,Ptr{PetscScalar},InsertMode),(A,coo_v,imode),"/Mat/MatSetValuesCOO.html") +@wrapper(:MatSetValues,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt},Ptr{PetscScalar},InsertMode),(mat,m,idxm,n,idxn,v,addv),"/Mat/MatSetValues.html") +@wrapper(:MatGetValues,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt},Ptr{PetscScalar}),(mat,m,idxm,n,idxn,v),"/Mat/MatGetValues.html") +@wrapper(:MatAssemblyBegin,PetscErrorCode,(Mat,MatAssemblyType),(mat,typ),"/Mat/MatAssemblyBegin.html") +@wrapper(:MatAssemblyEnd,PetscErrorCode,(Mat,MatAssemblyType),(mat,typ),"/Mat/MatAssemblyEnd.html") +@wrapper(:MatGetSize,PetscErrorCode,(Mat,Ptr{PetscInt},Ptr{PetscInt}),(mat,m,n),"/Mat/MatGetSize.html") +@wrapper(:MatEqual,PetscErrorCode,(Mat,Mat,Ptr{PetscBool}),(A,B,flg),"/Mat/MatEqual.html") +@wrapper(:MatMultAdd,PetscErrorCode,(Mat,Vec,Vec,Vec),(mat,v1,v2,v3),"/Mat/MatMultAdd.html") +@wrapper(:MatMult,PetscErrorCode,(Mat,Vec,Vec),(mat,x,y),"/Mat/MatMult.html") +@wrapper(:MatScale,PetscErrorCode,(Mat,PetscScalar),(mat,alpha),"/Mat/MatScale.html") +@wrapper(:MatConvert,PetscErrorCode,(Mat,MatType,MatReuse,Ptr{Mat}),(mat,newtype,reuse,M),"/Mat/MatConvert.html") +@wrapper(:MatGetInfo,PetscErrorCode,(Mat,MatInfoType,Ptr{MatInfo}),(mat,flag,info),"/Mat/MatGetInfo.html") +@wrapper(:MatZeroEntries,PetscErrorCode,(Mat,),(mat,),"/Mat/MatZeroEntries.html") +@wrapper(:MatCopy,PetscErrorCode,(Mat,Mat,MatStructure),(A,B,str),"/Mat/MatCopy.html") +@wrapper(:MatSetBlockSize,PetscErrorCode,(Mat,PetscInt),(mat,bs),"/Mat/MatSetBlockSize.html") +@wrapper(:MatMumpsSetIcntl,PetscErrorCode,(Mat,PetscInt,PetscInt),(mat,icntl,val),"/Mat/MatMumpsSetIcntl.html") +@wrapper(:MatMumpsSetCntl,PetscErrorCode,(Mat,PetscInt,PetscReal),(mat,icntl,val),"/Mat/MatMumpsSetCntl.html") +@wrapper(:MatMPIAIJSetPreallocation,PetscErrorCode,(Mat,PetscInt,Ptr{PetscInt},PetscInt,Ptr{PetscInt}),(B,d_nz,d_nnz,o_nz,o_nnz),"/Mat/MatMPIAIJSetPreallocation.html") + +# Matrix products related + +""" +Julia alias for the `MatProductType` C enum. + +See [PETSc manual]($docs_url/Mat/MatProductType.html). +""" +@enum MatProductType begin + MATPRODUCT_UNSPECIFIED = 0 + MATPRODUCT_AB + MATPRODUCT_AtB + MATPRODUCT_ABt + MATPRODUCT_PtAP + MATPRODUCT_RARt + MATPRODUCT_ABC +end + +""" +Julia alias for `MatProductAlgorithm` C type. + +See [PETSc manual]($docs_url/Mat/MatProductAlgorithm.html). +""" +const MatProductAlgorithm = Cstring +const MATPRODUCTALGORITHMDEFAULT = "default" +const MATPRODUCTALGORITHMSORTED = "sorted" +const MATPRODUCTALGORITHMSCALABLE = "scalable" +const MATPRODUCTALGORITHMSCALABLEFAST = "scalable_fast" +const MATPRODUCTALGORITHMHEAP = "heap" +const MATPRODUCTALGORITHMBHEAP = "btheap" +const MATPRODUCTALGORITHMLLCONDENSED = "llcondensed" +const MATPRODUCTALGORITHMROWMERGE = "rowmerge" +const MATPRODUCTALGORITHMOUTERPRODUCT = "outerproduct" +const MATPRODUCTALGORITHMATB = "at*b" +const MATPRODUCTALGORITHMRAP = "rap" +const MATPRODUCTALGORITHMNONSCALABLE = "nonscalable" +const MATPRODUCTALGORITHMSEQMPI = "seqmpi" +const MATPRODUCTALGORITHMBACKEND = "backend" +const MATPRODUCTALGORITHMOVERLAPPING = "overlapping" +const MATPRODUCTALGORITHMMERGED = "merged" +const MATPRODUCTALGORITHMALLATONCE = "allatonce" +const MATPRODUCTALGORITHMALLATONCEMERGED = "allatonce_merged" +const MATPRODUCTALGORITHMALLGATHERV = "allgatherv" +const MATPRODUCTALGORITHMCYCLIC = "cyclic" +const MATPRODUCTALGORITHMHYPRE = "hypre" + +@wrapper(:MatMatMult,PetscErrorCode,(Mat,Mat,MatReuse,PetscReal,Ptr{Mat}),(A,B,scall,fill,C),"/Mat/MatMatMult.html") +@wrapper(:MatProductCreate,PetscErrorCode,(Mat,Mat,Mat,Ptr{Mat}),(A,B,C,D),"/Mat/MatProductCreate.html") +@wrapper(:MatProductSetType,PetscErrorCode,(Mat,MatProductType),(mat,productype),"/Mat/MatProductSetType.html") +@wrapper(:MatProductSymbolic,PetscErrorCode,(Mat,),(mat,),"/Mat/MatProductSymbolic.html") +@wrapper(:MatProductNumeric,PetscErrorCode,(Mat,),(mat,),"/Mat/MatProductNumeric.html") +@wrapper(:MatProductReplaceMats,PetscErrorCode,(Mat,Mat,Mat,Mat),(A,B,C,D),"/Mat/MatProductReplaceMats.html") +@wrapper(:MatProductSetAlgorithm,PetscErrorCode,(Mat,MatProductAlgorithm),(mat,alg),"/Mat/MatProductSetAlgorithm.html") +@wrapper(:MatProductGetAlgorithm,PetscErrorCode,(Mat,Ptr{MatProductAlgorithm}),(mat,alg),"/Mat/MatProductGetAlgorithm.html") +@wrapper(:MatProductSetFill,PetscErrorCode,(Mat,PetscReal),(mat,fill),"/Mat/MatProductSetFill.html") +@wrapper(:MatProductSetFromOptions,PetscErrorCode,(Mat,),(mat,),"/Mat/MatProductSetFromOptions.html") +@wrapper(:MatProductClear,PetscErrorCode,(Mat,),(mat,),"/Mat/MatProductClear.html") # Null space related """ Julia alias for the `MatNullSpace` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpace.html). +See [PETSc manual]($docs_url/Mat/MatNullSpace.html). """ struct MatNullSpace ptr::Ptr{Cvoid} @@ -553,17 +612,17 @@ MatNullSpace() = MatNullSpace(Ptr{Cvoid}()) Base.convert(::Type{MatNullSpace},p::Ptr{Cvoid}) = MatNullSpace(p) Base.unsafe_convert(::Type{Ptr{Cvoid}},v::MatNullSpace) = v.ptr -@wrapper(:MatSetNearNullSpace,PetscErrorCode,(Mat,MatNullSpace),(mat,nullsp),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetNearNullSpace.html") -@wrapper(:MatNullSpaceCreateRigidBody,PetscErrorCode,(Vec,Ptr{MatNullSpace}),(coords,sp),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceCreateRigidBody.html") -@wrapper(:MatNullSpaceCreate,PetscErrorCode,(MPI.Comm,PetscBool,PetscInt,Ptr{Vec},Ptr{MatNullSpace}),(comm,has_cnst,n,vecs,sp),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceCreate.html") -@wrapper(:MatNullSpaceDestroy,PetscErrorCode,(Ptr{MatNullSpace},),(ns,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatNullSpaceDestroy.html") +@wrapper(:MatSetNearNullSpace,PetscErrorCode,(Mat,MatNullSpace),(mat,nullsp),"/Mat/MatSetNearNullSpace.html") +@wrapper(:MatNullSpaceCreateRigidBody,PetscErrorCode,(Vec,Ptr{MatNullSpace}),(coords,sp),"/Mat/MatNullSpaceCreateRigidBody.html") +@wrapper(:MatNullSpaceCreate,PetscErrorCode,(MPI.Comm,PetscBool,PetscInt,Ptr{Vec},Ptr{MatNullSpace}),(comm,has_cnst,n,vecs,sp),"/Mat/MatNullSpaceCreate.html") +@wrapper(:MatNullSpaceDestroy,PetscErrorCode,(Ptr{MatNullSpace},),(ns,),"/Mat/MatNullSpaceDestroy.html") # KSP and PC related things """ Julia alias for `KSPType` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPType.html). +See [PETSc manual]($docs_url/KSP/KSPType.html). """ const KSPType = Cstring const KSPRICHARDSON = "richardson" @@ -616,7 +675,7 @@ const KSPHPDDM = "hpddm" """ Julia alias for `PCType` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCType.html). +See [PETSc manual]($docs_url/PC/PCType.html). """ const PCType = Cstring const PCNONE = "none" @@ -672,7 +731,7 @@ const PCHARA = "hara" """ Julia alias for the `KSP` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSP.html). +See [PETSc manual]($docs_url/KSP/KSP.html). """ struct KSP ptr::Ptr{Cvoid} @@ -684,7 +743,7 @@ Base.unsafe_convert(::Type{Ptr{Cvoid}},v::KSP) = v.ptr """ Julia alias for the `PC` C type. -See [PETSc manual](https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PC.html). +See [PETSc manual]($docs_url/PC/PC.html). """ struct PC ptr::Ptr{Cvoid} @@ -693,31 +752,31 @@ PC() = PC(Ptr{Cvoid}()) Base.convert(::Type{PC},p::Ptr{Cvoid}) = PC(p) Base.unsafe_convert(::Type{Ptr{Cvoid}},v::PC) = v.ptr -@wrapper(:KSPCreate,PetscErrorCode,(MPI.Comm,Ptr{KSP}),(comm,inksp),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPCreate.html") -@wrapper(:KSPDestroy,PetscErrorCode,(Ptr{KSP},),(ksp,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPDestroy.html") -@wrapper(:KSPSetFromOptions,PetscErrorCode,(KSP,),(ksp,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetFromOptions.html") -@wrapper(:KSPSetOptionsPrefix,PetscErrorCode,(KSP,Cstring),(ksp,prefix),"https://petsc.org/release/docs/manualpages/KSP/KSPSetOptionsPrefix.html") -@wrapper(:KSPSetUp,PetscErrorCode,(KSP,),(ksp,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetUp.html") -@wrapper(:KSPSetOperators,PetscErrorCode,(KSP,Mat,Mat),(ksp,Amat,Pmat),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetOperators.html") -@wrapper(:KSPSetTolerances,PetscErrorCode,(KSP,PetscReal,PetscReal,PetscReal,PetscInt),(ksp,rtol,abstol,dtol,maxits),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetTolerances.html") -@wrapper(:KSPSolve,PetscErrorCode,(KSP,Vec,Vec),(ksp,b,x),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSolve.html") -@wrapper(:KSPSolveTranspose,PetscErrorCode,(KSP,Vec,Vec),(ksp,b,x),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSolveTranspose.html") -@wrapper(:KSPGetIterationNumber,PetscErrorCode,(KSP,Ptr{PetscInt}),(ksp,its),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPGetIterationNumber.html") -@wrapper(:KSPView,PetscErrorCode,(KSP,PetscViewer),(ksp,viewer),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPView.html") -@wrapper(:KSPSetInitialGuessNonzero,PetscErrorCode,(KSP,PetscBool),(ksp,flg),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetInitialGuessNonzero.html") -@wrapper(:KSPSetType,PetscErrorCode,(KSP,KSPType),(ksp,typ),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPSetType.html") -@wrapper(:KSPGetPC,PetscErrorCode,(KSP,Ptr{PC}),(ksp,pc),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPGetPC.html") -@wrapper(:PCSetType,PetscErrorCode,(PC,PCType),(pc,typ),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCSetType.html") -@wrapper(:PCView,PetscErrorCode,(PC,PetscViewer),(pc,viewer),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCView.html") -@wrapper(:PCFactorSetMatSolverType,PetscErrorCode,(PC,PCType),(pc,typ),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCFactorSetMatSolverType.html") -@wrapper(:PCFactorSetUpMatSolverType,PetscErrorCode,(PC,),(pc,),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCFactorSetUpMatSolverType.html") -@wrapper(:PCFactorGetMatrix,PetscErrorCode,(PC,Ptr{Mat}),(ksp,mat),"https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCFactorGetMatrix.html") +@wrapper(:KSPCreate,PetscErrorCode,(MPI.Comm,Ptr{KSP}),(comm,inksp),"/KSP/KSPCreate.html") +@wrapper(:KSPDestroy,PetscErrorCode,(Ptr{KSP},),(ksp,),"/KSP/KSPDestroy.html") +@wrapper(:KSPSetFromOptions,PetscErrorCode,(KSP,),(ksp,),"/KSP/KSPSetFromOptions.html") +@wrapper(:KSPSetOptionsPrefix,PetscErrorCode,(KSP,Cstring),(ksp,prefix),"/KSP/KSPSetOptionsPrefix.html") +@wrapper(:KSPSetUp,PetscErrorCode,(KSP,),(ksp,),"/KSP/KSPSetUp.html") +@wrapper(:KSPSetOperators,PetscErrorCode,(KSP,Mat,Mat),(ksp,Amat,Pmat),"/KSP/KSPSetOperators.html") +@wrapper(:KSPSetTolerances,PetscErrorCode,(KSP,PetscReal,PetscReal,PetscReal,PetscInt),(ksp,rtol,abstol,dtol,maxits),"/KSP/KSPSetTolerances.html") +@wrapper(:KSPSolve,PetscErrorCode,(KSP,Vec,Vec),(ksp,b,x),"/KSP/KSPSolve.html") +@wrapper(:KSPSolveTranspose,PetscErrorCode,(KSP,Vec,Vec),(ksp,b,x),"/KSP/KSPSolveTranspose.html") +@wrapper(:KSPGetIterationNumber,PetscErrorCode,(KSP,Ptr{PetscInt}),(ksp,its),"/KSP/KSPGetIterationNumber.html") +@wrapper(:KSPView,PetscErrorCode,(KSP,PetscViewer),(ksp,viewer),"/KSP/KSPView.html") +@wrapper(:KSPSetInitialGuessNonzero,PetscErrorCode,(KSP,PetscBool),(ksp,flg),"/KSP/KSPSetInitialGuessNonzero.html") +@wrapper(:KSPSetType,PetscErrorCode,(KSP,KSPType),(ksp,typ),"/KSP/KSPSetType.html") +@wrapper(:KSPGetPC,PetscErrorCode,(KSP,Ptr{PC}),(ksp,pc),"/KSP/KSPGetPC.html") +@wrapper(:PCSetType,PetscErrorCode,(PC,PCType),(pc,typ),"/PC/PCSetType.html") +@wrapper(:PCView,PetscErrorCode,(PC,PetscViewer),(pc,viewer),"/PC/PCView.html") +@wrapper(:PCFactorSetMatSolverType,PetscErrorCode,(PC,PCType),(pc,typ),"/PC/PCFactorSetMatSolverType.html") +@wrapper(:PCFactorSetUpMatSolverType,PetscErrorCode,(PC,),(pc,),"/PC/PCFactorSetUpMatSolverType.html") +@wrapper(:PCFactorGetMatrix,PetscErrorCode,(PC,Ptr{Mat}),(ksp,mat),"/PC/PCFactorGetMatrix.html") """ Julia alias for the `SNES` C type. -See [PETSc manual](https://petsc.org/release/docs/manualpages/SNES/SNES.html). +See [PETSc manual]($docs_url/SNES/SNES.html). """ struct SNES ptr::Ptr{Cvoid} @@ -749,22 +808,22 @@ const SNESCOMPOSITE = "composite" const SNESPATCH = "patch" -@wrapper(:SNESCreate,PetscErrorCode,(MPI.Comm,Ptr{SNES}),(comm,snes),"https://petsc.org/release/docs/manualpages/SNES/SNESCreate.html") -@wrapper(:SNESSetFunction,PetscErrorCode,(SNES,Vec,Ptr{Cvoid},Ptr{Cvoid}),(snes,vec,fptr,ctx),"https://petsc.org/release/docs/manualpages/SNES/SNESSetFunction.html") -@wrapper(:SNESSetJacobian,PetscErrorCode,(SNES,Mat,Mat,Ptr{Cvoid},Ptr{Cvoid}),(snes,A,P,jacptr,ctx),"https://petsc.org/release/docs/manualpages/SNES/SNESSetJacobian.html") -@wrapper(:SNESSolve,PetscErrorCode,(SNES,Vec,Vec),(snes,b,x),"https://petsc.org/release/docs/manualpages/SNES/SNESSolve.html") -@wrapper(:SNESDestroy,PetscErrorCode,(Ptr{SNES},),(snes,),"https://petsc.org/release/docs/manualpages/SNES/SNESDestroy.html") -@wrapper(:SNESSetFromOptions,PetscErrorCode,(SNES,),(snes,),"https://petsc.org/release/docs/manualpages/SNES/SNESSetFromOptions.html") -@wrapper(:SNESView,PetscErrorCode,(SNES,PetscViewer),(snes,viewer),"https://petsc.org/release/docs/manualpages/SNES/SNESView.html") -@wrapper(:SNESSetType,PetscErrorCode,(SNES,SNESType),(snes,type),"https://petsc.org/release/docs/manualpages/SNES/SNESSetType.html") -@wrapper(:SNESGetKSP,PetscErrorCode,(SNES,Ptr{KSP}),(snes,ksp),"https://petsc.org/release/docs/manualpages/SNES/SNESGetKSP.html") -@wrapper(:SNESGetIterationNumber,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,iter),"https://petsc.org/release/docs/manualpages/SNES/SNESGetIterationNumber.html") -@wrapper(:SNESGetLinearSolveIterations,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,iter),"https://petsc.org/release/docs/manualpages/SNES/SNESGetLinearSolveIterations.html") -@wrapper(:SNESSetCountersReset,PetscErrorCode,(SNES,PetscBool),(snes,reset),"https://petsc.org/release/docs/manualpages/SNES/SNESSetCountersReset.html") -@wrapper(:SNESGetNumberFunctionEvals,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,nfuncs),"https://petsc.org/release/docs/manualpages/SNES/SNESGetNumberFunctionEvals.html") -@wrapper(:SNESGetLinearSolveFailures,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,nfails),"https://petsc.org/release/docs/manualpages/SNES/SNESGetLinearSolveFailures.html") +@wrapper(:SNESCreate,PetscErrorCode,(MPI.Comm,Ptr{SNES}),(comm,snes),"/SNES/SNESCreate.html") +@wrapper(:SNESSetFunction,PetscErrorCode,(SNES,Vec,Ptr{Cvoid},Ptr{Cvoid}),(snes,vec,fptr,ctx),"/SNES/SNESSetFunction.html") +@wrapper(:SNESSetJacobian,PetscErrorCode,(SNES,Mat,Mat,Ptr{Cvoid},Ptr{Cvoid}),(snes,A,P,jacptr,ctx),"/SNES/SNESSetJacobian.html") +@wrapper(:SNESSolve,PetscErrorCode,(SNES,Vec,Vec),(snes,b,x),"/SNES/SNESSolve.html") +@wrapper(:SNESDestroy,PetscErrorCode,(Ptr{SNES},),(snes,),"/SNES/SNESDestroy.html") +@wrapper(:SNESSetFromOptions,PetscErrorCode,(SNES,),(snes,),"/SNES/SNESSetFromOptions.html") +@wrapper(:SNESView,PetscErrorCode,(SNES,PetscViewer),(snes,viewer),"/SNES/SNESView.html") +@wrapper(:SNESSetType,PetscErrorCode,(SNES,SNESType),(snes,type),"/SNES/SNESSetType.html") +@wrapper(:SNESGetKSP,PetscErrorCode,(SNES,Ptr{KSP}),(snes,ksp),"/SNES/SNESGetKSP.html") +@wrapper(:SNESGetIterationNumber,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,iter),"/SNES/SNESGetIterationNumber.html") +@wrapper(:SNESGetLinearSolveIterations,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,iter),"/SNES/SNESGetLinearSolveIterations.html") +@wrapper(:SNESSetCountersReset,PetscErrorCode,(SNES,PetscBool),(snes,reset),"/SNES/SNESSetCountersReset.html") +@wrapper(:SNESGetNumberFunctionEvals,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,nfuncs),"/SNES/SNESGetNumberFunctionEvals.html") +@wrapper(:SNESGetLinearSolveFailures,PetscErrorCode,(SNES,Ptr{PetscInt}),(snes,nfails),"/SNES/SNESGetLinearSolveFailures.html") # Garbage collection of PETSc objects -@wrapper(:PetscObjectRegisterDestroy,PetscErrorCode,(Ptr{Cvoid},),(obj,),"https://petsc.org/release/docs/manualpages/Sys/PetscObjectRegisterDestroy.html") -@wrapper(:PetscObjectRegisterDestroyAll,PetscErrorCode,(),(),"https://petsc.org/release/docs/manualpages/Sys/PetscObjectRegisterDestroyAll.html") +@wrapper(:PetscObjectRegisterDestroy,PetscErrorCode,(Ptr{Cvoid},),(obj,),"/Sys/PetscObjectRegisterDestroy.html") +@wrapper(:PetscObjectRegisterDestroyAll,PetscErrorCode,(),(),"/Sys/PetscObjectRegisterDestroyAll.html") diff --git a/test/mpi_array/api_test.jl b/test/mpi_array/api_test.jl new file mode 100644 index 0000000..969fb9e --- /dev/null +++ b/test/mpi_array/api_test.jl @@ -0,0 +1,33 @@ +module ApiTests + +using Test +using MPI +using PartitionedArrays + +repodir = normpath(joinpath(@__DIR__,"..","..")) + +defs = joinpath(repodir,"test","mpi_array","api_test_defs.jl") + +include(defs) +params = (;nodes_per_dir=(10,10,10),parts_per_dir=(1,1,1)) +with_mpi(dist->Defs.main(dist,params)) + +code = quote + using MPI; MPI.Init() + using PartitionedArrays + include($defs) + params = (;nodes_per_dir=(10,10,10),parts_per_dir=(2,2,2)) + with_mpi(dist->Defs.main(dist,params)) +end +run(`$(mpiexec()) -np 8 $(Base.julia_cmd()) --project=$repodir -e $code`) + +code = quote + using MPI; MPI.Init() + using PartitionedArrays + include($defs) + params = (;nodes_per_dir=(10,10,10),parts_per_dir=(2,4,1)) + with_mpi(dist->Defs.main(dist,params)) +end +run(`$(mpiexec()) -np 8 $(Base.julia_cmd()) --project=$repodir -e $code`) + +end # module diff --git a/test/mpi_array/api_test_defs.jl b/test/mpi_array/api_test_defs.jl new file mode 100644 index 0000000..d9250cb --- /dev/null +++ b/test/mpi_array/api_test_defs.jl @@ -0,0 +1,85 @@ +module Defs + +using PartitionedArrays +using PetscCall +using LinearAlgebra +using Test + +function spmv_petsc!(b,A,x) + # Convert the input to petsc objects + mat = Ref{PetscCall.Mat}() + vec_b = Ref{PetscCall.Vec}() + vec_x = Ref{PetscCall.Vec}() + parts = linear_indices(partition(x)) + petsc_comm = PetscCall.setup_petsc_comm(parts) + args_A = PetscCall.MatCreateMPIAIJWithSplitArrays_args(A,petsc_comm) + args_b = PetscCall.VecCreateMPIWithArray_args(copy(b),petsc_comm) + args_x = PetscCall.VecCreateMPIWithArray_args(copy(x),petsc_comm) + ownership = (args_A,args_b,args_x) + PetscCall.@check_error_code PetscCall.MatCreateMPIAIJWithSplitArrays(args_A...,mat) + PetscCall.@check_error_code PetscCall.MatAssemblyBegin(mat[],PetscCall.MAT_FINAL_ASSEMBLY) + PetscCall.@check_error_code PetscCall.MatAssemblyEnd(mat[],PetscCall.MAT_FINAL_ASSEMBLY) + PetscCall.@check_error_code PetscCall.VecCreateMPIWithArray(args_b...,vec_b) + PetscCall.@check_error_code PetscCall.VecCreateMPIWithArray(args_x...,vec_x) + # This line does the actual product + PetscCall.@check_error_code PetscCall.MatMult(mat[],vec_x[],vec_b[]) + # Move the result back to julia + PetscCall.VecCreateMPIWithArray_args_reversed!(b,args_b) + # Cleanup + GC.@preserve ownership PetscCall.@check_error_code PetscCall.MatDestroy(mat) + GC.@preserve ownership PetscCall.@check_error_code PetscCall.VecDestroy(vec_b) + GC.@preserve ownership PetscCall.@check_error_code PetscCall.VecDestroy(vec_x) + b +end + +function test_spmm_petsc(A,B) + parts = linear_indices(partition(A)) + petsc_comm = PetscCall.setup_petsc_comm(parts) + C1, cacheC = spmm(A,B,reuse=true) + mat_A = Ref{PetscCall.Mat}() + mat_B = Ref{PetscCall.Mat}() + mat_C = Ref{PetscCall.Mat}() + args_A = PetscCall.MatCreateMPIAIJWithSplitArrays_args(A,petsc_comm) + args_B = PetscCall.MatCreateMPIAIJWithSplitArrays_args(B,petsc_comm) + ownership = (args_A,args_B) + PetscCall.@check_error_code PetscCall.MatCreateMPIAIJWithSplitArrays(args_A...,mat_A) + PetscCall.@check_error_code PetscCall.MatCreateMPIAIJWithSplitArrays(args_B...,mat_B) + PetscCall.@check_error_code PetscCall.MatProductCreate(mat_A[],mat_B[],C_NULL,mat_C) + PetscCall.@check_error_code PetscCall.MatProductSetType(mat_C[],PetscCall.MATPRODUCT_AB) + PetscCall.@check_error_code PetscCall.MatProductSetFromOptions(mat_C[]) + PetscCall.@check_error_code PetscCall.MatProductSymbolic(mat_C[]) + PetscCall.@check_error_code PetscCall.MatProductNumeric(mat_C[]) + PetscCall.@check_error_code PetscCall.MatProductReplaceMats(mat_A[],mat_B[],C_NULL,mat_C[]) + PetscCall.@check_error_code PetscCall.MatProductNumeric(mat_C[]) + PetscCall.@check_error_code PetscCall.MatProductClear(mat_C[]) + GC.@preserve ownership PetscCall.@check_error_code PetscCall.MatDestroy(mat_A) + GC.@preserve ownership PetscCall.@check_error_code PetscCall.MatDestroy(mat_B) + GC.@preserve ownership PetscCall.@check_error_code PetscCall.MatDestroy(mat_C) +end + +function main(distribute,params) + nodes_per_dir = params.nodes_per_dir + parts_per_dir = params.parts_per_dir + np = prod(parts_per_dir) + ranks = LinearIndices((np,)) |> distribute + A = PartitionedArrays.laplace_matrix(nodes_per_dir,parts_per_dir,ranks) + rows = partition(axes(A,1)) + cols = partition(axes(A,2)) + x = pones(cols) + b1 = pzeros(rows) + b2 = pzeros(rows) + mul!(b1,A,x) + if ! PetscCall.initialized() + PetscCall.init() + end + spmv_petsc!(b2,A,x) + c = b1-b2 + tol = 1.0e-12 + @test norm(b1) > tol + @test norm(b2) > tol + @test norm(c)/norm(b1) < tol + B = 2*A + test_spmm_petsc(A,B) +end + +end #module diff --git a/test/mpi_array/ksp_test.jl b/test/mpi_array/ksp_test.jl index de150ac..b649fe1 100644 --- a/test/mpi_array/ksp_test.jl +++ b/test/mpi_array/ksp_test.jl @@ -1,3 +1,5 @@ +module KspTests + using MPI using Test @@ -19,6 +21,5 @@ end run(`$mpiexec_cmd -np 3 $(Base.julia_cmd()) --project=$repodir -e $code`) -nothing - +end # module diff --git a/test/runtests.jl b/test/runtests.jl index def9f05..7067cd0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,10 @@ module PetscCallTest using PetscCall using Test +@testset "API" begin + @testset "PartitionedArrays: MPIArray" begin include("mpi_array/api_test.jl") end +end + @testset "KSP" begin @testset "Sequential" begin include("ksp_test.jl") end @testset "PartitionedArrays: DebugArray" begin include("debug_array/ksp_test.jl") end