FEM: calculix writer, move constraint initialtemperature in separate module, use generic constraint writer and fix unit tests

This commit is contained in:
Bernd Hahnebach
2021-07-11 23:50:14 +02:00
parent b43bdecef6
commit 9715034bc9
5 changed files with 55 additions and 18 deletions

View File

@@ -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

View File

@@ -0,0 +1,50 @@
# ***************************************************************************
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * 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

View File

@@ -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

View File

@@ -8204,6 +8204,7 @@ Evolumes
***********************************************************
** Initial temperature constraint
*INITIAL CONDITIONS,TYPE=TEMPERATURE
** ConstraintInitialTemperature
Nall,273.0
***********************************************************

View File

@@ -124,6 +124,7 @@ Evolumes
***********************************************************
** Initial temperature constraint
*INITIAL CONDITIONS,TYPE=TEMPERATURE
** FemConstraintInitialTemperature
Nall,300.0
***********************************************************