FEM: solver elmer unit test, small improvements
This commit is contained in:
@@ -69,6 +69,10 @@ def setup_base(doc=None, solvertype="ccxtools"):
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
if solvertype == "elmer":
|
||||
# set ThermalExpansionCoefficient
|
||||
# FIXME elmer elasticity needs the dictionary key "ThermalExpansionCoefficient"
|
||||
mat["ThermalExpansionCoefficient"] = "0 um/m/K"
|
||||
material_object.Material = mat
|
||||
|
||||
# mesh
|
||||
@@ -85,6 +89,7 @@ def setup_base(doc=None, solvertype="ccxtools"):
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
femmesh_obj.CharacteristicLengthMin = "8.0 mm"
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
@@ -108,7 +113,10 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
elif solvertype == "elmer":
|
||||
analysis.addObject(ObjectsFem.makeSolverElmer(doc, "SolverElmer"))
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
)[0]
|
||||
ObjectsFem.makeEquationElasticity(doc, solver_object)
|
||||
elif solvertype == "z88":
|
||||
analysis.addObject(ObjectsFem.makeSolverZ88(doc, "SolverZ88"))
|
||||
if solvertype == "calculix" or solvertype == "ccxtools":
|
||||
|
||||
@@ -31,7 +31,6 @@ from os.path import join
|
||||
import FreeCAD
|
||||
|
||||
import femsolver.run
|
||||
import ObjectsFem
|
||||
from . import support_utils as testtools
|
||||
from .support_utils import fcc_print
|
||||
|
||||
@@ -98,34 +97,17 @@ class TestSolverElmer(unittest.TestCase):
|
||||
from femexamples.boxanalysis_static import setup
|
||||
setup(self.document, "elmer")
|
||||
|
||||
analysis_obj = self.document.Analysis
|
||||
# for information:
|
||||
# elmer needs gmsh mesho object
|
||||
# FIXME error message on Python solver run
|
||||
# the examples do use a gmsh mesh object thus ok
|
||||
# FIXME elmer elasticity needs the dict key "ThermalExpansionCoefficient" in material
|
||||
|
||||
solver_obj = self.document.SolverElmer
|
||||
material_obj = self.document.MechanicalMaterial
|
||||
mesh_obj = self.document.Mesh
|
||||
box_object = self.document.Box
|
||||
|
||||
base_name = "cube_static"
|
||||
analysis_dir = testtools.get_unit_test_tmp_dir(self.temp_dir, solver_obj.Name)
|
||||
|
||||
# TODO move to elmer solver of femexample code
|
||||
ObjectsFem.makeEquationElasticity(self.document, solver_obj)
|
||||
|
||||
# set ThermalExpansionCoefficient
|
||||
# FIXME elmer elasticity needs the dictionary key "ThermalExpansionCoefficient"
|
||||
# even on simple elasticity analysis, otherwise it fails
|
||||
mat = material_obj.Material
|
||||
mat["ThermalExpansionCoefficient"] = "0 um/m/K"
|
||||
material_obj.Material = mat
|
||||
|
||||
# elmer needs a GMHS mesh object
|
||||
# FIXME error message on Python solver run
|
||||
mesh_gmsh = ObjectsFem.makeMeshGmsh(self.document)
|
||||
mesh_gmsh.CharacteristicLengthMin = "9 mm"
|
||||
mesh_gmsh.FemMesh = mesh_obj.FemMesh
|
||||
mesh_gmsh.Part = box_object
|
||||
analysis_obj.addObject(mesh_gmsh)
|
||||
self.document.removeObject(mesh_obj.Name) # remove original mesh object
|
||||
|
||||
# save the file
|
||||
save_fc_file = join(analysis_dir, solver_obj.Name + "_" + base_name + ".FCStd")
|
||||
fcc_print("Save FreeCAD file to {}...".format(save_fc_file))
|
||||
|
||||
@@ -13,7 +13,7 @@ Physical Volume("Solid1") = {1};
|
||||
// no boundary layer settings for this mesh
|
||||
// min, max Characteristic Length
|
||||
Mesh.CharacteristicLengthMax = 1e+22;
|
||||
Mesh.CharacteristicLengthMin = 9.0;
|
||||
Mesh.CharacteristicLengthMin = 8.0;
|
||||
|
||||
// optimize the mesh
|
||||
Mesh.Optimize = 1;
|
||||
|
||||
Reference in New Issue
Block a user