Skip to content

Commit 338f32f

Browse files
garth-wellsjorgensdschnellerhase
authored
Fix logic and uses ranges in interpolate (#4049)
* Add failing test * Add fix that compares the underlying mesh before using copy without dof transformation * Swith order of comparsions to do pointers first. * Further clarifications in the interpolation code for matching meshes * Remove unused variable * Add test checking that copying only happens when cells0 is equal to arange(num_cells_local+num_ghosts) * Doc linting * Another doc linting fix * Clang formatting * Use size_t * Simplify * Simplifications * const fixes * Add debug check * Fix * Simplify * Fix typo * Small doc improvements * Use ranges * More ranges * More ranges * Updates * Doc fixes * Logic fix * Simplify * Small fix * Tidy up * Use new interface * Binding fix * Simplify * Improvements * Fix * More logix improvements * Update Expression logic * Simplify * Re-enable test * Simplification * Remove commented code * Iterator improvements * Tidy * Update cpp/dolfinx/fem/Function.h Co-authored-by: Paul T. Kühner <56360279+schnellerhase@users.noreply.github.com> * Add sign test * Name updates * Update cpp/dolfinx/fem/interpolate.h Co-authored-by: Paul T. Kühner <56360279+schnellerhase@users.noreply.github.com> * Tidy * Tidy * Code improvements * Remove testing * Tidy docs * Doc improvements * Small upate * Small update --------- Co-authored-by: jorgensd <dokken92@gmail.com> Co-authored-by: Jørgen S. Dokken <dokken@simula.no> Co-authored-by: Paul T. Kühner <56360279+schnellerhase@users.noreply.github.com>
1 parent 952f46a commit 338f32f

21 files changed

Lines changed: 587 additions & 465 deletions

File tree

cpp/demo/custom_kernel/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ double assemble_matrix0(std::shared_ptr<const fem::FunctionSpace<T>> V,
8383
auto sp = la::SparsityPattern(
8484
V->mesh()->comm(), {dofmap->index_map, dofmap->index_map},
8585
{dofmap->index_map_bs(), dofmap->index_map_bs()});
86-
fem::sparsitybuild::cells(sp, {cells, cells}, {*dofmap, *dofmap});
86+
fem::sparsitybuild::cells(sp, std::pair{cells, cells}, {*dofmap, *dofmap});
8787
sp.finalize();
8888
la::MatrixCSR<T> A(sp);
8989
common::Timer timer("Assembler0 std::function (matrix)");
@@ -134,7 +134,7 @@ double assemble_matrix1(const mesh::Geometry<T>& g, const fem::DofMap& dofmap,
134134
auto sp = la::SparsityPattern(dofmap.index_map->comm(),
135135
{dofmap.index_map, dofmap.index_map},
136136
{dofmap.index_map_bs(), dofmap.index_map_bs()});
137-
fem::sparsitybuild::cells(sp, {cells, cells}, {dofmap, dofmap});
137+
fem::sparsitybuild::cells(sp, std::pair{cells, cells}, {dofmap, dofmap});
138138
sp.finalize();
139139
la::MatrixCSR<T> A(sp);
140140
auto ident = [](auto, auto, auto, auto) {}; // DOF permutation not required

cpp/demo/interpolation_different_meshes/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <dolfinx/io/ADIOS2Writers.h>
1212
#include <dolfinx/mesh/generation.h>
1313
#include <memory>
14+
#include <ranges>
1415

1516
using namespace dolfinx;
1617
using T = double;
@@ -72,14 +73,13 @@ int main(int argc, char* argv[])
7273
auto cell_map
7374
= mesh_hex->topology()->index_map(mesh_hex->topology()->dim());
7475
assert(cell_map);
75-
std::vector<std::int32_t> cells(
76-
cell_map->size_local() + cell_map->num_ghosts(), 0);
77-
std::iota(cells.begin(), cells.end(), 0);
76+
auto cells = std::ranges::views::iota(0, cell_map->size_local()
77+
+ cell_map->num_ghosts());
7878
geometry::PointOwnershipData<T> interpolation_data
7979
= fem::create_interpolation_data(
8080
u_hex->function_space()->mesh()->geometry(),
8181
*u_hex->function_space()->element(),
82-
*u_tet->function_space()->mesh(), std::span(cells), 1e-8);
82+
*u_tet->function_space()->mesh(), cells, 1e-8);
8383
u_hex->interpolate(*u_tet, cells, interpolation_data);
8484

8585
#ifdef HAS_ADIOS2

cpp/dolfinx/common/types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ struct scalar_value
2828
/// @internal
2929
typedef T type;
3030
};
31+
3132
/// @private
3233
template <scalar T>
3334
struct scalar_value<T, std::void_t<typename T::value_type>>
3435
{
3536
typedef typename T::value_type type;
3637
};
38+
3739
/// @private Convenience typedef
3840
template <scalar T>
3941
using scalar_value_t = typename scalar_value<T>::type;

cpp/dolfinx/fem/ElementDofLayout.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <cassert>
1010
#include <functional>
1111
#include <numeric>
12+
#include <span>
1213
#include <stdexcept>
1314

1415
using namespace dolfinx;

cpp/dolfinx/fem/FiniteElement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class FiniteElement
8787
///
8888
/// This constructs a mixed element \f$E_0 \times E_1 \times \ldots
8989
/// \times E_{n-1}\f$. The *i*th sub-element \f$E_i\f$ can be accessed
90-
/// by ::extract_sub_element. Functions defined on mixed element
90+
/// by ::extract_sub_element. Function%s defined on mixed element
9191
/// spaces cannot be interpolated into directly. It is necessary to
9292
/// first extract a sub-Function (view), which can then be
9393
/// interpolated into.

cpp/dolfinx/fem/Form.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class Form
542542
/// @brief Coefficient function mesh integration entity indices.
543543
///
544544
/// This method is equivalent to ::domain_arg, but returns mesh entity
545-
/// indices for coefficient \link Function Functions. \endlink
545+
/// indices for coefficient Function%s.
546546
///
547547
/// @param[in] type Integral type.
548548
/// @param[in] idx Integral identifier.

0 commit comments

Comments
 (0)