Skip to content

Commit efd09de

Browse files
committed
Start adding pressure bc
1 parent 1b52208 commit efd09de

2 files changed

Lines changed: 35 additions & 10 deletions

File tree

examples/Hdiv-mixed/main.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,34 @@ int main(int argc, char **argv) {
158158
// -- Set up libCEED objects
159159
PetscCall( SetupLibceed(dm, dm_u0, dm_p0, dm_H1, ceed, app_ctx,
160160
problem_data, ceed_data) );
161-
//CeedVectorView(force_ceed, "%12.8f", stdout);
162-
//PetscCall( DMAddBoundariesPressure(ceed, ceed_data, app_ctx, problem_data, dm,
163-
// bc_pressure) );
161+
162+
// ---------------------------------------------------------------------------
163+
// Setup pressure boundary conditions
164+
// ---------------------------------------------------------------------------
165+
// --Create empty local vector for libCEED
166+
Vec P_loc;
167+
PetscInt P_loc_size;
168+
CeedScalar *p0;
169+
CeedVector P_ceed;
170+
PetscMemType pressure_mem_type;
171+
PetscCall( DMCreateLocalVector(dm, &P_loc) );
172+
PetscCall( VecGetSize(P_loc, &P_loc_size) );
173+
PetscCall( VecZeroEntries(P_loc) );
174+
PetscCall( VecGetArrayAndMemType(P_loc, &p0, &pressure_mem_type) );
175+
CeedVectorCreate(ceed, P_loc_size, &P_ceed);
176+
CeedVectorSetArray(P_ceed, MemTypeP2C(pressure_mem_type), CEED_USE_POINTER,
177+
p0);
178+
// -- Apply operator to create local pressure vector on boundary
179+
PetscCall( DMAddBoundariesPressure(ceed, ceed_data, app_ctx, problem_data, dm,
180+
P_ceed) );
181+
CeedVectorView(P_ceed, "%12.8f", stdout);
182+
// -- Map local to global
183+
Vec P;
184+
CeedVectorTakeArray(P_ceed, MemTypeP2C(pressure_mem_type), NULL);
185+
PetscCall( VecRestoreArrayAndMemType(P_loc, &p0) );
186+
PetscCall( DMCreateGlobalVector(dm, &P) );
187+
PetscCall( VecZeroEntries(P) );
188+
PetscCall( DMLocalToGlobal(dm, P_loc, ADD_VALUES, P) );
164189

165190
// ---------------------------------------------------------------------------
166191
// Setup context for projection problem; post-processing.c

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,20 @@ PetscErrorCode SetupLibceed(DM dm, DM dm_u0, DM dm_p0, DM dm_H1,
285285
L2BasisP0(dim, Q, q_ref, q_weights, interp_p, problem_data->quadrature_mode);
286286
CeedBasisCreateH1(ceed, CEED_TOPOLOGY_QUAD, num_comp_p, 1, num_qpts, interp_p,
287287
grad, q_ref,q_weights, &ceed_data->basis_p);
288-
//HdivBasisQuad(Q, q_ref, q_weights, interp_u, div,
289-
// CEED_GAUSS_LOBATTO);
290-
//CeedBasisCreateHdiv(ceed, CEED_TOPOLOGY_QUAD, num_comp_u, P_u, num_qpts,
291-
// interp_u, div, q_ref, q_weights, &ceed_data->basis_u_face);
288+
HdivBasisQuad(Q, q_ref, q_weights, interp_u, div,
289+
CEED_GAUSS_LOBATTO);
290+
CeedBasisCreateHdiv(ceed, CEED_TOPOLOGY_QUAD, num_comp_u, P_u, num_qpts,
291+
interp_u, div, q_ref, q_weights, &ceed_data->basis_u_face);
292292
} else {
293293
HdivBasisHex(Q, q_ref, q_weights, interp_u, div, problem_data->quadrature_mode);
294294
CeedBasisCreateHdiv(ceed, CEED_TOPOLOGY_HEX, num_comp_u, P_u, num_qpts,
295295
interp_u, div, q_ref, q_weights, &ceed_data->basis_u);
296296
L2BasisP0(dim, Q, q_ref, q_weights, interp_p, problem_data->quadrature_mode);
297297
CeedBasisCreateH1(ceed, CEED_TOPOLOGY_HEX, num_comp_p, 1, num_qpts, interp_p,
298298
grad, q_ref,q_weights, &ceed_data->basis_p);
299-
//HdivBasisHex(Q, q_ref, q_weights, interp_u, div, CEED_GAUSS_LOBATTO);
300-
//CeedBasisCreateHdiv(ceed, CEED_TOPOLOGY_HEX, num_comp_u, P_u, num_qpts,
301-
// interp_u, div, q_ref, q_weights, &ceed_data->basis_u_face);
299+
HdivBasisHex(Q, q_ref, q_weights, interp_u, div, CEED_GAUSS_LOBATTO);
300+
CeedBasisCreateHdiv(ceed, CEED_TOPOLOGY_HEX, num_comp_u, P_u, num_qpts,
301+
interp_u, div, q_ref, q_weights, &ceed_data->basis_u_face);
302302
}
303303

304304
CeedBasisCreateTensorH1Lagrange(ceed, dim, num_comp_x, 2, Q,

0 commit comments

Comments
 (0)