diagnostics/m_diagnostics_paraview.f90
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | !> @brief Module for ParaView output using VTKFortran (if linked) | ||
| 2 | module m_diagnostics_paraview | ||
| 3 | #include "petsc.fi" | ||
| 4 | use m_common, only: wp | ||
| 5 | #ifdef VTKFORTRAN_IS_LINKED | ||
| 6 | use vtk_fortran | ||
| 7 | #endif | ||
| 8 | |||
| 9 | ! Preprocessor macro for VTK function calls with error checking (similar to PetscCall) | ||
| 10 | ! Automatically handles conditional compilation internally | ||
| 11 | ! | ||
| 12 | ! Usage patterns: | ||
| 13 | ! 1. Single line: VTKCall(func(args)) | ||
| 14 | ! 2. Multi-line with backslash continuation: | ||
| 15 | ! VTKCall(func(arg1, \ | ||
| 16 | ! arg2, \ | ||
| 17 | ! arg3)) | ||
| 18 | #ifdef VTKFORTRAN_IS_LINKED | ||
| 19 | #define VTKCall(vtk_function_call) \ | ||
| 20 | ierr = vtk_function_call; \ | ||
| 21 | if (ierr /= 0) error stop "ParaView VTKFortran error code "//trim(int_to_str(ierr)) | ||
| 22 | #else | ||
| 23 | #define VTKCall(vtk_function_call) | ||
| 24 | #endif | ||
| 25 | |||
| 26 | use m_mform_basis, only: MFormSpace, MFormFun | ||
| 27 | |||
| 28 | implicit none | ||
| 29 | |||
| 30 | private | ||
| 31 | public :: ParaView | ||
| 32 | |||
| 33 | !> ParaView output handler (wraps around VTKFortran if available, otherwise does nothing) | ||
| 34 | type ParaView | ||
| 35 | integer :: current_file_index = 0 | ||
| 36 | character(len=256) :: filename_base | ||
| 37 | logical :: is_initialized = .false. | ||
| 38 | type(MFormSpace) :: space0 | ||
| 39 | |||
| 40 | #ifdef VTKFORTRAN_IS_LINKED | ||
| 41 | !> VTK file from VTKFortran | ||
| 42 | type(vtk_file) :: vtkfile | ||
| 43 | #endif | ||
| 44 | |||
| 45 | contains | ||
| 46 | procedure :: init => paraview_init | ||
| 47 | procedure, private :: paraview_write | ||
| 48 | procedure, private :: paraview_write_multiple | ||
| 49 | generic :: write => paraview_write, paraview_write_multiple | ||
| 50 | procedure :: destroy => paraview_destroy | ||
| 51 | ! Private helper methods | ||
| 52 | procedure, private :: write_single_field => paraview_write_single_field | ||
| 53 | end type ParaView | ||
| 54 | |||
| 55 | contains | ||
| 56 | |||
| 57 | #ifdef VTKFORTRAN_IS_LINKED | ||
| 58 | !> Convert integer to string for error messages | ||
| 59 | ✗ | pure function int_to_str(i) result(int_str) | |
| 60 | integer, intent(in) :: i | ||
| 61 | character(len=20) :: int_str | ||
| 62 | ✗ | write (int_str, '(I0)') i | |
| 63 | ✗ | end function int_to_str | |
| 64 | #endif | ||
| 65 | |||
| 66 | !> @brief Initialize ParaView output | ||
| 67 | !> | ||
| 68 | !> @param[in] this ParaView object | ||
| 69 | !> @param[in] filename Base name for output files | ||
| 70 | !> @param[in] space0 The space of 0-forms for which data will be written | ||
| 71 | 2 | subroutine paraview_init(this, filename, space0) | |
| 72 | class(ParaView), intent(inout) :: this | ||
| 73 | character(len=*), intent(in) :: filename | ||
| 74 | type(MFormSpace), intent(in) :: space0 | ||
| 75 | |||
| 76 | 2 | this%filename_base = filename | |
| 77 | 2 | this%current_file_index = 0 | |
| 78 |
5/8✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 9 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 8 not taken.
✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 12 not taken.
✓ Branch 10 → 11 taken 1 time.
✓ Branch 10 → 12 taken 1 time.
|
2 | this%space0 = space0 |
| 79 | 2 | this%is_initialized = .true. | |
| 80 | #ifndef VTKFORTRAN_IS_LINKED | ||
| 81 | write (*, *) "ParaView::init: VTKFortran not linked, cannot initialize ParaView output." | ||
| 82 | #endif | ||
| 83 | |||
| 84 |
1/2✓ Branch 2 → 3 taken 2 times.
✗ Branch 2 → 4 not taken.
|
2 | end subroutine paraview_init |
| 85 | |||
| 86 | !> @brief Write a single field to an already initialized VTK file | ||
| 87 | !> | ||
| 88 | !> @param[in] this ParaView object | ||
| 89 | !> @param[in] mfun The field function to evaluate and write (contains its own name) | ||
| 90 | !> @param[in] nx1, nx2, ny1, ny2, nz1, nz2 Array bounds | ||
| 91 | !> @param[in] xp_coords Logical coordinates for evaluation | ||
| 92 | !> @param[in] yp_coords Logical coordinates for evaluation | ||
| 93 | !> @param[in] zp_coords Logical coordinates for evaluation | ||
| 94 | !> @param[in] coord_transform _(optional)_ The coordinate transformation associated with the m-form | ||
| 95 | 8 | subroutine paraview_write_single_field(this, mfun, nx1, nx2, ny1, ny2, nz1, nz2, & | |
| 96 | 8 | xp_coords, yp_coords, zp_coords, coord_transform) | |
| 97 | use m_mform, only: evaluate | ||
| 98 | use m_coord_transform_abstract, only: CoordTransformAbstract | ||
| 99 | |||
| 100 | class(ParaView), intent(inout) :: this | ||
| 101 | type(MFormFun), intent(in) :: mfun | ||
| 102 | integer, intent(in) :: nx1, nx2, ny1, ny2, nz1, nz2 | ||
| 103 | real(wp), intent(in) :: xp_coords(nx1:nx2, ny1:ny2, nz1:nz2) | ||
| 104 | real(wp), intent(in) :: yp_coords(nx1:nx2, ny1:ny2, nz1:nz2) | ||
| 105 | real(wp), intent(in) :: zp_coords(nx1:nx2, ny1:ny2, nz1:nz2) | ||
| 106 | class(CoordTransformAbstract), optional, intent(in) :: coord_transform | ||
| 107 | |||
| 108 | 8 | real(wp), allocatable :: data_values(:, :, :) | |
| 109 | 8 | real(wp), allocatable :: data_values_x(:, :, :), data_values_y(:, :, :), data_values_z(:, :, :) | |
| 110 | |||
| 111 | integer :: i, j, k, ierr | ||
| 112 | |||
| 113 |
2/2✓ Branch 2 → 3 taken 4 times.
✓ Branch 2 → 39 taken 4 times.
|
8 | if (mfun%space%m == 0 .or. mfun%space%m == 3) then |
| 114 | ! Allocate data for this field | ||
| 115 |
10/20✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 4 times.
✓ Branch 5 → 4 taken 4 times.
✗ Branch 5 → 6 not taken.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 4 times.
✓ Branch 8 → 7 taken 4 times.
✗ Branch 8 → 9 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 4 times.
✓ Branch 11 → 10 taken 4 times.
✗ Branch 11 → 12 not taken.
✓ Branch 12 → 13 taken 4 times.
✗ Branch 12 → 14 not taken.
✓ Branch 14 → 15 taken 4 times.
✗ Branch 14 → 16 not taken.
✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 4 times.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 4 times.
|
20 | allocate (data_values(nx1:nx2, ny1:ny2, nz1:nz2)) |
| 116 | |||
| 117 | ! Evaluate field at all points | ||
| 118 |
6/6✓ Branch 21 → 22 taken 68 times.
✓ Branch 21 → 28 taken 4 times.
✓ Branch 22 → 23 taken 612 times.
✓ Branch 22 → 27 taken 68 times.
✓ Branch 23 → 24 taken 10404 times.
✓ Branch 23 → 25 taken 612 times.
|
11088 | do k = nz1, nz2; do j = ny1, ny2; do i = nx1, nx2 |
| 119 | data_values(i, j, k) = evaluate(mfun, xp_coords(i, j, k), yp_coords(i, j, k), zp_coords(i, j, k), & | ||
| 120 | 11016 | coord_transform=coord_transform) | |
| 121 | end do; end do; end do | ||
| 122 | |||
| 123 | ! Write this field's data to VTK | ||
| 124 |
1/4✗ Branch 29 → 30 not taken.
✓ Branch 29 → 36 taken 4 times.
✗ Branch 33 → 34 not taken.
✗ Branch 33 → 35 not taken.
|
4 | VTKCall(this%vtkfile%xml_writer%write_dataarray(data_name=trim(mfun%name), x=data_values, one_component=.true.)) |
| 125 | |||
| 126 |
1/2✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 4 times.
|
4 | deallocate (data_values) |
| 127 | else | ||
| 128 | ! Allocate data for vector field | ||
| 129 |
10/20✗ Branch 39 → 40 not taken.
✓ Branch 39 → 41 taken 4 times.
✓ Branch 41 → 40 taken 4 times.
✗ Branch 41 → 42 not taken.
✗ Branch 42 → 43 not taken.
✓ Branch 42 → 44 taken 4 times.
✓ Branch 44 → 43 taken 4 times.
✗ Branch 44 → 45 not taken.
✗ Branch 45 → 46 not taken.
✓ Branch 45 → 47 taken 4 times.
✓ Branch 47 → 46 taken 4 times.
✗ Branch 47 → 48 not taken.
✓ Branch 48 → 49 taken 4 times.
✗ Branch 48 → 50 not taken.
✓ Branch 50 → 51 taken 4 times.
✗ Branch 50 → 52 not taken.
✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 4 times.
✗ Branch 54 → 55 not taken.
✓ Branch 54 → 56 taken 4 times.
|
20 | allocate (data_values_x(nx1:nx2, ny1:ny2, nz1:nz2)) |
| 130 |
8/16✗ Branch 56 → 57 not taken.
✓ Branch 56 → 58 taken 4 times.
✓ Branch 58 → 57 taken 4 times.
✗ Branch 58 → 59 not taken.
✗ Branch 59 → 60 not taken.
✓ Branch 59 → 61 taken 4 times.
✓ Branch 61 → 60 taken 4 times.
✗ Branch 61 → 62 not taken.
✗ Branch 62 → 63 not taken.
✓ Branch 62 → 64 taken 4 times.
✓ Branch 64 → 63 taken 4 times.
✗ Branch 64 → 65 not taken.
✗ Branch 65 → 66 not taken.
✓ Branch 65 → 67 taken 4 times.
✗ Branch 67 → 68 not taken.
✓ Branch 67 → 69 taken 4 times.
|
16 | allocate (data_values_y(nx1:nx2, ny1:ny2, nz1:nz2)) |
| 131 |
8/16✗ Branch 69 → 70 not taken.
✓ Branch 69 → 71 taken 4 times.
✓ Branch 71 → 70 taken 4 times.
✗ Branch 71 → 72 not taken.
✗ Branch 72 → 73 not taken.
✓ Branch 72 → 74 taken 4 times.
✓ Branch 74 → 73 taken 4 times.
✗ Branch 74 → 75 not taken.
✗ Branch 75 → 76 not taken.
✓ Branch 75 → 77 taken 4 times.
✓ Branch 77 → 76 taken 4 times.
✗ Branch 77 → 78 not taken.
✗ Branch 78 → 79 not taken.
✓ Branch 78 → 80 taken 4 times.
✗ Branch 80 → 81 not taken.
✓ Branch 80 → 82 taken 4 times.
|
16 | allocate (data_values_z(nx1:nx2, ny1:ny2, nz1:nz2)) |
| 132 | |||
| 133 |
6/6✓ Branch 83 → 84 taken 68 times.
✓ Branch 83 → 90 taken 4 times.
✓ Branch 84 → 85 taken 612 times.
✓ Branch 84 → 89 taken 68 times.
✓ Branch 85 → 86 taken 10404 times.
✓ Branch 85 → 87 taken 612 times.
|
11088 | do k = nz1, nz2; do j = ny1, ny2; do i = nx1, nx2 |
| 134 | data_values_x(i, j, k) = evaluate(mfun, 1, xp_coords(i, j, k), yp_coords(i, j, k), zp_coords(i, j, k), & | ||
| 135 | 10404 | coord_transform=coord_transform) | |
| 136 | data_values_y(i, j, k) = evaluate(mfun, 2, xp_coords(i, j, k), yp_coords(i, j, k), zp_coords(i, j, k), & | ||
| 137 | 10404 | coord_transform=coord_transform) | |
| 138 | data_values_z(i, j, k) = evaluate(mfun, 3, xp_coords(i, j, k), yp_coords(i, j, k), zp_coords(i, j, k), & | ||
| 139 | 11016 | coord_transform=coord_transform) | |
| 140 | end do; end do; end do | ||
| 141 | |||
| 142 | ! Write vector field to VTK | ||
| 143 |
1/4✗ Branch 91 → 92 not taken.
✓ Branch 91 → 98 taken 4 times.
✗ Branch 95 → 96 not taken.
✗ Branch 95 → 97 not taken.
|
4 | VTKCall(this%vtkfile%xml_writer%write_dataarray(data_name=trim(mfun%name), \ |
| 144 | x = data_values_x, y = data_values_y, z = data_values_z)) | ||
| 145 | |||
| 146 |
3/6✗ Branch 98 → 99 not taken.
✓ Branch 98 → 100 taken 4 times.
✗ Branch 100 → 101 not taken.
✓ Branch 100 → 102 taken 4 times.
✗ Branch 102 → 103 not taken.
✓ Branch 102 → 104 taken 4 times.
|
4 | deallocate (data_values_x, data_values_y, data_values_z) |
| 147 | end if | ||
| 148 | |||
| 149 |
4/8✗ Branch 105 → 106 not taken.
✓ Branch 105 → 107 taken 8 times.
✗ Branch 107 → 108 not taken.
✓ Branch 107 → 109 taken 8 times.
✗ Branch 109 → 110 not taken.
✓ Branch 109 → 111 taken 8 times.
✗ Branch 111 → 112 not taken.
✓ Branch 111 → 113 taken 8 times.
|
8 | end subroutine paraview_write_single_field |
| 150 | |||
| 151 | !> @brief Write m-form data to a new VTK file | ||
| 152 | !> | ||
| 153 | !> @param[in] this ParaView object | ||
| 154 | !> @param[in] mfun The m-form function to evaluate and write to file | ||
| 155 | !> @param[in] coord_transform _(optional)_ The coordinate transformation associated with the m-form | ||
| 156 | !> @param[in] time _(optional)_ time value to include in output | ||
| 157 | !> @param[in] refine _(optional)_ refinement level in all directions (overrides per direction) for output | ||
| 158 | !> @param[in] refine_x _(optional)_ refinement level in the x-direction for output | ||
| 159 | !> @param[in] refine_y _(optional)_ refinement level in the y-direction for output | ||
| 160 | !> @param[in] refine_z _(optional)_ refinement level in the z-direction for output | ||
| 161 | 4 | subroutine paraview_write(this, mfun, coord_transform, time, refine, refine_x, refine_y, refine_z) | |
| 162 | use m_mform, only: get_coords | ||
| 163 | use m_coord_transform_abstract, only: CoordTransformAbstract | ||
| 164 | |||
| 165 | class(ParaView), intent(inout) :: this | ||
| 166 | type(MFormFun), intent(in) :: mfun | ||
| 167 | class(CoordTransformAbstract), optional, intent(in) :: coord_transform | ||
| 168 | real(wp), intent(in), optional :: time | ||
| 169 | integer, intent(in), optional :: refine, refine_x, refine_y, refine_z | ||
| 170 | |||
| 171 | integer :: ierr | ||
| 172 | character(len=256) :: filename | ||
| 173 | 4 | real(wp), allocatable :: x_coords(:, :, :), y_coords(:, :, :), z_coords(:, :, :) | |
| 174 | 4 | real(wp), allocatable :: xp_coords(:, :, :), yp_coords(:, :, :), zp_coords(:, :, :) | |
| 175 | integer :: nx1, nx2, ny1, ny2, nz1, nz2, sze_tmp | ||
| 176 | |||
| 177 | integer :: refine_x_, refine_y_, refine_z_ | ||
| 178 | |||
| 179 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 4 times.
|
4 | if (.not. this%is_initialized) error stop "ParaView::paraview_write: object not initialized." |
| 180 | |||
| 181 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 4 times.
|
4 | if (present(refine)) then |
| 182 | ✗ | refine_x_ = refine | |
| 183 | ✗ | refine_y_ = refine | |
| 184 | ✗ | refine_z_ = refine | |
| 185 | else | ||
| 186 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 4 times.
|
4 | if (present(refine_x)) then |
| 187 | ✗ | refine_x_ = refine_x | |
| 188 | else | ||
| 189 | 4 | refine_x_ = 0 | |
| 190 | end if | ||
| 191 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 4 times.
|
4 | if (present(refine_y)) then |
| 192 | ✗ | refine_y_ = refine_y | |
| 193 | else | ||
| 194 | 4 | refine_y_ = 0 | |
| 195 | end if | ||
| 196 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 4 times.
|
4 | if (present(refine_z)) then |
| 197 | ✗ | refine_z_ = refine_z | |
| 198 | else | ||
| 199 | 4 | refine_z_ = 0 | |
| 200 | end if | ||
| 201 | end if | ||
| 202 | |||
| 203 | 4 | write (filename, '(A,I5.5,A)') trim(this%filename_base), this%current_file_index, '.vtu' | |
| 204 | |||
| 205 |
1/2✓ Branch 20 → 21 taken 4 times.
✗ Branch 20 → 110 not taken.
|
4 | if (mfun%tp_funs(1)%shmem_window%leader()) then |
| 206 | ! Get coordinates | ||
| 207 | call get_coords(this%space0, x_coords, y_coords, z_coords, & | ||
| 208 | 4 | refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, coord_transform=coord_transform, node_based=.true.) | |
| 209 | call get_coords(this%space0, xp_coords, yp_coords, zp_coords, & | ||
| 210 | 4 | refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, node_based=.true.) | |
| 211 | |||
| 212 |
2/4✓ Branch 23 → 24 taken 4 times.
✗ Branch 23 → 25 not taken.
✓ Branch 25 → 26 taken 4 times.
✗ Branch 25 → 27 not taken.
|
8 | nx1 = lbound(x_coords, 1); nx2 = ubound(x_coords, 1) |
| 213 |
2/4✓ Branch 27 → 28 taken 4 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 4 times.
✗ Branch 29 → 31 not taken.
|
8 | ny1 = lbound(x_coords, 2); ny2 = ubound(x_coords, 2) |
| 214 |
2/4✓ Branch 31 → 32 taken 4 times.
✗ Branch 31 → 33 not taken.
✓ Branch 33 → 34 taken 4 times.
✗ Branch 33 → 35 not taken.
|
8 | nz1 = lbound(x_coords, 3); nz2 = ubound(x_coords, 3) |
| 215 | |||
| 216 |
1/2✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 4 times.
|
4 | if (mfun%space%dimensionality == 2) then |
| 217 | ✗ | nz2 = nz1 ! For 2D spaces, only one layer in z-direction | |
| 218 | ✗ | refine_z_ = 0 | |
| 219 | end if | ||
| 220 | |||
| 221 | ! Initialize VTK file | ||
| 222 |
1/4✗ Branch 38 → 39 not taken.
✓ Branch 38 → 45 taken 4 times.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 44 not taken.
|
4 | VTKCall(this%vtkfile%initialize(format='BINARY', \ |
| 223 | filename = trim(filename), \ | ||
| 224 | mesh_topology = 'StructuredGrid', \ | ||
| 225 | is_volatile = .false., \ | ||
| 226 | nx1 = nx1, nx2 = nx2, \ | ||
| 227 | ny1 = ny1, ny2 = ny2, \ | ||
| 228 | nz1 = nz1, nz2 = nz2)) | ||
| 229 | |||
| 230 | ! Write geometry and open dataarray section | ||
| 231 |
1/4✗ Branch 46 → 47 not taken.
✓ Branch 46 → 54 taken 4 times.
✗ Branch 50 → 51 not taken.
✗ Branch 50 → 52 not taken.
|
4 | VTKCall(this%vtkfile%xml_writer%write_piece(nx1=nx1, nx2=nx2, ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2)) |
| 232 |
2/2✓ Branch 54 → 53 taken 12 times.
✓ Branch 54 → 55 taken 4 times.
|
16 | sze_tmp = size(x_coords) ! NOTE: this is a workaround to avoid a NVHPC compiler bug: |
| 233 | ! https://forums.developer.nvidia.com/t/compiler-bug-allocatable-polymorphic-types-with-tbps-acting-on-allocatable-array | ||
| 234 |
1/4✗ Branch 56 → 57 not taken.
✓ Branch 56 → 63 taken 4 times.
✗ Branch 60 → 61 not taken.
✗ Branch 60 → 62 not taken.
|
4 | VTKCall(this%vtkfile%xml_writer%write_geo(n=sze_tmp, x=x_coords, y=y_coords, z=z_coords)) |
| 235 |
1/4✗ Branch 64 → 65 not taken.
✓ Branch 64 → 71 taken 4 times.
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 70 not taken.
|
4 | VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='open')) |
| 236 | |||
| 237 | ! Write single field using helper method | ||
| 238 | call this%write_single_field(mfun, nx1, nx2, ny1, ny2, nz1, nz2, & | ||
| 239 | 4 | xp_coords, yp_coords, zp_coords, coord_transform=coord_transform) | |
| 240 | |||
| 241 | ! Close dataarray section and finalize | ||
| 242 |
1/4✗ Branch 73 → 74 not taken.
✓ Branch 73 → 80 taken 4 times.
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 79 not taken.
|
4 | VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='close')) |
| 243 |
1/4✗ Branch 81 → 82 not taken.
✓ Branch 81 → 88 taken 4 times.
✗ Branch 85 → 86 not taken.
✗ Branch 85 → 87 not taken.
|
4 | VTKCall(this%vtkfile%xml_writer%write_piece()) |
| 244 |
1/4✗ Branch 89 → 90 not taken.
✓ Branch 89 → 96 taken 4 times.
✗ Branch 93 → 94 not taken.
✗ Branch 93 → 95 not taken.
|
4 | VTKCall(this%vtkfile%finalize()) |
| 245 | |||
| 246 | #ifdef VTKFORTRAN_IS_LINKED | ||
| 247 | 4 | call this%vtkfile%free() | |
| 248 | #endif | ||
| 249 | |||
| 250 |
3/6✗ Branch 97 → 98 not taken.
✓ Branch 97 → 99 taken 4 times.
✗ Branch 99 → 100 not taken.
✓ Branch 99 → 101 taken 4 times.
✗ Branch 101 → 102 not taken.
✓ Branch 101 → 103 taken 4 times.
|
4 | deallocate (x_coords, y_coords, z_coords) |
| 251 |
3/6✗ Branch 103 → 104 not taken.
✓ Branch 103 → 105 taken 4 times.
✗ Branch 105 → 106 not taken.
✓ Branch 105 → 107 taken 4 times.
✗ Branch 107 → 108 not taken.
✓ Branch 107 → 109 taken 4 times.
|
4 | deallocate (xp_coords, yp_coords, zp_coords) |
| 252 | end if | ||
| 253 | |||
| 254 |
1/2✗ Branch 111 → 112 not taken.
✓ Branch 111 → 115 taken 4 times.
|
4 | PetscCallMPI(MPI_Barrier(this%space0%tp_spaces(1)%domain%comm, ierr)) |
| 255 | |||
| 256 | 4 | this%current_file_index = this%current_file_index + 1 | |
| 257 |
6/24✗ Branch 113 → 114 not taken.
✗ Branch 113 → 127 not taken.
✗ Branch 115 → 116 not taken.
✓ Branch 115 → 117 taken 4 times.
✗ Branch 117 → 118 not taken.
✓ Branch 117 → 119 taken 4 times.
✗ Branch 119 → 120 not taken.
✓ Branch 119 → 121 taken 4 times.
✗ Branch 121 → 122 not taken.
✓ Branch 121 → 123 taken 4 times.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 4 times.
✗ Branch 125 → 126 not taken.
✓ Branch 125 → 148 taken 4 times.
✗ Branch 129 → 130 not taken.
✗ Branch 129 → 131 not taken.
✗ Branch 133 → 134 not taken.
✗ Branch 133 → 135 not taken.
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 139 not taken.
✗ Branch 141 → 142 not taken.
✗ Branch 141 → 143 not taken.
✗ Branch 145 → 146 not taken.
✗ Branch 145 → 149 not taken.
|
4 | end subroutine paraview_write |
| 258 | |||
| 259 | !> @brief Write multiple fields to a new VTK file | ||
| 260 | !> | ||
| 261 | !> @param[in] this ParaView object | ||
| 262 | !> @param[in] mfuns Array of m-form functions to evaluate and write to file | ||
| 263 | !> @param[in] coord_transform _(optional)_ The coordinate transformation associated with the m-forms | ||
| 264 | !> @param[in] time _(optional)_ time value to include in output | ||
| 265 | !> @param[in] refine _(optional)_ refinement level in all directions (overrides per direction) for output | ||
| 266 | !> @param[in] refine_x _(optional)_ refinement level in the x-direction for output | ||
| 267 | !> @param[in] refine_y _(optional)_ refinement level in the y-direction for output | ||
| 268 | !> @param[in] refine_z _(optional)_ refinement level in the z-direction for output | ||
| 269 |
1/2✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 1 time.
|
1 | subroutine paraview_write_multiple(this, mfuns, coord_transform, time, refine, refine_x, refine_y, refine_z) |
| 270 | use m_mform, only: get_coords | ||
| 271 | use m_coord_transform_abstract, only: CoordTransformAbstract | ||
| 272 | |||
| 273 | class(ParaView), intent(inout) :: this | ||
| 274 | type(MFormFun), intent(in) :: mfuns(:) ! Multiple fields (e.g., E-field, B-field) | ||
| 275 | class(CoordTransformAbstract), optional, intent(in) :: coord_transform | ||
| 276 | real(wp), intent(in), optional :: time | ||
| 277 | integer, intent(in), optional :: refine, refine_x, refine_y, refine_z | ||
| 278 | |||
| 279 | integer :: ierr, field_idx | ||
| 280 | character(len=256) :: filename | ||
| 281 | 1 | real(wp), allocatable :: x_coords(:, :, :), y_coords(:, :, :), z_coords(:, :, :) | |
| 282 | 1 | real(wp), allocatable :: xp_coords(:, :, :), yp_coords(:, :, :), zp_coords(:, :, :) | |
| 283 | integer :: nx1, nx2, ny1, ny2, nz1, nz2, sze_tmp | ||
| 284 | |||
| 285 | integer :: refine_x_, refine_y_, refine_z_ | ||
| 286 | |||
| 287 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 1 time.
|
1 | if (.not. this%is_initialized) error stop "ParaView::paraview_write_multiple: object not initialized." |
| 288 | |||
| 289 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 1 time.
|
1 | if (present(refine)) then |
| 290 | ✗ | refine_x_ = refine | |
| 291 | ✗ | refine_y_ = refine | |
| 292 | ✗ | refine_z_ = refine | |
| 293 | else | ||
| 294 |
1/2✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 1 time.
|
1 | if (present(refine_x)) then |
| 295 | ✗ | refine_x_ = refine_x | |
| 296 | else | ||
| 297 | 1 | refine_x_ = 0 | |
| 298 | end if | ||
| 299 |
1/2✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 1 time.
|
1 | if (present(refine_y)) then |
| 300 | ✗ | refine_y_ = refine_y | |
| 301 | else | ||
| 302 | 1 | refine_y_ = 0 | |
| 303 | end if | ||
| 304 |
1/2✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 1 time.
|
1 | if (present(refine_z)) then |
| 305 | ✗ | refine_z_ = refine_z | |
| 306 | else | ||
| 307 | 1 | refine_z_ = 0 | |
| 308 | end if | ||
| 309 | end if | ||
| 310 | |||
| 311 |
1/2✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 114 not taken.
|
1 | if (mfuns(1)%tp_funs(1)%shmem_window%leader()) then |
| 312 | |||
| 313 | 1 | write (filename, '(A,I5.5,A)') trim(this%filename_base), this%current_file_index, '.vtu' | |
| 314 | |||
| 315 | ! Get coordinates once (geometry is shared by all fields) | ||
| 316 | call get_coords(this%space0, x_coords, y_coords, z_coords, & | ||
| 317 | 1 | refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, coord_transform=coord_transform, node_based=.true.) | |
| 318 | call get_coords(this%space0, xp_coords, yp_coords, zp_coords, & | ||
| 319 | 1 | refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, node_based=.true.) | |
| 320 | |||
| 321 |
2/4✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 27 not taken.
✓ Branch 27 → 28 taken 1 time.
✗ Branch 27 → 29 not taken.
|
2 | nx1 = lbound(x_coords, 1); nx2 = ubound(x_coords, 1) |
| 322 |
2/4✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 31 not taken.
✓ Branch 31 → 32 taken 1 time.
✗ Branch 31 → 33 not taken.
|
2 | ny1 = lbound(x_coords, 2); ny2 = ubound(x_coords, 2) |
| 323 |
2/4✓ Branch 33 → 34 taken 1 time.
✗ Branch 33 → 35 not taken.
✓ Branch 35 → 36 taken 1 time.
✗ Branch 35 → 37 not taken.
|
2 | nz1 = lbound(x_coords, 3); nz2 = ubound(x_coords, 3) |
| 324 | |||
| 325 | ! Initialize VTK file once | ||
| 326 |
1/4✗ Branch 38 → 39 not taken.
✓ Branch 38 → 45 taken 1 time.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 44 not taken.
|
1 | VTKCall(this%vtkfile%initialize(format='BINARY', \ |
| 327 | filename = trim(filename), \ | ||
| 328 | mesh_topology = 'StructuredGrid', \ | ||
| 329 | is_volatile = .false., \ | ||
| 330 | nx1 = nx1, nx2 = nx2, \ | ||
| 331 | ny1 = ny1, ny2 = ny2, \ | ||
| 332 | nz1 = nz1, nz2 = nz2)) | ||
| 333 | |||
| 334 | ! Write geometry once | ||
| 335 |
1/4✗ Branch 46 → 47 not taken.
✓ Branch 46 → 54 taken 1 time.
✗ Branch 50 → 51 not taken.
✗ Branch 50 → 52 not taken.
|
1 | VTKCall(this%vtkfile%xml_writer%write_piece(nx1=nx1, nx2=nx2, ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2)) |
| 336 |
2/2✓ Branch 54 → 53 taken 3 times.
✓ Branch 54 → 55 taken 1 time.
|
4 | sze_tmp = size(x_coords) |
| 337 |
1/4✗ Branch 56 → 57 not taken.
✓ Branch 56 → 63 taken 1 time.
✗ Branch 60 → 61 not taken.
✗ Branch 60 → 62 not taken.
|
1 | VTKCall(this%vtkfile%xml_writer%write_geo(n=sze_tmp, x=x_coords, y=y_coords, z=z_coords)) |
| 338 | |||
| 339 | ! Open dataarray section | ||
| 340 |
1/4✗ Branch 64 → 65 not taken.
✓ Branch 64 → 71 taken 1 time.
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 70 not taken.
|
1 | VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='open')) |
| 341 | |||
| 342 | ! Write all fields using helper method | ||
| 343 |
2/2✓ Branch 72 → 73 taken 4 times.
✓ Branch 72 → 75 taken 1 time.
|
5 | do field_idx = 1, size(mfuns) |
| 344 | ! Write this field using helper method (uses mfun%name internally) | ||
| 345 | call this%write_single_field(mfuns(field_idx), & | ||
| 346 | nx1, nx2, ny1, ny2, nz1, nz2, & | ||
| 347 | 5 | xp_coords, yp_coords, zp_coords, coord_transform=coord_transform) | |
| 348 | end do | ||
| 349 | |||
| 350 | ! Close dataarray section and finalize | ||
| 351 |
1/4✗ Branch 77 → 78 not taken.
✓ Branch 77 → 84 taken 1 time.
✗ Branch 81 → 82 not taken.
✗ Branch 81 → 83 not taken.
|
1 | VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='close')) |
| 352 |
1/4✗ Branch 85 → 86 not taken.
✓ Branch 85 → 92 taken 1 time.
✗ Branch 89 → 90 not taken.
✗ Branch 89 → 91 not taken.
|
1 | VTKCall(this%vtkfile%xml_writer%write_piece()) |
| 353 |
1/4✗ Branch 93 → 94 not taken.
✓ Branch 93 → 100 taken 1 time.
✗ Branch 97 → 98 not taken.
✗ Branch 97 → 99 not taken.
|
1 | VTKCall(this%vtkfile%finalize()) |
| 354 | |||
| 355 | #ifdef VTKFORTRAN_IS_LINKED | ||
| 356 | 1 | call this%vtkfile%free() | |
| 357 | #endif | ||
| 358 | |||
| 359 |
3/6✗ Branch 101 → 102 not taken.
✓ Branch 101 → 103 taken 1 time.
✗ Branch 103 → 104 not taken.
✓ Branch 103 → 105 taken 1 time.
✗ Branch 105 → 106 not taken.
✓ Branch 105 → 107 taken 1 time.
|
1 | deallocate (x_coords, y_coords, z_coords) |
| 360 |
3/6✗ Branch 107 → 108 not taken.
✓ Branch 107 → 109 taken 1 time.
✗ Branch 109 → 110 not taken.
✓ Branch 109 → 111 taken 1 time.
✗ Branch 111 → 112 not taken.
✓ Branch 111 → 113 taken 1 time.
|
1 | deallocate (xp_coords, yp_coords, zp_coords) |
| 361 | end if | ||
| 362 | |||
| 363 |
1/2✗ Branch 115 → 116 not taken.
✓ Branch 115 → 119 taken 1 time.
|
1 | PetscCallMPI(MPI_Barrier(this%space0%tp_spaces(1)%domain%comm, ierr)) |
| 364 | |||
| 365 | 1 | this%current_file_index = this%current_file_index + 1 | |
| 366 |
6/24✗ Branch 117 → 118 not taken.
✗ Branch 117 → 131 not taken.
✗ Branch 119 → 120 not taken.
✓ Branch 119 → 121 taken 1 time.
✗ Branch 121 → 122 not taken.
✓ Branch 121 → 123 taken 1 time.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 1 time.
✗ Branch 125 → 126 not taken.
✓ Branch 125 → 127 taken 1 time.
✗ Branch 127 → 128 not taken.
✓ Branch 127 → 129 taken 1 time.
✗ Branch 129 → 130 not taken.
✓ Branch 129 → 152 taken 1 time.
✗ Branch 133 → 134 not taken.
✗ Branch 133 → 135 not taken.
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 139 not taken.
✗ Branch 141 → 142 not taken.
✗ Branch 141 → 143 not taken.
✗ Branch 145 → 146 not taken.
✗ Branch 145 → 147 not taken.
✗ Branch 149 → 150 not taken.
✗ Branch 149 → 153 not taken.
|
1 | end subroutine paraview_write_multiple |
| 367 | |||
| 368 | 2 | subroutine paraview_destroy(this) | |
| 369 | class(ParaView), intent(inout) :: this | ||
| 370 | |||
| 371 | integer :: ierr | ||
| 372 | |||
| 373 | 2 | this%is_initialized = .false. | |
| 374 | 2 | end subroutine paraview_destroy | |
| 375 | |||
| 376 | ✗ | end module m_diagnostics_paraview | |
| 377 |