Initiate
Initiate an instance of Mesh.
Structure
INTERFACE
MODULE SUBROUTINE obj_Initiate(obj, hdf5, group)
CLASS(Mesh_), INTENT(INOUT) :: obj
!! mesh object
TYPE(HDF5File_), INTENT(INOUT) :: hdf5
!! Mesh file in hdf5 file format
CHARACTER(*), INTENT(IN) :: group
!! location in HDF5 file
END SUBROUTINE obj_Initiate
END INTERFACE
Examples
Converting mesh from gmsh to easifem format
Click here to see example
This example shows how to convert the mesh generated from Gmsh, MSHFile_
format into the HDF5File_
format.
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE( MSHFile_ ) :: mshFile
TYPE( HDF5File_ ) :: hdf5file
Initiate an instance of MSHFile_
which is created by Gmsh
CALL mshFile%Initiate( filename="./mesh.msh", STATUS="OLD", ACTION="READ" )
Open the mesh file.
CALL mshFile%Open()
Read the mesh information from the file.
CALL mshFile%Read()
Initiate an instance of HDF5File_
. We will save mesh data in this file.
CALL hdf5file%Initiate( "./mesh.h5", MODE="NEW" )
Open the HDF5File_
file so that we can write mesh data in this file.
CALL hdf5file%Open()
exporting mesh from MSHFile
file to HDF5File
.
CALL mshFile%Export( hdf5=hdf5file, group="" )
Cleaning up
CALL mshFile%Deallocate()
CALL hdf5file%Deallocate()
END PROGRAM main
Reading surface mesh in 2D
Examples
This example shows how to initiate an instance of Mesh_
by reading data from mesh file, which is in HDF5File_
format.
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE( Mesh_ ) :: obj
TYPE( HDF5File_ ) :: meshfile
CHARACTER( LEN = *), PARAMETER :: filename="./mesh.h5"
Initiate and open the mesh file which is in HDF5File_
format.
CALL meshfile%Initiate( FileName=filename, MODE="READ" )
Open the mesh file
CALL meshfile%Open()
Initiate an instance of Mesh_
CALL obj%Initiate(hdf5=meshfile, group="/surfaceEntities_1" )
Display the content of mesh.
CALL obj%Display("")
cleaning up.
CALL obj%Deallocate()
CALL meshfile%Deallocate()
END PROGRAM main
Reading curve mesh in 2D
Examples
This example shows how to initiate an instance of Mesh by reading data from mesh file.
This example is same as the previous example, but in this example we construct curveEntities_1
.
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE( Mesh_ ) :: obj
TYPE( HDF5File_ ) :: meshfile
CALL meshfile%Initiate( FileName="./mesh.h5", MODE="READ" )
CALL meshfile%Open()
CALL obj%Initiate(hdf5=meshfile, group="/curveEntities_1" )
CALL obj%Display("")
CALL obj%Deallocate()
CALL meshfile%Deallocate()
END PROGRAM main
Reading more than one mesh
Examples
This example shows how to create multiple meshes and store them into an array of .
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE( MeshPointer_ ) :: meshes(2)
TYPE( HDF5FilePointer_ ) :: meshfiles(2)
! Open multiple mesh files which art in [[HDF5File_]] format.
ALLOCATE( HDF5File_::meshfiles(1)%ptr )
CALL meshfiles(1)%ptr%Initiate( FileName="./mesh_tri6.h5", MODE="READ" )
ALLOCATE( HDF5File_::meshfiles(2)%ptr )
CALL meshfiles(2)%ptr%Initiate( FileName="./mesh_tri3.h5", MODE="READ" )
CALL meshfiles(1)%ptr%Open()
CALL meshfiles(2)%ptr%Open()
! Create multiple meshes and store them inside the [[MeshPointer_]]
ALLOCATE( Mesh_::meshes(1)%ptr)
CALL meshes(1)%ptr%Initiate(hdf5=meshfiles(1)%ptr, &
& group="/surfaceEntities_1" )
ALLOCATE( Mesh_::meshes(2)%ptr)
CALL meshes(2)%ptr%Initiate(hdf5=meshfiles(2)%ptr, &
& group="/surfaceEntities_1" )
! Display the meshes on terminal.
CALL meshes(1)%ptr%Display("")
CALL meshes(2)%ptr%Display("")
CALL meshes(1)%ptr%Deallocate()
CALL meshes(2)%ptr%Deallocate()
CALL meshfiles(1)%ptr%Close()
CALL meshfiles(1)%ptr%Deallocate()
CALL meshfiles(2)%ptr%Close()
CALL meshfiles(2)%ptr%Deallocate()
END PROGRAM main