jax_fem.generate module#

class jax_fem.generate_mesh.Mesh(points, cells, ele_type='TET4')[source]#

Bases: object

A custom mesh manager might be better using a third-party library like meshio.

count_selected_faces(location_fn)[source]#

Given location functions, compute the count of faces that satisfy the location function. Useful for setting up distributed load conditions.

Parameters:

location_fns (List[Callable]) – Callable: a function that inputs a point and returns a boolean value describing whether the boundary condition should be applied.

Returns:

face_count

Return type:

int

jax_fem.generate_mesh.box_mesh(Nx, Ny, Nz, domain_x, domain_y, domain_z)[source]#

HEX8 mesh, generated by our own code

jax_fem.generate_mesh.box_mesh_gmsh(Nx, Ny, Nz, Lx, Ly, Lz, data_dir, ele_type='HEX8')[source]#

References: https://gitlab.onelab.info/gmsh/gmsh/-/blob/master/examples/api/hex.py https://gitlab.onelab.info/gmsh/gmsh/-/blob/gmsh_4_7_1/tutorial/python/t1.py https://gitlab.onelab.info/gmsh/gmsh/-/blob/gmsh_4_7_1/tutorial/python/t3.py

Accepts ele_type = ‘HEX8’, ‘TET4’ or ‘TET10’, mesh will be generated with the help of gmsh

jax_fem.generate_mesh.check_mesh_TET4(points, cells)[source]#
jax_fem.generate_mesh.cylinder_mesh_gmsh(data_dir, R=5, H=10, circle_mesh=5, hight_mesh=20, rect_ratio=0.4)[source]#

By Xinxin Wu at PKU in July, 2022 Reference: https://www.researchgate.net/post/How_can_I_create_a_structured_mesh_using_a_transfinite_volume_in_gmsh R: radius H: hight circle_mesh:num of meshs in circle lines hight_mesh:num of meshs in hight rect_ratio: rect length/R

jax_fem.generate_mesh.get_elements(ele_type)[source]#

Mesh node ordering is important. If the input mesh file is Gmsh .msh or Abaqus .inp, meshio would convert it to its own ordering. My experience shows that meshio ordering is the same as Abaqus. For example, for a 10-node tetrahedron element, the ordering of meshio is the following https://web.mit.edu/calculix_v2.7/CalculiX/ccx_2.7/doc/ccx/node33.html The troublesome thing is that basix has a different ordering. As shown below https://defelement.com/elements/lagrange.html The consequence is that we need to define this “re_order” variable to make sure the ordering is correct.

jax_fem.generate_mesh.get_face_shape_vals_and_grads(ele_type, gauss_order=None)[source]#

TODO: Add comments

Returns:

  • face_shape_vals (ndarray) – (6, 4, 8) = (num_faces, num_face_quads, num_nodes)

  • face_shape_grads_ref (ndarray) – (6, 4, 3) = (num_faces, num_face_quads, num_nodes, dim)

  • face_weights (ndarray) – (6, 4) = (num_faces, num_face_quads)

  • face_normals (ndarray) – (6, 3) = (num_faces, dim)

  • face_inds (ndarray) – (6, 4) = (num_faces, num_face_vertices)

jax_fem.generate_mesh.get_meshio_cell_type(ele_type)[source]#

Reference: nschloe/meshio

jax_fem.generate_mesh.rectangle_mesh(Nx, Ny, domain_x, domain_y)[source]#

QUAD4 mesh, generated by our own code