Skip to content

Commit e56d551

Browse files
committed
make style
1 parent 05d7acf commit e56d551

File tree

6 files changed

+49
-43
lines changed

6 files changed

+49
-43
lines changed

examples/Hdiv-mixed/include/boundary.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ PetscErrorCode CreateBCLabel(DM dm, const char name[]);
1616
// Add Dirichlet boundaries to DM
1717
// ---------------------------------------------------------------------------
1818
PetscErrorCode DMAddBoundariesDirichlet(DM dm);
19-
PetscErrorCode BoundaryDirichletMMS(PetscInt dim, PetscReal t, const PetscReal coords[],
19+
PetscErrorCode BoundaryDirichletMMS(PetscInt dim, PetscReal t,
20+
const PetscReal coords[],
2021
PetscInt num_comp_u, PetscScalar *u, void *ctx);
2122
#endif // boundary_h

examples/Hdiv-mixed/main.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ int main(int argc, char **argv) {
7272
// ---------------------------------------------------------------------------
7373
{
7474
PetscErrorCode (*p)(ProblemData *, void *);
75-
PetscCall( PetscFunctionListFind(app_ctx->problems, app_ctx->problem_name, &p) );
75+
PetscCall( PetscFunctionListFind(app_ctx->problems, app_ctx->problem_name,
76+
&p) );
7677
if (!p) SETERRQ(PETSC_COMM_SELF, 1, "Problem '%s' not found",
7778
app_ctx->problem_name);
7879
PetscCall( (*p)(problem_data, &user) );
@@ -140,7 +141,7 @@ int main(int argc, char **argv) {
140141
// ---------------------------------------------------------------------------
141142
// -- Set up libCEED objects
142143
PetscCall( SetupLibceed(dm, ceed, app_ctx, problem_data, U_g_size,
143-
U_loc_size, ceed_data, rhs_ceed, &target) );
144+
U_loc_size, ceed_data, rhs_ceed, &target) );
144145
//CeedVectorView(rhs_ceed, "%12.8f", stdout);
145146
// ---------------------------------------------------------------------------
146147
// Gather RHS
@@ -167,9 +168,9 @@ int main(int argc, char **argv) {
167168
// Operator
168169
Mat mat;
169170
PetscCall( MatCreateShell(comm, U_l_size, U_l_size, U_g_size, U_g_size,
170-
user, &mat) );
171+
user, &mat) );
171172
PetscCall( MatShellSetOperation(mat, MATOP_MULT,
172-
(void(*)(void))MatMult_Ceed) );
173+
(void(*)(void))MatMult_Ceed) );
173174
PetscCall( MatShellSetVecType(mat, vec_type) );
174175

175176
KSP ksp;
@@ -184,7 +185,7 @@ int main(int argc, char **argv) {
184185
// ---------------------------------------------------------------------------
185186
CeedScalar l2_error_u, l2_error_p;
186187
PetscCall( ComputeError(user, U_g, target,
187-
&l2_error_u, &l2_error_p) );
188+
&l2_error_u, &l2_error_p) );
188189

189190
// ---------------------------------------------------------------------------
190191
// Output results
@@ -198,15 +199,15 @@ int main(int argc, char **argv) {
198199
PetscCall( KSPGetIterationNumber(ksp, &its) );
199200
PetscCall( KSPGetResidualNorm(ksp, &rnorm) );
200201
PetscCall( PetscPrintf(comm,
201-
" KSP:\n"
202-
" KSP Type : %s\n"
203-
" KSP Convergence : %s\n"
204-
" Total KSP Iterations : %" PetscInt_FMT "\n"
205-
" Final rnorm : %e\n"
206-
" L2 Error of u and p : %e, %e\n",
207-
ksp_type, KSPConvergedReasons[reason], its,
208-
(double)rnorm, (double)l2_error_u,
209-
(double)l2_error_p) );
202+
" KSP:\n"
203+
" KSP Type : %s\n"
204+
" KSP Convergence : %s\n"
205+
" Total KSP Iterations : %" PetscInt_FMT "\n"
206+
" Final rnorm : %e\n"
207+
" L2 Error of u and p : %e, %e\n",
208+
ksp_type, KSPConvergedReasons[reason], its,
209+
(double)rnorm, (double)l2_error_u,
210+
(double)l2_error_p) );
210211

211212
// ---------------------------------------------------------------------------
212213
// Save solution (paraview)

examples/Hdiv-mixed/src/boundary.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ PetscErrorCode DMAddBoundariesDirichlet(DM dm) {
3333
}
3434
DMLabel label;
3535
PetscCall( DMGetLabel(dm, name, &label) );
36-
PetscCall( DMAddBoundary(dm, DM_BC_ESSENTIAL, "mms", label, 1, face_ids, 0, 0, NULL,
37-
(void(*)(void))BoundaryDirichletMMS, NULL, NULL, NULL) );
38-
36+
PetscCall( DMAddBoundary(dm, DM_BC_ESSENTIAL, "mms", label, 1, face_ids, 0, 0,
37+
NULL,
38+
(void(*)(void))BoundaryDirichletMMS, NULL, NULL, NULL) );
39+
3940

4041
PetscFunctionReturn(0);
4142
}
@@ -46,7 +47,8 @@ PetscErrorCode DMAddBoundariesDirichlet(DM dm) {
4647
// ---------------------------------------------------------------------------
4748
// Boundary function for manufactured solution
4849
// ---------------------------------------------------------------------------
49-
PetscErrorCode BoundaryDirichletMMS(PetscInt dim, PetscReal t, const PetscReal coords[],
50+
PetscErrorCode BoundaryDirichletMMS(PetscInt dim, PetscReal t,
51+
const PetscReal coords[],
5052
PetscInt num_comp_u, PetscScalar *u, void *ctx) {
5153
PetscScalar x = coords[0];
5254
PetscScalar y = coords[1];
@@ -62,7 +64,7 @@ PetscErrorCode BoundaryDirichletMMS(PetscInt dim, PetscReal t, const PetscReal c
6264
u[1] = -M_PI*sin(M_PI*x) *cos(M_PI*y) *sin(M_PI*z);
6365
u[2] = -M_PI*sin(M_PI*x) *sin(M_PI*y) *cos(M_PI*z);
6466
}
65-
67+
6668

6769
PetscFunctionReturn(0);
6870
}

examples/Hdiv-mixed/src/cl-options.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ PetscErrorCode RegisterProblems_Hdiv(AppCtx app_ctx) {
2626
PetscFunctionBeginUser;
2727
// 1) darcy2d (Hdiv_DARCY2D is created in darcy2d.c)
2828
PetscCall( PetscFunctionListAdd(&app_ctx->problems, "darcy2d",
29-
Hdiv_DARCY2D) );
29+
Hdiv_DARCY2D) );
3030
// 2) darcy3d (Hdiv_DARCY3D is created in dacry3d.c)
3131
PetscCall( PetscFunctionListAdd(&app_ctx->problems, "darcy3d",
32-
Hdiv_DARCY3D) );
32+
Hdiv_DARCY3D) );
3333
// 3) darcy3d-prism
3434

3535
// 4) richard
@@ -46,24 +46,24 @@ PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx app_ctx) {
4646
PetscOptionsBegin(comm, NULL, "H(div) examples in PETSc with libCEED", NULL);
4747

4848
PetscCall( PetscOptionsFList("-problem", "Problem to solve", NULL,
49-
app_ctx->problems,
50-
app_ctx->problem_name, app_ctx->problem_name, sizeof(app_ctx->problem_name),
51-
&problem_flag) );
49+
app_ctx->problems,
50+
app_ctx->problem_name, app_ctx->problem_name, sizeof(app_ctx->problem_name),
51+
&problem_flag) );
5252

5353
app_ctx->degree = 1;
5454
PetscCall( PetscOptionsInt("-degree", "Polynomial degree of finite elements",
55-
NULL, app_ctx->degree, &app_ctx->degree, NULL) );
55+
NULL, app_ctx->degree, &app_ctx->degree, NULL) );
5656

5757
app_ctx->q_extra = 0;
5858
PetscCall( PetscOptionsInt("-q_extra", "Number of extra quadrature points",
59-
NULL, app_ctx->q_extra, &app_ctx->q_extra, NULL) );
59+
NULL, app_ctx->q_extra, &app_ctx->q_extra, NULL) );
6060

6161
// Neumann boundary conditions
6262
app_ctx->bc_traction_count = 16;
6363
PetscCall( PetscOptionsIntArray("-bc_traction",
64-
"Face IDs to apply traction (Neumann) BC",
65-
NULL, app_ctx->bc_traction_faces,
66-
&app_ctx->bc_traction_count, NULL) );
64+
"Face IDs to apply traction (Neumann) BC",
65+
NULL, app_ctx->bc_traction_faces,
66+
&app_ctx->bc_traction_count, NULL) );
6767
// Set vector for each traction BC
6868
for (PetscInt i = 0; i < app_ctx->bc_traction_count; i++) {
6969
// Traction vector
@@ -76,8 +76,8 @@ PetscErrorCode ProcessCommandLineOptions(MPI_Comm comm, AppCtx app_ctx) {
7676
PetscInt max_n = 3;
7777
PetscBool set = false;
7878
PetscCall( PetscOptionsScalarArray(option_name,
79-
"Traction vector for constrained face", NULL,
80-
app_ctx->bc_traction_vector[i], &max_n, &set) );
79+
"Traction vector for constrained face", NULL,
80+
app_ctx->bc_traction_vector[i], &max_n, &set) );
8181

8282
if (!set)
8383
SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP,

examples/Hdiv-mixed/src/matops.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PetscErrorCode ApplyLocal_Ceed(User user, Vec X, Vec Y) {
1616

1717
// Setup libCEED vectors
1818
PetscCall( VecGetArrayReadAndMemType(user->X_loc, (const PetscScalar **)&x,
19-
&x_mem_type) );
19+
&x_mem_type) );
2020
PetscCall( VecGetArrayAndMemType(user->Y_loc, &y, &y_mem_type) );
2121
CeedVectorSetArray(user->x_ceed, MemTypeP2C(x_mem_type), CEED_USE_POINTER, x);
2222
CeedVectorSetArray(user->y_ceed, MemTypeP2C(y_mem_type), CEED_USE_POINTER, y);
@@ -28,7 +28,8 @@ PetscErrorCode ApplyLocal_Ceed(User user, Vec X, Vec Y) {
2828
// Restore PETSc vectors
2929
CeedVectorTakeArray(user->x_ceed, MemTypeP2C(x_mem_type), NULL);
3030
CeedVectorTakeArray(user->y_ceed, MemTypeP2C(y_mem_type), NULL);
31-
PetscCall( VecRestoreArrayReadAndMemType(user->X_loc, (const PetscScalar **)&x) );
31+
PetscCall( VecRestoreArrayReadAndMemType(user->X_loc,
32+
(const PetscScalar **)&x) );
3233
PetscCall( VecRestoreArrayAndMemType(user->Y_loc, &y) );
3334

3435
// Local-to-global
@@ -81,7 +82,8 @@ PetscErrorCode ComputeError(User user, Vec X, CeedVector target,
8182
CEED_REQUEST_IMMEDIATE);
8283
// Restore PETSc vector
8384
CeedVectorTakeArray(user->x_ceed, MemTypeP2C(mem_type), NULL);
84-
PetscCall( VecRestoreArrayReadAndMemType(user->X_loc, (const PetscScalar **)&x) );
85+
PetscCall( VecRestoreArrayReadAndMemType(user->X_loc,
86+
(const PetscScalar **)&x) );
8587
// Compute L2 error for each field
8688
CeedInt c_start, c_end, dim, num_elem, num_qpts;
8789
PetscCall( DMGetDimension(user->dm, &dim) );

examples/Hdiv-mixed/src/setup-libceed.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ PetscErrorCode CreateRestrictionFromPlex(Ceed ceed, DM dm, CeedInt height,
5757
PetscFunctionBeginUser;
5858

5959
PetscCall( DMPlexGetLocalOffsets(dm, domain_label, value, height, 0, &num_elem,
60-
&elem_size, &num_comp, &num_dof, &elem_restr_offsets) );
60+
&elem_size, &num_comp, &num_dof, &elem_restr_offsets) );
6161

6262
CeedElemRestrictionCreate(ceed, num_elem, elem_size, num_comp,
6363
1, num_dof, CEED_MEM_HOST, CEED_COPY_VALUES,
@@ -91,15 +91,15 @@ PetscErrorCode CreateRestrictionFromPlexOriented(Ceed ceed, DM dm,
9191
PetscCall( DMPlexGetHeightStratum(dm, 0, &c_start, &c_end) );
9292
num_elem = c_end - c_start;
9393
PetscCall( PetscMalloc1(num_elem*dim*PetscPowInt(P, dim),
94-
&restr_indices_u) );
94+
&restr_indices_u) );
9595
PetscCall( PetscMalloc1(num_elem,&restr_indices_p) );
9696
bool *orient_indices_u; // to flip the dof
9797
PetscCall( PetscMalloc1(num_elem*dim*PetscPowInt(P, dim), &orient_indices_u) );
9898
for (p = 0, elem_offset = 0; p < num_elem; p++) {
9999
PetscInt num_indices, *indices, faces_per_elem, dofs_per_face;
100100
PetscCall( DMPlexGetClosureIndices(dm, section, section, p, PETSC_TRUE,
101-
&num_indices, &indices, NULL, NULL) );
102-
101+
&num_indices, &indices, NULL, NULL) );
102+
103103
restr_indices_p[p] = indices[num_indices - 1];
104104
PetscCall( DMPlexGetConeOrientation(dm, p, &ornt) );
105105
// Get number of faces per element
@@ -117,7 +117,7 @@ PetscErrorCode CreateRestrictionFromPlexOriented(Ceed ceed, DM dm,
117117
}
118118
}
119119
PetscCall( DMPlexRestoreClosureIndices(dm, section, section, p, PETSC_TRUE,
120-
&num_indices, &indices, NULL, NULL) );
120+
&num_indices, &indices, NULL, NULL) );
121121
}
122122
//if (elem_offset != num_elem*dim*PetscPowInt(P, dim))
123123
// SETERRQ(PETSC_COMM_SELF, PETSC_ERR_LIB,
@@ -206,10 +206,10 @@ PetscErrorCode SetupLibceed(DM dm, Ceed ceed, AppCtx app_ctx,
206206
PetscInt value = 0;
207207
// -- Coordinate restriction
208208
PetscCall( CreateRestrictionFromPlex(ceed, dm_coord, height, domain_label,
209-
value, &ceed_data->elem_restr_x) );
209+
value, &ceed_data->elem_restr_x) );
210210
// -- Solution restriction
211211
PetscCall( CreateRestrictionFromPlexOriented(ceed, dm, P,
212-
&ceed_data->elem_restr_u, &ceed_data->elem_restr_p) );
212+
&ceed_data->elem_restr_u, &ceed_data->elem_restr_p) );
213213
// -- Geometric ceed_data restriction
214214
PetscCall( DMPlexGetHeightStratum(dm, 0, &c_start, &c_end) );
215215
num_elem = c_end - c_start;
@@ -357,7 +357,7 @@ PetscErrorCode SetupLibceed(DM dm, Ceed ceed, AppCtx app_ctx,
357357
CeedElemRestriction elem_restr_x_face, elem_restr_qd_i_face;
358358
num_qpts_face = CeedIntPow(Q, dim - height);
359359
PetscCall( CreateRestrictionFromPlex(ceed, dm_coord, height, domain_label, 4,
360-
&elem_restr_x_face) );
360+
&elem_restr_x_face) );
361361

362362
CeedElemRestrictionGetNumElements(elem_restr_x_face, &loc_num_elem_face);
363363
CeedElemRestrictionCreateStrided(ceed, loc_num_elem_face, num_qpts_face,

0 commit comments

Comments
 (0)