Skip to content

Commit

Permalink
FEM: ccx writer, splitted writer, improve surface sets for tie and co…
Browse files Browse the repository at this point in the history
…ntact
  • Loading branch information
berndhahnebach committed Apr 24, 2020
1 parent 52dcaad commit b1623c4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
60 changes: 36 additions & 24 deletions src/Mod/Fem/femsolver/calculix/writer.py
Expand Up @@ -34,6 +34,7 @@
import six
import sys
import time
from os.path import join

import FreeCAD

Expand All @@ -59,7 +60,6 @@ def __init__(
member,
dir_name
)
from os.path import join
self.mesh_name = self.mesh_object.Name
self.include = join(self.dir_name, self.mesh_name)
self.file_name = self.include + ".inp"
Expand Down Expand Up @@ -211,23 +211,8 @@ def write_calculix_splitted_input_file(self):
inpfileMain.write("*INCLUDE,INPUT=" + self.mesh_name + "_Node_sets.inp \n")
inpfileNodes.close()

if self.contact_objects:
inpfileMain.write("\n***********************************************************\n")
inpfileMain.write("** Surfaces for contact constraint\n")
inpfileMain.write("** written by write_surfaces_constraints_contact\n")
inpfileMain.write("*INCLUDE,INPUT=" + self.mesh_name + "_Surface_Contact.inp \n")
inpfileContact = open(self.include + "_Surface_Contact.inp", "w")
self.write_surfaces_constraints_contact(inpfileContact)
inpfileContact.close()

if self.tie_objects:
inpfileMain.write("\n***********************************************************\n")
inpfileMain.write("** Surfaces for tie constraint\n")
inpfileMain.write("** written by write_surfaces_constraints_tie\n")
inpfileMain.write("*INCLUDE,INPUT=" + self.mesh_name + "_Surface_Tie.inp \n")
inpfileTie = open(self.include + "_Surface_Tie.inp", "w")
self.write_surfaces_constraints_tie(inpfileTie)
inpfileTie.close()
self.write_surfaces_constraints_contact(inpfileMain, True)
self.write_surfaces_constraints_tie(inpfileMain, True)

if self.transform_objects:
inpfileMain.write("\n***********************************************************\n")
Expand Down Expand Up @@ -522,18 +507,32 @@ def write_node_sets_constraints_planerotation(self, f):
for i in range(len(MPC_nodes)):
f.write(str(MPC_nodes[i]) + ",\n")

def write_surfaces_constraints_contact(self, f):
def write_surfaces_constraints_contact(self, f, splitted=None):
if not self.contact_objects:
return
# write for all analysis types

# get faces
self.get_constraints_contact_faces()

# write faces to file
write_name = "contact"
write_name = "constraints_contact_surface_sets"
f.write("\n***********************************************************\n")
f.write("** Surfaces for contact constraint\n")
f.write("** {}\n".format(write_name.replace("_", " ")))
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))

if splitted is True:
file_name_splitt = self.mesh_name + "_" + write_name + ".inp"
f.write("** {}\n".format(write_name.replace("_", " ")))
f.write("*INCLUDE,INPUT={}\n".format(file_name_splitt))
inpfile_splitt = open(join(self.dir_name, file_name_splitt), "w")
self.write_surfacefaces_constraints_contact(inpfile_splitt)
inpfile_splitt.close()
else:
self.write_surfacefaces_constraints_contact(f)

def write_surfacefaces_constraints_contact(self, f):
# write faces to file
for femobj in self.contact_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
contact_obj = femobj["Object"]
Expand All @@ -547,18 +546,31 @@ def write_surfaces_constraints_contact(self, f):
for i in femobj["ContactMasterFaces"]:
f.write("{},S{}\n".format(i[0], i[1]))

def write_surfaces_constraints_tie(self, f):
def write_surfaces_constraints_tie(self, f, splitted=None):
if not self.tie_objects:
return
# write for all analysis types

# get faces
self.get_constraints_tie_faces()

# write faces to file
write_name = "constraints_tie_surface_sets"
f.write("\n***********************************************************\n")
f.write("** Surfaces for tie constraint\n")
f.write("** {}\n".format(write_name.replace("_", " ")))
f.write("** written by {} function\n".format(sys._getframe().f_code.co_name))

if splitted is True:
file_name_splitt = self.mesh_name + "_" + write_name + ".inp"
f.write("** {}\n".format(write_name.replace("_", " ")))
f.write("*INCLUDE,INPUT={}\n".format(file_name_splitt))
inpfile_splitt = open(join(self.dir_name, file_name_splitt), "w")
self.write_surfacefaces_constraints_tie(inpfile_splitt)
inpfile_splitt.close()
else:
self.write_surfacefaces_constraints_tie(f)

def write_surfacefaces_constraints_tie(self, f):
# write faces to file
for femobj in self.tie_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
tie_obj = femobj["Object"]
Expand Down
Expand Up @@ -23069,7 +23069,7 @@ Efaces
197,

***********************************************************
** Surfaces for contact constraint
** constraints contact surface sets
** written by write_surfaces_constraints_contact function
** ConstraintContact
*SURFACE, NAME=DEPConstraintContact
Expand Down
Expand Up @@ -4430,7 +4430,7 @@ Evolumes
1569,

***********************************************************
** Surfaces for contact constraint
** constraints contact surface sets
** written by write_surfaces_constraints_contact function
** ConstraintContact
*SURFACE, NAME=DEPConstraintContact
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/femtest/data/ccx/constraint_tie.inp
Expand Up @@ -18544,7 +18544,7 @@ Evolumes
461,

***********************************************************
** Surfaces for tie constraint
** constraints tie surface sets
** written by write_surfaces_constraints_tie function
** ConstraintTie
*SURFACE, NAME=TIE_DEPConstraintTie
Expand Down

0 comments on commit b1623c4

Please sign in to comment.