Loading [MathJax]/extensions/tex2jax.js
Neko 0.9.99
A portable framework for high-order spectral element flow simulations
All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Pages
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
39 use field_list, only : field_list_t
41 use device
42 use output, only : output_t
43 implicit none
44 private
45
47 type, public, extends(output_t) :: fluid_output_t
48 type(field_list_t) :: fluid
49 contains
50 procedure, pass(this) :: init => fluid_output_init
51 procedure, pass(this) :: sample => fluid_output_sample
52 procedure, pass(this) :: free => fluid_output_free
53 end type fluid_output_t
54
55contains
56
57 subroutine fluid_output_init(this, precision, fluid, scalar, name, path)
58 class(fluid_output_t), intent(inout) :: this
59 integer, intent(inout) :: precision
60 class(fluid_scheme_base_t), intent(in), target :: fluid
61 class(scalar_scheme_t), intent(in), optional, target :: scalar
62 character(len=*), intent(in), optional :: name
63 character(len=*), intent(in), optional :: path
64 character(len=1024) :: fname
65
66 if (present(name) .and. present(path)) then
67 fname = trim(path) // trim(name) // '.fld'
68 else if (present(name)) then
69 fname = trim(name) // '.fld'
70 else if (present(path)) then
71 fname = trim(path) // 'field.fld'
72 else
73 fname = 'field.fld'
74 end if
75
76 call this%init_base(fname, precision)
77
78 if (present(scalar)) then
79 call this%fluid%init(5)
80 else
81 call this%fluid%init(4)
82 end if
83
84 call this%fluid%assign(1, fluid%p)
85 call this%fluid%assign(2, fluid%u)
86 call this%fluid%assign(3, fluid%v)
87 call this%fluid%assign(4, fluid%w)
88
89 if (present(scalar)) then
90 call this%fluid%assign(5, scalar%s)
91 end if
92
93 end subroutine fluid_output_init
94
96 subroutine fluid_output_free(this)
97 class(fluid_output_t), intent(inout) :: this
98
99 call this%fluid%free()
100
101 end subroutine fluid_output_free
102
104 subroutine fluid_output_sample(this, t)
105 class(fluid_output_t), intent(inout) :: this
106 real(kind=rp), intent(in) :: t
107 integer :: i
108
109 if (neko_bcknd_device .eq. 1) then
110
111 associate(fields => this%fluid%items)
112 do i = 1, size(fields)
113 call device_memcpy(fields(i)%ptr%x, fields(i)%ptr%x_d, &
114 fields(i)%ptr%dof%size(), device_to_host, &
115 sync=(i .eq. size(fields))) ! Sync on the last field
116 end do
117 end associate
118
119 end if
120
121 call this%file_%write(this%fluid, t)
122
123 end subroutine fluid_output_sample
124
125end module fluid_output
Copy data between host and device (or device and device)
Definition device.F90:65
Device abstraction, common interface for various accelerators.
Definition device.F90:34
integer, parameter, public device_to_host
Definition device.F90:46
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.
subroutine fluid_output_init(this, precision, fluid, scalar, name, path)
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.