Skip to content

Commit bacbceb

Browse files
authored
Merge pull request #12 from mscroggs/restructure
Restructure
2 parents 12a2b18 + ce40e6a commit bacbceb

24 files changed

+406
-385
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2020.12.4
1+
2021.1.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
author_email="[email protected]",
2929
maintainer_email="[email protected]",
3030
url="https://github.com/mscroggs/symfem",
31-
packages=["symfem"],
31+
packages=["symfem", "symfem.core", "symfem.elements"],
3232
data_files=data_files,
3333
include_package_data=True,
3434
install_requires=requirements

symfem/__init__.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""symfem: Symbolic Finite Element Method Definitions."""
22
import os as _os
3-
from . import simplex as _simplex
4-
from . import tp as _tp
5-
from . import references as _references
6-
from .finite_element import FiniteElement as _FiniteElement
3+
import importlib as _il
4+
from .core import references as _references
5+
from .core.finite_element import FiniteElement as _FiniteElement
76

87
_folder = _os.path.dirname(_os.path.realpath(__file__))
98

@@ -19,17 +18,23 @@
1918

2019
_elementlist = {}
2120

22-
for _cell_class, _module in [("simplex", _simplex), ("tp", _tp)]:
23-
_elementlist[_cell_class] = {}
24-
for _class_name in dir(_module):
25-
_element = getattr(_module, _class_name)
26-
if (
27-
isinstance(_element, type)
28-
and issubclass(_element, _FiniteElement)
29-
and _element != _FiniteElement
30-
):
31-
for _n in _element.names:
32-
_elementlist[_cell_class][_n] = _element
21+
22+
for _file in _os.listdir(_os.path.join(_folder, "elements")):
23+
if _file.endswith(".py") and "__init__" not in _file:
24+
_fname = _file[:-3]
25+
_module = _il.import_module(f"symfem.elements.{_fname}")
26+
27+
for _class_name in dir(_module):
28+
_element = getattr(_module, _class_name)
29+
if (
30+
isinstance(_element, type)
31+
and issubclass(_element, _FiniteElement)
32+
and _element != _FiniteElement
33+
):
34+
for _n in _element.names:
35+
if _n in _elementlist:
36+
assert _element == _elementlist[_n]
37+
_elementlist[_n] = _element
3338

3439

3540
def create_reference(cell_type):
@@ -70,12 +75,7 @@ def create_element(cell_type, element_type, order):
7075
"""
7176
reference = create_reference(cell_type)
7277

73-
if reference.simplex:
74-
if element_type in _elementlist["simplex"]:
75-
return _elementlist["simplex"][element_type](reference, order)
76-
77-
if reference.tp:
78-
if element_type in _elementlist["tp"]:
79-
return _elementlist["tp"][element_type](reference, order)
78+
if element_type in _elementlist:
79+
return _elementlist[element_type](reference, order)
8080

8181
raise ValueError(f"Unsupported element type: {element_type}")

symfem/core/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""The core of the symfem library."""
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)