Skip to content

Commit

Permalink
Rename scalar_value_type_t -> scalar_value_t
Browse files Browse the repository at this point in the history
  • Loading branch information
schnellerhase committed Feb 20, 2025
1 parent 3000e1c commit e1300cf
Show file tree
Hide file tree
Showing 25 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion cpp/demo/biharmonic/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@

using namespace dolfinx;
using T = PetscScalar;
using U = typename dolfinx::scalar_value_type_t<T>;
using U = typename dolfinx::scalar_value_t<T>;

// Inside the `main` function, we begin by defining a mesh of the
// domain. As the unit square is a very standard domain, we can use a
Expand Down
2 changes: 1 addition & 1 deletion cpp/demo/codim_0_assembly/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

using namespace dolfinx;
using T = PetscScalar;
using U = typename dolfinx::scalar_value_type_t<T>;
using U = typename dolfinx::scalar_value_t<T>;

int main(int argc, char* argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion cpp/demo/hyperelasticity/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

using namespace dolfinx;
using T = PetscScalar;
using U = typename dolfinx::scalar_value_type_t<T>;
using U = typename dolfinx::scalar_value_t<T>;

/// Hyperelastic problem class
class HyperElasticProblem
Expand Down
2 changes: 1 addition & 1 deletion cpp/demo/mixed_poisson/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

using namespace dolfinx;
using T = PetscScalar;
using U = typename dolfinx::scalar_value_type_t<T>;
using U = typename dolfinx::scalar_value_t<T>;

int main(int argc, char* argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion cpp/demo/poisson/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

using namespace dolfinx;
using T = PetscScalar;
using U = typename dolfinx::scalar_value_type_t<T>;
using U = typename dolfinx::scalar_value_t<T>;

// Then follows the definition of the coefficient functions (for $f$ and
// $g$), which are derived from the {cpp:class}`Expression` class in
Expand Down
2 changes: 1 addition & 1 deletion cpp/demo/poisson_matrix_free/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void solver(MPI_Comm comm)
int main(int argc, char* argv[])
{
using T = PetscScalar;
using U = typename dolfinx::scalar_value_type_t<T>;
using U = typename dolfinx::scalar_value_t<T>;
init_logging(argc, argv);
MPI_Init(&argc, &argv);
solver<T, U>(MPI_COMM_WORLD);
Expand Down
2 changes: 1 addition & 1 deletion cpp/dolfinx/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ struct scalar_value<T, std::void_t<typename T::value_type>>
};
/// @private Convenience typedef
template <scalar T>
using scalar_value_type_t = typename scalar_value<T>::type;
using scalar_value_t = typename scalar_value<T>::type;
} // namespace dolfinx
2 changes: 1 addition & 1 deletion cpp/dolfinx/fem/DirichletBC.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ std::array<std::vector<std::int32_t>, 2> locate_dofs_geometrical(
/// space (trial space) and degrees of freedom to which the boundary
/// condition applies.
template <dolfinx::scalar T,
std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::floating_point U = dolfinx::scalar_value_t<T>>
class DirichletBC
{
private:
Expand Down
2 changes: 1 addition & 1 deletion cpp/dolfinx/fem/Expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace dolfinx::fem
/// @tparam T The scalar type
/// @tparam U The mesh geometry scalar type
template <dolfinx::scalar T,
std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::floating_point U = dolfinx::scalar_value_t<T>>
class Expression
{
public:
Expand Down
4 changes: 2 additions & 2 deletions cpp/dolfinx/fem/Form.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum class IntegralType : std::int8_t

/// @brief Represents integral data, containing the integral ID, the
/// kernel, and a list of entities to integrate over.
template <dolfinx::scalar T, std::floating_point U = scalar_value_type_t<T>>
template <dolfinx::scalar T, std::floating_point U = scalar_value_t<T>>
struct integral_data
{
/// @brief Create a structure to hold integral data.
Expand Down Expand Up @@ -134,7 +134,7 @@ struct integral_data
/// @tparam U Float (real) type used for the finite element and geometry.
/// @tparam Kern Element kernel.
template <dolfinx::scalar T,
std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::floating_point U = dolfinx::scalar_value_t<T>>
class Form
{
public:
Expand Down
2 changes: 1 addition & 1 deletion cpp/dolfinx/fem/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Expression;
/// @tparam T The function scalar type.
/// @tparam U The mesh geometry scalar type.
template <dolfinx::scalar T,
std::floating_point U = dolfinx::scalar_value_type_t<T>>
std::floating_point U = dolfinx::scalar_value_t<T>>
class Function
{
public:
Expand Down
14 changes: 7 additions & 7 deletions cpp/dolfinx/fem/assemble_matrix_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ using mdspan2_t = MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
template <dolfinx::scalar T>
void assemble_cells(
la::MatSet<T> auto mat_set, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x,
std::span<const scalar_value_t<T>> x,
std::span<const std::int32_t> cells,
std::tuple<mdspan2_t, int, std::span<const std::int32_t>> dofmap0,
fem::DofTransformKernel<T> auto P0,
Expand All @@ -84,7 +84,7 @@ void assemble_cells(
const int ndim1 = bs1 * num_dofs1;
std::vector<T> Ae(ndim0 * ndim1);
std::span<T> _Ae(Ae);
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));

// Iterate over active cells
assert(cells0.size() == cells.size());
Expand Down Expand Up @@ -194,7 +194,7 @@ void assemble_cells(
template <dolfinx::scalar T>
void assemble_exterior_facets(
la::MatSet<T> auto mat_set, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, int num_facets_per_cell,
std::span<const scalar_value_t<T>> x, int num_facets_per_cell,
std::span<const std::int32_t> facets,
std::tuple<mdspan2_t, int, std::span<const std::int32_t>> dofmap0,
fem::DofTransformKernel<T> auto P0,
Expand All @@ -213,7 +213,7 @@ void assemble_exterior_facets(
const auto [dmap1, bs1, facets1] = dofmap1;

// Data structures used in assembly
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
const int num_dofs0 = dmap0.extent(1);
const int num_dofs1 = dmap1.extent(1);
const int ndim0 = bs0 * num_dofs0;
Expand Down Expand Up @@ -333,7 +333,7 @@ void assemble_exterior_facets(
template <dolfinx::scalar T>
void assemble_interior_facets(
la::MatSet<T> auto mat_set, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, int num_facets_per_cell,
std::span<const scalar_value_t<T>> x, int num_facets_per_cell,
std::span<const std::int32_t> facets,
std::tuple<const DofMap&, int, std::span<const std::int32_t>> dofmap0,
fem::DofTransformKernel<T> auto P0,
Expand All @@ -352,7 +352,7 @@ void assemble_interior_facets(
const auto [dmap1, bs1, facets1] = dofmap1;

// Data structures used in assembly
using X = scalar_value_type_t<T>;
using X = scalar_value_t<T>;
std::vector<X> coordinate_dofs(2 * x_dofmap.extent(1) * 3);
std::span<X> cdofs0(coordinate_dofs.data(), x_dofmap.extent(1) * 3);
std::span<X> cdofs1(coordinate_dofs.data() + x_dofmap.extent(1) * 3,
Expand Down Expand Up @@ -493,7 +493,7 @@ void assemble_interior_facets(
template <dolfinx::scalar T, std::floating_point U>
void assemble_matrix(
la::MatSet<T> auto mat_set, const Form<T, U>& a,
std::span<const scalar_value_type_t<T>> x, std::span<const T> constants,
std::span<const scalar_value_t<T>> x, std::span<const T> constants,
const std::map<std::pair<IntegralType, int>,
std::pair<std::span<const T>, int>>& coefficients,
std::span<const std::int8_t> bc0, std::span<const std::int8_t> bc1)
Expand Down
14 changes: 7 additions & 7 deletions cpp/dolfinx/fem/assemble_scalar_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace dolfinx::fem::impl
{
/// Assemble functional over cells
template <dolfinx::scalar T>
T assemble_cells(mdspan2_t x_dofmap, std::span<const scalar_value_type_t<T>> x,
T assemble_cells(mdspan2_t x_dofmap, std::span<const scalar_value_t<T>> x,
std::span<const std::int32_t> cells, FEkernel<T> auto fn,
std::span<const T> constants, std::span<const T> coeffs,
int cstride)
Expand All @@ -32,7 +32,7 @@ T assemble_cells(mdspan2_t x_dofmap, std::span<const scalar_value_type_t<T>> x,
return value;

// Create data structures used in assembly
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));

// Iterate over all cells
for (std::size_t index = 0; index < cells.size(); ++index)
Expand All @@ -59,7 +59,7 @@ T assemble_cells(mdspan2_t x_dofmap, std::span<const scalar_value_type_t<T>> x,
/// Execute kernel over exterior facets and accumulate result
template <dolfinx::scalar T>
T assemble_exterior_facets(mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x,
std::span<const scalar_value_t<T>> x,
int num_facets_per_cell,
std::span<const std::int32_t> facets,
FEkernel<T> auto fn, std::span<const T> constants,
Expand All @@ -71,7 +71,7 @@ T assemble_exterior_facets(mdspan2_t x_dofmap,
return value;

// Create data structures used in assembly
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));

// Iterate over all facets
assert(facets.size() % 2 == 0);
Expand Down Expand Up @@ -103,7 +103,7 @@ T assemble_exterior_facets(mdspan2_t x_dofmap,
/// Assemble functional over interior facets
template <dolfinx::scalar T>
T assemble_interior_facets(mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x,
std::span<const scalar_value_t<T>> x,
int num_facets_per_cell,
std::span<const std::int32_t> facets,
FEkernel<T> auto fn, std::span<const T> constants,
Expand All @@ -116,7 +116,7 @@ T assemble_interior_facets(mdspan2_t x_dofmap,
return value;

// Create data structures used in assembly
using X = scalar_value_type_t<T>;
using X = scalar_value_t<T>;
std::vector<X> coordinate_dofs(2 * x_dofmap.extent(1) * 3);
std::span<X> cdofs0(coordinate_dofs.data(), x_dofmap.extent(1) * 3);
std::span<X> cdofs1(coordinate_dofs.data() + x_dofmap.extent(1) * 3,
Expand Down Expand Up @@ -166,7 +166,7 @@ T assemble_interior_facets(mdspan2_t x_dofmap,
template <dolfinx::scalar T, std::floating_point U>
T assemble_scalar(
const fem::Form<T, U>& M, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, std::span<const T> constants,
std::span<const scalar_value_t<T>> x, std::span<const T> constants,
const std::map<std::pair<IntegralType, int>,
std::pair<std::span<const T>, int>>& coefficients)
{
Expand Down
32 changes: 16 additions & 16 deletions cpp/dolfinx/fem/assemble_vector_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ using mdspan2_t = MDSPAN_IMPL_STANDARD_NAMESPACE::mdspan<
template <dolfinx::scalar T, int _bs0 = -1, int _bs1 = -1>
void _lift_bc_cells(
std::span<T> b, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, FEkernel<T> auto kernel,
std::span<const scalar_value_t<T>> x, FEkernel<T> auto kernel,
std::span<const std::int32_t> cells,
std::tuple<mdspan2_t, int, std::span<const std::int32_t>> dofmap0,
fem::DofTransformKernel<T> auto P0,
Expand All @@ -94,7 +94,7 @@ void _lift_bc_cells(
assert(_bs1 < 0 or _bs1 == bs1);

// Data structures used in bc application
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<T> Ae, be;
assert(cells0.size() == cells.size());
assert(cells1.size() == cells.size());
Expand Down Expand Up @@ -261,7 +261,7 @@ void _lift_bc_cells(
template <dolfinx::scalar T, int _bs = -1>
void _lift_bc_exterior_facets(
std::span<T> b, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, int num_facets_per_cell,
std::span<const scalar_value_t<T>> x, int num_facets_per_cell,
FEkernel<T> auto kernel, std::span<const std::int32_t> facets,
std::tuple<mdspan2_t, int, std::span<const std::int32_t>> dofmap0,
fem::DofTransformKernel<T> auto P0,
Expand All @@ -280,7 +280,7 @@ void _lift_bc_exterior_facets(
const auto [dmap1, bs1, facets1] = dofmap1;

// Data structures used in bc application
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<T> Ae, be;
assert(facets.size() % 2 == 0);
assert(facets0.size() == facets.size());
Expand Down Expand Up @@ -410,7 +410,7 @@ void _lift_bc_exterior_facets(
template <dolfinx::scalar T, int _bs = -1>
void _lift_bc_interior_facets(
std::span<T> b, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, int num_facets_per_cell,
std::span<const scalar_value_t<T>> x, int num_facets_per_cell,
FEkernel<T> auto kernel, std::span<const std::int32_t> facets,
std::tuple<mdspan2_t, int, std::span<const std::int32_t>> dofmap0,
fem::DofTransformKernel<T> auto P0,
Expand All @@ -429,7 +429,7 @@ void _lift_bc_interior_facets(
const auto [dmap1, bs1, facets1] = dofmap1;

// Data structures used in assembly
using X = scalar_value_type_t<T>;
using X = scalar_value_t<T>;
std::vector<X> coordinate_dofs(2 * x_dofmap.extent(1) * 3);
std::span<X> cdofs0(coordinate_dofs.data(), x_dofmap.extent(1) * 3);
std::span<X> cdofs1(coordinate_dofs.data() + x_dofmap.extent(1) * 3,
Expand Down Expand Up @@ -632,7 +632,7 @@ void _lift_bc_interior_facets(
template <dolfinx::scalar T, int _bs = -1>
void assemble_cells(
fem::DofTransformKernel<T> auto P0, std::span<T> b, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x,
std::span<const scalar_value_t<T>> x,
std::span<const std::int32_t> cells,
std::tuple<mdspan2_t, int, std::span<const std::int32_t>> dofmap,
FEkernel<T> auto kernel, std::span<const T> constants,
Expand All @@ -646,7 +646,7 @@ void assemble_cells(
assert(_bs < 0 or _bs == bs);

// Create data structures used in assembly
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<T> be(bs * dmap.extent(1));
std::span<T> _be(be);

Expand Down Expand Up @@ -718,7 +718,7 @@ void assemble_cells(
template <dolfinx::scalar T, int _bs = -1>
void assemble_exterior_facets(
fem::DofTransformKernel<T> auto P0, std::span<T> b, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, int num_facets_per_cell,
std::span<const scalar_value_t<T>> x, int num_facets_per_cell,
std::span<const std::int32_t> facets,
std::tuple<mdspan2_t, int, std::span<const std::int32_t>> dofmap,
FEkernel<T> auto fn, std::span<const T> constants,
Expand All @@ -735,7 +735,7 @@ void assemble_exterior_facets(
// FIXME: Add proper interface for num_dofs
// Create data structures used in assembly
const int num_dofs = dmap.extent(1);
std::vector<scalar_value_type_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<scalar_value_t<T>> coordinate_dofs(3 * x_dofmap.extent(1));
std::vector<T> be(bs * num_dofs);
std::span<T> _be(be);
assert(facets.size() % 2 == 0);
Expand Down Expand Up @@ -814,7 +814,7 @@ void assemble_exterior_facets(
template <dolfinx::scalar T, int _bs = -1>
void assemble_interior_facets(
fem::DofTransformKernel<T> auto P0, std::span<T> b, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x, int num_facets_per_cell,
std::span<const scalar_value_t<T>> x, int num_facets_per_cell,
std::span<const std::int32_t> facets,
std::tuple<const DofMap&, int, std::span<const std::int32_t>> dofmap,
FEkernel<T> auto fn, std::span<const T> constants,
Expand All @@ -829,7 +829,7 @@ void assemble_interior_facets(
assert(_bs < 0 or _bs == bs);

// Create data structures used in assembly
using X = scalar_value_type_t<T>;
using X = scalar_value_t<T>;
std::vector<X> coordinate_dofs(2 * x_dofmap.extent(1) * 3);
std::span<X> cdofs0(coordinate_dofs.data(), x_dofmap.extent(1) * 3);
std::span<X> cdofs1(coordinate_dofs.data() + x_dofmap.extent(1) * 3,
Expand Down Expand Up @@ -926,7 +926,7 @@ void assemble_interior_facets(
/// @param[in] alpha Scaling to apply
template <dolfinx::scalar T, std::floating_point U>
void lift_bc(std::span<T> b, const Form<T, U>& a, mdspan2_t x_dofmap,
std::span<const scalar_value_type_t<T>> x,
std::span<const scalar_value_t<T>> x,
std::span<const T> constants,
const std::map<std::pair<IntegralType, int>,
std::pair<std::span<const T>, int>>& coefficients,
Expand Down Expand Up @@ -1146,7 +1146,7 @@ void apply_lifting(
template <dolfinx::scalar T, std::floating_point U>
void assemble_vector(
std::span<T> b, const Form<T, U>& L,
std::span<const scalar_value_type_t<T>> x, std::span<const T> constants,
std::span<const scalar_value_t<T>> x, std::span<const T> constants,
const std::map<std::pair<IntegralType, int>,
std::pair<std::span<const T>, int>>& coefficients)
{
Expand Down Expand Up @@ -1301,14 +1301,14 @@ void assemble_vector(
{
std::shared_ptr<const mesh::Mesh<U>> mesh = L.mesh();
assert(mesh);
if constexpr (std::is_same_v<U, scalar_value_type_t<T>>)
if constexpr (std::is_same_v<U, scalar_value_t<T>>)
{
assemble_vector(b, L, mesh->geometry().x(), constants, coefficients);
}
else
{
auto x = mesh->geometry().x();
std::vector<scalar_value_type_t<T>> _x(x.begin(), x.end());
std::vector<scalar_value_t<T>> _x(x.begin(), x.end());
assemble_vector(b, L, _x, constants, coefficients);
}
}
Expand Down
Loading

0 comments on commit e1300cf

Please sign in to comment.