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

Add support for dual triangle/tetra-regions #373

Merged
merged 2 commits into from
Jan 16, 2023

Conversation

adtzlr
Copy link
Owner

@adtzlr adtzlr commented Jan 16, 2023

No description provided.

@adtzlr adtzlr added the enhancement New feature or request label Jan 16, 2023
@adtzlr adtzlr added this to the 6.3 milestone Jan 16, 2023
@adtzlr adtzlr self-assigned this Jan 16, 2023
@adtzlr
Copy link
Owner Author

adtzlr commented Jan 16, 2023

Example 1:

import felupe as fem
import numpy as np

line = fem.mesh.Line(a=15, b=30, n=6)
mesh = fem.mesh.revolve(line, phi=180, axis=2, n=13)
bush = fem.mesh.triangulate(mesh)
mesh = fem.mesh.add_midpoints_edges(bush)

# fix midpoints
pts = fem.mesh.revolve(line, phi=180, axis=2, n=25).points
for p in pts:
    x = np.linalg.norm(mesh.points, axis=1)
    dx = np.linalg.norm(mesh.points - p, axis=1)
    i = np.argmin(dx)
    if dx[i] / x[i] < 0.01:
        mesh.points[i] = p
        
region = fem.RegionQuadraticTriangle(mesh)
field = fem.FieldsMixed(region, n=3, planestrain=True)
umat = fem.ThreeFieldVariation(fem.NeoHooke(mu=1, bulk=5000))

solid = fem.SolidBody(umat, field)
inner = np.isclose(np.linalg.norm(mesh.points, axis=1), 15, rtol=0.01)
outer = np.isclose(np.linalg.norm(mesh.points, axis=1), 30, rtol=0.01)
bounds = dict(
    sym=fem.Boundary(field[0], fy=0, skip=(1, 0)),
    inner=fem.Boundary(field[0], mask=inner, skip=(1, 0)),
    outer=fem.Boundary(field[0], mask=outer),
    move=fem.Boundary(field[0], mask=inner, skip=(0, 1)),
)
step = fem.Step(
    items=[solid], 
    ramp={bounds["move"]: fem.math.linsteps([0, 5], 50)}, 
    boundaries=bounds
)
job = fem.CharacteristicCurve(steps=[step], boundary=bounds["move"])
job.evaluate(filename="bushing.xdmf")
job.plot(yscale=2)

image
(unstable)

@codecov
Copy link

codecov bot commented Jan 16, 2023

Codecov Report

Base: 97.36% // Head: 97.36% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (02b5f23) compared to base (2bfe392).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #373   +/-   ##
=======================================
  Coverage   97.36%   97.36%           
=======================================
  Files          81       81           
  Lines        3568     3574    +6     
=======================================
+ Hits         3474     3480    +6     
  Misses         94       94           
Impacted Files Coverage Δ
felupe/region/_templates.py 99.03% <100.00%> (+0.05%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@adtzlr
Copy link
Owner Author

adtzlr commented Jan 16, 2023

and the 2D plane-strain MINI-element:

import felupe as fem
import matadi as mat
import numpy as np

line = fem.mesh.Line(a=15, b=30, n=21)
mesh = fem.mesh.revolve(line, phi=180, axis=2, n=21)
bush = fem.mesh.triangulate(mesh)
mesh = fem.mesh.add_midpoints_faces(bush)
mesh.points[mesh.npoints - mesh.ncells:] = 0
mesh.cell_type = "triangle"

# fix midpoints
pts = fem.mesh.revolve(line, phi=180, axis=2, n=41).points
for p in pts:
    x = np.linalg.norm(mesh.points, axis=1)
    dx = np.linalg.norm(mesh.points - p, axis=1)
    i = np.argmin(dx)
    if dx[i] / x[i] < 0.01:
        mesh.points[i] = p
        
region = fem.RegionTriangleMINI(mesh)
field = fem.FieldsMixed(region, n=3, planestrain=True)
umat = fem.ThreeFieldVariation(fem.NeoHooke(mu=1, bulk=5000))

solid = fem.SolidBody(umat, field)
inner = np.isclose(np.linalg.norm(mesh.points, axis=1), 15, rtol=0.01)
outer = np.isclose(np.linalg.norm(mesh.points, axis=1), 30, rtol=0.01)
bounds = dict(
    sym=fem.Boundary(field[0], fy=0, skip=(1, 0)),
    inner=fem.Boundary(field[0], mask=inner, skip=(1, 0)),
    outer=fem.Boundary(field[0], mask=outer),
    move=fem.Boundary(field[0], mask=inner, skip=(0, 1)),
)
step = fem.Step(
    items=[solid], 
    ramp={bounds["move"]: fem.math.linsteps([0, 9], 10)}, 
    boundaries=bounds
)
job = fem.CharacteristicCurve(steps=[step], boundary=bounds["move"])
job.evaluate(filename="bushing.xdmf", mesh=bush.as_meshio())
job.plot(yscale=2)

image

(quite bad large strain prediction)

@adtzlr adtzlr merged commit db03fcb into main Jan 16, 2023
@adtzlr adtzlr deleted the add-dual-triangle-tetra-region branch January 16, 2023 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant