@@ -27,8 +27,10 @@ def parse(self):
2727 self ._parse_output (self ._fileconfig )
2828 self ._parse_materials (self ._fileconfig )
2929 self ._parse_particles (self ._fileconfig )
30- self ._parse_math_functions (self ._fileconfig )
31- self ._parse_external_loading (self ._fileconfig )
30+ if "math_functions" in self ._fileconfig :
31+ self ._parse_math_functions (self ._fileconfig )
32+ if "external_loading" in self ._fileconfig :
33+ self ._parse_external_loading (self ._fileconfig )
3234 mesh = self ._parse_mesh (self ._fileconfig )
3335 return mesh
3436
@@ -78,33 +80,39 @@ def _parse_math_functions(self, config):
7880 def _parse_external_loading (self , config ):
7981 external_loading = {}
8082 external_loading ["gravity" ] = jnp .array (config ["external_loading" ]["gravity" ])
81- cnf_list = []
82- for cnfconfig in config ["external_loading" ]["concentrated_nodal_forces" ]:
83- if "math_function_id" in cnfconfig :
84- fn = self .parsed_config ["math_functions" ][cnfconfig ["math_function_id" ]]
85- else :
86- fn = Unit (- 1 )
87- cnf = NodalForce (
88- node_ids = jnp .array (cnfconfig ["node_ids" ]),
89- function = fn ,
90- dir = cnfconfig ["dir" ],
91- force = cnfconfig ["force" ],
92- )
93- cnf_list .append (cnf )
83+ external_loading ["concentrated_nodal_forces" ] = []
84+ external_loading ["particle_surface_traction" ] = []
85+ if "concentrated_nodal_forces" in config ["external_loading" ]:
86+ cnf_list = []
87+ for cnfconfig in config ["external_loading" ]["concentrated_nodal_forces" ]:
88+ if "math_function_id" in cnfconfig :
89+ fn = self .parsed_config ["math_functions" ][
90+ cnfconfig ["math_function_id" ]
91+ ]
92+ else :
93+ fn = Unit (- 1 )
94+ cnf = NodalForce (
95+ node_ids = jnp .array (cnfconfig ["node_ids" ]),
96+ function = fn ,
97+ dir = cnfconfig ["dir" ],
98+ force = cnfconfig ["force" ],
99+ )
100+ cnf_list .append (cnf )
101+ external_loading ["concentrated_nodal_forces" ] = cnf_list
94102
95- pst_list = []
96- for pstconfig in config [ "external_loading" ][ "particle_surface_traction" ]:
97- pst = ParticleTraction (
98- pset = jnp . array ( pstconfig [ "pset" ]),
99- function = self . parsed_config [ "math_functions" ][
100- pstconfig [ "math_function_id" ]
101- ],
102- dir = pstconfig [ "dir" ],
103- traction = pstconfig ["traction " ],
104- )
105- pst_list . append ( pst )
106- external_loading [ "concentrated_nodal_forces" ] = cnf_list
107- external_loading ["particle_surface_traction" ] = pst_list
103+ if "particle_surface_traction" in config [ "external_loading" ]:
104+ pst_list = []
105+ for pstconfig in config [ "external_loading" ][ "particle_surface_traction" ]:
106+ pst = ParticleTraction (
107+ pset = jnp . array ( pstconfig [ "pset" ]),
108+ function = self . parsed_config [ "math_functions" ][
109+ pstconfig [ "math_function_id" ]
110+ ],
111+ dir = pstconfig ["dir " ],
112+ traction = pstconfig [ "traction" ],
113+ )
114+ pst_list . append ( pst )
115+ external_loading ["particle_surface_traction" ] = pst_list
108116 self .parsed_config ["external_loading" ] = external_loading
109117
110118 def _parse_mesh (self , config ):
0 commit comments