forked from FEniCS/fiat
-
Notifications
You must be signed in to change notification settings - Fork 7
Add fuse element infrastructure #127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
indiamai
wants to merge
47
commits into
main
Choose a base branch
from
indiamai/integrate_fuse
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
6573217
First draft of expanding set size to match when unioning
indiamai dc5188a
Change condition of extension
indiamai c75efef
Adapt new coeff construction for vec sets
indiamai dfd1347
select larger of degrees
indiamai 21f1bf1
Add orthonormal requirement
indiamai 3eb0d1a
merge master
indiamai 2c21e27
Merge master
indiamai 2b45bd5
Move finat commits from old branch
indiamai 9b05688
Lint
indiamai 3a7bb5b
Merge master
indiamai 8d1a074
Refactor to deal with single source of truth
indiamai b72cd61
Refactoring
indiamai a89d057
Renaming fuse project (#125)
indiamai ac81474
Address Pablo's comments
indiamai 9420a6d
Lint
indiamai be81de3
Remove final references to India Def
indiamai 2e3ed6c
Add test, small change to spatial dimension management
indiamai 0b593e5
remove fuse dependency
indiamai 263dad1
Modify code to use np.pad
indiamai ad63ee0
Add extension of coefficients to allow union of polysets with differe…
indiamai 3a5b073
Small changes to allow different topologies
indiamai 8d52e22
remove orthonormal as seems to be no longer necessary
indiamai 8eaa60c
Remove further orthonormals
indiamai d3b31cb
Merge branch 'indiamai/extend_coeffs' into indiamai/integrate_fuse
indiamai b5e41fe
Merge branch 'master' into indiamai/integrate_fuse
indiamai f31fd72
Update UFL rep of fuse element to cover both regular fuse and tensor …
indiamai a91c7a2
tensor prod infrastructure
indiamai 2bc3161
convert things to generic as_Cell and add flattening infra for fuse
indiamai 4953241
Add generic hypercube class
indiamai e8aaa56
Change type to allow comparision of subclasses of tensor product cell…
indiamai a726c98
Add function that moves any cell to a simplex. Modify DPC to use
indiamai 7d5ef1c
Integrate hypercube changes to fuse (#137)
indiamai 9e2f7c0
Merge branch 'master' into indiamai/integrate_fuse
indiamai 2f8a74d
Merge branch 'master' into indiamai/integrate_fuse
indiamai 8771342
First stab at a rewrite of connectivity to respect non UFC ordering
indiamai 2373db4
refactor, simplify
indiamai 3482800
remove print
indiamai ef6c59c
modify to use hasse diagram for fuse sub entities
indiamai df581a7
remove print
indiamai dde1c05
add the ablity to pass facet orientation to facet quadrature rule
indiamai f04175e
Merge branch 'master' into indiamai/integrate_fuse
indiamai ab73328
add clearer error
indiamai 85cef62
Merge branch 'main' into indiamai/integrate_fuse
indiamai e665761
Move fuse as_cell dependence out of UFL and into final.ufl (#184)
indiamai 53bc284
Merge branch 'main' into indiamai/integrate_fuse
indiamai a4a887c
Merge branch 'main' into indiamai/integrate_fuse
indiamai 4633e7f
Merge branch 'main' into indiamai/integrate_fuse
indiamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -133,7 +133,7 @@ class Cell: | |||||||||
| """Abstract class for a reference cell. Provides accessors for | ||||||||||
| geometry (vertex coordinates) as well as topology (orderings of | ||||||||||
| vertices that make up edges, faces, etc.""" | ||||||||||
| def __init__(self, shape, vertices, topology): | ||||||||||
| def __init__(self, shape, vertices, topology, sub_entities=None): | ||||||||||
| """The constructor takes a shape code, the physical vertices expressed | ||||||||||
| as a list of tuples of numbers, and the topology of a cell. | ||||||||||
|
|
||||||||||
|
|
@@ -145,24 +145,42 @@ def __init__(self, shape, vertices, topology): | |||||||||
| self.vertices = vertices | ||||||||||
| self.topology = topology | ||||||||||
|
|
||||||||||
| # Given the topology, work out for each entity in the cell, | ||||||||||
| # which other entities it contains. | ||||||||||
| self.sub_entities = {} | ||||||||||
| for dim, entities in topology.items(): | ||||||||||
| self.sub_entities[dim] = {} | ||||||||||
|
|
||||||||||
| for e, v in entities.items(): | ||||||||||
| vertices = frozenset(v) | ||||||||||
| sub_entities = [] | ||||||||||
|
|
||||||||||
| for dim_, entities_ in topology.items(): | ||||||||||
| for e_, vertices_ in entities_.items(): | ||||||||||
| if vertices.issuperset(vertices_): | ||||||||||
| sub_entities.append((dim_, e_)) | ||||||||||
|
|
||||||||||
| # Sort for the sake of determinism and by UFC conventions | ||||||||||
| self.sub_entities[dim][e] = sorted(sub_entities) | ||||||||||
|
|
||||||||||
| if sub_entities: | ||||||||||
| self.sub_entities = sub_entities | ||||||||||
| else: | ||||||||||
| # If sub entity list not provided | ||||||||||
| # Given the topology, work out for each entity in the cell, | ||||||||||
| # which other entities it contains. | ||||||||||
| self.sub_entities = {} | ||||||||||
| self.sub_entities_old = {} | ||||||||||
| for dim, entities in topology.items(): | ||||||||||
| self.sub_entities[dim] = {} | ||||||||||
| self.sub_entities_old[dim] = {} | ||||||||||
|
|
||||||||||
| for e, v in entities.items(): | ||||||||||
| vertices = frozenset(v) | ||||||||||
| sub_entities = [] | ||||||||||
| sub_entities_old = [] | ||||||||||
| for dim_, entities_ in topology.items(): | ||||||||||
| for e_, vertices_ in entities_.items(): | ||||||||||
| if vertices.issuperset(vertices_): | ||||||||||
| sub_entities_old.append((dim_, e_)) | ||||||||||
|
|
||||||||||
| # in order to maintain ordering, extract subentities from vertex numbering | ||||||||||
| entities_of_dim_ = list(entities_.values()) | ||||||||||
|
|
||||||||||
| from itertools import permutations | ||||||||||
| # generate all possible sub entities | ||||||||||
| sub_list = permutations(v, len(entities_of_dim_[0])) | ||||||||||
| for s in sub_list: | ||||||||||
| # add the sub entities in the same order as in topology | ||||||||||
| for i, val in entities_.items(): | ||||||||||
| if set(s) == set(val) and (dim_, i) not in sub_entities: | ||||||||||
| sub_entities.append((dim_, i)) | ||||||||||
|
|
||||||||||
| self.sub_entities[dim][e] = list(sub_entities) | ||||||||||
| self.sub_entities_old[dim][e] = list(sub_entities_old) | ||||||||||
| self.sub_entities = self.sub_entities_old | ||||||||||
| # Build super-entity dictionary by inverting the sub-entity dictionary | ||||||||||
| self.super_entities = {dim: {entity: [] for entity in topology[dim]} for dim in topology} | ||||||||||
| for dim0 in topology: | ||||||||||
|
|
@@ -183,7 +201,6 @@ def __init__(self, shape, vertices, topology): | |||||||||
| neighbors = children if dim1 < dim0 else parents | ||||||||||
| d01_entities = tuple(e for d, e in neighbors if d == dim1) | ||||||||||
| self.connectivity[(dim0, dim1)].append(d01_entities) | ||||||||||
|
|
||||||||||
| # Dictionary with derived cells | ||||||||||
| self._split_cache = {} | ||||||||||
|
|
||||||||||
|
|
@@ -387,14 +404,14 @@ class SimplicialComplex(Cell): | |||||||||
|
|
||||||||||
| This consists of list of vertex locations and a topology map defining facets. | ||||||||||
| """ | ||||||||||
| def __init__(self, shape, vertices, topology): | ||||||||||
| def __init__(self, shape, vertices, topology, sub_ents=None): | ||||||||||
| # Make sure that every facet has the right number of vertices to be | ||||||||||
| # a simplex. | ||||||||||
| for dim in topology: | ||||||||||
| for entity in topology[dim]: | ||||||||||
| assert len(topology[dim][entity]) == dim + 1 | ||||||||||
|
|
||||||||||
| super().__init__(shape, vertices, topology) | ||||||||||
| super().__init__(shape, vertices, topology, sub_ents) | ||||||||||
|
|
||||||||||
| def compute_normal(self, facet_i, cell=None): | ||||||||||
| """Returns the unit normal vector to facet i of codimension 1.""" | ||||||||||
|
|
@@ -528,7 +545,8 @@ def make_points(self, dim, entity_id, order, variant=None, interior=1): | |||||||||
| facet of dimension dim. Order indicates how many points to | ||||||||||
| include in each direction.""" | ||||||||||
| if dim == 0: | ||||||||||
| return (self.get_vertices()[entity_id], ) | ||||||||||
| return (self.get_vertices()[self.get_topology()[dim][entity_id][0]],) | ||||||||||
| # return (self.get_vertices()[entity_id], ) | ||||||||||
|
Comment on lines
+548
to
+549
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| elif 0 < dim <= self.get_spatial_dimension(): | ||||||||||
| entity_verts = \ | ||||||||||
| self.get_vertices_of_subcomplex( | ||||||||||
|
|
@@ -1144,7 +1162,7 @@ def compute_normal(self, i): | |||||||||
| class TensorProductCell(Cell): | ||||||||||
| """A cell that is the product of FIAT cells.""" | ||||||||||
|
|
||||||||||
| def __init__(self, *cells): | ||||||||||
| def __init__(self, *cells, sub_entities=None): | ||||||||||
| # Vertices | ||||||||||
| vertices = tuple(tuple(chain(*coords)) | ||||||||||
| for coords in product(*[cell.get_vertices() | ||||||||||
|
|
@@ -1167,7 +1185,7 @@ def __init__(self, *cells): | |||||||||
| topology[dim] = dict(enumerate(topology[dim][key] | ||||||||||
| for key in sorted(topology[dim]))) | ||||||||||
|
|
||||||||||
| super().__init__(TENSORPRODUCT, vertices, topology) | ||||||||||
| super().__init__(TENSORPRODUCT, vertices, topology, sub_entities) | ||||||||||
| self.cells = tuple(cells) | ||||||||||
|
|
||||||||||
| def __repr__(self): | ||||||||||
|
|
@@ -1317,10 +1335,14 @@ def compare(self, op, other): | |||||||||
| This is done dimension by dimension.""" | ||||||||||
| if hasattr(other, "product"): | ||||||||||
| other = other.product | ||||||||||
| if isinstance(other, type(self)): | ||||||||||
| if isinstance(other, TensorProductCell): | ||||||||||
| return all(op(a, b) for a, b in zip(self.cells, other.cells)) | ||||||||||
| else: | ||||||||||
| return op(self, other) | ||||||||||
| if op == operator.gt or op == operator.lt or operator.ne: | ||||||||||
| return not op(other, self) | ||||||||||
| if op == operator.ge or op == operator.le: | ||||||||||
| return not op(other, self) or operator.eq(self, other) | ||||||||||
| raise ValueError("Unknown operator in cell comparison") | ||||||||||
|
|
||||||||||
| def __gt__(self, other): | ||||||||||
| return self.compare(operator.gt, other) | ||||||||||
|
|
@@ -1410,15 +1432,15 @@ def is_macrocell(self): | |||||||||
| class Hypercube(Cell): | ||||||||||
| """Abstract class for a reference hypercube""" | ||||||||||
|
|
||||||||||
| def __init__(self, dimension, product): | ||||||||||
| def __init__(self, dimension, product, sub_entities=None): | ||||||||||
| self.dimension = dimension | ||||||||||
| self.shape = hypercube_shapes[dimension] | ||||||||||
|
|
||||||||||
| pt = product.get_topology() | ||||||||||
| verts = product.get_vertices() | ||||||||||
| topology = flatten_entities(pt) | ||||||||||
|
|
||||||||||
| super().__init__(self.shape, verts, topology) | ||||||||||
| super().__init__(self.shape, verts, topology, sub_entities) | ||||||||||
|
|
||||||||||
| self.product = product | ||||||||||
| self.unflattening_map = compute_unflattening_map(pt) | ||||||||||
|
|
@@ -1845,3 +1867,10 @@ def max_complex(complexes): | |||||||||
| return max_cell | ||||||||||
| else: | ||||||||||
| raise ValueError("Cannot find the maximal complex") | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def cell_to_simplex(cell): | ||||||||||
| if cell.is_simplex(): | ||||||||||
| return cell | ||||||||||
| else: | ||||||||||
| return ufc_simplex(cell.get_dimension()) | ||||||||||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.