| 1 | # *************************************************************************** |
| 2 | # * Copyright (c) 2019 Bernd Hahnebach <[email protected]> * |
| 3 | # * Copyright (c) 2020 Sudhanshu Dubey <[email protected]> * |
| 4 | # * * |
| 5 | # * This file is part of the FreeCAD CAx development system. * |
| 6 | # * * |
| 7 | # * This program is free software; you can redistribute it and/or modify * |
| 8 | # * it under the terms of the GNU Lesser General Public License (LGPL) * |
| 9 | # * as published by the Free Software Foundation; either version 2 of * |
| 10 | # * the License, or (at your option) any later version. * |
| 11 | # * for detail see the LICENCE text file. * |
| 12 | # * * |
| 13 | # * This program is distributed in the hope that it will be useful, * |
| 14 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 15 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 16 | # * GNU Library General Public License for more details. * |
| 17 | # * * |
| 18 | # * You should have received a copy of the GNU Library General Public * |
| 19 | # * License along with this program; if not, write to the Free Software * |
| 20 | # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
| 21 | # * USA * |
| 22 | # * * |
| 23 | # *************************************************************************** |
| 24 | |
| 25 | import ObjectsFem |
| 26 | |
| 27 | from . import manager |
| 28 | from .ccx_cantilever_base_solid import setup_cantilever_base_solid |
| 29 | from .manager import init_doc |
| 30 | |
| 31 | |
| 32 | def get_information(): |
| 33 | return { |
| 34 | "name": "CCX cantilever prescribed displacement", |
| 35 | "meshtype": "solid", |
| 36 | "meshelement": "Tet10", |
| 37 | "constraints": ["fixed", "displacement"], |
| 38 | "solvers": ["ccxtools", "elmer"], |
| 39 | "material": "solid", |
| 40 | "equations": ["mechanical"], |
| 41 | } |
| 42 | |
| 43 | |
| 44 | def get_explanation(header=""): |
| 45 | return ( |
| 46 | header |
| 47 | + """ |
| 48 | |
| 49 | To run the example from Python console use: |
| 50 | from femexamples.ccx_cantilever_prescribeddisplacement import setup |
| 51 | setup() |
| 52 | |
| 53 | |
| 54 | See forum topic post: |
| 55 | ... |
| 56 | |
| 57 | """ |
| 58 | ) |
| 59 | |
| 60 | |
| 61 | def setup(doc=None, solvertype="ccxtools", test_mode=False): |
| 62 | |
| 63 | if solvertype == "z88": |
| 64 | # constraint displacement is not supported for Z88 |
| 65 | # pass a not valid solver name for z88, thus no solver is created |
| 66 | solvertype = "z88_not_valid" |
| 67 | |
| 68 | # init FreeCAD document |
| 69 | if doc is None: |
| 70 | doc = init_doc() |
| 71 | |
| 72 | # explanation object |
| 73 | # just keep the following line and change text string in get_explanation method |
| 74 | manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information()))) |
| 75 | |
| 76 | # setup CalculiX cantilever |
| 77 | # apply a prescribed displacement of 250 mm in -z on the front end face |
| 78 | doc = setup_cantilever_base_solid(doc, solvertype, test_mode) |
| 79 | analysis = doc.Analysis |
| 80 | geom_obj = doc.Box |
| 81 | |
| 82 | # constraint displacement |
| 83 | con_disp = ObjectsFem.makeConstraintDisplacement(doc, name="ConstraintDisplacementPrescribed") |
| 84 | con_disp.References = [(geom_obj, "Face2")] |
| 85 | con_disp.zFree = False |
| 86 | con_disp.zDisplacement = -250.0 |
| 87 | analysis.addObject(con_disp) |
| 88 | |
| 89 | doc.recompute() |
| 90 | return doc |