Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions docs/docs-api/MassMatrix/MassMatrix_.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ date: 20 Nov 2021
update: 20 Nov 2021
tags:
- MassMatrix
category:
- MassMatrix
- Finite Element
---

# MassMatrix

## Theory

$$
Expand All @@ -19,19 +20,27 @@ $$
\int_{\Omega } \rho N^{I} N^{J}d\Omega
$$

## Constructor methods
## Example 1

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.

$$
\int_{\Omega } N^{I}\rho N^{J}d\Omega
$$

`rho` can be a constant, or a function of spatial coordinates, or some nonlinear function.

In this example, we use

!!! note "MassMatrix"
- ReferenceLine element,
- QuadraturePoint are `GaussLegendre`
- order of integrand is 2.

$$
\int_{\Omega } N^{I} N^{J}d\Omega
$$

You can learn more about this in

- [[MassMatrix_test_1]] for [[ReferenceLine_]] `Line2`
- [[MassMatrix_test_2]] for [[ReferenceLine_]] `Line3`
- [[MassMatrix_test_3]] for mixed FEM type, Line2 and Line3 [[ReferenceLine_]]

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

111 changes: 0 additions & 111 deletions docs/docs-api/MassMatrix/MassMatrix_test_1.md

This file was deleted.

133 changes: 133 additions & 0 deletions docs/docs-api/MassMatrix/examples/MassMatrix_test_3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: MassMatrix example 3
author: Vikas Sharma, Ph.D.
date: 20 Nov 2021
update: 20 Nov 2021
tags:
- ReferenceLine
- ReferenceLine/Initiate
- QuadraturePoint/Initiate
- ElemshapeData/Initiate
- MassMatrix
---

# MassMatrix example 3

!!! 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.

$$
\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`.

$$
\int_{\Omega } N^{I} N^{J}d\Omega
$$

This TYPE of mass matrix is useful when $rho$ is a constant.

## Modules and classes

## Usage

```fortran
PROGRAM main
USE easifemBase
IMPLICIT NONE
TYPE(Elemshapedata_) :: test, elemsdForsimplex, trial
TYPE(Quadraturepoint_) :: quad
TYPE(Referenceline_) :: simplexElem, refElemFortest, refElemFortrial
REAL(DFP), ALLOCATABLE :: mat(:, :), XiJ(:, :)
INTEGER( I4B ), PARAMETER :: orderFortest = 1, orderForTrial = 2
```

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

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

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

```fortran
simplexElem = referenceline(nsd=1)
CALL simplexElem%LagrangeElement(order=orderForTest, highOrderObj=refElemForTest)
CALL simplexElem%LagrangeElement(order=orderForTrial, highOrderObj=refElemForTrial)
```

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

```fortran
CALL initiate( obj=quad, refelem=simplexElem, order=orderForTest+orderForTrial, &
& quadratureType='GaussLegendre' )
```

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

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

!!! note ""
Initiate an instance of [[ElemeshapeData_]] for test function.

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

!!! note ""
Initiate an instance of [[ElemeshapeData_]] for trial function.

```fortran
CALL initiate(obj=trial, &
& quad=quad, &
& refelem=refElemForTrial, &
& ContinuityType=typeH1, &
& InterpolType=typeLagrangeInterpolation)
CALL Set(obj=trial, val=xij, N=elemsdForSimplex%N, &
& dNdXi=elemsdForSimplex%dNdXi)
```

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

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

??? example "Results"

```bash
mat:
-------------------------
0.33333 0.00000 0.66667
0.00000 0.33333 0.66667
```

!!! settings "Cleanup"

```fortran
END PROGRAM main
```
Loading