Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/setup_repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ git checkout indiamai/integrate_fuse
git status
python3 -m pip install --break-system-packages -e .

/usr/bin/git config --global --add safe.directory ~
cd ~
git clone https://github.com/firedrakeproject/ufl.git
/usr/bin/git config --global --add safe.directory ~/ufl
cd ufl
git fetch
git checkout indiamai/integrate-fuse
git status
python3 -m pip install --break-system-packages -e .
#/usr/bin/git config --global --add safe.directory ~
#cd ~
#git clone https://github.com/firedrakeproject/ufl.git
#/usr/bin/git config --global --add safe.directory ~/ufl
#cd ufl
#git fetch
#git checkout indiamai/integrate-fuse
#git status
#python3 -m pip install --break-system-packages -e .
16 changes: 3 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ jobs:
# Run on the Github hosted runner
runs-on: ubuntu-latest
container:
image: firedrakeproject/firedrake-vanilla-default:latest
#image: firedrakeproject/firedrake-vanilla-default:latest
image: firedrakeproject/firedrake-vanilla-default:dev-main
# Steps represent a sequence of tasks that will be executed as
# part of the jobs
steps:
Expand Down Expand Up @@ -44,17 +45,6 @@ jobs:
git checkout indiamai/integrate_fuse
git status
python3 -m pip install --break-system-packages -e .
- name: Checkout correct UFL branch
run: |
/usr/bin/git config --global --add safe.directory ~
cd ~
git clone https://github.com/firedrakeproject/ufl.git
/usr/bin/git config --global --add safe.directory ~/ufl
cd ufl
git fetch
git checkout indiamai/integrate-fuse
git status
python3 -m pip install --break-system-packages -e .
- name: Run tests
run: |
pip list
Expand Down Expand Up @@ -104,4 +94,4 @@ jobs:
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}
valColorRange: ${{ env.total }}
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ lint:

test_examples:
@echo " Running examples"
@python3 -m pytest test/test_2d_examples_docs.py
@python3 -m pytest test/test_3d_examples_docs.py
@FIREDRAKE_USE_FUSE=1 python3 -m pytest test/test_2d_examples_docs.py
@FIREDRAKE_USE_FUSE=1 python3 -m pytest test/test_3d_examples_docs.py

tests:
@echo " Running all tests"
@python3 -m coverage run -p -m pytest -rx test
@FIREDRAKE_USE_FUSE=1 python3 -m coverage run -p -m pytest -rx test

coverage:
@python3 -m coverage combine
Expand All @@ -34,13 +34,13 @@ coverage:
test_cells:
@echo " Running all cell comparison tests"
@firedrake-clean
@python3 -m pytest -rPx --run-cleared test/test_cells.py::test_ref_els[expect0]
@FIREDRAKE_USE_FUSE=1 python3 -m pytest -rPx --run-cleared test/test_cells.py::test_ref_els[expect0]
@firedrake-clean
@python3 -m pytest -rPx --run-cleared test/test_cells.py::test_ref_els[expect1]
@FIREDRAKE_USE_FUSE=1 python3 -m pytest -rPx --run-cleared test/test_cells.py::test_ref_els[expect1]

clean:
@(cd docs/ && make clean)

prepush: lint tests
@rm .coverage.*
make clean docs
make clean docs
4 changes: 1 addition & 3 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import pytest

def pytest_addoption(parser):
parser.addoption(
"--run-cleared",
action="store_true",
default=False,
help="Run tests that require a cleared cache",
)
)
9 changes: 6 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_css_files = ["additional.css"]


def setup(app):
app.add_css_file('additional.css')
app.add_css_file('additional.css')


html_theme_options = {
'navbar_links': [
Expand All @@ -109,11 +112,11 @@ def setup(app):
'globaltoc_depth': 2,
}

html_sidebars = {'api/*': ['localtoc.html'],
html_sidebars = {'api/*': ['localtoc.html'],
'api': ['localtoc.html'],
'about': [],
'install': [],
'index': ['localtoc.html'],
'manual': ['localtoc.html'],
'manual/*': ['localtoc.html'],
'_generated/*': ['custom-sidebar.html'], }
'_generated/*': ['custom-sidebar.html'], }
1 change: 0 additions & 1 deletion fuse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from fuse.cells import Point, Edge, polygon, make_tetrahedron, constructCellComplex
from fuse.groups import S1, S2, S3, D4, Z3, Z4, C3, C4, S4, A4, tri_C3, tet_edges, tet_faces, sq_edges, GroupRepresentation, PermutationSetRepresentation, get_cyc_group, get_sym_group
from fuse.dof import DeltaPairing, DOF, L2Pairing, FuseFunction, PointKernel, PolynomialKernel, ComponentKernel
Expand Down
48 changes: 39 additions & 9 deletions fuse/cells.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from sympy.combinatorics.named_groups import SymmetricGroup
from fuse.utils import sympy_to_numpy, fold_reduce, numpy_to_str_tuple, orientation_value
from FIAT.reference_element import Simplex, TensorProductCell as FiatTensorProductCell, Hypercube
from FIAT.quadrature_schemes import create_quadrature
from ufl.cell import Cell, TensorProductCell
from functools import cache

Expand Down Expand Up @@ -94,7 +95,7 @@ def compute_scaled_verts(d, n):
:param: n: number of vertices
"""
if d == 2:
source = np.array([0, 1])
source = np.array([-np.sqrt(3)/2, -1/2])
rot_coords = [source for i in range(0, n)]

rot_mat = np.array([[np.cos((2*np.pi)/n), -np.sin((2*np.pi)/n)], [np.sin((2*np.pi)/n), np.cos((2*np.pi)/n)]])
Expand Down Expand Up @@ -544,7 +545,7 @@ def get_node(self, node, return_coords=False):
if return_coords:
top_level_node = self.d_entities_ids(self.graph_dim())[0]
if self.dimension == 0:
return [()]
return ()
return self.attachment(top_level_node, node)()
return self.G.nodes.data("point_class")[node]

Expand Down Expand Up @@ -623,7 +624,11 @@ def basis_vectors(self, return_coords=True, entity=None):
if self.dimension == 0:
# return [[]
raise ValueError("Dimension 0 entities cannot have Basis Vectors")
top_level_node = self_levels[0][0]
if self.oriented:
# ordered_vertices() handles the orientation so we want to drop the orientation node
top_level_node = self_levels[1][0]
else:
top_level_node = self_levels[0][0]
v_0 = vertices[0]
if return_coords:
v_0_coords = self.attachment(top_level_node, v_0)()
Expand Down Expand Up @@ -656,6 +661,27 @@ def to_tikz(self, show=True, scale=3):
return "\n".join(tikz_commands)
return tikz_commands

def generate_facet_parameterisation(self, facet_num):
raise NotImplementedError("Facet Parameterisation can be expressed using polynomials")
# facet = self.d_entities(self.dimension - 1)[facet_num]
facet = self.get_node(facet_num)
facet_dim = facet.dimension
if facet_dim != self.dimension - 1:
raise ValueError(f"Supplied node {facet_num} is not a facet")
if facet_dim > 1:
raise NotImplementedError("Facet parameterisation is not implemented for dimensions greater than 1")
verts = facet.vertices()
v_coords = np.array([self.get_node(v.id, return_coords=True) for v in verts])
stacked = np.c_[np.ones((self.dimension,)), v_coords[:, 0].reshape(self.dimension, 1)]
b = np.array([0, 1])
coeffs = np.linalg.solve(stacked, b)
symbol_names = ["x", "y", "z"]
symbols = [1] + [sp.Symbol(symbol_names[d]) for d in range(facet_dim)]
res = 0
for d in range(facet_dim + 1):
res += coeffs[d] * symbols[d]
return res, symbols[1:]

def plot(self, show=True, plain=False, ax=None, filename=None):
""" for now into 2 dimensional space """
if self.dimension == 3:
Expand Down Expand Up @@ -767,6 +793,12 @@ def attachment(self, source, dst):

return lambda *x: fold_reduce(attachments[0], *x)

def quadrature(self, degree):
fiat_el = self.to_fiat()
Q = create_quadrature(fiat_el, degree)
pts, wts = Q.get_points(), Q.get_weights()
return pts, wts

def cell_attachment(self, dst):
if not isinstance(dst, int):
raise ValueError
Expand All @@ -775,6 +807,8 @@ def cell_attachment(self, dst):

def orient(self, o):
""" Orientation node is always labelled with -1 """
if self.oriented:
o = self.oriented * o
oriented_point = copy.deepcopy(self)
top_level_node = oriented_point.d_entities_ids(
oriented_point.dimension)[0]
Expand Down Expand Up @@ -838,10 +872,7 @@ def __call__(self, *x):
if hasattr(self.attachment, '__iter__'):
res = []
for attach_comp in self.attachment:
if len(attach_comp.atoms(sp.Symbol)) == len(x):
res.append(sympy_to_numpy(attach_comp, syms, x))
else:
res.append(attach_comp.subs({syms[i]: x[i] for i in range(len(x))}))
res.append(sympy_to_numpy(attach_comp, syms, x))
return tuple(res)
return sympy_to_numpy(self.attachment, syms, x)
return x
Expand Down Expand Up @@ -885,7 +916,6 @@ def get_spatial_dimension(self):
def get_sub_entities(self):
self.A.get_sub_entities()
self.B.get_sub_entities()
breakpoint()

def dimension(self):
return tuple(self.A.dimension, self.B.dimension)
Expand Down Expand Up @@ -1076,7 +1106,7 @@ def __init__(self, cell, name=None):
super(CellComplexToUFL, self).__init__(name)

def to_fiat(self):
return self.cell_complex.to_fiat(name=self.cellname())
return self.cell_complex.to_fiat(name=self.cellname)

def __repr__(self):
return super(CellComplexToUFL, self).__repr__()
Expand Down
Loading
Loading