diff --git a/CHANGELOG.md b/CHANGELOG.md index 20223e39..383c08fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ All notable changes to this project will be documented in this file. The format - Fix `Boundary(..., mode="and")` by ignoring any undefined axis. - Fix `tools.hello_world(planestrain=True)` with the correct region `RegionQuad` for the plane-strain template. - Fix the cells-array in `RegionQuadraticQuadBoundary` for midpoints of edges. +- Fix `FieldContainer.plot()` for regions without the shape-function gradients available. ### Removed - Remove the unused `shape`-argument in `element.Element(shape)`. Adopt the arbitrary-lagrange element to use its own `dim`-argument. This simplifies the creation of custom finite element formulations. diff --git a/src/felupe/view/_field.py b/src/felupe/view/_field.py index dbc3575d..3c367958 100644 --- a/src/felupe/view/_field.py +++ b/src/felupe/view/_field.py @@ -81,34 +81,38 @@ def __init__( point_data_from_field = {} cell_data_from_field = {} - if project is None: - cell_data_from_field = { - "Deformation Gradient": field.evaluate.deformation_gradient() - .mean(-2) - .T, - "Logarithmic Strain": field.evaluate.strain(tensor=True, asvoigt=True) - .mean(-2) - .T, - "Principal Values of Logarithmic Strain": field.evaluate.strain( - tensor=False - ) - .mean(-2) - .T, - } - elif callable(project): - point_data_from_field = { - "Deformation Gradient": project( - field.evaluate.deformation_gradient(), field.region - ), - "Logarithmic Strain": project( - field.evaluate.strain(tensor=True, asvoigt=True), field.region - ), - "Principal Values of Logarithmic Strain": project( - field.evaluate.strain(tensor=False), field.region - ), - } - else: - raise TypeError("The project-argument must be callable or None.") + if hasattr(field.region, "dhdX"): + + if project is None: + cell_data_from_field = { + "Deformation Gradient": field.evaluate.deformation_gradient() + .mean(-2) + .T, + "Logarithmic Strain": field.evaluate.strain( + tensor=True, asvoigt=True + ) + .mean(-2) + .T, + "Principal Values of Logarithmic Strain": field.evaluate.strain( + tensor=False + ) + .mean(-2) + .T, + } + elif callable(project): + point_data_from_field = { + "Deformation Gradient": project( + field.evaluate.deformation_gradient(), field.region + ), + "Logarithmic Strain": project( + field.evaluate.strain(tensor=True, asvoigt=True), field.region + ), + "Principal Values of Logarithmic Strain": project( + field.evaluate.strain(tensor=False), field.region + ), + } + else: + raise TypeError("The project-argument must be callable or None.") point_data_from_field["Displacement"] = displacement(field)