Skip to content

Commit

Permalink
Merge branch 'PETSc-3.22-compatible' into 'development'
Browse files Browse the repository at this point in the history
adjustments for PETSc 3.22.x

See merge request damask/DAMASK!981
  • Loading branch information
dmentock committed Oct 23, 2024
2 parents 4e070e5 + e8ad7b3 commit 8c42662
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Fortran.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Grid and Mesh Solver
on: [push]

env:
PETSC_VERSION: '3.21.4'
PETSC_VERSION: '3.22.0'
HOMEBREW_NO_ANALYTICS: 'ON' # Make Homebrew installation a little quicker
HOMEBREW_NO_AUTO_UPDATE: 'ON'
HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: 'ON'
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ endif()
project(Prerequisites LANGUAGES)
set(ENV{PKG_CONFIG_PATH} "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
pkg_check_modules(PETSC_MIN REQUIRED PETSc>=3.12.0 QUIET) #CMake does not support version range
pkg_check_modules(PETSC REQUIRED PETSc<3.22.0)
pkg_check_modules(PETSC REQUIRED PETSc<3.23.0)

pkg_get_variable(CMAKE_Fortran_COMPILER PETSc fcompiler)
pkg_get_variable(CMAKE_C_COMPILER PETSc ccompiler)
Expand Down
2 changes: 1 addition & 1 deletion src/CLI.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
!> @brief Parse command line interface for PETSc-based solvers
!--------------------------------------------------------------------------------------------------
#define PETSC_MINOR_MIN 12
#define PETSC_MINOR_MAX 21
#define PETSC_MINOR_MAX 22

module CLI
use, intrinsic :: ISO_fortran_env
Expand Down
7 changes: 6 additions & 1 deletion src/grid/grid_mech_spectral_Galerkin.f90
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ subroutine MatShellSetOperation(mat,op_num,op_callback,ierr)
end subroutine MatShellSetOperation
end interface MatShellSetOperation

#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR<22)
interface SNESSetJacobian
subroutine SNESSetJacobian(snes_mech,A,P,jac_callback,ctx,ierr)
use petscsnes
Expand All @@ -145,6 +146,7 @@ subroutine SNESSetJacobian(snes_mech,A,P,jac_callback,ctx,ierr)
PetscErrorCode :: ierr
end subroutine SNESSetJacobian
end interface SNESSetJacobian
#endif

interface SNESSetUpdate
subroutine SNESSetUpdate(snes_mech,upd_callback,ierr)
Expand Down Expand Up @@ -678,14 +680,17 @@ end subroutine GK_op
subroutine set_F_aim(snes, step, ierr)
SNES :: snes
PetscInt :: step ! curr completed petsc iter
PetscErrorCode :: ierr
PetscErrorCode, intent(out) :: ierr


real(pREAL), dimension(3,3) :: &
deltaF_aim

deltaF_aim = math_mul3333xx33(S, P_av - P_aim)
F_aim = F_aim - deltaF_aim

ierr = 0_pPETSCERRORCODE

end subroutine set_F_aim

end module grid_mechanical_spectral_Galerkin
10 changes: 10 additions & 0 deletions src/mesh/discretization_mesh.f90
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,25 @@ subroutine discretization_mesh_init()
#else
call PetscDTSimplexQuadrature(dimplex, p_i, -1, quadrature, err_PETSc)
CHKERRQ(err_PETSc)
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=22)
call PetscQuadratureGetData(quadrature,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, &
mesh_maxNips,qPointsP,PETSC_NULL_REAL_PTR,err_PETSc)
#else
call PetscQuadratureGetData(quadrature,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), &
mesh_maxNips,qPointsP,PETSC_NULL_REAL_PTR,err_PETSc)
#endif
CHKERRQ(err_PETSc)

call mesh_FEM_build_ipCoordinates(dimPlex,qPointsP)
call mesh_FEM_build_ipVolumes(dimPlex)

#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=22)
call PetscQuadratureRestoreData(quadrature,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, &
PETSC_NULL_INTEGER,qPointsP,PETSC_NULL_REAL_PTR,err_PETSc)
#else
call PetscQuadratureRestoreData(quadrature,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), &
PETSC_NULL_INTEGER(1),qPointsP,PETSC_NULL_REAL_PTR,err_PETSc)
#endif
CHKERRQ(err_PETSc)
call PetscQuadratureDestroy(quadrature, err_PETSc)
CHKERRQ(err_PETSc)
Expand Down
10 changes: 10 additions & 0 deletions src/mesh/mesh_mech_FEM.f90
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,23 @@ subroutine FEM_mechanical_init(mechBC,num_mesh)
#else
call PetscDTSimplexQuadrature(dimplex,num%p_i,-1,mechQuad,err_PETSc)
CHKERRQ(err_PETSc)
#if (PETSC_VERSION_MAJOR==3 && PETSC_VERSION_MINOR>=22)
call PetscQuadratureGetData(mechQuad,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, &
nQuadrature,PETSC_NULL_REAL_PTR,qWeightsP,err_PETSc)
CHKERRQ(err_PETSc)
qWeights = qWeightsP
call PetscQuadratureRestoreData(mechQuad,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER, &
PETSC_NULL_INTEGER,PETSC_NULL_REAL_PTR,qWeightsP, &
err_PETSc)
#else
call PetscQuadratureGetData(mechQuad,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), &
nQuadrature,PETSC_NULL_REAL_PTR,qWeightsP,err_PETSc)
CHKERRQ(err_PETSc)
qWeights = qWeightsP
call PetscQuadratureRestoreData(mechQuad,PETSC_NULL_INTEGER(1),PETSC_NULL_INTEGER(1), &
PETSC_NULL_INTEGER(1),PETSC_NULL_REAL_PTR,qWeightsP, &
err_PETSc)
#endif
CHKERRQ(err_PETSc)
nc = dimPlex
#endif
Expand Down
13 changes: 7 additions & 6 deletions src/prec.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ module prec
integer, parameter :: pI32 = selected_int_kind(9) !< number with at least up to +-1e9 (typically 32 bit)
integer, parameter :: pI64 = selected_int_kind(18) !< number with at least up to +-1e18 (typically 64 bit)
#ifdef PETSC
PetscInt, private :: dummy_int
integer, parameter :: pPETSCINT = kind(dummy_int)
PetscScalar, private :: dummy_scalar
real(pREAL), parameter, private :: pPETSCSCALAR = kind(dummy_scalar)
PetscInt, private :: dummy_int
PetscErrorCode, private :: dummy_error_code
integer, parameter :: pPETSCINT = kind(dummy_int)
integer, parameter :: pPETSCERRORCODE = kind(dummy_error_code)
#endif
integer, parameter :: pSTRLEN = 256 !< default string length
integer, parameter :: pPATHLEN = 4096 !< maximum length of a path name on linux
Expand Down Expand Up @@ -251,10 +251,11 @@ subroutine prec_selfTest()
real(pREAL), dimension(1) :: f
integer(pI64), dimension(1) :: i
real(pREAL), dimension(2) :: r
#ifdef PETSC
PetscScalar :: dummy_scalar


#ifdef PETSC
if (pREAL /= pPETSCSCALAR) error stop 'PETSc and DAMASK scalar datatypes do not match'
if (pREAL /= kind(dummy_scalar)) error stop 'PETSc and DAMASK scalar datatypes do not match'
#endif
realloc_lhs_test = [1,2]
if (any(realloc_lhs_test/=[1,2])) error stop 'LHS allocation'
Expand Down

0 comments on commit 8c42662

Please sign in to comment.