Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
avm_simcomp.f90
Go to the documentation of this file.
1! Copyright (c) 2026, 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
38 use json_module, only : json_file
40 use case, only : case_t
41 use time_state, only : time_state_t
42 use artificial_viscosity_model, only : avm_t, avm_factory
46 implicit none
47 private
48
51 type, public, extends(simulation_component_t) :: avm_simcomp_t
53 class(avm_t), allocatable :: avm
55 type(field_writer_t) :: writer
56 contains
58 procedure, pass(this) :: init => avm_simcomp_init_from_json
60 procedure, pass(this) :: free => avm_simcomp_free
62 procedure, pass(this) :: preprocess_ => avm_simcomp_preprocess
64 procedure, pass(this) :: compute_ => avm_simcomp_compute
66 procedure, pass(this) :: restart_ => avm_simcomp_restart
67 end type avm_simcomp_t
68
69contains
70
75 subroutine avm_simcomp_init_from_json(this, json, case)
76 class(avm_simcomp_t), intent(inout), target :: this
77 type(json_file), intent(inout) :: json
78 class(case_t), intent(inout), target :: case
79 character(len=:), allocatable :: name
80 character(len=:), allocatable :: model_name
81 character(len=NEKO_VARNAME_LEN) :: fields(1)
82
83 call this%free()
84
85 call json_get_or_default(json, "name", name, "artificial_viscosity_model")
86 call json_get(json, "model", model_name)
87 this%name = name
88
89 call this%init_base(json, case)
90
91 ! Create the AVM first so we can get the field name it uses
92 call avm_factory(this%avm, model_name, case, json)
93
94 ! Get the field name from the model's reg_coeff field and add it to the
95 ! field_writer output list
96 fields(1) = this%avm%reg_coeff%name
97 call json%add("fields", fields)
98
99 call this%writer%init(json, case)
100
101 if (allocated(name)) deallocate(name)
102 if (allocated(model_name)) deallocate(model_name)
103 end subroutine avm_simcomp_init_from_json
104
107 subroutine avm_simcomp_free(this)
108 class(avm_simcomp_t), intent(inout) :: this
109 call this%free_base()
110 call this%writer%free()
111
112 if (allocated(this%avm)) then
113 call this%avm%free()
114 deallocate(this%avm)
115 end if
116 end subroutine avm_simcomp_free
117
121 subroutine avm_simcomp_preprocess(this, time)
122 class(avm_simcomp_t), intent(inout) :: this
123 type(time_state_t), intent(in) :: time
124
125 call this%avm%preprocess(time)
126 end subroutine avm_simcomp_preprocess
127
131 subroutine avm_simcomp_compute(this, time)
132 class(avm_simcomp_t), intent(inout) :: this
133 type(time_state_t), intent(in) :: time
134
135 call this%avm%compute(time)
136 end subroutine avm_simcomp_compute
137
141 subroutine avm_simcomp_restart(this, time)
142 class(avm_simcomp_t), intent(inout) :: this
143 type(time_state_t), intent(in) :: time
144
145 call this%avm%restart(time)
146 end subroutine avm_simcomp_restart
147
148end module avm_simcomp
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.
Implements avm_t.
Definition avm.f90:35
Implements the avm_simcomp_t type.
subroutine avm_simcomp_init_from_json(this, json, case)
Constructor from json.
subroutine avm_simcomp_free(this)
Destructor.
subroutine avm_simcomp_compute(this, time)
Compute the avm_simcomp field.
subroutine avm_simcomp_preprocess(this, time)
Compute the avm_simcomp field.
subroutine avm_simcomp_restart(this, time)
Compute the avm_simcomp field when restart.
Defines a simulation case.
Definition case.f90:34
Implements the field_writer_t type.
Utilities for retrieving parameters from the case files.
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
subroutine restart_(this, time)
Dummy restart function.
subroutine preprocess_(this, time)
Dummy preprocessing function.
subroutine compute_(this, time)
Dummy compute function.
Module with things related to the simulation time.
Utilities.
Definition utils.f90:35
integer, parameter, public neko_varname_len
Definition utils.f90:43
Base abstract type for artificial viscosity models.
Definition avm.f90:48
A simulation component that drives the computation of the artificial viscosity method.
A simulation component that writes a 3d field to a file.
Base abstract class for simulation components.
A struct that contains all info about the time, expand as needed.