Skip to content

Commit d1de1a6

Browse files
default rule generator
1 parent b120317 commit d1de1a6

File tree

5 files changed

+1014
-1
lines changed

5 files changed

+1014
-1
lines changed

data/default.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"common": "",
3+
"root_path": "",
4+
"geometry": null,
5+
"space": {
6+
"discr_order": 1,
7+
"pressure_discr_order": 1,
8+
"use_p_ref": false,
9+
"advanced": {
10+
"discr_order_max": 4,
11+
"serendipity": false,
12+
"isoparametric": false,
13+
"use_spline": false,
14+
"bc_method": "lsq",
15+
"n_boundary_samples": -1,
16+
"quadrature_order": -1,
17+
"poly_bases": "MFSHarmonic",
18+
"integral_constraints": 2,
19+
"n_harmonic_samples": 10,
20+
"force_no_ref_for_harmonic": false,
21+
"B": 3,
22+
"h1_formula": false,
23+
"count_flipped_els": true
24+
}
25+
},
26+
"time": null,
27+
"contact": {
28+
"enabled": false,
29+
"dhat": 1e-3,
30+
"dhat_percentage": 0.8,
31+
"epsv": 1e-3,
32+
"friction_coefficient": 0
33+
},
34+
"solver": {
35+
"linear": {
36+
"solver": "",
37+
"precond": ""
38+
},
39+
"nonlinear": {
40+
"solver" : "newton",
41+
"f_delta" : 1e-10,
42+
"grad_norm" : 1e-8,
43+
"max_iterations" : 1000,
44+
"use_grad_norm" : true,
45+
"relative_gradient" : false,
46+
"line_search": {
47+
"method" : "backtracking",
48+
"use_grad_norm_tol" : 1e-4
49+
}
50+
},
51+
"augmented_lagrangian" : {
52+
"initial_weight" : 1e6,
53+
"max_weight" : 1e11,
54+
"force" : false
55+
},
56+
"contact": {
57+
"CCD" : {
58+
"broad_phase" : "hash_grid",
59+
"tolerance" : 1e-6,
60+
"max_iterations" : 1e6
61+
},
62+
"friction_iterations" : 1,
63+
"friction_convergence_tol": 1e-2,
64+
"barrier_stiffness": "adaptive",
65+
"lagged_damping_weight": 0
66+
},
67+
"ignore_inertia" : false,
68+
"advanced": {
69+
"cache_size" : 900000,
70+
"lump_mass_matrix" : false
71+
}
72+
},
73+
"materials" : null,
74+
"boundary_conditions": {
75+
"rhs": null,
76+
"dirichlet_boundary": [],
77+
"neumann_boundary": [],
78+
"pressure_boundary": [],
79+
"obstacle_displacements": []
80+
},
81+
"initial_conditions": {
82+
"solution": null,
83+
"velocity": null,
84+
"acceleration": null
85+
},
86+
"output": {
87+
"json" : "",
88+
"paraview" : {
89+
"file_name" : "",
90+
"vismesh_rel_area" : 0.00001,
91+
"skip_frame" : 1,
92+
"high_order_mesh" : true,
93+
"volume" : true,
94+
"surface" : false,
95+
"wireframe" : false,
96+
"options" : {
97+
"material" : false,
98+
"body_ids" : false,
99+
"contact_forces" : false,
100+
"friction_forces" : false,
101+
"velocity" : false,
102+
"acceleration" : false
103+
},
104+
"reference": {
105+
"solution": null,
106+
"gradient": null
107+
}
108+
},
109+
"data" : {
110+
"solution" : "",
111+
"full_mat" : "",
112+
"stiffness_mat" : "",
113+
"solution_mat" : "",
114+
"stress_mat" : "",
115+
"u_path" : "",
116+
"v_path" : "",
117+
"a_path" : "",
118+
"mises" : "",
119+
"nodes" : ""
120+
},
121+
"advanced": {
122+
"timestep_prefix" : "step_",
123+
"sol_on_grid" : -1,
124+
"compute_error" : true,
125+
"sol_at_node" : -1,
126+
"vis_boundary_only" : false,
127+
"curved_mesh_size" : false,
128+
"save_solve_sequence_debug" : false,
129+
"save_time_sequence" : true,
130+
"save_nl_solve_sequence" : false,
131+
"spectrum" : false
132+
}
133+
},
134+
"input": {
135+
"data" : {
136+
"u_path" : "",
137+
"v_path" : "",
138+
"a_path" : ""
139+
}
140+
}
141+
142+
}

data/rule_generator.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import json
2+
from xml.etree.ElementPath import prepare_descendant
3+
4+
default = None
5+
with open('./default.json', "r") as f:
6+
default = json.load(f)
7+
8+
rules = []
9+
10+
def parse(default:json, prepending = ''):
11+
for k, v in default.items():
12+
if type(v) == dict:
13+
key = prepending + "/" + k
14+
tmp = {}
15+
tmp["pointers"] = key
16+
tmp['default'] = 'null'
17+
tmp['type'] = 'object'
18+
tmp['optional'] = [*v.keys()]
19+
tmp['doc'] = "//TODO"
20+
rules.append(tmp)
21+
parse(v, prepending=key)
22+
else:
23+
key = prepending + "/" + k
24+
tmp = {}
25+
tmp['pointers'] = key
26+
if v == "":
27+
tmp["default"] = 'null'
28+
tmp['type'] = 'string'
29+
elif type(v) == list:
30+
tmp['default'] = v
31+
tmp['type'] = 'list'
32+
elif type(v) == int:
33+
tmp['default'] = v
34+
tmp['type'] = 'int'
35+
elif type(v) == float:
36+
tmp['default'] = v
37+
tmp['type'] = 'float'
38+
elif type(v) == bool:
39+
tmp['default'] = v
40+
tmp['type'] = 'bool'
41+
tmp['doc'] = '//TODO'
42+
rules.append(tmp)
43+
parse(default)
44+
with open('tmp_rules.json', 'w') as f:
45+
json.dump(rules, f, indent=4)

data/rules.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@
517517
{
518518
"pointer": "/output/advanced/save_time_sequence",
519519
"type":"bool",
520-
"default":"//TODO",
520+
"default":"TODO",
521521
"doc": "Whether to save the results for each timestep"
522522
}
523523
]

0 commit comments

Comments
 (0)