Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute curvature on mesh boundary and use in model specifications #152

Merged
merged 6 commits into from
Dec 19, 2023

Conversation

emmetfrancis
Copy link
Collaborator

@emmetfrancis emmetfrancis commented Dec 6, 2023

This PR includes the following additions to SMART:

In mesh_tools:

  • Add function compute_curvature, which computes the mean curvature over specified boundaries and writes out curvatures as a vertex mesh function over the parent mesh. Currently only tested in 2D.
  • Add return_curvature as an argument to create_2dcell. If only a half cell geometry is desired, curvatures are computed over the whole cell contour to avoid errors at the x = 0 axis, then linearly interpolated onto the half-cell mesh.

In mesh:

  • Add curvature as an attribute of parent_mesh objects (is empty by default).

In model:

  • If parent_mesh.curvature is not empty, each compartment has an associated dolfin function curv_func containing curvatures from the vertex mesh function mapped onto the compartment's FunctionSpace using the new function model.mf0_to_fun.
  • If user defines an initial condition that contains curv as a free symbol, then the associated curv_func is substituted into this expression when evaluating the initial condition in model.dolfin_set_function_values

In model_assembly:

  • Add curv to equation variables for reaction that include curv as a free symbol.

A new version of example 2, example2_withcurv has been added to demonstrate use of the new features.

@emmetfrancis
Copy link
Collaborator Author

To do before merging:

  • Test curvature calculations in 3D.
  • Alter curvature definition for axisymmetric geometries defined on 2D mesh.
  • Consider defining curvature as a parameter (would require implementing spatially-dependent parameters, maybe in a separate PR)

@emmetfrancis
Copy link
Collaborator Author

First two points above have been completed (curvature needed to be divided by 2 for consistency in 3D). Spatially-dependent parameters may be implemented in a future PR.

kappa_mf = d.MeshFunction("double", dmesh_half, 0)

for i in range(len(cell_marker_vec)):
mesh = d.MeshView.create(mf_cell, cell_marker_vec[i])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for later: we could use the new create_meshview function in dolfin to avoid some, But not all parallel issued

@emmetfrancis
Copy link
Collaborator Author

Added the few curvature calculation tests to the "tests" folder. The calculations in 3D are quite inaccurate here (likely very sensitive to the discretization); we could look into improving this calculation in the future.

@finsberg finsberg self-requested a review December 18, 2023 10:18
@finsberg finsberg merged commit 7b0595a into development Dec 19, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants