Skip to content
Snippets Groups Projects
Commit 6a2d44f7 authored by Nils Kohl's avatar Nils Kohl :full_moon_with_face:
Browse files

Fixing FE coefficient "getter" for vector spaces.

parent 3190dc38
No related branches found
No related tags found
1 merge request!24Parametric mappings
...@@ -468,10 +468,13 @@ def fem_function_on_element( ...@@ -468,10 +468,13 @@ def fem_function_on_element(
domain == "reference" domain == "reference"
), "Tabulating the basis evaluation not implemented for affine domain." ), "Tabulating the basis evaluation not implemented for affine domain."
rows = geometry.dimensions if function_space.is_vectorial else 1
if domain == "reference": if domain == "reference":
# On the reference domain, the reference coordinates symbols can be used directly, so no substitution # On the reference domain, the reference coordinates symbols can be used directly, so no substitution
# has to be performed for the shape functions. # has to be performed for the shape functions.
s = sp.zeros(1, 1)
s = sp.zeros(rows, 1)
for dof, phi in zip( for dof, phi in zip(
dofs, dofs,
( (
...@@ -487,7 +490,7 @@ def fem_function_on_element( ...@@ -487,7 +490,7 @@ def fem_function_on_element(
# On the affine / computational domain, the evaluation point is first mapped to reference space and then # On the affine / computational domain, the evaluation point is first mapped to reference space and then
# the reference space coordinate symbols are substituted with the transformed point. # the reference space coordinate symbols are substituted with the transformed point.
eval_point_on_ref = trafo_affine_point_to_ref(geometry, symbolizer=symbolizer) eval_point_on_ref = trafo_affine_point_to_ref(geometry, symbolizer=symbolizer)
s = sp.zeros(1, 1) s = sp.zeros(rows, 1)
for dof, phi in zip( for dof, phi in zip(
dofs, dofs,
function_space.shape( function_space.shape(
...@@ -523,7 +526,7 @@ def fem_function_gradient_on_element( ...@@ -523,7 +526,7 @@ def fem_function_gradient_on_element(
dof_map: Optional[List[int]] = None, dof_map: Optional[List[int]] = None,
basis_eval: Union[str, List[sp.Expr]] = "default", basis_eval: Union[str, List[sp.Expr]] = "default",
dof_symbols: Optional[List[DoFSymbol]] = None, dof_symbols: Optional[List[DoFSymbol]] = None,
) -> sp.Matrix: ) -> Tuple[sp.Matrix, List[DoFSymbol]]:
"""Returns an expression that is the gradient of the element-local polynomial, either in affine or reference coordinates. """Returns an expression that is the gradient of the element-local polynomial, either in affine or reference coordinates.
The expression is build using DoFSymbol instances so that the DoFs can be resolved later. The expression is build using DoFSymbol instances so that the DoFs can be resolved later.
...@@ -553,7 +556,8 @@ def fem_function_gradient_on_element( ...@@ -553,7 +556,8 @@ def fem_function_gradient_on_element(
if domain == "reference": if domain == "reference":
# On the reference domain, the reference coordinates symbols can be used directly, so no substitution # On the reference domain, the reference coordinates symbols can be used directly, so no substitution
# has to be performed for the shape functions. # has to be performed for the shape functions.
s = sp.zeros(geometry.dimensions, 1) cols = geometry.dimensions if function_space.is_vectorial else 1
s = sp.zeros(geometry.dimensions, cols)
for dof, grad_phi in zip( for dof, grad_phi in zip(
dofs, dofs,
( (
...@@ -571,4 +575,4 @@ def fem_function_gradient_on_element( ...@@ -571,4 +575,4 @@ def fem_function_gradient_on_element(
raise HOGException( raise HOGException(
f"Invalid domain '{domain}': cannot evaluate local polynomial here." f"Invalid domain '{domain}': cannot evaluate local polynomial here."
) )
return s, dofs return sp.Matrix(s), dofs
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment