deepmodeling / jax-fem

Differentiable Finite Element Method with JAX
GNU General Public License v3.0
290 stars 45 forks source link

Boundary conditions using mesh properties. #20

Closed wilko339 closed 7 months ago

wilko339 commented 8 months ago

When defining boundary conditions for nodes, is there a way the interface can be extended to not only take in the node coordinates, but also the node index? Something like this:

def top_nodes(point, index):
    top = jnp.isclose(point[2], upper_surface_height, atol=TOLERANCE    # Nodes on the top surface of my mesh
    active = jnp.any(jnp.in1d(point.index, active_nodes))    # Nodes in my predefined active list
    return top & active

I am implementing a layer-by-layer model with element activation. I can deactivate elements above a certain height based on their centroid, but when applying the boundary condition, I cannot select only the nodes connected to my active elements with the XYZ position alone.

Any suggestions welcome!

tianjuxue commented 8 months ago

Are you imposing Dirichlet boundary condition or Neumann condition?

wilko339 commented 8 months ago

Neumann, an input heat flux.

tianjuxue commented 8 months ago

I have implemented the feature you requested. Please check this example and let me know if this fixes your problem.