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: unit tests, add z88 writing test framework
- Loading branch information
1 parent
cab4077
commit 5b104e1
Showing
14 changed files
with
965 additions
and
0 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,142 @@ | ||
# *************************************************************************** | ||
# * Copyright (c) 2018 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 * | ||
# * * | ||
# *************************************************************************** | ||
|
||
__title__ = "Solver z88 FEM unit tests" | ||
__author__ = "Bernd Hahnebach" | ||
__url__ = "http://www.freecadweb.org" | ||
|
||
import unittest | ||
from os import listdir | ||
from os.path import join | ||
|
||
import FreeCAD | ||
|
||
import femsolver.run | ||
from . import support_utils as testtools | ||
from .support_utils import fcc_print | ||
|
||
|
||
class TestSolverZ88(unittest.TestCase): | ||
fcc_print("import TestSolverZ88") | ||
|
||
# ******************************************************************************************** | ||
def setUp( | ||
self | ||
): | ||
# setUp is executed before every test | ||
|
||
# new document | ||
self.document = FreeCAD.newDocument(self.__class__.__name__) | ||
|
||
# more inits | ||
self.mesh_name = "Mesh" | ||
|
||
# ******************************************************************************************** | ||
def tearDown( | ||
self | ||
): | ||
# tearDown is executed after every test | ||
FreeCAD.closeDocument(self.document.Name) | ||
|
||
# ******************************************************************************************** | ||
def test_00print( | ||
self | ||
): | ||
# since method name starts with 00 this will be run first | ||
# this test just prints a line with stars | ||
|
||
fcc_print("\n{0}\n{1} run FEM TestSolverFrameWork tests {2}\n{0}".format( | ||
100 * "*", | ||
10 * "*", | ||
55 * "*" | ||
)) | ||
|
||
# ******************************************************************************************** | ||
def test_solver_z88( | ||
self | ||
): | ||
from femexamples.boxanalysis_static import setup | ||
setup(self.document, "z88") | ||
self.z88_inputfile_writing_test("cube_static") | ||
|
||
# ******************************************************************************************** | ||
def z88_inputfile_writing_test( | ||
self, | ||
base_name | ||
): | ||
|
||
self.document.recompute() | ||
|
||
# start | ||
fcc_print( | ||
"\n------------- Start of FEM Z88 tests for {} -------" | ||
.format(base_name) | ||
) | ||
|
||
# get analysis working directory and save FreeCAD file | ||
working_dir = testtools.get_fem_test_tmp_dir("solver_z88_" + base_name) | ||
save_fc_file = join(working_dir, base_name + ".FCStd") | ||
fcc_print("Save FreeCAD file to {} ...".format(save_fc_file)) | ||
self.document.saveAs(save_fc_file) | ||
|
||
# write input file | ||
machine = self.document.SolverZ88.Proxy.createMachine( | ||
self.document.SolverZ88, | ||
working_dir, | ||
True # set testmode to True | ||
) | ||
machine.target = femsolver.run.PREPARE | ||
machine.start() | ||
machine.join() # wait for the machine to finish | ||
|
||
# compare input file with the given one | ||
test_path = join(testtools.get_fem_test_home_dir(), "z88", base_name) | ||
test_files = [f for f in listdir(test_path)] | ||
for test_file in test_files: | ||
inpfile_given = join( | ||
test_path, | ||
test_file | ||
) | ||
inpfile_totest = join( | ||
working_dir, | ||
test_file | ||
) | ||
fcc_print( | ||
"Comparing {} to {}" | ||
.format(inpfile_given, inpfile_totest) | ||
) | ||
ret = testtools.compare_inp_files( | ||
inpfile_given, | ||
inpfile_totest | ||
) | ||
self.assertFalse( | ||
ret, | ||
"Z88 write_inp_file for {0} test failed.\n{1}".format(base_name, ret) | ||
) | ||
|
||
# end | ||
fcc_print( | ||
"--------------- End of FEM Z88 tests for {} ---------" | ||
.format(base_name) | ||
) |
Empty file.
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 @@ | ||
200000.0 0.300 |
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,49 @@ | ||
DYNAMIC START | ||
--------------------------------------------------------------------------- | ||
Z88 new version 14OS Z88 neue Version 14OS | ||
--------------------------------------------------------------------------- | ||
|
||
--------------------------------------------------------------------------- | ||
LANGUAGE SPRACHE | ||
--------------------------------------------------------------------------- | ||
GERMAN | ||
|
||
--------------------------------------------------------------------------- | ||
Entries for mesh generator Z88N Daten fuer Netzgenerator | ||
--------------------------------------------------------------------------- | ||
NET START | ||
MAXSE 40000 | ||
MAXESS 800 | ||
MAXKSS 4000 | ||
MAXAN 15 | ||
NET END | ||
|
||
--------------------------------------------------------------------------- | ||
Common entries for all modules gemeinsame Daten fuer alle Module | ||
--------------------------------------------------------------------------- | ||
|
||
COMMON START | ||
MAXGS 50000000 | ||
MAXKOI 1200000 | ||
MAXK 60000 | ||
MAXE 300000 | ||
MAXNFG 200000 | ||
MAXMAT 32 | ||
MAXPEL 32 | ||
MAXJNT 32 | ||
MAXPR 10000 | ||
MAXRBD 15000 | ||
MAXIEZ 6000000 | ||
MAXGP 2000000 | ||
COMMON END | ||
|
||
--------------------------------------------------------------------------- | ||
Entries for Cuthill-McKee Z88H Daten fuer Cuthill- McKee Programm | ||
--------------------------------------------------------------------------- | ||
CUTKEE START | ||
MAXGRA 200 | ||
MAXNDL 1000 | ||
CUTKEE END | ||
|
||
|
||
DYNAMIC END |
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,2 @@ | ||
1 | ||
1 129 0 0 0 0 0 0 0 |
Oops, something went wrong.