FE-Project
Loading...
Searching...
No Matches
scale_mesh_topography.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
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 !-----------------------------------------------------------------------------
30 implicit none
31 private
32
33 !-----------------------------------------------------------------------------
34 !
35 !++ Public type & procedure
36 !
37 type, public :: meshtopography
38 type(meshfield2d) :: topo
39 contains
40 procedure :: init => meshtopography_init
41 procedure :: final => meshtopography_final
42 procedure :: setvcoordinate => meshtopography_set_vcoordinate
43 end type meshtopography
44
45 !-----------------------------------------------------------------------------
46 !
47 !++ Public parameters & variables
48 !
49
50 !-----------------------------------------------------------------------------
51 !
52 !++ Private procedure
53 !
54
55 !-----------------------------------------------------------------------------
56 !
57 !++ Private parameters & variables
58 !
59
60contains
61!OCL SERIAL
62 subroutine meshtopography_init( this, varname, mesh )
63 implicit none
64
65 class(meshtopography), intent(inout) :: this
66 character(len=*), intent(in) :: varname
67 class(meshbase2d), intent(in), target :: mesh
68
69 integer :: n
70 !-----------------------------------------------------------------------------
71
72 call this%topo%Init( varname, "m", mesh )
73
74 do n=1, mesh%LOCAL_MESH_NUM
75!$omp parallel workshare
76 this%topo%local(n)%val(:,:) = 0.0_rp
77!$omp end parallel workshare
78 end do
79
80 return
81 end subroutine meshtopography_init
82
83!OCL SERIAL
84 subroutine meshtopography_final( this )
85 implicit none
86
87 class(meshtopography), intent(inout) :: this
88 !-----------------------------------------------------------------------------
89
90 call this%topo%Final()
91
92 return
93 end subroutine meshtopography_final
94
95!OCL SERIAL
96 subroutine meshtopography_set_vcoordinate( this, mesh3D, &
97 vcoord_id, zTop, comm3D, comm2D )
98
99 use scale_sparsemat, only: sparsemat
102 implicit none
103
104 class(meshtopography), target, intent(inout) :: this
105 class(meshbase3d), intent(inout), target :: mesh3D
106 integer, intent(in) :: vcoord_id
107 real(RP), intent(in) :: zTop
108 class(meshfieldcommbase), intent(inout) :: comm3D
109 class(meshfieldcommbase), intent(inout) :: comm2D
110
111 type(sparsemat) :: Dx2D, Dy2D, Lift2D
112 class(localmesh3d), pointer :: lcmesh
113 class(localmesh2d), pointer :: lcmesh2D
114 class(elementbase3d), pointer :: elem3D
115
116 integer :: n
117 integer :: ke, ke2D
118
119 type(meshfieldcontainer) :: comm2d_varlist(1)
120 type(meshfieldcontainer) :: comm3d_varlist(4)
121
122 type(meshfield3d), target :: zlev, GsqrtV, G13, G23
123 type(meshfield3d), target :: tmp_G13, tmp_G23
124
125 logical :: flag_covariantvec
126 !-------------------------------------------------------------
127
128 lcmesh => mesh3d%lcmesh_list(1)
129 lcmesh2d => lcmesh%lcmesh2D
130 call dx2d %Init( lcmesh2d%refElem2D%Dx1 )
131 call dy2d %Init( lcmesh2d%refElem2D%Dx2 )
132 call lift2d%Init( lcmesh2d%refElem2D%Lift )
133
134 ! Exchange topography data to fill halo
135
136 comm2d_varlist(1)%field2d => this%topo
137 call comm2d%Put(comm2d_varlist, 1)
138 call comm2d%Exchange()
139 call comm2d%Get(comm2d_varlist, 1)
140
141 ! Calculate metric factors associated with general vertical coordinates
142
143 call zlev%Init( "zlev", "", mesh3d )
144 call gsqrtv%Init( "GsqrtV", "", mesh3d )
145 call g13%Init( "G13", "", mesh3d )
146 call g23%Init( "G23", "", mesh3d )
147
148 call tmp_g13%Init( "tmp_G13", "", mesh3d )
149 call tmp_g23%Init( "tmp_G23", "", mesh3d )
150
151 do n=1, mesh3d%LOCAL_MESH_NUM
152 lcmesh => mesh3d%lcmesh_list(n)
153 lcmesh2d => lcmesh%lcmesh2D
154 elem3d => lcmesh%refElem3D
155
157 g13%local(n)%val, g23%local(n)%val, zlev%local(n)%val, & ! (out)
158 gsqrtv%local(n)%val, & ! (out)
159 this%topo%local(n)%val(:,:), ztop, vcoord_id, & ! (in)
160 lcmesh, lcmesh%refElem3D, lcmesh2d, lcmesh2d%refElem2D, & ! (in)
161 dx2d, dy2d, lift2d ) ! (in)
162
163 !$omp parallel do private(ke2D)
164 do ke=lcmesh%NeS, lcmesh%NeE
165 ke2d = lcmesh%EMap3Dto2D(ke)
166 tmp_g13%local(n)%val(:,ke) = &
167 lcmesh%GIJ(elem3d%IndexH2Dto3D(:),ke2d,1,1) * g13%local(n)%val(:,ke) &
168 + lcmesh%GIJ(elem3d%IndexH2Dto3D(:),ke2d,1,2) * g23%local(n)%val(:,ke)
169 tmp_g23%local(n)%val(:,ke) = &
170 lcmesh%GIJ(elem3d%IndexH2Dto3D(:),ke2d,2,1) * g13%local(n)%val(:,ke) &
171 + lcmesh%GIJ(elem3d%IndexH2Dto3D(:),ke2d,2,2) * g23%local(n)%val(:,ke)
172 end do
173 end do
174
175 ! Exchange metric data to fill halo
176
177 comm3d_varlist(1)%field3d => zlev
178 comm3d_varlist(2)%field3d => gsqrtv
179 comm3d_varlist(3)%field3d => tmp_g13
180 comm3d_varlist(4)%field3d => tmp_g23
181
182 flag_covariantvec = .false.
183 select type(comm3d)
185 call comm3d%SetCovariantVec( 1, g13, g23 )
186 flag_covariantvec = .true.
187 end select
188
189 call comm3d%Put(comm3d_varlist, 1)
190 call comm3d%Exchange()
191 call comm3d%Get(comm3d_varlist, 1)
192
193 ! Update metric data managed by local mesh
194
195 do n=1, mesh3d%LOCAL_MESH_NUM
196 lcmesh => mesh3d%lcmesh_list(n)
197 elem3d => lcmesh%refElem3D
198
199 if ( flag_covariantvec ) then
200 call mesh3d%Set_geometric_with_vcoord( n, &
201 gsqrtv%local(n)%val, zlev%local(n)%val, g13%local(n)%val, g23%local(n)%val )
202 else
203 call mesh3d%Set_geometric_with_vcoord( n, &
204 gsqrtv%local(n)%val, zlev%local(n)%val, tmp_g13%local(n)%val, tmp_g23%local(n)%val )
205 end if
206 end do
207
208 !---
209 call zlev%Final()
210 call gsqrtv%Final()
211 call g13%Final()
212 call g23%Final()
213 call tmp_g13%Final()
214 call tmp_g23%Final()
215
216 call dx2d%Final()
217 call dy2d%Final()
218 call lift2d%Final()
219
220 return
221 end subroutine meshtopography_set_vcoordinate
222
223end 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)
module common / sparsemat
Base derived type to manage data communication.