CSRSparsity
CSRSparsity
is a user type for storing the compressed sparse row sparse matrix.
Constructor Methods
We have three methods to construct an instance of CSRSparsity
.
Initiate
methodCSRSparsity
functionCSRSparsityPointer
function
In order to construct an instance of CSRSparsity
, we need to specify nrow
ncol
and DOF object. By using DOF_
object we can specify the degrees of freedom structure inside CSRMatrix_
. Then one can use the Initiate method.
Working example is given below based on this concept.
Click here to see the example
Example 1
This example shows how to create an instance of CSRSparsity_
.
- First we will create an instance of
DOF_
- Then we will use it to create an instance of
CSRSparsity_
.
PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE( CSRSparsity_ ) :: obj
TYPE( DOF_ ) :: dofobj
INTEGER( I4B ) :: i
CALL Initiate( &
& obj=dofobj, &
& tNodes=[12], &
& names=['K'], &
& spaceCompo=[1], &
& timeCompo=[1], &
& storageFMT=NODES_FMT )
CALL Initiate( obj, ncol=12, nrow=12, idof=dofobj, jdof=dofobj )
CALL Display( obj, "CSRSparsity : " )
CALL Deallocate( dofobj )
CALL Deallocate( obj )
END PROGRAM main
For multi-physics applications following example will be helpful.
Click here to see the example
example 2
This example shows how to create an instance of CSRSparsity_
for block matrix storage. Following methods are tested:
PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE( CSRSparsity_ ) :: obj
TYPE( DOF_ ) :: dofobj
INTEGER( I4B ) :: i
CALL Initiate( &
& obj=dofobj, &
& tNodes=[20, 10], &
& names=['V', 'P'], &
& spaceCompo=[3, 1], &
& timeCompo=[1, 1], &
& storageFMT=FMT_DOF )
CALL Initiate( &
& obj, &
& ncol=(.tnodes. dofobj), &
& nrow=(.tNodes. dofobj), &
& idof=dofobj, &
& jdof=dofobj )
CALL Display( obj, "CSRSparsity : " )
CALL Deallocate( dofobj )
CALL Deallocate( obj )
END PROGRAM main
EASIFEM also has an assignment operator (=) to initiate an instance of CSRSparsity_
.
MODULE SUBROUTINE initiate( obj, obj2 )
TYPE( CSRSparsity_ ), INTENT( INOUT ) :: obj
TYPE( CSRSparsity_ ), INTENT( IN ) :: obj2
END SUBROUTINE initiate
However, if you have IA
andJA
indices, then you can initiate the CSRSparsity_
object using the following command.
MODULE SUBROUTINE initiate( obj, IA, JA )
TYPE( CSRSparsity_ ), INTENT( INOUT ) :: obj
INTEGER( I4B ), INTENT( IN ) :: IA( : ), JA( : )
END SUBROUTINE initiate
Set Methods
After constructing the instance of CSRSparsity_
we set the sparsity by calling SetSparsity.
All methods
📄️ Structure
CSRSparsity is data type for handling CSRMatrix in EASIFEM.
📄️ Deallocate
You can destruct an instance of CSRSparsity_ by calling Deallocate method as shown below.
📄️ Display
This method prints the contents of CSRSparsity_ object on the screen or to the file.
📄️ GetDiagonal
This subroutine returns the diagonal entries of sparse matrix.
📄️ GetNNZ
This function returns the number of non zeros.
📄️ GetSym
Make sparse matrix symmetric.
📄️ Initiate
Initiate an instance of CSRSparsity_.
📄️ SetSparsity
This subroutine sets the sparsity pattern in the CSRSparsity object.
📄️ Shape
This function Returns the shape of the array.
📄️ Size
This function returns the size of the sparse matrix.