File: t17.f90

package info (click to toggle)
gmsh 4.13.1%2Bds1-6
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 96,160 kB
  • sloc: cpp: 434,242; ansic: 114,885; f90: 15,323; python: 13,442; yacc: 7,299; java: 3,491; lisp: 3,191; lex: 630; perl: 571; makefile: 497; sh: 439; xml: 414; javascript: 113; pascal: 35; modula3: 32
file content (57 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
! ------------------------------------------------------------------------------
!
!  Gmsh Fortran tutorial 17
!
!  Anisotropic background mesh
!
! ------------------------------------------------------------------------------

! As seen in `t7.f90', mesh sizes can be specified very accurately by providing a
! background mesh, i.e., a post-processing view that contains the target mesh
! sizes.

! Here, the background mesh is represented as a metric tensor field defined on a
! square. One should use bamg as 2d mesh generator to enable anisotropic meshes
! in 2D.
program t17

use, intrinsic :: iso_c_binding
use gmsh

implicit none

type(gmsh_t) :: gmsh
integer(c_int) :: bg_field, ret
character(len=GMSH_API_MAX_STR_LEN) :: cmd

call gmsh%initialize()

call gmsh%model%add("t17")

! Create a square
ret = gmsh%model%occ%addRectangle(-2d0, -2d0, 0d0, 4d0, 4d0)
call gmsh%model%occ%synchronize()

! Merge a post-processing view containing the target anisotropic mesh sizes
call gmsh%merge('../t17_bgmesh.pos')

! Apply the view as the current background mesh
bg_field = gmsh%model%mesh%field%add("PostView")
call gmsh%model%mesh%field%setNumber(bg_field, "ViewIndex", 0d0)
call gmsh%model%mesh%field%setAsBackgroundMesh(bg_field)

! Use bamg
call gmsh%option%setNumber("Mesh.SmoothRatio", 3d0)
call gmsh%option%setNumber("Mesh.AnisoMax", 1000d0)
call gmsh%option%setNumber("Mesh.Algorithm", 7d0)

call gmsh%model%mesh%generate(2)
call gmsh%write("t17.msh")

! Launch the GUI to see the results:
call get_command(cmd)
if (index(cmd, "-nopopup") == 0) call gmsh%fltk%run()

call gmsh%finalize()

end program t17