Skip to main content

Creating structured mesh in 2D using EASIFEM

· 4 min read
Vikas Sharma
Assistant Professor, Kyoto University, Japan
Shion Shimizu
Doctoral Student, Kyoto University, Japan

Creating a structured mesh of quadrangles

To create a structured mesh of quadrangles in easifem, we will need following classes:

  • GmshStructuredMesh_Class: This is high-level interface on top of Gmsh library to create structured meshes.
  • Gmsh_Class: Interface to Gmsh library.
  • MSHFile_Class: Reading gmsh files
  • HDF5File_Class: Writing gmsh files to HDF5 file.

Very small mesh of quadrangles

PROGRAM main
USE GmshStructuredMesh_Class
USE Gmsh_Class
USE FPL
USE GlobalData
USE MSHFIle_Class
USE HDF5File_Class

IMPLICIT NONE

TYPE(GmshStructuredMesh_) :: obj
TYPE(Gmsh_) :: gmsh
TYPE(ParameterList_) :: param
! CHARACTER(*), PARAMETER :: title = "small_quad4_mesh"
CHARACTER(*), PARAMETER :: title = "very_small_quad4_mesh"
REAL(DFP), PARAMETER :: pointsOnAxis1(2) = [0.0, 1.0]
REAL(DFP), PARAMETER :: pointsOnAxis2(2) = [0.0, 1.0]

INTEGER(I4B), PARAMETER :: transfinitePointsOnAxis1(1) = [3]
INTEGER(I4B), PARAMETER :: transfinitePointsOnAxis2(1) = [3]

INTEGER(I4B) :: ierr

TYPE(MSHFile_) :: mshFile
TYPE(HDF5File_) :: hdf5file

CALL FPL_Init()
CALL param%Initiate()

CALL SetGmshStructuredMeshParam(param=param, &
filename=title//".msh", &
pointsOnAxis1=pointsOnAxis1, &
pointsOnAxis2=pointsOnAxis2, &
transfinitePointsOnAxis1=transfinitePointsOnAxis1, &
transfinitePointsOnAxis2=transfinitePointsOnAxis2, &
recombineAll=.TRUE.)

CALL obj%Initiate(param)

ierr = gmsh%initialize()
ierr = gmsh%model%add("GmshStructuredMesh2D")
CALL obj%Generate(gmsh)
! ierr = gmsh%fltk%run()
ierr = gmsh%finalize()

CALL param%DEALLOCATE()
CALL obj%DEALLOCATE()

CALL mshFile%Initiate(filename=title//'.msh', STATUS="OLD", ACTION="READ")
CALL mshFile%OPEN()
CALL mshFile%READ()
CALL hdf5file%Initiate(title//'.h5', MODE="NEW")
CALL hdf5file%OPEN()
CALL mshFile%Export(hdf5=hdf5file, group="")
CALL mshFile%DEALLOCATE()
CALL hdf5file%DEALLOCATE()

END PROGRAM main

Setting up a new kernel using EASIFEM

· 11 min read
Vikas Sharma
Assistant Professor, Kyoto University, Japan
Shion Shimizu
Doctoral Student, Kyoto University, Japan

This post explains the meaning of kernel in EASIFEM platform. It also describe the steps to create a new kernel in EASIFEM.

What is a kernel?

A kernel is a computer program written in object oriented programming paradigm which attempts to solve a partial differential equation. In easifem, the term kernel is used for solving a particular PDE.

Why particular PDE?

In our experience when we focus on solving a particular PDE, we can design the kernel quickly and more efficiently. This is because the kernel has specific tasks to perform with limited number of kernel parameters. We believe that this is a good balance between flexibility, efficiency and speed of development. In the past, we have tried to create a generic PDE solver type kernel but after few years the kernel became too complex and difficult to maintain by a group of developers. Therefore, we want to define a kernel for a specific PDE.

Is kernel flexible?

Yes, the kernel has sufficient amount of flexibility. For example, the coefficient of PDE can be constant, spatially changing or time dependent. The boundary condition can also be constant, space, time, or space-time dependent.

Kernel is blend of procedural programming and object oriented programming?

A kernel is a blend of procedural programming and object oriented programming. The procedural programming comes into the picture because a kernel is trying to solve a specific PDE by using a specific method. In this sense, the kernel's design is driven keeping procedure programming in mind. However, a kernel can solve several problems governed by the same PDE. These problems can have different types of boundary conditions and material properties. Also, we can use several numerical methods to solve the problem. In order to facilitate these objectives, we use object oriented programming.