Skip to content

Commit b004380

Browse files
authored
Tidy up syntax (FEniCS#2793)
* Tidy up some syntax * Add dispatch for sonarcloud * Bump sonarcloud java version * Use https * Concepts update
1 parent c6f5a85 commit b004380

File tree

14 files changed

+70
-63
lines changed

14 files changed

+70
-63
lines changed

.github/workflows/sonarcloud.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
pull_request:
77
branches:
88
- main
9+
workflow_dispatch:
10+
11+
912
jobs:
1013
build:
1114
name: Build
@@ -27,11 +30,11 @@ jobs:
2730
run: |
2831
apt-get -y update
2932
apt-get install unzip
30-
- name: Set up JDK 11
33+
- name: Set up JDK 17
3134
uses: actions/setup-java@v3
3235
with:
3336
distribution: 'zulu'
34-
java-version: 11
37+
java-version: 17
3538
- name: Cache SonarCloud packages
3639
uses: actions/cache@v3
3740
with:

COPYING.LESSER

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GNU LESSER GENERAL PUBLIC LICENSE
22
Version 3, 29 June 2007
33

4-
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
4+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
55
Everyone is permitted to copy and distribute verbatim copies
66
of this license document, but changing it is not allowed.
77

@@ -10,7 +10,7 @@
1010
the terms and conditions of version 3 of the GNU General Public
1111
License, supplemented by the additional permissions listed below.
1212

13-
0. Additional Definitions.
13+
0. Additional Definitions.
1414

1515
As used herein, "this License" refers to version 3 of the GNU Lesser
1616
General Public License, and the "GNU GPL" refers to version 3 of the GNU
@@ -111,7 +111,7 @@ the following:
111111
a copy of the Library already present on the user's computer
112112
system, and (b) will operate properly with a modified version
113113
of the Library that is interface-compatible with the Linked
114-
Version.
114+
Version.
115115

116116
e) Provide Installation Information, but only if you would otherwise
117117
be required to provide such information under section 6 of the

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Lesser General Public License for more details.
192192

193193
You should have received a copy of the GNU Lesser General Public
194194
License along with DOLFINx. If not, see
195-
<http://www.gnu.org/licenses/>.
195+
<https://www.gnu.org/licenses/>.
196196

197197
## Contact
198198

cpp/dolfinx/common/IndexMap.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ IndexMap::IndexMap(MPI_Comm comm, std::int32_t local_size,
360360

361361
// Get global offset (index), using partial exclusive reduction
362362
std::int64_t offset = 0;
363-
const std::int64_t local_size_tmp = (std::int64_t)local_size;
363+
const std::int64_t local_size_tmp = local_size;
364364
MPI_Request request_scan;
365365
int ierr = MPI_Iexscan(&local_size_tmp, &offset, 1, MPI_INT64_T, MPI_SUM,
366366
comm, &request_scan);

cpp/dolfinx/fem/DirichletBC.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,12 @@ class DirichletBC
291291
/// @note The size of of `g` must be equal to the block size if `V`.
292292
/// Use the Function version if this is not the case, e.g. for some
293293
/// mixed spaces.
294-
template <typename S, std::convertible_to<std::vector<std::int32_t>> X,
294+
template <typename S, typename X,
295295
typename
296296
= std::enable_if_t<std::is_convertible_v<S, T>
297297
or std::is_convertible_v<S, std::span<const T>>>>
298+
requires std::is_convertible_v<std::remove_cvref_t<X>,
299+
std::vector<std::int32_t>>
298300
DirichletBC(const S& g, X&& dofs, std::shared_ptr<const FunctionSpace<U>> V)
299301
: DirichletBC(std::make_shared<Constant<T>>(g), dofs, V)
300302
{
@@ -315,7 +317,9 @@ class DirichletBC
315317
/// @note The size of of `g` must be equal to the block size if `V`.
316318
/// Use the Function version if this is not the case, e.g. for some
317319
/// mixed spaces.
318-
template <std::convertible_to<std::vector<std::int32_t>> X>
320+
template <typename X>
321+
requires std::is_convertible_v<std::remove_cvref_t<X>,
322+
std::vector<std::int32_t>>
319323
DirichletBC(std::shared_ptr<const Constant<T>> g, X&& dofs,
320324
std::shared_ptr<const FunctionSpace<U>> V)
321325
: _function_space(V), _g(g), _dofs0(std::forward<X>(dofs)),
@@ -363,7 +367,9 @@ class DirichletBC
363367
/// @note The indices in `dofs` are for *blocks*, e.g. a block index
364368
/// corresponds to 3 degrees-of-freedom if the dofmap associated with
365369
/// `g` has block size 3.
366-
template <std::convertible_to<std::vector<std::int32_t>> X>
370+
template <typename X>
371+
requires std::is_convertible_v<std::remove_cvref_t<X>,
372+
std::vector<std::int32_t>>
367373
DirichletBC(std::shared_ptr<const Function<T, U>> g, X&& dofs)
368374
: _function_space(g->function_space()), _g(g),
369375
_dofs0(std::forward<X>(dofs)),

cpp/dolfinx/io/XDMFFile.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ XDMFFile::XDMFFile(MPI_Comm comm, const std::filesystem::path& filename,
7676
pugi::xml_node xdmf_node = _xml_doc->append_child("Xdmf");
7777
assert(xdmf_node);
7878
xdmf_node.append_attribute("Version") = "3.0";
79-
xdmf_node.append_attribute("xmlns:xi") = "http://www.w3.org/2001/XInclude";
79+
xdmf_node.append_attribute("xmlns:xi") = "https://www.w3.org/2001/XInclude";
8080

8181
pugi::xml_node domain_node = xdmf_node.append_child("Domain");
8282
if (!domain_node)
@@ -108,7 +108,7 @@ XDMFFile::XDMFFile(MPI_Comm comm, const std::filesystem::path& filename,
108108
assert(xdmf_node);
109109
xdmf_node.append_attribute("Version") = "3.0";
110110
xdmf_node.append_attribute("xmlns:xi")
111-
= "http://www.w3.org/2001/XInclude";
111+
= "https://www.w3.org/2001/XInclude";
112112

113113
pugi::xml_node domain_node = xdmf_node.append_child("Domain");
114114
if (!domain_node)

cpp/dolfinx/mesh/Topology.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ determine_sharing_ranks(MPI_Comm comm, std::span<const std::int64_t> indices)
7676
auto it = dest_to_index.begin();
7777
while (it != dest_to_index.end())
7878
{
79-
// const int neigh_rank = dest.size();
80-
8179
// Store global rank and find iterator to next global rank
8280
dest.push_back((*it)[0]);
8381
auto it1
@@ -763,7 +761,7 @@ std::int32_t Topology::create_entities(int dim)
763761
return -1;
764762

765763
// Create local entities
766-
const auto [cell_entity, entity_vertex, index_map, interprocess_entities]
764+
auto [cell_entity, entity_vertex, index_map, interprocess_entities]
767765
= compute_entities(_comm.comm(), *this, dim);
768766

769767
if (cell_entity)

docker/Dockerfile.redhat

+37-37
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,33 @@ RUN dnf -y update && \
2121
dnf config-manager --set-enabled crb && \
2222
dnf install -y epel-release && \
2323
dnf -y install \
24-
bison \
25-
boost-devel \
26-
boost-filesystem \
27-
boost-timer \
28-
boost-program-options \
29-
cmake \
30-
gcc \
31-
gcc-c++ \
32-
gcc-gfortran \
33-
pugixml-devel \
34-
python3 \
35-
python3-devel \
36-
python3-pip \
37-
# Required for PETSc build
38-
diffutils \
39-
findutils \
40-
flex \
41-
# Utility
42-
git \
43-
# Only in crb set
44-
ninja-build \
45-
openblas-devel && \
24+
bison \
25+
boost-devel \
26+
boost-filesystem \
27+
boost-timer \
28+
boost-program-options \
29+
cmake \
30+
gcc \
31+
gcc-c++ \
32+
gcc-gfortran \
33+
pugixml-devel \
34+
python3 \
35+
python3-devel \
36+
python3-pip \
37+
# Required for PETSc build
38+
diffutils \
39+
findutils \
40+
flex \
41+
# Utility
42+
git \
43+
# Only in crb set
44+
ninja-build \
45+
openblas-devel && \
4646
dnf -y clean all && \
4747
rm -rf /var/cache
4848

4949
# Build MPICH (see https://github.com/pmodels/mpich/issues/5811)
50-
RUN curl -L -O http://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz && \
50+
RUN curl -L -O https://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz && \
5151
tar -xf mpich-${MPICH_VERSION}.tar.gz && \
5252
cd mpich-${MPICH_VERSION} && \
5353
FCFLAGS=-fallow-argument-mismatch FFLAGS=-fallow-argument-mismatch ./configure --with-device=ch4:ofi --enable-shared --prefix=/usr/local && \
@@ -69,24 +69,24 @@ RUN python3 -m pip install --no-binary="numpy" --no-cache-dir cffi numba mpi4py
6969
python3 -m pip install --no-cache-dir cppimport pytest pytest-xdist scipy matplotlib
7070

7171
# Build PETSc
72-
RUN curl -L -O http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-${PETSC_VERSION}.tar.gz && \
72+
RUN curl -L -O https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-${PETSC_VERSION}.tar.gz && \
7373
mkdir petsc && \
7474
tar -xf petsc-lite-${PETSC_VERSION}.tar.gz -C petsc --strip-components=1 && \
7575
cd petsc && \
7676
python3 ./configure \
77-
--with-shared-libraries \
78-
--with-fortran-bindings=no \
79-
--with-scalar-type=real \
80-
--with-64-bit-indices=yes \
81-
--with-debugging=yes \
82-
--download-ptscotch \
83-
--download-hypre \
84-
--download-metis \
85-
--download-mumps \
86-
--download-scalapack \
87-
--download-superlu_dist \
88-
--prefix=/usr/local \
89-
--with-make-np=${BUILD_NP} && \
77+
--with-shared-libraries \
78+
--with-fortran-bindings=no \
79+
--with-scalar-type=real \
80+
--with-64-bit-indices=yes \
81+
--with-debugging=yes \
82+
--download-ptscotch \
83+
--download-hypre \
84+
--download-metis \
85+
--download-mumps \
86+
--download-scalapack \
87+
--download-superlu_dist \
88+
--prefix=/usr/local \
89+
--with-make-np=${BUILD_NP} && \
9090
make all && \
9191
make install && \
9292
cd src/binding/petsc4py && \

docker/Dockerfile.test-env

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ RUN apt-get -qq update && \
132132

133133
# Install MPI
134134
RUN if [ "$MPI" = "mpich" ]; then \
135-
wget http://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz && \
135+
wget https://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz && \
136136
tar xfz mpich-${MPICH_VERSION}.tar.gz && \
137137
cd mpich-${MPICH_VERSION} && \
138138
./configure ${MPICH_CONFIGURE_OPTIONS} && \
@@ -201,7 +201,7 @@ ENV PYTHONPATH=/usr/local/lib:$PYTHONPATH
201201
ENV PETSC_DIR=/usr/local/petsc SLEPC_DIR=/usr/local/slepc
202202
RUN apt-get -qq update && \
203203
apt-get -y install bison flex && \
204-
wget -nc --quiet http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-${PETSC_VERSION}.tar.gz -O petsc-${PETSC_VERSION}.tar.gz && \
204+
wget -nc --quiet https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-lite-${PETSC_VERSION}.tar.gz -O petsc-${PETSC_VERSION}.tar.gz && \
205205
mkdir -p ${PETSC_DIR} && tar -xf petsc-${PETSC_VERSION}.tar.gz -C ${PETSC_DIR} --strip-components 1 && \
206206
cd ${PETSC_DIR} && \
207207
# Real32, 32-bit int

python/doc/source/installation.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ C++ core
3232
.. rubric:: Required
3333

3434
- C++ compiler (supporting the C++20 standard)
35-
- `Boost <http://www.boost.org>`_, with the following compiled Boost
35+
- `Boost <https://www.boost.org>`_, with the following compiled Boost
3636
components
3737

3838
- timer
3939

4040
- `CMake <https://cmake.org>`_ [build dependency]
4141
- `pkg-config <https://www.freedesktop.org/wiki/Software/pkg-config/>`_
42-
- `Basix <http://github.com/FEniCS/basix>`_
42+
- `Basix <https://github.com/FEniCS/basix>`_
4343
- `pugixml <https://pugixml.org/>`_
4444
- UFCx [``ufcx.h``, provided by FFCx]
4545
- MPI
@@ -64,9 +64,9 @@ Below are additional requirements for the Python interface.
6464
.. rubric:: Required
6565

6666
- Python
67-
- FFCx, UFL and Basix (http://github.com/FEniCS/).
67+
- FFCx, UFL and Basix (https://github.com/FEniCS/).
6868
- pybind11 (https://github.com/pybind/pybind11)
69-
- NumPy (http://www.numpy.org)
69+
- NumPy (https://www.numpy.org)
7070
- mpi4py
7171
- petsc4py
7272

python/dolfinx/io/gmshio.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
# Map from Gmsh cell type identifier (integer) to DOLFINx cell type and
29-
# degree http://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format
29+
# degree https://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format
3030
_gmsh_to_cells = {1: ("interval", 1), 2: ("triangle", 1),
3131
3: ("quadrilateral", 1), 4: ("tetrahedron", 1),
3232
5: ("hexahedron", 1), 8: ("interval", 2),
@@ -41,7 +41,7 @@
4141
def ufl_mesh(gmsh_cell: int, gdim: int) -> ufl.Mesh:
4242
"""Create a UFL mesh from a Gmsh cell identifier and geometric dimension.
4343
44-
See http://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format.
44+
See https://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format.
4545
4646
Args:
4747
gmsh_cell: Gmsh cell identifier.

python/test/unit/fem/test_dofmap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def test_entity_closure_dofs(mesh_factory):
142142
assert set(V.dofmap.entity_closure_dofs(mesh, d, all_cells)) == set(range(V.dim))
143143

144144

145-
def test_block_size(mesh):
145+
def test_block_size():
146146
meshes = [create_unit_square(MPI.COMM_WORLD, 8, 8),
147147
create_unit_cube(MPI.COMM_WORLD, 4, 4, 4),
148148
create_unit_square(MPI.COMM_WORLD, 8, 8, CellType.quadrilateral),

python/test/unit/fem/test_function.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def f(x):
176176
# (np.float32, "float"), # Fails on Redhat CI, needs further investigation
177177
(np.float64, "double")
178178
])
179-
def test_cffi_expression(types, V):
179+
def test_cffi_expression(types):
180180
vtype, xtype = types
181181
mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3, dtype=vtype)
182182
V = FunctionSpace(mesh, ('Lagrange', 1))

python/test/unit/fem/test_function_space.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_component(V, W, Q):
8989
def test_equality(V, V2, W, W2):
9090
assert V == V # /NOSONAR
9191
assert V == V2
92-
assert W == W
92+
assert W == W # /NOSONAR
9393
assert W == W2
9494

9595

0 commit comments

Comments
 (0)