Skip to main content

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 method
  • CSRSparsity function
  • CSRSparsityPointer 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