Skip to content

Commit

Permalink
FEM: z88, add it to the new solver framework
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach authored and wwmayer committed Dec 2, 2017
1 parent d9bef5a commit 609e97a
Show file tree
Hide file tree
Showing 9 changed files with 704 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/Mod/Fem/App/CMakeLists.txt
Expand Up @@ -129,6 +129,13 @@ SET(FemSolver_SRCS
femsolver/signal.py
)

SET(FemZ88_SRCS
femsolver/z88/__init__.py
femsolver/z88/solver.py
femsolver/z88/tasks.py
femsolver/z88/writer.py
)

SET(FemGuiScripts_SRCS
PyGui/FemCommands.py
PyGui/FemSelectionObserver.py
Expand Down Expand Up @@ -332,6 +339,7 @@ fc_target_copy_resource(Fem
${FemGuiScripts_SRCS}
${FemTests_SRCS}
${FemSolver_SRCS}
${FemZ88_SRCS}
)

SET_BIN_DIR(Fem Fem /Mod/Fem)
Expand Down
10 changes: 10 additions & 0 deletions src/Mod/Fem/CMakeLists.txt
Expand Up @@ -84,6 +84,16 @@ INSTALL(
Mod/Fem/femsolver
)

INSTALL(
FILES
femsolver/z88/__init__.py
femsolver/z88/solver.py
femsolver/z88/tasks.py
femsolver/z88/writer.py
DESTINATION
Mod/Fem/femsolver/z88
)

INSTALL(
FILES
PyGui/FemCommands.py
Expand Down
10 changes: 3 additions & 7 deletions src/Mod/Fem/ObjectsFem.py
Expand Up @@ -321,14 +321,10 @@ def makeSolverCalculix(doc, name="CalculiX"):
return obj


def makeSolverZ88(doc, name="Z88"):
def makeSolverZ88(doc, name="SolverZ88"):
'''makeSolverZ88(document, [name]): makes a Z88 solver object'''
obj = doc.addObject("Fem::FemSolverObjectPython", name)
import PyObjects._FemSolverZ88
PyObjects._FemSolverZ88._FemSolverZ88(obj)
if FreeCAD.GuiUp:
import PyGui._ViewProviderFemSolverZ88
PyGui._ViewProviderFemSolverZ88._ViewProviderFemSolverZ88(obj.ViewObject)
import femsolver.z88.solver
obj = femsolver.z88.solver.create(doc, name)
return obj


Expand Down
4 changes: 3 additions & 1 deletion src/Mod/Fem/PyGui/_CommandFemSolverRun.py
Expand Up @@ -52,7 +52,9 @@ def load_results(ret_code):
print ("CalculiX failed ccx finished with error {}".format(ret_code))

self.solver = FreeCADGui.Selection.getSelection()[0] # see 'with_solver' in FemCommands for selection check
if self.solver.SolverType == "FemSolverCalculix":
if FemUtils.isDerivedFrom(self.solver, "Fem::FemSolverObjectZ88"):
self._newActivated()
elif self.solver.SolverType == "FemSolverCalculix":
import FemToolsCcx
self.fea = FemToolsCcx.FemToolsCcx(None, self.solver)
self.fea.reset_mesh_purge_results_checked()
Expand Down
6 changes: 6 additions & 0 deletions src/Mod/Fem/femsolver/settings.py
Expand Up @@ -36,6 +36,7 @@

_ELMER_PARAM = "User parameter:BaseApp/Preferences/Mod/Fem/Elmer"
_GRID_PARAM = "User parameter:BaseApp/Preferences/Mod/Fem/Grid"
_Z88_PARAM = "User parameter:BaseApp/Preferences/Mod/Fem/Z88"


class _BinaryDlg(object):
Expand Down Expand Up @@ -65,6 +66,11 @@ def getBinary(self):
param=_GRID_PARAM,
useDefault="UseStandardGridLocation",
customPath="gridBinaryPath"),
"Z88": _BinaryDlg(
default="z88r",
param=_Z88_PARAM,
useDefault="UseStandardZ88Location",
customPath="z88BinaryPath"),
}


Expand Down
Empty file.
90 changes: 90 additions & 0 deletions src/Mod/Fem/femsolver/z88/solver.py
@@ -0,0 +1,90 @@
# ***************************************************************************
# * *
# * Copyright (c) 2017 - Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * 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 *
# * *
# ***************************************************************************

__title__ = "Z88 SolverObject"
__author__ = "Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"

## @package SolverZ88
# \ingroup FEM

import os
import glob

import FreeCAD
import FemUtils

from .. import run
from .. import solverbase
from . import tasks


if FreeCAD.GuiUp:
import FemGui

ANALYSIS_TYPES = ["static"]


def create(doc, name="SolverZ88"):
return FemUtils.createObject(
doc, name, Proxy, ViewProxy)


class Proxy(solverbase.Proxy):
"""The Fem::FemSolver's Proxy python type, add solver specific properties
"""

Type = "Fem::FemSolverObjectZ88"

def __init__(self, obj):
super(Proxy, self).__init__(obj)
obj.Proxy = self

# z88_prefs = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Fem/Z88")

obj.addProperty("App::PropertyEnumeration", "AnalysisType", "Fem", "Type of the analysis")
obj.AnalysisType = ANALYSIS_TYPES
obj.AnalysisType = ANALYSIS_TYPES[0]

def createMachine(self, obj, directory):
return run.Machine(
solver=obj, directory=directory,
check=tasks.Check(),
prepare=tasks.Prepare(),
solve=tasks.Solve(),
results=tasks.Results())

def editSupported(self):
return True

def edit(self, directory):
pattern = os.path.join(directory, "*.txt")
print(pattern)
f = glob.glob(pattern)[0]
FemGui.open(f)

def execute(self, obj):
return


class ViewProxy(solverbase.ViewProxy):
pass

0 comments on commit 609e97a

Please sign in to comment.