WANtaroHP (Expression of FEM result by GMT)

toJA

Outline of this page

In this page, methods to express the FEM results using GMT are introduced.

Drawings in eps format by GMT are converted to drawings in png format using 'ImageMagick.'

Contents
Mesh and 3D monochrome contour
Mesh and 2D color contour
Mesh and 2D color contour
2D plot

Drawing FEM mesh and contour map by GMT

Drawing 2D plot with legend by GMT



Expression of the result of heat conduction analysis

Outline

This is a Fortran program to show FEM mesh and 3D plot of temperature distribution by using GMT.

Fortran program (f90_GMTheat.f90)

Some explanations are shown below.

Following files must be prepared before execution of the program.

FilenameDescriptionRemarks
_col_mesh.txtInput file for defining mesh color.Filename is fixed
_inp_base.txtInput file for drawing informationFilename is fixed
out_CPT_ondom.csvOutput file by FEM analysisFilename is changeable

Output file by FEM analysis is a output by the program 'f90_FEM_HEAT.exe' made by webmaster.

Batch file which carries out the process is shown below. Some files which are read from Fortran program are made in this batch file.

001  gfortran -o f90_GMTheat.exe f90_GMTheat.f90
002
003  rem definition of mesh color (1:MATEL)
004  echo 255,192,203 > _col_mesh.txt
005  echo 255,250,205 >> _col_mesh.txt
006
007  rem definition of basic data
008  rem integer::ind,ibc
009  rem real(4)::baselength,baseheight
010  rem real(4)::bavx,bfvx
011  rem real(4)::bavz,bfvz
012  rem character::strx*100,stry*100
013  echo 0 0 > _inp_base.txt
014  echo 10.0 5.0 >> _inp_base.txt
015  echo 10.0 5.0 >> _inp_base.txt
016  echo 5.0 1.0 >> _inp_base.txt
017  echo "x-distance (m)" >> _inp_base.txt
018  echo "y-distance (m)" >> _inp_base.txt
019
020  f90_GMTheat out_CPT_ondom.csv
021
022
023  del _*
001
To compile the program of 'f90_GMTheat.f90'
004-005
To make the file '_col_mesh.txt.' Mesh colors are defined by this file, 3 figures means 'R G B' in this file. In this example, new file is made using command 'echo' in this batch file, and since 2 materials are used (parameter MATEL=2), 2 kinds of color is defined.
013-018
To make the file '_inp_base.txt.' This file defines the parameters for GMT.
indDraw node number and element number in FEM mesh. (0: no, 1: yes)
ibcDraw boundary conditions in FEM mesh. (0: no, 1: yes)
baselengthSize of x and y-axis in unit of 'cm'
baseheightSize of z-axis in unit of 'cm'
bavxValue of 'a' in '-B' option for x and y-axis on GMT
bfvxValue of 'f' in '-B' option for x and y-axis on GMT
bavzValue of 'a' in '-B' option for z-axis on GMT
bfvzValue of 'f' in '-B' option for z-axis on GMT
strxLabel for x-axis. Double prime (") is required because of character
stryLabel for y-axis. Double prime (") is required because of character
Note) label for z-axis is fixed character 'Temperature.'
020
To execute the program 'f90_GMTheat.exe.' Functions of this 'exe' file are to make the batch file 'bat_gmt_xyz.bat' and to execute it by calling built-in subroutine 'system(***).'
Input file 'out_CPT_ondom.csv' which storages the result of FEM analysis is read from command line of command prompt on Windows.
Output drawings are shown below.
FilenameDescriptionRemarks
fig_gmt_mesh.epsFEM mesh drawing in eps formatOutput filename is fixed.
fig_gmt_xyz_xx.eps3D temperature distribution drawing in eps formatOutput filename is fixed. 'xx' means time history.
Symbols for boundary conditions in FEM mesh drawing
SymbolDescription
Boundary of given temperature
Boundary of heat transfer side
023
To delete work files

Programs and drawings

Source code by f90 and batch file for execution

FilenameDescription
f90 program sorce code
batch file for execution of GMT

sample drawing of the temperature around the tunnel

below samples shows the temperature variation around tunnel in rock area. Average temperature of year is 10°C, amplitude of temperature change in year is ±10°C.

Filenamedescription
Batch file for execution
Output drawing (initial state)
Output drawing (639 days later)
Output drawings (pdf file)


Expression of result of seepage flow analysis

Outline

This program can show the FEM mesh, pressure head contour map, total head contour map and flow velocity vector map by using GMT.

Fortran program (f90_GMTseep.f90)

Some explanations are shown below.

Following files must be prepared before execution of the program.

FilenameDescriptionRemarks
_col_mesh.txtInput file for defining mesh colorFilename is fixed
_inp_base.txtInput file for drawing informationFilename is fixed
0_cpt.cptInput cpt file for reading by GMTFilename is fixed
out_fem_zone4m.csvOutput file by FEM analysisFilename is changeable

Output file by FEM analysis is a output by the program 'f90_FEM_SEEP.exe' made by webmaster.

Batch file which carries out the process is shown below. Some files which are read from Fortran program are made in this batch file.

001  gfortran -o f90_GMTseep.exe f90_GMTseep.f90
002
003  copy 0_cpt_dam.cpt 0_cpt.cpt
004
005  rem define of mesh color (1:MATEL)
006  echo 255 255 204 > _col_mesh.txt
007  echo   0 255 255 >> _col_mesh.txt
008  echo 255   0 255 >> _col_mesh.txt
009  echo   0 255 255 >> _col_mesh.txt
010  echo 255 255 204 >> _col_mesh.txt
011
012  rem integer::ind,ibc,iph,ivc,isc
013  rem real(4)::baselength,grdspc
014  rem real(4)::bav,bfv
015  rem real(4)::conint,annint
016  rem character::strx*100,strz*100
017  echo 0 1 1 1 1 > _inp_base.txt
018  echo 12.0 0.1 >> _inp_base.txt
019  echo 10.0 5.0 >> _inp_base.txt
020  echo  1.0 5.0 >> _inp_base.txt
021  echo "Distance (m)" >> _inp_base.txt
022  echo "Altitude (m)" >> _inp_base.txt
023
024  f90_GMTseep out_fem_zone4m.csv
025  copy fig_gmt_mesh.eps fig_gmt_mesh_dam.eps
026  copy fig_gmt_conp.eps fig_gmt_conp_dam.eps
027  copy fig_gmt_vect.eps fig_gmt_vect_dam.eps
028
029  del fig_gmt_mesh.eps
030  del fig_gmt_conp.eps
031  del fig_gmt_conh.eps
032  del fig_gmt_vect.eps
033  del _*
001
To compile the program 'f90_GMTseep.f90'
003
To copy '0_cpt_dam.cpt' which has been prepared beforehand to '0_cpt.cpt.'
006-010
To make the file '_col_mesh.txt.' Mesh colors are defined by this file, 3 figures means 'R G B' in this file. In this example, new file is made using command 'echo' in this batch file, and since 5 materials are used (parameter MATEL=5), 5 kinds of color is defined.
017-022
To make the file '_inp_base.txt.' This file defines the parameter for GMT.
indDraw node number and element number in FEM mesh. (0: no, 1: yes)
ibcDraw boundary conditions in FEM mesh. (0: no, 1: yes)
iphSuperimpose total head line on pressure head contour, or reverse. (0: no, 1: yes)
ivcSpecify the kind of contour map superimposed on velocity vector map (1: pressure head contour, 2: total head contour)
iscDraw scale map for contour (0: no, 1: yes)
baselengthSize of drawing in unit of 'cm'
grdspcMesh interval for 'grd' file
bavValue of 'a' in '-B' option for x and y-axis on GMT
bfvValue of 'f' in '-B' option for x and y-axis on GMT
conintValue of interval of contour in '-C' option of 'grdcontour' command
annintvalue of interval of tickmark in '-A' option of 'grdcontour' command
strxLabel for x(horizontal)-axis. Double prime (") is required because of character
strzLabel for z(vertical)-axis. Double prime (") is required because of character
024
To execute the program 'f90_GMTseep.exe.' Functions of this exe file are to make the batch file 'bat_gmt_seep.bat' and to execute it by calling built-in subroutine 'system(***).'
Input file 'out_fem_zone4m.csv' which storages the result of FEM analysis is read from command line of command prompt on Windows.
Output drawings are shown below.
FilenameDescriptionRemarks
fig_gmt_mesh.epsFEM mesh drawing in eps formatOutput filename is fixed
fig_gmt_conp.epsPressure head contour map in eps formatOutput filename is fixed
fig_gmt_conh.epsTotal head contour map in eps formatOutput filename is fixed
fig_gmt_vect.epsVelocity vector map in eps format. Output filename is fixed
Symbols for boundary conditions in FEM mesh drawing
SymbolDescription
Boundary of given total head
Boundary of given discharge
Boundary of seepage surface
025-027
Since output filename is fixed, it is necessary to change the output filename into another name by a copy command etc after output.
029-033
To delete work files

Programs and drawings

Source code by f90

FilenameDescription
f90 source code
Batch file for GMT execution

Zoned embankment dam

FilenameDescription
cpt file for GMT (to define the colors of contour map)
Batch file for GMT execution
Output image of FEM mesh
Output image of pressure head contour map
Output image of velocity vector map

Homogeneous embankment dam

FilenameDescription
Batch file for GMT execution
Output image of FEM mesh
Output image of pressure head contour map
Output image of velocity vector map

Pressure head distribution around tunnel

FilenameDescription
cpt file for GMT (to define the colors of contour map)
Batch file for GMT execution
Output image of FEM mesh
Output image of pressure head contour
Output image of total head contour
Output image of velocity vector map


Expression of the result of 2D stress analysis

Outline

This program can show the FEM mesh and principal stress contour maps by using GMT.

Fortran program (f90_GMTplnt.f90)

Following files must be prepared before execution of the program.

FilenameDescriptionRemarks
_col_mesh.txtInput file for defining mesh colorFilename is fixed
_inp_base.txtInput file for drawing informationFilename is fixed
0_cpt.cptInput cpt file for reading by GMTFilename is fixed
out4nodPS0_L.csvOutput file by FEM analysisFilename is changeable

Output file by FEM analysis is a output by the program 'f90_FEM_PLNT.exe' made by webmaster.

Batch file which carries out the process is shown below. Some files which are read from Fortran program are made in this batch file.

001  gfortran -o f90_GMTplnt.exe f90_GMTplnt.f90
002
003  makecpt -Cno_green -T-1/1/0.1 -I > 1_cpt.cpt
004  gawk "{a[NR]=$0}END{for(i=1;i<=NR-1;i++){print a[i]};gsub(/(128)/,\"255\",a[NR]);print a[NR]}" 1_cpt.cpt > 0_cpt.cpt
005
006  rem define of drawing data
007  rem integer::ind,ibc,ifc,isc
008  rem real(4)::baselength,grdspc
009  rem real(4)::bav,bfv
010  rem real(4)::conint,annint
011  rem character::strx*100,stry*100
012  rem integer::ncut,numcut(10)
013  echo 0 1 0 1 > _inp_base.txt
014  echo 12.0 50 >> _inp_base.txt
015  echo 5000.0 5000.0 >> _inp_base.txt
016  echo  0.5 0.5 >> _inp_base.txt
017  echo "x-distance (mm)" >> _inp_base.txt
018  echo "y-distance (mm)" >> _inp_base.txt
019  echo  1 1 >> _inp_base.txt
020
021  rem define of mesh colour (1:MATEL)
022  echo 0,0,0 > _col_mesh.txt
023  echo 255,192,203 >> _col_mesh.txt
024  echo 255,250,205 >> _col_mesh.txt
025
026  f90_GMTplnt out4nodPS0_L.csv
027  copy fig_gmt_mesh.eps fig_gmt_mesh_ps.eps
028  copy fig_gmt_ps1.eps fig_gmt_ps1_ps.eps
029  copy fig_gmt_ps2.eps fig_gmt_ps2_ps.eps
030
031  del fig_gmt_mesh.eps
032  del fig_gmt_ps1.eps
033  del fig_gmt_ps2.eps
034  del _*
001
To compile the program 'f90_GMTplnt.f90'
003
To make file '1_cpt.cpt' by GMT command 'makecpt.' In this case, 'no_green' is used as the base file, and set range of -1 to 1, set sign as reverse of default.
004
To make file '0_cpt.cpt' using 'gawk.' In this treatment, the color 'gray' in last row of file '1_cpt.cpt' is changed to the color 'white.'
013-019
To make the file '_inp_base.txt.' This file defines the parameter for GMT.
indDraw node number and element number in FEM mesh. (0: no, 1: yes)
ibcDraw boundary conditions in FEM mesh. (0: no, 1: yes)
ifcdraw load conditions in FEM mesh. (0: no, 1: yes)
iscDraw scale map for contour. (0: no, 1: yes)
baselengthSize of drawing in unit of 'cm'
grdspcMesh interval for 'grd' file
bavValue of 'a' in '-B' option for x and y-axis on GMT
bfvValue of 'f' in '-B' option for x and y-axis on GMT
conintValue of inteval of contour in '-C' option of 'grdcontour' command
annintvalue of interval of tickmark in '-A' option of 'grdcontour' command
strxLabel for x(horizontal)-axis. Double prime (") is required because of character
stryLabel for y(vertical)-axis. Double prime (") is required because of character
ncutNumber of materials which are not use in contour creation. In this case, it is 'one' for steel penstock.
numcut(i)Material number which is no use in contour creation. In this case, it is 'one' for material number of steel penstock. It is necessary to define 'ncut' and 'numcut' in 1 row.
022-024
To make the file '_col_mesh.txt.' Mesh colors are defined by this file, 3 figures means 'R G B' in this file. In this example, new file is made using command 'echo' in this batch file, and since 3 materials are used (parameter MATEL=3), 3 kinds of color is defined.
026
To execute the program 'f90_GMTplnt.exe.' Functions of this exe file are to make the batch file 'bat_gmt_plnt.bat' and to execute it by calling built-in subroutine 'system(***).'
Input file 'out_4nodPS0_L.csv' which storages the result of FEM analysis is read from command line of command prompt on Windows.
Output drawings are shown below.
FilenameDescriptionRemarks
fig_gmt_mesh.epsFEM mesh in eps formatfilename is fixed
fig_gmt_ps1.eps1st principal stress contour in eps formatfilename is fixed
fig_gmt_ps2.eps2nd principal stress contour in eps formatfilename is fixed
Symbols for boundary conditions in FEM mesh drawing
SymbolDescription
Boundary of given displacement in x-direction
Boundary of given displacement in y-direction
Boundary of given displacement in both of x and y-directions
027-029
Since output filename is fixed, it is necessary to change the output filename into another name by a copy command etc after output.
031-034
To delete work files.

Programs and drawings

Source code by f90

FilenameDescription
f90 source code
Batch file for GMT execution

Example of principal stress distribution of plate with holes under uniform tension

An example of principal stress distribution of plate with holes under uniform tension is shown in this section.

FilenameDescription
Batch file for GMT execution
Output image of FEM mesh (png)
Output image of 1st principal stress contour (png)
Output image of 2nd principal stress contour (png)

Example of principal stress distribution around embedded steel penstock

FilenameDescription
Batch file for GMT execution
Output ipage of FEM mesh (png)
Output image of 1st principal stress contour (png)
Output image of 2nd principal stress contour (png)


Drawing 2D plot with legend

Outline

Batch file for execution of f90 program is shown below.

gfortran -o f90_GMTgra.exe f90_GMTgra.f90
f90_GMTgra inp_form.txt bat_test.bat

f90 program code for reading control data is shown below.

call getarg(1,fnameR) !input filename for control
call getarg(2,fnameW) !output filename (batch filename for GMT execution)

open(11,file=fnameR,status='old')
read(11,'(a)') fnameF  !output image filename (eps)
read(11,'(a)') xlabel  !label of x-axis
read(11,'(a)') ylabel  !label of y-axis
read(11,'(a)') range   !range of x-axis/range of y-axis
read(11,'(a)') scale   !length of x-axis/length of y-axis
read(11,'(a)') xga     !grid interval and tickmark for x-axis
read(11,'(a)') yga     !grid interval and tickmark for y-axis
read(11,*) nplot,dplot !number of plot data, size of symbol
allocate(fn(1:nplot),sxp(1:nplot),syp(1:nplot),sleg(1:nplot))
allocate(nline(1:nplot),nsymb(1:nplot))
do i=1,nplot
    !data filename, column for x, column for y, line type, symbol, title
    read(11,*) fn(i),sxp(i),syp(i),nline(i),nsymb(i),sleg(i)
end do
read(11,*) strP,dx,dy   !location of legend, distance from x-axis, distance from y-axis
read(11,*) ipt,scl,llen !font size, font w/h, line length (number of characters)
close(11)
Line type (nline) Symbol (nsymb)
0none 0none
1solid line 10circle 11black circle
2dash line 20square 21black square
3long and short dash line30triangle 31black triangle
4broken line 40diamond 41black diamond
Location of legend in the graph (strP)
"bl" bottom left (in graph area)
"br" bottom right (in graph area)
"tr" top right (in graph area)
"tl" top left (in graph area)
"ot" top right (out of graph area)
"or" bottom right (out of graph area)
dx, dy
: distance from x-axis and y-axis to out line of legend area
ipt
: Font size (pt)
scl
: ratio of width and height of 1 font (width/height)
llen
: length of line in number of characters

Programs and drawings

Source code by f90

FilenameDescription
program source code by f90

Samples

FilenameDescription
Input data
Input data
Input data for control
Batch file for GMT
Batch file for drawing legend
Output image (png)

toJA
inserted by FC2 system