Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates in CSRMatrix #271

Merged
merged 8 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
430 changes: 429 additions & 1 deletion src/modules/CSRMatrix/src/CSRMatrix_GetMethods.F90

Large diffs are not rendered by default.

38 changes: 36 additions & 2 deletions src/modules/CSRSparsity/src/CSRSparsity_Method.F90
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ MODULE CSRSparsity_Method
PUBLIC :: OPERATOR(.endColumn.)
PUBLIC :: SetIA
PUBLIC :: SetJA
PUBLIC :: GetIA
PUBLIC :: GetJA

!----------------------------------------------------------------------------
! Initiate@ConstructorMethods
Expand Down Expand Up @@ -722,7 +724,7 @@ END SUBROUTINE obj_SetSparsity_final
END INTERFACE SetSparsity

!----------------------------------------------------------------------------
! SetIA@GetMethods
! SetIA@SetMethods
!----------------------------------------------------------------------------

!> author: Vikas Sharma, Ph. D.
Expand All @@ -738,7 +740,7 @@ END SUBROUTINE obj_SetIA
END INTERFACE SetIA

!----------------------------------------------------------------------------
! SetJA@GetMethods
! SetJA@SetMethods
!----------------------------------------------------------------------------

!> author: Vikas Sharma, Ph. D.
Expand All @@ -753,6 +755,38 @@ MODULE PURE SUBROUTINE obj_SetJA(obj, indx, VALUE)
END SUBROUTINE obj_SetJA
END INTERFACE SetJA

!----------------------------------------------------------------------------
! GetIA@GetMethods
!----------------------------------------------------------------------------

!> author: Vikas Sharma, Ph. D.
! date: 2023-12-23
! summary: Get entry from IA

INTERFACE GetIA
MODULE PURE FUNCTION obj_GetIA(obj, irow) RESULT(ans)
TYPE(CSRSparsity_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: irow
INTEGER(I4B) :: ans
END FUNCTION obj_GetIA
END INTERFACE GetIA

!----------------------------------------------------------------------------
! GetJA@GetMethods
!----------------------------------------------------------------------------

!> author: Vikas Sharma, Ph. D.
! date: 2023-12-14
! summary: Get entry from JA

INTERFACE GetJA
MODULE PURE FUNCTION obj_GetJA(obj, indx) RESULT(ans)
TYPE(CSRSparsity_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: indx
INTEGER(I4B) :: ans
END FUNCTION obj_GetJA
END INTERFACE GetJA

!----------------------------------------------------------------------------
! GetSym@SymMethods
!----------------------------------------------------------------------------
Expand Down
56 changes: 41 additions & 15 deletions src/modules/Utility/src/ConvertUtility.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ MODULE ConvertUtility
PRIVATE

PUBLIC :: Convert
PUBLIC :: ConvertSafe

!----------------------------------------------------------------------------
! Convert@ConvertMethods
Expand All @@ -47,7 +48,7 @@ MODULE ConvertUtility
! this routine works when matrix is square.
!@endnote

INTERFACE
INTERFACE Convert
MODULE PURE SUBROUTINE convert_1(From, To, Conversion, nns, tdof)
REAL(DFP), INTENT(IN) :: From(:, :)
!! Matrix in one format
Expand All @@ -57,12 +58,45 @@ MODULE PURE SUBROUTINE convert_1(From, To, Conversion, nns, tdof)
!! `Conversion` can be `NodesToDOF` or `DOFToNodes`
INTEGER(I4B), INTENT(IN) :: nns, tdof
END SUBROUTINE convert_1
END INTERFACE

INTERFACE Convert
MODULE PROCEDURE convert_1
END INTERFACE Convert

!----------------------------------------------------------------------------
! Convert@ConvertMethods
!----------------------------------------------------------------------------

!> author: Vikas Sharma, Ph. D.
! date: 6 March 2021
! summary: Rearrange the degrees of freedom in a finite element matrix
!
!# Introduction
!
! This subroutine changes the storage pattern of a two-d matrix
! - Usually element matrix in easifem are stored in `FMT_DOF`
! - Global matrices/tanmat, however, are stored in `FMT_Nodes`
! - This subroutine is, therefore, in settings or adding values in
! [[SparseMatrix_]].
!
! > This subroutine converts changes the storage format of dense matrix.
! Usually, elemental finite element matrix is stored in `DOF_FMT`, and global
! matrix/ tanmat, may be stored in `Nodes_FMT`.
!
!@note
! All dof should have the same order of interpolation, therefore,
! this routine works when matrix is square.
!@endnote

INTERFACE ConvertSafe
MODULE PURE SUBROUTINE convert_1_safe(From, To, Conversion, nns, tdof)
REAL(DFP), INTENT(IN) :: From(:, :)
!! Matrix in one format
REAL(DFP), INTENT(INOUT) :: To(:, :)
!! Matrix is desired format
INTEGER(I4B), INTENT(IN) :: Conversion
!! `Conversion` can be `NodesToDOF` or `DOFToNodes`
INTEGER(I4B), INTENT(IN) :: nns, tdof
END SUBROUTINE convert_1_safe
END INTERFACE ConvertSafe

!----------------------------------------------------------------------------
! Convert@ConvertMethods
!----------------------------------------------------------------------------
Expand All @@ -85,15 +119,11 @@ END SUBROUTINE convert_1
!
! Contains the block matrix structure in 2D.

INTERFACE
INTERFACE Convert
MODULE PURE SUBROUTINE convert_2(From, To)
REAL(DFP), INTENT(IN) :: From(:, :, :, :)
REAL(DFP), ALLOCATABLE, INTENT(INOUT) :: To(:, :)
END SUBROUTINE convert_2
END INTERFACE

INTERFACE Convert
MODULE PROCEDURE convert_2
END INTERFACE Convert

!----------------------------------------------------------------------------
Expand All @@ -105,17 +135,13 @@ END SUBROUTINE convert_2
! summary: This subroutine converts rank4 matrix to rank2 matrix
!

INTERFACE
INTERFACE Convert
MODULE PURE SUBROUTINE convert_3(From, To)
REAL(DFP), INTENT(IN) :: From(:, :, :, :, :, :)
!! I, J, ii, jj, a, b
REAL(DFP), ALLOCATABLE, INTENT(INOUT) :: To(:, :, :, :)
!! I, J, a, b
END SUBROUTINE convert_3
END INTERFACE

INTERFACE Convert
MODULE PROCEDURE convert_3
END INTERFACE Convert

!----------------------------------------------------------------------------
Expand Down
8 changes: 6 additions & 2 deletions src/submodules/CSRMatrix/src/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,15 @@
!----------------------------------------------------------------------------

MODULE PROCEDURE obj_Initiate3
CALL DEALLOCATE (obj)
CALL Initiate(obj=obj%csr, IA=IA, JA=JA, ncol=ncol)
obj%csrOwnership = .TRUE.
IF (PRESENT(matrixProp)) obj%matrixProp = TRIM(matrixProp)
CALL Initiate(obj=obj%csr, IA=IA, JA=JA, ncol=ncol)
CALL Reallocate(obj%A, SIZE(A))
#ifdef USE_BLAS95
CALL Copy(y=obj%A, x=A)
#else
obj%A = A
#endif
CALL SetTotalDimension(obj, 2_I4B)
CALL SetSparsity(obj)
END PROCEDURE obj_Initiate3
Expand Down
Loading
Loading