FEM: calculix writer, move constraint selfweigt in separate module and use generic constraint writer

This commit is contained in:
Bernd Hahnebach
2021-07-11 23:31:25 +02:00
parent a154d3b93f
commit b43bdecef6
3 changed files with 68 additions and 34 deletions

View File

@@ -197,6 +197,7 @@ SET(FemSolverCalculix_SRCS
femsolver/calculix/con_planerotation.py
femsolver/calculix/con_pressure.py
femsolver/calculix/con_sectionprint.py
femsolver/calculix/con_selfweight.py
femsolver/calculix/con_temperature.py
femsolver/calculix/con_tie.py
femsolver/calculix/con_transform.py

View File

@@ -0,0 +1,65 @@
# ***************************************************************************
# * 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 selfweight"
__author__ = "Bernd Hahnebach"
__url__ = "https://www.freecadweb.org"
def get_analysis_types():
return ["buckling", "static", "thermomech"]
def get_constraint_title():
return "Self weight Constraint"
def get_before_write_constraint():
return ""
def get_after_write_constraint():
return ""
def write_constraint(f, femobj, selwei_obj, ccxwriter):
f.write("*DLOAD\n")
f.write(
# elset, GRAV, magnitude, direction x, dir y ,dir z
"{},GRAV,{},{},{},{}\n"
.format(
ccxwriter.ccx_eall,
ccxwriter.gravity, # actual magnitude of gravity vector
selwei_obj.Gravity_x, # coordinate x of normalized gravity vector
selwei_obj.Gravity_y, # y
selwei_obj.Gravity_z # z
)
)
f.write("\n")
# grav (erdbeschleunigung) is equal for all elements
# should be only one constraint
# different element sets for different density
# are written in the material element sets already

View File

@@ -47,6 +47,7 @@ from . import con_heatflux
from . import con_planerotation
from . import con_pressure
from . import con_sectionprint
from . import con_selfweight
from . import con_temperature
from . import con_tie
from . import con_transform
@@ -226,7 +227,7 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
self.write_constraints_data(inpfile, self.fixed_objects, con_fixed)
self.write_constraints_data(inpfile, self.displacement_objects, con_displacement)
self.write_constraints_data(inpfile, self.sectionprint_objects, con_sectionprint)
self.write_constraints_selfweight(inpfile)
self.write_constraints_data(inpfile, self.selfweight_objects, con_selfweight)
self.write_constraints_data(inpfile, self.centrif_objects, con_centrif)
self.write_constraints_sets(inpfile, self.force_objects, con_force)
self.write_constraints_sets(inpfile, self.pressure_objects, con_pressure)
@@ -380,39 +381,6 @@ class FemInputWriterCcx(writerbase.FemInputWriter):
# OvG: Initial temperature
f.write("{0},{1}\n".format(self.ccx_nall, inittemp_obj.initialTemperature))
# ********************************************************************************************
# constraints selfweight
def write_constraints_selfweight(self, f):
if not self.selfweight_objects:
return
if self.analysis_type not in ["buckling", "static", "thermomech"]:
return
# write constraint to file
f.write("\n***********************************************************\n")
f.write("** Self weight Constraint\n")
for femobj in self.selfweight_objects:
# femobj --> dict, FreeCAD document object is femobj["Object"]
selwei_obj = femobj["Object"]
f.write("** " + selwei_obj.Label + "\n")
f.write("*DLOAD\n")
f.write(
# elset, GRAV, magnitude, direction x, dir y ,dir z
"{},GRAV,{},{},{},{}\n"
.format(
self.ccx_eall,
self.gravity, # actual magnitude of gravity vector
selwei_obj.Gravity_x, # coordinate x of normalized gravity vector
selwei_obj.Gravity_y, # y
selwei_obj.Gravity_z # z
)
)
f.write("\n")
# grav (erdbeschleunigung) is equal for all elements
# should be only one constraint
# different element sets for different density
# are written in the material element sets already
# ********************************************************************************************
# handle elements for constraints fluidsection with Liquid Inlet or Outlet
# belongs to write_constraints_fluidsection, should be next method