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
vorticity.f90
Go to the documentation of this file.
1! Copyright (c) 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!
33!
35
37 use num_types, only : rp, dp, sp
38 use json_module, only : json_file
41 use field, only : field_t
42 use time_state, only : time_state_t
43 use operators, only : curl
44 use case, only : case_t
48 use device, only : glb_cmd_event
49 implicit none
50 private
51
54 type, public, extends(simulation_component_t) :: vorticity_t
56 type(field_t), pointer :: u
58 type(field_t), pointer :: v
60 type(field_t), pointer :: w
61
63 type(field_t), pointer :: omega_x
65 type(field_t), pointer :: omega_y
67 type(field_t), pointer :: omega_z
68
70 type(field_t) :: temp1
72 type(field_t) :: temp2
73
75 type(field_writer_t) :: writer
76
77 contains
79 procedure, pass(this) :: init => vorticity_init_from_json
81 procedure, pass(this) :: init_from_components => &
84 procedure, pass(this) :: free => vorticity_free
86 procedure, pass(this) :: compute_ => vorticity_compute
87 end type vorticity_t
88
89contains
90
92 subroutine vorticity_init_from_json(this, json, case)
93 class(vorticity_t), intent(inout) :: this
94 type(json_file), intent(inout) :: json
95 class(case_t), intent(inout), target :: case
96 character(len=20) :: fields(3)
97
98 ! Add fields keyword to the json so that the field_writer picks it up.
99 ! Will also add fields to the registry.
100 fields(1) = "omega_x"
101 fields(2) = "omega_y"
102 fields(3) = "omega_z"
103
104 call json%add("fields", fields)
105
106 call this%init_base(json, case)
107 call this%writer%init(json, case)
108
110 end subroutine vorticity_init_from_json
111
114 class(vorticity_t), intent(inout) :: this
115
116 this%u => neko_field_registry%get_field_by_name("u")
117 this%v => neko_field_registry%get_field_by_name("v")
118 this%w => neko_field_registry%get_field_by_name("w")
119
120 this%omega_x => neko_field_registry%get_field_by_name("omega_x")
121 this%omega_y => neko_field_registry%get_field_by_name("omega_y")
122 this%omega_z => neko_field_registry%get_field_by_name("omega_z")
123
124 call this%temp1%init(this%u%dof)
125 call this%temp2%init(this%u%dof)
126
127 end subroutine vorticity_init_from_components
128
130 subroutine vorticity_free(this)
131 class(vorticity_t), intent(inout) :: this
132 call this%free_base()
133 call this%writer%free()
134 call this%temp1%free()
135 call this%temp2%free()
136
137 nullify(this%u)
138 nullify(this%v)
139 nullify(this%w)
140 nullify(this%omega_x)
141 nullify(this%omega_y)
142 nullify(this%omega_z)
143 end subroutine vorticity_free
144
146 subroutine vorticity_compute(this, time)
147 class(vorticity_t), intent(inout) :: this
148 type(time_state_t), intent(in) :: time
149
150 call curl(this%omega_x, this%omega_y, this%omega_z, this%u, this%v, &
151 this%w, this%temp1, this%temp2, this%case%fluid%c_Xh, &
153 end subroutine vorticity_compute
154
155end module vorticity
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Defines a simulation case.
Definition case.f90:34
Device abstraction, common interface for various accelerators.
Definition device.F90:34
type(c_ptr), bind(C), public glb_cmd_event
Event for the global command queue.
Definition device.F90:56
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
Implements the field_writer_t type.
Defines a field.
Definition field.f90:34
Implements fld_file_output_t.
Utilities for retrieving parameters from the case files.
integer, parameter, public dp
Definition num_types.f90:9
integer, parameter, public sp
Definition num_types.f90:8
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Operators.
Definition operators.f90:34
subroutine, public curl(w1, w2, w3, u1, u2, u3, work1, work2, coef, event)
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
subroutine compute_(this, time)
Dummy compute function.
Module with things related to the simulation time.
Implements the vorticity_t type.
Definition vorticity.f90:36
subroutine vorticity_compute(this, time)
Compute the vorticity field.
subroutine vorticity_init_from_components(this)
Actual constructor.
subroutine vorticity_free(this)
Destructor.
subroutine vorticity_init_from_json(this, json, case)
Constructor from json.
Definition vorticity.f90:93
A simulation component that writes a 3d field to a file.
A simple output saving a list of fields to a .fld file.
Base abstract class for simulation components.
A struct that contains all info about the time, expand as needed.
A simulation component that computes the vorticity field. Added to the field registry as omega_x,...
Definition vorticity.f90:54