Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
FEM: ccx input writer: reorder defs and def calls and
- fix presure and force are written for thermomech too
- change some comments
- fix FEM unit tests
  • Loading branch information
berndhahnebach committed Aug 10, 2016
1 parent 50ca24f commit 46a2996
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 72 deletions.
142 changes: 80 additions & 62 deletions src/Mod/Fem/FemInputWriterCcx.py
Expand Up @@ -93,28 +93,45 @@ def write_calculix_input_file(self):
if self.contact_objects:
self.write_constraints_contact(inpfile)

# steps and constraints dependent on steps
if self.analysis_type == "thermomech":
# step begin
if self.analysis_type == "frequency":
self.write_step_begin_static_frequency(inpfile)
self.write_analysis_frequency(inpfile)
elif self.analysis_type == "static":
self.write_step_begin_static_frequency(inpfile)
elif self.analysis_type == "thermomech":
self.write_step_begin_thermomech(inpfile)
self.write_analysis_thermomech(inpfile)
else:
self.write_step_begin_static_frequency(inpfile)

# constraints depend on step used in all analysis types
if self.fixed_objects:
self.write_constraints_fixed(inpfile)
if self.displacement_objects:
self.write_constraints_displacement(inpfile)
if self.analysis_type == "thermomech":
self.write_constraints_temperature(inpfile)
self.write_constraints_heatflux(inpfile)
if self.analysis_type is None or self.analysis_type == "static":

# constraints depend on step and depending on analysis type
if self.analysis_type == "frequency":
pass
elif self.analysis_type == "static":
if self.selfweight_objects:
self.write_constraints_selfweight(inpfile)
if self.force_objects:
self.write_constraints_force(inpfile)
if self.pressure_objects:
self.write_constraints_pressure(inpfile)
elif self.analysis_type == "frequency":
self.write_analysis_frequency(inpfile)
elif self.analysis_type == "thermomech":
if self.selfweight_objects:
self.write_constraints_selfweight(inpfile)
if self.force_objects:
self.write_constraints_force(inpfile)
if self.pressure_objects:
self.write_constraints_pressure(inpfile)
if self.temperature_objects:
self.write_constraints_temperature(inpfile)
if self.heatflux_objects:
self.write_constraints_heatflux(inpfile)

# output and step end
self.write_outputs_types(inpfile)
self.write_step_end(inpfile)

Expand Down Expand Up @@ -301,6 +318,15 @@ def write_materials(self, f):
f.write('*SPECIFIC HEAT \n')
f.write('{0:.3e}, \n'.format(SH_in_JkgK))

def write_constraints_initialtemperature(self, f):
f.write('\n***********************************************************\n')
f.write('** Initial temperature constraint\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
f.write('*INITIAL CONDITIONS,TYPE=TEMPERATURE\n')
for itobj in self.initialtemperature_objects: # Should only be one
inittemp_obj = itobj['Object']
f.write('Nall,{}\n'.format(inittemp_obj.initialTemperature)) # OvG: Initial temperature

def write_femelementsets(self, f):
f.write('\n***********************************************************\n')
f.write('** Sections\n')
Expand Down Expand Up @@ -375,9 +401,37 @@ def write_step_begin_thermomech(self, f):
f.write(self.solver_obj.IterationsControlParameterIter + '\n')
f.write(self.solver_obj.IterationsControlParameterCutb + '\n')

def write_analysis_frequency(self, f):
f.write('\n***********************************************************\n')
f.write('** Frequency analysis\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
f.write('*FREQUENCY\n')
f.write('{},{},{}\n'.format(self.solver_obj.EigenmodesCount, self.solver_obj.EigenmodeLowLimit, self.solver_obj.EigenmodeHighLimit))

def write_analysis_thermomech(self, f):
f.write('\n***********************************************************\n')
f.write('** Coupled temperature displacement analysis\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
thermomech_analysis = '*COUPLED TEMPERATURE-DISPLACEMENT'
if self.solver_obj.MatrixSolverType == "default":
pass
elif self.solver_obj.MatrixSolverType == "spooles":
thermomech_analysis += ', SOLVER=SPOOLES'
elif self.solver_obj.MatrixSolverType == "iterativescaling":
thermomech_analysis += ', SOLVER=ITERATIVE SCALING'
elif self.solver_obj.MatrixSolverType == "iterativecholesky":
thermomech_analysis += ', SOLVER=ITERATIVE CHOLESKY'
if self.solver_obj.SteadyState:
thermomech_analysis += ', STEADY STATE'
self.solver_obj.TimeInitialStep = 1.0 # Set time to 1 and ignore user inputs for steady state
self.solver_obj.TimeEnd = 1.0
thermomech_time = '{},{}'.format(self.solver_obj.TimeInitialStep, self.solver_obj.TimeEnd) # OvG: 1.0 increment, total time 1 for steady state will cut back automatically
f.write(thermomech_analysis + '\n')
f.write(thermomech_time + '\n')

def write_constraints_fixed(self, f):
f.write('\n***********************************************************\n')
f.write('** Constraints\n')
f.write('** Fixed Constraints\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.fixed_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
fix_obj_name = femobj['Object'].Name
Expand Down Expand Up @@ -458,35 +512,26 @@ def write_constraints_planerotation(self, f):
f.write('*MPC\n')
f.write('PLANE,' + fric_obj_name + '\n')

def write_constraints_temperature(self, f):
f.write('\n***********************************************************\n')
f.write('** Fixed temperature constraint applied\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for ftobj in self.temperature_objects:
fixedtemp_obj = ftobj['Object']
f.write('*BOUNDARY\n')
f.write('{},11,11,{}\n'.format(fixedtemp_obj.Name, fixedtemp_obj.Temperature))
f.write('\n')

def write_constraints_selfweight(self, f):
f.write('\n***********************************************************\n')
f.write('** Self weight\n')
f.write('** Self weight Constraint\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for femobj in self.selfweight_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
selwei_obj_name = femobj['Object'].Name
f.write('** ' + selwei_obj_name + '\n')
f.write('*DLOAD\n')
f.write('Eall,GRAV,9810,0,0,-1\n')
f.write('\n')
# die grav (erdbeschleunigung) ist fuer alle gleich
# die verschidene density wurde in den material sets geschrieben !
# grav (erdbeschleunigung) is equal for all elements
# should be only one constraint
# different elment sets for different density are written in the material element sets allready

def write_constraints_force(self, f):
# check shape type of reference shape and get node loads
self.get_constraints_force_nodeloads()
# write node loads to file
f.write('\n***********************************************************\n')
f.write('** Node loads\n')
f.write('** Node loads Constraints\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
f.write('*CLOAD\n')
for femobj in self.force_objects: # femobj --> dict, FreeCAD document object is femobj['Object']
Expand Down Expand Up @@ -526,6 +571,16 @@ def write_constraints_pressure(self, f):
for i in v:
f.write("{},P{},{}\n".format(i[0], i[1], rev * prs_obj.Pressure))

def write_constraints_temperature(self, f):
f.write('\n***********************************************************\n')
f.write('** Fixed temperature constraint applied\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
for ftobj in self.temperature_objects:
fixedtemp_obj = ftobj['Object']
f.write('*BOUNDARY\n')
f.write('{},11,11,{}\n'.format(fixedtemp_obj.Name, fixedtemp_obj.Temperature))
f.write('\n')

def write_constraints_heatflux(self, f):
f.write('\n***********************************************************\n')
f.write('** Heatflux constraints\n')
Expand All @@ -542,43 +597,6 @@ def write_constraints_heatflux(self, f):
for i in v:
f.write("{},F{},{},{}\n".format(i[0], i[1], heatflux_obj.AmbientTemp, heatflux_obj.FilmCoef * 0.001)) # SvdW add factor to force heatflux to units system of t/mm/s/K # OvG: Only write out the VolumeIDs linked to a particular face

def write_analysis_frequency(self, f):
f.write('\n***********************************************************\n')
f.write('** Frequency analysis\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
f.write('*FREQUENCY\n')
f.write('{},{},{}\n'.format(self.solver_obj.EigenmodesCount, self.solver_obj.EigenmodeLowLimit, self.solver_obj.EigenmodeHighLimit))

def write_analysis_thermomech(self, f):
f.write('\n***********************************************************\n')
f.write('** Coupled temperature displacement analysis\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
thermomech_analysis = '*COUPLED TEMPERATURE-DISPLACEMENT'
if self.solver_obj.MatrixSolverType == "default":
pass
elif self.solver_obj.MatrixSolverType == "spooles":
thermomech_analysis += ', SOLVER=SPOOLES'
elif self.solver_obj.MatrixSolverType == "iterativescaling":
thermomech_analysis += ', SOLVER=ITERATIVE SCALING'
elif self.solver_obj.MatrixSolverType == "iterativecholesky":
thermomech_analysis += ', SOLVER=ITERATIVE CHOLESKY'
if self.solver_obj.SteadyState:
thermomech_analysis += ', STEADY STATE'
self.solver_obj.TimeInitialStep = 1.0 # Set time to 1 and ignore user inputs for steady state
self.solver_obj.TimeEnd = 1.0
thermomech_time = '{},{}'.format(self.solver_obj.TimeInitialStep, self.solver_obj.TimeEnd) # OvG: 1.0 increment, total time 1 for steady state will cut back automatically
f.write(thermomech_analysis + '\n')
f.write(thermomech_time + '\n')

def write_constraints_initialtemperature(self, f):
f.write('\n***********************************************************\n')
f.write('** Initial temperature constraint\n')
f.write('** written by {} function\n'.format(sys._getframe().f_code.co_name))
f.write('*INITIAL CONDITIONS,TYPE=TEMPERATURE\n')
for itobj in self.initialtemperature_objects: # Should only be one
inittemp_obj = itobj['Object']
f.write('Nall,{}\n'.format(inittemp_obj.initialTemperature)) # OvG: Initial temperature

def write_outputs_types(self, f):
f.write('\n***********************************************************\n')
f.write('** Outputs --> frd file\n')
Expand Down
14 changes: 7 additions & 7 deletions src/Mod/Fem/test_files/ccx/cube_frequency.inp
Expand Up @@ -488,20 +488,20 @@ Eall
*STATIC

***********************************************************
** Constraints
** Frequency analysis
** written by write_analysis_frequency function
*FREQUENCY
10,0.0,1000000.0

***********************************************************
** Fixed Constraints
** written by write_constraints_fixed function
*BOUNDARY
FemConstraintFixed,1
FemConstraintFixed,2
FemConstraintFixed,3


***********************************************************
** Frequency analysis
** written by write_analysis_frequency function
*FREQUENCY
10,0.0,1000000.0

***********************************************************
** Outputs --> frd file
** written by write_outputs_types function
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Fem/test_files/ccx/cube_static.inp
Expand Up @@ -485,7 +485,7 @@ Eall
*STATIC

***********************************************************
** Constraints
** Fixed Constraints
** written by write_constraints_fixed function
*BOUNDARY
FemConstraintFixed,1
Expand All @@ -494,7 +494,7 @@ FemConstraintFixed,3


***********************************************************
** Node loads
** Node loads Constraints
** written by write_constraints_force function
*CLOAD
** FemConstraintForce
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/test_files/ccx/spine_thermomech.inp
Expand Up @@ -137,7 +137,7 @@ Nall,300.0
1.0,1.0

***********************************************************
** Constraints
** Fixed Constraints
** written by write_constraints_fixed function
*BOUNDARY
FemConstraintFixed,1
Expand Down

0 comments on commit 46a2996

Please sign in to comment.