43 REAL,
PARAMETER :: tsim = 10.0
44 REAL,
PARAMETER :: gamma = 1.4
45 REAL,
PARAMETER :: re = 1.0e+4
47 REAL,
PARAMETER :: rho0 = 1.0
48 REAL,
PARAMETER :: v0 =-0.5
49 REAL,
PARAMETER :: p0 = 2.5
50 REAL,
PARAMETER :: rho1 = 2.0
51 REAL,
PARAMETER :: v1 = 0.5
52 REAL,
PARAMETER :: p1 = p0
54 INTEGER,
PARAMETER :: mgeo = cartesian
55 INTEGER,
PARAMETER :: res = 50
56 REAL,
PARAMETER :: xyzlen= 1.0
58 INTEGER,
PARAMETER :: onum = 10
59 CHARACTER(LEN=256),
PARAMETER &
61 CHARACTER(LEN=256),
PARAMETER &
64 CLASS(
fosite),
ALLOCATABLE :: sim
65 CLASS(marray_compound),
POINTER :: pvar,pvar_init
68 INTEGER,
DIMENSION(:),
ALLOCATABLE :: seed
73 CALL random_seed(size=n)
74 ALLOCATE(sim,pvar,seed(n))
80 CALL initdata(sim%Mesh, sim%Physics, sim%Timedisc)
82 CALL sim%Physics%new_statevector(pvar_init,primitive)
86 CALL sim%Physics%new_statevector(pvar,primitive)
96 CALL setattr(sim%config,
"/datafile/filename", (trim(odir) // trim(ofname) //
"_rotate"))
98 sim%Timedisc%pvar%data1d(:) = pvar_init%data1d(:)
99 CALL sim%Physics%Convert2Conservative(sim%Timedisc%pvar,sim%Timedisc%cvar)
102 sigma = sqrt(sum((sim%Timedisc%pvar%data4d(:,:,:,:)-pvar%data4d(:,:,:,:))**2)/
SIZE(pvar%data4d))
106 DEALLOCATE(pvar,seed,sim)
107 tap_check_small(sigma,tiny(sigma),
"x-y symmetry test")
115 CLASS(fosite),
INTENT(INOUT) :: Sim
116 TYPE(Dict_TYP),
POINTER :: config
119 TYPE(Dict_TYP),
POINTER :: mesh, physics, boundary, datafile, &
120 sources, timedisc, fluxes
125 "meshtype" / midpoint, &
130 "xmin" / (-0.5*xyzlen), &
131 "xmax" / (0.5*xyzlen), &
132 "ymin" / (-0.5*xyzlen), &
133 "ymax" / (0.5*xyzlen), &
150 "variables" / conservative, &
152 "limiter" / monocent, &
161 "western" / periodic, &
162 "eastern" / periodic, &
163 "southern" / periodic, &
164 "northern" / periodic, &
165 "bottomer" / periodic, &
166 "topper" / periodic &
172 dynvis = abs(rho0 * xyzlen * (v0-v1) / re)
173 IF (dynvis.GT.tiny(1.0))
THEN 175 "vis/stype" / viscosity, &
176 "vis/vismodel" / molecular, &
177 "vis/dynconst" / dynvis, &
178 "vis/bulkconst" / (-2./3.*dynvis), &
179 "vis/output/dynvis" / 0, &
180 "vis/output/stress" / 0, &
181 "vis/output/kinvis" / 0, &
182 "vis/output/bulkvis" / 0 &
188 "method" / modified_euler, &
192 "dtlimit" / 1.0e-10, &
193 "maxiter" / 100000, &
194 "output/pressure" / 1, &
195 "output/density" / 1, &
196 "output/xvelocity" / 1, &
197 "output/yvelocity" / 1 &
202 "fileformat" / vtk, &
204 "filename" / (trim(odir) // trim(ofname)), &
210 "physics" / physics, &
211 "boundary" / boundary, &
213 "timedisc" / timedisc, &
214 "datafile" / datafile &
216 IF (
ASSOCIATED(sources)) &
217 CALL setattr(config,
"sources", sources)
220 SUBROUTINE initdata(Mesh,Physics,Timedisc)
223 CLASS(physics_base) :: Physics
224 CLASS(mesh_base) :: Mesh
225 CLASS(timedisc_base) :: Timedisc
229 REAL,
DIMENSION(Mesh%IGMIN:Mesh%IGMAX,Mesh%JGMIN:Mesh%JGMAX,Mesh%KGMIN:Mesh%KGMAX,2) :: dv
231 INTENT(IN) :: mesh,physics
232 INTENT(INOUT) :: timedisc
236 CALL system_clock(count=clock)
237 seed = clock + (timedisc%getrank()+1) * (/(k-1, k=1,n)/)
238 CALL random_seed(put=seed)
239 CALL random_number(dv)
242 SELECT TYPE(pvar => timedisc%pvar)
243 TYPE IS(statevector_euler)
245 WHERE ((mesh%bcenter(:,:,:,2).LT.(mesh%ymin+0.25*xyzlen)).OR. &
246 (mesh%bcenter(:,:,:,2).GT.(sim%Mesh%ymin+0.75*xyzlen)))
247 pvar%density%data3d(:,:,:) = rho0
248 pvar%velocity%data4d(:,:,:,1) = v0
249 pvar%velocity%data4d(:,:,:,2) = 0.0
250 pvar%pressure%data3d(:,:,:) = p0
252 pvar%density%data3d(:,:,:) = rho1
253 pvar%velocity%data4d(:,:,:,1) = v1
254 pvar%velocity%data4d(:,:,:,2) = 0.0
255 pvar%pressure%data3d(:,:,:) = p1
258 DO k=mesh%KGMIN,mesh%KGMAX
259 pvar%velocity%data4d(:,:,k,1) = pvar%velocity%data4d(:,:,k,1) &
260 + (dv(:,:,k,1)-0.5)*0.02
261 pvar%velocity%data4d(:,:,k,2) = pvar%velocity%data4d(:,:,k,2) &
262 + (dv(:,:,k,2)-0.5)*0.02
265 CALL physics%Error(
"KHI2D::InitData",
"only non-isothermal HD supported")
269 CALL physics%Convert2Conservative(timedisc%pvar,timedisc%cvar)
270 CALL mesh%Info(
" DATA-----> initial condition: " // &
271 "Kelvin-Helmholtz instability")
277 CLASS(mesh_base),
INTENT(IN) :: Mesh
278 CLASS(marray_compound),
INTENT(INOUT) :: pvar_in,pvar_out
279 CHARACTER(LEN=2),
INTENT(IN) :: dir
283 SELECT TYPE(pin => pvar_in)
284 TYPE IS(statevector_euler)
285 SELECT TYPE(pout => pvar_out)
286 TYPE IS(statevector_euler)
290 DO k=mesh%KGMIN,mesh%KGMAX
292 pout%density%data3d(:,:,k) = transpose(pin%density%data3d(:,:,k))
293 pout%pressure%data3d(:,:,k) = transpose(pin%pressure%data3d(:,:,k))
295 pout%velocity%data4d(:,:,k,1) = transpose(pin%velocity%data4d(:,:,k,2))
296 pout%velocity%data4d(:,:,k,2) = transpose(pin%velocity%data4d(:,:,k,1))
299 CALL mesh%Error(
"KHI2D::TransposeData",
"directions must be one of 'xy','xz' or 'yz'")
subroutine initdata(Mesh, Physics, Fluxes, Timedisc)
subroutine transposedata(Mesh, pvar_in, pvar_out, dir)
subroutine makeconfig(Sim, config)
program khi
Kelvin-Helmholtz instability.