|
| 1 | +!> author: Vikas Sharma, Ph. D. |
| 2 | +! date: 2025-10-23 |
| 3 | +! summary: Study of DirichletBC class |
| 4 | + |
| 5 | +PROGRAM main |
| 6 | +USE GlobalData, ONLY: DFP, I4B, LGT |
| 7 | +USE ExceptionHandler_Class, ONLY: e, EXCEPTION_INFORMATION |
| 8 | +USE DirichletBC_Class |
| 9 | +USE FEDomain_Class |
| 10 | +USE AbstractMesh_Class |
| 11 | +USE FEDOF_Class |
| 12 | +USE ScalarField_Class |
| 13 | +USE Display_Method |
| 14 | +USE ReallocateUtility |
| 15 | + |
| 16 | +IMPLICIT NONE |
| 17 | + |
| 18 | +!---------------------------------------------------------------------------- |
| 19 | +! Parameters |
| 20 | +!---------------------------------------------------------------------------- |
| 21 | +CHARACTER(*), PARAMETER :: tomlFileName = "./test2.toml" |
| 22 | + |
| 23 | +!---------------------------------------------------------------------------- |
| 24 | +! Types and variables |
| 25 | +!---------------------------------------------------------------------------- |
| 26 | +TYPE(DirichletBC_) :: obj |
| 27 | +TYPE(FEDomain_) :: dom |
| 28 | +TYPE(ScalarField_) :: u |
| 29 | +TYPE(FEDOF_) :: fedof, geofedof |
| 30 | +INTEGER(I4B) :: tsize, iNodeOnNode, iNodeOnEdge, iNodeOnFace, nrow, ncol |
| 31 | + |
| 32 | +!---------------------------------------------------------------------------- |
| 33 | +! Allocatables and pointers |
| 34 | +!---------------------------------------------------------------------------- |
| 35 | +CLASS(AbstractMesh_), POINTER :: cellMesh, boundaryMesh |
| 36 | +INTEGER(I4B), ALLOCATABLE :: nodeNum(:) |
| 37 | +REAL(DFP), ALLOCATABLE :: nodalValue(:, :) |
| 38 | + |
| 39 | +!---------------------------------------------------------------------------- |
| 40 | +! Setting the verbosity |
| 41 | +! In Debug mode, there will many messages printed to the screen |
| 42 | +! Following code suppress information-exception. |
| 43 | +!---------------------------------------------------------------------------- |
| 44 | + |
| 45 | +! CALL e%setQuietMode(EXCEPTION_INFORMATION, .TRUE.) |
| 46 | + |
| 47 | +!---------------------------------------------------------------------------- |
| 48 | +! Domain: Initiate FEDomain and print info |
| 49 | +!---------------------------------------------------------------------------- |
| 50 | + |
| 51 | +CALL dom%ImportFromToml(tomlName="domain", filename=tomlFileName) |
| 52 | +! CALL dom%DisplayDomainInfo(msg="DomainInfo: ") |
| 53 | + |
| 54 | +!---------------------------------------------------------------------------- |
| 55 | +! ScalarField and FEDOF: Initiate scalarField and fedof |
| 56 | +!---------------------------------------------------------------------------- |
| 57 | + |
| 58 | +CALL u%ImportFromToml(tomlName="u", fedof=fedof, geofedof=geofedof, dom=dom, & |
| 59 | + filename=tomlFileName) |
| 60 | +! CALL fedof%Display(msg="FEDOF info: ") |
| 61 | + |
| 62 | +!---------------------------------------------------------------------------- |
| 63 | +! DirichletBC: Import from toml |
| 64 | +!---------------------------------------------------------------------------- |
| 65 | + |
| 66 | +CALL obj%ImportFromToml(filename=tomlFileName, dom=dom, tomlName="dbc") |
| 67 | +! CALL obj%Display("DirichletBC Info: ") |
| 68 | + |
| 69 | +!---------------------------------------------------------------------------- |
| 70 | +! DirichletBC: Get the total node numbers |
| 71 | +!---------------------------------------------------------------------------- |
| 72 | +tsize = obj%GetTotalNodeNum(fedof=fedof) |
| 73 | +CALL Display(tsize, "Total Node Num: ") |
| 74 | + |
| 75 | +!---------------------------------------------------------------------------- |
| 76 | +! DirichletBC: Get the node numbers |
| 77 | +!---------------------------------------------------------------------------- |
| 78 | + |
| 79 | +CALL Reallocate(nodeNum, tsize, isExpand=.TRUE., expandFactor=2) |
| 80 | +CALL obj%Get(fedof=fedof, nodeNum=nodeNum, tsize=tsize, & |
| 81 | + iNodeOnNode=iNodeOnNode, iNodeOnEdge=iNodeOnEdge, & |
| 82 | + iNodeOnFace=iNodeOnFace) |
| 83 | +CALL Display(tsize, "tsize = ") |
| 84 | +CALL Display(nodeNum(1:tsize), "nodeNum", full=.TRUE., orient="ROW") |
| 85 | +CALL Display(iNodeOnNode, "iNodeOnNode = ") |
| 86 | +CALL Display(iNodeOnFace, "iNodeOnFace = ") |
| 87 | +CALL Display(iNodeOnEdge, "iNodeOnEdge = ") |
| 88 | + |
| 89 | +!---------------------------------------------------------------------------- |
| 90 | +! DirichletBC: Get the nodal values |
| 91 | +!---------------------------------------------------------------------------- |
| 92 | + |
| 93 | +CALL Reallocate(nodalValue, tsize, 2, isExpand=.TRUE., expandFactor=2) |
| 94 | +CALL Display(SHAPE(nodalValue), "shape(nodalValue) before Get: ") |
| 95 | +nrow = 0; ncol = 0 |
| 96 | +CALL obj%Get(fedof=fedof, geofedof=geofedof, nodeNum=nodeNum, & |
| 97 | + nodalValue=nodalValue, nrow=nrow, ncol=ncol) |
| 98 | + |
| 99 | +CALL Display(nodeNum(1:nrow), "nodeNum(1:nrow): ", & |
| 100 | + full=.TRUE., advance="NO") |
| 101 | +CALL Display(nodalValue(1:nrow, 1:ncol), "nodalValue: ", & |
| 102 | + full=.TRUE.) |
| 103 | +CALL Display([nrow, ncol], "[nrow, ncol]: ") |
| 104 | + |
| 105 | +!---------------------------------------------------------------------------- |
| 106 | +! Cleanup |
| 107 | +!---------------------------------------------------------------------------- |
| 108 | + |
| 109 | +CALL dom%DEALLOCATE() |
| 110 | + |
| 111 | +END PROGRAM main |
0 commit comments