diff --git a/src/Mod/Fem/CMakeLists.txt b/src/Mod/Fem/CMakeLists.txt index a1f3530e71..0227fb21be 100755 --- a/src/Mod/Fem/CMakeLists.txt +++ b/src/Mod/Fem/CMakeLists.txt @@ -194,6 +194,7 @@ SET(FemSolverCalculix_SRCS femsolver/calculix/con_fixed.py femsolver/calculix/con_force.py femsolver/calculix/con_heatflux.py + femsolver/calculix/con_initialtemperature.py femsolver/calculix/con_planerotation.py femsolver/calculix/con_pressure.py femsolver/calculix/con_sectionprint.py diff --git a/src/Mod/Fem/femsolver/calculix/con_initialtemperature.py b/src/Mod/Fem/femsolver/calculix/con_initialtemperature.py new file mode 100644 index 0000000000..7b4bd8f94e --- /dev/null +++ b/src/Mod/Fem/femsolver/calculix/con_initialtemperature.py @@ -0,0 +1,50 @@ +# *************************************************************************** +# * Copyright (c) 2021 Bernd Hahnebach * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +# * GNU Library General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with this program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** + +__title__ = "FreeCAD FEM calculix constraint initialtemperature" +__author__ = "Bernd Hahnebach" +__url__ = "https://www.freecadweb.org" + + +def get_analysis_types(): + return ["thermomech"] + + +def get_constraint_title(): + return "Initial temperature constraint" + + +def get_before_write_constraint(): + return "*INITIAL CONDITIONS,TYPE=TEMPERATURE\n" + + +def get_after_write_constraint(): + return "" + + +def write_constraint(f, femobj, inittemp_obj, ccxwriter): + + f.write("{0},{1}\n".format(ccxwriter.ccx_nall, inittemp_obj.initialTemperature)) + + +# Should only be one object in the analysis diff --git a/src/Mod/Fem/femsolver/calculix/writer.py b/src/Mod/Fem/femsolver/calculix/writer.py index e4776b3033..332c12ded1 100644 --- a/src/Mod/Fem/femsolver/calculix/writer.py +++ b/src/Mod/Fem/femsolver/calculix/writer.py @@ -44,6 +44,7 @@ from . import con_displacement from . import con_fixed from . import con_force from . import con_heatflux +from . import con_initialtemperature as con_initialtemp from . import con_planerotation from . import con_pressure from . import con_sectionprint @@ -210,7 +211,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter): # materials and fem element types self.write_materials(inpfile) - self.write_constraints_initialtemperature(inpfile) + self.write_constraints_data(inpfile, self.initialtemperature_objects, con_initialtemp) # self.write_femelement_geometry(inpfile) self.write_femelementsets(inpfile) @@ -364,23 +365,6 @@ class FemInputWriterCcx(writerbase.FemInputWriter): if write_after != "": f.write(write_after) - # ******************************************************************************************** - # constraints initialtemperature - def write_constraints_initialtemperature(self, f): - if not self.initialtemperature_objects: - return - if self.analysis_type not in ["thermomech"]: - return - - # write constraint to file - f.write("\n***********************************************************\n") - f.write("** Initial temperature constraint\n") - f.write("*INITIAL CONDITIONS,TYPE=TEMPERATURE\n") - for itobj in self.initialtemperature_objects: # Should only be one - inittemp_obj = itobj["Object"] - # OvG: Initial temperature - f.write("{0},{1}\n".format(self.ccx_nall, inittemp_obj.initialTemperature)) - # ******************************************************************************************** # handle elements for constraints fluidsection with Liquid Inlet or Outlet # belongs to write_constraints_fluidsection, should be next method diff --git a/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp b/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp index 337ccada1a..0eaddf774e 100644 --- a/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp +++ b/src/Mod/Fem/femtest/data/calculix/thermomech_bimetall.inp @@ -8204,6 +8204,7 @@ Evolumes *********************************************************** ** Initial temperature constraint *INITIAL CONDITIONS,TYPE=TEMPERATURE +** ConstraintInitialTemperature Nall,273.0 *********************************************************** diff --git a/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp b/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp index 41e21bf692..f4bd019240 100644 --- a/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp +++ b/src/Mod/Fem/femtest/data/calculix/thermomech_spine.inp @@ -124,6 +124,7 @@ Evolumes *********************************************************** ** Initial temperature constraint *INITIAL CONDITIONS,TYPE=TEMPERATURE +** FemConstraintInitialTemperature Nall,300.0 ***********************************************************