Skip to content

Commit

Permalink
add test, format black
Browse files Browse the repository at this point in the history
  • Loading branch information
adtzlr committed Nov 28, 2024
1 parent 5692cac commit d5b28a2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/felupe/mechanics/_solidbody.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,13 @@ def _cauchy_stress(self, field=None):
return dot(P, transpose(F)) / J

def _mass(self, density=None):

if density is None:
density = self.density

field = self.field[0].as_container()
dim = field[0].dim

form = self._form(
fun=[density * np.eye(dim).reshape(dim, dim, 1, 1)],
v=field,
Expand All @@ -413,5 +413,5 @@ def _mass(self, density=None):
grad_v=[False],
grad_u=[False],
)

return form.assemble()
17 changes: 15 additions & 2 deletions tests/test_free_vibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@


def test_free_vibration():

mesh = fem.Cube(a=(0, 0, 5), b=(50, 100, 30), n=(3, 6, 4))
region = fem.RegionHexahedron(mesh)
field = fem.FieldContainer([fem.Field(region, dim=3)])

umat = fem.NeoHooke(mu=1, bulk=2)
solid = fem.SolidBody(umat=umat, field=field, density=1.5e-9)

job = fem.FreeVibration([solid]).evaluate(x0=field)
new_field, frequency = job.extract(x0=field, n=-1, inplace=False)


def test_free_vibration_mixed():

meshes = [
fem.Cube(a=(0, 0, 30), b=(50, 100, 35), n=(3, 6, 2)),
fem.Cube(a=(0, 0, 5), b=(50, 100, 30), n=(3, 6, 4)),
Expand Down Expand Up @@ -34,8 +48,7 @@ def test_free_vibration():
job = fem.FreeVibration(solids, boundaries).evaluate(x0=field)
new_field, frequency = job.extract(x0=field, n=-1, inplace=False)

assert np.isclose(new_field[0].values.max(), 358.08157)


if __name__ == "__main__":
test_free_vibration()
test_free_vibration_mixed()
6 changes: 5 additions & 1 deletion tests/test_mechanics.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ def test_solidbody_incompressible():

umat = fem.OgdenRoxburgh(fem.NeoHooke(mu=1), r=3, m=1, beta=0)
b = fem.SolidBodyNearlyIncompressible(
umat=umat, field=u, bulk=5000, state=fem.StateNearlyIncompressible(u), density=1.0
umat=umat,
field=u,
bulk=5000,
state=fem.StateNearlyIncompressible(u),
density=1.0,
)

M = b.assemble.mass()
Expand Down

0 comments on commit d5b28a2

Please sign in to comment.