
Hi all,
I'm trying to model a magnet encased in a cube of elastomer for part of a project. I've seemingly tried everything under the sun, but ive been rather limited due to the poor interactive documentation.
I have to core problems:
Defining a region by a function: Material parameters can be defined over just a region, as such a function to define an inner regions of given bounds:
def inner_region_(coors, domain=None ,magnet=None): x, y, z = coors[:, 0], coors[:, 1], coors[:, 2]
mag_min_x, mag_max_x = str((magnet[1][0] - (magnet[0][0] / 2))), str((magnet[1][0] + (magnet[0][0] / 2)))
mag_min_y, mag_max_y = str((magnet[1][1] - (magnet[0][1] / 2))), str((magnet[1][1] + (magnet[0][1] / 2)))
mag_min_z, mag_max_z = str((magnet[1][2] - (magnet[0][2] / 2))), str((magnet[1][2] + (magnet[0][2] / 2)))
parse_def_min = 'vertices in (' + x + ' > ' + mag_min_x + ') & (' + y + ' > ' + mag_min_y + ') & (' + z + ' > ' + mag_min_z + ')'
parse_def_max = '& (' + x + ' < ' + mag_max_x + ') & (' + y + ' < ' + mag_max_y + ') & (' + z + ' < ' + mag_max_z + ')'
#pls dont hate my ugly strings :)
parse_def = parse_def_min + parse_def_max
flag = nm.where(parse_def)[0]
print(flag)
return flag
I then call the function constructor in my main, again like the tutorials:
inner_region = Function('inner_region', inner_region_, extra_args=magnet)
and define the region off the domain:
magnet_region = domain.create_region('magnet0', 'vertices by inner_region','facet')
(i think i also need to make this region a child of my Omega (all node) region)
which fails miserably, due to the Function constructor seemingly not creating a Functions instance when called, but this is just from a bit of debugging (im no expert :D)
Secondly, I can't seem to configure having two materials over differing regions in the mesh. I think this is partly due to the above but also very limited examples concerning this use case interactively. If someone could run me through this i'd be extremely grateful!
BTW Im making meshes with pymesh, so cant use groups as a work around!