Skip to content

Commit 3d9e425

Browse files
committed
doc for custom laws
1 parent 878daaf commit 3d9e425

File tree

2 files changed

+35
-13
lines changed

2 files changed

+35
-13
lines changed

docsrc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"myst_parser",
4747
'nbsphinx',
4848
'sphinx_copybutton',
49+
'sphinx_design',
4950
]
5051

5152
nbsphinx_custom_formats = {

docsrc/gettingstarted/overview.rst

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,46 @@ Using the ``elastodynamicsx.pde`` package:
9191
* Multi-point constraint BCs:
9292
*Periodic*
9393

94-
* User-defined material laws and BCs:
94+
* User-defined material laws and BCs, using the ```ufl``` library:
9595

96-
.. jupyter-execute::
96+
.. dropdown:: Custom material laws
97+
98+
Specify :math:`\mathbf{M}`, :math:`\mathbf{C}` and :math:`\mathbf{K}`:
99+
100+
.. jupyter-execute::
101+
102+
import ufl
103+
104+
# ###
105+
# Here we re-implement mat1 using the interface for custom material laws
106+
dx_mat1 = ufl.Measure("dx", domain=V.mesh, subdomain_data=cell_tags)(tag_mat1)
107+
108+
# mass form
109+
m = lambda u, v: 1 * ufl.inner(u, v) * dx_mat1
110+
111+
# stiffness form
112+
epsilon = lambda u: ufl.sym(ufl.grad(u))
113+
sigma = lambda u: 2 * ufl.nabla_div(u) * ufl.Identity(len(u)) + 2 * 1 * epsilon(u)
114+
k = lambda u, v: ufl.inner(sigma(u), epsilon(v)) * dx_mat1
115+
116+
mat1_user_defined = material(V, 'custom', is_linear=True, M_fn=m, K_fn=k)
117+
118+
.. dropdown:: Custom BCs
119+
120+
Specify :math:`\mathbf{C}`, :math:`\mathbf{K}` and :math:`\mathbf{b}`:
97121

98-
import ufl
122+
.. jupyter-execute::
99123

100-
# ###
101-
# Here we re-implement mat1 using the interface for custom material laws
102-
dx_mat1 = ufl.Measure("dx", domain=V.mesh, subdomain_data=cell_tags)(tag_mat1)
124+
import ufl
103125

104-
# mass form
105-
m = lambda u, v: ufl.inner(u, v) * dx_mat1
126+
# ###
127+
# Here we re-implement bc1 using the interface for custom BCs
128+
ds_bc1 = ufl.Measure("ds", domain=V.mesh, subdomain_data=facet_tags)(tag_top)
106129

107-
# stiffness form
108-
epsilon = lambda u: ufl.sym(ufl.grad(u))
109-
sigma = lambda u: 2 * ufl.nabla_div(u) * ufl.Identity(len(u)) + 2 * 1 * epsilon(u)
110-
k = lambda u, v: ufl.inner(sigma(u), epsilon(v)) * dx_mat1
130+
# right hand side term
131+
b = lambda v: ufl.inner(T_N, v) * ds_bc1
111132

112-
mat1_user_defined = material(V, 'custom', is_linear=True, M_fn=m, K_fn=k)
133+
bc1_user_defined = boundarycondition(V , 'custom', b_fn=b)
113134

114135
* Define **body forces**:
115136

0 commit comments

Comments
 (0)