cashocs.create_material_parameter#
- cashocs.create_material_parameter(
- material_dict: dict,
- mesh: CashocsMesh,
- dg0_space: fenics.FunctionSpace | None = None,
Creates a material parameter that can vary for different subdomains.
- Parameters:
material_dict (dict) – The dictionary that contains the material parameters. The keys are the indices of the subdomains (as generated with Gmsh) and the values are the values of the material parameter on the respective subdomain. If multiple subdomains share the same value, they can also be put inside a tuple and used as a single key for the dictionary.
mesh (CashocsMesh) – The finite element mesh.
dg0_space (fenics.FunctionSpace | None) – The space of DG0 elements on the mesh. If this is None, then the space is created internally.
- Returns:
A UFL expression that can be used as material parameter.
- Return type:
ufl.core.expr.Expr
Examples
Consider the following Poisson problem
\[- \nabla \cdot (\mu \nabla u) = f \text{ in } \Omega \quad u = 0 \text{ on } \Gamma,\]where the parameter \(\mu\) varies between two subdomains, i.e., \(\mu = \mu_{in}\) in \(\Omega_{in}\) and \(\mu = \mu_{out}\) in \(\Omega_{out}\), where \(\Omega = \Omega_{in} \cup \Omega_{out}\). The parameter \(\mu\) can be created with the help of this function. Assume that \(\Omega_{in}\) has the index 1 and that \(\Omega_{out}\) has index 2, then we can use the following code
mesh, subdomains, boundaries, dx, ds, dS = cashocs.import_mesh(...) mu_in = 1.0 # example mu_out = 10.0 # example material_dict = {1: mu_in, 2: mu_out} mu = cashocs.create_material_parameter(material_dict)