FEM: examples, some code improvements

This commit is contained in:
Bernd Hahnebach
2020-03-13 08:24:27 +01:00
parent 2b12bbe274
commit 8705a6f3cf
11 changed files with 193 additions and 195 deletions

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples import boxanalysis as box
@@ -34,8 +33,9 @@ box.setup_frequency()
import FreeCAD
import ObjectsFem
import Fem
import ObjectsFem
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -52,14 +52,14 @@ def setup_base(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# part
box_obj = doc.addObject("Part::Box", "Box")
box_obj.Height = box_obj.Width = box_obj.Length = 10
# geometry object
geom_obj = doc.addObject("Part::Box", "Box")
geom_obj.Height = geom_obj.Width = geom_obj.Length = 10
doc.recompute()
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -98,7 +98,7 @@ def setup_static(doc=None, solvertype="ccxtools"):
# setup box static, add a fixed, force and a pressure constraint
doc = setup_base(doc, solvertype)
box_obj = doc.Box
geom_obj = doc.Box
analysis = doc.Analysis
# solver
@@ -127,22 +127,22 @@ def setup_static(doc=None, solvertype="ccxtools"):
fixed_constraint = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, name="FemConstraintFixed")
)[0]
fixed_constraint.References = [(box_obj, "Face1")]
fixed_constraint.References = [(geom_obj, "Face1")]
# force_constraint
force_constraint = analysis.addObject(
ObjectsFem.makeConstraintForce(doc, name="FemConstraintForce")
)[0]
force_constraint.References = [(box_obj, "Face6")]
force_constraint.References = [(geom_obj, "Face6")]
force_constraint.Force = 40000.0
force_constraint.Direction = (box_obj, ["Edge5"])
force_constraint.Direction = (geom_obj, ["Edge5"])
force_constraint.Reversed = True
# pressure_constraint
pressure_constraint = analysis.addObject(
ObjectsFem.makeConstraintPressure(doc, name="FemConstraintPressure")
)[0]
pressure_constraint.References = [(box_obj, "Face2")]
pressure_constraint.References = [(geom_obj, "Face2")]
pressure_constraint.Pressure = 1000.0
pressure_constraint.Reversed = False

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples import ccx_cantilever_std as canti
@@ -36,8 +35,9 @@ canti.setup_cantileverhexa20faceload()
import FreeCAD
import ObjectsFem
import Fem
import ObjectsFem
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -54,15 +54,16 @@ def setup_cantileverbase(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# part
box_obj = doc.addObject("Part::Box", "Box")
box_obj.Height = box_obj.Width = 1000
box_obj.Length = 8000
# geometry object
# name is important because the other method in this module use obj name
geom_obj = doc.addObject("Part::Box", "Box")
geom_obj.Height = geom_obj.Width = 1000
geom_obj.Length = 8000
doc.recompute()
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -106,7 +107,7 @@ def setup_cantileverbase(doc=None, solvertype="ccxtools"):
fixed_constraint = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
)[0]
fixed_constraint.References = [(doc.Box, "Face1")]
fixed_constraint.References = [(geom_obj, "Face1")]
# mesh
from .meshes.mesh_canticcx_tetra10 import create_nodes, create_elements

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# contact example shell to shell elements
# https://forum.freecadweb.org/viewtopic.php?f=18&t=42228
# based on https://forum.freecadweb.org/viewtopic.php?f=18&t=42228#p359488
@@ -34,10 +33,11 @@ setup()
import FreeCAD
import ObjectsFem
import Fem
import ObjectsFem
import Part
import BOPTools.SplitFeatures
from BOPTools import SplitFeatures
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -54,10 +54,11 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# parts
# geometry objects
# TODO turn circle of upper tube to have the line on the other side
# make a boolean fragment of them to be sure there is a mesh point on remesh
# but as long as we do not remesh it works without the boolean fragment too
# tubes
tube_radius = 25
tube_length = 500
@@ -87,13 +88,15 @@ def setup(doc=None, solvertype="ccxtools"):
force_point.ViewObject.PointSize = 10.0
force_point.ViewObject.PointColor = (1.0, 0.0, 0.0)
BooleanFrag = BOPTools.SplitFeatures.makeBooleanFragments(name='BooleanFragments')
BooleanFrag.Objects = [upper_tube, force_point]
# boolean fragment of upper tubo and force point
boolfrag = SplitFeatures.makeBooleanFragments(name='BooleanFragments')
boolfrag.Objects = [upper_tube, force_point]
if FreeCAD.GuiUp:
upper_tube.ViewObject.hide()
compound = doc.addObject("Part::Compound", "Compound")
compound.Links = [BooleanFrag, lower_tube]
# compound out of bool frag and lower tube
goem_obj = doc.addObject("Part::Compound", "AllGeomCompound")
goem_obj.Links = [boolfrag, lower_tube]
# line for load direction
sh_load_line = Part.makeLine(v_force_pt, FreeCAD.Vector(0, 150, 475))
@@ -107,7 +110,7 @@ def setup(doc=None, solvertype="ccxtools"):
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
goem_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# constraint contact for solid to solid mesh
# https://forum.freecadweb.org/viewtopic.php?f=18&t=20276
# to run the example use:
@@ -33,11 +32,12 @@ setup()
import FreeCAD
import Part
import ObjectsFem
import Fem
from FreeCAD import Vector, Rotation
from FreeCAD import Rotation
from FreeCAD import Vector
import Fem
import ObjectsFem
import Part
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -54,7 +54,7 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# parts
# geometry objects
# bottom box
bottom_box_obj = doc.addObject("Part::Box", "BottomBox")
bottom_box_obj.Length = 100
@@ -82,8 +82,8 @@ def setup(doc=None, solvertype="ccxtools"):
doc.recompute()
# all geom fusion
all_geom_fusion_obj = doc.addObject("Part::MultiFuse", "AllGeomFusion")
all_geom_fusion_obj.Shapes = [bottom_box_obj, top_halfcyl_obj]
geom_obj = doc.addObject("Part::MultiFuse", "AllGeomFusion")
geom_obj.Shapes = [bottom_box_obj, top_halfcyl_obj]
if FreeCAD.GuiUp:
bottom_box_obj.ViewObject.hide()
top_halfcyl_obj.ViewObject.hide()
@@ -91,7 +91,7 @@ def setup(doc=None, solvertype="ccxtools"):
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -142,17 +142,17 @@ def setup(doc=None, solvertype="ccxtools"):
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
)[0]
con_fixed.References = [
(all_geom_fusion_obj, "Face5"),
(all_geom_fusion_obj, "Face6"),
(all_geom_fusion_obj, "Face8"),
(all_geom_fusion_obj, "Face9"),
(geom_obj, "Face5"),
(geom_obj, "Face6"),
(geom_obj, "Face8"),
(geom_obj, "Face9"),
]
# constraint pressure
con_pressure = analysis.addObject(
ObjectsFem.makeConstraintPressure(doc, name="ConstraintPressure")
)[0]
con_pressure.References = [(all_geom_fusion_obj, "Face10")]
con_pressure.References = [(geom_obj, "Face10")]
con_pressure.Pressure = 100.0 # Pa ? = 100 Mpa ?
con_pressure.Reversed = False
@@ -161,8 +161,8 @@ def setup(doc=None, solvertype="ccxtools"):
ObjectsFem.makeConstraintContact(doc, name="ConstraintContact")
)[0]
con_contact.References = [
(all_geom_fusion_obj, "Face7"), # first seams slave face, TODO proof in writer code!
(all_geom_fusion_obj, "Face3"), # second seams master face, TODO proof in writer code!
(geom_obj, "Face7"), # first seams slave face, TODO proof in writer code!
(geom_obj, "Face3"), # second seams master face, TODO proof in writer code!
]
con_contact.Friction = 0.0
con_contact.Slope = 1000000.0 # contact stiffness 1000000.0 kg/(mm*s^2)

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# constraint tie, bond two surfaces together (solid mesh only)
# https://forum.freecadweb.org/viewtopic.php?f=18&t=42783
# to run the example use:
@@ -33,12 +32,12 @@ setup()
import FreeCAD
import ObjectsFem
import Fem
import Part
import BOPTools.SplitFeatures
from FreeCAD import Vector
import Fem
import ObjectsFem
import Part
from BOPTools import SplitFeatures
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -55,7 +54,7 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# parts
# geometry objects
# cones cut
cone_outer_sh = Part.makeCone(1100, 1235, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359)
cone_inner_sh = Part.makeCone(1050, 1185, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359)
@@ -71,8 +70,8 @@ def setup(doc=None, solvertype="ccxtools"):
line_force_obj = doc.addObject("Part::Feature", "Line_Force")
line_force_obj.Shape = line_force_sh
geom_all_obj = BOPTools.SplitFeatures.makeBooleanFragments(name='BooleanFragments')
geom_all_obj.Objects = [cone_cut_obj, line_fix_obj, line_force_obj]
geom_obj = SplitFeatures.makeBooleanFragments(name='BooleanFragments')
geom_obj.Objects = [cone_cut_obj, line_fix_obj, line_force_obj]
if FreeCAD.GuiUp:
cone_cut_obj.ViewObject.hide()
line_fix_obj.ViewObject.hide()
@@ -82,7 +81,7 @@ def setup(doc=None, solvertype="ccxtools"):
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -121,15 +120,15 @@ def setup(doc=None, solvertype="ccxtools"):
con_fixed = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
)[0]
con_fixed.References = [(geom_all_obj, "Edge1")]
con_fixed.References = [(geom_obj, "Edge1")]
# constraint force
con_force = doc.Analysis.addObject(
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
)[0]
con_force.References = [(geom_all_obj, "Edge2")]
con_force.References = [(geom_obj, "Edge2")]
con_force.Force = 10000.0 # 10000 N = 10 kN
con_force.Direction = (geom_all_obj, ["Edge2"])
con_force.Direction = (geom_obj, ["Edge2"])
con_force.Reversed = False
# constraint tie
@@ -137,8 +136,8 @@ def setup(doc=None, solvertype="ccxtools"):
ObjectsFem.makeConstraintTie(doc, name="ConstraintTie")
)[0]
con_tie.References = [
(geom_all_obj, "Face5"),
(geom_all_obj, "Face7"),
(geom_obj, "Face5"),
(geom_obj, "Face7"),
]
con_tie.Tolerance = 25.0

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples.material_multiple_twoboxes import setup
@@ -29,10 +28,12 @@ setup()
"""
import FreeCAD
import ObjectsFem
import Fem
import ObjectsFem
from BOPTools import SplitFeatures
from CompoundTools import CompoundFilter
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -49,38 +50,37 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# part
# create a CompSolid of two Boxes extract the CompSolid
# we are able to remesh if needed
# geometry objects
# two boxes
boxlow = doc.addObject("Part::Box", "BoxLower")
boxupp = doc.addObject("Part::Box", "BoxUpper")
boxupp.Placement.Base = (0, 0, 10)
# for BooleanFragments Occt >=6.9 is needed
"""
import BOPTools.SplitFeatures
bf = BOPTools.SplitFeatures.makeBooleanFragments(name="BooleanFragments")
# boolean fragment of the two boxes
bf = SplitFeatures.makeBooleanFragments(name="BooleanFragments")
bf.Objects = [boxlow, boxupp]
bf.Mode = "CompSolid"
self.active_doc.recompute()
doc.recompute()
bf.Proxy.execute(bf)
bf.purgeTouched()
for obj in bf.ViewObject.Proxy.claimChildren():
obj.ViewObject.hide()
self.active_doc.recompute()
import CompoundTools.CompoundFilter
cf = CompoundTools.CompoundFilter.makeCompoundFilter(name="MultiMatCompSolid")
cf.Base = bf
cf.FilterType = "window-volume"
cf.Proxy.execute(cf)
cf.purgeTouched()
cf.Base.ViewObject.hide()
"""
if FreeCAD.GuiUp:
for child in bf.ViewObject.Proxy.claimChildren():
child.ViewObject.hide()
doc.recompute()
# extract CompSolid by compound filter tool
geom_obj = CompoundFilter.makeCompoundFilter(name="MultiMatCompSolid")
geom_obj.Base = bf
geom_obj.FilterType = "window-volume"
geom_obj.Proxy.execute(geom_obj)
geom_obj.purgeTouched()
if FreeCAD.GuiUp:
geom_obj.Base.ViewObject.hide()
doc.recompute()
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -132,17 +132,13 @@ def setup(doc=None, solvertype="ccxtools"):
fixed_constraint = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
)[0]
# fixed_constraint.References = [(cf, "Face3")]
fixed_constraint.References = [(boxlow, "Face5")]
fixed_constraint.References = [(geom_obj, "Face5")]
# pressure_constraint
pressure_constraint = analysis.addObject(
ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
)[0]
# pressure_constraint.References = [(cf, "Face3")]
pressure_constraint.References = [(boxlow, "Face5")]
# pressure_constraint.References = [(cf, "Face9")]
pressure_constraint.References = [(boxupp, "Face6")]
pressure_constraint.References = [(geom_obj, "Face11")]
pressure_constraint.Pressure = 1000.0
pressure_constraint.Reversed = False

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples.material_nl_platewithhole import setup
@@ -31,9 +30,13 @@ setup()
import FreeCAD
import ObjectsFem
import Fem
from FreeCAD import Vector as vec
import Fem
import ObjectsFem
import Part
from Part import makeCircle as ci
from Part import makeLine as ln
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -64,11 +67,7 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# part
import Part
from FreeCAD import Vector as vec
from Part import makeLine as ln
from Part import makeCircle as ci
# geometry objects
v1 = vec(-200, -100, 0)
v2 = vec(200, -100, 0)
@@ -81,13 +80,13 @@ def setup(doc=None, solvertype="ccxtools"):
v5 = vec(0, 0, 0)
c1 = ci(50, v5)
face = Part.makeFace([Part.Wire([l1, l2, l3, l4]), c1], "Part::FaceMakerBullseye")
partfem = doc.addObject("Part::Feature", "Hole_Plate")
partfem.Shape = face.extrude(vec(0, 0, 10))
geom_obj = doc.addObject("Part::Feature", "Hole_Plate")
geom_obj.Shape = face.extrude(vec(0, 0, 10))
doc.recompute()
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -136,13 +135,13 @@ def setup(doc=None, solvertype="ccxtools"):
fixed_constraint = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
)[0]
fixed_constraint.References = [(partfem, "Face4")]
fixed_constraint.References = [(geom_obj, "Face4")]
# force constraint
pressure_constraint = doc.Analysis.addObject(
ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
)[0]
pressure_constraint.References = [(partfem, "Face2")]
pressure_constraint.References = [(geom_obj, "Face2")]
pressure_constraint.Pressure = 130.0
pressure_constraint.Reversed = True

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples.rc_wall_2d import setup
@@ -31,8 +30,12 @@ setup()
import FreeCAD
import ObjectsFem
from FreeCAD import Vector as vec
import Fem
import ObjectsFem
import Part
from Part import makeLine as ln
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -49,10 +52,7 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# part
from FreeCAD import Vector as vec
import Part
from Part import makeLine as ln
# geom objects
v1 = vec(0, -2000, 0)
v2 = vec(500, -2000, 0)
@@ -70,13 +70,13 @@ def setup(doc=None, solvertype="ccxtools"):
l6 = ln(v6, v7)
l7 = ln(v7, v8)
l8 = ln(v8, v1)
rcwall = doc.addObject("Part::Feature", "FIB_Wall")
rcwall.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8]))
geom_obj = doc.addObject("Part::Feature", "FIB_Wall")
geom_obj.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8]))
doc.recompute()
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -130,22 +130,22 @@ def setup(doc=None, solvertype="ccxtools"):
fixed_constraint = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
)[0]
fixed_constraint.References = [(rcwall, "Edge1"), (rcwall, "Edge5")]
fixed_constraint.References = [(geom_obj, "Edge1"), (geom_obj, "Edge5")]
# force constraint
force_constraint = doc.Analysis.addObject(
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
)[0]
force_constraint.References = [(rcwall, "Edge7")]
force_constraint.References = [(geom_obj, "Edge7")]
force_constraint.Force = 1000000.0
force_constraint.Direction = (rcwall, ["Edge8"])
force_constraint.Direction = (geom_obj, ["Edge8"])
force_constraint.Reversed = False
# displacement_constraint
displacement_constraint = doc.Analysis.addObject(
ObjectsFem.makeConstraintDisplacement(doc, name="ConstraintDisplacmentPrescribed")
)[0]
displacement_constraint.References = [(rcwall, "Face1")]
displacement_constraint.References = [(geom_obj, "Face1")]
displacement_constraint.zFix = True
# mesh

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# thermomechanical bimetall
# https://forum.freecadweb.org/viewtopic.php?f=18&t=43040&start=10#p366664
# analytical solution 7.05 mm deflection in the invar material direction
@@ -34,13 +33,13 @@ setup()
"""
import FreeCAD
import ObjectsFem
import Fem
from FreeCAD import Vector, Rotation
import BOPTools.SplitFeatures
from FreeCAD import Rotation
from FreeCAD import Vector
import Fem
import ObjectsFem
from BOPTools import SplitFeatures
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -57,7 +56,7 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# parts
# geom objects
# bottom box
bottom_box_obj = doc.addObject("Part::Box", "BottomBox")
bottom_box_obj.Length = 100
@@ -77,8 +76,8 @@ def setup(doc=None, solvertype="ccxtools"):
doc.recompute()
# all geom boolean fragment
all_geom_boolfrag_obj = BOPTools.SplitFeatures.makeBooleanFragments(name='BooleanFragments')
all_geom_boolfrag_obj.Objects = [bottom_box_obj, top_box_obj]
geom_obj = SplitFeatures.makeBooleanFragments(name='BooleanFragments')
geom_obj.Objects = [bottom_box_obj, top_box_obj]
if FreeCAD.GuiUp:
bottom_box_obj.ViewObject.hide()
top_box_obj.ViewObject.hide()
@@ -86,7 +85,7 @@ def setup(doc=None, solvertype="ccxtools"):
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -124,7 +123,7 @@ def setup(doc=None, solvertype="ccxtools"):
mat["ThermalConductivity"] = "200 W/m/K"
mat["ThermalExpansionCoefficient"] = "0.00002 m/m/K"
material_obj_bottom.Material = mat
material_obj_bottom.References = [(all_geom_boolfrag_obj, "Solid1")]
material_obj_bottom.References = [(geom_obj, "Solid1")]
analysis.addObject(material_obj_bottom)
material_obj_top = analysis.addObject(
@@ -138,7 +137,7 @@ def setup(doc=None, solvertype="ccxtools"):
mat["ThermalConductivity"] = "13 W/m/K"
mat["ThermalExpansionCoefficient"] = "0.0000012 m/m/K"
material_obj_top.Material = mat
material_obj_top.References = [(all_geom_boolfrag_obj, "Solid2")]
material_obj_top.References = [(geom_obj, "Solid2")]
analysis.addObject(material_obj_top)
# constraint fixed
@@ -146,8 +145,8 @@ def setup(doc=None, solvertype="ccxtools"):
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
)[0]
con_fixed.References = [
(all_geom_boolfrag_obj, "Face1"),
(all_geom_boolfrag_obj, "Face7"),
(geom_obj, "Face1"),
(geom_obj, "Face7"),
]
# constraint initial temperature
@@ -161,16 +160,16 @@ def setup(doc=None, solvertype="ccxtools"):
ObjectsFem.makeConstraintTemperature(doc, "ConstraintTemperature")
)[0]
constraint_temperature.References = [
(all_geom_boolfrag_obj, "Face1"),
(all_geom_boolfrag_obj, "Face2"),
(all_geom_boolfrag_obj, "Face3"),
(all_geom_boolfrag_obj, "Face4"),
(all_geom_boolfrag_obj, "Face5"),
(all_geom_boolfrag_obj, "Face7"),
(all_geom_boolfrag_obj, "Face8"),
(all_geom_boolfrag_obj, "Face9"),
(all_geom_boolfrag_obj, "Face10"),
(all_geom_boolfrag_obj, "Face11"),
(geom_obj, "Face1"),
(geom_obj, "Face2"),
(geom_obj, "Face3"),
(geom_obj, "Face4"),
(geom_obj, "Face5"),
(geom_obj, "Face7"),
(geom_obj, "Face8"),
(geom_obj, "Face9"),
(geom_obj, "Face10"),
(geom_obj, "Face11"),
]
constraint_temperature.Temperature = 373.0
constraint_temperature.CFlux = 0.0

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples.thermomech_flow1d import setup
@@ -31,8 +30,11 @@ setup()
import FreeCAD
import ObjectsFem
from FreeCAD import Vector as vec
import Fem
import ObjectsFem
from Draft import makeWire
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -49,40 +51,40 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
p1 = FreeCAD.Vector(0, 0, 50)
p2 = FreeCAD.Vector(0, 0, -50)
p3 = FreeCAD.Vector(0, 0, -4300)
p4 = FreeCAD.Vector(4950, 0, -4300)
p5 = FreeCAD.Vector(5000, 0, -4300)
p6 = FreeCAD.Vector(8535.53, 0, -7835.53)
p7 = FreeCAD.Vector(8569.88, 0, -7870.88)
p8 = FreeCAD.Vector(12105.41, 0, -11406.41)
p9 = FreeCAD.Vector(12140.76, 0, -11441.76)
p10 = FreeCAD.Vector(13908.53, 0, -13209.53)
p11 = FreeCAD.Vector(13943.88, 0, -13244.88)
p12 = FreeCAD.Vector(15046.97, 0, -14347.97)
p13 = FreeCAD.Vector(15046.97, 0, -7947.97)
p14 = FreeCAD.Vector(15046.97, 0, -7847.97)
p15 = FreeCAD.Vector(0, 0, 0)
p16 = FreeCAD.Vector(0, 0, -2175)
p17 = FreeCAD.Vector(2475, 0, -4300)
p18 = FreeCAD.Vector(4975, 0, -4300)
p19 = FreeCAD.Vector(6767.765, 0, -6067.765)
p20 = FreeCAD.Vector(8552.705, 0, -7853.205)
p21 = FreeCAD.Vector(10337.645, 0, -9638.645)
p22 = FreeCAD.Vector(12123.085, 0, -11424.085)
p23 = FreeCAD.Vector(13024.645, 0, -12325.645)
p24 = FreeCAD.Vector(13926.205, 0, -13227.205)
p25 = FreeCAD.Vector(14495.425, 0, -13796.425)
p26 = FreeCAD.Vector(15046.97, 0, -11147.97)
p27 = FreeCAD.Vector(15046.97, 0, -7897.97)
# geometry objects
p1 = vec(0, 0, 50)
p2 = vec(0, 0, -50)
p3 = vec(0, 0, -4300)
p4 = vec(4950, 0, -4300)
p5 = vec(5000, 0, -4300)
p6 = vec(8535.53, 0, -7835.53)
p7 = vec(8569.88, 0, -7870.88)
p8 = vec(12105.41, 0, -11406.41)
p9 = vec(12140.76, 0, -11441.76)
p10 = vec(13908.53, 0, -13209.53)
p11 = vec(13943.88, 0, -13244.88)
p12 = vec(15046.97, 0, -14347.97)
p13 = vec(15046.97, 0, -7947.97)
p14 = vec(15046.97, 0, -7847.97)
p15 = vec(0, 0, 0)
p16 = vec(0, 0, -2175)
p17 = vec(2475, 0, -4300)
p18 = vec(4975, 0, -4300)
p19 = vec(6767.765, 0, -6067.765)
p20 = vec(8552.705, 0, -7853.205)
p21 = vec(10337.645, 0, -9638.645)
p22 = vec(12123.085, 0, -11424.085)
p23 = vec(13024.645, 0, -12325.645)
p24 = vec(13926.205, 0, -13227.205)
p25 = vec(14495.425, 0, -13796.425)
p26 = vec(15046.97, 0, -11147.97)
p27 = vec(15046.97, 0, -7897.97)
points = [
p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
p11, p12, p13, p14, p15, p16, p17, p18, p19, p20,
p21, p22, p23, p24, p25, p26, p27
]
from Draft import makeWire
line = makeWire(
geom_obj = makeWire(
points,
closed=False,
face=False,
@@ -92,7 +94,7 @@ def setup(doc=None, solvertype="ccxtools"):
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -136,7 +138,7 @@ def setup(doc=None, solvertype="ccxtools"):
inlet.SectionType = "Liquid"
inlet.LiquidSectionType = "PIPE INLET"
inlet.InletPressure = 0.1
inlet.References = [(line, "Edge1")]
inlet.References = [(geom_obj, "Edge1")]
entrance = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -145,7 +147,7 @@ def setup(doc=None, solvertype="ccxtools"):
entrance.LiquidSectionType = "PIPE ENTRANCE"
entrance.EntrancePipeArea = 31416.00
entrance.EntranceArea = 25133.00
entrance.References = [(line, "Edge2")]
entrance.References = [(geom_obj, "Edge2")]
manning1 = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -155,7 +157,7 @@ def setup(doc=None, solvertype="ccxtools"):
manning1.ManningArea = 31416
manning1.ManningRadius = 50
manning1.ManningCoefficient = 0.002
manning1.References = [(line, "Edge3"), (line, "Edge5")]
manning1.References = [(geom_obj, "Edge3"), (geom_obj, "Edge5")]
bend = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -166,7 +168,7 @@ def setup(doc=None, solvertype="ccxtools"):
bend.BendRadiusDiameter = 1.5
bend.BendAngle = 45
bend.BendLossCoefficient = 0.4
bend.References = [(line, "Edge4")]
bend.References = [(geom_obj, "Edge4")]
enlargement1 = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -175,7 +177,7 @@ def setup(doc=None, solvertype="ccxtools"):
enlargement1.LiquidSectionType = "PIPE ENLARGEMENT"
enlargement1.EnlargeArea1 = 31416.00
enlargement1.EnlargeArea2 = 70686.00
enlargement1.References = [(line, "Edge6")]
enlargement1.References = [(geom_obj, "Edge6")]
manning2 = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -185,7 +187,7 @@ def setup(doc=None, solvertype="ccxtools"):
manning2.ManningArea = 70686.00
manning2.ManningRadius = 75
manning2.ManningCoefficient = 0.002
manning2.References = [(line, "Edge7")]
manning2.References = [(geom_obj, "Edge7")]
contraction = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -194,7 +196,7 @@ def setup(doc=None, solvertype="ccxtools"):
contraction.LiquidSectionType = "PIPE CONTRACTION"
contraction.ContractArea1 = 70686
contraction.ContractArea2 = 17671
contraction.References = [(line, "Edge8")]
contraction.References = [(geom_obj, "Edge8")]
manning3 = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -204,7 +206,7 @@ def setup(doc=None, solvertype="ccxtools"):
manning3.ManningArea = 17671.00
manning3.ManningRadius = 37.5
manning3.ManningCoefficient = 0.002
manning3.References = [(line, "Edge11"), (line, "Edge9")]
manning3.References = [(geom_obj, "Edge11"), (geom_obj, "Edge9")]
gate_valve = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -213,7 +215,7 @@ def setup(doc=None, solvertype="ccxtools"):
gate_valve.LiquidSectionType = "PIPE GATE VALVE"
gate_valve.GateValvePipeArea = 17671
gate_valve.GateValveClosingCoeff = 0.5
gate_valve.References = [(line, "Edge10")]
gate_valve.References = [(geom_obj, "Edge10")]
enlargement2 = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -222,7 +224,7 @@ def setup(doc=None, solvertype="ccxtools"):
enlargement2.LiquidSectionType = "PIPE ENLARGEMENT"
enlargement2.EnlargeArea1 = 17671
enlargement2.EnlargeArea2 = 1e12
enlargement2.References = [(line, "Edge12")]
enlargement2.References = [(geom_obj, "Edge12")]
outlet = analysis.addObject(
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
@@ -230,7 +232,7 @@ def setup(doc=None, solvertype="ccxtools"):
outlet.SectionType = "Liquid"
outlet.LiquidSectionType = "PIPE OUTLET"
outlet.OutletPressure = 0.1
outlet.References = [(line, "Edge13")]
outlet.References = [(geom_obj, "Edge13")]
self_weight = analysis.addObject(
ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight")

View File

@@ -21,7 +21,6 @@
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples.thermomech_spine import setup
@@ -29,10 +28,10 @@ setup()
"""
import FreeCAD
import ObjectsFem
import Fem
import ObjectsFem
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
@@ -49,16 +48,16 @@ def setup(doc=None, solvertype="ccxtools"):
if doc is None:
doc = init_doc()
# part
box_obj = doc.addObject("Part::Box", "Box")
box_obj.Height = 25.4
box_obj.Width = 25.4
box_obj.Length = 203.2
# geometry object
geom_obj = doc.addObject("Part::Box", "Box")
geom_obj.Height = 25.4
geom_obj.Width = 25.4
geom_obj.Length = 203.2
doc.recompute()
if FreeCAD.GuiUp:
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().viewAxonometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
# analysis
@@ -104,7 +103,7 @@ def setup(doc=None, solvertype="ccxtools"):
fixed_constraint = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed")
)[0]
fixed_constraint.References = [(box_obj, "Face1")]
fixed_constraint.References = [(geom_obj, "Face1")]
# initialtemperature_constraint
initialtemperature_constraint = analysis.addObject(
@@ -116,7 +115,7 @@ def setup(doc=None, solvertype="ccxtools"):
temperature_constraint = analysis.addObject(
ObjectsFem.makeConstraintTemperature(doc, "FemConstraintTemperature")
)[0]
temperature_constraint.References = [(box_obj, "Face1")]
temperature_constraint.References = [(geom_obj, "Face1")]
temperature_constraint.Temperature = 310.93
# heatflux_constraint
@@ -124,10 +123,10 @@ def setup(doc=None, solvertype="ccxtools"):
ObjectsFem.makeConstraintHeatflux(doc, "FemConstraintHeatflux")
)[0]
heatflux_constraint.References = [
(box_obj, "Face3"),
(box_obj, "Face4"),
(box_obj, "Face5"),
(box_obj, "Face6")
(geom_obj, "Face3"),
(geom_obj, "Face4"),
(geom_obj, "Face5"),
(geom_obj, "Face6")
]
heatflux_constraint.AmbientTemp = 255.3722
heatflux_constraint.FilmCoef = 5.678