-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
introduce MixedMesh class #303
Open
ksagiyam
wants to merge
1
commit into
FEniCS:main
Choose a base branch
from
firedrakeproject:ksagiyam/introduce_mixed_map_0
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.
Open
Changes from all commits
Commits
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 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,81 @@ | ||
from ufl import ( | ||
CellVolume, | ||
Coefficient, | ||
FacetArea, | ||
FacetNormal, | ||
FunctionSpace, | ||
Measure, | ||
Mesh, | ||
MixedMesh, | ||
SpatialCoordinate, | ||
TestFunction, | ||
TrialFunction, | ||
grad, | ||
inner, | ||
split, | ||
triangle, | ||
) | ||
from ufl.algorithms import compute_form_data | ||
from ufl.domain import extract_domains | ||
from ufl.finiteelement import FiniteElement, MixedElement | ||
from ufl.pullback import contravariant_piola, identity_pullback | ||
from ufl.sobolevspace import H1, L2, HDiv | ||
|
||
|
||
def test_mixed_function_space_with_mixed_mesh_basic(): | ||
cell = triangle | ||
elem0 = FiniteElement("Lagrange", cell, 1, (), identity_pullback, H1) | ||
elem1 = FiniteElement("Brezzi-Douglas-Marini", cell, 1, (2,), contravariant_piola, HDiv) | ||
elem2 = FiniteElement("Discontinuous Lagrange", cell, 0, (), identity_pullback, L2) | ||
elem = MixedElement([elem0, elem1, elem2]) | ||
mesh0 = Mesh(FiniteElement("Lagrange", cell, 1, (2,), identity_pullback, H1), ufl_id=100) | ||
mesh1 = Mesh(FiniteElement("Lagrange", cell, 1, (2,), identity_pullback, H1), ufl_id=101) | ||
mesh2 = Mesh(FiniteElement("Lagrange", cell, 1, (2,), identity_pullback, H1), ufl_id=102) | ||
domain = MixedMesh([mesh0, mesh1, mesh2]) | ||
V = FunctionSpace(domain, elem) | ||
u = TrialFunction(V) | ||
v = TestFunction(V) | ||
f = Coefficient(V, count=1000) | ||
g = Coefficient(V, count=2000) | ||
u0, u1, u2 = split(u) | ||
v0, v1, v2 = split(v) | ||
f0, f1, f2 = split(f) | ||
g0, g1, g2 = split(g) | ||
dx1 = Measure("dx", mesh1) | ||
x = SpatialCoordinate(mesh1) | ||
form = x[1] * f0 * inner(grad(u0), v1) * dx1(999) | ||
fd = compute_form_data( | ||
form, | ||
do_apply_function_pullbacks=True, | ||
do_apply_integral_scaling=True, | ||
do_apply_geometry_lowering=True, | ||
preserve_geometry_types=(CellVolume, FacetArea), | ||
do_apply_restrictions=True, | ||
do_estimate_degrees=True, | ||
complex_mode=False, | ||
) | ||
(id0,) = fd.integral_data | ||
assert fd.preprocessed_form.arguments() == (v, u) | ||
assert fd.reduced_coefficients == [f] | ||
assert form.coefficients()[fd.original_coefficient_positions[0]] is f | ||
assert id0.domain is mesh1 | ||
assert id0.integral_type == "cell" | ||
assert id0.subdomain_id == (999,) | ||
assert fd.original_form.domain_numbering()[id0.domain] == 0 | ||
assert id0.integral_coefficients == set([f]) | ||
assert id0.enabled_coefficients == [True] | ||
|
||
|
||
def test_mixed_function_space_with_mixed_mesh_signature(): | ||
cell = triangle | ||
mesh0 = Mesh(FiniteElement("Lagrange", cell, 1, (2,), identity_pullback, H1), ufl_id=100) | ||
mesh1 = Mesh(FiniteElement("Lagrange", cell, 1, (2,), identity_pullback, H1), ufl_id=101) | ||
dx0 = Measure("dx", mesh0) | ||
dx1 = Measure("dx", mesh1) | ||
n0 = FacetNormal(mesh0) | ||
n1 = FacetNormal(mesh1) | ||
form_a = inner(n1, n1) * dx0(999) | ||
form_b = inner(n0, n0) * dx1(999) | ||
assert form_a.signature() == form_b.signature() | ||
assert extract_domains(form_a) == (mesh0, mesh1) | ||
assert extract_domains(form_b) == (mesh1, mesh0) |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What else com
gq._domain
be? is this relying on the deprecated definition that adomain
can be defined just through aufl.Cell
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It checks if
gq._domain
isMesh
and notMixedMesh
.