Skip to content

Commit

Permalink
FEM: oofem writer, write fixed constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Apr 17, 2019
1 parent 87d6db1 commit d4b6d59
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Mod/Fem/femsolver/oofem/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def __init__(self, analysis):

self.constraints_contact = []
self.constraints_displacement = self.get_several_member('Fem::ConstraintDisplacement')
self.constraints_fixed = []
self.constraints_fixed = self.get_several_member('Fem::ConstraintFixed')
self.constraints_force = self.get_several_member('Fem::ConstraintForce')
self.constraints_heatflux = []
self.constraints_initialtemperature = []
Expand Down
47 changes: 46 additions & 1 deletion src/Mod/Fem/femsolver/oofem/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def write_components_size_record(self, f):
self.force_objects = tmp_list
# count bcs
bc_count = 0
all_bcs = self.displacement_objects + self.force_objects
all_bcs = self.displacement_objects + self.fixed_objects + self.force_objects
for femobj in all_bcs: # femobj --> dict, FreeCAD document object is femobj['Object']
bc_count += 1
femobj['bc_number'] = bc_count
Expand Down Expand Up @@ -565,6 +565,42 @@ def write_boundary_condition_record(self, f):
)
f.write(line_all)

# separator line
if self.write_comments is True:
f.write('#\n')

# fixed constraints
# get nodes of fixed constraints
self.get_constraints_fixed_nodes()

# write fixed constraints
if self.write_comments is True:
f.write('# FreeCAD fixed constraints\n')
for femobj in self.fixed_objects: # femobj --> dict, FreeCAD document object is femobj['Object']

# beginn and bc number
line_begin = 'BoundaryCondition {0} loadTimeFunction 1'.format(femobj['bc_number'])

# dofs and values
if self.domain == '2dPlaneStress':
line_dofs = 'dofs 2 1 2'
line_values = 'values 2 0 0'
elif self.domain == '3d':
line_dofs = 'dofs 3 1 2 3'
line_values = 'values 3 0 0 0'

# set
line_set = 'set {0}'.format(femobj['bc_number'] + self.cs_count)

# build and write line
line_all = (
line_begin + ' '
+ line_dofs + ' '
+ line_values + ' '
+ line_set + '\n'
)
f.write(line_all)

def write_nodal_load_record(self, f):
if self.write_comments is True:
f.write('#\n')
Expand Down Expand Up @@ -673,6 +709,15 @@ def write_set_record(self, f):
line_nodes = line_nodes.rstrip() # remove white space at the end
f.write(line_start + ' ' + line_nodes + '\n')

# bc fixed constraints sets
for femobj in self.fixed_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
line_start = 'Set {0} nodes {1}'.format((femobj['bc_number'] + self.cs_count), len(femobj['Nodes']))
line_nodes = '' # init
for n in femobj['Nodes']:
line_nodes = line_nodes + str(n) + ' '
line_nodes = line_nodes.rstrip() # remove white space at the end
f.write(line_start + ' ' + line_nodes + '\n')

# node load sets
for femobj in self.force_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
line_start = 'Set {0} nodes {1}'.format((femobj['bc_number'] + self.cs_count), len(femobj['Nodes']))
Expand Down

0 comments on commit d4b6d59

Please sign in to comment.