Skip to content

Import pyvista.UnstructuredGrid as MeshContainer? #830

@adtzlr

Description

@adtzlr

Take the points and cells_dict of an unstructured grid and create a MeshContainer. This should simplify things like

import felupe as fem
import pyvista as pv
import skgmsh as sg

source = pv.Polygon(n_sides=6, radius=1, fill=False)
delaunay_2d = sg.frontal_delaunay_2d(edge_source=source, target_sizes=0.1)

mesh = (
    fem.Mesh(
        points=delaunay_2d.points[:, :2],  # in-plane points
        cells=delaunay_2d.cells_dict[pv.CellType.TRIANGLE],  # triangle cells
        cell_type="triangle",
    )
    .flip()
    .rotate(90, axis=2)
)
region = fem.RegionTriangle(mesh)
field = fem.FieldContainer([fem.FieldPlaneStrain(region, dim=2)])
boundaries, loadcase = fem.dof.shear(
    field,
    sym=False,
    moves=(0.75, 0.0, 0.0),
)
solid = fem.SolidBody(umat=fem.LinearElastic(E=1, nu=0.4), field=field)
step = fem.Step(items=[solid], boundaries=boundaries)
job = fem.Job(steps=[step]).evaluate()
ax = solid.imshow("Principal Values of Logarithmic Strain", project=fem.project)

image

to

source = pv.Polygon(n_sides=6, radius=1, fill=False)
delaunay_2d = sg.frontal_delaunay_2d(edge_source=source, target_sizes=0.1)

mesh = fem.mesh.from_unstructured_grid(delaunay_2d)[0].rotate(90, axis=2)
mesh.update(points=mesh.points[:, :2])
# ...

Tasks

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions