@@ -23,6 +23,7 @@ def parse(self):
2323 with open (self ._filepath , "rb" ) as f :
2424 self ._fileconfig = tl .load (f )
2525
26+ self .entity_sets = json .load (open (self ._fileconfig ["mesh" ]["entity_sets" ]))
2627 self ._parse_meta (self ._fileconfig )
2728 self ._parse_output (self ._fileconfig )
2829 self ._parse_materials (self ._fileconfig )
@@ -33,6 +34,21 @@ def parse(self):
3334 mesh = self ._parse_mesh (self ._fileconfig )
3435 return mesh
3536
37+ def _get_node_set_ids (self , set_ids ):
38+ all_ids = []
39+ for set_id in set_ids :
40+ ids = self .entity_sets ["node_sets" ][str (set_id )]
41+ all_ids .extend (ids )
42+ return jnp .asarray (all_ids )
43+
44+ def _get_particle_set_ids (self , set_type , set_nos , set_ids ):
45+ all_ids = []
46+ for set_no in set_nos :
47+ for set_id in set_ids :
48+ ids = self .entity_sets ["particle_sets" ][set_no ][str (set_id )]
49+ all_ids .extend (ids )
50+ return jnp .asarray (all_ids )
51+
3652 def _parse_meta (self , config ):
3753 self .parsed_config ["meta" ] = config ["meta" ]
3854
@@ -91,7 +107,7 @@ def _parse_external_loading(self, config):
91107 else :
92108 fn = Unit (- 1 )
93109 cnf = NodalForce (
94- node_ids = jnp . array (cnfconfig ["node_ids " ]),
110+ node_ids = self . _get_node_set_ids (cnfconfig ["nset_ids " ]),
95111 function = fn ,
96112 dir = cnfconfig ["dir" ],
97113 force = cnfconfig ["force" ],
@@ -110,7 +126,9 @@ def _parse_external_loading(self, config):
110126 fn = Unit (- 1 )
111127 pst = ParticleTraction (
112128 pset = pstconfig ["pset" ],
113- pids = jnp .array (pstconfig ["pids" ]),
129+ pids = self ._get_particle_set_ids (
130+ "particle" , pstconfig ["pset" ], pstconfig ["pset_ids" ]
131+ ),
114132 function = fn ,
115133 dir = pstconfig ["dir" ],
116134 traction = pstconfig ["traction" ],
@@ -123,10 +141,15 @@ def _parse_external_loading(self, config):
123141 def _parse_mesh (self , config ):
124142 element_cls = getattr (mpel , config ["mesh" ]["element" ])
125143 mesh_cls = getattr (mpmesh , f"Mesh{ config ['meta' ]['dimension' ]} D" )
144+
126145 constraints = [
127- (jnp .asarray (c ["node_ids" ]), Constraint (c ["dir" ], c ["velocity" ]))
146+ (
147+ self ._get_node_set_ids (c ["nset_ids" ]),
148+ Constraint (c ["dir" ], c ["velocity" ]),
149+ )
128150 for c in config ["mesh" ]["constraints" ]
129151 ]
152+
130153 if config ["mesh" ]["type" ] == "generator" :
131154 elements = element_cls (
132155 config ["mesh" ]["nelements" ],
@@ -141,6 +164,7 @@ def _parse_mesh(self, config):
141164 raise NotImplementedError (
142165 "Mesh type other than `generator` not yet supported."
143166 )
167+
144168 self .parsed_config ["elements" ] = elements
145169 mesh = mesh_cls (self .parsed_config )
146170 return mesh
0 commit comments