diff --git a/src/Mod/Fem/FemInputWriterCcx.py b/src/Mod/Fem/FemInputWriterCcx.py index 9f02a4583207..90da6fdd4698 100644 --- a/src/Mod/Fem/FemInputWriterCcx.py +++ b/src/Mod/Fem/FemInputWriterCcx.py @@ -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) @@ -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') @@ -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 @@ -458,19 +512,9 @@ 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 @@ -478,15 +522,16 @@ def write_constraints_selfweight(self, f): 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'] @@ -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') @@ -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') diff --git a/src/Mod/Fem/test_files/ccx/cube_frequency.inp b/src/Mod/Fem/test_files/ccx/cube_frequency.inp index d73be717301f..9e129a1b61c3 100644 --- a/src/Mod/Fem/test_files/ccx/cube_frequency.inp +++ b/src/Mod/Fem/test_files/ccx/cube_frequency.inp @@ -488,7 +488,13 @@ 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 @@ -496,12 +502,6 @@ 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 diff --git a/src/Mod/Fem/test_files/ccx/cube_static.inp b/src/Mod/Fem/test_files/ccx/cube_static.inp index da7c57152cdf..7706518e86d4 100644 --- a/src/Mod/Fem/test_files/ccx/cube_static.inp +++ b/src/Mod/Fem/test_files/ccx/cube_static.inp @@ -485,7 +485,7 @@ Eall *STATIC *********************************************************** -** Constraints +** Fixed Constraints ** written by write_constraints_fixed function *BOUNDARY FemConstraintFixed,1 @@ -494,7 +494,7 @@ FemConstraintFixed,3 *********************************************************** -** Node loads +** Node loads Constraints ** written by write_constraints_force function *CLOAD ** FemConstraintForce diff --git a/src/Mod/Fem/test_files/ccx/spine_thermomech.inp b/src/Mod/Fem/test_files/ccx/spine_thermomech.inp index a72e04979832..edcec75907e1 100644 --- a/src/Mod/Fem/test_files/ccx/spine_thermomech.inp +++ b/src/Mod/Fem/test_files/ccx/spine_thermomech.inp @@ -137,7 +137,7 @@ Nall,300.0 1.0,1.0 *********************************************************** -** Constraints +** Fixed Constraints ** written by write_constraints_fixed function *BOUNDARY FemConstraintFixed,1