Skip to main content

MassMatrix example 2

!!! note "" This example shows how to USE the SUBROUTINE called MassMatrix to create a mass matrix in space domain.

Here, we want to DO the following.

ΩNIρNJdΩ\int_{\Omega } N^{I}\rho N^{J}d\Omega

!!! warning "" rho can be a constant, or a FUNCTION of spatial coordinates, or some nonlinear FUNCTION.

In this example, following mass matrix is formed for [[ReferenceLine_]] element, [[QuadraturePoint_]] are GaussLegendre.

ΩNINJdΩ\int_{\Omega } N^{I} N^{J}d\Omega

This TYPE of mass matrix is useful in cases WHERE rhorho is a constant.

Modules and classes

Usage

PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(Elemshapedata_) :: test, elemsdForsimplex
TYPE(Quadraturepoint_) :: quad
TYPE(Referenceline_) :: simplexElem, refElem
REAL(DFP), ALLOCATABLE :: mat(:, :), XiJ(:, :)
INTEGER( I4B ), PARAMETER :: order = 2

!!! note "" Let us now create the physical coordinate of the line element.

    XiJ = RESHAPE([-1, 1], [1, 2])

!!! note "" Now we create an instance of [[ReferenceLine_]].

    simplexElem = referenceline(nsd=1)
CALL simplexElem%LagrangeElement(order=order, highOrderObj=refelem)

!!! note "" Here, we create the quadrature points.

    CALL initiate( obj=quad, refelem=refelem, order=order*2, &
& quadratureType='GaussLegendre' )

!!! note "" Initiate an instance of [[ElemshapeData_]]. You can learn more about it from [[ElemshapeData_test]].

    CALL initiate(obj=elemsdForsimplex, &
& quad=quad, &
& refelem=simplexElem, &
& ContinuityType=typeH1, &
& InterpolType=typeLagrangeInterpolation)

!!! note "" Initiate an instance of [[ElemeshapeData_]].

    CALL initiate(obj=test, &
& quad=quad, &
& refelem=refElem, &
& ContinuityType=typeH1, &
& InterpolType=typeLagrangeInterpolation)
CALL Set(obj=test, val=xij, N=elemsdForSimplex%N, &
& dNdXi=elemsdForSimplex%dNdXi)

!!! note "" Let us now create the mass matrix.

    mat=MassMatrix(test=test, trial=test)
CALL Display(mat, "mat:")

??? example "Results"

            mat:           
---------------------------
0.26667 -0.06667 0.13333
-0.06667 0.26667 0.13333
0.13333 0.13333 1.06667

!!! settings "Cleanup"

END PROGRAM main