Replies: 1 comment 1 reply
|
Hello @m-vik, Does this kind of tool meet your expectations? import numpy as np
from EasyFEA import Display, ElemType, Models, Simulations
from EasyFEA.Geoms import Domain
if __name__ == "__main__":
Display.Clear()
# mesh --------------------------------------------
result = "Exx"
domain = Domain((0, 0), (1, 1))
mesh = domain.Mesh_2D(elemType=ElemType.TRI3)
coords_p = np.array(
[
[0.5, 0.5, 0.0],
[0.8, 0.95, 0.0],
[0.08, 0.95, 0.0],
]
)
ax = Display.Plot_Mesh(mesh)
ax.plot(
*coords_p[:, : mesh.inDim].T,
ls="",
marker="s",
color="red",
)
# simu --------------------------------------------
simu = Simulations.Elastic(
mesh,
Models.Elastic.Isotropic(2, E=1, v=0.3),
)
simu.add_dirichlet(
mesh.Nodes_Conditions(lambda x, y, z: x == 0), [0, 0], ["x", "y"]
)
simu.add_dirichlet(mesh.Nodes_Conditions(lambda x, y, z: x == 1), [0.1], ["x"])
simu.Solve()
Display.Plot_Result(simu, "ux", plotMesh=True)
# get values --------------------------------------------
groupElem = mesh.groupElem
detectedNodes, detectedElements_e, connect_e_n, coordInElem_n = (
groupElem.Get_Mapping(
coords_p,
needCoordinates=(groupElem.order > 1),
)
)
values_p = np.zeros(len(coords_p))
if groupElem.order == 1:
result_e = simu.Result(result, nodeValues=False) # (Ne,)
for element, pidx in zip(detectedElements_e, connect_e_n):
values_p[pidx] = result_e[element]
useNodeValues = False
else:
Eps_n = simu.Result(result, nodeValues=True) # (Nn,)
Eps_e = groupElem.Locates_sol_e(Eps_n, 1) # (Ne, nPe)
for element, pidx in zip(detectedElements_e, connect_e_n):
xi = coordInElem_n[pidx] # (n_pts_in_e, dim)
N_pg = groupElem._Eval_Functions(groupElem._N(), xi) # (n_pts_in_e, 1, nPe)
values_p[pidx] = np.einsum("pin,n->p", N_pg, Eps_e[element])
useNodeValues = True
ax = Display.Plot_Result(
simu,
result,
nodeValues=useNodeValues,
plotMesh=True,
ncolors=11,
)
for p in detectedNodes:
ax.scatter(
*coords_p[p, : mesh.inDim],
marker="o",
label=f"{values_p[p]:.3f}",
)
ax.legend()
Display.plt.show()
|
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Hello,
I made an elastic simulation. I would like to know if it is possible to sample the strain along defined points (so basically interpolated between the elements/nodes). Because i need to investigate specific areas of my model.
Thank you!
All reactions