Mod: improved plot for each data

Mod: cwd for gui settings
Mod: smooth stages
This commit is contained in:
L-Nafaryus 2022-01-12 23:17:42 +05:00
parent 479e7d666a
commit e501b8b52b
No known key found for this signature in database
GPG Key ID: C76D8DCD2727DBB7
3 changed files with 83 additions and 8 deletions

View File

@ -132,8 +132,13 @@ class UltimateRunner(object):
params["label"], params["direction"], params["alpha"] params["label"], params["direction"], params["alpha"]
)) ))
filename = "shape.step" filename = "shape.step"
shapepath = path.join(self.casepath(), filename)
timer = Timer() timer = Timer()
if path.exists(shapepath) and shapeParams.shapeStatus == "done" and not self.config["overwrite"]:
logger.info("Shape exists. Skipping ...")
return
shape = { shape = {
"simple": Simple, "simple": Simple,
"bodyCentered": BodyCentered, "bodyCentered": BodyCentered,
@ -189,8 +194,13 @@ class UltimateRunner(object):
params["label"], params["direction"], params["alpha"] params["label"], params["direction"], params["alpha"]
)) ))
filename = "mesh.mesh" filename = "mesh.mesh"
meshpath = path.join(self.casepath(), filename)
timer = Timer() timer = Timer()
if path.exists(meshpath) and meshParams.meshStatus == "done" and not self.config["overwrite"]:
logger.info("Mesh exists. Skipping ...")
return
if not self.shape: if not self.shape:
shapefile = "shape.step" shapefile = "shape.step"
filepath = path.join(self.casepath(), shapefile) filepath = path.join(self.casepath(), shapefile)

View File

@ -24,12 +24,20 @@ layout = html.Div([
is_open = False, is_open = False,
style = message style = message
), ),
dbc.Alert(
id = "general-status",
duration = 10000,
dismissable = True,
is_open = False,
style = message
),
# General # General
html.H2("General"), html.H2("General"),
html.Hr(), html.Hr(),
html.P("Path: {}".format(os.environ.get("ANISOTROPY_CWD", ""))), html.P("Path"),
dbc.Button("Save", id = "submit", style = minWidth), dcc.Input(id = "cwd", style = { "min-width": "500px" }),
html.Br(),
dbc.Button("Save general", id = "general-save", style = minWidth),
# Options # Options
html.H2("Options"), html.H2("Options"),
@ -42,6 +50,7 @@ layout = html.Div([
options = [ { "label": k, "value": k } for k in ["all", "shape", "mesh", "flow", "postProcess"] ], options = [ { "label": k, "value": k } for k in ["all", "shape", "mesh", "flow", "postProcess"] ],
style = minWidth style = minWidth
), ),
dbc.Button("Save", id = "submit", style = minWidth),
# Cases # Cases
html.H2("Cases"), html.H2("Cases"),
@ -54,6 +63,29 @@ layout = html.Div([
# Callbacks # Callbacks
## ##
@app.callback( @app.callback(
Output("general-status", "children"),
Output("general-status", "is_open"),
Output("general-status", "color"),
[ Input("general-save", "n_clicks") ],
[
State("cwd", "value"),
],
prevent_initial_call = True
)
def generalSave(clicks, cwd):
if not os.path.abspath(cwd):
return "Cwd path must be absolute", True, "danger"
if cwd[-1] == "/":
cwd = cwd[ :-1]
os.environ["ANISOTROPY_CWD"] = cwd
return "General settings saved", True, "success"
@app.callback(
Output("cwd", "value"),
Output("nprocs", "value"), Output("nprocs", "value"),
Output("stage", "value"), Output("stage", "value"),
Output("cases", "value"), Output("cases", "value"),
@ -69,7 +101,7 @@ def settingsLoad(pathname):
if os.path.exists(filepath): if os.path.exists(filepath):
config.load(filepath) config.load(filepath)
return config["nprocs"], config["stage"], toml.dumps(config.content) return os.environ["ANISOTROPY_CWD"], config["nprocs"], config["stage"], toml.dumps(config.content)
@app.callback( @app.callback(

View File

@ -71,6 +71,22 @@ class MeshRepresentation(object):
return representation return representation
def databaseColumns():
from anisotropy.database import Database
import re
db = Database()
idcol = re.compile(r"\s*_id")
columns = []
for table in db.tables:
for column in table._meta.columns.keys():
if not idcol.search(column):
columns.append(column)
return columns
### ###
# Layout # Layout
## ##
@ -151,7 +167,7 @@ plotcontrols = html.Div([
html.P("Data"), html.P("Data"),
dcc.Dropdown( dcc.Dropdown(
id = "plot-data", id = "plot-data",
options = [ { "label": v, "value": v } for v in [ "porosity",] ], options = [ { "label": v, "value": v } for v in databaseColumns() ],
value = "porosity", value = "porosity",
), ),
html.Br(), html.Br(),
@ -233,9 +249,15 @@ def plotDraw(clicks, execution, structure, direction, data):
else: else:
break break
if direction == "all":
select = (models.Shape.alpha, column, models.Shape.direction)
else:
select = (models.Shape.alpha, column)
query = ( query = (
models.Shape models.Shape
.select(models.Shape.alpha, column) .select(*select)
.join(models.Execution, JOIN.LEFT_OUTER) .join(models.Execution, JOIN.LEFT_OUTER)
.switch(models.Shape) .switch(models.Shape)
.join(models.Mesh, JOIN.LEFT_OUTER) .join(models.Mesh, JOIN.LEFT_OUTER)
@ -243,15 +265,20 @@ def plotDraw(clicks, execution, structure, direction, data):
.where( .where(
models.Shape.exec_id == execution, models.Shape.exec_id == execution,
models.Shape.label == structure, models.Shape.label == structure,
models.Shape.direction == json.loads(direction),
) )
) )
print(query.sql())
if not direction == "all":
query = qeury.where(models.Shape.direction == json.loads(direction))
with db: with db:
if query.exists(): if query.exists():
table = [] table = []
for row in query.dicts(): for row in query.dicts():
for k in row.keys():
if type(row[k]) == list:
row[k] = str(row[k])
table.append(row) table.append(row)
else: else:
@ -273,6 +300,12 @@ def plotDraw(clicks, execution, structure, direction, data):
fig = px.line( fig = px.line(
DataFrame(table), x = "alpha", y = data, title = structure, markers = True DataFrame(table), x = "alpha", y = data, title = structure, markers = True
) )
if direction == "all":
fig = px.line(
DataFrame(table), x = "alpha", y = data, title = structure, markers = True, color = "direction"
)
fig.layout.template = "custom_dark" fig.layout.template = "custom_dark"
fig.update_xaxes(showline=True, linewidth=1, linecolor='#4f687d', mirror=True) fig.update_xaxes(showline=True, linewidth=1, linecolor='#4f687d', mirror=True)
fig.update_yaxes(showline=True, linewidth=1, linecolor='#4f687d', mirror=True) fig.update_yaxes(showline=True, linewidth=1, linecolor='#4f687d', mirror=True)