Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vickysharma0812 committed Apr 19, 2024
1 parent e7d57f6 commit 4423912
Show file tree
Hide file tree
Showing 20 changed files with 513 additions and 86 deletions.
20 changes: 20 additions & 0 deletions docs/docs-api/AppendUtility/examples/_Append_test_1.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PROGRAM main
USE easifemBase
IMPLICIT NONE
INTEGER(I4B), ALLOCATABLE :: intvec1(:)
REAL(DFP), ALLOCATABLE :: realvec1(:)

CALL Append(intvec1, 1)
CALL OK(ALL(intvec1 .EQ. [1]), "Append single ENTRY")

CALL Append(intvec1, [2, 3])
CALL OK(ALL(intvec1 .EQ. [1, 2, 3]), "Append a vector")

CALL Append(realvec1, 1.0_DFP)
CALL OK(ALL(realvec1 .EQ. [1.0_DFP]), "Append single ENTRY")

CALL Append(realvec1, [2.0_DFP, 3.0_DFP])
CALL OK(ALL(realvec1 .EQ. [1.0_DFP, 2.0_DFP, 3.0_DFP]), "Append a vector")

DEALLOCATE (intvec1, realvec1)
END PROGRAM main
18 changes: 10 additions & 8 deletions docs/docs-api/AppendUtility/examples/_Append_test_1.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- markdownlint-disable MD041 MD013 MD033 -->

```fortran
PROGRAM main
USE easifemBase
Expand All @@ -9,29 +11,29 @@ PROGRAM main
Now lets us append a single ENTRY to a vector of integers.

```fortran
CALL Append(intvec1, 1)
CALL OK( ALL(intvec1 .EQ. [1]), "Append single ENTRY" )
CALL Append(intvec1, 1)
CALL OK( ALL(intvec1 .EQ. [1]), "Append single ENTRY" )
```

Appending a vector to a vector.

```fortran
CALL Append(intvec1, [2,3])
CALL OK( ALL(intvec1 .EQ. [1,2,3]), "Append a vector" )
CALL Append(intvec1, [2,3])
CALL OK( ALL(intvec1 .EQ. [1,2,3]), "Append a vector" )
```

Now lets us append a single real value to realvec.

```fortran
CALL Append(realvec1, 1.0_DFP)
CALL OK( ALL(realvec1 .EQ. [1.0_DFP]), "Append single ENTRY" )
CALL Append(realvec1, 1.0_DFP)
CALL OK( ALL(realvec1 .EQ. [1.0_DFP]), "Append single ENTRY" )
```

Appending vector to a vector.

```fortran
CALL Append(realvec1, [2.0_DFP,3.0_DFP])
CALL OK( ALL(realvec1 .EQ. [1.0_DFP,2.0_DFP,3.0_DFP]), "Append a vector" )
CALL Append(realvec1, [2.0_DFP,3.0_DFP])
CALL OK( ALL(realvec1 .EQ. [1.0_DFP,2.0_DFP,3.0_DFP]), "Append a vector" )
```

Cleanup
Expand Down
2 changes: 1 addition & 1 deletion docs/docs-api/Domain/examples/_Initiate_test_1.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PROGRAM main
TYPE(Domain_) :: dom
TYPE(HDF5File_) :: meshfile
CHARACTER(*), PARAMETER :: filename= &
& "../../Mesh/examples/meshdata/small_mesh_3d.h5"
"../../Mesh/examples/meshdata/small_mesh_3d.h5"
CALL meshfile%Initiate(filename, mode="READ")
CALL meshfile%Open()
CALL dom%Initiate(meshfile, '')
Expand Down
6 changes: 5 additions & 1 deletion docs/docs-api/Domain/examples/_Initiate_test_1.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<!-- markdownlint-disable MD041 MD013 MD033 -->

```fortran
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE(Domain_) :: dom
TYPE(HDF5File_) :: meshfile
CHARACTER(*), PARAMETER :: filename= &
& "../../Mesh/examples/meshdata/small_mesh_3d.h5"
"../../Mesh/examples/meshdata/small_mesh_3d.h5"
CALL meshfile%Initiate(filename, mode="READ")
CALL meshfile%Open()
Expand Down
37 changes: 37 additions & 0 deletions docs/docs-api/FEDomain/GetMeshPointer.md
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
# GetMeshPointer

<!-- markdownlint-disable MD041 MD013 MD033 -->

This function returns the mesh pointer stored in the domain.

## Interface

<Tabs>
<TabItem value="interface" label="Interface" default>

```fortran
INTERFACE
MODULE FUNCTION Domain_GetMeshPointer1(obj, dim, entityNum) RESULT(Ans)
CLASS(Domain_), INTENT(IN) :: obj
INTEGER(I4B), INTENT(IN) :: dim
!! dimension of mesh entity
INTEGER(I4B), INTENT(IN) :: entityNum
!! entity number
CLASS(Mesh_), POINTER :: ans
END FUNCTION Domain_GetMeshPointer1
END INTERFACE
```

</TabItem>

<TabItem value="example" label="example">

import EXAMPLE10 from "./examples/_GetMeshPointer_test_1.md";

<EXAMPLE10 />

</TabItem>

<TabItem value="close" label="↢ close">

</TabItem>
</Tabs>
2 changes: 2 additions & 0 deletions docs/docs-api/FEDomain/examples/_GetMeshPointer_test_1.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- markdownlint-disable MD041 MD013 MD033 -->

```fortran
PROGRAM main
USE easifemBase
Expand Down
35 changes: 17 additions & 18 deletions docs/docs-api/FEMesh/examples/_GetElementToElements_test_1.F90
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@

PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE( FEMesh_ ) :: obj
TYPE( HDF5File_ ) :: meshfile
INTEGER( I4B ), ALLOCATABLE :: nptrs( :, : )
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE(FEMesh_) :: obj
TYPE(HDF5File_) :: meshfile
INTEGER(I4B), ALLOCATABLE :: elem2elem(:, :)
CHARACTER(*), PARAMETER :: filename="../../Mesh/examples/meshdata/small_mesh.h5"
! Initiate and open the mesh file which is in [[HDF5File_]] format. Then, create an instance of mesh.
CALL meshfile%Initiate(filename, "READ" )
CALL meshfile%Open()
CALL obj%Initiate(hdf5=meshfile, group="/surfaceEntities_1" )
! Initiate and open the mesh file which is in [[HDF5File_]] format. Then, create an instance of mesh.
CALL meshfile%Initiate(filename, "READ")
CALL meshfile%OPEN()
CALL obj%Initiate(hdf5=meshfile, group="/surfaceEntities_1")

nptrs = obj%GetElementToElements( globalElement=23, onlyElements=.FALSE. )
CALL Display( nptrs, "Element connected to iel=23")
elem2elem = obj%GetElementToElements(globalElement=23, onlyElements=.FALSE.)
CALL Display(elem2elem, "Element connected to iel=23")

nptrs = obj%GetElementToElements( globalElement=23, onlyElements=.TRUE. )
CALL Display( nptrs, "Element connected to iel=23")
elem2elem = obj%GetElementToElements(globalElement=23, onlyElements=.TRUE.)
CALL Display(elem2elem, "Element connected to iel=23")

CALL obj%Deallocate()
CALL meshfile%Close()
CALL meshfile%Deallocate()
CALL obj%DEALLOCATE()
CALL meshfile%CLOSE()
CALL meshfile%DEALLOCATE()
END PROGRAM main
49 changes: 49 additions & 0 deletions docs/docs-api/Mesh/examples/_GetElementToElements_test_2.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
PROGRAM main
USE easifemBase
USE easifemClasses

IMPLICIT NONE

CHARACTER(*), PARAMETER :: filename = "./meshdata/small_mesh.h5"
INTEGER(I4B), ALLOCATABLE :: elem2elem(:, :)
INTEGER(I4B) :: globalElement, ii
TYPE(ElemData_) :: elemdata1, elemdata2
TYPE(FEMesh_) :: obj
TYPE(HDF5File_) :: meshfile
LOGICAL(LGT) :: isok

CALL e%setQuietMode(EXCEPTION_INFORMATION, .TRUE.)
CALL meshfile%Initiate(filename, "READ")
CALL meshfile%OPEN()
CALL obj%Initiate(hdf5=meshfile, group="/surfaceEntities_1")

globalElement = 23
elem2elem = obj%GetElementToElements(globalElement=globalElement, &
onlyElements=.FALSE.)
CALL Display(elem2elem, "Element connected to iel="//tostring(globalElement))
CALL obj%GetElemData(globalElement=globalElement, elemdata=elemdata1, &
islocal=.FALSE.)
CALL Blanklines(nol=2)

CALL ElemData_Display(elemdata1, "elemdata: ")

DO ii = 1, SIZE(elem2elem, 1)

globalElement = elem2elem(ii, 1)
CALL obj%GetElemData(globalElement=globalElement, elemdata=elemdata2, &
islocal=.FALSE.)

isok = elemdata1%globalFaces(elem2elem(ii, 2)) &
.EQ. elemdata2%globalFaces(elem2elem(ii, 3))
CALL OK(isok, "GetElementToElements test-a : ")

isok = (elemdata1%faceOrient(1, elem2elem(ii, 2)) &
+ elemdata2%faceOrient(1, elem2elem(ii, 3))) .EQ. 0
CALL OK(isok, "GetElementToElements test-b : ")

END DO

CALL obj%DEALLOCATE()
CALL meshfile%CLOSE()
CALL meshfile%DEALLOCATE()
END PROGRAM main
122 changes: 122 additions & 0 deletions docs/docs-api/Mesh/examples/_GetElementToElements_test_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<!-- markdownlint-disable MD041 MD013 MD033 -->

```fortran
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
CHARACTER(*), PARAMETER :: filename = "./meshdata/small_mesh.h5"
INTEGER(I4B), ALLOCATABLE :: elem2elem(:, :)
INTEGER(I4B) :: globalElement
TYPE(ElemData_) :: elemdata
TYPE(FEMesh_) :: obj
TYPE(HDF5File_) :: meshfile
CALL e%setQuietMode(EXCEPTION_INFORMATION, .TRUE.)
CALL meshfile%Initiate(filename, "READ")
CALL meshfile%OPEN()
CALL obj%Initiate(hdf5=meshfile, group="/surfaceEntities_1")
elem2elem = obj%GetElementToElements(globalElement=23, onlyElements=.FALSE.)
CALL Display(elem2elem, "Element connected to iel=23")
CALL obj%GetElemData(globalElement=23, elemdata=elemdata, islocal=.FALSE.)
CALL ElemData_Display(elemdata, "elemdata: ")
CALL Blanklines(nol=2)
globalElement = 22
elem2elem = obj%GetElementToElements(globalElement=globalElement, &
onlyElements=.FALSE.)
CALL Display(elem2elem, "Element connected to iel="// &
tostring(globalElement))
CALL obj%GetElemData(globalElement=globalElement, elemdata=elemdata, &
islocal=.FALSE.)
CALL ElemData_Display(elemdata, "elemdata: ")
CALL obj%DEALLOCATE()
CALL meshfile%CLOSE()
CALL meshfile%DEALLOCATE()
END PROGRAM main
```

```bash title="results"
Element connected to iel=23
---------------------------
22 1 2
26 2 3
25 3 1
elemdata:
isActive: TRUE
globalElemNum: 23
localElemNum: 11
elementType:INTERNAL_ELEMENT
elementName:Triangle3
globalNodes:
-------------
9
10
11
globalEdges:
-------------
22
23
24
edgeOrient:
------------
1
1
1
globalElements:
----------------
22
1
2
26
2
3
25
3
1
boundaryData:
--------------


Element connected to iel=22
---------------------------
20 1 3
23 2 1
14 3 2
elemdata:
isActive: TRUE
globalElemNum: 22
localElemNum: 10
elementType:INTERNAL_ELEMENT
elementName:Triangle3
globalNodes:
-------------
9
8
10
globalEdges:
-------------
20
22
5
edgeOrient:
------------
-1
1
1
globalElements:
----------------
20
1
3
23
2
1
14
3
2
boundaryData:
--------------
```
44 changes: 44 additions & 0 deletions docs/docs-api/Mesh/examples/_GetElementToElements_test_3.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PROGRAM main
USE easifemBase
USE easifemClasses

IMPLICIT NONE

CHARACTER(*), PARAMETER :: filename = "./meshdata/small_mesh.h5"
INTEGER(I4B), ALLOCATABLE :: elem2elem(:, :)
INTEGER(I4B) :: globalElement
TYPE(ElemData_) :: elemdata1, elemdata2
TYPE(FEMesh_) :: obj
TYPE(HDF5File_) :: meshfile

CALL e%setQuietMode(EXCEPTION_INFORMATION, .TRUE.)
CALL meshfile%Initiate(filename, "READ")
CALL meshfile%OPEN()
CALL obj%Initiate(hdf5=meshfile, group="/surfaceEntities_1")

globalElement = 23
elem2elem = obj%GetElementToElements(globalElement=globalElement, &
onlyElements=.FALSE.)
CALL Display(elem2elem, "Element connected to iel="//tostring(globalElement))
CALL obj%GetElemData(globalElement=globalElement, elemdata=elemdata1, &
islocal=.FALSE.)
! CALL ElemData_Display(elemdata1, "elemdata: ")
CALL Blanklines(nol=2)

DO ii = 1, SIZE(elem2elem, 1)

globalElement = elem2elem(1, ii)
! elem2elem = obj%GetElementToElements(globalElement=globalElement, &
! onlyElements=.FALSE.)
! CALL Display(elem2elem, "Element connected to iel="// &
! tostring(globalElement))
CALL obj%GetElemData(globalElement=globalElement, elemdata=elemdata, &
islocal=.FALSE.)
! CALL ElemData_Display(elemdata, "elemdata: ")

END DO

CALL obj%DEALLOCATE()
CALL meshfile%CLOSE()
CALL meshfile%DEALLOCATE()
END PROGRAM main
Loading

0 comments on commit 4423912

Please sign in to comment.