From a7af3140d15f3eb73dddb410dd6ea3652707c184 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 10:00:55 +0000 Subject: [PATCH 01/11] Mesh refinement interface improvements --- cpp/dolfinx/refinement/plaza.cpp | 29 +++++----- cpp/dolfinx/refinement/plaza.h | 54 +++++++++--------- cpp/dolfinx/refinement/refine.cpp | 6 +- cpp/dolfinx/refinement/refine.h | 27 ++++----- python/dolfinx/mesh.py | 50 +++++++++++++---- python/dolfinx/wrappers/refinement.cpp | 71 ++++++++++++++---------- python/test/unit/mesh/test_refinement.py | 27 +++++---- 7 files changed, 147 insertions(+), 117 deletions(-) diff --git a/cpp/dolfinx/refinement/plaza.cpp b/cpp/dolfinx/refinement/plaza.cpp index d85a2fce7d0..6025e6c0f69 100644 --- a/cpp/dolfinx/refinement/plaza.cpp +++ b/cpp/dolfinx/refinement/plaza.cpp @@ -458,19 +458,18 @@ compute_refinement(MPI_Comm neighbor_comm, const mesh::Mesh& mesh, const std::vector& long_edge, const std::vector& edge_ratio_ok, - plaza::RefinementOptions options) + plaza::Option option) { const std::int32_t tdim = mesh.topology().dim(); const std::int32_t num_cell_edges = tdim * 3 - 3; const std::int32_t num_cell_vertices = tdim + 1; - bool compute_facets - = (options == plaza::RefinementOptions::parent_facet - or options == plaza::RefinementOptions::parent_cell_and_facet); + bool compute_facets = (option == plaza::Option::parent_facet + or option == plaza::Option::parent_cell_and_facet); bool compute_parent_cell - = (options == plaza::RefinementOptions::parent_cell - or options == plaza::RefinementOptions::parent_cell_and_facet); + = (option == plaza::Option::parent_cell + or option == plaza::Option::parent_cell_and_facet); // Make new vertices in parallel const auto [new_vertex_map, new_vertex_coords, xshape] @@ -610,12 +609,11 @@ compute_refinement(MPI_Comm neighbor_comm, //----------------------------------------------------------------------------- std::tuple, std::vector> -plaza::refine(const mesh::Mesh& mesh, bool redistribute, - RefinementOptions options) +plaza::refine(const mesh::Mesh& mesh, bool redistribute, Option option) { auto [cell_adj, new_coords, xshape, parent_cell, parent_facet] - = compute_refinement_data(mesh, options); + = compute_refinement_data(mesh, option); if (dolfinx::MPI::size(mesh.comm()) == 1) { @@ -645,11 +643,11 @@ plaza::refine(const mesh::Mesh& mesh, bool redistribute, //----------------------------------------------------------------------------- std::tuple, std::vector> plaza::refine(const mesh::Mesh& mesh, std::span edges, - bool redistribute, RefinementOptions options) + bool redistribute, Option option) { auto [cell_adj, new_vertex_coords, xshape, parent_cell, parent_facet] - = compute_refinement_data(mesh, edges, options); + = compute_refinement_data(mesh, edges, option); if (dolfinx::MPI::size(mesh.comm()) == 1) { @@ -680,8 +678,7 @@ plaza::refine(const mesh::Mesh& mesh, std::span edges, std::tuple, std::vector, std::array, std::vector, std::vector> -plaza::compute_refinement_data(const mesh::Mesh& mesh, - RefinementOptions options) +plaza::compute_refinement_data(const mesh::Mesh& mesh, Option option) { if (mesh.topology().cell_type() != mesh::CellType::triangle @@ -725,7 +722,7 @@ plaza::compute_refinement_data(const mesh::Mesh& mesh, = compute_refinement(comm, std::vector( map_e->size_local() + map_e->num_ghosts(), true), - edge_ranks, mesh, long_edge, edge_ratio_ok, options); + edge_ranks, mesh, long_edge, edge_ratio_ok, option); MPI_Comm_free(&comm); return {std::move(cell_adj), std::move(new_vertex_coords), xshape, @@ -737,7 +734,7 @@ std::tuple, std::vector, std::vector> plaza::compute_refinement_data(const mesh::Mesh& mesh, std::span edges, - RefinementOptions options) + Option option) { if (mesh.topology().cell_type() != mesh::CellType::triangle and mesh.topology().cell_type() != mesh::CellType::tetrahedron) @@ -801,7 +798,7 @@ plaza::compute_refinement_data(const mesh::Mesh& mesh, auto [cell_adj, new_vertex_coords, xshape, parent_cell, parent_facet] = compute_refinement(comm, marked_edges, edge_ranks, mesh, long_edge, - edge_ratio_ok, options); + edge_ratio_ok, option); MPI_Comm_free(&comm); return {std::move(cell_adj), std::move(new_vertex_coords), xshape, diff --git a/cpp/dolfinx/refinement/plaza.h b/cpp/dolfinx/refinement/plaza.h index c106189b909..696ad66c13f 100644 --- a/cpp/dolfinx/refinement/plaza.h +++ b/cpp/dolfinx/refinement/plaza.h @@ -29,12 +29,12 @@ namespace dolfinx::refinement namespace plaza { -/// Selection of options when refining a Mesh. `parent_cell` will output a list -/// containing the local parent cell index for each new cell, `parent_facet` -/// will output a list of the cell-local facet indices in the parent cell of -/// each facet in each new cell (or -1 if no match). `parent_cell_and_facet` -/// will output both datasets. -enum class RefinementOptions : int +/// Selection of options when refining a Mesh. `parent_cell` will output +/// a list containing the local parent cell index for each new cell, +/// `parent_facet` will output a list of the cell-local facet indices in +/// the parent cell of each facet in each new cell (or -1 if no match). +/// `parent_cell_and_facet` will output both datasets. +enum class Option : int { none = 0, parent_cell = 1, @@ -42,65 +42,61 @@ enum class RefinementOptions : int parent_cell_and_facet = 3 }; -/// Uniform refine, optionally redistributing and optionally -/// calculating the parent-child relationships, selected by `RefinementOptions`. +/// @brief Uniform refine, optionally redistributing and optionally +/// calculating the parent-child relationships`. /// /// @param[in] mesh Input mesh to be refined /// @param[in] redistribute Flag to call the mesh partitioner to /// redistribute after refinement -/// @param[in] options RefinementOptions enum to choose the computation of -/// parent facets, parent cells. If an option is unselected, an empty list is -/// returned. -/// @return New Mesh and optional parent cell index, parent facet indices +/// @param[in] option Control the computation of parent facets, parent +/// cells. If an option is unselected, an empty list is returned. +/// @return Refined mesh and optional parent cell index, parent facet +/// indices std::tuple, std::vector> -refine(const mesh::Mesh& mesh, bool redistribute, RefinementOptions options); +refine(const mesh::Mesh& mesh, bool redistribute, Option option); -/// Refine with markers, optionally redistributing, and optionally -/// calculating the parent-child relationships, selected by `RefinementOptions`. +/// @brief Refine with markers, optionally redistributing, and +/// optionally calculating the parent-child relationships. /// /// @param[in] mesh Input mesh to be refined /// @param[in] edges Indices of the edges that should be split by this /// refinement /// @param[in] redistribute Flag to call the Mesh Partitioner to /// redistribute after refinement -/// @param[in] options RefinementOptions enum to choose the computation of -/// parent facets, parent cells. If an option is unselected, an empty list is -/// returned. +/// @param[in] option Control the computation of parent facets, parent +/// cells. If an option is unselected, an empty list is returned. /// @return New Mesh and optional parent cell index, parent facet indices std::tuple, std::vector> refine(const mesh::Mesh& mesh, std::span edges, - bool redistribute, RefinementOptions options); + bool redistribute, Option option); -/// Refine mesh returning new mesh data. +/// @brief Refine mesh returning new mesh data. /// /// @param[in] mesh Input mesh to be refined -/// @param[in] options RefinementOptions enum to choose the computation of -/// parent facets, parent cells. If an option is unselected, an empty list is -/// returned. +/// @param[in] option Control computation of parent facets and parent +/// cells. If an option is unselected, an empty list is returned. /// @return New mesh data: cell topology, vertex coordinates, vertex /// coordinates shape, and optional parent cell index, and parent facet /// indices. std::tuple, std::vector, std::array, std::vector, std::vector> -compute_refinement_data(const mesh::Mesh& mesh, RefinementOptions options); +compute_refinement_data(const mesh::Mesh& mesh, Option option); /// Refine with markers returning new mesh data. /// /// @param[in] mesh Input mesh to be refined /// @param[in] edges Indices of the edges that should be split by this /// refinement -/// @param[in] options RefinementOptions enum to choose the computation of -/// parent facets, parent cells. If an option is unselected, an empty list is -/// returned. +/// @param[in] option Control the computation of parent facets, parent +/// cells. If an option is unselected, an empty list is returned. /// @return New mesh data: cell topology, vertex coordinates and parent /// cell index, and stored parent facet indices (if requested). std::tuple, std::vector, std::array, std::vector, std::vector> compute_refinement_data(const mesh::Mesh& mesh, - std::span edges, - RefinementOptions options); + std::span edges, Option option); } // namespace plaza } // namespace dolfinx::refinement diff --git a/cpp/dolfinx/refinement/refine.cpp b/cpp/dolfinx/refinement/refine.cpp index 05a4c323591..f81f989b43e 100644 --- a/cpp/dolfinx/refinement/refine.cpp +++ b/cpp/dolfinx/refinement/refine.cpp @@ -22,7 +22,7 @@ mesh::Mesh refinement::refine(const mesh::Mesh& mesh, bool redistribute) } auto [refined_mesh, parent_cell, parent_facet] - = plaza::refine(mesh, redistribute, plaza::RefinementOptions::none); + = plaza::refine(mesh, redistribute, plaza::Option::none); // Report the number of refined cells const int D = mesh.topology().dim(); @@ -45,8 +45,8 @@ mesh::Mesh refinement::refine(const mesh::Mesh& mesh, throw std::runtime_error("Refinement only defined for simplices"); } - auto [refined_mesh, parent_cell, parent_facet] = plaza::refine( - mesh, edges, redistribute, plaza::RefinementOptions::none); + auto [refined_mesh, parent_cell, parent_facet] + = plaza::refine(mesh, edges, redistribute, plaza::Option::none); // Report the number of refined cells const int D = mesh.topology().dim(); diff --git a/cpp/dolfinx/refinement/refine.h b/cpp/dolfinx/refinement/refine.h index 99db84a89e8..a4751ab0c87 100644 --- a/cpp/dolfinx/refinement/refine.h +++ b/cpp/dolfinx/refinement/refine.h @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2021 Garth N. Wells +// Copyright (C) 2010-2023 Garth N. Wells // // This file is part of DOLFINx (https://www.fenicsproject.org) // @@ -8,7 +8,6 @@ #include #include -#include namespace dolfinx::mesh { @@ -17,26 +16,24 @@ class Mesh; namespace dolfinx::refinement { - -/// Create a uniformly refined mesh +/// @brief Create a uniformly refined mesh. /// -/// @param[in] mesh The mesh from which to build a refined Mesh -/// @param[in] redistribute Optional argument to redistribute the -/// refined mesh if mesh is a distributed mesh. -/// @return A refined mesh +/// @param[in] mesh Mesh to create a new, refined mesh from +/// @param[in] redistribute If `true` refined mesh is re-partitioned +/// across MPI ranks. +/// @return Refined mesh mesh::Mesh refine(const mesh::Mesh& mesh, bool redistribute = true); -/// Create a locally refined mesh +/// @brief Create a locally refined mesh. /// -/// @param[in] mesh The mesh from which to build a refined Mesh -/// @param[in] edges Indices of the edges that should be split by this +/// @param[in] mesh Mesh to create a new, refined mesh from. +/// @param[in] edges Indices of the edges that should be split during /// refinement. mesh::compute_incident_entities can be used to compute /// the edges that are incident to other entities, e.g. incident to /// cells. -/// @param[in] redistribute Optional argument to redistribute the -/// refined mesh if mesh is a distributed mesh. -/// @return A locally refined mesh +/// @param[in] redistribute If `true` refined mesh is re-partitioned +/// across MPI ranks. +/// @return Refined mesh. mesh::Mesh refine(const mesh::Mesh& mesh, std::span edges, bool redistribute = true); - } // namespace dolfinx::refinement diff --git a/python/dolfinx/mesh.py b/python/dolfinx/mesh.py index 858a9976b0a..5be0ce29bab 100644 --- a/python/dolfinx/mesh.py +++ b/python/dolfinx/mesh.py @@ -162,27 +162,53 @@ def transfer_cell_meshtag(meshtag: MeshTags, mesh1: Mesh, parent_cell: npt.NDArr def refine(mesh: Mesh, edges: typing.Optional[np.ndarray] = None, redistribute: bool = True) -> Mesh: - """Refine a mesh + """Refine a mesh. Args: - mesh: The mesh from which to build a refined mesh - edges: Optional argument to specify which edges should be refined. If - not supplied uniform refinement is applied. + mesh: Mesh from which to create the refined mesh. + edges: Indices of edges to split during refinement. If `None`, + uniform refinement is uses. redistribute: - Optional argument to redistribute the refined mesh if mesh is a - distributed mesh. + Refined mesh is re-partitioned if `True` Returns: - A refined mesh + Refined mesh + """ if edges is None: - mesh_refined = _cpp.refinement.refine(mesh._cpp_object, redistribute) + mesh1 = _cpp.refinement.refine(mesh._cpp_object, redistribute) else: - mesh_refined = _cpp.refinement.refine(mesh._cpp_object, edges, redistribute) + mesh1 = _cpp.refinement.refine(mesh._cpp_object, edges, redistribute) + element = mesh._ufl_domain.ufl_coordinate_element() + domain = ufl.Mesh(element) + return Mesh(mesh1, domain) + + +def refine_plaza(mesh: Mesh, edges: typing.Optional[np.ndarray] = None, redistribute: bool = True, + option: _cpp.refinement.RefinementOption = _cpp.refinement.RefinementOption.none) -> Mesh: + """Refine a mesh. + + Args: + mesh: Mesh from which to create the refined mesh. + edges: Indices of edges to split during refinement. If `None`, + uniform refinement is uses. + redistribute: + Refined mesh is re-partitioned if `True` + option: + Control computation of the parent-refined mesh data. - coordinate_element = mesh._ufl_domain.ufl_coordinate_element() - domain = ufl.Mesh(coordinate_element) - return Mesh(mesh_refined, domain) + Returns: + Refined mesh, list of parent cell for each refine cell, and list + of parent facets. + + """ + if edges is None: + mesh1, cells, facets = _cpp.refinement.refine_plaza(mesh._cpp_object, redistribute) + else: + mesh1, cells, facets = _cpp.refinement.refine_plaza(mesh._cpp_object, edges, redistribute) + element = mesh._ufl_domain.ufl_coordinate_element() + domain = ufl.Mesh(element) + return Mesh(mesh1, domain), cells, facets def create_mesh(comm: _MPI.Comm, cells: typing.Union[np.ndarray, _cpp.graph.AdjacencyList_int64], diff --git a/python/dolfinx/wrappers/refinement.cpp b/python/dolfinx/wrappers/refinement.cpp index 52546de5658..2c677e8f0fa 100644 --- a/python/dolfinx/wrappers/refinement.cpp +++ b/python/dolfinx/wrappers/refinement.cpp @@ -4,6 +4,7 @@ // // SPDX-License-Identifier: LGPL-3.0-or-later +#include "array.h" #include #include #include @@ -17,31 +18,57 @@ namespace py = pybind11; namespace dolfinx_wrappers { - void refinement(py::module& m) { - - py::enum_(m, - "RefinementOptions") - .value("parent_facet", - dolfinx::refinement::plaza::RefinementOptions::parent_facet) - .value("parent_cell", - dolfinx::refinement::plaza::RefinementOptions::parent_cell) - .value( - "parent_cell_and_facet", - dolfinx::refinement::plaza::RefinementOptions::parent_cell_and_facet); + py::enum_(m, "RefinementOption") + .value("none", dolfinx::refinement::plaza::Option::none) + .value("parent_facet", dolfinx::refinement::plaza::Option::parent_facet) + .value("parent_cell", dolfinx::refinement::plaza::Option::parent_cell) + .value("parent_cell_and_facet", + dolfinx::refinement::plaza::Option::parent_cell_and_facet); // dolfinx::refinement::refine m.def("refine", py::overload_cast( &dolfinx::refinement::refine), py::arg("mesh"), py::arg("redistribute") = true); + m.def( + "refine", + [](const dolfinx::mesh::Mesh& mesh, + const py::array_t& edges, + bool redistribute) + { + assert(edges.ndim() == 1); + return dolfinx::refinement::refine( + mesh, std::span(edges.data(), edges.size()), redistribute); + }, + py::arg("mesh"), py::arg("edges"), py::arg("redistribute") = true); + m.def( + "refine_plaza", + [](const dolfinx::mesh::Mesh& mesh0, bool redistribute, + dolfinx::refinement::plaza::Option option) + { + auto [mesh1, cell, facet] + = dolfinx::refinement::plaza::refine(mesh0, redistribute, option); + return std::tuple{std::move(mesh1), as_pyarray(std::move(cell)), + as_pyarray(std::move(facet))}; + }, + py::arg("mesh"), py::arg("redistribute"), py::arg("option")); + m.def( + "refine_plaza", + [](const dolfinx::mesh::Mesh& mesh0, py::array_t edges, + bool redistribute, dolfinx::refinement::plaza::Option option) + { + assert(edges.ndim() == 1); + auto [mesh1, cell, facet] = dolfinx::refinement::plaza::refine( + mesh0, std::span(edges.data(), edges.size()), + redistribute, option); + return std::tuple{std::move(mesh1), as_pyarray(std::move(cell)), + as_pyarray(std::move(facet))}; + }, + py::arg("mesh"), py::arg("edges"), py::arg("redistribute"), + py::arg("option")); - m.def("plaza_refine_data", - py::overload_cast( - &dolfinx::refinement::plaza::refine), - py::arg("mesh"), py::arg("redistribute"), py::arg("options")); m.def( "transfer_facet_meshtag", [](const dolfinx::mesh::MeshTags& parent_meshtag, @@ -68,18 +95,6 @@ void refinement(py::module& m) }, py::arg("parent_meshtag"), py::arg("refined_mesh"), py::arg("parent_cell")); - - m.def( - "refine", - [](const dolfinx::mesh::Mesh& mesh, - const py::array_t& edges, - bool redistribute) - { - assert(edges.ndim() == 1); - return dolfinx::refinement::refine( - mesh, std::span(edges.data(), edges.size()), redistribute); - }, - py::arg("mesh"), py::arg("edges"), py::arg("redistribute") = true); } } // namespace dolfinx_wrappers diff --git a/python/test/unit/mesh/test_refinement.py b/python/test/unit/mesh/test_refinement.py index c2d1bff450e..8c2e426d591 100644 --- a/python/test/unit/mesh/test_refinement.py +++ b/python/test/unit/mesh/test_refinement.py @@ -6,18 +6,18 @@ import numpy import pytest -from numpy import isclose, logical_and - import ufl -from dolfinx import cpp as _cpp from dolfinx.fem import FunctionSpace, form from dolfinx.fem.petsc import assemble_matrix from dolfinx.mesh import (CellType, DiagonalType, GhostMode, compute_incident_entities, create_unit_cube, create_unit_square, locate_entities, - locate_entities_boundary, meshtags, refine) - + locate_entities_boundary, meshtags, refine, + refine_plaza) from mpi4py import MPI +from numpy import isclose, logical_and + +from dolfinx import cpp as _cpp def test_Refinecreate_unit_square(): @@ -138,10 +138,11 @@ def test_refine_facet_meshtag(tdim): meshtag = meshtags(mesh, tdim - 1, numpy.array(facet_indices, dtype=numpy.int32), numpy.arange(len(facet_indices), dtype=numpy.int32)) - fine_mesh, parent_cell, parent_facet = _cpp.refinement.plaza_refine_data( - mesh._cpp_object, False, _cpp.refinement.RefinementOptions.parent_cell_and_facet) + fine_mesh, parent_cell, parent_facet = refine_plaza( + mesh, False, _cpp.refinement.RefinementOption.parent_cell_and_facet) fine_mesh.topology.create_entities(tdim - 1) - new_meshtag = _cpp.refinement.transfer_facet_meshtag(meshtag._cpp_object, fine_mesh, parent_cell, parent_facet) + new_meshtag = _cpp.refinement.transfer_facet_meshtag( + meshtag._cpp_object, fine_mesh._cpp_object, parent_cell, parent_facet) assert len(new_meshtag.indices) == (tdim * 2 - 2) * len(meshtag.indices) # New tags should be on facets with one cell (i.e. exterior) @@ -154,26 +155,24 @@ def test_refine_facet_meshtag(tdim): facet_indices = numpy.arange(mesh.topology.index_map(tdim - 1).size_local) meshtag = meshtags(mesh, tdim - 1, numpy.array(facet_indices, dtype=numpy.int32), numpy.arange(len(facet_indices), dtype=numpy.int32)) - new_meshtag = _cpp.refinement.transfer_facet_meshtag(meshtag._cpp_object, fine_mesh, parent_cell, parent_facet) + new_meshtag = _cpp.refinement.transfer_facet_meshtag( + meshtag._cpp_object, fine_mesh._cpp_object, parent_cell, parent_facet) assert len(new_meshtag.indices) == (tdim * 2 - 2) * len(meshtag.indices) @pytest.mark.parametrize("tdim", [2, 3]) def test_refine_cell_meshtag(tdim): - if tdim == 3: mesh = create_unit_cube(MPI.COMM_WORLD, 2, 3, 5, CellType.tetrahedron, GhostMode.none) else: mesh = create_unit_square(MPI.COMM_WORLD, 2, 5, CellType.triangle, GhostMode.none) mesh.topology.create_entities(1) - cell_indices = numpy.arange(mesh.topology.index_map(tdim).size_local) meshtag = meshtags(mesh, tdim, numpy.array(cell_indices, dtype=numpy.int32), numpy.arange(len(cell_indices), dtype=numpy.int32)) - fine_mesh, parent_cell, parent_facet = _cpp.refinement.plaza_refine_data( - mesh._cpp_object, False, _cpp.refinement.RefinementOptions.parent_cell_and_facet) - new_meshtag = _cpp.refinement.transfer_cell_meshtag(meshtag._cpp_object, fine_mesh, parent_cell) + fine_mesh, parent_cell, _ = refine_plaza(mesh, False, _cpp.refinement.RefinementOption.parent_cell_and_facet) + new_meshtag = _cpp.refinement.transfer_cell_meshtag(meshtag._cpp_object, fine_mesh._cpp_object, parent_cell) assert sum(new_meshtag.values) == (tdim * 4 - 4) * sum(meshtag.values) assert len(new_meshtag.indices) == (tdim * 4 - 4) * len(meshtag.indices) From 6897ffe05a7ee7a1776341612921b8ca0b0fcaab Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 10:19:47 +0000 Subject: [PATCH 02/11] Improve wrapping --- python/dolfinx/mesh.py | 25 +++++++++++++++++------- python/test/unit/mesh/test_refinement.py | 18 +++++++---------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/python/dolfinx/mesh.py b/python/dolfinx/mesh.py index 5be0ce29bab..74aa4a07d5b 100644 --- a/python/dolfinx/mesh.py +++ b/python/dolfinx/mesh.py @@ -18,6 +18,7 @@ build_dual_graph, cell_dim, create_cell_partitioner, exterior_facet_indices, to_string, to_type) +from dolfinx.cpp.refinement import RefinementOption from mpi4py import MPI as _MPI from dolfinx import cpp as _cpp @@ -144,21 +145,30 @@ def locate_entities_boundary(mesh: Mesh, dim: int, marker: typing.Callable) -> n } -def transfer_cell_meshtag(meshtag: MeshTags, mesh1: Mesh, parent_cell: npt.NDArray[np.int32]) -> MeshTags: - """Generate cell mesh tags on a refined mesh from the meshtgs on the coarse parent mesh +def transfer_meshtag(meshtag: MeshTags, mesh1: Mesh, parent_cell: npt.NDArray[np.int32], + parent_facet: typing.Optional[npt.NDArray[np.int8]] = None) -> MeshTags: + """Generate cell mesh tags on a refined mesh from the mesh tags on the coarse parent mesh. Args: meshtag: Mesh tags on the coarse, parent mesh mesh1: The refined mesh parent_cell: Index of the parent cell for each cell in the refined mesh + parent_facet: Index of the local parent facet for each cell + in the refined mesh. Only required for transfer tags on facets. Returns: - Mesh tags on the refined mesh + Mesh tags on the refined mesh. """ - - mt = _cpp.refinement.transfer_cell_meshtag(meshtag._cpp_object, mesh1._cpp_object, parent_cell) - return MeshTags(mt, mesh1) + if meshtag.dim == meshtag.mesh.topology.dim: + mt = _cpp.refinement.transfer_cell_meshtag(meshtag._cpp_object, mesh1._cpp_object, parent_cell) + return MeshTags(mt, mesh1) + elif meshtag.dim == meshtag.mesh.topology.dim - 1: + assert parent_facet is not None + mt = _cpp.refinement.transfer_facet_meshtag(meshtag._cpp_object, mesh1._cpp_object, parent_cell, parent_facet) + return MeshTags(mt, mesh1) + else: + raise RuntimeError("MeshTag transfer is supported on on cells or facets.") def refine(mesh: Mesh, edges: typing.Optional[np.ndarray] = None, redistribute: bool = True) -> Mesh: @@ -185,7 +195,8 @@ def refine(mesh: Mesh, edges: typing.Optional[np.ndarray] = None, redistribute: def refine_plaza(mesh: Mesh, edges: typing.Optional[np.ndarray] = None, redistribute: bool = True, - option: _cpp.refinement.RefinementOption = _cpp.refinement.RefinementOption.none) -> Mesh: + option: RefinementOption = RefinementOption.none) -> tuple[Mesh, npt.NDArray[np.int32], + npt.NDArray[np.int32]]: """Refine a mesh. Args: diff --git a/python/test/unit/mesh/test_refinement.py b/python/test/unit/mesh/test_refinement.py index 8c2e426d591..97fe47141e6 100644 --- a/python/test/unit/mesh/test_refinement.py +++ b/python/test/unit/mesh/test_refinement.py @@ -7,18 +7,17 @@ import numpy import pytest import ufl +from dolfinx.cpp.refinement import RefinementOption from dolfinx.fem import FunctionSpace, form from dolfinx.fem.petsc import assemble_matrix from dolfinx.mesh import (CellType, DiagonalType, GhostMode, compute_incident_entities, create_unit_cube, create_unit_square, locate_entities, locate_entities_boundary, meshtags, refine, - refine_plaza) + refine_plaza, transfer_meshtag) from mpi4py import MPI from numpy import isclose, logical_and -from dolfinx import cpp as _cpp - def test_Refinecreate_unit_square(): """Refine mesh of unit square.""" @@ -138,11 +137,9 @@ def test_refine_facet_meshtag(tdim): meshtag = meshtags(mesh, tdim - 1, numpy.array(facet_indices, dtype=numpy.int32), numpy.arange(len(facet_indices), dtype=numpy.int32)) - fine_mesh, parent_cell, parent_facet = refine_plaza( - mesh, False, _cpp.refinement.RefinementOption.parent_cell_and_facet) + fine_mesh, parent_cell, parent_facet = refine_plaza(mesh, False, RefinementOption.parent_cell_and_facet) fine_mesh.topology.create_entities(tdim - 1) - new_meshtag = _cpp.refinement.transfer_facet_meshtag( - meshtag._cpp_object, fine_mesh._cpp_object, parent_cell, parent_facet) + new_meshtag = transfer_meshtag(meshtag, fine_mesh, parent_cell, parent_facet) assert len(new_meshtag.indices) == (tdim * 2 - 2) * len(meshtag.indices) # New tags should be on facets with one cell (i.e. exterior) @@ -155,8 +152,7 @@ def test_refine_facet_meshtag(tdim): facet_indices = numpy.arange(mesh.topology.index_map(tdim - 1).size_local) meshtag = meshtags(mesh, tdim - 1, numpy.array(facet_indices, dtype=numpy.int32), numpy.arange(len(facet_indices), dtype=numpy.int32)) - new_meshtag = _cpp.refinement.transfer_facet_meshtag( - meshtag._cpp_object, fine_mesh._cpp_object, parent_cell, parent_facet) + new_meshtag = transfer_meshtag(meshtag, fine_mesh, parent_cell, parent_facet) assert len(new_meshtag.indices) == (tdim * 2 - 2) * len(meshtag.indices) @@ -172,7 +168,7 @@ def test_refine_cell_meshtag(tdim): meshtag = meshtags(mesh, tdim, numpy.array(cell_indices, dtype=numpy.int32), numpy.arange(len(cell_indices), dtype=numpy.int32)) - fine_mesh, parent_cell, _ = refine_plaza(mesh, False, _cpp.refinement.RefinementOption.parent_cell_and_facet) - new_meshtag = _cpp.refinement.transfer_cell_meshtag(meshtag._cpp_object, fine_mesh._cpp_object, parent_cell) + fine_mesh, parent_cell, _ = refine_plaza(mesh, False, RefinementOption.parent_cell_and_facet) + new_meshtag = transfer_meshtag(meshtag, fine_mesh, parent_cell) assert sum(new_meshtag.values) == (tdim * 4 - 4) * sum(meshtag.values) assert len(new_meshtag.indices) == (tdim * 4 - 4) * len(meshtag.indices) From ffa12741bec27f61ae5fa4cc8e2905013fc5b51f Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 10:27:27 +0000 Subject: [PATCH 03/11] Tidy up --- cpp/dolfinx/refinement/plaza.cpp | 43 ++++++++++++------------ python/test/unit/mesh/test_refinement.py | 3 +- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/cpp/dolfinx/refinement/plaza.cpp b/cpp/dolfinx/refinement/plaza.cpp index 6025e6c0f69..14dfc377aba 100644 --- a/cpp/dolfinx/refinement/plaza.cpp +++ b/cpp/dolfinx/refinement/plaza.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -31,7 +30,7 @@ void enforce_rules(MPI_Comm neighbor_comm, const graph::AdjacencyList& shared_edges, std::vector& marked_edges, const mesh::Mesh& mesh, - const std::vector& long_edge) + std::span long_edge) { common::Timer t0("PLAZA: Enforce rules"); @@ -95,9 +94,9 @@ void enforce_rules(MPI_Comm neighbor_comm, } //----------------------------------------------------------------------------- // 2D version of subdivision allowing for uniform subdivision (flag) -std::vector -get_triangles(const std::vector& indices, - const std::int32_t longest_edge, bool uniform) +std::vector get_triangles(std::span indices, + const std::int32_t longest_edge, + bool uniform) { // v0 and v1 are at ends of longest_edge (e2) opposite vertex has same // index as longest_edge @@ -135,8 +134,8 @@ get_triangles(const std::vector& indices, //----------------------------------------------------------------------------- // 3D version of subdivision std::vector -get_tetrahedra(const std::vector& indices, - const std::vector& longest_edge) +get_tetrahedra(std::span indices, + std::span longest_edge) { // Connectivity matrix for ten possible points (4 vertices + 6 edge // midpoints) ordered {v0, v1, v2, v3, e0, e1, e2, e3, e4, e5} Only need @@ -248,8 +247,8 @@ get_tetrahedra(const std::vector& indices, /// being similar shape /// @return std::vector -get_simplices(const std::vector& indices, - const std::vector& longest_edge, std::int32_t tdim, +get_simplices(std::span indices, + std::span longest_edge, int tdim, bool uniform) { if (tdim == 2) @@ -381,20 +380,19 @@ face_long_edge(const mesh::Mesh& mesh) return std::pair(std::move(long_edge), std::move(edge_ratio_ok)); } //----------------------------------------------------------------- -// Computes the parent-child facet relationship -// @param simplex_set - index into indices for each child cell -// @return mapping from child to parent facets, using cell-local index +/// Computes the parent-child facet relationship +/// @param simplex_set - index into indices for each child cell +/// @return mapping from child to parent facets, using cell-local index template std::vector -compute_parent_facets(const std::vector& simplex_set) +compute_parent_facets(std::span simplex_set) { assert(simplex_set.size() % (tdim + 1) == 0); - std::vector parent_facet(simplex_set.size(), -1); - // Index lookups in 'indices' for the child vertices that occur on each parent - // facet in 2D and 3D. In 2D each edge has 3 child vertices, and in 3D each - // triangular facet has six child vertices. + // Index lookups in 'indices' for the child vertices that occur on + // each parent facet in 2D and 3D. In 2D each edge has 3 child + // vertices, and in 3D each triangular facet has six child vertices. constexpr std::array, 3> facet_table_2d{ {{1, 2, 3}, {0, 2, 4}, {0, 1, 5}}}; @@ -436,6 +434,7 @@ compute_parent_facets(const std::vector& simplex_set) cf.end(), set_output.begin()); num_common_vertices = std::distance(set_output.begin(), it); } + if (num_common_vertices == tdim) { assert(parent_facet[cc * (tdim + 1) + fci] == -1); @@ -460,13 +459,12 @@ compute_refinement(MPI_Comm neighbor_comm, const std::vector& edge_ratio_ok, plaza::Option option) { - const std::int32_t tdim = mesh.topology().dim(); - const std::int32_t num_cell_edges = tdim * 3 - 3; - const std::int32_t num_cell_vertices = tdim + 1; + int tdim = mesh.topology().dim(); + int num_cell_edges = tdim * 3 - 3; + int num_cell_vertices = tdim + 1; bool compute_facets = (option == plaza::Option::parent_facet or option == plaza::Option::parent_cell_and_facet); - bool compute_parent_cell = (option == plaza::Option::parent_cell or option == plaza::Option::parent_cell_and_facet); @@ -482,7 +480,6 @@ compute_refinement(MPI_Comm neighbor_comm, auto map_c = mesh.topology().index_map(tdim); assert(map_c); - auto c_to_v = mesh.topology().connectivity(tdim, 0); assert(c_to_v); auto c_to_e = mesh.topology().connectivity(tdim, 1); @@ -535,6 +532,7 @@ compute_refinement(MPI_Comm neighbor_comm, if (compute_parent_cell) parent_cell.push_back(c); + if (compute_facets) { if (tdim == 3) @@ -577,6 +575,7 @@ compute_refinement(MPI_Comm neighbor_comm, for (std::int32_t i = 0; i < ncells; ++i) parent_cell.push_back(c); } + if (compute_facets) { std::vector npf; diff --git a/python/test/unit/mesh/test_refinement.py b/python/test/unit/mesh/test_refinement.py index 97fe47141e6..5495dc9c3e5 100644 --- a/python/test/unit/mesh/test_refinement.py +++ b/python/test/unit/mesh/test_refinement.py @@ -7,10 +7,9 @@ import numpy import pytest import ufl -from dolfinx.cpp.refinement import RefinementOption from dolfinx.fem import FunctionSpace, form from dolfinx.fem.petsc import assemble_matrix -from dolfinx.mesh import (CellType, DiagonalType, GhostMode, +from dolfinx.mesh import (CellType, DiagonalType, GhostMode, RefinementOption, compute_incident_entities, create_unit_cube, create_unit_square, locate_entities, locate_entities_boundary, meshtags, refine, From 72467bc8ceee93e437c26919455a6be30b29c1b1 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 14:57:38 +0000 Subject: [PATCH 04/11] Small simplification --- cpp/dolfinx/refinement/plaza.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cpp/dolfinx/refinement/plaza.h b/cpp/dolfinx/refinement/plaza.h index 696ad66c13f..255e4b9b5ff 100644 --- a/cpp/dolfinx/refinement/plaza.h +++ b/cpp/dolfinx/refinement/plaza.h @@ -20,15 +20,11 @@ template class MeshTags; } // namespace dolfinx::mesh -namespace dolfinx::refinement -{ - /// Function in this namespace implement the refinement method described /// in Plaza and Carey "Local refinement of simplicial grids based on /// the skeleton" (Applied Numerical Mathematics 32 (2000) 195-218). -namespace plaza +namespace dolfinx::refinement::plaza { - /// Selection of options when refining a Mesh. `parent_cell` will output /// a list containing the local parent cell index for each new cell, /// `parent_facet` will output a list of the cell-local facet indices in @@ -76,7 +72,7 @@ refine(const mesh::Mesh& mesh, std::span edges, /// @param[in] option Control computation of parent facets and parent /// cells. If an option is unselected, an empty list is returned. /// @return New mesh data: cell topology, vertex coordinates, vertex -/// coordinates shape, and optional parent cell index, and parent facet +/// coordinates shape, and optional parent cell index, and parent facet /// indices. std::tuple, std::vector, std::array, std::vector, @@ -97,6 +93,4 @@ std::tuple, std::vector, std::vector> compute_refinement_data(const mesh::Mesh& mesh, std::span edges, Option option); - -} // namespace plaza -} // namespace dolfinx::refinement +} // namespace dolfinx::refinement::plaza From 67791146705703a1715719ad6a9e30cc50930d2a Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 15:27:41 +0000 Subject: [PATCH 05/11] Doc fixes --- cpp/dolfinx/common/dolfin_common.h | 13 ++++++----- cpp/dolfinx/common/utils.h | 1 + cpp/dolfinx/dolfinx.h | 5 +++++ cpp/dolfinx/fem/dolfin_fem.h | 11 +++++----- cpp/dolfinx/geometry/dolfin_geometry.h | 10 ++++----- cpp/dolfinx/graph/dolfin_graph.h | 12 +++++------ cpp/dolfinx/io/dolfin_io.h | 10 ++++----- cpp/dolfinx/la/dolfin_la.h | 10 ++++----- cpp/dolfinx/mesh/dolfin_mesh.h | 10 ++++----- cpp/dolfinx/nls/dolfin_nls.h | 10 ++++----- cpp/dolfinx/refinement/dolfin_refinement.h | 12 +++++------ cpp/dolfinx/refinement/plaza.h | 25 +++++++++++----------- 12 files changed, 60 insertions(+), 69 deletions(-) diff --git a/cpp/dolfinx/common/dolfin_common.h b/cpp/dolfinx/common/dolfin_common.h index 565ca5e3ac5..bdf059ccbad 100644 --- a/cpp/dolfinx/common/dolfin_common.h +++ b/cpp/dolfinx/common/dolfin_common.h @@ -1,13 +1,12 @@ #pragma once -namespace dolfinx -{ -/*! \namespace dolfinx::common - \brief Miscellaneous classes, functions and types - This namespace provides utility type functions for managing subsystems, - convenience classes and library-wide typedefs. -*/ +/// @brief Miscellaneous classes, functions and types. +/// +/// This namespace provides utility type functions for managing +/// subsystems, convenience classes and library-wide typedefs. +namespace dolfinx::common +{ } // DOLFINx common diff --git a/cpp/dolfinx/common/utils.h b/cpp/dolfinx/common/utils.h index f51f874ce5e..5a49c487417 100644 --- a/cpp/dolfinx/common/utils.h +++ b/cpp/dolfinx/common/utils.h @@ -13,6 +13,7 @@ #include #include +/// @namespace Foobar namespace dolfinx::common { diff --git a/cpp/dolfinx/dolfinx.h b/cpp/dolfinx/dolfinx.h index 13209b9e509..4325eb7b224 100644 --- a/cpp/dolfinx/dolfinx.h +++ b/cpp/dolfinx/dolfinx.h @@ -1,5 +1,10 @@ #pragma once +/// @brief Top-level namespace +namespace dolfinx +{ +} + // DOLFINx interface #include diff --git a/cpp/dolfinx/fem/dolfin_fem.h b/cpp/dolfinx/fem/dolfin_fem.h index 994772e8dfa..c10fb23a1b4 100644 --- a/cpp/dolfinx/fem/dolfin_fem.h +++ b/cpp/dolfinx/fem/dolfin_fem.h @@ -1,12 +1,11 @@ #pragma once -namespace dolfinx +/// @brief Finite element method functionality +/// +/// Classes and algorithms for finite element method spaces and +/// operations. +namespace dolfinx::fem { -/*! \namespace dolfinx::fem - \brief Finite element method functionality - - Classes and algorithms for finite element method spaces and operations. -*/ } // DOLFINx fem interface diff --git a/cpp/dolfinx/geometry/dolfin_geometry.h b/cpp/dolfinx/geometry/dolfin_geometry.h index cf8a30f194e..f03e9cf351a 100644 --- a/cpp/dolfinx/geometry/dolfin_geometry.h +++ b/cpp/dolfinx/geometry/dolfin_geometry.h @@ -1,12 +1,10 @@ #pragma once -namespace dolfinx +/// @brief Geometry data structures and algorithms +/// +/// Tools for geometric data structures and operations, e.g. searching. +namespace dolfinx::geometry { -/*! \namespace dolfinx::geometry - \brief Geometry data structures and algorithms - - Tools for geometric data structures and operations, e.g. searching. -*/ } // DOLFINx geometry interface diff --git a/cpp/dolfinx/graph/dolfin_graph.h b/cpp/dolfinx/graph/dolfin_graph.h index 0b401327731..040fcb59dea 100644 --- a/cpp/dolfinx/graph/dolfin_graph.h +++ b/cpp/dolfinx/graph/dolfin_graph.h @@ -1,13 +1,11 @@ #pragma once -namespace dolfinx +/// @brief Graph data structures and algorithms. +/// +/// Data structures for building and representing graphs, and algorithms +/// on graphs, e.g., re-ordering and partitioning. +namespace dolfinx::::graph { -/*! \namespace dolfinx::graph - \brief Graph data structures and algorithms - - Data structures for building and representing graphs, and algorithms on - graphs, e.g., re-ordering and partitioning. -*/ } // DOLFINx graph interface diff --git a/cpp/dolfinx/io/dolfin_io.h b/cpp/dolfinx/io/dolfin_io.h index 362adb99c79..551fecffdcf 100644 --- a/cpp/dolfinx/io/dolfin_io.h +++ b/cpp/dolfinx/io/dolfin_io.h @@ -1,12 +1,10 @@ #pragma once -namespace dolfinx +/// @brief Support for file IO. +/// +/// IO to files for checkpointing and visualisation. +namespace dolfinx::io { -/*! \namespace dolfinx::io - \brief Support for file IO - - IO to files for checkpointing and visualisation. -*/ } // DOLFINx io interface diff --git a/cpp/dolfinx/la/dolfin_la.h b/cpp/dolfinx/la/dolfin_la.h index b3152770df1..dd4d9fe1f03 100644 --- a/cpp/dolfinx/la/dolfin_la.h +++ b/cpp/dolfinx/la/dolfin_la.h @@ -1,12 +1,10 @@ #pragma once -namespace dolfinx +/// @brief Linear algebra interface. +/// +/// Interface to linear algebra data structures and solvers. +namespace dolfinx::la { -/*! \namespace dolfinx::la - \brief Linear algebra interface - - Interface to linear algebra data structures and solvers -*/ } // DOLFINx la interface diff --git a/cpp/dolfinx/mesh/dolfin_mesh.h b/cpp/dolfinx/mesh/dolfin_mesh.h index f6792ed19cc..7185d24f655 100644 --- a/cpp/dolfinx/mesh/dolfin_mesh.h +++ b/cpp/dolfinx/mesh/dolfin_mesh.h @@ -1,12 +1,10 @@ #pragma once -namespace dolfinx +/// @brief Mesh data structures and algorithms on meshes +/// +/// Representations of meshes and support for operations on meshes. +namespace dolfinx::mesh { -/*! \namespace dolfinx::mesh - \brief Mesh data structures and algorithms on meshes - - Representations of meshes and support for operations on meshes. -*/ } // DOLFINx mesh interface diff --git a/cpp/dolfinx/nls/dolfin_nls.h b/cpp/dolfinx/nls/dolfin_nls.h index 907e20f7ee0..7c685bb32a8 100644 --- a/cpp/dolfinx/nls/dolfin_nls.h +++ b/cpp/dolfinx/nls/dolfin_nls.h @@ -1,12 +1,10 @@ #pragma once -namespace dolfinx +/// @brief Nonlinear solvers. +/// +/// Methods for solving nonlinear equations. +namespace dolfinx::nls { -/*! \namespace dolfinx::nls - \brief Nonlinear solvers - - Methods for solving nonlinear equations -*/ } // DOLFINx nonlinear solver diff --git a/cpp/dolfinx/refinement/dolfin_refinement.h b/cpp/dolfinx/refinement/dolfin_refinement.h index a14c323c4bc..0b593a3fb58 100644 --- a/cpp/dolfinx/refinement/dolfin_refinement.h +++ b/cpp/dolfinx/refinement/dolfin_refinement.h @@ -1,13 +1,11 @@ #pragma once -namespace dolfinx +/// @brief Mesh refinement algorithms. +/// +/// Methods for refining meshes uniformly, or with markers, using edge +/// bisection. +namespace dolfinx:: ::refinement { -/*! \namespace dolfinx::refinement - \brief Mesh refinement algorithms - - Methods for refining meshes uniformly, or with markers, using - edge bisection. -*/ } // DOLFINx refinement interface diff --git a/cpp/dolfinx/refinement/plaza.h b/cpp/dolfinx/refinement/plaza.h index 255e4b9b5ff..b9e80dea411 100644 --- a/cpp/dolfinx/refinement/plaza.h +++ b/cpp/dolfinx/refinement/plaza.h @@ -20,22 +20,23 @@ template class MeshTags; } // namespace dolfinx::mesh -/// Function in this namespace implement the refinement method described -/// in Plaza and Carey "Local refinement of simplicial grids based on -/// the skeleton" (Applied Numerical Mathematics 32 (2000) 195-218). +/// @brief Plaza mesh refinement. +/// +/// Functions for the refinement method described in Plaza and Carey +/// "Local refinement of simplicial grids based on the skeleton", +/// Applied Numerical Mathematics 32 (2000), 195-218. namespace dolfinx::refinement::plaza { -/// Selection of options when refining a Mesh. `parent_cell` will output -/// a list containing the local parent cell index for each new cell, -/// `parent_facet` will output a list of the cell-local facet indices in -/// the parent cell of each facet in each new cell (or -1 if no match). -/// `parent_cell_and_facet` will output both datasets. +/// @brief Options for mesh refinement. enum class Option : int { - none = 0, - parent_cell = 1, - parent_facet = 2, - parent_cell_and_facet = 3 + none = 0, /*!< No extra data */ + parent_cell + = 1, /*!< Compute list with the parent cell index for each new cell */ + parent_facet + = 2, /*!< Compute a list of the cell-local facet indices in the parent cell of + each facet in each new cell (or -1 if no match) */ + parent_cell_and_facet = 3 /*!< Both cell and facet parent data */ }; /// @brief Uniform refine, optionally redistributing and optionally From 844629e0458e98901c2f68aa92013256111ebaa0 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 19:23:25 +0000 Subject: [PATCH 06/11] Doc fix --- cpp/dolfinx/common/utils.h | 2 +- cpp/dolfinx/fem/petsc.h | 12 ++++++++---- cpp/dolfinx/refinement/plaza.h | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cpp/dolfinx/common/utils.h b/cpp/dolfinx/common/utils.h index 5a49c487417..7237850b1f8 100644 --- a/cpp/dolfinx/common/utils.h +++ b/cpp/dolfinx/common/utils.h @@ -13,7 +13,7 @@ #include #include -/// @namespace Foobar +/// @namespace Generic tools namespace dolfinx::common { diff --git a/cpp/dolfinx/fem/petsc.h b/cpp/dolfinx/fem/petsc.h index f6bc374592f..f1b59faf8a0 100644 --- a/cpp/dolfinx/fem/petsc.h +++ b/cpp/dolfinx/fem/petsc.h @@ -26,7 +26,7 @@ template class DirichletBC; class FunctionSpace; -/// Helper functions for assembly into PETSc data structures +/// @brief Helper functions for assembly into PETSc data structures namespace petsc { /// Create a matrix @@ -71,9 +71,10 @@ Vec create_vector_nest( // -- Vectors ---------------------------------------------------------------- -/// Assemble linear form into an already allocated PETSc vector. Ghost -/// contributions are not accumulated (not sent to owner). Caller is -/// responsible for calling VecGhostUpdateBegin/End. +/// @brief Assemble linear form into an already allocated PETSc vector. +/// +/// Ghost contributions are not accumulated (not sent to owner). Caller +/// is responsible for calling `VecGhostUpdateBegin/End`. /// /// @param[in,out] b The PETsc vector to assemble the form into. The /// vector must already be initialised with the correct size. The @@ -104,6 +105,9 @@ void assemble_vector(Vec b, const Form& L); // FIXME: need to pass an array of Vec for x0? // FIXME: clarify zeroing of vector +/// @brief Modify RHS vector to account for Dirichlet boundary +/// conditions. +/// /// Modify b such that: /// /// b <- b - scale * A_j (g_j - x0_j) diff --git a/cpp/dolfinx/refinement/plaza.h b/cpp/dolfinx/refinement/plaza.h index b9e80dea411..096dffce552 100644 --- a/cpp/dolfinx/refinement/plaza.h +++ b/cpp/dolfinx/refinement/plaza.h @@ -27,14 +27,14 @@ class MeshTags; /// Applied Numerical Mathematics 32 (2000), 195-218. namespace dolfinx::refinement::plaza { -/// @brief Options for mesh refinement. +/// @brief Options for data to compute during mesh refinement. enum class Option : int { none = 0, /*!< No extra data */ parent_cell = 1, /*!< Compute list with the parent cell index for each new cell */ parent_facet - = 2, /*!< Compute a list of the cell-local facet indices in the parent cell of + = 2, /*!< Compute list of the cell-local facet indices in the parent cell of each facet in each new cell (or -1 if no match) */ parent_cell_and_facet = 3 /*!< Both cell and facet parent data */ }; From d1d199855d9d7f266652cf8afad7b43ff33eac64 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 19:34:44 +0000 Subject: [PATCH 07/11] Update some dolfin -> dolfinx names --- cpp/dolfinx/common/CMakeLists.txt | 50 +++++++-------- .../{dolfin_common.h => dolfinx_common.h} | 0 .../common/{dolfin_doc.h => dolfinx_doc.h} | 0 cpp/dolfinx/dolfinx.h | 18 +++--- cpp/dolfinx/fem/CMakeLists.txt | 64 +++++++++---------- cpp/dolfinx/fem/DofMap.cpp | 2 +- cpp/dolfinx/fem/DofMap.h | 2 +- cpp/dolfinx/fem/assemble_vector_impl.h | 2 +- .../fem/{dolfin_fem.h => dolfinx_fem.h} | 0 cpp/dolfinx/geometry/CMakeLists.txt | 14 ++-- .../{dolfin_geometry.h => dolfinx_geometry.h} | 0 cpp/dolfinx/graph/CMakeLists.txt | 16 ++--- .../graph/{dolfin_graph.h => dolfinx_graph.h} | 0 cpp/dolfinx/io/CMakeLists.txt | 42 ++++++------ cpp/dolfinx/io/{dolfin_io.h => dolfinx_io.h} | 0 cpp/dolfinx/la/CMakeLists.txt | 2 +- cpp/dolfinx/la/{dolfin_la.h => dolfinx_la.h} | 0 cpp/dolfinx/la/petsc.h | 1 + cpp/dolfinx/mesh/CMakeLists.txt | 2 +- .../mesh/{dolfin_mesh.h => dolfinx_mesh.h} | 0 cpp/dolfinx/nls/CMakeLists.txt | 2 +- .../nls/{dolfin_nls.h => dolfinx_nls.h} | 0 cpp/dolfinx/refinement/CMakeLists.txt | 13 ++-- ...lfin_refinement.h => dolfinx_refinement.h} | 0 24 files changed, 116 insertions(+), 114 deletions(-) rename cpp/dolfinx/common/{dolfin_common.h => dolfinx_common.h} (100%) rename cpp/dolfinx/common/{dolfin_doc.h => dolfinx_doc.h} (100%) rename cpp/dolfinx/fem/{dolfin_fem.h => dolfinx_fem.h} (100%) rename cpp/dolfinx/geometry/{dolfin_geometry.h => dolfinx_geometry.h} (100%) rename cpp/dolfinx/graph/{dolfin_graph.h => dolfinx_graph.h} (100%) rename cpp/dolfinx/io/{dolfin_io.h => dolfinx_io.h} (100%) rename cpp/dolfinx/la/{dolfin_la.h => dolfinx_la.h} (100%) rename cpp/dolfinx/mesh/{dolfin_mesh.h => dolfinx_mesh.h} (100%) rename cpp/dolfinx/nls/{dolfin_nls.h => dolfinx_nls.h} (100%) rename cpp/dolfinx/refinement/{dolfin_refinement.h => dolfinx_refinement.h} (100%) diff --git a/cpp/dolfinx/common/CMakeLists.txt b/cpp/dolfinx/common/CMakeLists.txt index 79e30b6fe53..88abaf6fe1b 100644 --- a/cpp/dolfinx/common/CMakeLists.txt +++ b/cpp/dolfinx/common/CMakeLists.txt @@ -1,32 +1,32 @@ set(HEADERS_common - ${CMAKE_CURRENT_SOURCE_DIR}/defines.h - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_common.h - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_doc.h - ${CMAKE_CURRENT_SOURCE_DIR}/IndexMap.h - ${CMAKE_CURRENT_SOURCE_DIR}/log.h - ${CMAKE_CURRENT_SOURCE_DIR}/loguru.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/sort.h - ${CMAKE_CURRENT_SOURCE_DIR}/math.h - ${CMAKE_CURRENT_SOURCE_DIR}/MPI.h - ${CMAKE_CURRENT_SOURCE_DIR}/Scatterer.h - ${CMAKE_CURRENT_SOURCE_DIR}/Table.h - ${CMAKE_CURRENT_SOURCE_DIR}/Timer.h - ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogger.h - ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogManager.h - ${CMAKE_CURRENT_SOURCE_DIR}/timing.h - ${CMAKE_CURRENT_SOURCE_DIR}/utils.h - PARENT_SCOPE + ${CMAKE_CURRENT_SOURCE_DIR}/defines.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_common.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_doc.h + ${CMAKE_CURRENT_SOURCE_DIR}/IndexMap.h + ${CMAKE_CURRENT_SOURCE_DIR}/log.h + ${CMAKE_CURRENT_SOURCE_DIR}/loguru.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/sort.h + ${CMAKE_CURRENT_SOURCE_DIR}/math.h + ${CMAKE_CURRENT_SOURCE_DIR}/MPI.h + ${CMAKE_CURRENT_SOURCE_DIR}/Scatterer.h + ${CMAKE_CURRENT_SOURCE_DIR}/Table.h + ${CMAKE_CURRENT_SOURCE_DIR}/Timer.h + ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogger.h + ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogManager.h + ${CMAKE_CURRENT_SOURCE_DIR}/timing.h + ${CMAKE_CURRENT_SOURCE_DIR}/utils.h + PARENT_SCOPE ) target_sources( dolfinx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/defines.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/IndexMap.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/log.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/MPI.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Table.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/Timer.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogger.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogManager.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/timing.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/IndexMap.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/log.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/MPI.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Table.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Timer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogger.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TimeLogManager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/timing.cpp ) \ No newline at end of file diff --git a/cpp/dolfinx/common/dolfin_common.h b/cpp/dolfinx/common/dolfinx_common.h similarity index 100% rename from cpp/dolfinx/common/dolfin_common.h rename to cpp/dolfinx/common/dolfinx_common.h diff --git a/cpp/dolfinx/common/dolfin_doc.h b/cpp/dolfinx/common/dolfinx_doc.h similarity index 100% rename from cpp/dolfinx/common/dolfin_doc.h rename to cpp/dolfinx/common/dolfinx_doc.h diff --git a/cpp/dolfinx/dolfinx.h b/cpp/dolfinx/dolfinx.h index 4325eb7b224..0de7ceb3499 100644 --- a/cpp/dolfinx/dolfinx.h +++ b/cpp/dolfinx/dolfinx.h @@ -7,12 +7,12 @@ namespace dolfinx // DOLFINx interface -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/cpp/dolfinx/fem/CMakeLists.txt b/cpp/dolfinx/fem/CMakeLists.txt index 0b923662bae..0aad755a0f8 100644 --- a/cpp/dolfinx/fem/CMakeLists.txt +++ b/cpp/dolfinx/fem/CMakeLists.txt @@ -1,39 +1,39 @@ set(HEADERS_fem - ${CMAKE_CURRENT_SOURCE_DIR}/Constant.h - ${CMAKE_CURRENT_SOURCE_DIR}/CoordinateElement.h - ${CMAKE_CURRENT_SOURCE_DIR}/DirichletBC.h - ${CMAKE_CURRENT_SOURCE_DIR}/DofMap.h - ${CMAKE_CURRENT_SOURCE_DIR}/ElementDofLayout.h - ${CMAKE_CURRENT_SOURCE_DIR}/Expression.h - ${CMAKE_CURRENT_SOURCE_DIR}/FiniteElement.h - ${CMAKE_CURRENT_SOURCE_DIR}/Form.h - ${CMAKE_CURRENT_SOURCE_DIR}/Function.h - ${CMAKE_CURRENT_SOURCE_DIR}/FunctionSpace.h - ${CMAKE_CURRENT_SOURCE_DIR}/assembler.h - ${CMAKE_CURRENT_SOURCE_DIR}/assemble_matrix_impl.h - ${CMAKE_CURRENT_SOURCE_DIR}/assemble_scalar_impl.h - ${CMAKE_CURRENT_SOURCE_DIR}/assemble_vector_impl.h - ${CMAKE_CURRENT_SOURCE_DIR}/discreteoperators.h - ${CMAKE_CURRENT_SOURCE_DIR}/dofmapbuilder.h - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_fem.h - ${CMAKE_CURRENT_SOURCE_DIR}/interpolate.h - ${CMAKE_CURRENT_SOURCE_DIR}/petsc.h - ${CMAKE_CURRENT_SOURCE_DIR}/sparsitybuild.h - ${CMAKE_CURRENT_SOURCE_DIR}/utils.h - PARENT_SCOPE + ${CMAKE_CURRENT_SOURCE_DIR}/Constant.h + ${CMAKE_CURRENT_SOURCE_DIR}/CoordinateElement.h + ${CMAKE_CURRENT_SOURCE_DIR}/DirichletBC.h + ${CMAKE_CURRENT_SOURCE_DIR}/DofMap.h + ${CMAKE_CURRENT_SOURCE_DIR}/ElementDofLayout.h + ${CMAKE_CURRENT_SOURCE_DIR}/Expression.h + ${CMAKE_CURRENT_SOURCE_DIR}/FiniteElement.h + ${CMAKE_CURRENT_SOURCE_DIR}/Form.h + ${CMAKE_CURRENT_SOURCE_DIR}/Function.h + ${CMAKE_CURRENT_SOURCE_DIR}/FunctionSpace.h + ${CMAKE_CURRENT_SOURCE_DIR}/assembler.h + ${CMAKE_CURRENT_SOURCE_DIR}/assemble_matrix_impl.h + ${CMAKE_CURRENT_SOURCE_DIR}/assemble_scalar_impl.h + ${CMAKE_CURRENT_SOURCE_DIR}/assemble_vector_impl.h + ${CMAKE_CURRENT_SOURCE_DIR}/discreteoperators.h + ${CMAKE_CURRENT_SOURCE_DIR}/dofmapbuilder.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_fem.h + ${CMAKE_CURRENT_SOURCE_DIR}/interpolate.h + ${CMAKE_CURRENT_SOURCE_DIR}/petsc.h + ${CMAKE_CURRENT_SOURCE_DIR}/sparsitybuild.h + ${CMAKE_CURRENT_SOURCE_DIR}/utils.h + PARENT_SCOPE ) target_sources( dolfinx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/DirichletBC.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/CoordinateElement.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DofMap.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ElementDofLayout.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FiniteElement.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/FunctionSpace.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/dofmapbuilder.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/interpolate.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/petsc.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/sparsitybuild.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/CoordinateElement.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/DofMap.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ElementDofLayout.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FiniteElement.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FunctionSpace.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dofmapbuilder.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/interpolate.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/petsc.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sparsitybuild.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp ) diff --git a/cpp/dolfinx/fem/DofMap.cpp b/cpp/dolfinx/fem/DofMap.cpp index baccd74a021..ee8fd000cbb 100644 --- a/cpp/dolfinx/fem/DofMap.cpp +++ b/cpp/dolfinx/fem/DofMap.cpp @@ -182,7 +182,7 @@ bool DofMap::operator==(const DofMap& map) const //----------------------------------------------------------------------------- int DofMap::bs() const noexcept { return _bs; } //----------------------------------------------------------------------------- -DofMap DofMap::extract_sub_dofmap(const std::vector& component) const +DofMap DofMap::extract_sub_dofmap(std::span component) const { assert(!component.empty()); diff --git a/cpp/dolfinx/fem/DofMap.h b/cpp/dolfinx/fem/DofMap.h index 668a6b8c12d..605e38921e4 100644 --- a/cpp/dolfinx/fem/DofMap.h +++ b/cpp/dolfinx/fem/DofMap.h @@ -129,7 +129,7 @@ class DofMap /// @brief Extract subdofmap component /// @param[in] component The component indices /// @return The dofmap for the component - DofMap extract_sub_dofmap(const std::vector& component) const; + DofMap extract_sub_dofmap(std::span component) const; /// @brief Create a "collapsed" dofmap (collapses a sub-dofmap) /// @param[in] comm MPI Communicator diff --git a/cpp/dolfinx/fem/assemble_vector_impl.h b/cpp/dolfinx/fem/assemble_vector_impl.h index 65cb679e931..bbf42cdadc9 100644 --- a/cpp/dolfinx/fem/assemble_vector_impl.h +++ b/cpp/dolfinx/fem/assemble_vector_impl.h @@ -869,7 +869,7 @@ void lift_bc(std::span b, const Form& a, std::span constants, /// @param[in] scale Scaling to apply template void apply_lifting( - std::span b, const std::vector>> a, + std::span b, std::vector>> a, const std::vector>& constants, const std::vector, std::pair, int>>>& coeffs, diff --git a/cpp/dolfinx/fem/dolfin_fem.h b/cpp/dolfinx/fem/dolfinx_fem.h similarity index 100% rename from cpp/dolfinx/fem/dolfin_fem.h rename to cpp/dolfinx/fem/dolfinx_fem.h diff --git a/cpp/dolfinx/geometry/CMakeLists.txt b/cpp/dolfinx/geometry/CMakeLists.txt index 2d9f70b7216..602e83d3b37 100644 --- a/cpp/dolfinx/geometry/CMakeLists.txt +++ b/cpp/dolfinx/geometry/CMakeLists.txt @@ -1,14 +1,14 @@ set(HEADERS_geometry - ${CMAKE_CURRENT_SOURCE_DIR}/BoundingBoxTree.h - ${CMAKE_CURRENT_SOURCE_DIR}/gjk.h - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_geometry.h - ${CMAKE_CURRENT_SOURCE_DIR}/utils.h - PARENT_SCOPE + ${CMAKE_CURRENT_SOURCE_DIR}/BoundingBoxTree.h + ${CMAKE_CURRENT_SOURCE_DIR}/gjk.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_geometry.h + ${CMAKE_CURRENT_SOURCE_DIR}/utils.h + PARENT_SCOPE ) target_sources( dolfinx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/BoundingBoxTree.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/gjk.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gjk.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp ) diff --git a/cpp/dolfinx/geometry/dolfin_geometry.h b/cpp/dolfinx/geometry/dolfinx_geometry.h similarity index 100% rename from cpp/dolfinx/geometry/dolfin_geometry.h rename to cpp/dolfinx/geometry/dolfinx_geometry.h diff --git a/cpp/dolfinx/graph/CMakeLists.txt b/cpp/dolfinx/graph/CMakeLists.txt index 6b670070603..4106f8ce381 100644 --- a/cpp/dolfinx/graph/CMakeLists.txt +++ b/cpp/dolfinx/graph/CMakeLists.txt @@ -1,15 +1,15 @@ set(HEADERS_graph - ${CMAKE_CURRENT_SOURCE_DIR}/AdjacencyList.h - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_graph.h - ${CMAKE_CURRENT_SOURCE_DIR}/ordering.h - ${CMAKE_CURRENT_SOURCE_DIR}/partitioners.h - ${CMAKE_CURRENT_SOURCE_DIR}/partition.h - PARENT_SCOPE + ${CMAKE_CURRENT_SOURCE_DIR}/AdjacencyList.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_graph.h + ${CMAKE_CURRENT_SOURCE_DIR}/ordering.h + ${CMAKE_CURRENT_SOURCE_DIR}/partitioners.h + ${CMAKE_CURRENT_SOURCE_DIR}/partition.h + PARENT_SCOPE ) target_sources( dolfinx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ordering.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/partitioners.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/partition.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/partitioners.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/partition.cpp ) diff --git a/cpp/dolfinx/graph/dolfin_graph.h b/cpp/dolfinx/graph/dolfinx_graph.h similarity index 100% rename from cpp/dolfinx/graph/dolfin_graph.h rename to cpp/dolfinx/graph/dolfinx_graph.h diff --git a/cpp/dolfinx/io/CMakeLists.txt b/cpp/dolfinx/io/CMakeLists.txt index 270c2d61378..b7f8d014348 100644 --- a/cpp/dolfinx/io/CMakeLists.txt +++ b/cpp/dolfinx/io/CMakeLists.txt @@ -1,28 +1,28 @@ set(HEADERS_io - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_io.h - ${CMAKE_CURRENT_SOURCE_DIR}/ADIOS2Writers.h - ${CMAKE_CURRENT_SOURCE_DIR}/cells.h - ${CMAKE_CURRENT_SOURCE_DIR}/HDF5Interface.h - ${CMAKE_CURRENT_SOURCE_DIR}/vtk_utils.h - ${CMAKE_CURRENT_SOURCE_DIR}/VTKFile.h - ${CMAKE_CURRENT_SOURCE_DIR}/XDMFFile.h - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_function.h - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_mesh.h - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_meshtags.h - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_read.h - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_utils.h - PARENT_SCOPE + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_io.h + ${CMAKE_CURRENT_SOURCE_DIR}/ADIOS2Writers.h + ${CMAKE_CURRENT_SOURCE_DIR}/cells.h + ${CMAKE_CURRENT_SOURCE_DIR}/HDF5Interface.h + ${CMAKE_CURRENT_SOURCE_DIR}/vtk_utils.h + ${CMAKE_CURRENT_SOURCE_DIR}/VTKFile.h + ${CMAKE_CURRENT_SOURCE_DIR}/XDMFFile.h + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_function.h + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_mesh.h + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_meshtags.h + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_read.h + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_utils.h + PARENT_SCOPE ) target_sources( dolfinx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ADIOS2Writers.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/cells.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/HDF5Interface.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/VTKFile.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/vtk_utils.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/XDMFFile.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_function.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_mesh.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/cells.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/HDF5Interface.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/VTKFile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/vtk_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/XDMFFile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_function.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_mesh.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/xdmf_utils.cpp ) diff --git a/cpp/dolfinx/io/dolfin_io.h b/cpp/dolfinx/io/dolfinx_io.h similarity index 100% rename from cpp/dolfinx/io/dolfin_io.h rename to cpp/dolfinx/io/dolfinx_io.h diff --git a/cpp/dolfinx/la/CMakeLists.txt b/cpp/dolfinx/la/CMakeLists.txt index 59ed9bf551b..f02e20aca43 100644 --- a/cpp/dolfinx/la/CMakeLists.txt +++ b/cpp/dolfinx/la/CMakeLists.txt @@ -1,5 +1,5 @@ set(HEADERS_la - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_la.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_la.h ${CMAKE_CURRENT_SOURCE_DIR}/MatrixCSR.h ${CMAKE_CURRENT_SOURCE_DIR}/SparsityPattern.h ${CMAKE_CURRENT_SOURCE_DIR}/Vector.h diff --git a/cpp/dolfinx/la/dolfin_la.h b/cpp/dolfinx/la/dolfinx_la.h similarity index 100% rename from cpp/dolfinx/la/dolfin_la.h rename to cpp/dolfinx/la/dolfinx_la.h diff --git a/cpp/dolfinx/la/petsc.h b/cpp/dolfinx/la/petsc.h index 19f525390b1..7d8dd78f389 100644 --- a/cpp/dolfinx/la/petsc.h +++ b/cpp/dolfinx/la/petsc.h @@ -28,6 +28,7 @@ namespace dolfinx::la { class SparsityPattern; +/// @brief PETSc linear algebra functions namespace petsc { /// Print error message for PETSc calls that return an error diff --git a/cpp/dolfinx/mesh/CMakeLists.txt b/cpp/dolfinx/mesh/CMakeLists.txt index f838f7e7437..f4132f63259 100644 --- a/cpp/dolfinx/mesh/CMakeLists.txt +++ b/cpp/dolfinx/mesh/CMakeLists.txt @@ -1,5 +1,5 @@ set(HEADERS_mesh - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_mesh.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_mesh.h ${CMAKE_CURRENT_SOURCE_DIR}/Mesh.h ${CMAKE_CURRENT_SOURCE_DIR}/Geometry.h ${CMAKE_CURRENT_SOURCE_DIR}/Topology.h diff --git a/cpp/dolfinx/mesh/dolfin_mesh.h b/cpp/dolfinx/mesh/dolfinx_mesh.h similarity index 100% rename from cpp/dolfinx/mesh/dolfin_mesh.h rename to cpp/dolfinx/mesh/dolfinx_mesh.h diff --git a/cpp/dolfinx/nls/CMakeLists.txt b/cpp/dolfinx/nls/CMakeLists.txt index 640701d4bde..d13a9c7c80d 100644 --- a/cpp/dolfinx/nls/CMakeLists.txt +++ b/cpp/dolfinx/nls/CMakeLists.txt @@ -1,5 +1,5 @@ set(HEADERS_nls - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_nls.h + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_nls.h ${CMAKE_CURRENT_SOURCE_DIR}/NewtonSolver.h PARENT_SCOPE ) diff --git a/cpp/dolfinx/nls/dolfin_nls.h b/cpp/dolfinx/nls/dolfinx_nls.h similarity index 100% rename from cpp/dolfinx/nls/dolfin_nls.h rename to cpp/dolfinx/nls/dolfinx_nls.h diff --git a/cpp/dolfinx/refinement/CMakeLists.txt b/cpp/dolfinx/refinement/CMakeLists.txt index eb59fdb1071..0917a22ca38 100644 --- a/cpp/dolfinx/refinement/CMakeLists.txt +++ b/cpp/dolfinx/refinement/CMakeLists.txt @@ -1,13 +1,14 @@ set(HEADERS_refinement - ${CMAKE_CURRENT_SOURCE_DIR}/dolfin_refinement.h - ${CMAKE_CURRENT_SOURCE_DIR}/plaza.h ${CMAKE_CURRENT_SOURCE_DIR}/refine.h - ${CMAKE_CURRENT_SOURCE_DIR}/utils.h - PARENT_SCOPE + ${CMAKE_CURRENT_SOURCE_DIR}/dolfinx_refinement.h + ${CMAKE_CURRENT_SOURCE_DIR}/plaza.h + ${CMAKE_CURRENT_SOURCE_DIR}/refine.h + ${CMAKE_CURRENT_SOURCE_DIR}/utils.h + PARENT_SCOPE ) target_sources( dolfinx PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/plaza.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/refine.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/refine.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp ) diff --git a/cpp/dolfinx/refinement/dolfin_refinement.h b/cpp/dolfinx/refinement/dolfinx_refinement.h similarity index 100% rename from cpp/dolfinx/refinement/dolfin_refinement.h rename to cpp/dolfinx/refinement/dolfinx_refinement.h From 1b14b14ec2bba8c38c79df6a9b9c3037fff0fa01 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 19:37:42 +0000 Subject: [PATCH 08/11] Small tidy up --- cpp/dolfinx/common/MPI.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpp/dolfinx/common/MPI.h b/cpp/dolfinx/common/MPI.h index e4e167445b7..a5cb03d56fd 100644 --- a/cpp/dolfinx/common/MPI.h +++ b/cpp/dolfinx/common/MPI.h @@ -25,7 +25,7 @@ #define MPICH_IGNORE_CXX_SEEK 1 #include -/// MPI support functionality +/// @brief MPI support functionality namespace dolfinx::MPI { @@ -36,8 +36,8 @@ enum class tag : int consensus_pex }; -/// A duplicate MPI communicator and manage lifetime of the -/// communicator +/// @brief A duplicate MPI communicator and manage lifetime of the +/// communicator. class Comm { public: From d3d7d3011b466f0224249ca35359544cbeded5d5 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 19:44:26 +0000 Subject: [PATCH 09/11] Small fixes --- cpp/dolfinx/graph/dolfinx_graph.h | 2 +- cpp/dolfinx/refinement/dolfinx_refinement.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/dolfinx/graph/dolfinx_graph.h b/cpp/dolfinx/graph/dolfinx_graph.h index 040fcb59dea..9cb6bfd5952 100644 --- a/cpp/dolfinx/graph/dolfinx_graph.h +++ b/cpp/dolfinx/graph/dolfinx_graph.h @@ -4,7 +4,7 @@ /// /// Data structures for building and representing graphs, and algorithms /// on graphs, e.g., re-ordering and partitioning. -namespace dolfinx::::graph +namespace dolfinx::graph { } diff --git a/cpp/dolfinx/refinement/dolfinx_refinement.h b/cpp/dolfinx/refinement/dolfinx_refinement.h index 0b593a3fb58..a49ece85944 100644 --- a/cpp/dolfinx/refinement/dolfinx_refinement.h +++ b/cpp/dolfinx/refinement/dolfinx_refinement.h @@ -4,7 +4,7 @@ /// /// Methods for refining meshes uniformly, or with markers, using edge /// bisection. -namespace dolfinx:: ::refinement +namespace dolfinx::refinement { } From d90447b571e28f75c8146668f66188f2436cac53 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 19:55:49 +0000 Subject: [PATCH 10/11] Another fix --- cpp/demo/interpolation_different_meshes/main.cpp | 2 +- cpp/dolfinx/common/MPI.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/demo/interpolation_different_meshes/main.cpp b/cpp/demo/interpolation_different_meshes/main.cpp index 2dad78c3763..aaf927d1b5f 100644 --- a/cpp/demo/interpolation_different_meshes/main.cpp +++ b/cpp/demo/interpolation_different_meshes/main.cpp @@ -5,7 +5,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later #include -#include +#include #include #include #include diff --git a/cpp/dolfinx/common/MPI.h b/cpp/dolfinx/common/MPI.h index a5cb03d56fd..689e3058380 100644 --- a/cpp/dolfinx/common/MPI.h +++ b/cpp/dolfinx/common/MPI.h @@ -355,7 +355,7 @@ distribute_to_postoffice(MPI_Comm comm, std::span x, // Find iterator to next global rank auto it1 - = std::find_if(it, dest_to_index.end(), + = std::find_if(it, s.end(), [r = dest.back()](auto& idx) { return idx[0] != r; }); // Store number of items for current rank From 4129ea79cd3a8a6d4de23237db20b44dc471f205 Mon Sep 17 00:00:00 2001 From: "Garth N. Wells" Date: Sat, 11 Feb 2023 20:03:17 +0000 Subject: [PATCH 11/11] Another fix --- cpp/dolfinx/common/MPI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/dolfinx/common/MPI.h b/cpp/dolfinx/common/MPI.h index 689e3058380..a5cb03d56fd 100644 --- a/cpp/dolfinx/common/MPI.h +++ b/cpp/dolfinx/common/MPI.h @@ -355,7 +355,7 @@ distribute_to_postoffice(MPI_Comm comm, std::span x, // Find iterator to next global rank auto it1 - = std::find_if(it, s.end(), + = std::find_if(it, dest_to_index.end(), [r = dest.back()](auto& idx) { return idx[0] != r; }); // Store number of items for current rank