Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 2 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,9 @@ dist/
*.iml
.idea/
.vscode/settings.json
examples/.ipynb_checkpoints/exm0-checkpoint.ipynb
examples/.ipynb_checkpoints/exm1-checkpoint.ipynb
examples/.ipynb_checkpoints/exm2-checkpoint.ipynb
examples/.ipynb_checkpoints/exm3-checkpoint.ipynb
examples/.ipynb_checkpoints/exm6-checkpoint.ipynb
examples/.ipynb_checkpoints/exm7-checkpoint.ipynb
examples/.ipynb_checkpoints/*
# .vscode/settings.json
examples/.ipynb_checkpoints/exm10-checkpoint.ipynb
examples/.ipynb_checkpoints/exm12-checkpoint.ipynb
examples/.ipynb_checkpoints/exm13-checkpoint.ipynb
calfem/.ipynb_checkpoints/core-checkpoint.py
calfem/.ipynb_checkpoints/geometry-checkpoint.py
calfem/.ipynb_checkpoints/mesh-checkpoint.py
calfem/.ipynb_checkpoints/vis_mpl-checkpoint.py
examples/.ipynb_checkpoints/exed1-checkpoint.py
examples/.ipynb_checkpoints/exed1-checkpoint.ui
examples/.ipynb_checkpoints/exm1-checkpoint.py
examples/.ipynb_checkpoints/exm2_mpl-checkpoint.py
examples/.ipynb_checkpoints/exm4_mpl-checkpoint.py
examples/.ipynb_checkpoints/exm7_mpl-checkpoint.py
examples/.ipynb_checkpoints/exs1-checkpoint.py
examples/.ipynb_checkpoints/Untitled1-checkpoint.ipynb
examples/.ipynb_checkpoints/exs4a-checkpoint.py
calfem/.ipynb_checkpoints/*
exm6.vtk

# new notebook examples
Expand Down
2 changes: 1 addition & 1 deletion build-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def build_package():

if __name__ == "__main__":

package_version = "3.6.4"
package_version = "3.6.5"

update_setup("calfem-python", package_version, "'numpy', 'visvis', 'pyvtk', 'matplotlib', 'scipy', 'gmsh', 'qtpy', 'vedo', 'tabulate'")

Expand Down
21 changes: 0 additions & 21 deletions calfem-python.psproj

This file was deleted.

4 changes: 2 additions & 2 deletions calfem/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4166,7 +4166,7 @@ def plante(ex, ey, ep, D, eq=None):
if eq is None:
return Ke
else:
return Ke, fe
return Ke, fe.T

#--------- plane strain --------------------------------------

Expand All @@ -4190,7 +4190,7 @@ def plante(ex, ey, ep, D, eq=None):
if eq is None:
return Ke
else:
return Ke, fe
return Ke, fe.T

else:
info("Error ! Check first argument, ptype=1 or 2 allowed")
Expand Down
81 changes: 77 additions & 4 deletions calfem/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import numpy as np
import calfem.core as cfc
import logging as cflog
import tabulate as tab

have_pyvtk = True

try:
import pyvtk as vtk
except:
except:
have_pyvtk = False

haveMatplotLib = True
Expand All @@ -23,14 +24,84 @@
have_mlab = haveMlab
have_matplotlib = haveMatplotLib

have_ipython = True

try:
from IPython.core.display import display, HTML
except:
have_ipython = False



def error(msg):
cflog.error(" "+msg)


def info(msg):
cflog.info(" "+msg)

def set_debug_level(level):
cflog.getLogger().setLevel(level)

def type_of_script():
try:
ipy_str = str(type(get_ipython()))
if 'zmqshell' in ipy_str:
return 'jupyter'
if 'terminal' in ipy_str:
return 'ipython'
except:
return 'terminal'

def disp(msg):
if type_of_script() == 'jupyter':
display(HTML(f"{msg}"))
else:
print(msg)

def disp_par(msg):
if type_of_script() == 'jupyter':
display(HTML(f"<p>{msg}</p>"))
else:
print(f"\nmsg\n")

def disp_bold(msg):
if type_of_script() == 'jupyter':
display(HTML(f"<b>{msg}</b>"))
else:
print(f"**{msg}**")

def disp_bold_par(msg):
if type_of_script() == 'jupyter':
display(HTML(f"<p><b>{msg}</b></p>"))
else:
print(f"\n**{msg}**\n")

def disp_h1(msg):
if type_of_script() == 'jupyter':
display(HTML(f"<h1>{msg}</h1>"))
else:
print(f"\n# {msg}\n")

def disp_h2(msg):
if type_of_script() == 'jupyter':
display(HTML(f"<h2>{msg}</h2>"))
else:
print(f"\n## {msg}\n")

def disp_h3(msg):
if type_of_script() == 'jupyter':
display(HTML(f"<h3>{msg}</h3>"))
else:
print(f"\n## {msg}\n")

def disp_array(a, headers=[], fmt=".4e", tablefmt="psql", showindex=False):
"""
Print a numpy array in a nice way.
"""
if type_of_script() == 'jupyter':
display(tab.tabulate(np.asarray(a), tablefmt="html", floatfmt=".4e", showindex=showindex, headers=headers))
else:
print(tab.tabulate(np.asarray(a), tablefmt=tablefmt, floatfmt=fmt, showindex=showindex, headers=headers))

class ElementProperties(object):
def __init__(self):
Expand Down Expand Up @@ -472,7 +543,9 @@ def export_vtk_stress(filename, coords, topo, a=None, el_scalar=None, el_vec1=No
el_vec2 Vector value for each element (list)
"""

points = coords.tolist()
points = np.zeros([coords.shape[0], 3], dtype=np.float64)
points[:,0:2] = coords
points = points.tolist()
polygons = (topo-1).tolist()

displ = []
Expand All @@ -485,7 +558,7 @@ def export_vtk_stress(filename, coords, topo, a=None, el_scalar=None, el_vec1=No

if a is not None:
for i in range(0, len(a), 2):
displ.append([np.asscalar(a[i]), np.asscalar(a[i+1]), 0.0])
displ.append([a[i].item(), a[i+1].item(), 0.0])

point_data = vtk.PointData(vtk.Vectors(displ, name="displacements"))

Expand Down
Loading