Neko  0.9.0
A portable framework for high-order spectral element flow simulations
lambda2.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 !
36 
37 module lambda2
38  use num_types, only : rp
39  use json_module, only : json_file
42  use field, only : field_t
43  use operators, only : lambda2op
44  use case, only : case_t
45  use field_writer, only : field_writer_t
46  use device
47  implicit none
48  private
49 
50  type, public, extends(simulation_component_t) :: lambda2_t
52  type(field_t), pointer :: u
54  type(field_t), pointer :: v
56  type(field_t), pointer :: w
57 
59  type(field_t), pointer :: lambda2
60 
62  type(field_t) :: temp1
63  type(field_t) :: temp2
64 
66  type(field_writer_t) :: writer
67 
68  contains
70  procedure, pass(this) :: init => lambda2_init_from_json
72  procedure, pass(this) :: init_from_attributes => &
75  procedure, pass(this) :: free => lambda2_free
77  procedure, pass(this) :: compute_ => lambda2_compute
78  end type lambda2_t
79 
80 contains
81 
83  subroutine lambda2_init_from_json(this, json, case)
84  class(lambda2_t), intent(inout) :: this
85  type(json_file), intent(inout) :: json
86  class(case_t), intent(inout), target ::case
87  character(len=20) :: fields(1)
88  type(field_t), pointer :: u, v, w, lambda2
89 
90  ! Add fields keyword to the json so that the field_writer picks it up.
91  ! Will also add fields to the registry.
92  fields(1) = "lambda2"
93  call json%add("fields", fields)
94 
95  call this%init_base(json, case)
96  call this%writer%init(json, case)
97  u => neko_field_registry%get_field("u")
98  v => neko_field_registry%get_field("v")
99  w => neko_field_registry%get_field("w")
100  lambda2 => neko_field_registry%get_field("lambda2")
101 
102  call lambda2_init_from_attributes(this, u, v, w, lambda2)
103  end subroutine lambda2_init_from_json
104 
106  subroutine lambda2_init_from_attributes(this, u, v, w, lambda2)
107  class(lambda2_t), intent(inout) :: this
108  type(field_t), pointer, intent(inout) :: u, v, w, lambda2
109 
110  this%u => u
111  this%v => v
112  this%w => w
113  this%lambda2 => lambda2
114 
115  end subroutine lambda2_init_from_attributes
116 
118  subroutine lambda2_free(this)
119  class(lambda2_t), intent(inout) :: this
120  call this%free_base()
121  end subroutine lambda2_free
122 
126  subroutine lambda2_compute(this, t, tstep)
127  class(lambda2_t), intent(inout) :: this
128  real(kind=rp), intent(in) :: t
129  integer, intent(in) :: tstep
130 
131  call lambda2op(this%lambda2, this%u, this%v, this%w, this%case%fluid%c_Xh)
132 
133  end subroutine lambda2_compute
134 
135 end module lambda2
Defines a simulation case.
Definition: case.f90:34
Device abstraction, common interface for various accelerators.
Definition: device.F90:34
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
A simulation component that computes lambda2 The values are stored in the field registry under the na...
Definition: lambda2.f90:37
subroutine lambda2_compute(this, t, tstep)
Compute the lambda2 field.
Definition: lambda2.f90:127
subroutine lambda2_init_from_attributes(this, u, v, w, lambda2)
Actual constructor.
Definition: lambda2.f90:107
subroutine lambda2_init_from_json(this, json, case)
Constructor from json.
Definition: lambda2.f90:84
subroutine lambda2_free(this)
Destructor.
Definition: lambda2.f90:119
integer, parameter, public rp
Global precision used in computations.
Definition: num_types.f90:12
Operators.
Definition: operators.f90:34
subroutine, public lambda2op(lambda2, u, v, w, coef)
Compute the Lambda2 field for a given velocity field.
Definition: operators.f90:503
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
A simulation component that writes a 3d field to a file.
Base abstract class for simulation components.