FE-Project
Loading...
Searching...
No Matches
scale_mesh_topography.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module FElib / Mesh / Topography
3!!
4!! @par Description
5!! A module to manage vertical coordinate with topography
6!!
7!! @author Yuta Kawai, Team SCALE
8!<
9!-------------------------------------------------------------------------------
10#include "scaleFElib.h"
12
13 !-----------------------------------------------------------------------------
14 !
15 !++ used modules
16 !
17 use scale_precision
18
24 use scale_meshfield_base, only: &
26 use scale_meshfieldcomm_base, only: &
28
29 use scale_sparsemat, only: sparsemat
30
31 !-----------------------------------------------------------------------------
32 implicit none
33 private
34
35 !-----------------------------------------------------------------------------
36 !
37 !++ Public type & procedure
38 !
39 !> Derived type to manage topography datat and setup vertical coordinate metric
40 type, public :: meshtopography
41 type(meshfield2d) :: topo
42 contains
43 procedure :: init => meshtopography_init
44 procedure :: final => meshtopography_final
45 procedure :: setvcoordinate => meshtopography_set_vcoordinate
46 end type meshtopography
47
48 !-----------------------------------------------------------------------------
49 !
50 !++ Public parameters & variables
51 !
52
53 !-----------------------------------------------------------------------------
54 !
55 !++ Private procedure
56 !
57
58 !-----------------------------------------------------------------------------
59 !
60 !++ Private parameters & variables
61 !
62
63contains
64!OCL SERIAL
65 subroutine meshtopography_init( this, varname, mesh )
66 implicit none
67
68 class(meshtopography), intent(inout) :: this
69 character(len=*), intent(in) :: varname
70 class(meshbase2d), intent(in), target :: mesh
71
72 integer :: n
73 !-----------------------------------------------------------------------------
74
75 call this%topo%Init( varname, "m", mesh )
76
77 do n=1, mesh%LOCAL_MESH_NUM
78!$omp parallel workshare
79 this%topo%local(n)%val(:,:) = 0.0_rp
80!$omp end parallel workshare
81 !$acc update device(this%topo%local(n)%val)
82 end do
83
84 return
85 end subroutine meshtopography_init
86
87 !> Finalize an object of MeshTopography
88!OCL SERIAL
89 subroutine meshtopography_final( this )
90 implicit none
91
92 class(meshtopography), intent(inout) :: this
93 !-----------------------------------------------------------------------------
94
95 call this%topo%Final()
96 return
97 end subroutine meshtopography_final
98
99 !> Setup vertical coordinate metric with topography data
100!OCL SERIAL
101 subroutine meshtopography_set_vcoordinate( this, mesh3D, &
102 vcoord_id, zTop, comm3D, comm2D )
104 implicit none
105
106 class(meshtopography), target, intent(inout) :: this !< Object of MeshTopography to manage topography data and vertical coordinate metric
107 class(meshbase3d), intent(inout), target :: mesh3D !< 3D mesh object
108 integer, intent(in) :: vcoord_id !< Vertical coordinate ID
109 real(RP), intent(in) :: zTop !< Height of the model domain
110 class(meshfieldcommbase), intent(inout) :: comm3D !< Object for 3D data communication
111 class(meshfieldcommbase), intent(inout) :: comm2D !< Object for 2D data communication
112
113 type(sparsemat) :: Dx2D, Dy2D, Lift2D
114 class(localmesh3d), pointer :: lcmesh
115 class(localmesh2d), pointer :: lcmesh2D
116 class(elementbase3d), pointer :: elem3D
117
118 integer :: n
119 integer :: ke, ke2D
120
121 type(meshfieldcontainer) :: comm2d_varlist(1)
122 type(meshfieldcontainer) :: comm3d_varlist(4)
123
124 type(meshfield3d), target :: zlev, GsqrtV, G13, G23
125 type(meshfield3d), target :: tmp_G13, tmp_G23
126
127 logical :: flag_covariantvec
128 !-------------------------------------------------------------
129
130 lcmesh => mesh3d%lcmesh_list(1)
131 lcmesh2d => lcmesh%lcmesh2D
132 call dx2d %Init( lcmesh2d%refElem2D%Dx1 )
133 call dy2d %Init( lcmesh2d%refElem2D%Dx2 )
134 call lift2d%Init( lcmesh2d%refElem2D%Lift )
135
136 ! Exchange topography data to fill halo
137
138 comm2d_varlist(1)%field2d => this%topo
139 call comm2d%Put(comm2d_varlist, 1)
140 call comm2d%Exchange()
141 call comm2d%Get(comm2d_varlist, 1)
142
143 ! Calculate metric factors associated with general vertical coordinates
144
145 call zlev%Init( "zlev", "", mesh3d )
146 call gsqrtv%Init( "GsqrtV", "", mesh3d )
147 call g13%Init( "G13", "", mesh3d )
148 call g23%Init( "G23", "", mesh3d )
149
150 call tmp_g13%Init( "tmp_G13", "", mesh3d )
151 call tmp_g23%Init( "tmp_G23", "", mesh3d )
152
153 do n=1, mesh3d%LOCAL_MESH_NUM
154 lcmesh => mesh3d%lcmesh_list(n)
155 lcmesh2d => lcmesh%lcmesh2D
156
157 call calc_vcoordinate_metrics_lc( &
158 g13%local(n)%val, g23%local(n)%val, tmp_g13%local(n)%val, tmp_g23%local(n)%val, & ! (out)
159 zlev%local(n)%val, gsqrtv%local(n)%val, & ! (out)
160 this%topo%local(n)%val, ztop, vcoord_id, & ! (in)
161 lcmesh, lcmesh%refElem3D, lcmesh2d, lcmesh2d%refElem2D, & ! (in)
162 lcmesh%GIJ(:,:,1,1), lcmesh%GIJ(:,:,1,2), lcmesh%GIJ(:,:,2,1), lcmesh%GIJ(:,:,2,2), & ! (in)
163 dx2d, dy2d, lift2d ) ! (in)
164 end do
165
166 ! Exchange metric data to fill halo
167
168 comm3d_varlist(1)%field3d => zlev
169 comm3d_varlist(2)%field3d => gsqrtv
170 comm3d_varlist(3)%field3d => tmp_g13
171 comm3d_varlist(4)%field3d => tmp_g23
172
173 flag_covariantvec = .false.
174 select type(comm3d)
176 call comm3d%SetCovariantVec( 1, g13, g23 )
177 flag_covariantvec = .true.
178 end select
179
180 call comm3d%Put(comm3d_varlist, 1)
181 call comm3d%Exchange()
182 call comm3d%Get(comm3d_varlist, 1)
183
184 ! Update metric data managed by local mesh
185
186 do n=1, mesh3d%LOCAL_MESH_NUM
187 lcmesh => mesh3d%lcmesh_list(n)
188 elem3d => lcmesh%refElem3D
189
190 if ( flag_covariantvec ) then
191 call mesh3d%Set_geometric_with_vcoord( n, &
192 gsqrtv%local(n)%val, zlev%local(n)%val, g13%local(n)%val, g23%local(n)%val )
193 else
194 call mesh3d%Set_geometric_with_vcoord( n, &
195 gsqrtv%local(n)%val, zlev%local(n)%val, tmp_g13%local(n)%val, tmp_g23%local(n)%val )
196 end if
197 end do
198
199 !---
200 call zlev%Final()
201 call gsqrtv%Final()
202 call g13%Final()
203 call g23%Final()
204 call tmp_g13%Final()
205 call tmp_g23%Final()
206
207 call dx2d%Final()
208 call dy2d%Final()
209 call lift2d%Final()
210
211 return
212 end subroutine meshtopography_set_vcoordinate
213
214!-- prviate ----
215
216!OCL SERIAL
217 subroutine calc_vcoordinate_metrics_lc( G13, G23, tmp_G13, tmp_G23, zlev, GsqrtV, &
218 topo, zTop, vcoord_id, lcmesh, elem3D, lcmesh2D, elem2D, &
219 G11, G12, G21, G22, Dx2D, Dy2D, Lift2D )
222 implicit none
223 type(localmesh3d), intent(in) :: lcmesh
224 type(localmesh2d), intent(in) :: lcmesh2D
225 class(elementbase3d), intent(in) :: elem3D
226 class(elementbase2d), intent(in) :: elem2D
227 real(RP), intent(out) :: G13(elem3D%Np,lcmesh%NeA)
228 real(RP), intent(out) :: G23(elem3D%Np,lcmesh%NeA)
229 real(RP), intent(out) :: tmp_G13(elem3D%Np,lcmesh%NeA)
230 real(RP), intent(out) :: tmp_G23(elem3D%Np,lcmesh%NeA)
231 real(RP), intent(out) :: zlev(elem3D%Np,lcmesh%NeA)
232 real(RP), intent(out) :: GsqrtV(elem3D%Np,lcmesh%NeA)
233 real(RP), intent(in) :: topo(elem2D%Np,lcmesh2D%NeA)
234 real(RP), intent(in) :: zTop
235 integer, intent(in) :: vcoord_id
236 real(RP), intent(in) :: G11(elem2D%Np,lcmesh2D%Ne)
237 real(RP), intent(in) :: G12(elem2D%Np,lcmesh2D%Ne)
238 real(RP), intent(in) :: G21(elem2D%Np,lcmesh2D%Ne)
239 real(RP), intent(in) :: G22(elem2D%Np,lcmesh2D%Ne)
240 type(sparsemat), intent(in) :: Dx2D, Dy2D, Lift2D
241
242 integer :: IndexH2Dto3D(elem3D%Np)
243 integer :: ke, ke2D, p
244 !------------------------------------------------------------------------------
245
247 g13, g23, zlev, gsqrtv, & ! (out)
248 topo, ztop, vcoord_id, & ! (in)
249 lcmesh, lcmesh%refElem3D, lcmesh2d, lcmesh2d%refElem2D, & ! (in)
250 dx2d, dy2d, lift2d ) ! (in)
251
252 indexh2dto3d(:) = elem3d%IndexH2Dto3D(:)
253 !$omp parallel do private(ke2D)
254 !$acc parallel loop private(ke2D) collapse(2) &
255 !$acc present(G11, G12, G21, G22, G13, G23, tmp_G13, tmp_G23, lcmesh, elem3D) copyin(IndexH2Dto3D)
256 do ke=lcmesh%NeS, lcmesh%NeE
257 do p=1, elem3d%Np
258 ke2d = lcmesh%EMap3Dto2D(ke)
259 tmp_g13(p,ke) = g11(indexh2dto3d(p),ke2d) * g13(p,ke) + g12(indexh2dto3d(p),ke2d) * g23(p,ke)
260 tmp_g23(p,ke) = g21(indexh2dto3d(p),ke2d) * g13(p,ke) + g22(indexh2dto3d(p),ke2d) * g23(p,ke)
261 end do
262 end do
263 return
264 end subroutine calc_vcoordinate_metrics_lc
265
266end module scale_mesh_topography
module FElib / Element / Base
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
module FElib / Mesh / Topography
subroutine meshtopography_init(this, varname, mesh)
module FElib / Data / base
module FElib / Data / Communication base
module FElib / Data / Communication in 3D cubed-sphere domain
module FElib / Mesh / utility for general vertical coordinate
subroutine, public meshutil_vcoord_getmetric(g13, g23, zlev, gsqrtv, topo, ztop, vcoord_id, lcmesh, elem, lcmesh2d, elem2d, dx2d, dy2d, lift2d)
Get metric terms of vertical coordinate transformation.
Module common / sparsemat.
Derived type representing a 2D reference element.
Derived type representing a 3D reference element.
Derived type representing a local mesh for 2D domain.
Derived type to manage a local 3D computational domain.
Derived type to manage a computational mesh (base type for 2D domain)
Derived type to manage a computational mesh (base type for 3D domain)
Derived type to manage topography datat and setup vertical coordinate metric.
Derived type representing a field with 2D mesh.
Derived type representing a field with 3D mesh.
Base derived type to manage data communication.
Container to save a pointer of MeshField(1D, 2D, 3D) object.
Base derived type to manage data communication with 3D cubed-sphere domain.
Derived type to manage a sparse matrix.