1 #define sll_transformation class(sll_c_coordinate_transformation_2d_base)
9 #include "sll_assert.h"
10 #include "sll_memory.h"
11 #include "sll_working_precision.h"
46 sll_transformation,
pointer :: tau
47 sll_real64,
dimension(:, :, :, :),
allocatable :: array
48 sll_real64,
dimension(:),
allocatable :: xgalo
49 sll_real64,
dimension(:),
allocatable :: wgalo
64 end interface operator(+)
69 end interface operator(-)
78 sll_transformation,
target :: tau
79 sll_real64,
external,
optional :: init_function
80 sll_int32,
intent(in) :: degree
88 sll_allocate(this%xgalo(degree + 1),
error)
89 sll_allocate(this%wgalo(degree + 1),
error)
94 nc_eta1 = tau%mesh%num_cells1
95 nc_eta2 = tau%mesh%num_cells2
96 allocate (this%array(1:degree + 1, 1:degree + 1, 1:nc_eta1, 1:nc_eta2))
99 if (
present(init_function))
then
110 sll_transformation,
pointer :: tau
111 sll_real64,
external,
optional :: init_function
112 sll_int32,
intent(in) :: degree
117 sll_allocate(this,
error)
121 sll_allocate(this%xgalo(degree + 1),
error)
122 sll_allocate(this%wgalo(degree + 1),
error)
127 associate(lm => this%tau%mesh)
128 nc_eta1 = lm%num_cells1
129 nc_eta2 = lm%num_cells2
132 allocate (this%array(1:degree + 1, 1:degree + 1, 1:nc_eta1, 1:nc_eta2))
135 if (
present(init_function))
then
147 sll_real64,
external :: init_function
149 sll_real64 :: offset(2)
152 sll_int32 :: i, j, ii, jj
154 sll_assert(
allocated(this%array))
156 do j = 1, this%tau%mesh%num_cells2
157 do i = 1, this%tau%mesh%num_cells1
158 offset(1) = this%tau%mesh%eta1_min + real(i - 1, f64)*this%tau%mesh%delta_eta1
159 offset(2) = this%tau%mesh%eta2_min + real(j - 1, f64)*this%tau%mesh%delta_eta2
160 do jj = 1, this%degree + 1
161 do ii = 1, this%degree + 1
162 eta1 = offset(1) + 0.5_f64*(this%xgalo(ii) + 1.0_f64)*this%tau%mesh%delta_eta1
163 eta2 = offset(2) + 0.5_f64*(this%xgalo(jj) + 1.0_f64)*this%tau%mesh%delta_eta2
164 this%array(ii, jj, i, j) = init_function(this%tau%x1(eta1, eta2), &
165 this%tau%x2(eta1, eta2), &
177 character(len=*) :: field_name
178 sll_int32,
optional :: file_format
179 sll_real64,
optional :: time
181 if (
present(file_format))
then
182 select case (file_format)
188 if (
present(time))
then
194 print
"(a)", field_name//
' write_to_file : Unknown format'
205 character(len=*) :: field_name
208 sll_real64 :: eta1, eta2
209 sll_real64 :: offset(2)
210 sll_int32 :: i, j, ii, jj
211 character(len=4) :: ctag
213 call sll_s_int2string(this%tag, ctag)
215 gnu_id = this%file_id
217 if (gnu_id == 0)
then
218 call sll_s_ascii_file_create(field_name//
".gnu", gnu_id,
error)
221 open (unit=gnu_id, file=field_name//
".gnu", position=
"append")
223 write (gnu_id,
"(a)")
"unset key"
224 write (gnu_id,
"(a)")
"set title '"//field_name//
" step "//ctag//
"'"
225 write (gnu_id,
"(a)")
"splot '"//field_name//ctag//
".dat' w l"
227 call sll_s_ascii_file_create(field_name//ctag//
".dat", file_id,
error)
229 associate(lm => this%tau%mesh)
231 do j = 1, lm%num_cells2
232 do i = 1, lm%num_cells1
234 offset(1) = lm%eta1_min + real(i - 1, f64)*lm%delta_eta1
235 offset(2) = lm%eta2_min + real(j - 1, f64)*lm%delta_eta2
236 do jj = 1, this%degree + 1
237 do ii = 1, this%degree + 1
238 eta1 = offset(1) + 0.5_f64*(this%xgalo(ii) + 1.0_f64)*lm%delta_eta1
239 eta2 = offset(2) + 0.5_f64*(this%xgalo(jj) + 1.0_f64)*lm%delta_eta2
240 write (file_id, *) this%tau%x1(eta1, eta2), &
241 this%tau%x2(eta1, eta2), &
242 sngl(this%array(ii, jj, i, j))
258 this%tag = this%tag + 1
259 this%file_id = gnu_id
269 sll_assert(w1%degree == w2%degree)
270 sll_assert(
allocated(w1%array))
271 sll_assert(
allocated(w2%array))
273 w3%array = w1%array + w2%array
283 w3%array = w1%array - w2%array
290 character(len=*) :: field_name
293 sll_int32,
parameter :: nlocmax = 16
295 sll_int32,
dimension(4) :: invpermut1 = (/1, 2, 4, 3/)
296 sll_int32,
dimension(9) :: invpermut2 = (/1, 5, 2, 8, 9, 6, 4, 7, 3/)
297 sll_int32,
dimension(16) :: invpermut3 = (/1, 5, 6, 2, 12, 13, 14, 7, 11, 16, 15, 8, 4, 10, 9, 3/)
298 sll_int32 :: invpermut(nlocmax), permut(nlocmax)
299 sll_int32 :: nloc, nel, neq, iel, ino, inoloc
300 sll_int32 :: i, j, k, l, ii, jj, ni, nj
301 sll_int32,
allocatable :: connec(:, :)
302 sll_real64,
allocatable :: coords(:, :)
303 sll_real64,
allocatable :: values(:)
304 sll_real64 :: offset(2), eta1, eta2
305 character(len=32) :: my_fmt
307 if (this%degree > 3)
then
308 write (*, *) é
'ordre non prvu'
312 associate(lm => this%tau%mesh)
316 nloc = (this%degree + 1)*(this%degree + 1)
318 neq = (ni*this%degree + 1)*(nj*this%degree + 1)
320 sll_allocate(connec(1:nloc, 1:neq),
error)
321 sll_allocate(coords(1:2, 1:neq),
error)
322 sll_allocate(values(1:neq),
error)
327 offset(1) = lm%eta1_min + i*lm%delta_eta1
328 offset(2) = lm%eta2_min + j*lm%delta_eta2
329 do jj = 0, this%degree
330 do ii = 0, this%degree
331 inoloc = 1 + ii + (this%degree + 1)*jj
332 ino = 1 + ii + this%degree*i + (this%degree*ni + 1)*(jj + this%degree*j)
333 connec(inoloc, iel) = ino
334 eta1 = offset(1) + .5_f64*(this%xgalo(ii + 1) + 1._f64)*lm%delta_eta1
335 eta2 = offset(2) + .5_f64*(this%xgalo(jj + 1) + 1._f64)*lm%delta_eta2
336 coords(1, ino) = this%tau%x1(eta1, eta2)
337 coords(2, ino) = this%tau%x2(eta1, eta2)
338 values(ino) = this%array(ii + 1, jj + 1, i + 1, j + 1)
344 select case (this%degree)
346 invpermut(1:nloc) = invpermut1
349 invpermut(1:nloc) = invpermut2
352 invpermut(1:nloc) = invpermut3
355 write (*, *) é
'ordre non prvu'
360 permut(invpermut(i)) = i
363 call sll_s_ascii_file_create(field_name//
".msh", file_id,
error)
364 write (file_id,
'(A)')
'$MeshFormat'
365 write (file_id,
'(A)')
'2 0 8'
366 write (file_id,
'(A)')
'$EndMeshFormat'
367 write (file_id,
'(A)')
'$Nodes'
368 write (file_id, *) neq
370 write (file_id,
'(i6,2x,3f10.5)') k, coords(1:2, k), 0.0
372 write (file_id,
'(A)')
'$EndNodes'
373 write (file_id,
'(A)')
'$Elements'
374 write (file_id, *) nel
376 write (my_fmt,
'(a, i0, a)')
'(3i6,', nloc,
'i5)'
379 do i = 1, lm%num_cells1
380 do j = 1, lm%num_cells2
382 write (file_id, trim(my_fmt)) k, typelem, 0, (connec(l, k), l=1, nloc)
385 write (file_id,
'(A)')
'$EndElements'
386 write (file_id,
'(A)')
'$NodeData'
388 write (file_id, *)
'values'
394 write (file_id, *) neq
396 write (file_id,
'(i6,2x,f10.5)') k, values(k)
398 write (file_id,
'(A)')
'$EndNodeData'
408 character(len=*) :: field_name
411 sll_int32 :: ni, nj, ino
412 sll_int32 :: i, j, ii, jj
413 sll_real64 :: offset(2)
414 sll_real64 :: eta1, eta2
417 call sll_s_ascii_file_create(field_name//
".mtv", file_id,
error)
419 write (file_id, *)
"$DATA=CONTCURVE"
420 write (file_id, *)
"%equalscale=T"
421 write (file_id, *)
"%contfill"
422 write (file_id, *)
"%toplabel='"//field_name//
"'"
424 associate(lm => this%tau%mesh)
426 do j = 1, lm%num_cells2
427 offset(2) = lm%eta2_min + real(j - 1, f64)*lm%delta_eta2
428 do jj = 1, merge(this%degree, this%degree + 1, j < lm%num_cells2)
429 do i = 1, lm%num_cells1
430 offset(1) = lm%eta1_min + real(i - 1, f64)*lm%delta_eta1
431 do ii = 1, merge(this%degree, this%degree + 1, i < lm%num_cells1)
432 eta1 = offset(1) + .5_f64*(this%xgalo(ii) + 1._f64)*lm%delta_eta1
433 eta2 = offset(2) + .5_f64*(this%xgalo(jj) + 1._f64)*lm%delta_eta2
434 write (file_id, *) sngl(this%tau%x1(eta1, eta2)), &
435 sngl(this%tau%x2(eta1, eta2)), &
436 sngl(this%array(ii, jj, i, j))
444 write (file_id, *)
"$DATA=CURVE3D"
445 write (file_id, *)
"%equalscale=T"
446 write (file_id, *)
"%meshplot"
447 write (file_id, *)
"%toplabel='"//field_name//
"'"
449 do j = 1, lm%num_cells2
450 do i = 1, lm%num_cells1
451 offset(1) = lm%eta1_min + (i - 1)*lm%delta_eta1
452 offset(2) = lm%eta2_min + (j - 1)*lm%delta_eta2
453 do jj = 1, this%degree
454 do ii = 1, this%degree
455 eta1 = offset(1) + .5_f64*(this%xgalo(ii) + 1._f64)*lm%delta_eta1
456 eta2 = offset(2) + .5_f64*(this%xgalo(jj) + 1._f64)*lm%delta_eta2
457 write (file_id, *) sngl(this%tau%x1(eta1, eta2)), &
458 sngl(this%tau%x2(eta1, eta2)), &
459 sngl(this%array(ii, jj, i, j))
460 eta1 = offset(1) + .5_f64*(this%xgalo(ii + 1) + 1._f64)*lm%delta_eta1
461 eta2 = offset(2) + .5_f64*(this%xgalo(jj) + 1._f64)*lm%delta_eta2
462 write (file_id, *) sngl(this%tau%x1(eta1, eta2)), &
463 sngl(this%tau%x2(eta1, eta2)), &
464 sngl(this%array(ii + 1, jj, i, j))
465 eta1 = offset(1) + .5_f64*(this%xgalo(ii + 1) + 1._f64)*lm%delta_eta1
466 eta2 = offset(2) + .5_f64*(this%xgalo(jj + 1) + 1._f64)*lm%delta_eta2
467 write (file_id, *) sngl(this%tau%x1(eta1, eta2)), &
468 sngl(this%tau%x2(eta1, eta2)), &
469 sngl(this%array(ii + 1, jj + 1, i, j))
470 eta1 = offset(1) + .5_f64*(this%xgalo(ii) + 1._f64)*lm%delta_eta1
471 eta2 = offset(2) + .5_f64*(this%xgalo(jj + 1) + 1._f64)*lm%delta_eta2
472 write (file_id, *) sngl(this%tau%x1(eta1, eta2)), &
473 sngl(this%tau%x2(eta1, eta2)), &
474 sngl(this%array(ii, jj + 1, i, j))
475 eta1 = offset(1) + .5_f64*(this%xgalo(ii) + 1._f64)*lm%delta_eta1
476 eta2 = offset(2) + .5_f64*(this%xgalo(jj) + 1._f64)*lm%delta_eta2
477 write (file_id, *) sngl(this%tau%x1(eta1, eta2)), &
478 sngl(this%tau%x2(eta1, eta2)), &
479 sngl(this%array(ii, jj, i, j))
491 offset(1) = lm%eta1_min + i*lm%delta_eta1
492 offset(2) = lm%eta2_min + j*lm%delta_eta2
493 do jj = 0, this%degree
494 do ii = 0, this%degree
495 ino = 1 + ii + this%degree*i + (this%degree*ni + 1)*(jj + this%degree*j)
496 eta1 = offset(1) + .5*(this%xgalo(ii + 1) + 1.)*lm%delta_eta1
497 eta2 = offset(2) + .5*(this%xgalo(jj + 1) + 1.)*lm%delta_eta2
498 write (file_id,
"(a)", advance=
"no")
"@text x1="
499 write (file_id,
"(g15.3)", advance=
"no") this%tau%x1(eta1, eta2)
500 write (file_id,
"(a)", advance=
"no")
" y1="
501 write (file_id,
"(g15.3)", advance=
"no") this%tau%x2(eta1, eta2)
502 write (file_id,
"(a)", advance=
"no")
" z1=0. lc=5 ll='"
503 write (file_id,
"(i4)", advance=
"no") ino
504 write (file_id,
"(a)")
"'"
510 write (file_id, *)
"$end"
519 character(len=*) :: field_name
520 sll_real64,
optional :: time
523 sll_int32 :: i, j, k, ii, jj
524 sll_real64 :: offset(2)
525 sll_real64 :: eta1, eta2
528 clength = len_trim(field_name)
530 sll_assert(this%degree < 10)
532 call sll_s_ascii_file_create(field_name//
".xmf", file_id,
error)
534 write (file_id,
"(a)")
"<?xml version='1.0' ?>"
535 write (file_id,
"(a)")
"<!DOCTYPE Xdmf SYSTEM 'Xdmf.dtd' []>"
536 write (file_id,
"(a)")
"<Xdmf Version='2.'>"
537 write (file_id,
"(a)")
"<Domain>"
538 write (file_id,
"(a)")
"<Grid Name='Mesh' GridType='Collection'>"
539 if (
present(time))
then
540 write (file_id,
"(a13,g15.3,a3)")
"<Time Value='", time,
"'/>"
543 associate(lm => this%tau%mesh)
546 do i = 1, lm%num_cells1
547 do j = 1, lm%num_cells2
548 offset(1) = lm%eta1_min + real(i - 1, f64)*lm%delta_eta1
549 offset(2) = lm%eta2_min + real(j - 1, f64)*lm%delta_eta2
551 write (file_id,
"(a,i6,a)")
"<Grid Name='Mesh", k,
"' GridType='Uniform'>"
552 write (file_id,
"(a,2i5,a)") &
553 "<Topology TopologyType='2DSMesh' NumberOfElements='", &
554 this%degree + 1, this%degree + 1,
"'/>"
555 write (file_id,
"(a)")
"<Geometry GeometryType='X_Y'>"
556 write (file_id,
"(a,2i3,a)")
"<DataItem Dimensions='", this%degree + 1, &
557 this%degree + 1,
"' NumberType='Float' Format='XML'>"
558 do jj = 1, this%degree + 1
559 do ii = 1, this%degree + 1
560 eta1 = offset(1) + .5*(this%xgalo(ii) + 1.0_f64)*lm%delta_eta1
561 eta2 = offset(2) + .5*(this%xgalo(jj) + 1.0_f64)*lm%delta_eta2
562 write (file_id,
"(f7.3)", advance=
'no') sngl(this%tau%x1(eta1, eta2))
566 write (file_id,
"(a)")
"</DataItem>"
567 write (file_id,
"(a,2i3,a)")
"<DataItem Dimensions='", this%degree + 1, &
568 this%degree + 1,
"' NumberType='Float' Format='XML'>"
569 do jj = 1, this%degree + 1
570 do ii = 1, this%degree + 1
571 eta1 = offset(1) + .5*(this%xgalo(ii) + 1.0_f64)*lm%delta_eta1
572 eta2 = offset(2) + .5*(this%xgalo(jj) + 1.0_f64)*lm%delta_eta2
573 write (file_id,
"(f7.3)", advance=
'no') sngl(this%tau%x2(eta1, eta2))
577 write (file_id,
"(a)")
"</DataItem>"
578 write (file_id,
"(a)")
"</Geometry>"
579 write (file_id,
"(a)")
"<Attribute Name='values' &
580 & AttributeType='Scalar' Center='Node'>"
581 write (file_id,
"(a,2i3,a)")
"<DataItem Dimensions='", &
582 this%degree + 1, this%degree + 1, &
583 "' NumberType='Float' Precision='4' Format='XML'>"
584 do jj = 1, this%degree + 1
585 do ii = 1, this%degree + 1
586 eta1 = offset(1) + .5_f64*(this%xgalo(ii) + 1._f64)*lm%delta_eta1
587 eta2 = offset(2) + .5_f64*(this%xgalo(jj) + 1._f64)*lm%delta_eta2
588 write (file_id,
"(f7.3)", advance=
'no') sngl(this%array(ii, jj, i, j))
592 write (file_id,
"(a)")
"</DataItem>"
593 write (file_id,
"(a)")
"</Attribute>"
594 write (file_id,
"(a)")
"</Grid>"
597 write (file_id,
"(a)")
"</Grid>"
598 write (file_id,
"(a)")
"</Domain>"
599 write (file_id,
"(a)")
"</Xdmf>"
Module that contains routines to write data in ASCII format file.
subroutine, public sll_s_ascii_file_create(file_name, file_id, error)
Create ASCII file.
Cartesian mesh basic types.
Solve Maxwell equations on cartesian domain with Disconituous Galerkine method:
subroutine write_dg_field_2d_to_file(this, field_name, file_format, time)
subroutine plot_dg_field_2d_with_gmsh(this, field_name)
type(sll_t_dg_field_2d) function dg_field_add(W1, W2)
subroutine plot_dg_field_2d_with_plotmtv(this, field_name)
subroutine, public sll_s_dg_field_2d_init(this, degree, tau, init_function)
subroutine plot_dg_field_2d_with_xdmf(this, field_name, time)
type(sll_t_dg_field_2d) function dg_field_sub(W1, W2)
subroutine set_value_dg_field_2d(this, init_function, time)
subroutine plot_dg_field_2d_with_gnuplot(this, field_name)
type(sll_t_dg_field_2d) function, pointer, public sll_f_new_dg_field_2d(degree, tau, init_function)
Gauss-Lobatto integration.
real(kind=f64) function, dimension(n), public sll_f_gauss_lobatto_points(n, a, b)
Returns a 1d array of size (n) containing gauss-lobatto points in the interval [a,...
real(kind=f64) function, dimension(n), public sll_f_gauss_lobatto_weights(n, a, b)
Returns a 1d array of size (n) containing gauss-lobatto weights in the interval [a,...
Some common numerical utilities.
subroutine, public sll_s_int2string(istep, cstep)
Convert an integer < 9999 to a 4 characters string.
Object to describe field data with DG numerical method.