diff --git a/examples/example1.py b/examples/example1.py new file mode 100644 index 0000000..5640313 --- /dev/null +++ b/examples/example1.py @@ -0,0 +1,66 @@ +import calfem.geometry as cfg +import calfem.mesh as cfm +import calfem.vis_mpl as cfv + +g = cfg.Geometry() + +# Add points + +g.point([0, 0]) # 0 +g.point([1, 0]) # 1 +g.point([1, 1]) # 2 +g.point([0, 1]) # 3 + +# Add points for circle + +r = 0.20 + +g.point([0.5, 0.5]) # 4 +g.point([0.5, 0.5+r]) # 5 +g.point([0.5, 0.5-r]) # 6 +g.point([0.5+r, 0.5]) # 7 +g.point([0.5-r, 0.5]) # 8 + +# Add lines + +g.spline([0, 1]) # 0 +g.spline([1, 2]) # 1 +g.spline([2, 3]) # 2 +g.spline([3, 0]) # 3 + +# TODO: Add circles HERE + +g.circle([5, 4, 7]) # 4 +g.circle([7, 4, 6]) # 5 +g.circle([6, 4, 8]) # 6 +g.circle([8, 4, 5]) # 7 + +# Add surface and hole UPDATE + +g.surface([0, 1, 2, 3], [[7, 6, 5, 4]]) + +#cfv.figure(fig_size=(10.0,10.0)) +#cfv.draw_geometry(g) + +mesh = cfm.GmshMesh(g) + +# Mesh properties + +mesh.el_type = 3 +mesh.dofs_per_node = 1 # Degrees of freedom per node. +mesh.el_size_factor = 0.040 # Factor that changes element sizes. + +coords, edof, dofs, bdofs, elementmarkers = mesh.create() + + +cfv.figure(fig_size=(10,10)) +cfv.draw_mesh( + coords=coords, + edof=edof, + dofs_per_node=mesh.dofs_per_node, + el_type=mesh.el_type, + filled=True, + title="Example 01" +) + +cfv.show_and_wait_mpl() diff --git a/pyproject.toml b/pyproject.toml index d01264a..dabe328 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,12 +12,8 @@ dependencies = [ "numpy", "scipy", "tabulate", - "visvis", - "vedo", - "pyvtk", - "qtpy", - "tabulate", ] + requires-python = ">=3.8" readme = "README.md" license = {text = "MIT"} @@ -48,3 +44,9 @@ build-backend = "pdm.backend" [tool.pdm] distribution = true + +[project.optional-dependencies] +visvis = [ "visvis" ] +vedo = [ "vedo" ] +pyvtk = [ "pyvtk" ] +qtpy = [ "qtpy" ] diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/calfem/utils.py b/src/calfem/utils.py index 4d84b4b..3899b45 100644 --- a/src/calfem/utils.py +++ b/src/calfem/utils.py @@ -58,17 +58,26 @@ def disp(msg): else: print(msg) +def str_disp(msg): + return f"{msg}\n" + def disp_par(msg): if type_of_script() == 'jupyter': display(HTML(f"
{msg}
")) else: print(f"\nmsg\n") +def str_disp_par(msg): + return f"\n{msg}\n" + def disp_bold(msg): if type_of_script() == 'jupyter': display(HTML(f"{msg}")) else: print(f"**{msg}**") + +def str_disp_bold(msg): + return f"**{msg}**" def disp_bold_par(msg): if type_of_script() == 'jupyter': @@ -76,23 +85,35 @@ def disp_bold_par(msg): else: print(f"\n**{msg}**\n") +def str_disp_bold_par(msg): + return f"\n**{msg}**\n" + def disp_h1(msg): if type_of_script() == 'jupyter': display(HTML(f"