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
weak_grad.f90
Go to the documentation of this file.
1! Copyright (c) 2024, 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 operators, only : opgrad
43 use time_state, only : time_state_t
44 use case, only : case_t
48 implicit none
49 private
50
53 type, public, extends(simulation_component_t) :: weak_grad_t
55 type(field_t), pointer :: u
57 type(field_t), pointer :: grad_x
59 type(field_t), pointer :: grad_y
61 type(field_t), pointer :: grad_z
63 type(field_writer_t) :: writer
64
65 contains
67 procedure, pass(this) :: init => weak_grad_init_from_json
69 procedure, pass(this) :: init_from_components => &
72 procedure, pass(this) :: free => weak_grad_free
74 procedure, pass(this) :: compute_ => weak_grad_compute
75 end type weak_grad_t
76
77contains
78
80 subroutine weak_grad_init_from_json(this, json, case)
81 class(weak_grad_t), intent(inout) :: this
82 type(json_file), intent(inout) :: json
83 class(case_t), intent(inout), target :: case
84 character(len=:), allocatable :: fieldname
85 character(len=20) :: fields(3)
86
87 ! Add fields keyword to the json so that the field_writer picks it up.
88 ! Will also add fields to the registry.
89 call json_get(json, "field", fieldname)
90
91 fields(1) = "weak_grad_" // trim(fieldname) // "_x"
92 fields(2) = "weak_grad_" // trim(fieldname) // "_y"
93 fields(3) = "weak_grad_" // trim(fieldname) // "_z"
94
95 call json%add("fields", fields)
96
97 call this%init_base(json, case)
98 call this%writer%init(json, case)
99
100 call weak_grad_init_from_components(this, fieldname)
101 end subroutine weak_grad_init_from_json
102
104 subroutine weak_grad_init_from_components(this, fieldname)
105 class(weak_grad_t), intent(inout) :: this
106 character(len=*) :: fieldname
107
108 this%u => neko_field_registry%get_field_by_name(trim(fieldname))
109
110 this%grad_x => neko_field_registry%get_field_by_name(&
111 "weak_grad_" // fieldname // "_x")
112 this%grad_y => neko_field_registry%get_field_by_name(&
113 "weak_grad_" // fieldname // "_y")
114 this%grad_z => neko_field_registry%get_field_by_name(&
115 "weak_grad_" // fieldname // "_z")
116
117
118 end subroutine weak_grad_init_from_components
119
121 subroutine weak_grad_free(this)
122 class(weak_grad_t), intent(inout) :: this
123 call this%free_base()
124 call this%writer%free()
125 nullify(this%grad_x)
126 nullify(this%grad_y)
127 nullify(this%grad_z)
128 nullify(this%u)
129 end subroutine weak_grad_free
130
133 subroutine weak_grad_compute(this, time)
134 class(weak_grad_t), intent(inout) :: this
135 type(time_state_t), intent(in) :: time
136
137 call opgrad(this%grad_x%x, this%grad_y%x, this%grad_z%x, this%u%x,&
138 this%case%fluid%c_Xh)
139 end subroutine weak_grad_compute
140
141end module weak_grad
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
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 opgrad(ux, uy, uz, u, coef, es, ee)
Compute the weak gradient of a scalar field, i.e. the gradient multiplied by the mass matrix.
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 weak_grad_t type.
Definition weak_grad.f90:36
subroutine weak_grad_init_from_json(this, json, case)
Constructor from json.
Definition weak_grad.f90:81
subroutine weak_grad_init_from_components(this, fieldname)
Actual constructor.
subroutine weak_grad_compute(this, time)
Compute the weak_grad field.
subroutine weak_grad_free(this)
Destructor.
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 weak gradient of a field. Wraps the opgrad operator.
Definition weak_grad.f90:53