FE-Project
Loading...
Searching...
No Matches
scale_meshutil_vcoord Module Reference

module FElib / Mesh / utility for general vertical coordinate More...

Functions/Subroutines

integer function, public meshutil_get_vcoord_typeid (vcoord_type)
 Get a type ID of 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.

Variables

character(*), parameter, public mesh_vcoord_terrain_following_name = "TERRAIN_FOLLOWING"
integer, parameter, public mesh_vcoord_terrain_following_id = 1

Detailed Description

module FElib / Mesh / utility for general vertical coordinate

Description
A module useful for general vertical coordinate
Author
Yuta Kawai, Team SCALE

Function/Subroutine Documentation

◆ meshutil_get_vcoord_typeid()

integer function, public scale_meshutil_vcoord::meshutil_get_vcoord_typeid ( character(len=*), intent(in) vcoord_type)

Get a type ID of vertical coordinate.

Parameters
[in]vcoord_typeName of vertical coordinate type

Definition at line 62 of file scale_meshutil_vcoord.F90.

63 implicit none
64
65 character(len=*), intent(in) :: vcoord_type !< Name of vertical coordinate type
66 integer :: vcoord_id
67
68 select case( vcoord_type )
69 case( mesh_vcoord_terrain_following_name )
70 vcoord_id = mesh_vcoord_terrain_following_id
71 case default
72 log_error("MeshUtil_VCoord_TypeID",*) "vcoord_type is inappropriate. Check!", vcoord_type
73 call prc_abort
74 end select
75
76 return

References mesh_vcoord_terrain_following_id, and mesh_vcoord_terrain_following_name.

Referenced by mod_atmos_mesh_gm::atmosmeshgm_init(), mod_atmos_mesh_rm::atmosmeshrm_init(), mod_ocean_mesh_gm::oceanmeshgm_init(), and mod_ocean_mesh_rm::oceanmeshrm_init().

◆ meshutil_vcoord_getmetric()

subroutine, public scale_meshutil_vcoord::meshutil_vcoord_getmetric ( real(rp), dimension(elem%np,lcmesh%nea), intent(out) g13,
real(rp), dimension(elem%np,lcmesh%nea), intent(out) g23,
real(rp), dimension(elem%np,lcmesh%nea), intent(out) zlev,
real(rp), dimension(elem%np,lcmesh%nea), intent(inout) gsqrtv,
real(rp), dimension(elem2d%np,lcmesh2d%nea), intent(in) topo,
real(rp), intent(in) ztop,
integer, intent(in) vcoord_id,
type(localmesh3d), intent(in) lcmesh,
class(elementbase3d), intent(in) elem,
type(localmesh2d), intent(in) lcmesh2d,
class(elementbase2d), intent(in) elem2d,
type(sparsemat), intent(in) dx2d,
type(sparsemat), intent(in) dy2d,
type(sparsemat), intent(in) lift2d )

Get metric terms of vertical coordinate transformation.

Definition at line 81 of file scale_meshutil_vcoord.F90.

84 implicit none
85
86 type(LocalMesh3D), intent(in) :: lcmesh
87 class(ElementBase3D), intent(in) :: elem
88 type(LocalMesh2D), intent(in) :: lcmesh2D
89 class(ElementBase2D), intent(in) :: elem2D
90 real(RP), intent(out) :: G13(elem%Np,lcmesh%NeA)
91 real(RP), intent(out) :: G23(elem%Np,lcmesh%NeA)
92 real(RP), intent(out) :: zlev(elem%Np,lcmesh%NeA)
93 real(RP), intent(inout) :: GsqrtV(elem%Np,lcmesh%NeA)
94 real(RP), intent(in) :: topo(elem2D%Np,lcmesh2D%NeA)
95 integer, intent(in) :: vcoord_id
96 real(RP), intent(in) :: zTop
97 type(SparseMat), intent(in) :: Dx2D
98 type(SparseMat), intent(in) :: Dy2D
99 type(SparseMat), intent(in) :: Lift2D
100
101 integer :: ke, ke2D, p
102 real(RP) :: del_flux(elem2D%NfpTot,lcmesh2D%Ne,2)
103 real(RP) :: Fx2D(elem2D%Np), Fy2D(elem2D%Np), LiftDelFlux2D(elem2D%Np,2)
104 real(RP) :: GradZs(elem2D%Np,lcmesh2D%Ne,2)
105 real(RP) :: coef3D
106
107 integer :: IndexH2Dto3D(elem%Np)
108 !------------------------------------------------
109
110 if ( vcoord_id == mesh_vcoord_terrain_following_id ) then
111
112 ! * z = topo + (1 - topo / zTop ) * zeta
113 ! * zeta = zTop * (z - topo)/(zTop - topo)
114 ! * Gi3 = (dzeta(x1,x2,z)/dxi)_z = d (zeta,z) / d (xi,z) = - d(z,zeta)/ d(xi,zeta) * d(xi,zeta)/d(xi,z)
115 ! = - (dz/dxi)_zeta * dzeta/dz
116 ! = (GsqrtV)^-1 * [ - 1 + zeta / zTop ] * d topo /dxi (i=1, 2)
117
118
119 indexh2dto3d(:) = elem%IndexH2Dto3D(:)
120
121 !$acc data create( del_flux, GradZs ) copyin( IndexH2Dto3D )
122
123 call cal_del_flux( del_flux, &
124 topo, lcmesh2d%normal_fn(:,:,1), lcmesh2d%normal_fn(:,:,2), &
125 lcmesh2d%VMapM, lcmesh2d%VMapP, lcmesh2d, elem2d )
126
127 !$omp parallel private(Fx2D, Fy2D, LiftDelFlux2D, coef3D )
128 !$acc parallel loop gang private(ke2D, Fx2D, Fy2D, LiftDelFlux2D, coef3D ) &
129 !$acc present(topo, del_flux, zlev, GsqrtV, G13, G23, lcmesh,elem,lcmesh2D,elem2D)
130 !$omp do
131 do ke2d=1, lcmesh2d%Ne
132 call sparsemat_matmul( dx2d, topo(:,ke2d), fx2d )
133 call sparsemat_matmul( dy2d, topo(:,ke2d), fy2d )
134#ifdef _OPENACC
135 call sparsemat_matmul( lift2d, lcmesh2d%Fscale(:,ke2d), del_flux(:,ke2d,1), liftdelflux2d(:,1))
136 call sparsemat_matmul( lift2d, lcmesh2d%Fscale(:,ke2d), del_flux(:,ke2d,2), liftdelflux2d(:,2))
137#else
138 call sparsemat_matmul( lift2d, lcmesh2d%Fscale(:,ke2d) * del_flux(:,ke2d,1), liftdelflux2d(:,1))
139 call sparsemat_matmul( lift2d, lcmesh2d%Fscale(:,ke2d) * del_flux(:,ke2d,2), liftdelflux2d(:,2))
140#endif
141 !$acc loop vector
142 do p=1, elem2d%Np
143 gradzs(p,ke2d,1) = lcmesh2d%Escale(p,ke2d,1,1) * fx2d(p) + liftdelflux2d(p,1)
144 gradzs(p,ke2d,2) = lcmesh2d%Escale(p,ke2d,2,2) * fy2d(p) + liftdelflux2d(p,2)
145 end do
146 end do
147 !$omp end do
148
149 !$omp do
150 !$acc parallel loop gang private(ke2D,coef3D) present(lcmesh,elem)
151 do ke=1, lcmesh%Ne
152 ke2d = lcmesh%EMap3Dto2D(ke)
153 !$acc loop vector
154 do p=1, elem%Np
155 coef3d = 1.0_rp - lcmesh%pos_en(p,ke,3) / ztop
156 zlev(p,ke) = lcmesh%pos_en(p,ke,3) &
157 + coef3d * topo(indexh2dto3d(p),ke2d)
158
159 gsqrtv(p,ke) = 1.0_rp - topo(indexh2dto3d(p),ke2d) / ztop ! dz/dzeta
160
161 coef3d = - coef3d / gsqrtv(p,ke)
162 g13(p,ke) = coef3d * gradzs(indexh2dto3d(p),ke2d,1)
163 g23(p,ke) = coef3d * gradzs(indexh2dto3d(p),ke2d,2)
164 end do
165 end do
166 !$omp end do
167 !$acc end parallel
168 !$omp end parallel
169
170 !$acc end data
171 else
172 log_error("Mesh_VCoord_GetMetric",*) "vcoord_id is inappropriate. Check!", vcoord_id
173 call prc_abort
174 end if
175 return

References mesh_vcoord_terrain_following_id.

Referenced by scale_mesh_topography::meshtopography_init().

Variable Documentation

◆ mesh_vcoord_terrain_following_name

character(*), parameter, public scale_meshutil_vcoord::mesh_vcoord_terrain_following_name = "TERRAIN_FOLLOWING"

Definition at line 44 of file scale_meshutil_vcoord.F90.

44 character(*), public, parameter :: MESH_VCOORD_TERRAIN_FOLLOWING_NAME = "TERRAIN_FOLLOWING"

Referenced by meshutil_get_vcoord_typeid().

◆ mesh_vcoord_terrain_following_id

integer, parameter, public scale_meshutil_vcoord::mesh_vcoord_terrain_following_id = 1

Definition at line 45 of file scale_meshutil_vcoord.F90.

45 integer, public, parameter :: MESH_VCOORD_TERRAIN_FOLLOWING_ID = 1

Referenced by meshutil_get_vcoord_typeid(), and meshutil_vcoord_getmetric().