FEM: examples, boxanalysis separated into 2 examples

The static and frequency analysis were separated
This commit is contained in:
Sudhanshu Dubey
2020-06-22 13:08:47 +02:00
committed by Bernd Hahnebach
parent 6360ab6cea
commit 54c8dbd812
4 changed files with 83 additions and 40 deletions

View File

@@ -42,7 +42,8 @@ SET(FemCommands_SRCS
SET(FemExamples_SRCS
femexamples/__init__.py
femexamples/boxanalysis.py
femexamples/boxanalysis_static.py
femexamples/boxanalysis_frequency.py
femexamples/ccx_cantilever_std.py
femexamples/constraint_contact_shell_shell.py
femexamples/constraint_contact_solid_solid.py

View File

@@ -0,0 +1,75 @@
# ***************************************************************************
# * 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 boxanalysis as box
box.setup()
"""
import FreeCAD
import ObjectsFem
from .boxanalysis_static import setup_base
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 box frequency, change solver attributes
doc = setup_base(doc, solvertype)
analysis = doc.Analysis
# solver
if solvertype == "calculix":
solver_object = analysis.addObject(
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
)[0]
elif solvertype == "ccxtools":
solver_object = analysis.addObject(
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
)[0]
solver_object.WorkingDir = u""
if solvertype == "calculix" or solvertype == "ccxtools":
solver_object.AnalysisType = "frequency"
solver_object.GeometricalNonlinearity = "linear"
solver_object.ThermoMechSteadyState = False
solver_object.MatrixSolverType = "default"
solver_object.IterationsControlParameterTimeUse = False
solver_object.EigenmodesCount = 10
solver_object.EigenmodeHighLimit = 1000000.0
solver_object.EigenmodeLowLimit = 0.01
doc.recompute()
return doc

View File

@@ -25,9 +25,7 @@
"""
from femexamples import boxanalysis as box
box.setup_base()
box.setup_static()
box.setup_frequency()
box.setup()
"""
@@ -76,6 +74,7 @@ def setup_base(doc=None, solvertype="ccxtools"):
# mesh
from .meshes.mesh_boxanalysis_tetra10 import create_nodes, create_elements
fem_mesh = Fem.FemMesh()
control = create_nodes(fem_mesh)
if not control:
@@ -83,16 +82,14 @@ def setup_base(doc=None, solvertype="ccxtools"):
control = create_elements(fem_mesh)
if not control:
FreeCAD.Console.PrintError("Error on creating elements.\n")
femmesh_obj = analysis.addObject(
doc.addObject("Fem::FemMeshObject", mesh_name)
)[0]
femmesh_obj = analysis.addObject(doc.addObject("Fem::FemMeshObject", mesh_name))[0]
femmesh_obj.FemMesh = fem_mesh
doc.recompute()
return doc
def setup_static(doc=None, solvertype="ccxtools"):
def setup(doc=None, solvertype="ccxtools"):
# setup box static, add a fixed, force and a pressure constraint
doc = setup_base(doc, solvertype)
@@ -146,33 +143,3 @@ def setup_static(doc=None, solvertype="ccxtools"):
doc.recompute()
return doc
def setup_frequency(doc=None, solvertype="ccxtools"):
# setup box frequency, change solver attributes
doc = setup_base(doc, solvertype)
analysis = doc.Analysis
# solver
if solvertype == "calculix":
solver_object = analysis.addObject(
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
)[0]
elif solvertype == "ccxtools":
solver_object = analysis.addObject(
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
)[0]
solver_object.WorkingDir = u""
if solvertype == "calculix" or solvertype == "ccxtools":
solver_object.AnalysisType = "frequency"
solver_object.GeometricalNonlinearity = "linear"
solver_object.ThermoMechSteadyState = False
solver_object.MatrixSolverType = "default"
solver_object.IterationsControlParameterTimeUse = False
solver_object.EigenmodesCount = 10
solver_object.EigenmodeHighLimit = 1000000.0
solver_object.EigenmodeLowLimit = 0.01
doc.recompute()
return doc

View File

@@ -100,7 +100,7 @@ def run_analysis(doc, base_name, filepath=""):
def run_boxanalysisstatic(solver=None, base_name=None):
from .boxanalysis import setup_static as setup
from .boxanalysis_static import setup
doc = setup()
if base_name is None:
@@ -115,7 +115,7 @@ def run_boxanalysisstatic(solver=None, base_name=None):
def run_boxanalysisfrequency(solver=None, base_name=None):
from .boxanalysis import setup_frequency as setup
from .boxanalysis_frequency import setup
doc = setup()
if base_name is None: