Skip to content

Commit 0481a4a

Browse files
committed
Adapt .dat, fix INFO and EXPORT mode
- The reading and writing of .dat files was adapted to the new 4C .dat file structure - Added new default .dat file from the current 4C repo - Fixed issue regarding INFO_MODE and EXPORT_MODE, which were not displayed after clicking on the respective buttons - Added EXPORT_STATUS to signal to the user that the export was successful (or not!)
1 parent 227e554 commit 0481a4a

File tree

5 files changed

+146
-85
lines changed

5 files changed

+146
-85
lines changed

src/fourc_webviewer/gui_utils.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,29 @@ def _bottom_sheet_info():
6262

6363
def _bottom_sheet_export(server_controller):
6464
with vuetify.VBottomSheet(v_model=("EXPORT_MODE",), inset=True):
65-
with vuetify.VCard(classes="text-center", height=150, title="Export"):
65+
with vuetify.VCard(classes="text-center", height=250, title="Export"):
6666
with vuetify.VCardText():
6767
vuetify.VTextField(
6868
label="Export .dat file", v_model=("EXPORT_DAT_PATH",)
6969
)
70+
vuetify.VAlert(
71+
title="Click on <save> to export the changed .dat file under the entered path",
72+
type="info",
73+
v_if = ("EXPORT_STATUS == EXPORT_STATUS_POSSIB[0]", ),
74+
classes = "h-50"
75+
)
76+
vuetify.VAlert(
77+
title="Your file was exported correctly!",
78+
type="success",
79+
v_if = ("EXPORT_STATUS == EXPORT_STATUS_POSSIB[1]", ),
80+
classes = "h-50"
81+
)
82+
vuetify.VAlert(
83+
title="There was a problem while trying to export! Check the entered path and the modified .dat file settings!",
84+
type="error",
85+
v_if = ("EXPORT_STATUS == EXPORT_STATUS_POSSIB[2]", ),
86+
classes = "h-50"
87+
)
7088
vuetify.VBtn(text="SAVE", color="primary", click=server_controller)
7189

7290

src/fourc_webviewer/input_file_utils/read_dat_file.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,19 +306,6 @@ def read_dat_file(dat_file_path):
306306
) # category variable -> used further down below for the sectioning of the file content
307307
while l < len(file_lines):
308308
match file_lines[l][0]: # sectioning based on first character
309-
case "=": # get file title
310-
curr_line_ind = l + 1
311-
while curr_line_ind < len(file_lines):
312-
if file_lines[curr_line_ind][0] == "=":
313-
l = curr_line_ind + 1
314-
break
315-
else:
316-
file_title.append(file_lines[curr_line_ind])
317-
curr_line_ind += 1
318-
if curr_line_ind == len(file_lines):
319-
raise Exception(
320-
"The entire file was read without sectioning a file title"
321-
)
322309
case (
323310
"-"
324311
): # Symbol indicates a new category -> The use of "-" as a bullet point in the file description is discussed below
@@ -520,6 +507,9 @@ def read_dat_file(dat_file_path):
520507
# take all lines from the geometry_categories and save them in a geometry_lines list
521508
geometry_lines = [l for l in file_lines[geometry_categories_indices[0] :]]
522509

510+
# add file name as a file title
511+
file_title.append(Path(dat_file_path).name)
512+
523513
return_dict = {
524514
"file_title": file_title,
525515
"file_description": file_description,

src/fourc_webviewer/input_file_utils/write_dat_file.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,14 @@ def write_dat_file(
3838
# geometry_lines: [<lines with geometry specific info>]; Example: ["-----------------------------------------------DNODE-NODE TOPOLOGY", "NODE 36 DNODE 1", "NODE 163 DNODE 1", ..., "-----------------------------------------------DLINE-NODE TOPOLOGY", "NODE 36 DLINE 1", "NODE 105 DLINE 1",...]
3939

4040
# initialize lines_list, containing all the file lines
41-
lines_list = ["//", "//"]
41+
lines_list = []
4242

4343
# number of characters for "===" and "---" lines
4444
num_of_chars = 100
4545

4646
# line length for the category lines with <name value>
4747
line_length = 60
4848

49-
# append title section
50-
lines_list.append("=" * num_of_chars)
51-
lines_list.append(
52-
" " * math.floor((num_of_chars - len(title)) / 2)
53-
+ title
54-
+ " " * math.ceil((num_of_chars - len(title)) / 2)
55-
)
56-
lines_list.append("=" * num_of_chars)
57-
5849
# append description section
5950
lines_list.append("-" * (num_of_chars - len("TITLE")) + "TITLE")
6051
lines_list.extend(description.split("\n"))

src/fourc_webviewer/run_webserver.py

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from vtkmodules.vtkCommonDataModel import vtkDataObject
2626
import fourc_webviewer.vturender as vtu
2727
from fourc_webviewer_default_files import DEFAULT_INPUT_FILE
28+
import time
2829

2930
# ------------------------------------------------------------------------------#
3031
# COMMON SERVER SETUP #
@@ -431,6 +432,15 @@ def STATE_initialization(temp_dir, dat_path, vtu_path, dat_file_content):
431432
STATE.EDIT_MODE_POSSIB = ["VIEW MODE", "EDIT MODE"]
432433
STATE.EDIT_MODE = STATE.EDIT_MODE_POSSIB[0]
433434

435+
# initialize info mode value: False (bottom sheet with infos is not displayed until "INFO" button is pressed, and INFO_MODE is then set to True)
436+
STATE.INFO_MODE = False
437+
438+
# initialize export mode value: False (bottom sheet with export settings is not displayed until "EXPORT" button is pressed, and EXPORT_MODE is then set to True)
439+
STATE.EXPORT_MODE = False
440+
441+
# initialize the export status and its possible choices
442+
STATE.EXPORT_STATUS_POSSIB = ["INFO", "SUCCESS", "ERROR"] # INFO: button was not yet clicked, SUCCESS: export was successful, ERROR: there was an error after trying to export
443+
STATE.EXPORT_STATUS = "INFO"
434444

435445
# ------------------------------------------------------------------------------#
436446
# STATE CHANGES #
@@ -450,6 +460,12 @@ def change_dat_path(DAT_PATH, **kwargs):
450460
STATE.RENDER_COUNT = 1
451461

452462

463+
# after changing the export .dat file path
464+
@STATE.change("EXPORT_DAT_PATH")
465+
def change_export_dat_path(EXPORT_DAT_PATH, **kwargs):
466+
# set export status to neutral ("INFO")
467+
STATE.EXPORT_STATUS = STATE.EXPORT_STATUS_POSSIB[0]
468+
453469
# after selecting another main category
454470
@STATE.change("SELECTED_MAIN_CATEGORY")
455471
def change_selected_main_category(SELECTED_MAIN_CATEGORY, **kwargs):
@@ -650,6 +666,12 @@ def change_materials_modif_attr(MATERIALS_MODIF_ATTR, **kwargs):
650666
STATE.dirty("MATERIALS")
651667

652668

669+
# after modifying the export mode (either after clicking on EXPORT or after canceling the export bottom sheet)
670+
@STATE.change("EXPORT_MODE")
671+
def change_export_mode(EXPORT_MODE, **kwargs):
672+
STATE.EXPORT_STATUS = STATE.EXPORT_STATUS_POSSIB[0] # set export status to neutral ("INFO")
673+
674+
653675
# ------------------------------------------------------------------------------#
654676
# CLICK EVENT FUNCTIONS #
655677
# ------------------------------------------------------------------------------#
@@ -662,7 +684,6 @@ def click_info_button():
662684
def click_export_button():
663685
STATE.EXPORT_MODE = not STATE.EXPORT_MODE
664686

665-
666687
# convert provided dat file
667688
def click_convert_button():
668689
# global dat and vtu file paths
@@ -691,19 +712,23 @@ def click_convert_button():
691712

692713
# export dat file
693714
def click_save_button():
694-
write_dat_file(
695-
STATE.TITLE,
696-
STATE.DESCRIPTION,
697-
STATE.CATEGORIES,
698-
STATE.CATEGORY_ITEMS,
699-
STATE.MATERIALS,
700-
STATE.CLONING_MATERIAL_MAP,
701-
STATE.FUNCT,
702-
STATE.COND_GENERAL_TYPES,
703-
STATE.COND_ENTITY_LIST,
704-
STATE.COND_CONTEXT_LIST,
705-
STATE.COND_TYPE_LIST,
706-
STATE.RESULT_DESCRIPTION,
707-
STATE.GEOMETRY_LINES,
708-
STATE.EXPORT_DAT_PATH,
709-
)
715+
try:
716+
write_dat_file(
717+
STATE.TITLE,
718+
STATE.DESCRIPTION,
719+
STATE.CATEGORIES,
720+
STATE.CATEGORY_ITEMS,
721+
STATE.MATERIALS,
722+
STATE.CLONING_MATERIAL_MAP,
723+
STATE.FUNCT,
724+
STATE.COND_GENERAL_TYPES,
725+
STATE.COND_ENTITY_LIST,
726+
STATE.COND_CONTEXT_LIST,
727+
STATE.COND_TYPE_LIST,
728+
STATE.RESULT_DESCRIPTION,
729+
STATE.GEOMETRY_LINES,
730+
STATE.EXPORT_DAT_PATH,
731+
)
732+
STATE.EXPORT_STATUS = STATE.EXPORT_STATUS_POSSIB[1]
733+
except:
734+
STATE.EXPORT_STATUS = STATE.EXPORT_STATUS_POSSIB[2]
Lines changed: 81 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,104 @@
1-
==================================================================
2-
General Data File BACI
3-
==================================================================
41
-------------------------------------------------------------TITLE
5-
Test: Apply constant displacement rate up to a certain displacement and hold this for a number of seconds.
6-
It should be tested whether the implemented model MAT_InelasticDefgradUnifiedViscoplastic is able to
7-
model stress relaxation.
2+
Simple test case based on 1hex8 element with isotropic elastic-viscoplastic
3+
behavior in a finite strain setting. The following conditions are assumed:
4+
- element is stretched at a constant strain rate
5+
- element can freely contract in lateral dimensions
6+
- viscoplasticity law: flow rule and hardening behavior modeled with the
7+
Reformulated Johnson-Cook law, as shown in:
8+
Mareau: A thermodynamically consistent formulation of the Johnson-Cook
9+
model, Mechanics of Materials 143, 2020
10+
- time integration of internal variables using logarithmic substepping, as shown in:
11+
Ana: Continuum Modeling and Calibration of Viscoplasticity in the Context
12+
of the Lithium Anode in Solid-State Batteries
13+
(Master's Thesis, Chair of Computational Mechanics, TU Munich, 2024)
814
------------------------------------------------------PROBLEM SIZE
9-
//ELEMENTS 1
10-
//NODES 8
1115
DIM 3
12-
--------------------------------------------------------PROBLEM TYP
13-
PROBLEMTYP Structure
14-
-----------------------------------------------------------------IO
16+
-------------------------------------------------------PROBLEM TYPE
17+
PROBLEMTYPE Structure
18+
----------------------------------------------------------------IO
1519
STRUCT_STRESS cauchy
1620
STRUCT_STRAIN log
17-
------------------------------------IO/RUNTIME VTK OUTPUT/STRUCTURE
21+
-----------------------------------IO/RUNTIME VTK OUTPUT/STRUCTURE
1822
OUTPUT_STRUCTURE yes
1923
DISPLACEMENT yes
2024
STRESS_STRAIN yes
21-
----------------------------------------------IO/RUNTIME VTK OUTPUT
25+
---------------------------------------------IO/RUNTIME VTK OUTPUT
2226
OUTPUT_DATA_FORMAT binary
2327
INTERVAL_STEPS 1
24-
-------------------------------------------------STRUCTURAL DYNAMIC
28+
------------------------------------------------STRUCTURAL DYNAMIC
2529
INT_STRATEGY Standard
26-
DYNAMICTYP Statics
30+
DYNAMICTYPE Statics
2731
RESULTSEVRY 1
2832
RESTARTEVRY 30
29-
TIMESTEP 1.25e-1
30-
NUMSTEP 1000000
31-
MAXTIME 1.25e1
33+
TIMESTEP 1.00e-6
34+
NUMSTEP 100000000
35+
MAXTIME 1.00e-4
3236
LINEAR_SOLVER 1
3337
TOLRES 1e-8
34-
TOLDISP 1e-10
35-
-----------------------------------------------------------SOLVER 1
38+
TOLDISP 1e-8
39+
NEGLECTINERTIA Yes
40+
----------------------------------------------------------SOLVER 1
3641
SOLVER UMFPACK
37-
----------------------------------------------------------MATERIALS
38-
MAT 1 MAT_MultiplicativeSplitDefgradElastHyper NUMMATEL 1 MATIDSEL 2 NUMFACINEL 1 INELDEFGRADFACIDS 3 DENS 5.34e-4
39-
MAT 2 ELAST_CoupNeoHooke YOUNG 7.810e3 NUE 0.38
40-
MAT 3 MAT_InelasticDefgradGenericIsotropicViscoplastic VP_FR_MATID 4
41-
MAT 4 MAT_ViscoplasticFlowRuleReformulatedJohnsonCook SIM_TEMPERATURE 293.0 MELT_TEMPERATURE 1793.0 REF_TEMPERATURE 293.0 TEMPERATURE_EXP 1.03 STRAIN_RATE_PREFAC 0.02 STRAIN_RATE_EXP_FAC 5 INIT_YIELD_STRENGTH 1.0 ISOTROP_HARDEN_PREFAC 10.0 ISOTROP_HARDEN_EXP 2.0
42-
-------------------------------------------------------------FUNCT1
42+
---------------------------------------------------------MATERIALS
43+
MAT 1 MAT_MultiplicativeSplitDefgradElastHyper NUMMATEL 1 MATIDSEL 2 NUMFACINEL 1 INELDEFGRADFACIDS 3 DENS 7830.0
44+
MAT 2 ELAST_CoupNeoHooke YOUNG 200.0e3 NUE 0.29
45+
MAT 3 MAT_InelasticDefgradTransvIsotropElastViscoplast VISCOPLAST_LAW_ID 4 FIBER_READER_ID 5 YIELD_COND_A 0.0 YIELD_COND_B 0.0 YIELD_COND_F 0.0 ANISOTROPY isotrop LOG_SUBSTEP True MAX_HALVE_NUM_SUBSTEP 10
46+
MAT 4 MAT_ViscoplasticLawReformulatedJohnsonCook STRAIN_RATE_PREFAC 1.0e0 STRAIN_RATE_EXP_FAC 0.014 INIT_YIELD_STRENGTH 792.0e-0 ISOTROP_HARDEN_PREFAC 510.0e-0 ISOTROP_HARDEN_EXP 0.26
47+
MAT 5 ELAST_CoupTransverselyIsotropic ALPHA 1.0 BETA 1.0 GAMMA 1.0 ANGLE 0 STR_TENS_ID 100
48+
MAT 100 ELAST_StructuralTensor STRATEGY Standard
49+
------------------------------------------------------------FUNCT1
4350
COMPONENT 0 SYMBOLIC_FUNCTION_OF_SPACE_TIME 1.2*x
4451
COMPONENT 1 SYMBOLIC_FUNCTION_OF_SPACE_TIME -0.080830788307857
4552
------------------------------------------------RESULT DESCRIPTION
46-
STRUCTURE DIS structure NODE 4 QUANTITY dispy VALUE -1.31962249833408790e-01 TOLERANCE 9.1e-10
47-
STRUCTURE DIS structure NODE 5 QUANTITY dispx VALUE -1.31962249833408513e-01 TOLERANCE 9.1e-10
48-
STRUCTURE DIS structure NODE 8 QUANTITY dispx VALUE -9.06271329067036280e-02 TOLERANCE 9.1e-10
49-
STRUCTURE DIS structure NODE 8 QUANTITY dispy VALUE -9.06271329067068060e-02 TOLERANCE 9.1e-10
50-
STRUCTURE DIS structure NODE 8 QUANTITY dispz VALUE 2.84025416687741394e-01 TOLERANCE 2.8e-09
51-
STRUCTURE DIS structure NODE 6 QUANTITY dispx VALUE -9.06271329067021153e-02 TOLERANCE 9.1e-10
52-
STRUCTURE DIS structure NODE 4 QUANTITY stress_zz VALUE 1.83879098311578976e-01 TOLERANCE 1.8e-07
53-
STRUCTURE DIS structure NODE 8 QUANTITY stress_zz VALUE 1.83879098311589884e-01 TOLERANCE 1.8e-07
54-
------------------------------------------------DESIGN DESCRIPTION
55-
NDPOINT 1
56-
NDLINE 0
57-
NDSURF 2
58-
NDVOL 0
53+
STRUCTURE DIS structure NODE 4 QUANTITY dispy VALUE -3.96619353942104843e-03 TOLERANCE 4.0e-11
54+
STRUCTURE DIS structure NODE 5 QUANTITY dispx VALUE -3.96619353942213090e-03 TOLERANCE 4.0e-11
55+
STRUCTURE DIS structure NODE 8 QUANTITY dispx VALUE -3.96619353942162696e-03 TOLERANCE 4.0e-11
56+
STRUCTURE DIS structure NODE 8 QUANTITY dispy VALUE -3.96619353942309367e-03 TOLERANCE 4.0e-11
57+
STRUCTURE DIS structure NODE 8 QUANTITY dispz VALUE 1.00501670841679491e-02 TOLERANCE 1.0e-10
58+
STRUCTURE DIS structure NODE 6 QUANTITY dispx VALUE -3.96619353942174319e-03 TOLERANCE 4.0e-11
59+
STRUCTURE DIS structure NODE 4 QUANTITY stress_zz VALUE 9.78458600965294636e+02 TOLERANCE 9.8e-04
60+
STRUCTURE DIS structure NODE 8 QUANTITY stress_zz VALUE 9.78458600965331243e+02 TOLERANCE 9.8e-04
5961
------------------------------------DESIGN POINT DIRICH CONDITIONS
60-
DPOINT 1
62+
DPOINT 2
6163
// bottom_vertex_full
6264
E 1 - NUMDOF 3 ONOFF 1 1 1 VAL 0.0 0.0 0.0 FUNCT none none none
65+
E 2 - NUMDOF 3 ONOFF 1 1 1 VAL 0.0 0.0 1.0 FUNCT none none 1
66+
-------------------------------------DESIGN LINE DIRICH CONDITIONS
67+
DLINE 5
68+
// top_back
69+
E 1 - NUMDOF 3 ONOFF 1 0 1 VAL 0.0 0.0 1.0 FUNCT none none 1
70+
// top_left
71+
E 2 - NUMDOF 3 ONOFF 0 1 1 VAL 0.0 0.0 1.0 FUNCT none none 1
72+
// top_bottom
73+
E 3 - NUMDOF 3 ONOFF 1 1 0 VAL 0.0 0.0 0.0 FUNCT none none none
74+
// bottom_back
75+
E 4 - NUMDOF 3 ONOFF 1 0 1 VAL 0.0 0.0 0.0 FUNCT none none none
76+
// bottom_left
77+
E 5 - NUMDOF 3 ONOFF 0 1 1 VAL 0.0 0.0 0.0 FUNCT none none none
6378
-------------------------------------DESIGN SURF DIRICH CONDITIONS
64-
DSURF 2
79+
DSURF 4
6580
// z_top
6681
E 1 - NUMDOF 3 ONOFF 0 0 1 VAL 0.0 0.0 1.0 FUNCT none none 1
6782
// z_bottom
6883
E 2 - NUMDOF 3 ONOFF 0 0 1 VAL 0.0 0.0 0.0 FUNCT none none none
84+
// z_back
85+
E 3 - NUMDOF 3 ONOFF 1 0 0 VAL 0.0 0.0 0.0 FUNCT none none none
86+
// z_left
87+
E 4 - NUMDOF 3 ONOFF 0 1 0 VAL 0.0 0.0 0.0 FUNCT none none none
6988
-----------------------------------------------DNODE-NODE TOPOLOGY
7089
NODE 2 DNODE 1
90+
NODE 1 DNODE 2
91+
-----------------------------------------------DLINE-NODE TOPOLOGY
92+
NODE 1 DLINE 1
93+
NODE 4 DLINE 1
94+
NODE 1 DLINE 2
95+
NODE 5 DLINE 2
96+
NODE 1 DLINE 3
97+
NODE 2 DLINE 3
98+
NODE 2 DLINE 4
99+
NODE 3 DLINE 4
100+
NODE 2 DLINE 5
101+
NODE 6 DLINE 5
71102
-----------------------------------------------DSURF-NODE TOPOLOGY
72103
NODE 1 DSURFACE 1
73104
NODE 4 DSURFACE 1
@@ -77,6 +108,14 @@ NODE 2 DSURFACE 2
77108
NODE 3 DSURFACE 2
78109
NODE 6 DSURFACE 2
79110
NODE 7 DSURFACE 2
111+
NODE 1 DSURFACE 3
112+
NODE 2 DSURFACE 3
113+
NODE 3 DSURFACE 3
114+
NODE 4 DSURFACE 3
115+
NODE 1 DSURFACE 4
116+
NODE 2 DSURFACE 4
117+
NODE 5 DSURFACE 4
118+
NODE 6 DSURFACE 4
80119
-------------------------------------------------------NODE COORDS
81120
NODE 1 COORD -5.0000000000000000e-01 -5.0000000000000000e-01 5.0000000000000000e-01
82121
NODE 2 COORD -5.0000000000000000e-01 -5.0000000000000000e-01 -5.0000000000000000e-01
@@ -87,6 +126,4 @@ NODE 6 COORD 5.0000000000000000e-01 -5.0000000000000000e-01 -5.00000000
87126
NODE 7 COORD 5.0000000000000000e-01 5.0000000000000000e-01 -5.0000000000000000e-01
88127
NODE 8 COORD 5.0000000000000000e-01 5.0000000000000000e-01 5.0000000000000000e-01
89128
------------------------------------------------STRUCTURE ELEMENTS
90-
1 SOLIDH8 HEX8 1 2 3 4 5 6 7 8 MAT 1 KINEM nonlinear EAS none
91-
---------------------------------------------------------------END
92-
// END
129+
1 SOLID HEX8 1 2 3 4 5 6 7 8 MAT 1 KINEM nonlinear FIBER1 0 0 1.0

0 commit comments

Comments
 (0)