|
| 1 | +--- |
| 2 | +title: MassMatrix example 3 |
| 3 | +author: Vikas Sharma, Ph.D. |
| 4 | +date: 20 Nov 2021 |
| 5 | +update: 20 Nov 2021 |
| 6 | +tags: |
| 7 | + - ReferenceLine |
| 8 | + - ReferenceLine/Initiate |
| 9 | + - QuadraturePoint/Initiate |
| 10 | + - ElemshapeData/Initiate |
| 11 | + - MassMatrix |
| 12 | +--- |
| 13 | + |
| 14 | +# MassMatrix example 3 |
| 15 | + |
| 16 | +!!! note "" |
| 17 | + This example shows how to USE the SUBROUTINE called `MassMatrix` to create a mass matrix in space domain. |
| 18 | + |
| 19 | +Here, we want to DO the following. |
| 20 | + |
| 21 | +$$ |
| 22 | +\int_{\Omega } N^{I}\rho N^{J}d\Omega |
| 23 | +$$ |
| 24 | + |
| 25 | +!!! warning "" |
| 26 | + `rho` can be a constant, or a FUNCTION of spatial coordinates, or some nonlinear FUNCTION. |
| 27 | + |
| 28 | +In this example, following mass matrix is formed for [[ReferenceLine_]] element, [[QuadraturePoint_]] are `GaussLegendre`. |
| 29 | + |
| 30 | +$$ |
| 31 | +\int_{\Omega } N^{I} N^{J}d\Omega |
| 32 | +$$ |
| 33 | + |
| 34 | +This TYPE of mass matrix is useful when $rho$ is a constant. |
| 35 | + |
| 36 | +## Modules and classes |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +```fortran |
| 41 | +PROGRAM main |
| 42 | + USE easifemBase |
| 43 | + IMPLICIT NONE |
| 44 | + TYPE(Elemshapedata_) :: test, elemsdForsimplex, trial |
| 45 | + TYPE(Quadraturepoint_) :: quad |
| 46 | + TYPE(Referenceline_) :: simplexElem, refElemFortest, refElemFortrial |
| 47 | + REAL(DFP), ALLOCATABLE :: mat(:, :), XiJ(:, :) |
| 48 | + INTEGER( I4B ), PARAMETER :: orderFortest = 1, orderForTrial = 2 |
| 49 | +``` |
| 50 | + |
| 51 | +!!! note "" |
| 52 | + Let us now create the physical coordinate of the line element. |
| 53 | + |
| 54 | +```fortran |
| 55 | + XiJ = RESHAPE([-1, 1], [1, 2]) |
| 56 | +``` |
| 57 | + |
| 58 | +!!! note "" |
| 59 | + Now we create an instance of [[ReferenceLine_]]. |
| 60 | + |
| 61 | +```fortran |
| 62 | + simplexElem = referenceline(nsd=1) |
| 63 | + CALL simplexElem%LagrangeElement(order=orderForTest, highOrderObj=refElemForTest) |
| 64 | + CALL simplexElem%LagrangeElement(order=orderForTrial, highOrderObj=refElemForTrial) |
| 65 | +``` |
| 66 | + |
| 67 | +!!! note "" |
| 68 | + Here, we create the quadrature points. |
| 69 | + |
| 70 | +```fortran |
| 71 | + CALL initiate( obj=quad, refelem=simplexElem, order=orderForTest+orderForTrial, & |
| 72 | + & quadratureType='GaussLegendre' ) |
| 73 | +``` |
| 74 | + |
| 75 | +!!! note "" |
| 76 | + Initiate an instance of [[ElemshapeData_]]. You can learn more about it from [[ElemshapeData_test]]. |
| 77 | + |
| 78 | +```fortran |
| 79 | + CALL initiate(obj=elemsdForsimplex, & |
| 80 | + & quad=quad, & |
| 81 | + & refelem=simplexElem, & |
| 82 | + & ContinuityType=typeH1, & |
| 83 | + & InterpolType=typeLagrangeInterpolation) |
| 84 | +``` |
| 85 | + |
| 86 | +!!! note "" |
| 87 | + Initiate an instance of [[ElemeshapeData_]] for test function. |
| 88 | + |
| 89 | +```fortran |
| 90 | + CALL initiate(obj=test, & |
| 91 | + & quad=quad, & |
| 92 | + & refelem=refElemForTest, & |
| 93 | + & ContinuityType=typeH1, & |
| 94 | + & InterpolType=typeLagrangeInterpolation) |
| 95 | + CALL Set(obj=test, val=xij, N=elemsdForSimplex%N, & |
| 96 | + & dNdXi=elemsdForSimplex%dNdXi) |
| 97 | +``` |
| 98 | + |
| 99 | +!!! note "" |
| 100 | + Initiate an instance of [[ElemeshapeData_]] for trial function. |
| 101 | + |
| 102 | +```fortran |
| 103 | + CALL initiate(obj=trial, & |
| 104 | + & quad=quad, & |
| 105 | + & refelem=refElemForTrial, & |
| 106 | + & ContinuityType=typeH1, & |
| 107 | + & InterpolType=typeLagrangeInterpolation) |
| 108 | + CALL Set(obj=trial, val=xij, N=elemsdForSimplex%N, & |
| 109 | + & dNdXi=elemsdForSimplex%dNdXi) |
| 110 | +``` |
| 111 | + |
| 112 | +!!! note "" |
| 113 | + Let us now create the mass matrix. |
| 114 | + |
| 115 | +```fortran |
| 116 | + mat=MassMatrix(test=test, trial=trial) |
| 117 | + CALL Display(mat, "mat:") |
| 118 | +``` |
| 119 | + |
| 120 | +??? example "Results" |
| 121 | + |
| 122 | + ```bash |
| 123 | + mat: |
| 124 | + ------------------------- |
| 125 | + 0.33333 0.00000 0.66667 |
| 126 | + 0.00000 0.33333 0.66667 |
| 127 | + ``` |
| 128 | + |
| 129 | +!!! settings "Cleanup" |
| 130 | + |
| 131 | +```fortran |
| 132 | +END PROGRAM main |
| 133 | +``` |
0 commit comments