Skip to content

Commit 014c4fe

Browse files
authored
Merge branch 'geoelements:main' into bingham
2 parents 123f164 + ca126a5 commit 014c4fe

File tree

8 files changed

+62
-10
lines changed

8 files changed

+62
-10
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"node_sets":
3+
{
4+
"0": [3, 7],
5+
"1": [0, 4]
6+
}
7+
}

benchmarks/2d/uniaxial_nodal_forces/mpm-nodal-forces.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ nelements = [3, 1]
3434
element_length = [0.1, 0.1]
3535
particle_element_ids = [0]
3636
element = "Quadrilateral4Node"
37+
entity_sets = "entity_sets.json"
3738

3839
[[mesh.constraints]]
39-
node_ids = [0, 4]
40+
nset_ids = [1]
4041
dir = 0
4142
velocity = 0.0
4243

@@ -56,7 +57,7 @@ init_velocity = 0.0
5657
gravity = [0, 0]
5758

5859
[[external_loading.concentrated_nodal_forces]]
59-
node_ids = [3, 7]
60+
nset_ids = [0]
6061
math_function_id = 0
6162
dir = 0
6263
force = 0.05
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"particle_sets": [
3+
{
4+
"0": [5, 11]
5+
}
6+
],
7+
"node_sets": {
8+
"0": [3, 7],
9+
"1": [0, 4]
10+
}
11+
}

benchmarks/2d/uniaxial_particle_traction/mpm-particle-traction.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ nelements = [3, 1]
3434
element_length = [0.1, 0.1]
3535
particle_element_ids = [0]
3636
element = "Quadrilateral4Node"
37+
entity_sets = "entity_sets.json"
3738

3839
[[mesh.constraints]]
39-
node_ids = [0, 4]
40+
nset_ids = [1]
4041
dir = 0
4142
velocity = 0.0
4243

@@ -57,7 +58,7 @@ gravity = [0, 0]
5758

5859
[[external_loading.particle_surface_traction]]
5960
pset = [0]
60-
pids = [[5, 11]]
61+
pset_ids = [0]
6162
math_function_id = 0
6263
dir = 0
6364
traction = 1
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"node_sets":
3+
{
4+
"0": [0, 1],
5+
"1": [2, 3]
6+
}
7+
}

benchmarks/2d/uniaxial_stress/mpm-uniaxial-stress.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ nelements = [1, 1]
3030
element_length = [1, 1]
3131
particle_element_ids = [0]
3232
element = "Quadrilateral4Node"
33+
entity_sets = "entity_sets.json"
3334

3435
[[mesh.constraints]]
35-
node_ids = [0, 1]
36+
nset_ids = [0]
3637
dir = 1
3738
velocity = 0.0
3839

3940
[[mesh.constraints]]
40-
node_ids = [2, 3]
41+
nset_ids = [1]
4142
dir = 1
4243
velocity = -0.01
4344

diffmpm/io.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

diffmpm/mesh.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def apply_traction_on_particles(self, curr_time):
4747
traction_val = factor * ptraction.traction
4848
for i, pset_id in enumerate(ptraction.pset):
4949
self.particles[pset_id].assign_traction(
50-
ptraction.pids[i], ptraction.dir, traction_val
50+
ptraction.pids, ptraction.dir, traction_val
5151
)
5252

5353
# breakpoint()

0 commit comments

Comments
 (0)