Skip to content
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

Simplify mesh creation interface and algorithms #2954

Merged
merged 92 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
d3aef55
Start simpplification
garth-wells Jan 1, 2024
2ff20f6
More simplifications
garth-wells Jan 1, 2024
1760a4d
Topology simplifications
garth-wells Jan 1, 2024
aa8b294
Simplifications
garth-wells Jan 2, 2024
cea2ad2
Doc fix
garth-wells Jan 2, 2024
9e226be
Small fix
garth-wells Jan 2, 2024
877ed2e
Simplification
garth-wells Jan 2, 2024
d820888
Simplifications
garth-wells Jan 2, 2024
241d7a6
Simplify
garth-wells Jan 2, 2024
a8051f1
Simplify
garth-wells Jan 2, 2024
40972ea
More simplifications
garth-wells Jan 2, 2024
ee8d4f5
Simplifications
garth-wells Jan 2, 2024
2e669ba
Remove untested demo
garth-wells Jan 2, 2024
149ff59
Keep simplifying
garth-wells Jan 2, 2024
40830e5
Python interface updates
garth-wells Jan 2, 2024
8a1299e
Undo change
garth-wells Jan 2, 2024
8523a9d
Merge remote-tracking branch 'origin/main' into garth/mesh-simplifica…
garth-wells Jan 2, 2024
d8c8ecf
Small update
garth-wells Jan 2, 2024
b5855b7
Simplifications
garth-wells Jan 2, 2024
1eae4f2
More small changes
garth-wells Jan 2, 2024
2d6834e
Simplify
garth-wells Jan 2, 2024
72784ce
Undo change
garth-wells Jan 2, 2024
3320cf9
Add assertions
garth-wells Jan 2, 2024
80b0103
Remove function arg
garth-wells Jan 2, 2024
ba51dd9
Flatten more data structures
garth-wells Jan 2, 2024
5d7d72d
Flatten data structures
garth-wells Jan 2, 2024
e7f8ccb
Simplify
garth-wells Jan 2, 2024
5aa0a36
Small fixes
garth-wells Jan 2, 2024
c508d1c
Fix
garth-wells Jan 2, 2024
b73df1e
Simplify type
garth-wells Jan 2, 2024
fcb576f
Updates
garth-wells Jan 3, 2024
fcca206
Updates
garth-wells Jan 3, 2024
7b6319f
Merge branch 'main' into garth/mesh-simplifications-4
garth-wells Jan 3, 2024
d65c5b5
Tidy up
garth-wells Jan 3, 2024
ca238b8
Work on creating meshes from Basix element
garth-wells Jan 3, 2024
4b32bca
Support different domain types
garth-wells Jan 3, 2024
5be7c27
Mesh creation updates
garth-wells Jan 3, 2024
075b28d
mypy updates
garth-wells Jan 3, 2024
0e817a3
Remove some assertions
garth-wells Jan 3, 2024
d829ee0
Disable some mypy
garth-wells Jan 3, 2024
a5e4099
Flake8 fix
garth-wells Jan 3, 2024
a9b60e9
More mypy ignores
garth-wells Jan 3, 2024
9d8e10a
Type improvements
garth-wells Jan 3, 2024
4fc8d7d
Merge remote-tracking branch 'origin/main' into garth/pymesh-domains
garth-wells Jan 4, 2024
02026d7
Revert
garth-wells Jan 4, 2024
3988e13
Updates for cmap type
garth-wells Jan 4, 2024
f4cb965
flake8 fix
garth-wells Jan 4, 2024
b23052e
Type hint improvements
garth-wells Jan 4, 2024
e49bf88
Merge branch 'main' into garth/pymesh-domains
mscroggs Jan 4, 2024
d78b149
flake8 fix
garth-wells Jan 4, 2024
18de24a
Merge branch 'garth/pymesh-domains' of github.com:FEniCS/dolfinx into…
garth-wells Jan 4, 2024
13cd286
dtype fixes
garth-wells Jan 4, 2024
631cdbd
Type updates
garth-wells Jan 4, 2024
5e95d0a
Simplify demo
garth-wells Jan 4, 2024
4723111
More mypy updates
garth-wells Jan 4, 2024
b43f908
Update Basix branch
garth-wells Jan 4, 2024
9b65292
Switch Basix branch
garth-wells Jan 4, 2024
b77fe0c
Fix dtype for gmsh
garth-wells Jan 4, 2024
14a743e
Another fix
garth-wells Jan 4, 2024
55c7885
Type updates
garth-wells Jan 4, 2024
fb08d1f
Type updates
garth-wells Jan 4, 2024
e15d4b2
Type updates
garth-wells Jan 4, 2024
97caf03
More updates
garth-wells Jan 4, 2024
4eec665
Tol updates
garth-wells Jan 4, 2024
ed0a2aa
More updates
garth-wells Jan 4, 2024
82df01b
Fix IO test
garth-wells Jan 4, 2024
15991e0
Revert Basix branch
garth-wells Jan 4, 2024
539e59c
Tidy up
garth-wells Jan 4, 2024
0e26bcf
Type fix
garth-wells Jan 5, 2024
0539552
Merge branch 'garth/pymesh-domains' of https://github.com/FEniCS/dolf…
garth-wells Jan 5, 2024
5166295
Enable test
garth-wells Jan 5, 2024
f23ea8c
Improve type handling
garth-wells Jan 5, 2024
24e68a4
Simplifications
garth-wells Jan 5, 2024
e32b0f4
Tidy up
garth-wells Jan 5, 2024
645670c
Improve test
garth-wells Jan 5, 2024
2495bc2
Handle scalar type in create_mesh
garth-wells Jan 5, 2024
842ce23
Update type hints
garth-wells Jan 5, 2024
6a73e51
Add comment
garth-wells Jan 5, 2024
2edbf75
Uncomment test
garth-wells Jan 5, 2024
cefd38c
Simplifications
garth-wells Jan 5, 2024
3d05a75
Type improvements
garth-wells Jan 5, 2024
f29dcb6
Simplification
garth-wells Jan 5, 2024
e1b1351
Merge branch 'main' into garth/mesh-simplifications-4
garth-wells Jan 5, 2024
9d8a6fa
Merge branch 'garth/pymesh-domains' into garth/mesh-simplifications-4
garth-wells Jan 5, 2024
dce1ed4
Merge remote-tracking branch 'origin/main' into garth/mesh-simplifica…
garth-wells Jan 5, 2024
3fc8f7c
Fix merge
garth-wells Jan 5, 2024
14c2496
Fix formatting
garth-wells Jan 5, 2024
e66f33e
Test update
garth-wells Jan 5, 2024
bad39ad
Cast mesh data if required
garth-wells Jan 5, 2024
9fcd6c2
Merge branch 'main' into garth/mesh-simplifications-4
garth-wells Jan 5, 2024
a4097c6
Test update
garth-wells Jan 5, 2024
a40a93e
Merge branch 'garth/mesh-simplifications-4' of github.com:FEniCS/dolf…
garth-wells Jan 5, 2024
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
2 changes: 1 addition & 1 deletion cpp/demo/hyperelasticity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ int main(int argc, char* argv[])
// stress.
constexpr auto family = basix::element::family::P;
const auto cell_type
= mesh::cell_type_to_basix_type(mesh->topology()->cell_types()[0]);
= mesh::cell_type_to_basix_type(mesh->topology()->cell_type());
constexpr int k = 0;
constexpr bool discontinuous = true;

Expand Down
4 changes: 2 additions & 2 deletions cpp/demo/interpolation_different_meshes/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ int main(int argc, char* argv[])
mesh::CellType::hexahedron));

basix::FiniteElement element_tet = basix::element::create_lagrange<double>(
mesh::cell_type_to_basix_type(mesh_tet->topology()->cell_types()[0]), 1,
mesh::cell_type_to_basix_type(mesh_tet->topology()->cell_type()), 1,
basix::element::lagrange_variant::equispaced, false);
auto V_tet = std::make_shared<fem::FunctionSpace<double>>(
fem::create_functionspace(mesh_tet, element_tet,
std::vector<std::size_t>{3}));

basix::FiniteElement element_hex = basix::element::create_lagrange<double>(
mesh::cell_type_to_basix_type(mesh_hex->topology()->cell_types()[0]), 2,
mesh::cell_type_to_basix_type(mesh_hex->topology()->cell_type()), 2,
basix::element::lagrange_variant::equispaced, false);
auto V_hex = std::make_shared<fem::FunctionSpace<double>>(
fem::create_functionspace(mesh_hex, element_hex,
Expand Down
40 changes: 0 additions & 40 deletions cpp/demo/mixed_topology/CMakeLists.txt

This file was deleted.

17 changes: 5 additions & 12 deletions cpp/dolfinx/fem/DirichletBC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,11 @@ std::vector<std::int32_t> fem::locate_dofs_topological(
const mesh::Topology& topology, const DofMap& dofmap, int dim,
std::span<const std::int32_t> entities, bool remote)
{
auto cell_types = topology.cell_types();
if (cell_types.size() > 1)
{
throw std::runtime_error("Multiple cell types in DirichletBC");
}
mesh::CellType cell_type = topology.cell_type();

// Prepare an element - local dof layout for dofs on entities of the
// entity_dim
const int num_cell_entities = mesh::cell_num_entities(cell_types.back(), dim);
const int num_cell_entities = mesh::cell_num_entities(cell_type, dim);
std::vector<std::vector<int>> entity_dofs;
for (int i = 0; i < num_cell_entities; ++i)
{
Expand Down Expand Up @@ -306,13 +302,10 @@ std::array<std::vector<std::int32_t>, 2> fem::locate_dofs_topological(
// Check that dof layouts are the same
assert(dofmap0.element_dof_layout() == dofmap1.element_dof_layout());

auto cell_types = topology.cell_types();
if (cell_types.size() > 1)
{
throw std::runtime_error("Multiple cell types in DirichletBC");
}
mesh::CellType cell_type = topology.cell_type();

// Build vector of local dofs for each cell entity
const int num_cell_entities = mesh::cell_num_entities(cell_types.back(), dim);
const int num_cell_entities = mesh::cell_num_entities(cell_type, dim);
std::vector<std::vector<int>> entity_dofs;
for (int i = 0; i < num_cell_entities; ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions cpp/dolfinx/fem/DofMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ std::pair<DofMap, std::vector<std::int32_t>> DofMap::collapse(
// Create new element dof layout and reset parent
ElementDofLayout collapsed_dof_layout = layout.copy();

auto [_index_map, bs, dofmap] = build_dofmap_data(
comm, topology, {collapsed_dof_layout}, reorder_fn);
auto [_index_map, bs, dofmap]
= build_dofmap_data(comm, topology, collapsed_dof_layout, reorder_fn);
auto index_map
= std::make_shared<common::IndexMap>(std::move(_index_map));
return DofMap(layout, index_map, bs, std::move(dofmap), bs);
Expand Down
5 changes: 2 additions & 3 deletions cpp/dolfinx/fem/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ class Expression
auto x_dofmap = mesh.geometry().dofmap();

// Get geometry data
auto cmaps = mesh.geometry().cmaps();
assert(cmaps.size() == 1);
auto& cmap = mesh.geometry().cmap();

const std::size_t num_dofs_g = cmaps.back().dim();
const std::size_t num_dofs_g = cmap.dim();
auto x_g = mesh.geometry().x();

// Create data structures used in evaluation
Expand Down
7 changes: 1 addition & 6 deletions cpp/dolfinx/fem/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,12 +415,7 @@ class Function
auto map = mesh->topology()->index_map(tdim);

// Get coordinate map
if (mesh->geometry().cmaps().size() > 1)
{
throw std::runtime_error(
"Function with multiple geometry maps not implemented.");
}
const CoordinateElement<geometry_type>& cmap = mesh->geometry().cmaps()[0];
const CoordinateElement<geometry_type>& cmap = mesh->geometry().cmap();

// Get geometry data
auto x_dofmap = mesh->geometry().dofmap();
Expand Down
4 changes: 1 addition & 3 deletions cpp/dolfinx/fem/FunctionSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,7 @@ class FunctionSpace
const auto [X, Xshape] = _element->interpolation_points();

// Get coordinate map
if (_mesh->geometry().cmaps().size() > 1)
throw std::runtime_error("Mixed topology not supported");
const CoordinateElement<geometry_type>& cmap = _mesh->geometry().cmaps()[0];
const CoordinateElement<geometry_type>& cmap = _mesh->geometry().cmap();

// Prepare cell geometry
auto x_dofmap = _mesh->geometry().dofmap();
Expand Down
18 changes: 8 additions & 10 deletions cpp/dolfinx/fem/assemble_matrix_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ void assemble_matrix(
= coefficients.at({IntegralType::exterior_facet, i});
impl::assemble_exterior_facets(
mat_set, x_dofmap, x, a.domain(IntegralType::exterior_facet, i),
pre_dof_transform, dofs0, bs0, post_dof_transform, dofs1, bs1, bc0,
bc1, fn, coeffs, cstride, constants, cell_info);
pre_dof_transform, dofs0, bs0, post_dof_transform, dofs1, bs1, bc0, bc1,
fn, coeffs, cstride, constants, cell_info);
}

if (a.num_integrals(IntegralType::interior_facet) > 0)
Expand All @@ -443,11 +443,9 @@ void assemble_matrix(
else
get_perm = [](std::size_t) { return 0; };

auto cell_types = mesh->topology()->cell_types();
if (cell_types.size() > 1)
throw std::runtime_error("Multiple cell types in the assembler.");
int num_cell_facets = mesh::cell_num_entities(cell_types.back(),
mesh->topology()->dim() - 1);
mesh::CellType cell_type = mesh->topology()->cell_type();
int num_cell_facets
= mesh::cell_num_entities(cell_type, mesh->topology()->dim() - 1);
const std::vector<int> c_offsets = a.coefficient_offsets();
for (int i : a.integral_ids(IntegralType::interior_facet))
{
Expand All @@ -457,9 +455,9 @@ void assemble_matrix(
= coefficients.at({IntegralType::interior_facet, i});
impl::assemble_interior_facets(
mat_set, x_dofmap, x, num_cell_facets,
a.domain(IntegralType::interior_facet, i), pre_dof_transform, *dofmap0,
bs0, post_dof_transform, *dofmap1, bs1, bc0, bc1, fn, coeffs,
cstride, c_offsets, constants, cell_info, get_perm);
a.domain(IntegralType::interior_facet, i), pre_dof_transform,
*dofmap0, bs0, post_dof_transform, *dofmap1, bs1, bc0, bc1, fn,
coeffs, cstride, c_offsets, constants, cell_info, get_perm);
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions cpp/dolfinx/fem/assemble_scalar_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,9 @@ T assemble_scalar(
mesh->topology_mutable()->create_entity_permutations();
const std::vector<std::uint8_t>& perms
= mesh->topology()->get_facet_permutations();
auto cell_types = mesh->topology()->cell_types();
if (cell_types.size() > 1)
throw std::runtime_error("Multiple cell types in the assembler");
int num_cell_facets = mesh::cell_num_entities(cell_types.back(),
mesh->topology()->dim() - 1);
mesh::CellType cell_type = mesh->topology()->cell_type();
int num_cell_facets
= mesh::cell_num_entities(cell_type, mesh->topology()->dim() - 1);
const std::vector<int> c_offsets = M.coefficient_offsets();
for (int i : M.integral_ids(IntegralType::interior_facet))
{
Expand Down
16 changes: 6 additions & 10 deletions cpp/dolfinx/fem/assemble_vector_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,11 +841,9 @@ void lift_bc(std::span<T> b, const Form<T, U>& a, mdspan2_t x_dofmap,
else
get_perm = [](std::size_t) { return 0; };

auto cell_types = mesh->topology()->cell_types();
if (cell_types.size() > 1)
throw std::runtime_error("Multiple cell types in the assembler");
int num_cell_facets = mesh::cell_num_entities(cell_types.back(),
mesh->topology()->dim() - 1);
mesh::CellType cell_type = mesh->topology()->cell_type();
int num_cell_facets
= mesh::cell_num_entities(cell_type, mesh->topology()->dim() - 1);
for (int i : a.integral_ids(IntegralType::interior_facet))
{
auto kernel = a.kernel(IntegralType::interior_facet, i);
Expand Down Expand Up @@ -1049,11 +1047,9 @@ void assemble_vector(
else
get_perm = [](std::size_t) { return 0; };

auto cell_types = mesh->topology()->cell_types();
if (cell_types.size() > 1)
throw std::runtime_error("Multiple cell types in the assembler");
int num_cell_facets = mesh::cell_num_entities(cell_types.back(),
mesh->topology()->dim() - 1);
mesh::CellType cell_type = mesh->topology()->cell_type();
int num_cell_facets
= mesh::cell_num_entities(cell_type, mesh->topology()->dim() - 1);
for (int i : L.integral_ids(IntegralType::interior_facet))
{
auto fn = L.kernel(IntegralType::interior_facet, i);
Expand Down
5 changes: 1 addition & 4 deletions cpp/dolfinx/fem/discreteoperators.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ void interpolation_matrix(const FunctionSpace<U>& V0,
const std::size_t value_size1 = e1->value_size() / bs1;

// Get geometry data
auto cmaps = mesh->geometry().cmaps();
assert(cmaps.size() == 1);

const CoordinateElement<U>& cmap = cmaps.back();
const CoordinateElement<U>& cmap = mesh->geometry().cmap();
auto x_dofmap = mesh->geometry().dofmap();
const std::size_t num_dofs_g = cmap.dim();
std::span<const U> x_g = mesh->geometry().x();
Expand Down
Loading
Loading