From 6c10af5d44be86c880e303f5037addb2f5724932 Mon Sep 17 00:00:00 2001 From: Jeremy L Thompson Date: Thu, 26 Sep 2024 13:30:24 -0600 Subject: [PATCH] minor - style and lcov fixes --- backends/memcheck/ceed-memcheck-vector.c | 3 ++- examples/ceed/ex1-volume.c | 3 ++- examples/ceed/ex2-surface.c | 3 ++- examples/fluids/src/petsc_ops.c | 12 ++++++++---- examples/fluids/src/setuplibceed.c | 3 ++- examples/petsc/bpsraw.c | 3 ++- examples/solids/src/setup-libceed.c | 5 ----- interface/ceed-preconditioning.c | 3 ++- tests/t217-elemrestriction.c | 5 +++-- tests/t319-basis.c | 10 ++++++++-- tests/t530-operator.c | 3 ++- tests/t531-operator.c | 5 ++++- tests/t533-operator.c | 6 ++++-- tests/t592-operator.c | 3 ++- 14 files changed, 43 insertions(+), 24 deletions(-) diff --git a/backends/memcheck/ceed-memcheck-vector.c b/backends/memcheck/ceed-memcheck-vector.c index ca86978165..325fd52c34 100644 --- a/backends/memcheck/ceed-memcheck-vector.c +++ b/backends/memcheck/ceed-memcheck-vector.c @@ -259,8 +259,9 @@ static int CeedVectorRestoreArray_Memcheck(CeedVector vec) { // Check for unset entries after write-only access if (impl->is_write_only_access) { for (CeedSize i = 0; i < length; i++) { - if (isnan(impl->array_writable_copy[i])) + if (isnan(impl->array_writable_copy[i])) { CeedDebug256(ceed, CEED_DEBUG_COLOR_WARNING, "WARNING: Vec entry %" CeedSize_FMT " is NaN after restoring write-only access", i); + } } impl->is_write_only_access = false; } diff --git a/examples/ceed/ex1-volume.c b/examples/ceed/ex1-volume.c index 04852f28c1..88bd472bf1 100644 --- a/examples/ceed/ex1-volume.c +++ b/examples/ceed/ex1-volume.c @@ -318,8 +318,9 @@ int BuildCartesianRestriction(Ceed ceed, CeedInt dim, CeedInt num_xyz[dim], Ceed } CeedElemRestrictionCreate(ceed, num_elem, num_nodes, num_comp, scalar_size, num_comp * scalar_size, CEED_MEM_HOST, CEED_COPY_VALUES, elem_nodes, restriction); - if (q_data_restriction) + if (q_data_restriction) { CeedElemRestrictionCreateStrided(ceed, num_elem, elem_qpts, num_comp, num_comp * elem_qpts * num_elem, CEED_STRIDES_BACKEND, q_data_restriction); + } free(elem_nodes); return 0; } diff --git a/examples/ceed/ex2-surface.c b/examples/ceed/ex2-surface.c index 2264f26c25..77b1480227 100644 --- a/examples/ceed/ex2-surface.c +++ b/examples/ceed/ex2-surface.c @@ -336,9 +336,10 @@ int BuildCartesianRestriction(Ceed ceed, CeedInt dim, CeedInt num_xyz[3], CeedIn local_elem_nodes[l_nodes] = g_nodes; } } - if (restriction) + if (restriction) { CeedElemRestrictionCreate(ceed, num_elem, num_nodes, num_comp, scalar_size, num_comp * scalar_size, CEED_MEM_HOST, CEED_COPY_VALUES, el_nodes, restriction); + } free(el_nodes); if (q_data_restriction) { diff --git a/examples/fluids/src/petsc_ops.c b/examples/fluids/src/petsc_ops.c index 398796f33b..f40e156af2 100644 --- a/examples/fluids/src/petsc_ops.c +++ b/examples/fluids/src/petsc_ops.c @@ -71,33 +71,37 @@ PetscErrorCode OperatorApplyContextCreate(DM dm_x, DM dm_y, Ceed ceed, CeedOpera PetscCall(VecGetLocalSize(X_loc, &X_size)); PetscCheck(X_size == x_size, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "X_loc (%" PetscInt_FMT ") not correct size for CeedOperator active input size (%" CeedSize_FMT ")", X_size, x_size); - if (dm_x) + if (dm_x) { PetscCheck(X_size == dm_X_size, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "X_loc size (%" PetscInt_FMT ") does not match dm_x local vector size (%" PetscInt_FMT ")", X_size, dm_X_size); + } } if (Y_loc) { PetscCall(VecGetLocalSize(Y_loc, &Y_size)); PetscCheck(Y_size == y_size, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "Y_loc (%" PetscInt_FMT ") not correct size for CeedOperator active output size (%" CeedSize_FMT ")", Y_size, y_size); - if (dm_y) + if (dm_y) { PetscCheck(Y_size == dm_Y_size, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "Y_loc size (%" PetscInt_FMT ") does not match dm_y local vector size (%" PetscInt_FMT ")", Y_size, dm_Y_size); + } } if (x_ceed && x_ceed != CEED_VECTOR_NONE) { PetscCallCeed(ceed, CeedVectorGetLength(x_ceed, &x_ceed_size)); PetscCheck(x_size >= 0 ? x_ceed_size == x_size : true, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "x_ceed (%" CeedSize_FMT ") not correct size for CeedOperator active input size (%" CeedSize_FMT ")", x_ceed_size, x_size); - if (dm_x) + if (dm_x) { PetscCheck(x_ceed_size == dm_X_size, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "x_ceed size (%" CeedSize_FMT ") does not match dm_x local vector size (%" PetscInt_FMT ")", x_ceed_size, dm_X_size); + } } if (y_ceed && y_ceed != CEED_VECTOR_NONE) { PetscCallCeed(ceed, CeedVectorGetLength(y_ceed, &y_ceed_size)); PetscCheck(y_ceed_size == y_size, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "y_ceed (%" CeedSize_FMT ") not correct size for CeedOperator active input size (%" CeedSize_FMT ")", y_ceed_size, y_size); - if (dm_y) + if (dm_y) { PetscCheck(y_ceed_size == dm_Y_size, PETSC_COMM_WORLD, PETSC_ERR_ARG_SIZ, "y_ceed size (%" CeedSize_FMT ") does not match dm_y local vector size (%" PetscInt_FMT ")", y_ceed_size, dm_Y_size); + } } } diff --git a/examples/fluids/src/setuplibceed.c b/examples/fluids/src/setuplibceed.c index 29b2d8f825..a5bdfe1bb1 100644 --- a/examples/fluids/src/setuplibceed.c +++ b/examples/fluids/src/setuplibceed.c @@ -117,8 +117,9 @@ static PetscErrorCode AddBCSubOperator(Ceed ceed, DM dm, CeedData ceed_data, DML PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface qdata", elem_restr_qd_i_sur, CEED_BASIS_NONE, q_data_sur)); PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "x", elem_restr_x_sur, basis_x_sur, ceed_data->x_coord)); PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "v", elem_restr_q_sur, basis_q_sur, CEED_VECTOR_ACTIVE)); - if (elem_restr_jd_i_sur) + if (elem_restr_jd_i_sur) { PetscCallCeed(ceed, CeedOperatorSetField(op_apply_bc, "surface jacobian data", elem_restr_jd_i_sur, CEED_BASIS_NONE, jac_data_sur)); + } if (qf_apply_bc_jacobian && elem_restr_jd_i_sur) { PetscCallCeed(ceed, CeedOperatorCreate(ceed, qf_apply_bc_jacobian, NULL, NULL, &op_apply_bc_jacobian)); diff --git a/examples/petsc/bpsraw.c b/examples/petsc/bpsraw.c index e43e6567c3..8a6e21bc93 100644 --- a/examples/petsc/bpsraw.c +++ b/examples/petsc/bpsraw.c @@ -506,8 +506,9 @@ int main(int argc, char **argv) { l_to_g_ind[here] = g_start[ir][jr][kr] + (ii * g_m_nodes[ir][jr][kr][1] + jj) * g_m_nodes[ir][jr][kr][2] + kk; if ((i_rank[0] == 0 && i == 0) || (i_rank[1] == 0 && j == 0) || (i_rank[2] == 0 && k == 0) || (i_rank[0] + 1 == p[0] && i + 1 == l_nodes[0]) || (i_rank[1] + 1 == p[1] && j + 1 == l_nodes[1]) || - (i_rank[2] + 1 == p[2] && k + 1 == l_nodes[2])) + (i_rank[2] + 1 == p[2] && k + 1 == l_nodes[2])) { continue; + } l_to_g_ind_0[l_0_count] = l_to_g_ind[here]; loc_ind[l_0_count++] = here; } diff --git a/examples/solids/src/setup-libceed.c b/examples/solids/src/setup-libceed.c index 608278ec5c..717fda952f 100644 --- a/examples/solids/src/setup-libceed.c +++ b/examples/solids/src/setup-libceed.c @@ -20,11 +20,6 @@ #include "../qfunctions/manufactured-force.h" // Manufactured solution forcing #include "../qfunctions/traction-boundary.h" // Traction boundaries -#if PETSC_VERSION_LT(3, 14, 0) -#define DMPlexGetClosureIndices(a, b, c, d, e, f, g, h, i) DMPlexGetClosureIndices(a, b, c, d, f, g, i) -#define DMPlexRestoreClosureIndices(a, b, c, d, e, f, g, h, i) DMPlexRestoreClosureIndices(a, b, c, d, f, g, i) -#endif - // ----------------------------------------------------------------------------- // Problem options // ----------------------------------------------------------------------------- diff --git a/interface/ceed-preconditioning.c b/interface/ceed-preconditioning.c index afc2089463..325c5c0017 100644 --- a/interface/ceed-preconditioning.c +++ b/interface/ceed-preconditioning.c @@ -2848,8 +2848,9 @@ int CeedOperatorCreateFDMElementInverse(CeedOperator op, CeedOperator *fdm_inv, CeedCall(CeedVectorGetArrayWrite(q_data, CEED_MEM_HOST, &q_data_array)); for (CeedInt e = 0; e < num_elem; e++) { for (CeedInt c = 0; c < num_comp; c++) { - for (CeedInt n = 0; n < num_nodes; n++) + for (CeedInt n = 0; n < num_nodes; n++) { q_data_array[(e * num_comp + c) * num_nodes + n] = 1. / (elem_avg[e] * fdm_diagonal[c * num_nodes + n]); + } } } CeedCall(CeedFree(&elem_avg)); diff --git a/tests/t217-elemrestriction.c b/tests/t217-elemrestriction.c index ca4f62a048..b9c52c52eb 100644 --- a/tests/t217-elemrestriction.c +++ b/tests/t217-elemrestriction.c @@ -55,10 +55,11 @@ int main(int argc, char **argv) { CeedVectorGetArrayRead(x, CEED_MEM_HOST, &x_array); for (CeedInt i = 0; i < num_elem + 1; i++) { - if (x_array[i] != (10 + i) * (i > 0 && i < num_elem ? 2.0 : 1.0)) + if (x_array[i] != (10 + i) * (i > 0 && i < num_elem ? 2.0 : 1.0)) { // LCOV_EXCL_START printf("Error in restricted array x[%" CeedInt_FMT "] = %f\n", i, (CeedScalar)x_array[i]); - // LCOV_EXCL_STOP + // LCOV_EXCL_STOP + } } CeedVectorRestoreArrayRead(x, &x_array); } diff --git a/tests/t319-basis.c b/tests/t319-basis.c index 18afff0a9e..f63299867a 100644 --- a/tests/t319-basis.c +++ b/tests/t319-basis.c @@ -224,13 +224,19 @@ int main(int argc, char **argv) { CeedScalar tol = 100 * CEED_EPSILON; for (CeedInt i = 0; i < 4 * 8; i++) { - if (fabs(interp_proj[i] - ((CeedScalar *)interp_proj_ref)[i]) > tol) + if (fabs(interp_proj[i] - ((CeedScalar *)interp_proj_ref)[i]) > tol) { + // LCOV_EXCL_START printf("Mixed Topology Projection: interp[%" CeedInt_FMT "] expected %f, got %f\n", i, interp_proj[i], ((CeedScalar *)interp_proj_ref)[i]); + // LCOV_EXCL_STOP + } } for (CeedInt i = 0; i < 3 * 4 * 8; i++) { - if (fabs(grad_proj[i] - ((CeedScalar *)grad_proj_ref)[i]) > tol) + if (fabs(grad_proj[i] - ((CeedScalar *)grad_proj_ref)[i]) > tol) { + // LCOV_EXCL_START printf("Mixed Topology Projection: grad[%" CeedInt_FMT "] expected %f, got %f\n", i, grad_proj[i], ((CeedScalar *)grad_proj_ref)[i]); + // LCOV_EXCL_STOP + } } CeedBasisDestroy(&basis_face); diff --git a/tests/t530-operator.c b/tests/t530-operator.c index d9d18083b0..60716e4544 100644 --- a/tests/t530-operator.c +++ b/tests/t530-operator.c @@ -94,12 +94,13 @@ int main(int argc, char **argv) { CeedVectorGetArrayRead(qf_assembled, CEED_MEM_HOST, &assembled_array); CeedVectorGetArrayRead(q_data, CEED_MEM_HOST, &q_data_array); - for (CeedInt i = 0; i < num_qpts; i++) + for (CeedInt i = 0; i < num_qpts; i++) { if (fabs(q_data_array[i] - assembled_array[i]) > 1e-9) { // LCOV_EXCL_START printf("Error: qf_assembled[%" CeedInt_FMT "] = %f != %f\n", i, assembled_array[i], q_data_array[i]); // LCOV_EXCL_STOP } + } CeedVectorRestoreArrayRead(qf_assembled, &assembled_array); CeedVectorRestoreArrayRead(q_data, &q_data_array); } diff --git a/tests/t531-operator.c b/tests/t531-operator.c index 39168ecba6..767f6a769e 100644 --- a/tests/t531-operator.c +++ b/tests/t531-operator.c @@ -131,8 +131,11 @@ int main(int argc, char **argv) { CeedVectorGetArrayRead(v, CEED_MEM_HOST, &v_array); CeedVectorGetArrayRead(v_assembled, CEED_MEM_HOST, &v_assembled_array); for (CeedInt i = 0; i < num_dofs; i++) { - if (fabs(v_array[i] - v_assembled_array[i]) > 100. * CEED_EPSILON) + if (fabs(v_array[i] - v_assembled_array[i]) > 100. * CEED_EPSILON) { + // LCOV_EXCL_START printf("Error: Linearized operator computed v[i] = %f != %f\n", v_assembled_array[i], v_array[i]); + // LCOV_EXCL_STOP + } } CeedVectorRestoreArrayRead(v, &v_array); CeedVectorRestoreArrayRead(v_assembled, &v_assembled_array); diff --git a/tests/t533-operator.c b/tests/t533-operator.c index 2a19143ffa..4ac1c523de 100644 --- a/tests/t533-operator.c +++ b/tests/t533-operator.c @@ -28,11 +28,12 @@ int main(int argc, char **argv) { { CeedScalar x_array[dim * num_dofs]; - for (CeedInt i = 0; i < nx * 2 + 1; i++) + for (CeedInt i = 0; i < nx * 2 + 1; i++) { for (CeedInt j = 0; j < ny * 2 + 1; j++) { x_array[i + j * (nx * 2 + 1) + 0 * num_dofs] = (CeedScalar)i / (2 * nx); x_array[i + j * (nx * 2 + 1) + 1 * num_dofs] = (CeedScalar)j / (2 * ny); } + } CeedVectorSetArray(x, CEED_MEM_HOST, CEED_COPY_VALUES, x_array); } CeedVectorCreate(ceed, num_dofs, &u); @@ -45,8 +46,9 @@ int main(int argc, char **argv) { col = i % nx; row = i / nx; offset = col * (p - 1) + row * (nx * 2 + 1) * (p - 1); - for (CeedInt j = 0; j < p; j++) + for (CeedInt j = 0; j < p; j++) { for (CeedInt k = 0; k < p; k++) ind_x[p * (p * i + k) + j] = offset + k * (nx * 2 + 1) + j; + } } CeedElemRestrictionCreate(ceed, num_elem, p * p, dim, num_dofs, dim * num_dofs, CEED_MEM_HOST, CEED_USE_POINTER, ind_x, &elem_restriction_x); CeedElemRestrictionCreate(ceed, num_elem, p * p, 1, 1, num_dofs, CEED_MEM_HOST, CEED_USE_POINTER, ind_x, &elem_restriction_u); diff --git a/tests/t592-operator.c b/tests/t592-operator.c index 91e519f3bb..1650e0fa89 100644 --- a/tests/t592-operator.c +++ b/tests/t592-operator.c @@ -173,12 +173,13 @@ int main(int argc, char **argv) { CeedVectorGetArrayRead(qf_assembled, CEED_MEM_HOST, &assembled_array); CeedVectorGetArrayRead(q_data, CEED_MEM_HOST, &q_data_array); - for (CeedInt i = 0; i < num_points; i++) + for (CeedInt i = 0; i < num_points; i++) { if (fabs(q_data_array[i] - assembled_array[i]) > 1e-9) { // LCOV_EXCL_START printf("Error: qf_assembled[%" CeedInt_FMT "] = %f != %f\n", i, assembled_array[i], q_data_array[i]); // LCOV_EXCL_STOP } + } CeedVectorRestoreArrayRead(qf_assembled, &assembled_array); CeedVectorRestoreArrayRead(q_data, &q_data_array); }