forked from FreeCAD/FreeCAD
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEM: Examples, ccx_cantilever_std separated into 4 examples
- Loading branch information
1 parent
6e6380b
commit 2ab23a5
Showing
5 changed files
with
205 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
64
src/Mod/Fem/femexamples/ccx_cantilever_prescribeddisplacement.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |