Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FieldsMixed() for MINI-elements #538

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ All notable changes to this project will be documented in this file. The format

## [Unreleased]

### Added
- Add cell-type argument to `Mesh.add_midpoints_volumes(cell_type=None)` and its variants for edges and faces.

### Changed
- Change function signature and enhance `dof.biaxial(field, lefts=(None, None), rights=(None, None), moves=(0.2, 0.2), axes=(0, 1), clampes=(False, False), sym=True)`. Now with a full-featured docstring including an example.
- Change function signature and enhance `dof.shear(field, bottom=None, top=None, moves=(0.2, 0.0, 0.0), axes=(0, 1), sym=True)`. Now with a full-featured docstring including an example. This is not backward compatible! However, due to the fact, that this was previously a non-documented function this won't enforce a new major version.

### Fixed
- Fix `FieldsMixed()` for regions with MINI-element formulations: Disable the disconnection of the dual mesh.

### Removed
- Remove `dof.planar()` because this is a special case of the biaxial load case `dof.biaxial(field, clampes=(True, False), moves=(0.2, 0), sym=False, axes=(0, 1))`.

Expand Down
14 changes: 14 additions & 0 deletions src/felupe/_field/_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ def __init__(
RegionTriangleMINI: RegionTriangle,
RegionLagrange: RegionLagrange,
}
mesh_kwargs = {
RegionHexahedron: {},
RegionQuad: {},
RegionQuadraticQuad: {},
RegionBiQuadraticQuad: {},
RegionQuadraticHexahedron: {},
RegionTriQuadraticHexahedron: {},
RegionQuadraticTetra: {},
RegionQuadraticTriangle: {},
RegionTetraMINI: {"disconnect": False},
RegionTriangleMINI: {"disconnect": False},
RegionLagrange: {},
}
points_per_cell = {
RegionConstantHexahedron: 1,
RegionConstantQuad: 1,
Expand All @@ -129,6 +142,7 @@ def __init__(
points_per_cell=points_per_cell[RegionDual],
offset=offset,
npoints=npoints,
**mesh_kwargs[type(region)],
)

region_dual = RegionDual(
Expand Down
71 changes: 37 additions & 34 deletions src/felupe/mesh/_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,10 @@ def collect_volumes(points, cells, cell_type):


@mesh_or_data
def add_midpoints_edges(points, cells, cell_type):
def add_midpoints_edges(points, cells, cell_type, cell_type_new=None):
""" "Add midpoints on edges for given points and cells
and update cell_type accordingly."""

cell_types_new = {
"triangle": "triangle6",
"tetra": "tetra10",
"quad": "quad8",
"hexahedron": "hexahedron20",
}

# collect edges
points_edges, cells_edges, _ = collect_edges(
points,
Expand All @@ -252,25 +245,22 @@ def add_midpoints_edges(points, cells, cell_type):
points_new = np.vstack((points, points_edges))
cells_new = np.hstack((cells, cells_edges))

return points_new, cells_new, cell_types_new[cell_type]
if cell_type_new is None:
cell_type_new = {
"triangle": "triangle6",
"tetra": "tetra10",
"quad": "quad8",
"hexahedron": "hexahedron20",
}[cell_type]

return points_new, cells_new, cell_type_new


@mesh_or_data
def add_midpoints_faces(points, cells, cell_type):
def add_midpoints_faces(points, cells, cell_type, cell_type_new=None):
""" "Add midpoints on faces for given points and cells
and update cell_type accordingly."""

cell_types_new = {
None: None,
"triangle": None,
"triangle6": "triangle7",
"tetra10": "tetra14",
"quad": None,
"quad8": "quad9",
"hexahedron": None,
"hexahedron20": "hexahedron26",
}

# collect faces
points_faces, cells_faces, _ = collect_faces(
points,
Expand All @@ -286,24 +276,26 @@ def add_midpoints_faces(points, cells, cell_type):
points_new = np.vstack((points, points_faces))
cells_new = np.hstack((cells, cells_faces))

return points_new, cells_new, cell_types_new[cell_type]
if cell_type_new is None:
cell_type_new = {
None: None,
"triangle": None,
"triangle6": "triangle7",
"tetra10": "tetra14",
"quad": None,
"quad8": "quad9",
"hexahedron": None,
"hexahedron20": "hexahedron26",
}[cell_type]

return points_new, cells_new, cell_type_new


@mesh_or_data
def add_midpoints_volumes(points, cells, cell_type):
def add_midpoints_volumes(points, cells, cell_type, cell_type_new=None):
""" "Add midpoints on volumes for given points and cells
and update cell_type accordingly."""

cell_types_new = {
None: None,
"tetra": None,
"tetra10": None,
"tetra14": "tetra15",
"hexahedron": None,
"hexahedron20": None,
"hexahedron26": "hexahedron27",
}

# collect volumes
points_volumes, cells_volumes, _ = collect_volumes(
points,
Expand All @@ -319,4 +311,15 @@ def add_midpoints_volumes(points, cells, cell_type):
points_new = np.vstack((points, points_volumes))
cells_new = np.hstack((cells, cells_volumes))

return points_new, cells_new, cell_types_new[cell_type]
if cell_type_new is None:
cell_type_new = {
None: None,
"tetra": None,
"tetra10": None,
"tetra14": "tetra15",
"hexahedron": None,
"hexahedron20": None,
"hexahedron26": "hexahedron27",
}[cell_type]

return points_new, cells_new, cell_type_new
12 changes: 6 additions & 6 deletions src/felupe/mesh/_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,13 +296,13 @@ def collect_volumes(self):
return collect_volumes(self)

@wraps(add_midpoints_edges)
def add_midpoints_edges(self):
return add_midpoints_edges(self)
def add_midpoints_edges(self, cell_type=None):
return add_midpoints_edges(self, cell_type_new=cell_type)

@wraps(add_midpoints_faces)
def add_midpoints_faces(self):
return add_midpoints_faces(self)
def add_midpoints_faces(self, cell_type=None):
return add_midpoints_faces(self, cell_type_new=cell_type)

@wraps(add_midpoints_volumes)
def add_midpoints_volumes(self):
return add_midpoints_volumes(self)
def add_midpoints_volumes(self, cell_type=None):
return add_midpoints_volumes(self, cell_type_new=cell_type)