This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # %% | |
| import numpy as np | |
| from ansys.dpf import post | |
| from ansys.dpf import core as dpf | |
| from ansys.dpf.core import examples | |
| rst = examples.simple_bar | |
| model = dpf.Model(rst) | |
| tfs = model.metadata.time_freq_support.time_frequencies.data | |
| print(model) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.callback( | |
| Output(f'{APP_ID}_geom_rep', 'children'), | |
| Output(f'{APP_ID}_store', 'data'), | |
| Output(f'{APP_ID}_nodes_upload', 'contents'), | |
| Output(f'{APP_ID}_elems_upload', 'contents'), | |
| Input(f'{APP_ID}_nodes_upload', 'contents'), | |
| Input(f'{APP_ID}_elems_upload', 'contents'), | |
| Input(f'{APP_ID}_elem_data_upload', 'contents'), | |
| Input(f'{APP_ID}_dropdown_cs', 'value'), | |
| Input(f'{APP_ID}_range_slider', 'value'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if e_data_b64: | |
| decoded_ed = base64.b64decode(e_data_b64.split(',')[1]) | |
| df_elem_data = pd.read_csv( | |
| io.StringIO(decoded_ed.decode('utf-8')), | |
| delim_whitespace=True, | |
| header=None, | |
| skiprows=1, | |
| names=['id', 'val'] | |
| ) | |
| df_elem_data = df_elem_data.sort_values('id').set_index('id', drop=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| layout = dbc.Container([ | |
| html.H1('Unstructured Mesh Viewer'), | |
| dbc.Row([ | |
| dbc.Col([ | |
| html.H3('Step 1: Upload your mesh'), | |
| # upload for nodes | |
| dcc.Store(id=f'{APP_ID}_store', data=[True]), | |
| dcc.Upload( | |
| id=f'{APP_ID}_nodes_upload', | |
| multiple=False, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ns_export_to_uGrid(n_ns_b64, e_ns_b64, e_data_b64=None): | |
| decoded_n = base64.b64decode(n_ns_b64.split(',')[1]) | |
| decoded_e = base64.b64decode(e_ns_b64.split(',')[1]) | |
| df_nodes = pd.read_csv(io.StringIO(decoded_n.decode('utf-8')), delim_whitespace=True, header=None, skiprows=1, names=['id', 'x', 'y', 'z']) | |
| df_nodes['id'] = df_nodes['id'].astype(int) | |
| df_nodes = df_nodes.set_index('id', drop=True) | |
| # fill missing ids in range as VTK uses position (index) to map cells to points | |
| df_nodes = df_nodes.reindex(np.arange(df_nodes.index.min(), df_nodes.index.max() + 1), fill_value=0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Element Number Element Type Nodes | |
| 1 Tet10 13678 14398 16466 16375 94108 97821 94113 94112 97819 102577 | |
| 2 Tet10 13468 14398 16466 13678 93150 97821 93155 93149 94108 94113 | |
| 3 Tet10 13064 16466 14398 16375 90412 97821 90409 90411 102577 97819 | |
| 4 Tet10 12489 13064 16466 14398 86479 90412 86481 86480 90409 97821 | |
| 5 Tet10 12495 16466 13064 15007 86521 90412 86516 86518 100327 90410 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.callback( | |
| [ | |
| Output(f'{APP_ID}_session_store', 'data'), | |
| Output(f'{APP_ID}_xaxis_select', 'options'), | |
| Output(f'{APP_ID}_yaxis_select', 'options'), | |
| ], | |
| [ | |
| Input(f'{APP_ID}_process_data_button', 'n_clicks'), | |
| ], | |
| [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.callback( | |
| Output(f'{APP_ID}_process_data_button', 'disabled'), | |
| [ | |
| Input(f'{APP_ID}_large_upload_fn_store', 'data'), | |
| Input(f'{APP_ID}_dcc_upload', 'contents') | |
| ], | |
| [ | |
| State(f'{APP_ID}_dcc_upload', 'filename') | |
| ] | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| layout = dbc.Container([ | |
| html.H1('Large User Input File Upload'), | |
| dcc.Store(id=f'{APP_ID}_session_store'), | |
| dcc.Store(id=f'{APP_ID}_large_upload_fn_store'), | |
| dbc.Row([ | |
| dbc.Col( | |
| du.Upload(id=f'{APP_ID}_large_upload') | |
| ), | |
| dbc.Col( | |
| dcc.Upload( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.callback( | |
| [ | |
| ServersideOutput(f'{APP_ID}_session_store', 'data'), | |
| Output(f'{APP_ID}_xaxis_select', 'options'), | |
| Output(f'{APP_ID}_yaxis_select', 'options'), | |
| ], | |
| [ | |
| Input(f'{APP_ID}_process_data_button', 'n_clicks'), | |
| ], | |
| [ |