FEM: examples, ccx_cantilever_std separated into 4 examples
This commit is contained in:
committed by
Bernd Hahnebach
parent
54c8dbd812
commit
cfec12ec10
@@ -44,7 +44,10 @@ SET(FemExamples_SRCS
|
||||
femexamples/__init__.py
|
||||
femexamples/boxanalysis_static.py
|
||||
femexamples/boxanalysis_frequency.py
|
||||
femexamples/ccx_cantilever_std.py
|
||||
femexamples/ccx_cantilever_faceload.py
|
||||
femexamples/ccx_cantilever_nodeload.py
|
||||
femexamples/ccx_cantilever_hexa20faceload.py
|
||||
femexamples/ccx_cantilever_prescribeddisplacement.py
|
||||
femexamples/constraint_contact_shell_shell.py
|
||||
femexamples/constraint_contact_solid_solid.py
|
||||
femexamples/constraint_tie.py
|
||||
|
||||
@@ -23,13 +23,9 @@
|
||||
|
||||
# to run the example use:
|
||||
"""
|
||||
from femexamples import ccx_cantilever_std as canti
|
||||
from femexamples import ccx_cantilever_faceload as canti
|
||||
|
||||
canti.setup_cantileverbase()
|
||||
canti.setup_cantileverfaceload()
|
||||
canti.setup_cantilevernodeload()
|
||||
canti.setup_cantileverprescribeddisplacement()
|
||||
canti.setup_cantileverhexa20faceload()
|
||||
canti.setup()
|
||||
|
||||
"""
|
||||
|
||||
@@ -125,7 +121,7 @@ def setup_cantileverbase(doc=None, solvertype="ccxtools"):
|
||||
return doc
|
||||
|
||||
|
||||
def setup_cantileverfaceload(doc=None, solvertype="ccxtools"):
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever, apply 9 MN on surface of front end face
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
@@ -141,66 +137,3 @@ def setup_cantileverfaceload(doc=None, solvertype="ccxtools"):
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
|
||||
def setup_cantilevernodeload(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
|
||||
# force_constraint
|
||||
force_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
# should be possible in one tuple too
|
||||
force_constraint.References = [
|
||||
(doc.Box, "Vertex5"),
|
||||
(doc.Box, "Vertex6"),
|
||||
(doc.Box, "Vertex7"),
|
||||
(doc.Box, "Vertex8")
|
||||
]
|
||||
force_constraint.Force = 9000000.0
|
||||
force_constraint.Direction = (doc.Box, ["Edge5"])
|
||||
force_constraint.Reversed = True
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
|
||||
def setup_cantileverprescribeddisplacement(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever
|
||||
# apply a prescribed displacement of 250 mm in -z on the front end face
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
|
||||
# displacement_constraint
|
||||
displacement_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintDisplacement(doc, name="ConstraintDisplacmentPrescribed")
|
||||
)[0]
|
||||
displacement_constraint.References = [(doc.Box, "Face2")]
|
||||
displacement_constraint.zFix = False
|
||||
displacement_constraint.zFree = False
|
||||
displacement_constraint.zDisplacement = -250.0
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
|
||||
def setup_cantileverhexa20faceload(doc=None, solvertype="ccxtools"):
|
||||
doc = setup_cantileverfaceload(doc, solvertype)
|
||||
|
||||
# load the hexa20 mesh
|
||||
from .meshes.mesh_canticcx_hexa20 import create_nodes, create_elements
|
||||
fem_mesh = Fem.FemMesh()
|
||||
control = create_nodes(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating nodes.\n")
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
|
||||
# overwrite mesh with the hexa20 mesh
|
||||
doc.getObject(mesh_name).FemMesh = fem_mesh
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
65
src/Mod/Fem/femexamples/ccx_cantilever_hexa20faceload.py
Normal file
65
src/Mod/Fem/femexamples/ccx_cantilever_hexa20faceload.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2019 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
# to run the example use:
|
||||
"""
|
||||
from femexamples import ccx_cantilever_hexa20faceload as canti
|
||||
|
||||
canti.setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
|
||||
import Fem
|
||||
|
||||
from . import ccx_cantilever_faceload as faceload
|
||||
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
doc = FreeCAD.newDocument()
|
||||
return doc
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
doc = faceload.setup(doc, solvertype)
|
||||
|
||||
# load the hexa20 mesh
|
||||
from .meshes.mesh_canticcx_hexa20 import create_nodes, create_elements
|
||||
fem_mesh = Fem.FemMesh()
|
||||
control = create_nodes(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating nodes.\n")
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
|
||||
# overwrite mesh with the hexa20 mesh
|
||||
doc.getObject(mesh_name).FemMesh = fem_mesh
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
69
src/Mod/Fem/femexamples/ccx_cantilever_nodeload.py
Normal file
69
src/Mod/Fem/femexamples/ccx_cantilever_nodeload.py
Normal file
@@ -0,0 +1,69 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2019 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
# to run the example use:
|
||||
"""
|
||||
from femexamples import ccx_cantilever_nodeload as canti
|
||||
|
||||
canti.setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
|
||||
import ObjectsFem
|
||||
|
||||
from .ccx_cantilever_faceload import setup_cantileverbase
|
||||
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
doc = FreeCAD.newDocument()
|
||||
return doc
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
|
||||
# force_constraint
|
||||
force_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
# should be possible in one tuple too
|
||||
force_constraint.References = [
|
||||
(doc.Box, "Vertex5"),
|
||||
(doc.Box, "Vertex6"),
|
||||
(doc.Box, "Vertex7"),
|
||||
(doc.Box, "Vertex8")
|
||||
]
|
||||
force_constraint.Force = 9000000.0
|
||||
force_constraint.Direction = (doc.Box, ["Edge5"])
|
||||
force_constraint.Reversed = True
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
@@ -0,0 +1,64 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2019 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * *
|
||||
# * 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 *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
# to run the example use:
|
||||
"""
|
||||
from femexamples import ccx_cantilever_prescribeddisplacement as canti
|
||||
|
||||
canti.setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
|
||||
import ObjectsFem
|
||||
|
||||
from .ccx_cantilever_faceload import setup_cantileverbase
|
||||
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
doc = FreeCAD.newDocument()
|
||||
return doc
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever
|
||||
# apply a prescribed displacement of 250 mm in -z on the front end face
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
|
||||
# displacement_constraint
|
||||
displacement_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintDisplacement(doc, name="ConstraintDisplacmentPrescribed")
|
||||
)[0]
|
||||
displacement_constraint.References = [(doc.Box, "Face2")]
|
||||
displacement_constraint.zFix = False
|
||||
displacement_constraint.zFree = False
|
||||
displacement_constraint.zDisplacement = -250.0
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
@@ -32,7 +32,7 @@ doc = run_boxanalysisfrequency()
|
||||
doc = run_ccx_cantileverfaceload()
|
||||
doc = run_ccx_cantilevernodeload()
|
||||
doc = run_ccx_cantileverprescribeddisplacement()
|
||||
doc = setup_cantileverhexa20faceload()
|
||||
doc = run_ccx_cantilever_hexa20faceload()
|
||||
doc = run_constraint_contact_shell_shell()
|
||||
doc = run_constraint_contact_solid_solid()
|
||||
doc = run_constraint_tie()
|
||||
@@ -130,7 +130,7 @@ def run_boxanalysisfrequency(solver=None, base_name=None):
|
||||
|
||||
def run_ccx_cantileverfaceload(solver=None, base_name=None):
|
||||
|
||||
from .ccx_cantilever_std import setup_cantileverfaceload as setup
|
||||
from .ccx_cantilever_faceload import setup
|
||||
doc = setup()
|
||||
|
||||
if base_name is None:
|
||||
@@ -145,7 +145,7 @@ def run_ccx_cantileverfaceload(solver=None, base_name=None):
|
||||
|
||||
def run_ccx_cantilevernodeload(solver=None, base_name=None):
|
||||
|
||||
from .ccx_cantilever_std import setup_cantilevernodeload as setup
|
||||
from .ccx_cantilever_nodeload import setup
|
||||
doc = setup()
|
||||
|
||||
if base_name is None:
|
||||
@@ -160,7 +160,7 @@ def run_ccx_cantilevernodeload(solver=None, base_name=None):
|
||||
|
||||
def run_ccx_cantileverprescribeddisplacement(solver=None, base_name=None):
|
||||
|
||||
from .ccx_cantilever_std import setup_cantileverprescribeddisplacement as setup
|
||||
from .ccx_cantilever_prescribeddisplacement import setup
|
||||
doc = setup()
|
||||
|
||||
if base_name is None:
|
||||
@@ -173,9 +173,9 @@ def run_ccx_cantileverprescribeddisplacement(solver=None, base_name=None):
|
||||
return doc
|
||||
|
||||
|
||||
def setup_cantileverhexa20faceload(solver=None, base_name=None):
|
||||
def run_ccx_cantilever_hexa20faceload(solver=None, base_name=None):
|
||||
|
||||
from .ccx_cantilever_std import setup_cantileverhexa20faceload as setup
|
||||
from .ccx_cantilever_hexa20faceload import setup
|
||||
doc = setup()
|
||||
|
||||
if base_name is None:
|
||||
@@ -329,6 +329,7 @@ def run_all():
|
||||
run_ccx_cantileverfaceload()
|
||||
run_ccx_cantilevernodeload()
|
||||
run_ccx_cantileverprescribeddisplacement()
|
||||
run_ccx_cantilever_hexa20faceload()
|
||||
run_constraint_contact_shell_shell()
|
||||
run_constraint_contact_solid_solid()
|
||||
run_constraint_tie()
|
||||
|
||||
Reference in New Issue
Block a user