Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fluid_output.f90
Go to the documentation of this file.
1! Copyright (c) 2020-2023, 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
38 use field_list, only : field_list_t
40 use device
41 use output, only : output_t
42 implicit none
43 private
44
46 type, public, extends(output_t) :: fluid_output_t
47 type(field_list_t) :: fluid
48 contains
49 procedure, pass(this) :: sample => fluid_output_sample
50 procedure, pass(this) :: free => fluid_output_free
51 end type fluid_output_t
52
53 interface fluid_output_t
54 module procedure fluid_output_init
55 end interface fluid_output_t
56
57contains
58
59 function fluid_output_init(precision, fluid, scalar, name, path) result(this)
60 integer, intent(inout) :: precision
61 class(fluid_scheme_t), intent(in), target :: fluid
62 class(scalar_scheme_t), intent(in), optional, target :: scalar
63 character(len=*), intent(in), optional :: name
64 character(len=*), intent(in), optional :: path
65 type(fluid_output_t) :: this
66 character(len=1024) :: fname
67
68 if (present(name) .and. present(path)) then
69 fname = trim(path) // trim(name) // '.fld'
70 else if (present(name)) then
71 fname = trim(name) // '.fld'
72 else if (present(path)) then
73 fname = trim(path) // 'field.fld'
74 else
75 fname = 'field.fld'
76 end if
77
78 call this%init_base(fname, precision)
79
80 if (present(scalar)) then
81 call this%fluid%init(5)
82 else
83 call this%fluid%init(4)
84 end if
85
86 call this%fluid%assign(1, fluid%p)
87 call this%fluid%assign(2, fluid%u)
88 call this%fluid%assign(3, fluid%v)
89 call this%fluid%assign(4, fluid%w)
90
91 if (present(scalar)) then
92 call this%fluid%assign(5, scalar%s)
93 end if
94
95 end function fluid_output_init
96
98 subroutine fluid_output_free(this)
99 class(fluid_output_t), intent(inout) :: this
100
101 call this%fluid%free()
102
103 end subroutine fluid_output_free
104
106 subroutine fluid_output_sample(this, t)
107 class(fluid_output_t), intent(inout) :: this
108 real(kind=rp), intent(in) :: t
109 integer :: i
110
111 if (neko_bcknd_device .eq. 1) then
112
113 associate(fields => this%fluid%items)
114 do i = 1, size(fields)
115 call device_memcpy(fields(i)%ptr%x, fields(i)%ptr%x_d, &
116 fields(i)%ptr%dof%size(), device_to_host, &
117 sync=(i .eq. size(fields))) ! Sync on the last field
118 end do
119 end associate
120
121 end if
122
123 call this%file_%write(this%fluid, t)
124
125 end subroutine fluid_output_sample
126
127end module fluid_output
Copy data between host and device (or device and device)
Definition device.F90:51
Device abstraction, common interface for various accelerators.
Definition device.F90:34
integer, parameter, public device_to_host
Definition device.F90:47
Defines an output for a fluid.
subroutine fluid_output_sample(this, t)
Sample a fluid solution at time t.
subroutine fluid_output_free(this)
Destroy a fluid output list.
type(fluid_output_t) function fluid_output_init(precision, fluid, scalar, name, path)
Fluid formulations.
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
Contains the scalar_scheme_t type.
field_list_t, To be able to group fields together
Base type of all fluid formulations.
Abstract type defining an output type.
Definition output.f90:41
Base type for a scalar advection-diffusion solver.