ImportFromToml
ImportFromToml
Initiate an instance of AbstractBC_
from toml configuration.
Interface 1
INTERFACE AbstractBCImportFromToml
MODULE SUBROUTINE bc_ImportFromToml1(obj, table, dom)
CLASS(AbstractBC_), INTENT(INOUT) :: obj
TYPE(toml_table), INTENT(INOUT) :: table
CLASS(Domain_), TARGET, INTENT(IN) :: dom
END SUBROUTINE bc_ImportFromToml1
END INTERFACE AbstractBCImportFromToml
info
This method is mainly for internal use.
Interface 2
INTERFACE AbstractBCImportFromToml
MODULE SUBROUTINE bc_ImportFromToml2(obj, dom, tomlName, afile, &
& filename, printToml)
CLASS(AbstractBC_), INTENT(INOUT) :: obj
CLASS(Domain_), TARGET, INTENT(IN) :: dom
CHARACTER(*), INTENT(IN) :: tomlName
TYPE(TxtFile_), OPTIONAL, INTENT(INOUT) :: afile
CHARACTER(*), OPTIONAL, INTENT(IN) :: filename
LOGICAL(LGT), OPTIONAL, INTENT(IN) :: printToml
END SUBROUTINE bc_ImportFromToml2
END INTERFACE AbstractBCImportFromToml
TOML configuration
Click here to see the toml-configuration file
[bc]
name = "DirichletBC"
# Name of the boundary condition
idof = 1
# idof denotes the degree of freedom where
# we apply the contraint,
# For x component idof is 1
# For y component idof is 2
# For z component idof is 3
nodalValueType = "Constant" # Time, SpaceTime, Space
# Other option: Constant, Time, Space, SpaceTime
# nodalValuetype denotes the type of boundary condition
# It can take following values
# Constant: It means the boundary condition is constant in
# space and time.
# Space: It means the boundary condition is variable in
# space but constant in time.
# Time: It means the boundary condition is variable in
# in time but constant in Space
# SpaceTime:It means the boundary condition is variable in
# both space and time.
value = 20.0
# Value of boundary condition
# The shape of value depends upon the nodalValueType as explained below.
# For nodalValueType="Constant", value should be a scalar real value
# For nodalValueType="Space", value should be a vector of real values
# value=[1.0, 2.0, 3.0, 4.0]
# For nodalValueType="Time", value should be a vector of real values
# value=[1.0, 2.0, 3.0, 4.0]
# For nodalValueType="SpaceTime", value should be two dimensional array of
# real values
# value=[[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]
isUserFunction = false
isNormal = false
isTangent = false
useExternal = false
[bc.function]
name = "boundaryFunction"
# name of the function
returnType = "Scalar"
# returnType must be "Scalar"
numReturns = 1
# number of returns must be 1
argType = "Space"
# argumen type of function, It can take following values
# "Constant", when the user function is constant
# "Space", when the user function is space dependent only.
# "Time", when the user function is time dependent only.
# "SpaceTime", when the user function is space-time dependent.
numArgs = 3
# number of arguments
# number of arguments should be 0, when argType is "Constant"
# number of arguments should be 1, when argType is "Time"
# number of arguments should be 3, when argType is "Space"
# number of arguments should be 4, when argType is "SpaceTime"
value = 1.0
# if lua script and luaFunctionName are absent then this
# variable must be given.
# When this is given, then argType must be Constant, and
# numArgs should be 0.
luaScript = "./hello.lua"
# name of the lua script which contains the functions
luaFunctionName = "hello"
# which function in the lua script to be used for boundary condition
[bc.boundary]
isSelectionByMeshID = false
# set isSelectionByMeshID to true when mesh selection is by meshID
# if this variable is set to true then we should provide following
# table
[bc.boundary.meshID]
point = [1, 2, 3]
# id of mesh of points
# you can also give the filename
line = [1, 2, 3, 4]
# id of mesh of lines
# you can also give the filename
surface = [1, 2, 3]
# id of mesh of surfaces
# you can also give the filename "filename.txt"
volume = [1, 2, 3]
# id of mesh of volumes
# you can also give the filename "filename.txt"
isSelectionByElemNum = false
# set isSelectionByElemNum to true when mesh selection is by
# specifying element number
# if this variable is set to true then we should provide following
# table
[bc.boundary.elemNum]
point = [1, 2, 3]
# element number for points
line = [1, 2, 3]
# element number of lines
surface = [1, 2, 3]
# element number of surfaces
volume = [1, 2, 3]
# element number of volume
isSelectionByBox = false
# set isSelectionByBox to true when mesh selection is by
# specifying the bounding boxes
# if this variable is set to true then we should provide following
# table
[bc.boundary.box]
point = [
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 0.0, zmax = 1.0 },
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 2.0, zmax = 3.0 },
]
# boxes for mesh of points
line = [
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 0.0, zmax = 1.0 },
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 2.0, zmax = 3.0 },
]
# boxes for mesh of lines
surface = [
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 0.0, zmax = 1.0 },
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 2.0, zmax = 3.0 },
]
# boxes for mesh of surfaces
volume = [
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 0.0, zmax = 1.0 },
{ xmin = 0.0, xmax = 1.0, ymin = 0.0, ymax = 1.0, zmin = 2.0, zmax = 3.0 },
]
# boxes for mesh of volumes
isSelectionByNodeNum = false
# set isSelectionByNodeNum to true when mesh selection is by
# by specifying the node number.
# if this variable is set to true then we should provide following
# table
[bc.boundary.nodeNum]
point = [1, 2, 3]
line = [1, 2, 3]
surface = [1, 2, 3]
volume = [1, 2, 3]
Examples
- example 1
- example 2
- example 3
- ↢ Close
In this example we will initiate an instance of DirichletBC_
by importing data from toml
configuration.
The content of toml config file is given below
Click here to see the toml file
[bc1]
name = "DirichletBC"
idof = 1
nodalValueType = "Constant"
value = 10.0
[bc1.boundary]
isSelectionByMeshID = true
[bc1.boundary.meshID]
surface = [1, 2]
Note that in the boundary condition is constant, and mesh is selected by mesh-id.
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE(DirichletBC_) :: obj
TYPE(Domain_) :: dom
TYPE(HDF5File_) :: domainfile
CHARACTER(*), PARAMETER :: domainfilename = "./mesh3D.h5"
CHARACTER(*), PARAMETER :: tomlFileName = "./DirichletBC.toml"
INTEGER(I4B) :: bottom = 1, top = 2, left = 3, right = 4, front = 5, behind = 6
CALL FPL_Init()
CALL domainfile%Initiate(filename=domainfilename, mode="READ")
CALL domainfile%OPEN()
CALL dom%Initiate(domainfile, group="")
CALL obj%ImportFromToml(filename=tomlFileName, dom=dom, tomlName="bc")
CALL obj%Display("DirichletBC = ")
CALL domainfile%DEALLOCATE()
CALL dom%DEALLOCATE()
CALL FPL_Finalize()
END PROGRAM main
Initiate an instance of DirichletBC_
by importing config from a Toml file.
In the toml file we define details of UserFunction.
Click here to see the toml file
[bc2]
name = "DirichletBC"
idof = 1
nodalValueType = "Constant"
isUserFunction = true
[bc2.function]
name = "func"
returnType = "Scalar"
argType = "Constant"
value = 10.0
# boundary
[bc2.boundary]
isSelectionByMeshID = true
[bc2.boundary.meshID]
surface = [1, 2]
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE(DirichletBC_) :: obj
TYPE(Domain_) :: dom
TYPE(HDF5File_) :: domainfile
CHARACTER(*), PARAMETER :: domainfilename = "./mesh3D.h5"
CHARACTER(*), PARAMETER :: tomlFileName = "./DirichletBC.toml"
INTEGER(I4B) :: bottom = 1, top = 2, left = 3, right = 4, &
& front = 5, behind = 6
INTEGER(I4B), ALLOCATABLE :: nodeNum(:)
REAL(DFP), ALLOCATABLE :: nodalValue(:, :)
CALL FPL_Init()
CALL domainfile%Initiate(filename=domainfilename, mode="READ")
CALL domainfile%OPEN()
CALL dom%Initiate(domainfile, group="")
CALL obj%ImportFromToml(filename=tomlFileName, dom=dom, tomlName="bc2")
CALL obj%Get(nodeNum=nodeNum, nodalValue=nodalValue)
CALL Display(nodeNum, "nodeNum", advance="NO")
CALL Display(nodalValue, "nodalValue", advance="YES")
CALL display(SIZE(nodeNum), "size = ")
CALL domainfile%DEALLOCATE()
CALL dom%DEALLOCATE()
CALL FPL_Finalize()
END PROGRAM main
Initiate an instance of DirichletBC_
by importing config from a Toml file.
In the toml file we define details of UserFunction.
Click here to see the toml file
[bc3]
name = "DirichletBC"
idof = 1
nodalValueType = "Space"
isUserFunction = true
[bc3.function]
name = "func"
returnType = "Scalar"
argType = "Space"
luaScript = "DirichletBC.lua"
luaFunctionName = "Func1"
# boundary
[bc3.boundary]
isSelectionByMeshID = true
[bc3.boundary.meshID]
surface = [1]
PROGRAM main
USE easifemBase
USE easifemClasses
IMPLICIT NONE
TYPE(DirichletBC_) :: obj
TYPE(Domain_) :: dom
TYPE(HDF5File_) :: domainfile
CHARACTER(*), PARAMETER :: domainfilename = "./mesh3D.h5"
CHARACTER(*), PARAMETER :: tomlFileName = "./DirichletBC.toml"
INTEGER(I4B) :: bottom = 1, top = 2, left = 3, right = 4, &
& front = 5, behind = 6
INTEGER(I4B), ALLOCATABLE :: nodeNum(:)
REAL(DFP), ALLOCATABLE :: nodalValue(:, :)
CALL FPL_Init()
CALL domainfile%Initiate(filename=domainfilename, mode="READ")
CALL domainfile%OPEN()
CALL dom%Initiate(domainfile, group="")
CALL obj%ImportFromToml(filename=tomlFileName, dom=dom, tomlName="bc3")
CALL obj%Get(nodeNum=nodeNum, nodalValue=nodalValue)
CALL Display(nodeNum, "nodeNum", advance="NO")
CALL Display(nodalValue, "nodalValue", advance="YES")
CALL display(SIZE(nodeNum), "size = ")
CALL domainfile%DEALLOCATE()
CALL dom%DEALLOCATE()
CALL FPL_Finalize()
END PROGRAM main