Skip to content

Commit d74fcba

Browse files
authored
Merge branch 'main' into dokken/mixed_quadrature
2 parents 5b7dcee + 213bf7c commit d74fcba

60 files changed

Lines changed: 1229 additions & 1074 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ccpp.yml

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,26 @@ jobs:
101101
pip install --no-build-isolation git+https://github.com/fenics/basix.git@${{ env.basix_ref }}
102102
pip install --no-build-isolation git+https://github.com/fenics/ffcx.git@${{ env.ffcx_ref }}
103103
104-
- name: Configure and install C++
105-
run: |
106-
cmake -Werror=dev --warn-uninitialized -G Ninja -DDOLFINX_ENABLE_PETSC=false -DCMAKE_BUILD_TYPE=Developer -B build -S cpp/
107-
cmake --build build
108-
sudo cmake --install build
109-
- name: Build C++ unit tests
110-
run: |
111-
cmake -Werror=dev --warn-uninitialized -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/test/ -S cpp/test/
112-
cmake --build build/test
113-
- name: Run C++ unit tests (serial)
114-
run: |
115-
cd build/test
116-
ctest -V --output-on-failure -R unittests
117-
- name: Run C++ unit tests (MPI)
118-
run: |
119-
cd build/test
120-
mpirun -n 3 ctest -V --output-on-failure -R unittests
104+
- name: Configure (C++)
105+
working-directory: cpp
106+
run: >
107+
cmake -B build -S .
108+
-Werror=dev
109+
--warn-uninitialized
110+
-G Ninja
111+
-DCMAKE_BUILD_TYPE=Developer
112+
-DBUILD_TESTING=true
113+
-DDOLFINX_ENABLE_PETSC=false
114+
115+
- name: Build and install (C++)
116+
working-directory: cpp/build
117+
run: |
118+
cmake --build .
119+
sudo cmake --install .
120+
121+
- name: Run tests (C++)
122+
working-directory: cpp/build
123+
run: cmake --build . --target test
121124

122125
- name: Build Python interface
123126
run: |
@@ -186,24 +189,30 @@ jobs:
186189
pip install --no-build-isolation git+https://github.com/FEniCS/basix.git@${{ env.basix_ref }}
187190
pip install --no-build-isolation git+https://github.com/FEniCS/ffcx.git@${{ env.ffcx_ref }}
188191
189-
- name: Configure, build and install C++ library
190-
run: |
191-
cmake -Werror=dev --warn-uninitialized -G Ninja -DCMAKE_BUILD_TYPE=Developer -DDOLFINX_ENABLE_ADIOS2=true -DDOLFINX_ENABLE_KAHIP=true -DDOLFINX_ENABLE_PARMETIS=false -DDOLFINX_ENABLE_PETSC=true -DDOLFINX_ENABLE_SCOTCH=true -DDOLFINX_ENABLE_SLEPC=true -B build -S cpp/
192-
cmake --build build
193-
cmake --install build
192+
- name: Configure (C++)
193+
working-directory: cpp
194+
run: >
195+
cmake -B build -S .
196+
-Werror=dev
197+
--warn-uninitialized
198+
-G Ninja
199+
-DCMAKE_BUILD_TYPE=Developer
200+
-DBUILD_TESTING=true
201+
-DDOLFINX_ENABLE_ADIOS2=true
202+
-DDOLFINX_ENABLE_KAHIP=true
203+
-DDOLFINX_ENABLE_PETSC=true
204+
-DDOLFINX_ENABLE_SCOTCH=true
205+
-DDOLFINX_ENABLE_SLEPC=true
206+
-DDOLFINX_ENABLE_PARMETIS=false
207+
208+
- name: Build and install (C++)
209+
working-directory: cpp/build
210+
run: cmake --build . --target install
211+
212+
- name: Run tests (C++)
213+
working-directory: cpp/build
214+
run: ctest -V --output-on-failure -R unittests
194215

195-
- name: Build C++ unit tests
196-
run: |
197-
cmake -Werror=dev --warn-uninitialized -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/test/ -S cpp/test/
198-
cmake --build build/test
199-
- name: Run C++ unit tests (serial)
200-
run: |
201-
cd build/test
202-
ctest -V --output-on-failure -R unittests
203-
- name: Run C++ unit tests (MPI)
204-
run: |
205-
cd build/test
206-
mpirun -n 3 ctest -V --output-on-failure -R unittests
207216
- name: Build and run C++ regression tests (serial and MPI (np=2))
208217
run: |
209218
cmake -Werror=dev --warn-uninitialized -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/demo/ -S cpp/demo/

.github/workflows/ci-spack.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,16 @@ jobs:
9494
run: |
9595
. ./spack-src/share/spack/setup-env.sh
9696
spack env activate .
97-
cmake -Werror=dev --warn-uninitialized -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build -S dolfinx-src/cpp/
98-
cmake --build build
99-
cmake --install build
97+
cmake -Werror=dev --warn-uninitialized -G Ninja -DBUILD_TESTING=true -DCMAKE_BUILD_TYPE=Developer -B build -S dolfinx-src/cpp/
98+
cmake --build build --target install
10099
101-
- name: Build C++ unit tests
100+
- name: Run tests (C++)
102101
run: |
103102
. ./spack-src/share/spack/setup-env.sh
104103
spack env activate .
105-
cmake -Werror=dev --warn-uninitialized -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/test/ -S dolfinx-src/cpp/test/
106-
cmake --build build/test
107-
- name: Run C++ unit tests (serial and MPI)
108-
run: |
109-
. ./spack-src/share/spack/setup-env.sh
110-
spack env activate .
111-
cd build/test
112-
mpiexec -np 2 ctest -V --output-on-failure -R unittests
104+
cd build
105+
ctest -V --output-on-failure -R unittests
106+
113107
- name: Build and run C++ regression tests (serial and MPI (np=2))
114108
run: |
115109
. ./spack-src/share/spack/setup-env.sh

.github/workflows/macos.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,24 @@ jobs:
7777
python -m pip install git+https://github.com/fenics/basix.git@${{ env.basix_ref }}
7878
python -m pip install git+https://github.com/fenics/ffcx.git@${{ env.ffcx_ref }}
7979
80-
- name: Build and install DOLFINx C++ library
80+
- name: Configure (C++)
81+
working-directory: cpp
82+
run: >
83+
cmake -B build -S .
84+
-Werror=dev
85+
--warn-uninitialized
86+
-G Ninja
87+
-DBUILD_TESTING=true
88+
89+
- name: Build and install (C++)
90+
working-directory: cpp/build
8191
run: |
82-
cmake -Werror=dev --warn-uninitialized -G Ninja -B build -S cpp/
83-
cmake --build build
84-
sudo cmake --install build
92+
cmake --build .
93+
sudo cmake --install .
8594
86-
- name: Build C++ unit tests
87-
run: |
88-
cmake -Werror=dev --warn-uninitialized -G Ninja -DCMAKE_BUILD_TYPE=Developer -B build/test/ -S cpp/test/
89-
cmake --build build/test
90-
91-
- name: Run C++ unit tests (serial)
92-
run: |
93-
cd build/test
94-
mpiexec -np 1 ctest -V --output-on-failure -R unittests
95-
96-
- name: Run C++ unit tests (MPI)
97-
run: |
98-
cd build/test
99-
mpiexec -np 3 ctest -V --output-on-failure -R unittests
95+
- name: Run tests (C++)
96+
working-directory: cpp/build
97+
run: ctest -V --output-on-failure -R unittests
10098

10199
- name: Build and install DOLFINx Python interface
102100
run: |

cpp/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,15 @@ endif()
479479
# Installation of DOLFINx library
480480
add_subdirectory(dolfinx)
481481

482+
# ------------------------------------------------------------------------------
483+
# Unit testing
484+
option(BUILD_TESTING "Build DOLFINx unit tests." OFF)
485+
set(DOLFINX_TEST_MPI_PROCESSES "1;3" CACHE STRING "List of process counts to run tests with.")
486+
include(CTest)
487+
if (BUILD_TESTING)
488+
add_subdirectory(test)
489+
endif()
490+
482491
# ------------------------------------------------------------------------------
483492
# Generate and install helper file dolfinx.conf
484493

cpp/demo/biharmonic/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ int main(int argc, char* argv[])
202202
// {cpp:class}`DirichletBC` takes two arguments: the value of the
203203
// boundary condition, and the part of the boundary on which the
204204
// condition applies. In our example, the value of the boundary
205-
// condition (0.0) can represented using a {cpp:class}`Function`,
205+
// condition (0) can represented using a {cpp:class}`Function`,
206206
// and the Dirichlet boundary is defined by the indices of degrees
207207
// of freedom to which the boundary condition applies. The
208208
// definition of the Dirichlet boundary condition then looks as
@@ -212,7 +212,7 @@ int main(int argc, char* argv[])
212212
auto facets = mesh::exterior_facet_indices(*mesh->topology());
213213
const auto bdofs = fem::locate_dofs_topological(
214214
*V->mesh()->topology_mutable(), *V->dofmap(), 1, facets);
215-
fem::DirichletBC<T> bc(0.0, bdofs, V);
215+
fem::DirichletBC<T> bc(0, bdofs, V);
216216

217217
// Now, we have specified the variational forms and can consider
218218
// the solution of the variational problem. First, we need to
@@ -237,11 +237,11 @@ int main(int argc, char* argv[])
237237
MatAssemblyBegin(A.mat(), MAT_FINAL_ASSEMBLY);
238238
MatAssemblyEnd(A.mat(), MAT_FINAL_ASSEMBLY);
239239

240-
b.set(0.0);
241-
fem::assemble_vector(b.mutable_array(), L);
242-
fem::apply_lifting<T, U>(b.mutable_array(), {a}, {{bc}}, {}, T(1.0));
240+
std::ranges::fill(b.array(), 0);
241+
fem::assemble_vector(b.array(), L);
242+
fem::apply_lifting(b.array(), {a}, {{bc}}, {}, T(1));
243243
b.scatter_rev(std::plus<T>());
244-
bc.set(b.mutable_array(), std::nullopt);
244+
bc.set(b.array(), std::nullopt);
245245

246246
la::petsc::KrylovSolver lu(MPI_COMM_WORLD);
247247
la::petsc::options::set("ksp_type", "preonly");
@@ -263,7 +263,7 @@ int main(int argc, char* argv[])
263263

264264
// Save solution in VTK format
265265
io::VTKFile file(MPI_COMM_WORLD, "u.pvd", "w");
266-
file.write<T>({u}, 0.0);
266+
file.write<T>({u}, 0);
267267
}
268268

269269
PetscFinalize();

cpp/demo/custom_kernel/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ double assemble_vector0(std::shared_ptr<const fem::FunctionSpace<T>> V,
111111
auto dofmap = V->dofmap();
112112
la::Vector<T> b(dofmap->index_map, 1);
113113
common::Timer timer("Assembler0 std::function (vector)");
114-
fem::assemble_vector(b.mutable_array(), L);
114+
fem::assemble_vector(b.array(), L);
115115
b.scatter_rev(std::plus<T>());
116116
return la::squared_norm(b);
117117
}
@@ -141,7 +141,7 @@ double assemble_matrix1(const mesh::Geometry<T>& g, const fem::DofMap& dofmap,
141141
common::Timer timer("Assembler1 lambda (matrix)");
142142
md::mdspan<const T, md::extents<std::size_t, md::dynamic_extent, 3>> x(
143143
g.x().data(), g.x().size() / 3, 3);
144-
fem::impl::assemble_cells<T>(
144+
fem::impl::assemble_cells_matrix<T>(
145145
A.mat_add_values(), g.dofmap(), x, cells, {dofmap.map(), 1, cells}, ident,
146146
{dofmap.map(), 1, cells}, ident, {}, {}, kernel, {}, {}, {}, {});
147147
A.scatter_rev();
@@ -167,9 +167,9 @@ double assemble_vector1(const mesh::Geometry<T>& g, const fem::DofMap& dofmap,
167167
md::mdspan<const T, md::extents<std::size_t, md::dynamic_extent, 3>> x(
168168
g.x().data(), g.x().size() / 3, 3);
169169
common::Timer timer("Assembler1 lambda (vector)");
170-
fem::impl::assemble_cells<T, 1>([](auto, auto, auto, auto) {},
171-
b.mutable_array(), g.dofmap(), x, cells,
172-
{dofmap.map(), 1, cells}, kernel, {}, {}, {});
170+
fem::impl::assemble_cells<1>([](auto, auto, auto, auto) {}, b.array(),
171+
g.dofmap(), x, cells, {dofmap.map(), 1, cells},
172+
kernel, {}, {}, {});
173173
b.scatter_rev(std::plus<T>());
174174
return la::squared_norm(b);
175175
}

cpp/demo/hyperelasticity/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ class HyperElasticProblem
8686
return [&](const Vec x, Vec)
8787
{
8888
// Assemble b and update ghosts
89-
std::span b(_b.mutable_array());
89+
std::span b(_b.array());
9090
std::ranges::fill(b, 0);
91-
fem::assemble_vector<T>(b, _l);
91+
fem::assemble_vector(b, _l);
9292
VecGhostUpdateBegin(_b_petsc, ADD_VALUES, SCATTER_REVERSE);
9393
VecGhostUpdateEnd(_b_petsc, ADD_VALUES, SCATTER_REVERSE);
9494

@@ -197,7 +197,7 @@ int main(int argc, char* argv[])
197197
constexpr U theta = std::numbers::pi / 3;
198198

199199
// New coordinates
200-
std::vector<U> fdata(3 * x.extent(1), 0.0);
200+
std::vector<U> fdata(3 * x.extent(1), 0);
201201
md::mdspan<U, md::extents<std::size_t, 3, md::dynamic_extent>> f(
202202
fdata.data(), 3, x.extent(1));
203203
for (std::size_t p = 0; p < x.extent(1); ++p)
@@ -282,12 +282,12 @@ int main(int argc, char* argv[])
282282

283283
// Save solution in VTK format
284284
io::VTKFile file_u(mesh->comm(), "u.pvd", "w");
285-
file_u.write<T>({*u}, 0.0);
285+
file_u.write<T>({*u}, 0);
286286

287287
// Save Cauchy stress in XDMF format
288288
io::XDMFFile file_sigma(mesh->comm(), "sigma.xdmf", "w");
289289
file_sigma.write_mesh(*mesh);
290-
file_sigma.write_function(sigma, 0.0);
290+
file_sigma.write_function(sigma, 0);
291291
}
292292

293293
PetscFinalize();

cpp/demo/interpolation-io/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void interpolate_scalar(std::shared_ptr<mesh::Mesh<U>> mesh,
6868
// ParaView
6969
io::VTXWriter<U> outfile(mesh->comm(), filename.replace_extension("bp"), {u},
7070
"BP4");
71-
outfile.write(0.0);
71+
outfile.write(0);
7272
outfile.close();
7373
#endif
7474
}
@@ -137,15 +137,15 @@ void interpolate_nedelec(std::shared_ptr<mesh::Mesh<U>> mesh,
137137
u->interpolate(
138138
[](auto x) -> std::pair<std::vector<T>, std::vector<std::size_t>>
139139
{
140-
std::vector<T> f(2 * x.extent(1), 0.0);
140+
std::vector<T> f(2 * x.extent(1), 0);
141141
std::copy_n(x.data_handle(), f.size(), f.begin());
142142
return {f, {2, x.extent(1)}};
143143
},
144144
cells0);
145145
u->interpolate(
146146
[](auto x) -> std::pair<std::vector<T>, std::vector<std::size_t>>
147147
{
148-
std::vector<T> f(2 * x.extent(1), 0.0);
148+
std::vector<T> f(2 * x.extent(1), 0);
149149
std::copy_n(x.data_handle(), f.size(), f.begin());
150150
std::ranges::transform(f, f.begin(), [](auto x) { return x + T(1); });
151151
return {f, {2, x.extent(1)}};
@@ -185,7 +185,7 @@ void interpolate_nedelec(std::shared_ptr<mesh::Mesh<U>> mesh,
185185
#ifdef HAS_ADIOS2
186186
io::VTXWriter<U> outfile(mesh->comm(), filename.replace_extension("bp"),
187187
{u_l}, "BP4");
188-
outfile.write(0.0);
188+
outfile.write(0);
189189
outfile.close();
190190
#endif
191191
}

cpp/demo/interpolation_different_meshes/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int main(int argc, char* argv[])
5353

5454
auto fun = [](auto x) -> std::pair<std::vector<T>, std::vector<std::size_t>>
5555
{
56-
std::vector<T> fdata(3 * x.extent(1), 0.0);
56+
std::vector<T> fdata(3 * x.extent(1), 0);
5757
using dextent = md::dextents<std::size_t, 2>;
5858
md::mdspan<double, dextent> f(fdata.data(), 3, x.extent(1));
5959
for (std::size_t i = 0; i < x.extent(1); ++i)
@@ -84,9 +84,9 @@ int main(int argc, char* argv[])
8484

8585
#ifdef HAS_ADIOS2
8686
io::VTXWriter<double> write_tet(mesh_tet->comm(), "u_tet.bp", {u_tet});
87-
write_tet.write(0.0);
87+
write_tet.write(0);
8888
io::VTXWriter<double> write_hex(mesh_hex->comm(), "u_hex.bp", {u_hex});
89-
write_hex.write(0.0);
89+
write_hex.write(0);
9090
#endif
9191
}
9292
MPI_Finalize();

cpp/demo/mixed_poisson/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,16 +327,16 @@ int main(int argc, char* argv[])
327327
MatAssemblyEnd(A.mat(), MAT_FINAL_ASSEMBLY);
328328

329329
// Assemble the linear form `L` into RHS vector
330-
b.set(0);
331-
fem::assemble_vector(b.mutable_array(), L);
330+
std::ranges::fill(b.array(), 0);
331+
fem::assemble_vector(b.array(), L);
332332

333333
// Modify unconstrained dofs on RHS to account for Dirichlet BC dofs
334334
// (constrained dofs), and perform parallel update on the vector.
335-
fem::apply_lifting<T, U>(b.mutable_array(), {a}, {{bc}}, {}, T(1));
335+
fem::apply_lifting(b.array(), {a}, {{bc}}, {}, T(1));
336336
b.scatter_rev(std::plus<T>());
337337

338338
// Set value for constrained dofs
339-
bc.set(b.mutable_array(), std::nullopt);
339+
bc.set(b.array(), std::nullopt);
340340

341341
// Create PETSc linear solver
342342
la::petsc::KrylovSolver lu(MPI_COMM_WORLD);

0 commit comments

Comments
 (0)