-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnumerics.py
128 lines (113 loc) · 5.03 KB
/
numerics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# numerics gittree menu
# ui_cards:
# appear below the gittree.
# ui_sub_cards:
# appear below ui_cards, change depending on settings in ui_cards.
# dialog_cards:
# popup-window called from button in ui_cards.
# @state.change:
# called from ui_cards, ui_sub_cards or dialog_cards, sets the configuration option.
# note that in the main menu, we need to call/add the following:
# 1) from numerics import *
# 2) call numerics_card() in SinglePageWithDrawerLayout
# 3) define a node in the gittree (pipeline)
# 4) define any global state variables that might be needed
# definition of ui_card
from uicard import ui_card, ui_subcard, server
from trame.widgets import vuetify
from su2_json import *
state, ctrl = server.state, server.controller
############################################################################
# Numerics models - list options #
############################################################################
# List: numerics model: spatial gradients NUM_METHOD_GRAD
LNumericsGrad= [
{"text": "Green-Gauss", "value": 0, "json": "GREEN_GAUSS"},
{"text": "Weighted Least Squares", "value": 1, "json": "WEIGHTED_LEAST_SQUARES"},
]
# List: numerics model: gradient reconstruction for MUSCL (NUM_METHOD_GRAD_RECON)
LNumericsGradRecon= [
{"text": "Green-Gauss", "value": 0, "json": "GREEN_GAUSS"},
{"text": "Weighted Least Squares", "value": 1, "json": "WEIGHTED_LEAST_SQUARES"},
]
# set the state variables using the json data from the config file
def set_json_numerics():
if 'CFL_NUMBER' in state.jsonData:
try:
state.CFL_idx = float(state.jsonData['CFL_NUMBER'])
except Exception as e:
log("error", f"Error in setting CFL number in Numeric Tab: \n {e}")
if 'NUM_METHOD_GRAD' in state.jsonData:
state.numerics_grad_idx = GetJsonIndex(state.jsonData['NUM_METHOD_GRAD'],LNumericsGrad)
if 'NUM_METHOD_GRAD_RECON' in state.jsonData:
state.numerics_grad_recon_idx = GetJsonIndex(state.jsonData['NUM_METHOD_GRAD_RECON'],LNumericsGradRecon)
state.dirty('CFL_idx')
state.dirty('numerics_grad_idx')
state.dirty('numerics_grad_recon_idx')
###############################################################
# PIPELINE CARD : Numerics
###############################################################
def numerics_card():
with ui_card(title="Numerics", ui_name="Numerics"):
log("info", "## Numerics Selection ##")
# 1 row of option lists
with vuetify.VRow(classes="pt-2"):
with vuetify.VCol(cols="10"):
# Then a list selection for numerics submodels
vuetify.VSelect(
# What to do when something is selected
v_model=("numerics_grad_idx", 0),
# The items in the list
items=("representations_grad",LNumericsGrad),
# the name of the list box
label="Spatial Gradients",
hide_details=True,
dense=True,
outlined=True,
classes="pt-1 mt-1",
)
vuetify.VSelect(
# What to do when something is selected
v_model=("numerics_grad_recon_idx", 0),
# The items in the list
items=("representations_grad_recon",LNumericsGradRecon),
# the name of the list box
label="MUSCL Spatial Gradients",
hide_details=True,
dense=True,
outlined=True,
classes="pt-1 mt-1",
)
vuetify.VTextField(
# What to do when something is selected
v_model=("CFL_idx", 1.0),
# the name of the list box
label="CFL",
)
###############################################################
# Numerics - state changes
###############################################################
@state.change("numerics_grad_idx")
def update_material(numerics_grad_idx, **kwargs):
log("info", f"numerics spatial gradient selection: = {numerics_grad_idx}")
# we want to call a submenu
#state.active_sub_ui = "submaterials_fluid"
# update config option value
state.jsonData['NUM_METHOD_GRAD']= GetJsonName(numerics_grad_idx,LNumericsGrad)
@state.change("numerics_grad_recon_idx")
def update_material(numerics_grad_recon_idx, **kwargs):
log("info", f"numerics MUSCL spatial gradient selection: = {numerics_grad_recon_idx}")
# we want to call a submenu
#state.active_sub_ui = "submaterials_fluid"
# update config option value
state.jsonData['NUM_METHOD_GRAD_RECON']= GetJsonName(numerics_grad_recon_idx,LNumericsGradRecon)
@state.change("CFL_idx")
def update_material(CFL_idx, **kwargs):
log("info", f"CFL value: = {CFL_idx}")
# we want to call a submenu
#state.active_sub_ui = "submaterials_fluid"
# update config option value
try:
state.jsonData['CFL_NUMBER']= float(CFL_idx)
except Exception as e:
log("error", f"Error in setting CFL number in Numeric Tab: \n {e}")