Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
field_output.f90
Go to the documentation of this file.
1! Copyright (c) 2026, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
35 use num_types, only : rp
36 use field_list, only : field_list_t
39 use output, only : output_t
40 implicit none
41 private
42
44 type, public, extends(output_t) :: field_output_t
46 type(field_list_t) :: fields
47 contains
49 procedure, pass(this) :: init => field_output_init
51 procedure, pass(this) :: free => field_output_free
53 procedure, pass(this) :: sample => field_output_sample
54 end type field_output_t
55
56contains
57
65 subroutine field_output_init(this, name, nfields, precision, path, format)
66 class(field_output_t), intent (inout) :: this
67 character(len=*), intent(in) :: name
68 integer, intent(in) :: nfields
69 integer, intent(in), optional :: precision
70 character(len=*), intent(in), optional :: path
71 character(len=*), intent(in), optional :: format
72 character(len=1024) :: fname, suffix
73
74 call this%free()
75
76 suffix = '.fld'
77 if (present(format)) then
78 select case (trim(format))
79 case ('nek5000', 'fld')
80 suffix = '.fld'
81 case ('vtkhdf')
82 suffix = '.vtkhdf'
83 case ('adios2')
84 suffix = '.bp'
85 case default
86 suffix = '.' // trim(format)
87 end select
88 end if
89
90 if (present(path)) then
91 fname = trim(path) // trim(name) // trim(suffix)
92 else
93 fname = trim(name) // trim(suffix)
94 end if
95
96 call this%init_base(fname, precision)
97
98 call this%fields%init(nfields)
99
100 end subroutine field_output_init
101
103 subroutine field_output_free(this)
104 class(field_output_t), intent(inout) :: this
105
106 call this%free_base()
107 call this%fields%free()
108
109 end subroutine field_output_free
110
113 subroutine field_output_sample(this, t)
114 class(field_output_t), intent(inout) :: this
115 real(kind=rp), intent(in) :: t
116 integer :: i
117
118 if (neko_bcknd_device .eq. 1) then
119 do i = 1, this%fields%size()
120 associate(field => this%fields%items(i)%ptr)
121 call field%copy_from(device_to_host, &
122 sync = i .eq. this%fields%size())
123 end associate
124 end do
125 end if
126
127 call this%file_%write(this%fields, t)
128
129 end subroutine field_output_sample
130
131end module field_output
Copy data between host and device (or device and device)
Definition device.F90:71
Device abstraction, common interface for various accelerators.
Definition device.F90:34
integer, parameter, public device_to_host
Definition device.F90:47
Implements field_output_t.
subroutine field_output_sample(this, t)
Writes the data.
subroutine field_output_init(this, name, nfields, precision, path, format)
Constructor.
subroutine field_output_free(this)
Destructor.
Defines a field.
Definition field.f90:34
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Defines an output.
Definition output.f90:34
field_list_t, To be able to group fields together
A simple output saving a list of fields to a file.
Abstract type defining an output type.
Definition output.f90:41