Skip to content

Commit

Permalink
FEM: examples, add explanation text object to all the rest examples
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Jun 17, 2021
1 parent 3626f48 commit bc9beff
Show file tree
Hide file tree
Showing 25 changed files with 550 additions and 216 deletions.
31 changes: 24 additions & 7 deletions src/Mod/Fem/femexamples/boxanalysis_frequency.py
Expand Up @@ -22,16 +22,11 @@
# * *
# ***************************************************************************

# to run the example use:
"""
from femexamples.boxanalysis_frequency import setup
setup()
"""

import ObjectsFem

from . import manager
from .boxanalysis_base import setup_boxanalysisbase
from .manager import init_doc


def get_information():
Expand All @@ -46,8 +41,30 @@ def get_information():
}


def get_explanation(header=""):
return header + """
To run the example from Python console use:
from femexamples.boxanalysis_frequency import setup
setup()
See forum topic post:
...
"""


def setup(doc=None, solvertype="ccxtools"):

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

# setup box frequency, change solver attributes
doc = setup_boxanalysisbase(doc, solvertype)
analysis = doc.Analysis
Expand Down
31 changes: 24 additions & 7 deletions src/Mod/Fem/femexamples/boxanalysis_static.py
Expand Up @@ -22,18 +22,13 @@
# * *
# ***************************************************************************

# to run the example use:
"""
from femexamples.boxanalysis_static import setup
setup()
"""

import FreeCAD

import ObjectsFem

from . import manager
from .boxanalysis_base import setup_boxanalysisbase
from .manager import init_doc


def get_information():
Expand All @@ -48,8 +43,30 @@ def get_information():
}


def get_explanation(header=""):
return header + """
To run the example from Python console use:
from femexamples.boxanalysis_static import setup
setup()
See forum topic post:
...
"""


def setup(doc=None, solvertype="ccxtools"):

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

# setup box static, add a fixed, force and a pressure constraint
doc = setup_boxanalysisbase(doc, solvertype)
geom_obj = doc.Box
Expand Down
33 changes: 25 additions & 8 deletions src/Mod/Fem/femexamples/ccx_cantilever_faceload.py
Expand Up @@ -22,16 +22,11 @@
# * *
# ***************************************************************************

# to run the example use:
"""
from femexamples.ccx_cantilever_faceload import setup
setup()
"""

import ObjectsFem

from . import manager
from .ccx_cantilever_base import setup_cantileverbase
from .manager import init_doc


def get_information():
Expand All @@ -46,9 +41,31 @@ def get_information():
}


def get_explanation(header=""):
return header + """
To run the example from Python console use:
from femexamples.ccx_cantilever_faceload import setup
setup()
See forum topic post:
...
"""


def setup(doc=None, solvertype="ccxtools"):
# setup CalculiX cantilever, apply 9 MN on surface of front end face

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

# setup CalculiX cantilever, apply 9 MN on surface of front end face
doc = setup_cantileverbase(doc, solvertype)
analysis = doc.Analysis
geom_obj = doc.Box
Expand Down
32 changes: 25 additions & 7 deletions src/Mod/Fem/femexamples/ccx_cantilever_hexa20faceload.py
Expand Up @@ -22,19 +22,14 @@
# * *
# ***************************************************************************

# to run the example use:
"""
from femexamples.ccx_cantilever_hexa20faceload import setup
setup()
"""

import FreeCAD

import Fem

from . import manager
from .ccx_cantilever_faceload import setup as setup_with_faceload
from .manager import get_meshname
from .manager import init_doc


def get_information():
Expand All @@ -49,8 +44,31 @@ def get_information():
}


def get_explanation(header=""):
return header + """
To run the example from Python console use:
from femexamples.ccx_cantilever_hexa20faceload import setup
setup()
See forum topic post:
...
"""


def setup(doc=None, solvertype="ccxtools"):

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

# setup cantilever faceload and exchange the mesh
doc = setup_with_faceload(doc, solvertype)
femmesh_obj = doc.getObject(get_meshname())

Expand Down
33 changes: 25 additions & 8 deletions src/Mod/Fem/femexamples/ccx_cantilever_nodeload.py
Expand Up @@ -22,16 +22,11 @@
# * *
# ***************************************************************************

# to run the example use:
"""
from femexamples.ccx_cantilever_nodeload import setup
setup()
"""

import ObjectsFem

from . import manager
from .ccx_cantilever_base import setup_cantileverbase
from .manager import init_doc


def get_information():
Expand All @@ -46,9 +41,31 @@ def get_information():
}


def get_explanation(header=""):
return header + """
To run the example from Python console use:
from femexamples.ccx_cantilever_nodeload import setup
setup()
See forum topic post:
...
"""


def setup(doc=None, solvertype="ccxtools"):
# setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

# setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face
doc = setup_cantileverbase(doc, solvertype)
analysis = doc.Analysis
geom_obj = doc.Box
Expand Down
35 changes: 26 additions & 9 deletions src/Mod/Fem/femexamples/ccx_cantilever_prescribeddisplacement.py
Expand Up @@ -22,16 +22,11 @@
# * *
# ***************************************************************************

# to run the example use:
"""
from femexamples.ccx_cantilever_prescribeddisplacement import setup
setup()
"""

import ObjectsFem

from . import manager
from .ccx_cantilever_base import setup_cantileverbase
from .manager import init_doc


def get_information():
Expand All @@ -46,15 +41,37 @@ def get_information():
}


def get_explanation(header=""):
return header + """
To run the example from Python console use:
from femexamples.ccx_cantilever_prescribeddisplacement import setup
setup()
See forum topic post:
...
"""


def setup(doc=None, solvertype="ccxtools"):
# setup CalculiX cantilever
# apply a prescribed displacement of 250 mm in -z on the front end face

if solvertype == "z88":
# constraint displacement is not supported for Z88
# pass a not valid solver name for z88, thus no solver is created
solvertype = "z88_not_valid"

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

# setup CalculiX cantilever
# apply a prescribed displacement of 250 mm in -z on the front end face
doc = setup_cantileverbase(doc, solvertype)
analysis = doc.Analysis
geom_obj = doc.Box
Expand Down
33 changes: 22 additions & 11 deletions src/Mod/Fem/femexamples/constraint_contact_shell_shell.py
Expand Up @@ -22,17 +22,6 @@
# * *
# ***************************************************************************

# to run the example use:
"""
from femexamples.constraint_contact_shell_shell import setup
setup()
"""

# 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

import FreeCAD

import Part
Expand All @@ -41,6 +30,7 @@
import Fem
import ObjectsFem

from . import manager
from .manager import get_meshname
from .manager import init_doc

Expand All @@ -57,12 +47,33 @@ def get_information():
}


def get_explanation(header=""):
return header + """
To run the example from Python console use:
from femexamples.constraint_contact_shell_shell import setup
setup()
See forum topic post:
https://forum.freecadweb.org/viewtopic.php?f=18&t=42228
based on https://forum.freecadweb.org/viewtopic.php?f=18&t=42228#p359488
contact example shell to shell elements
"""


def setup(doc=None, solvertype="ccxtools"):

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))

# geometric 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
Expand Down

0 comments on commit bc9beff

Please sign in to comment.