Skip to content

Commit

Permalink
Fix FieldContainer.plot() for RegionVertex (no gradient available)
Browse files Browse the repository at this point in the history
  • Loading branch information
adtzlr committed Feb 17, 2025
1 parent b5349e7 commit f3614c1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
60 changes: 32 additions & 28 deletions src/felupe/view/_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f3614c1

Please sign in to comment.