Skip to content

Commit aa50380

Browse files
Adding MassMatrix and TomlUtility
1 parent 16e9016 commit aa50380

File tree

12 files changed

+616
-122
lines changed

12 files changed

+616
-122
lines changed

docs/docs-api/MassMatrix/MassMatrix_.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ date: 20 Nov 2021
55
update: 20 Nov 2021
66
tags:
77
- MassMatrix
8+
category:
9+
- MassMatrix
10+
- Finite Element
811
---
912

10-
# MassMatrix
11-
1213
## Theory
1314

1415
$$
@@ -19,19 +20,27 @@ $$
1920
\int_{\Omega } \rho N^{I} N^{J}d\Omega
2021
$$
2122

22-
## Constructor methods
23+
## Example 1
24+
25+
This example shows how to use the subroutine called `MassMatrix` to create a mass matrix in space domain.
26+
27+
Here, we want to do the following.
28+
29+
$$
30+
\int_{\Omega } N^{I}\rho N^{J}d\Omega
31+
$$
32+
33+
`rho` can be a constant, or a function of spatial coordinates, or some nonlinear function.
34+
35+
In this example, we use
2336

24-
!!! note "MassMatrix"
37+
- ReferenceLine element,
38+
- QuadraturePoint are `GaussLegendre`
39+
- order of integrand is 2.
2540

2641
$$
2742
\int_{\Omega } N^{I} N^{J}d\Omega
2843
$$
29-
30-
You can learn more about this in
31-
32-
- [[MassMatrix_test_1]] for [[ReferenceLine_]] `Line2`
33-
- [[MassMatrix_test_2]] for [[ReferenceLine_]] `Line3`
34-
- [[MassMatrix_test_3]] for mixed FEM type, Line2 and Line3 [[ReferenceLine_]]
3544

36-
- [ ] TODO add examples for creating mass matrix for triangle3 and triangle6 and 3D elements.
45+
This type of mass matrix is useful in cases where $rho$ is a constant.
3746

docs/docs-api/MassMatrix/MassMatrix_test_1.md

Lines changed: 0 additions & 111 deletions
This file was deleted.
File renamed without changes.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
```
File renamed without changes.

0 commit comments

Comments
 (0)