FE-Project
Loading...
Searching...
No Matches
scale_mesh_bndinfo.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Mesh / Boundary information
3!!
4!! @par Description
5!! A module to manage boundary information of computational domain
6!!
7!! @author Yuta Kawai, Team SCALE
8!<
9!-------------------------------------------------------------------------------
10#include "scaleFElib.h"
12 !-----------------------------------------------------------------------------
13 !
14 !++ Used modules
15 !
16 use scale_precision
17 use scale_io
18 use scale_prc
19
20 !-----------------------------------------------------------------------------
21 implicit none
22 private
23 !-----------------------------------------------------------------------------
24 !
25 !++ Public type & procedures
26 !
27
28 !> Derived type to manage boundary information of computational domain
29 type, public :: meshbndinfo
30 integer, allocatable :: list(:)
31 real(rp), allocatable :: val(:)
32 character(len=H_SHORT) :: tag
33 contains
34 procedure :: init => meshbndinfo_init
35 procedure :: final => meshbndinfo_final
36 procedure, private :: set_by_id => meshbndinfo_set_by_id
37 procedure, private :: set_by_name => meshbndinfo_set_by_name
38 generic :: set => set_by_id, set_by_name
39 end type meshbndinfo
40
41 public :: bndtype_nametoid
42
43 !-----------------------------------------------------------------------------
44 !
45 !++ Public parameters & variables
46 !
47 character(len=*), public , parameter :: bnd_type_nospec_name = 'NONSPEC'
48 integer, public, parameter :: bnd_type_nospec_id = 0
49 character(len=*), public, parameter :: bnd_type_periodic_name = 'PERIODIC'
50 integer, public, parameter :: bnd_type_periodic_id = 1
51 character(len=*), public, parameter :: bnd_type_slip_name = 'SLIP'
52 integer, public, parameter :: bnd_type_slip_id = 2
53 character(len=*), public, parameter :: bnd_type_noslip_name = 'NOSLIP'
54 integer, public, parameter:: bnd_type_noslip_id = 3
55 character(len=*), public , parameter :: bnd_type_adiabat_name = 'ADIABATIC'
56 integer, public, parameter :: bnd_type_adiabat_id = 4
57 character(len=*), public , parameter :: bnd_type_fixval_name = 'FIXVAL'
58 integer, public, parameter :: bnd_type_fixval_id = 5
59
60 !-----------------------------------------------------------------------------
61 !
62 !++ Private procedures
63 !
64 !-------------------
65
66contains
67 !> Initialize an object to manage boundary information
68!OCL SERIAL
69 subroutine meshbndinfo_init(this, list_size, tag)
70 use scale_const, only: &
71 undef8 => const_undef8
72 implicit none
73 class(meshbndinfo), intent(inout) :: this
74 integer, intent(in) :: list_size
75 character(*), optional, intent(in) :: tag
76
77 integer :: i
78 !------------------------------------------------------
79
80 allocate( this%list(list_size) )
81 allocate( this%val(list_size) )
82 !$acc enter data create( this%list, this%val )
83
84 !$omp parallel do
85 do i = 1, list_size
86 this%list(i) = bnd_type_nospec_id
87 this%val(i) = undef8
88 end do
89
90 if (present(tag)) then
91 this%tag = tag
92 else
93 this%tag = ''
94 end if
95
96 return
97 end subroutine meshbndinfo_init
98
99 !> Finalize an object to manage boundary information
100!OCL SERIAL
101 subroutine meshbndinfo_final(this)
102 implicit none
103 class(meshbndinfo), intent(inout) :: this
104 !------------------------------------------------------
105
106 if (allocated(this%list)) then
107 !$acc exit data delete(this%list)
108 deallocate(this%list)
109 end if
110 if (allocated(this%val)) then
111 !$acc exit data delete(this%val)
112 deallocate(this%val)
113 end if
114 return
115 end subroutine meshbndinfo_final
116
117!OCL SERIAL
118 subroutine meshbndinfo_set_by_id(this, is, ie, bnd_type_id, val)
119 implicit none
120 class(meshbndinfo), intent(inout) :: this
121 integer, intent(in) :: is
122 integer, intent(in) :: ie
123 integer, intent(in) :: bnd_type_id
124 real(rp), intent(in), optional :: val
125 !------------------------------------------------------
126
127 this%list(is:ie) = bnd_type_id
128 !$acc update device( this%list(is:ie) )
129 if ( present(val) ) then
130 this%val(is:ie) = val
131 !$acc update device( this%val(is:ie) )
132 end if
133
134 return
135 end subroutine meshbndinfo_set_by_id
136
137!OCL SERIAL
138 subroutine meshbndinfo_set_by_name(this, is, ie, bnd_type_name, val)
139 implicit none
140 class(meshbndinfo), intent(inout) :: this
141 integer, intent(in) :: is
142 integer, intent(in) :: ie
143 character(*), intent(in) :: bnd_type_name
144 real(rp), intent(in), optional :: val
145
146 integer :: bnd_type_id
147 !------------------------------------------------------
148 bnd_type_id = bndtype_nametoid(bnd_type_name)
149 call meshbndinfo_set_by_id(this, is, ie, bnd_type_id, val)
150
151 return
152 end subroutine meshbndinfo_set_by_name
153
154!OCL SERIAL
155 function bndtype_nametoid(bnd_type_name) result(bnd_type_id)
156 implicit none
157 character(*), intent(in) :: bnd_type_name
158
159 integer :: bnd_type_id
160 !------------------------------------------------------
161
162 select case(trim(bnd_type_name))
164 bnd_type_id = bnd_type_nospec_id
166 bnd_type_id = bnd_type_periodic_id
167 case (bnd_type_slip_name)
168 bnd_type_id = bnd_type_slip_id
170 bnd_type_id = bnd_type_noslip_id
172 bnd_type_id = bnd_type_adiabat_id
174 bnd_type_id = bnd_type_fixval_id
175 case default
176 log_error('BndType_NameToID ',*) trim(bnd_type_name) // ' is not supported. Check!'
177 call prc_abort
178 end select
179
180 return
181 end function bndtype_nametoid
182
183end module scale_mesh_bndinfo
module FElib / Mesh / Boundary information
integer, parameter, public bnd_type_slip_id
character(len= *), parameter, public bnd_type_fixval_name
character(len= *), parameter, public bnd_type_slip_name
character(len= *), parameter, public bnd_type_adiabat_name
character(len= *), parameter, public bnd_type_nospec_name
integer, parameter, public bnd_type_fixval_id
integer function, public bndtype_nametoid(bnd_type_name)
integer, parameter, public bnd_type_periodic_id
character(len= *), parameter, public bnd_type_noslip_name
character(len= *), parameter, public bnd_type_periodic_name
integer, parameter, public bnd_type_nospec_id
integer, parameter, public bnd_type_adiabat_id
integer, parameter, public bnd_type_noslip_id
Derived type to manage boundary information of computational domain.