2021-12-14 17:50:00 +05:00
|
|
|
import os, shutil
|
2021-11-19 23:35:12 +05:00
|
|
|
from os import path
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
unittest.TestLoader.sortTestMethodsUsing = None
|
|
|
|
|
|
|
|
class TestCore(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
try:
|
2021-12-14 17:50:00 +05:00
|
|
|
import netgen.occ
|
|
|
|
_ = netgen.occ.Pnt(0, 0, 0)
|
2021-11-19 23:35:12 +05:00
|
|
|
|
2021-12-14 17:50:00 +05:00
|
|
|
except Exception as e:
|
|
|
|
self.skipTest(e)
|
2021-11-19 23:35:12 +05:00
|
|
|
|
|
|
|
else:
|
2021-12-14 17:50:00 +05:00
|
|
|
from anisotropy import core
|
2021-11-19 23:35:12 +05:00
|
|
|
|
|
|
|
self.core = core
|
|
|
|
|
2021-12-01 16:58:06 +05:00
|
|
|
self.currentPath = os.path.abspath(".")
|
2021-12-14 17:50:00 +05:00
|
|
|
self.outputPath = os.path.join(os.path.dirname(__file__), "test_core_output")
|
2021-11-19 23:35:12 +05:00
|
|
|
os.makedirs(self.outputPath, exist_ok = True)
|
|
|
|
|
|
|
|
def test_config(self):
|
|
|
|
from copy import deepcopy
|
|
|
|
|
|
|
|
config = self.core.DefaultConfig()
|
|
|
|
contentOld = deepcopy(config.content)
|
|
|
|
filepath = os.path.join(self.outputPath, "test_config.toml")
|
|
|
|
config.dump(filepath)
|
|
|
|
|
|
|
|
config = self.core.Config()
|
|
|
|
config.load(filepath)
|
|
|
|
|
|
|
|
self.assertEqual(contentOld, config.content)
|
|
|
|
|
|
|
|
def test_runner(self):
|
|
|
|
os.chdir(self.outputPath)
|
|
|
|
|
|
|
|
pathOld = os.path.abspath(".")
|
|
|
|
config = self.core.DefaultConfig()
|
2021-12-14 17:50:00 +05:00
|
|
|
# TODO: config for solo case
|
2021-12-10 19:33:54 +05:00
|
|
|
runner = self.core.UltimateRunner(config = config)
|
2021-12-14 17:50:00 +05:00
|
|
|
runner.createRow()
|
2021-11-19 23:35:12 +05:00
|
|
|
|
|
|
|
runner.computeShape()
|
|
|
|
self.assertTrue(path.isfile(path.join(runner.casepath(), "shape.step")))
|
|
|
|
|
|
|
|
runner.computeMesh()
|
|
|
|
self.assertTrue(path.isfile(path.join(runner.casepath(), "mesh.mesh")))
|
|
|
|
|
|
|
|
runner.computeFlow()
|
2021-12-01 16:58:06 +05:00
|
|
|
self.assertTrue(path.isfile(path.join(runner.casepath(), "mesh.mesh")))
|
2021-11-19 23:35:12 +05:00
|
|
|
|
|
|
|
os.chdir(pathOld)
|
|
|
|
|
|
|
|
def tearDown(self):
|
2021-12-01 16:58:06 +05:00
|
|
|
os.chdir(self.currentPath)
|
2021-12-14 17:50:00 +05:00
|
|
|
shutil.rmtree(self.outputPath)
|
2021-11-19 23:35:12 +05:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|