FEM: code formating, print function
This commit is contained in:
committed by
Yorik van Havre
parent
d150dec132
commit
72db8632ab
@@ -63,7 +63,7 @@ def insert(filename, docname):
|
||||
########## module specific methods ##########
|
||||
def import_dat(filename, Analysis=None):
|
||||
r = readResult(filename)
|
||||
# print ("Results {}".format(r))
|
||||
# print("Results {}".format(r))
|
||||
return r
|
||||
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class WriteXDMFTaskPanel:
|
||||
default_value = int(self.form.tableGroups.item(r, 3).text())
|
||||
marked_value = int(self.form.tableGroups.item(r, 4).text())
|
||||
except:
|
||||
print("ERROR: value conversion failed in table to dict: assuming 0 for default, 1 for marked.")
|
||||
FreeCAD.Console.PrintError("ERROR: value conversion failed in table to dict: assuming 0 for default, 1 for marked.\n")
|
||||
|
||||
group_values_dict[g] = (marked_value, default_value)
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
from __future__ import print_function
|
||||
|
||||
__title__ = "FreeCAD Fenics XDMF mesh reader"
|
||||
__author__ = "Johannes Hartung"
|
||||
@@ -29,10 +28,12 @@ __url__ = "http://www.freecadweb.org"
|
||||
# \ingroup FEM
|
||||
# \brief FreeCAD Fenics Mesh XDMF reader for FEM workbench
|
||||
|
||||
import FreeCAD
|
||||
|
||||
|
||||
def read_fenics_mesh_xdmf(xdmffilename):
|
||||
|
||||
print("Not operational, yet")
|
||||
FreeCAD.Console.PrintMessage("Not operational, yet\n")
|
||||
|
||||
return {'Nodes': {},
|
||||
'Hexa8Elem': {}, 'Penta6Elem': {}, 'Tetra4Elem': {}, 'Tetra10Elem': {},
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__title__ = "FemMesh to Mesh converter"
|
||||
__author__ = "Frantisek Loeffelmann, Ulrich Brammer, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
@@ -99,7 +97,7 @@ def femmesh_2_mesh(myFemMesh, myResults=None):
|
||||
if myFemMesh.VolumeCount > 0:
|
||||
for ele in myFemMesh.Volumes:
|
||||
element_nodes = myFemMesh.getElementNodes(ele)
|
||||
# print 'element_node: ', element_nodes
|
||||
# print('element_node: ', element_nodes)
|
||||
faceDef = face_dicts[len(element_nodes)]
|
||||
|
||||
for key in faceDef:
|
||||
@@ -115,13 +113,13 @@ def femmesh_2_mesh(myFemMesh, myResults=None):
|
||||
faceCode += (node << shifter)
|
||||
# x << n: x shifted left by n bits = Multiplication
|
||||
shifter += shiftBits
|
||||
# print 'codeList: ', codeList
|
||||
# print('codeList: ', codeList)
|
||||
faceCodeDict[faceCode] = nodeList
|
||||
faceCodeList.append(faceCode)
|
||||
elif myFemMesh.FaceCount > 0:
|
||||
for ele in myFemMesh.Faces:
|
||||
element_nodes = myFemMesh.getElementNodes(ele)
|
||||
# print 'element_node: ', element_nodes
|
||||
# print('element_node: ', element_nodes)
|
||||
faceDef = {1: [0, 1, 2]}
|
||||
|
||||
for key in faceDef:
|
||||
@@ -137,7 +135,7 @@ def femmesh_2_mesh(myFemMesh, myResults=None):
|
||||
faceCode += (node << shifter)
|
||||
# x << n: x shifted left by n bits = Multiplication
|
||||
shifter += shiftBits
|
||||
# print 'codeList: ', codeList
|
||||
# print('codeList: ', codeList)
|
||||
faceCodeDict[faceCode] = nodeList
|
||||
faceCodeList.append(faceCode)
|
||||
|
||||
@@ -152,7 +150,7 @@ def femmesh_2_mesh(myFemMesh, myResults=None):
|
||||
if faceCodeList[actFaceIdx] == faceCodeList[actFaceIdx + 1]:
|
||||
actFaceIdx += 2
|
||||
else:
|
||||
# print 'found a single Face: ', faceCodeList[actFaceIdx]
|
||||
# print('found a single Face: ', faceCodeList[actFaceIdx])
|
||||
singleFaces.append(faceCodeList[actFaceIdx])
|
||||
actFaceIdx += 1
|
||||
else:
|
||||
@@ -172,14 +170,14 @@ def femmesh_2_mesh(myFemMesh, myResults=None):
|
||||
myFemMesh.getNodeById(face_nodes[1]) + dispVec1,
|
||||
myFemMesh.getNodeById(face_nodes[2]) + dispVec2]
|
||||
output_mesh.extend(triangle)
|
||||
# print 'my triangle: ', triangle
|
||||
# print('my triangle: ', triangle)
|
||||
if len(face_nodes) == 4:
|
||||
dispVec3 = myResults.DisplacementVectors[myResults.NodeNumbers.index(face_nodes[3])]
|
||||
triangle = [myFemMesh.getNodeById(face_nodes[2]) + dispVec2,
|
||||
myFemMesh.getNodeById(face_nodes[3]) + dispVec3,
|
||||
myFemMesh.getNodeById(face_nodes[0]) + dispVec0]
|
||||
output_mesh.extend(triangle)
|
||||
# print 'my 2. triangle: ', triangle
|
||||
# print('my 2. triangle: ', triangle)
|
||||
|
||||
else:
|
||||
for myFace in singleFaces:
|
||||
@@ -188,13 +186,13 @@ def femmesh_2_mesh(myFemMesh, myResults=None):
|
||||
myFemMesh.getNodeById(face_nodes[1]),
|
||||
myFemMesh.getNodeById(face_nodes[2])]
|
||||
output_mesh.extend(triangle)
|
||||
# print 'my triangle: ', triangle
|
||||
# print('my triangle: ', triangle)
|
||||
if len(face_nodes) == 4:
|
||||
triangle = [myFemMesh.getNodeById(face_nodes[2]),
|
||||
myFemMesh.getNodeById(face_nodes[3]),
|
||||
myFemMesh.getNodeById(face_nodes[0])]
|
||||
output_mesh.extend(triangle)
|
||||
# print 'my 2. triangle: ', triangle
|
||||
# print('my 2. triangle: ', triangle)
|
||||
|
||||
end_time = time.clock()
|
||||
print('Mesh by surface search method: ', end_time - start_time)
|
||||
|
||||
@@ -248,11 +248,11 @@ class GmshTools():
|
||||
|
||||
def get_group_data(self):
|
||||
# TODO: solids, faces, edges and vertexes don't seem to work together in one group,
|
||||
# some print or make them work together
|
||||
# some output message or make them work together
|
||||
|
||||
# mesh group objects
|
||||
if not self.mesh_obj.MeshGroupList:
|
||||
# print (' No mesh group objects.')
|
||||
# print(' No mesh group objects.')
|
||||
pass
|
||||
else:
|
||||
print(' Mesh group objects, we need to get the elements.')
|
||||
@@ -284,7 +284,7 @@ class GmshTools():
|
||||
def get_region_data(self):
|
||||
# mesh regions
|
||||
if not self.mesh_obj.MeshRegionList:
|
||||
# print (' No mesh regions.')
|
||||
# print(' No mesh regions.')
|
||||
pass
|
||||
else:
|
||||
print(' Mesh regions, we need to get the elements.')
|
||||
@@ -301,7 +301,7 @@ class GmshTools():
|
||||
'It is strongly recommended to extract the shape to mesh from the Compound and use this one.'
|
||||
)
|
||||
FreeCAD.Console.PrintError(error_message + "\n")
|
||||
# TODO: no gui popup because FreeCAD will be in a endless print loop
|
||||
# TODO: no gui popup because FreeCAD will be in a endless output loop
|
||||
# as long as the pop up is on --> maybe find a better solution for
|
||||
# either of both --> thus the pop up is in task panel
|
||||
for mr_obj in self.mesh_obj.MeshRegionList:
|
||||
@@ -349,7 +349,7 @@ class GmshTools():
|
||||
# currently only one boundary layer setting object is allowed, but multiple boundary can be selected
|
||||
# Mesh.CharacteristicLengthMin, must be zero, or a value less than first inflation layer height
|
||||
if not self.mesh_obj.MeshBoundaryLayerList:
|
||||
# print (' No mesh boundary layer setting document object.')
|
||||
# print(' No mesh boundary layer setting document object.')
|
||||
pass
|
||||
else:
|
||||
print(' Mesh boundary layers, we need to get the elements.')
|
||||
|
||||
@@ -26,12 +26,12 @@ __url__ = "http://www.freecadweb.org"
|
||||
## @package Fenics
|
||||
# \ingroup FEM
|
||||
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
|
||||
try:
|
||||
import fenics
|
||||
except:
|
||||
print("No Fenics modules found, please install them.")
|
||||
FreeCAD.Console.PrintError("No Fenics modules found, please install them.")
|
||||
else:
|
||||
import numpy as np
|
||||
|
||||
|
||||
Reference in New Issue
Block a user