Skip to content

Commit

Permalink
FEM: Examples, ccx_cantilever_std separated into 4 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudhanshu-Dubey14 committed May 9, 2020
1 parent 6e6380b commit 2ab23a5
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 71 deletions.
5 changes: 4 additions & 1 deletion src/Mod/Fem/CMakeLists.txt
Expand Up @@ -37,7 +37,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
Expand Down
Expand Up @@ -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()
"""

Expand Down Expand Up @@ -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)
Expand All @@ -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 changes: 65 additions & 0 deletions src/Mod/Fem/femexamples/ccx_cantilever_hexa20faceload.py
@@ -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. *
# * *
# * FreeCAD 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 FreeCAD; 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
import ObjectsFem

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 changes: 69 additions & 0 deletions src/Mod/Fem/femexamples/ccx_cantilever_nodeload.py
@@ -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. *
# * *
# * FreeCAD 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 FreeCAD; 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 Fem
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
64 changes: 64 additions & 0 deletions src/Mod/Fem/femexamples/ccx_cantilever_prescribeddisplacement.py
@@ -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. *
# * *
# * FreeCAD 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 FreeCAD; 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 Fem
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

0 comments on commit 2ab23a5

Please sign in to comment.