geometry_logcylindrical.f90
Go to the documentation of this file.
1!#############################################################################
2!# #
3!# fosite - 3D hydrodynamical simulation program #
4!# module: geometry_logcylindrical.f90 #
5!# #
6!# Copyright (C) 2007-2018 #
7!# Tobias Illenseer <tillense@astrophysik.uni-kiel.de> #
8!# Jannes Klee <jklee@astrophysik.uni-kiel.de> #
9!# #
10!# This program is free software; you can redistribute it and/or modify #
11!# it under the terms of the GNU General Public License as published by #
12!# the Free Software Foundation; either version 2 of the License, or (at #
13!# your option) any later version. #
14!# #
15!# This program is distributed in the hope that it will be useful, but #
16!# WITHOUT ANY WARRANTY; without even the implied warranty of #
17!# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or #
18!# NON INFRINGEMENT. See the GNU General Public License for more #
19!# details. #
20!# #
21!# You should have received a copy of the GNU General Public License #
22!# along with this program; if not, write to the Free Software #
23!# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
24!# #
25!#############################################################################
26
27!----------------------------------------------------------------------------!
32!----------------------------------------------------------------------------!
36 USE common_dict
37 IMPLICIT NONE
38 !--------------------------------------------------------------------------!
40 CONTAINS
42 PROCEDURE :: scalefactors_1
43 PROCEDURE :: scalefactors_2
44 PROCEDURE :: scalefactors_3
45 PROCEDURE :: scalefactors_4
46 PROCEDURE :: radius_1
47 PROCEDURE :: radius_2
48 PROCEDURE :: radius_3
49 PROCEDURE :: radius_4
50 PROCEDURE :: positionvector_1
51 PROCEDURE :: positionvector_2
52 PROCEDURE :: positionvector_3
53 PROCEDURE :: positionvector_4
62 PROCEDURE :: finalize
63 END TYPE
64 PRIVATE
65 CHARACTER(LEN=32), PARAMETER :: geometry_name = "logcylindrical"
66 !--------------------------------------------------------------------------!
68 !--------------------------------------------------------------------------!
69
70CONTAINS
71
72 SUBROUTINE initgeometry_logcylindrical(this,config)
73 IMPLICIT NONE
74 !------------------------------------------------------------------------!
75 CLASS(geometry_logcylindrical), INTENT(INOUT) :: this
76 TYPE(dict_typ), POINTER :: config
77 !------------------------------------------------------------------------!
78 REAL :: gparam
79 !------------------------------------------------------------------------!
80 CALL getattr(config, "gparam", gparam, 1.0)
81
82 CALL this%SetScale(gparam)
83 CALL this%InitGeometry(logcylindrical,geometry_name,config)
84 CALL this%SetAzimuthIndex(2)
85 END SUBROUTINE initgeometry_logcylindrical
86
87 PURE SUBROUTINE scalefactors_1(this,coords,hx,hy,hz)
88 IMPLICIT NONE
89 !------------------------------------------------------------------------!
90 CLASS(geometry_logcylindrical), INTENT(IN) :: this
91 REAL, INTENT(IN), DIMENSION(:,:) :: coords
92 REAL, INTENT(OUT), DIMENSION(:) :: hx,hy,hz
93 !------------------------------------------------------------------------!
94 CALL scalefactors(this%geoparam(1),coords(:,1),coords(:,2),coords(:,3),hx(:),hy(:),hz(:))
95 END SUBROUTINE scalefactors_1
96
97 PURE SUBROUTINE scalefactors_2(this,coords,hx,hy,hz)
98 IMPLICIT NONE
99 !------------------------------------------------------------------------!
100 CLASS(geometry_logcylindrical), INTENT(IN) :: this
101 REAL, INTENT(IN), DIMENSION(:,:,:) :: coords
102 REAL, INTENT(OUT), DIMENSION(:,:) :: hx,hy,hz
103 !------------------------------------------------------------------------!
104 CALL scalefactors(this%geoparam(1),coords(:,:,1),coords(:,:,2),coords(:,:,3), &
105 hx(:,:),hy(:,:),hz(:,:))
106 END SUBROUTINE scalefactors_2
107
108 PURE SUBROUTINE scalefactors_3(this,coords,hx,hy,hz)
109 IMPLICIT NONE
110 !------------------------------------------------------------------------!
111 CLASS(geometry_logcylindrical), INTENT(IN) :: this
112 REAL, INTENT(IN), DIMENSION(:,:,:,:) :: coords
113 REAL, INTENT(OUT), DIMENSION(:,:,:) :: hx,hy,hz
114 !------------------------------------------------------------------------!
115 CALL scalefactors(this%geoparam(1),coords(:,:,:,1),coords(:,:,:,2),coords(:,:,:,3), &
116 hx(:,:,:),hy(:,:,:),hz(:,:,:))
117 END SUBROUTINE scalefactors_3
118
119 PURE SUBROUTINE scalefactors_4(this,coords,hx,hy,hz)
120 IMPLICIT NONE
121 !------------------------------------------------------------------------!
122 CLASS(geometry_logcylindrical), INTENT(IN) :: this
123 REAL, INTENT(IN), DIMENSION(:,:,:,:,:) :: coords
124 REAL, INTENT(OUT), DIMENSION(:,:,:,:) :: hx,hy,hz
125 !------------------------------------------------------------------------!
126 CALL scalefactors(this%geoparam(1),coords(:,:,:,:,1),coords(:,:,:,:,2),coords(:,:,:,:,3), &
127 hx(:,:,:,:),hy(:,:,:,:),hz(:,:,:,:))
128 END SUBROUTINE scalefactors_4
129
130 PURE SUBROUTINE radius_1(this,coords,r)
131 IMPLICIT NONE
132 !------------------------------------------------------------------------!
133 CLASS(geometry_logcylindrical), INTENT(IN) :: this
134 REAL, DIMENSION(:,:), INTENT(IN) :: coords
135 REAL, DIMENSION(:), INTENT(OUT) :: r
136 !------------------------------------------------------------------------!
137 r = radius(this%geoparam(1),coords(:,1),coords(:,3))
138 END SUBROUTINE radius_1
139
140 PURE SUBROUTINE radius_2(this,coords,r)
141 IMPLICIT NONE
142 !------------------------------------------------------------------------!
143 CLASS(geometry_logcylindrical), INTENT(IN) :: this
144 REAL, DIMENSION(:,:,:), INTENT(IN) :: coords
145 REAL, DIMENSION(:,:), INTENT(OUT) :: r
146 !------------------------------------------------------------------------!
147 r = radius(this%geoparam(1),coords(:,:,1),coords(:,:,3))
148 END SUBROUTINE radius_2
149
150 PURE SUBROUTINE radius_3(this,coords,r)
151 IMPLICIT NONE
152 !------------------------------------------------------------------------!
153 CLASS(geometry_logcylindrical), INTENT(IN) :: this
154 REAL, DIMENSION(:,:,:,:), INTENT(IN) :: coords
155 REAL, DIMENSION(:,:,:), INTENT(OUT) :: r
156 !------------------------------------------------------------------------!
157 r = radius(this%geoparam(1),coords(:,:,:,1),coords(:,:,:,3))
158 END SUBROUTINE radius_3
159
160 PURE SUBROUTINE radius_4(this,coords,r)
161 IMPLICIT NONE
162 !------------------------------------------------------------------------!
163 CLASS(geometry_logcylindrical), INTENT(IN) :: this
164 REAL, DIMENSION(:,:,:,:,:), INTENT(IN) :: coords
165 REAL, DIMENSION(:,:,:,:), INTENT(OUT) :: r
166 !------------------------------------------------------------------------!
167 r = radius(this%geoparam(1),coords(:,:,:,:,1),coords(:,:,:,:,3))
168 END SUBROUTINE radius_4
169
170 PURE SUBROUTINE positionvector_1(this,coords,posvec)
171 IMPLICIT NONE
172 !------------------------------------------------------------------------!
173 CLASS(geometry_logcylindrical), INTENT(IN) :: this
174 REAL, DIMENSION(:,:), INTENT(IN) :: coords
175 REAL, DIMENSION(:,:), INTENT(OUT) :: posvec
176 !------------------------------------------------------------------------!
177 CALL positionvector(this%geoparam(1),coords(:,1),coords(:,3),posvec(:,1), &
178 posvec(:,2),posvec(:,3))
179 END SUBROUTINE positionvector_1
180
181 PURE SUBROUTINE positionvector_2(this,coords,posvec)
182 IMPLICIT NONE
183 !------------------------------------------------------------------------!
184 CLASS(geometry_logcylindrical), INTENT(IN) :: this
185 REAL, DIMENSION(:,:,:), INTENT(IN) :: coords
186 REAL, DIMENSION(:,:,:), INTENT(OUT) :: posvec
187 !------------------------------------------------------------------------!
188 CALL positionvector(this%geoparam(1),coords(:,:,1),coords(:,:,3), &
189 posvec(:,:,1),posvec(:,:,2),posvec(:,:,3))
190 END SUBROUTINE positionvector_2
191
192 PURE SUBROUTINE positionvector_3(this,coords,posvec)
193 IMPLICIT NONE
194 !------------------------------------------------------------------------!
195 CLASS(geometry_logcylindrical), INTENT(IN) :: this
196 REAL, DIMENSION(:,:,:,:), INTENT(IN) :: coords
197 REAL, DIMENSION(:,:,:,:), INTENT(OUT) :: posvec
198 !------------------------------------------------------------------------!
199 CALL positionvector(this%geoparam(1),coords(:,:,:,1),coords(:,:,:,3), &
200 posvec(:,:,:,1),posvec(:,:,:,2),posvec(:,:,:,3))
201 END SUBROUTINE positionvector_3
202
203 PURE SUBROUTINE positionvector_4(this,coords,posvec)
204 IMPLICIT NONE
205 !------------------------------------------------------------------------!
206 CLASS(geometry_logcylindrical), INTENT(IN) :: this
207 REAL, DIMENSION(:,:,:,:,:), INTENT(IN) :: coords
208 REAL, DIMENSION(:,:,:,:,:), INTENT(OUT) :: posvec
209 !------------------------------------------------------------------------!
210 CALL positionvector(this%geoparam(1),coords(:,:,:,:,1),coords(:,:,:,:,3), &
211 posvec(:,:,:,:,1),posvec(:,:,:,:,2),posvec(:,:,:,:,3))
212 END SUBROUTINE positionvector_4
213
214 PURE SUBROUTINE convert2cartesian_coords_1(this,curv,cart)
215 IMPLICIT NONE
216 !------------------------------------------------------------------------!
217 CLASS(geometry_logcylindrical), INTENT(IN) :: this
218 REAL, DIMENSION(:,:), INTENT(IN) :: curv
219 REAL, DIMENSION(:,:), INTENT(OUT) :: cart
220 !------------------------------------------------------------------------!
221 CALL convert2cartesian_coords(this%geoparam(1),curv(:,1),curv(:,2),curv(:,3), &
222 cart(:,1),cart(:,2),cart(:,3))
223 END SUBROUTINE convert2cartesian_coords_1
224
225 PURE SUBROUTINE convert2cartesian_coords_2(this,curv,cart)
226 IMPLICIT NONE
227 !------------------------------------------------------------------------!
228 CLASS(geometry_logcylindrical), INTENT(IN) :: this
229 REAL, DIMENSION(:,:,:), INTENT(IN) :: curv
230 REAL, DIMENSION(:,:,:), INTENT(OUT) :: cart
231 !------------------------------------------------------------------------!
232 CALL convert2cartesian_coords(this%geoparam(1),curv(:,:,1),curv(:,:,2),curv(:,:,3), &
233 cart(:,:,1),cart(:,:,2),cart(:,:,3))
234 END SUBROUTINE convert2cartesian_coords_2
235
236 PURE SUBROUTINE convert2cartesian_coords_3(this,curv,cart)
237 IMPLICIT NONE
238 !------------------------------------------------------------------------!
239 CLASS(geometry_logcylindrical), INTENT(IN) :: this
240 REAL, DIMENSION(:,:,:,:), INTENT(IN) :: curv
241 REAL, DIMENSION(:,:,:,:), INTENT(OUT) :: cart
242 !------------------------------------------------------------------------!
243 CALL convert2cartesian_coords(this%geoparam(1),curv(:,:,:,1),curv(:,:,:,2),curv(:,:,:,3), &
244 cart(:,:,:,1),cart(:,:,:,2),cart(:,:,:,3))
245 END SUBROUTINE convert2cartesian_coords_3
246
247 PURE SUBROUTINE convert2cartesian_coords_4(this,curv,cart)
248 IMPLICIT NONE
249 !------------------------------------------------------------------------!
250 CLASS(geometry_logcylindrical), INTENT(IN) :: this
251 REAL, DIMENSION(:,:,:,:,:), INTENT(IN) :: curv
252 REAL, DIMENSION(:,:,:,:,:), INTENT(OUT) :: cart
253 !------------------------------------------------------------------------!
254 CALL convert2cartesian_coords(this%geoparam(1),curv(:,:,:,:,1),curv(:,:,:,:,2),curv(:,:,:,:,3), &
255 cart(:,:,:,:,1),cart(:,:,:,:,2),cart(:,:,:,:,3))
256 END SUBROUTINE convert2cartesian_coords_4
257
258 PURE SUBROUTINE convert2curvilinear_coords_1(this,cart,curv)
259 IMPLICIT NONE
260 !------------------------------------------------------------------------!
261 CLASS(geometry_logcylindrical), INTENT(IN) :: this
262 REAL, DIMENSION(:,:), INTENT(IN) :: cart
263 REAL, DIMENSION(:,:), INTENT(OUT) :: curv
264 !------------------------------------------------------------------------!
265 CALL convert2curvilinear_coords(this%geoparam(1),cart(:,1),cart(:,2),cart(:,3), &
266 curv(:,1),curv(:,2),curv(:,3))
267 END SUBROUTINE convert2curvilinear_coords_1
268
269 PURE SUBROUTINE convert2curvilinear_coords_2(this,cart,curv)
270 IMPLICIT NONE
271 !------------------------------------------------------------------------!
272 CLASS(geometry_logcylindrical), INTENT(IN) :: this
273 REAL, DIMENSION(:,:,:), INTENT(IN) :: cart
274 REAL, DIMENSION(:,:,:), INTENT(OUT) :: curv
275 !------------------------------------------------------------------------!
276 CALL convert2curvilinear_coords(this%geoparam(1),cart(:,:,1),cart(:,:,2),cart(:,:,3), &
277 curv(:,:,1),curv(:,:,2),curv(:,:,3))
278 END SUBROUTINE convert2curvilinear_coords_2
279
280 PURE SUBROUTINE convert2curvilinear_coords_3(this,cart,curv)
281 IMPLICIT NONE
282 !------------------------------------------------------------------------!
283 CLASS(geometry_logcylindrical), INTENT(IN) :: this
284 REAL, DIMENSION(:,:,:,:), INTENT(IN) :: cart
285 REAL, DIMENSION(:,:,:,:), INTENT(OUT) :: curv
286 !------------------------------------------------------------------------!
287 CALL convert2curvilinear_coords(this%geoparam(1),cart(:,:,:,1),cart(:,:,:,2),cart(:,:,:,3), &
288 curv(:,:,:,1),curv(:,:,:,2),curv(:,:,:,3))
289 END SUBROUTINE convert2curvilinear_coords_3
290
291 PURE SUBROUTINE convert2curvilinear_coords_4(this,cart,curv)
292 IMPLICIT NONE
293 !------------------------------------------------------------------------!
294 CLASS(geometry_logcylindrical), INTENT(IN) :: this
295 REAL, DIMENSION(:,:,:,:,:), INTENT(IN) :: cart
296 REAL, DIMENSION(:,:,:,:,:), INTENT(OUT) :: curv
297 !------------------------------------------------------------------------!
298 CALL convert2curvilinear_coords(this%geoparam(1),cart(:,:,:,:,1),cart(:,:,:,:,2),cart(:,:,:,:,3), &
299 curv(:,:,:,:,1),curv(:,:,:,:,2),curv(:,:,:,:,3))
300 END SUBROUTINE convert2curvilinear_coords_4
301
302 SUBROUTINE finalize(this)
303 IMPLICIT NONE
304 !------------------------------------------------------------------------!
305 CLASS(geometry_logcylindrical), INTENT(INOUT) :: this
306 !------------------------------------------------------------------------!
307 CALL this%Finalize_base()
308 END SUBROUTINE finalize
309
310 ELEMENTAL SUBROUTINE scalefactors(gp,logr,phi,z,hlogr,hphi,hz)
311 IMPLICIT NONE
312 !------------------------------------------------------------------------!
313 REAL, INTENT(IN) :: gp,logr,phi,z
314 REAL, INTENT(OUT) :: hlogr,hphi,hz
315 !------------------------------------------------------------------------!
316 hlogr = gp*exp(logr)
317 hphi = hlogr
318 hz = 1.
319 END SUBROUTINE scalefactors
320
321 ELEMENTAL FUNCTION radius(gp,logr,z)
322 IMPLICIT NONE
323 !------------------------------------------------------------------------!
324 REAL, INTENT(IN) :: gp,logr,z
325 REAL :: radius
326 !------------------------------------------------------------------------!
327 REAL :: r
328 !------------------------------------------------------------------------!
329 r = gp*exp(logr)
330 radius = sqrt(r*r+z*z)
331 END FUNCTION radius
332
333 ELEMENTAL SUBROUTINE positionvector(gp,logr,z,rx,ry,rz)
334 IMPLICIT NONE
335 !------------------------------------------------------------------------!
336 REAL, INTENT(IN) :: gp,logr,z
337 REAL, INTENT(OUT) :: rx,ry,rz
338 !------------------------------------------------------------------------!
339 rx = radius(gp,logr,z)
340 ry = 0.0
341 rz = z
342 END SUBROUTINE positionvector
343
344 ELEMENTAL SUBROUTINE convert2cartesian_coords(gp,logr,phi,zz,x,y,z)
345 IMPLICIT NONE
346 !------------------------------------------------------------------------!
347 REAL, INTENT(IN) :: gp,logr,phi,zz
348 REAL, INTENT(OUT) :: x,y,z
349 !------------------------------------------------------------------------!
350 REAL :: r
351 !------------------------------------------------------------------------!
352 r = gp*exp(logr)
353 x = r*cos(phi)
354 y = r*sin(phi)
355 z = zz
356 END SUBROUTINE convert2cartesian_coords
357
358 ELEMENTAL SUBROUTINE convert2curvilinear_coords(gp,x,y,z,logr,phi,zz)
359 IMPLICIT NONE
360 !------------------------------------------------------------------------!
361 REAL, INTENT(IN) :: gp,x,y,z
362 REAL, INTENT(OUT) :: logr,phi,zz
363 !------------------------------------------------------------------------!
364 REAL :: x_,y_
365 !------------------------------------------------------------------------!
366 x_ = x/gp
367 y_ = y/gp
368 logr = 0.5*log(x_*x_+y_*y_)
369 phi = atan2(y_,x_)
370 IF (phi.LT.0.0) THEN
371 phi = phi + 2.0*pi
372 END IF
373 zz = z
374 END SUBROUTINE convert2curvilinear_coords
375
Dictionary for generic data types.
Definition: common_dict.f90:61
type(logging_base), save this
base class for geometrical properties
real, parameter, public pi
integer, parameter, public logcylindrical
pure subroutine convert2curvilinear_coords(this, cart, curv)
Convert cartesian to curvilinear coordinates.
pure subroutine convert2cartesian_coords(this, curv, cart)
Convert curvilinear to cartesian coordinates.
defines properties of a 3D cylindrical mesh
elemental subroutine positionvector(r, z, rx, ry, rz)
pure subroutine positionvector_3(this, coords, posvec)
character(len=32), parameter geometry_name
pure subroutine convert2cartesian_coords_3(this, curv, cart)
pure subroutine positionvector_4(this, coords, posvec)
pure subroutine convert2cartesian_coords_2(this, curv, cart)
pure subroutine convert2curvilinear_coords_3(this, cart, curv)
pure subroutine convert2cartesian_coords_1(this, curv, cart)
pure subroutine radius_4(this, coords, r)
pure subroutine scalefactors_1(this, coords, hx, hy, hz)
pure subroutine scalefactors_2(this, coords, hx, hy, hz)
pure subroutine radius_1(this, coords, r)
pure subroutine convert2curvilinear_coords_4(this, cart, curv)
pure subroutine radius_3(this, coords, r)
pure subroutine positionvector_2(this, coords, posvec)
pure subroutine convert2curvilinear_coords_1(this, cart, curv)
pure subroutine positionvector_1(this, coords, posvec)
pure subroutine convert2cartesian_coords_4(this, curv, cart)
pure subroutine scalefactors_3(this, coords, hx, hy, hz)
pure subroutine scalefactors_4(this, coords, hx, hy, hz)
pure subroutine convert2curvilinear_coords_2(this, cart, curv)
elemental real function radius(r, z)
pure subroutine radius_2(this, coords, r)
elemental subroutine scalefactors(r, hr, hphi, hz)
defines properties of a 3D logcylindrical mesh
subroutine initgeometry_logcylindrical(this, config)