Skip to content

Commit 236dcbd

Browse files
committed
SWE: Assign DM label 'panel' for different faces of initial cube
1 parent 01fa172 commit 236dcbd

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

examples/fluids/shallow-water/shallowwater.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int main(int argc, char **argv) {
8080
PetscScalar R_e = 6.37122e6; // Earth radius (m)
8181
PetscScalar g = 9.81; // gravitational acceleration (m/s^2)
8282
PetscScalar H0 = 0; // constant mean height (m)
83-
PetscScalar gamma = 0; // angle between axis of rotation and polar axis
83+
PetscScalar gamma = 0; // angle between axis of rotation and polar axis
8484
PetscScalar mpersquareds;
8585
// Check PETSc CUDA support
8686
PetscBool petschavecuda, setmemtyperequest = PETSC_FALSE;
@@ -209,7 +209,7 @@ int main(int argc, char **argv) {
209209
.gamma = gamma,
210210
.time = 0.
211211
};
212-
212+
213213
ProblemContext_s probl_ctx = {
214214
.g = g,
215215
.H0 = H0,
@@ -229,6 +229,16 @@ int main(int argc, char **argv) {
229229
CHKERRQ(ierr);
230230
// Set the object name
231231
ierr = PetscObjectSetName((PetscObject)dm, "Sphere"); CHKERRQ(ierr);
232+
// Define cube panels (charts)
233+
DMLabel label;
234+
PetscInt c, cStart, cEnd, npanel;
235+
ierr = DMCreateLabel(dm, "panel");
236+
ierr = DMGetLabel(dm, "panel", &label);
237+
// Assign different panel (chart) values to the six faces of the cube
238+
ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd); CHKERRQ(ierr);
239+
for (c = cStart, npanel = 0; c < cEnd; c++) {
240+
ierr = DMLabelSetValue(label, c, npanel++); CHKERRQ(ierr);
241+
}
232242
// Distribute mesh over processes
233243
{
234244
DM dmDist = NULL;
@@ -366,7 +376,7 @@ int main(int argc, char **argv) {
366376

367377
// Setup libCEED's objects
368378
ierr = PetscMalloc1(1, &ceeddata); CHKERRQ(ierr);
369-
ierr = SetupLibceed(dm, ceed, degree, qextra, ncompx, ncompq, user, ceeddata,
379+
ierr = SetupLibceed(dm, ceed, degree, qextra, ncompx, ncompq, user, ceeddata,
370380
problem, &phys_ctx, &probl_ctx); CHKERRQ(ierr);
371381

372382
// Set up PETSc context
@@ -403,7 +413,7 @@ int main(int argc, char **argv) {
403413
ierr = ICs_FixMultiplicity(ceeddata->op_ics, ceeddata->xcorners, user->q0ceed,
404414
dm, Qloc, Q, ceeddata->Erestrictq,
405415
&phys_ctx, 0.0); CHKERRQ(ierr);
406-
416+
407417
MPI_Comm_rank(comm, &rank);
408418
if (!rank) {
409419
ierr = PetscMkdir(user->outputfolder); CHKERRQ(ierr);
@@ -425,8 +435,8 @@ int main(int argc, char **argv) {
425435
ierr = DMRestoreLocalVector(dm, &Qloc); CHKERRQ(ierr);
426436

427437
// Set up the MatShell for the associated Jacobian operator
428-
ierr = MatCreateShell(PETSC_COMM_SELF, ncompq*odofs, ncompq*odofs,
429-
PETSC_DETERMINE, PETSC_DETERMINE, user, &J);
438+
ierr = MatCreateShell(PETSC_COMM_SELF, ncompq*odofs, ncompq*odofs,
439+
PETSC_DETERMINE, PETSC_DETERMINE, user, &J);
430440
CHKERRQ(ierr);
431441
// Set the MatShell operation needed for the Jacobian
432442
ierr = MatShellSetOperation(J, MATOP_MULT,

0 commit comments

Comments
 (0)